VAPOR3 3.9.4
MainForm.h
Go to the documentation of this file.
1//************************************************************************
2// *
3// Copyright (C) 2004 *
4// University Corporation for Atmospheric Research *
5// All Rights Reserved *
6// *
7//************************************************************************/
8//
9// File: MainForm.h
10//
11// Author: Alan Norton
12// National Center for Atmospheric Research
13// PO 3000, Boulder, Colorado
14//
15// Date: July 2004
16//
17// Description: Definition of MainForm class
18// This QT Main Window class supports all main window functionality
19// including menus, tab dialog, docking, visualizer window,
20// and some of the communication between these classes.
21// There is only one of these, it is created by the main program.
22// Other classes can use getInstance() to obtain it
23//
24#ifndef MAINFORM_H
25#define MAINFORM_H
26
27#include "vapor/VAssert.h"
28#include <qvariant.h>
29#include <qmainwindow.h>
30#include <qstring.h>
31#include <QPaintEvent>
32#include <QActionGroup>
33#include <QLabel>
34#include <QComboBox>
35#include <QIcon>
36#include <QLineEdit>
37#include <QWidgetAction>
38#include <chrono>
43#include "AnimationController.h"
44//#include "MiscParams.h"
45#include "TabManager.h"
46
47class QApplication;
48class QSpacerItem;
49class QMenu;
50class QToolBar;
51class QWidget;
52class QDesktopWidget;
53class QMdiArea;
54class QDockWindow;
55class QLabel;
56class QSpinBox;
57class ProgressStatusBar;
58class QTimer;
59class QDialog;
60
61class VizWindow;
62class VizWinMgr;
63class VizSelectCombo;
64
65class BannerGUI;
66class Statistics;
67class Plot;
68class PythonVariables;
69class ErrorReporter;
71class AppSettingsMenu;
72
73namespace VAPoR {
74class XmlNode;
75};
76
77class MainForm : public QMainWindow {
78 Q_OBJECT
79
80public:
81 MainForm(vector<QString> files, QApplication *app, bool interactive = true, string filesType = "auto", QWidget *parent = 0);
83
84 int RenderAndExit(int start, int end, const std::string &baseFile, int width, int height);
85
86protected:
87 bool eventFilter(QObject *obj, QEvent *event);
88
89private:
90 static const QEvent::Type ParamsChangeEvent;
91 static const QEvent::Type ParamsIntermediateChangeEvent;
92 static const std::string _documentationURL;
93
94 QMdiArea * _mdiArea;
95 QApplication *_App;
96
97 // Animation actions
98 //
99 QAction *_playForwardAction;
100 QAction *_playBackwardAction;
101 QAction *_pauseAction;
102
103 // Undo/redo actions
104 //
105 QAction * _editUndoAction;
106 QAction * _editRedoAction;
107 QAction * _appSettingsAction;
108 QLineEdit * _timeStepEdit;
109 QIntValidator *_timeStepEditValidator;
110
111 QComboBox *_alignViewCombo;
112 QMenuBar * _main_Menubar;
113 QMenu * _File;
114 QMenu * _Edit;
115 QMenu * _Tools;
116 QMenu * _captureMenu;
117 QMenu * _helpMenu;
118 QMenu * _developerMenu;
119
120 QToolBar *_vizToolBar;
121 QToolBar *_animationToolBar;
122
123 // Submenus under the File menu:
124 //
125 QMenu *_dataMenu;
126 QMenu *_closeVDCMenu;
127 QMenu *_importMenu;
128 QMenu *_sessionMenu;
129
130 // File menu:
131 //
132 QAction *_fileOpenAction;
133 QAction *_fileSaveAction;
134 QAction *_fileSaveAsAction;
135 QAction *_fileExitAction;
136
137 // Help menu
138 //
139 QAction *_helpAboutAction;
140 QAction *_whatsThisAction;
141 QAction *_installCLIToolsAction;
142 QAction *_webDocumentationAction;
143
144 // Data menu
145 //
146 QAction *_dataLoad_MetafileAction;
147 QAction *_dataClose_MetafileAction;
148 QAction *_fileNew_SessionAction;
149 QAction *_plotAction;
150 QAction *_statsAction;
151 QAction *_pythonAction;
152
153 // Capture menu
154 //
155 QMenu * _singleImageMenu;
156 QAction *_captureSingleJpegAction;
157 QAction *_captureSinglePngAction;
158 QAction *_captureSingleTiffAction;
159
160 QMenu * _imageSequenceMenu;
161 QAction *_captureJpegSequenceAction;
162 QAction *_capturePngSequenceAction;
163 QAction *_captureTiffSequenceAction;
164
165 QAction *_captureEndImageAction;
166
167 // Toolbars:
168 //
169 QAction * _tileAction;
170 QAction * _cascadeAction;
171 QAction * _homeAction;
172 QAction * _sethomeAction;
173 QAction * _viewAllAction;
174 QAction * _viewRegionAction;
175 QAction * _stepForwardAction;
176 QAction * _stepBackAction;
177 QSpinBox * _interactiveRefinementSpin;
178 QDockWidget *_tabDockWindow;
179
180 bool _animationCapture = false;
181 int _progressSavedFB = -1;
182 bool _progressEnabled = false;
183 bool _needToReenableProgressAfterAnimation = false;
184 QAction *_progressEnabledMenuItem = nullptr;
185
186 ProgressStatusBar * _status = nullptr;
187 std::chrono::time_point<std::chrono::system_clock> _progressLastUpdateTime;
188 const QObject * _disableUserInputForAllExcept = nullptr;
189 bool _insideMessedUpQtEventLoop = false;
190
191 Statistics * _stats;
192 Plot * _plot;
193 PythonVariables * _pythonVariables;
194 AppSettingsMenu * _appSettingsMenu;
195 BannerGUI * _banner;
196 VizSelectCombo * _windowSelector;
197 VAPoR::ControlExec *_controlExec;
198 VAPoR::ParamsMgr * _paramsMgr;
199 TabManager * _tabMgr;
200 AnimationController *_animationController;
201 VizWinMgr * _vizWinMgr;
202 string _capturingAnimationVizName;
203
204 bool _stateChangeFlag;
205 bool _sessionNewFlag;
206 bool _begForCitation;
207 int _eventsSinceLastSave;
208 bool _buttonPressed;
209 bool _paramsEventQueued = false;
210
211 ErrorReporter *_errRep;
212
213 ParamsWidgetDemo *_paramsWidgetDemo = nullptr;
214
215 QMenu *_loadBookmarkMenu;
216 QMenu *_deleteBookmarkMenu;
217
218 void createBookmark();
219 void populateBookmarkList();
220 void loadBookmark(int i);
221 void deleteBookmark(int i);
222
223 // Zero out all member variables
224 //
225 void _initMembers();
226
227 void _performSessionAutoSave();
228 void _stateChangeCB();
229 void _intermediateStateChangedCB();
230
231 QMdiArea *getMDIArea() { return _mdiArea; }
232
233 QApplication *getApp() { return _App; }
234
235 void setInteractiveRefinementSpin(int);
236 void enableKeyframing(bool onoff);
237 VizSelectCombo *getWindowSelector() { return _windowSelector; }
238
239 // Set the animation buttons in pause state,
240 // don't trigger an event:
241 //
242 void setPause()
243 {
244 _playForwardAction->setChecked(false);
245 _playBackwardAction->setChecked(false);
246 _pauseAction->setChecked(true);
247 }
248
249 void showCitationReminder();
250
251 void stopAnimCapture(string vizName)
252 {
253 if (vizName == _capturingAnimationVizName) endAnimCapture();
254 }
255
256 GUIStateParams *GetStateParams() const
257 {
258 VAssert(_paramsMgr != NULL);
259 return ((GUIStateParams *)_paramsMgr->GetParams(GUIStateParams::GetClassType()));
260 }
261
262 SettingsParams *GetSettingsParams() const
263 {
264 VAssert(_paramsMgr != NULL);
265 return ((SettingsParams *)_paramsMgr->GetParams(SettingsParams::GetClassType()));
266 }
267
268 AnimationParams *GetAnimationParams() const
269 {
270 VAssert(_paramsMgr != NULL);
272 }
273
274 /*MiscParams *GetMiscParams() const {
275 VAssert(_paramsMgr != NULL);
276 return ((MiscParams *)
277 _paramsMgr->GetParams(MiscParams::GetClassType())
278 );
279 }*/
280
281 // Set the various widgets in the main window consistent with latest
282 // params settings:
283 //
284 void updateMenus();
285 void update();
286 virtual void undoRedoHelper(bool undo);
287 static bool doesQStringContainNonASCIICharacter(const QString &s);
288 static int checkQStringContainsNonASCIICharacter(const QString &s);
289 std::vector<string> myGetOpenFileNames(string prompt, string dir, string filter, bool multi);
290
291 void closeDataHelper(string dataSetName);
292
293 bool openDataHelper(string dataSetName, string format, const vector<string> &files, const vector<string> &options = vector<string>());
294
295 enum DatasetExistsAction { Prompt, AddNew, ReplaceFirst };
296 void loadDataHelper(string dataSetName, const std::vector<string> &files, string prompt, string filter, string format, bool multi, DatasetExistsAction existsAction = Prompt);
297 void _createCaptureMenu();
298 void _createToolsMenu();
299 void _createEditMenu();
300 void _createFileMenu();
301 void _createHelpMenu();
302 void _createDeveloperMenu();
303 void createMenus();
304 void hookupSignals();
305 void _createAnimationToolBar();
306 void _createVizToolBar();
307 void createToolBars();
308 void _createProgressWidget();
309 void _disableProgressWidget();
310 virtual void sessionOpenHelper(string fileName, bool loadDatasets = true);
311 void closeAllParamsDatasets();
312 void loadAllParamsDatasets();
313
314 template<class T> bool isDatasetValidFormat(const std::vector<std::string> &paths) const;
315 bool determineDatasetFormat(const std::vector<std::string> &paths, std::string *fmt) const;
316
317 void CheckForUpdates();
318 void CheckForNotices();
319 void CheckForCasperVGL();
320
321 bool isOpenGLContextActive() const;
322
323 // Enable/Disable all the widgets that require data to be present
324 //
325 void enableWidgets(bool onOff);
326
327 void enableAnimationWidgets(bool onOff);
328
329 void _fileSaveHelper(string path);
330
331 string _getDataSetName(string file, DatasetExistsAction existsAction = Prompt);
332
333private slots:
334 void _plotClosed();
335 void _statsClosed();
336 void sessionOpen(QString qfileName = "", bool loadDatasets = true);
337 void fileSave();
338 void fileSaveAs();
339 void fileExit();
340 void undo();
341 void redo();
342 void helpAbout();
343 void loadData(string fileName = "");
344 void closeData(string fileName = "");
345 void sessionNew();
346 void captureJpegSequence();
347 void captureTiffSequence();
348 void capturePngSequence();
349 void selectAnimCatureOutput(string filter, string defaultSuffix);
350 void startAnimCapture(string baseFile, string defaultSuffix = "tiff");
351 void endAnimCapture();
352 void captureSingleImage(string filter, string defaultSuffix);
353 void captureSingleJpeg();
354 void captureSinglePng();
355 void captureSingleTiff();
356 void installCLITools();
357 void launchStats();
358 void launchPlotUtility();
359 void launchPythonVariables();
360
361 // animation toolbar:
362 void _setTimeStep();
363
364 void launchWebDocs() const;
365 void setInteractiveRefLevel(int);
366 void loadStartingPrefs();
367
368 void setActiveEventRouter(string type);
369
370 void _setProj4String(string proj4String);
371
372 void _setAnimationOnOff(bool onOff);
373 void _setAnimationDraw();
374};
375#endif // MAINFORM_H
#define VAssert(expr)
Definition: VAssert.h:9
This class is just migrated legacy code to de-spaghetti other legacy code. (It is not written by me)
A class that specifies parameters used in animation.
static string GetClassType()
A utility singleton class that provides error reporting functinality.
Definition: ErrorReporter.h:78
static string GetClassType()
bool eventFilter(QObject *obj, QEvent *event)
int RenderAndExit(int start, int end, const std::string &baseFile, int width, int height)
MainForm(vector< QString > files, QApplication *app, bool interactive=true, string filesType="auto", QWidget *parent=0)
Definition: Plot.h:26
A class for describing settings at settings.
static string GetClassType()
A class that manages the contents of the parameter tabs in VAPOR GUI.
Definition: TabManager.h:73
Provides API for VAPOR visualizer User Interfaces (UIs)
A singleton class for managing Params instances.
Definition: ParamsMgr.h:53
ParamsBase * GetParams(string classType)
Definition: ParamsMgr.h:371
A class for managing all visualizers.
Definition: VizWinMgr.h:49