To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Tag: | Revision:

root / main / MainWindow.h

History | View | Annotate | Download (9.87 KB)

1
/* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
2

    
3
/*
4
    Sonic Lineup
5
    Comparative visualisation and alignment of related audio recordings
6
    Centre for Digital Music, Queen Mary, University of London.
7
    
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License as
10
    published by the Free Software Foundation; either version 2 of the
11
    License, or (at your option) any later version.  See the file
12
    COPYING included with this distribution for more information.
13
*/
14

    
15
#ifndef VECT_MAIN_WINDOW_H
16
#define VECT_MAIN_WINDOW_H
17

    
18
#include <QFrame>
19
#include <QString>
20
#include <QUrl>
21
#include <QMainWindow>
22
#include <QPointer>
23

    
24
#include "framework/MainWindowBase.h"
25
#include "base/Command.h"
26
#include "view/ViewManager.h"
27
#include "base/PropertyContainer.h"
28
#include "base/RecentFiles.h"
29
#include "layer/LayerFactory.h"
30
#include "transform/Transform.h"
31
#include "framework/SVFileReader.h"
32
#include "widgets/InteractiveFileFinder.h"
33
#include "align/Align.h"
34

    
35
#include "SmallSession.h"
36

    
37
#include <map>
38

    
39
class VersionTester;
40
class Document;
41
class PaneStack;
42
class Pane;
43
class View;
44
class Fader;
45
class Overview;
46
class Layer;
47
class WaveformLayer;
48
class TimeInstantLayer;
49
class WaveFileModel;
50
class AudioCallbackPlaySource;
51
class AudioCallbackPlayTarget;
52
class CommandHistory;
53
class QMenu;
54
class AudioDial;
55
class QLabel;
56
class QCheckBox;
57
class PreferencesDialog;
58
class QTreeView;
59
class QPushButton;
60
class KeyReference;
61
class QScrollArea;
62
class OSCMessage;
63
class QToolButton;
64

    
65
class MainWindow : public MainWindowBase
66
{
67
    Q_OBJECT
68

    
69
public:
70
    MainWindow(AudioMode audioMode);
71
    virtual ~MainWindow();
72

    
73
signals:
74
    void canSelectPreviousDisplayMode(bool);
75
    void canSelectNextDisplayMode(bool);
76

    
77
    void externalAlignmentProgramChanged();
78

    
79
public slots:
80
    void openSmallSession(const SmallSession &);
81
    bool reopenLastSession();
82

    
83
    void preferenceChanged(PropertyContainer::PropertyName) override;
84
    bool commitData(bool mayAskUser); // on session shutdown
85

    
86
    void goFullScreen();
87
    void endFullScreen();
88

    
89
    void selectMainPane();
90

    
91
    void introDialog();
92
    void checkForNewerVersion();
93

    
94
protected slots:
95
    virtual void openFiles();
96
    virtual void openLocation();
97
    virtual void openRecentSession();
98
    virtual void checkpointSession();
99
    virtual void browseRecordedAudio();
100
    virtual void newSession();
101
    virtual void preferences();
102

    
103
    void closeSession() override;
104

    
105
    void outlineWaveformModeSelected();
106
    void standardWaveformModeSelected();
107
    void spectrogramModeSelected();
108
    void melodogramModeSelected();
109
    void azimuthModeSelected();
110
    void pitchModeSelected();
111
    void keyModeSelected();
112

    
113
    void previousDisplayMode();
114
    void nextDisplayMode();
115

    
116
    void toggleSalientFeatures();
117
    void toggleVerticalScales();
118

    
119
    virtual void renameCurrentLayer();
120

    
121
    void paneAdded(Pane *) override;
122
    void paneHidden(Pane *) override;
123
    void paneAboutToBeDeleted(Pane *) override;
124
    void paneDropAccepted(Pane *, QStringList) override;
125
    void paneDropAccepted(Pane *, QString) override;
126

    
127
    void record() override;
128

    
129
    void alignmentTypeChanged();
130
    void alignmentSubsequenceChanged();
131
    void updateAlignmentPreferences(Align::AlignmentType type,
132
                                    bool subsequence);
133
    void selectAlignmentProgram();
134
    void clearAlignmentProgram();
135

    
136
    void playSpeedChanged(int);
137
    void speedUpPlayback();
138
    void slowDownPlayback();
139
    void restoreNormalPlayback();
140

    
141
    void monitoringLevelsChanged(float, float) override;
142
    
143
    void betaReleaseWarning();
144

    
145
    void sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool) override;
