]> git.sesse.net Git - kdenlive/blob - src/scopes/scopemanager.h
Merge branch 'master' into audioAlign
[kdenlive] / src / scopes / scopemanager.h
1 /***************************************************************************
2  *   Copyright (C) 2011 by Simon Andreas Eugster (simon.eu@gmail.com)      *
3  *   This file is part of kdenlive. See www.kdenlive.org.                  *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  ***************************************************************************/
10
11 #ifndef SCOPEMANAGER_H
12 #define SCOPEMANAGER_H
13
14 #include <QtCore/QList>
15
16 #include "scopes/audioscopes/abstractaudioscopewidget.h"
17 #include "scopes/colorscopes/abstractgfxscopewidget.h"
18
19 class QDockWidget;
20 class MonitorManager;
21 class AbstractRender;
22
23 /**
24   \brief Manages communication between Scopes and Renderer
25
26   The scope manager handles the data transfer between the active Renderer and
27   all scopes that have been registered via ScopeManager::addScope(AbstractAudioScopeWidget, QDockWidget)
28   or ScopeManager::addScope(AbstractGfxScopeWidget, QDockWidget). It checks whether the renderer really
29   needs to send data (it does not, for example, if no scopes are visible).
30   */
31 class ScopeManager : QObject
32 {
33     Q_OBJECT
34
35     struct GfxScopeData {
36         AbstractGfxScopeWidget *scope;
37         QDockWidget *scopeDockWidget;
38         bool singleFrameRequested;
39         GfxScopeData() { singleFrameRequested = false; }
40     };
41
42     struct AudioScopeData {
43         AbstractAudioScopeWidget *scope;
44         QDockWidget *scopeDockWidget;
45         bool singleFrameRequested;
46         AudioScopeData() { singleFrameRequested = false; }
47     };
48
49 public:
50     ScopeManager(MonitorManager *monitorManager);
51
52     /**
53       Adds a scope and sets up signal/slot connections to ensure that the scope
54       receives data when required.
55       \see addScope(AbstractGfxScopeWidget, QDockWidget)
56       */
57     bool addScope(AbstractAudioScopeWidget *audioScope, QDockWidget *audioScopeWidget = NULL);
58     /**
59       \see addScope(AbstractAudioScopeWidget, QDockWidget)
60       */
61     bool addScope(AbstractGfxScopeWidget *colorScope, QDockWidget *colorScopeWidget = NULL);
62
63 private:
64     MonitorManager *m_monitorManager;
65     QList<AudioScopeData> m_audioScopes;
66     QList<GfxScopeData> m_colorScopes;
67
68     AbstractRender *m_lastConnectedRenderer;
69
70     QSignalMapper *m_signalMapper;
71
72     /**
73       Checks whether there is any scope accepting audio data, or if all of them are hidden
74       or if auto refresh is disabled.
75       \see imagesAcceptedByScopes(): Same for image data
76       */
77     bool audioAcceptedByScopes() const;
78     /**
79       \see audioAcceptedByScopes()
80       */
81     bool imagesAcceptedByScopes() const;
82
83
84     /**
85       Checks whether audio data is required, and notifies the renderer (enable or disable data sending).
86       \see checkActiveAudioScopes() for image data
87       */
88     void checkActiveAudioScopes();
89     /**
90       Checks whether any scope accepts frames, and notifies the renderer.
91       \see checkActiveAudioScopes() for audio data
92       */
93     void checkActiveColourScopes();
94
95 private slots:
96     /**
97       Updates the signal/slot connection since the active renderer has changed.
98       */
99     void slotUpdateActiveRenderer();
100     /**
101       The scope source was deleted, clear it.
102       */
103     void slotClearColorScopes();
104     /**
105       \see checkActiveAudioScopes()
106       \see checkActiveColourScopes()
107       */
108     
109     void slotCheckActiveScopes();
110     void slotDistributeFrame(QImage image);
111     void slotDistributeAudio(QVector<int16_t> sampleData, int freq, int num_channels, int num_samples);
112     /**
113       Allows a scope to explicitly request a new frame, even if the scope's autoRefresh is disabled.
114       */
115     void slotRequestFrame(const QString widgetName);
116
117
118 };
119
120 #endif // SCOPEMANAGER_H