]> git.sesse.net Git - kdenlive/blob - src/scopes/scopemanager.h
Fix indent
[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() {
40             scope = NULL;
41             scopeDockWidget = NULL;
42             singleFrameRequested = false;
43         }
44     };
45
46     struct AudioScopeData {
47         AbstractAudioScopeWidget *scope;
48         QDockWidget *scopeDockWidget;
49         bool singleFrameRequested;
50         AudioScopeData() {
51             scope = NULL;
52             scopeDockWidget = NULL;
53             singleFrameRequested = false; 
54         }
55     };
56
57 public:
58     ScopeManager(MonitorManager *monitorManager);
59
60     /**
61       Adds a scope and sets up signal/slot connections to ensure that the scope
62       receives data when required.
63       \see addScope(AbstractGfxScopeWidget, QDockWidget)
64       */
65     bool addScope(AbstractAudioScopeWidget *audioScope, QDockWidget *audioScopeWidget = NULL);
66     /**
67       \see addScope(AbstractAudioScopeWidget, QDockWidget)
68       */
69     bool addScope(AbstractGfxScopeWidget *colorScope, QDockWidget *colorScopeWidget = NULL);
70
71 private:
72     MonitorManager *m_monitorManager;
73     QList<AudioScopeData> m_audioScopes;
74     QList<GfxScopeData> m_colorScopes;
75
76     AbstractRender *m_lastConnectedRenderer;
77
78     QSignalMapper *m_signalMapper;
79
80     /**
81       Checks whether there is any scope accepting audio data, or if all of them are hidden
82       or if auto refresh is disabled.
83       \see imagesAcceptedByScopes(): Same for image data
84       */
85     bool audioAcceptedByScopes() const;
86     /**
87       \see audioAcceptedByScopes()
88       */
89     bool imagesAcceptedByScopes() const;
90
91
92     /**
93       Checks whether audio data is required, and notifies the renderer (enable or disable data sending).
94       \see checkActiveAudioScopes() for image data
95       */
96     void checkActiveAudioScopes();
97     /**
98       Checks whether any scope accepts frames, and notifies the renderer.
99       \see checkActiveAudioScopes() for audio data
100       */
101     void checkActiveColourScopes();
102
103 private slots:
104     /**
105       Updates the signal/slot connection since the active renderer has changed.
106       */
107     void slotUpdateActiveRenderer();
108     /**
109       The scope source was deleted, clear it.
110       */
111     void slotClearColorScopes();
112     /**
113       \see checkActiveAudioScopes()
114       \see checkActiveColourScopes()
115       */
116     
117     void slotCheckActiveScopes();
118     void slotDistributeFrame(const QImage &image);
119     void slotDistributeAudio(const QVector<int16_t> &sampleData, int freq, int num_channels, int num_samples);
120     /**
121       Allows a scope to explicitly request a new frame, even if the scope's autoRefresh is disabled.
122       */
123     void slotRequestFrame(const QString &widgetName);
124
125
126 };
127
128 #endif // SCOPEMANAGER_H