146
    void audioOverloadPluginDisabled() override;
147

    
148
    void documentModified() override;
149
    void documentRestored() override;
150

    
151
    void updateMenuStates() override;
152
    void updateDescriptionLabel() override;
153
    void updateWindowTitle() override;
154

    
155
    void layerRemoved(Layer *) override;
156
    void layerInAView(Layer *, bool) override;
157

    
158
    void mainModelChanged(ModelId) override;
159
    void modelAdded(ModelId) override;
160

    
161
    virtual void mainModelGainChanged(float);
162
    virtual void mainModelPanChanged(float);
163

    
164
    void modelGenerationFailed(QString, QString) override;
165
    void modelGenerationWarning(QString, QString) override;
166
    void modelRegenerationFailed(QString, QString, QString) override;
167
    void modelRegenerationWarning(QString, QString, QString) override;
168

    
169
    void alignmentComplete(ModelId) override;
170
    void alignmentFailed(ModelId, QString) override;
171

    
172
    virtual void salientLayerCompletionChanged(ModelId);
173

    
174
    void paneRightButtonMenuRequested(Pane *, QPoint) override { /* none */ }
175
    void panePropertiesRightButtonMenuRequested(Pane *, QPoint) override { /* none */ }
176
    void layerPropertiesRightButtonMenuRequested(Pane *, Layer *, QPoint) override { /* none */ }
177

    
178
    virtual void setupRecentSessionsMenu();
179

    
180
    virtual void showLayerTree();
181

    
182
    void handleOSCMessage(const OSCMessage &) override;
183

    
184
    virtual void mouseEnteredWidget();
185
    virtual void mouseLeftWidget();
186

    
187
    virtual void website();
188
    virtual void help();
189
    virtual void whatsNew();
190
    virtual void about();
191
    virtual void keyReference();
192

    
193
    void newerVersionAvailable(QString) override;
194

    
195
protected:
196
    LevelPanToolButton      *m_mainLevelPan;
197
    AudioDial               *m_playSpeed;
198
    
199
    QScrollArea             *m_mainScroll;
200

    
201
    bool                     m_mainMenusCreated;
202
    QToolBar                *m_playbackToolBar;
203
    QMenu                   *m_recentSessionsMenu;
204

    
205
    QAction                 *m_deleteSelectedAction;
206
    QAction                 *m_ffwdAction;
207
    QAction                 *m_rwdAction;
208

    
209
    QAction                 *m_playAction;
210
    QAction                 *m_zoomInAction;
211
    QAction                 *m_zoomOutAction;
212
    QAction                 *m_zoomFitAction;
213
    QAction                 *m_scrollLeftAction;
214
    QAction                 *m_scrollRightAction;
215

    
216
    QAction                 *m_selectPreviousPaneAction;
217
    QAction                 *m_selectNextPaneAction;
218
    QAction                 *m_selectPreviousDisplayModeAction;
219
    QAction                 *m_selectNextDisplayModeAction;
220

    
221
    QAction                 *m_subsequenceAlignmentAction;
222
    Align::AlignmentType     m_previousActiveAlignmentType;
223
    bool                     m_previousSubsequence;
224
    
225
    RecentFiles              m_recentSessions;
226
    
227
    bool                     m_exiting;
228

    
229
    QFrame                  *m_playControlsSpacer;
230
    int                      m_playControlsWidth;
231

    
232
    QPointer<PreferencesDialog> m_preferencesDialog;
233
    QPointer<QTreeView>      m_layerTreeView;
234

    
235
    KeyReference            *m_keyReference;
236
    VersionTester           *m_versionTester;
237
    bool                     m_networkPermission;
238
    QString                  m_newerVersionIs;
239

    
240
    QString getReleaseText() const;
241
    
242
    void setupMenus() override;
243
    
244
    virtual void setupFileMenu();
245
    virtual void setupViewMenu();
246
    virtual void setupAlignmentMenu();
247
    virtual void setupPlaybackMenu();
248
    virtual void setupHelpMenu();
249

    
250
    enum DisplayMode {
251
        OutlineWaveformMode,
252
        WaveformMode,
253
        SpectrogramMode,
254
        MelodogramMode,
255
        AzimuthMode,
256
        PitchMode,
257
        KeyMode
258
    };
259
    std::map<DisplayMode, QPushButton *> m_modeButtons;
260
    std::map<DisplayMode, QString> m_modeLayerNames;
261
    std::vector<DisplayMode> m_modeDisplayOrder;
262
    
263
    virtual void reselectMode();
264
    virtual void updateModeFromLayers(); // after loading a session
265
    virtual void selectTransformDrivenMode(DisplayMode mode,
266
                                           QString transformId,
267
                                           Transform::ParameterMap parameters,
268
                                           QString layerPropertyXml,
269
                                           bool includeGhostReference);
270
    DisplayMode m_displayMode;
271

    
272
    void closeEvent(QCloseEvent *e) override;
273
    bool checkSaveModified() override;
274

    
275
    virtual void configureNewPane(Pane *p);
276
    virtual bool selectExistingLayerForMode(Pane *, QString,
277
                                            ModelId *createFrom);
278

    
279
    virtual void addSalientFeatureLayer(Pane *, ModelId); // a WaveFileModel
280
    virtual void mapSalientFeatureLayer(ModelId); // a WaveFileModel
281

    
282
    void mapAllSalientFeatureLayers();
283

    
284
    // Return the salient-feature layer in the given pane. If pane is
285
    // unspecified, return the main salient-feature layer, i.e. the
286
    // first one found in any pane that is associated with the main
287
    // model. If none is found, return nullptr.
288
    virtual TimeInstantLayer *findSalientFeatureLayer(Pane *pane = nullptr);
289
    
290
    bool m_salientCalculating;
291
    std::set<ModelId> m_salientPending; // Aligned WaveFileModels
292
    int m_salientColour;
293
    
294
    void updateVisibleRangeDisplay(Pane *p) const override;
295
    void updatePositionStatusDisplays() const override;
296

    
297
    // Generate and return a filename into which to save the session,
298
    // based on the identity of the main model. This should be fixed
299
    // from the point where the identity of the main model is first
300
    // known.
301
    QString makeSessionFilename();
302

    
303
    // Generate and return a label to associate with the session in
304
    // the recent-sessions menu. This may depend on factors other than
305
    // the identity of the main model, such as the number of files
306
    // open, and so may change during the lifetime of the session.
307
    QString makeSessionLabel();
308

    
309
    // Construct a SmallSession, which contains the origin URIs of the
310
    // files in the current session
311
    SmallSession makeSmallSession();
312

    
313
    // Open a session from the given SmallSession file path
314
    void openSmallSessionFile(QString path);
315

    
316
    bool approveAlignmentProgram();
317

    
318
    enum SessionState {
319
        NoSession,
320
        SessionLoading,
321
        SessionActive
322
    };
323
    SessionState m_sessionState;
324

    
325
    bool m_shownAlignmentError;
326

    
327
    void loadStyle();
328
};
329

    
330

    
331
#endif