File indexing completed on 2024-06-02 04:35:10
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2007 The University of Toronto * 0004 * netterfield@astro.utoronto.ca * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 ***************************************************************************/ 0012 0013 #ifndef MAINWINDOW_H 0014 #define MAINWINDOW_H 0015 0016 #include <QMainWindow> 0017 #include <QPointer> 0018 #include <QLabel> 0019 0020 #if defined(__QNX__) 0021 #include <QDateTime> 0022 #endif // defined(__QNX__) 0023 0024 class QMenu; 0025 class QAction; 0026 class QProgressBar; 0027 class QUndoGroup; 0028 class QPrinter; 0029 class QSettings; 0030 class QSignalMapper; 0031 0032 namespace Kst { 0033 0034 class DataManager; 0035 class DebugDialog; 0036 class Document; 0037 class ExportGraphicsDialog; 0038 class ExportVectorsDialog; 0039 class LogDialog; 0040 class DifferentiateCurvesDialog; 0041 class FilterMultipleDialog; 0042 class ChooseColorDialog; 0043 class ChangeDataSampleDialog; 0044 class ChangeFileDialog; 0045 class BugReportWizard; 0046 class ApplicationSettingsDialog; 0047 class ThemeDialog; 0048 class AboutDialog; 0049 class ShortcutDialog; 0050 class TabWidget; 0051 class View; 0052 class ScriptServer; 0053 class ViewVectorDialog; 0054 0055 0056 class MainWindow : public QMainWindow 0057 { 0058 Q_OBJECT 0059 public: 0060 MainWindow(); 0061 ~MainWindow(); 0062 0063 QUndoGroup *undoGroup() const; 0064 TabWidget *tabWidget() const; 0065 Document *document() const; 0066 QProgressBar *progressBar() const; 0067 bool initFromCommandLine(); 0068 bool isHighlightPoint() { return _highlightPoint; } 0069 bool isTiedTabs(); 0070 void setStatusMessage(QString message, int timeout=0, bool delayed = false); 0071 void updateStatusMessage(); 0072 QString statusMessage(); 0073 0074 static void setWidgetFlags(QWidget*); 0075 void updateRecentKstFiles(const QString& newfilename = QString()); 0076 0077 void setKstWindowTitle(); 0078 QString scriptServerName(); 0079 bool scriptServerNameSet(); 0080 void setScriptServerName(QString server_name); 0081 0082 public Q_SLOTS: 0083 void copyTab(); 0084 void toggleStatusBar(); 0085 void showDataManager(); 0086 void showDebugDialog(); 0087 void showExportGraphicsDialog(); 0088 void showExportVectorsDialog(); 0089 void showLogDialog(); 0090 void showVectorEditor(); 0091 void showScalarEditor(); 0092 void showMatrixEditor(); 0093 void showStringEditor(); 0094 void showSettingsDialog(); 0095 void showThemeDialog(); 0096 void clearDefaults(); 0097 void clearDataSourceSettings(); 0098 void showDifferentiateCurvesDialog(); 0099 void filterMultipleDialog(); 0100 void showChooseColorDialog(); 0101 void showChangeDataSampleDialog(); 0102 void showChangeFileDialog(); 0103 void showDataWizard(); 0104 void showDataWizard(const QString &dataFile); 0105 void showBugReportWizard(); 0106 void showPluginDialog(QString &pluginName); 0107 0108 void readFromEnd(); 0109 void readToEnd(); 0110 void pause(bool pause); 0111 void back(double scale = 1.0); 0112 void forward(double scale = 1.0); 0113 void backSmall() {back(0.2);} 0114 void forwardSmall() {forward(0.2);} 0115 void reload(); 0116 0117 void updateViewItems(qint64 serial); 0118 void updateProgress(int percent, const QString& message); 0119 0120 void save(); 0121 void saveAs(); 0122 void open(); 0123 void newDoc(bool force=false); 0124 void openFile(const QString &file); 0125 void cleanUpDataSourceList(); 0126 #ifndef KST_NO_PRINTER 0127 void print(); 0128 void setPrinterDefaults(QPrinter *printer); 0129 void savePrinterDefaults(QPrinter *printer); 0130 void printToPrinter(QPrinter *printer); 0131 void printFromCommandLine(const QString &printFileName); 0132 #endif 0133 void exportGraphicsFile(const QString &filename, const QString &format, int w, int h, int display, bool export_all, int autosave_period); 0134 void exportLog(const QString &imagename, QString &msgfilename, const QString &_format, int x_size, int y_size, 0135 int size_option_index, const QString &message); 0136 0137 0138 void clearDrawingMarker(); 0139 void tiedZoomRemoved(); 0140 void allPlotsTiedZoom(); 0141 0142 void updateRecentDataFiles(const QString& newfilename = QString()); 0143 void videoTutorial(int); 0144 0145 QStringList recentDataFiles(); 0146 0147 void cleanupRecentDataFilesList(); 0148 0149 private Q_SLOTS: 0150 void aboutToQuit(); 0151 void about(); 0152 void showShortcutDialog(); 0153 void currentViewChanged(); 0154 void currentViewModeChanged(); 0155 0156 void createBox(); 0157 void createEllipse(); 0158 void createLabel(); 0159 void createCircle(); 0160 void createLine(); 0161 void createArrow(); 0162 void createPicture(); 0163 void createPlot(); 0164 void insertPlot(); 0165 #ifndef KST_NO_SVG 0166 void createSvg(); 0167 #endif 0168 void createSharedAxisBox(); 0169 0170 void createScalar(); 0171 void createVector(); 0172 void createMatrix(); 0173 void createString(); 0174 void createCurve(); 0175 void createPSD(); 0176 void createEquation(); 0177 void createHistogram(); 0178 void createImage(); 0179 void createSpectogram(); 0180 void createEventMonitor(); 0181 0182 void performHeavyStartupActions(); 0183 void cleanup(); 0184 0185 void setLayoutMode(bool layoutMode); 0186 void toggleTiedZoom(); 0187 0188 void setHighlightPoint(bool); 0189 void changeZoomOnlyMode(QAction*); 0190 0191 void openRecentKstFile(); 0192 void openRecentDataFile(); 0193 void checkRecentFilesOnExistence(); 0194 0195 void autoExportImage(); 0196 0197 protected: 0198 void closeEvent(QCloseEvent *e); 0199 0200 private: 0201 void createActions(); 0202 void createMenus(); 0203 void createStatusBar(); 0204 void createToolBars(); 0205 0206 void readSettings(); 0207 void writeSettings(); 0208 bool promptSaveDone(); 0209 0210 QAction* createRecentFileAction(const QString& filename, int idx, const QString& text, const char* openslot); 0211 void updateRecentFiles(const QString& key, QMenu *menu, QList<QAction*>& actions, QMenu* submenu, const QString& newfilename, const char* openslot); 0212 0213 void dragEnterEvent(QDragEnterEvent *event); 0214 void dropEvent(QDropEvent *event); 0215 #if defined(__QNX__) 0216 void keyPressEvent(QKeyEvent *event); 0217 bool eventFilter(QObject *obj, QEvent *event); 0218 void qnxToggleToolbarVisibility(); 0219 #endif // defined(__QNX__) 0220 0221 private: 0222 Document *_doc; 0223 TabWidget *_tabWidget; 0224 QUndoGroup *_undoGroup; 0225 ScriptServer* _scriptServer; 0226 QSettings& _settings; 0227 0228 DataManager *_dataManager; 0229 DebugDialog *_debugDialog; 0230 ExportGraphicsDialog *_exportGraphics; 0231 ExportVectorsDialog *_exportVectors; 0232 LogDialog *_logDialog; 0233 DifferentiateCurvesDialog *_differentiateCurvesDialog; 0234 FilterMultipleDialog *_filterMultipleDialog; 0235 ChooseColorDialog *_chooseColorDialog; 0236 ChangeDataSampleDialog *_changeDataSampleDialog; 0237 ChangeFileDialog *_changeFileDialog; 0238 BugReportWizard *_bugReportWizard; 0239 ApplicationSettingsDialog *_applicationSettingsDialog; 0240 ThemeDialog *_themeDialog; 0241 AboutDialog* _aboutDialog; 0242 ShortcutDialog* _shortcutDialog; 0243 ViewVectorDialog* _viewVectorDialog; 0244 QSignalMapper* _videoMapper; 0245 QPointer<QProgressBar> _progressBar; 0246 QLabel *_messageLabel; 0247 0248 bool _highlightPoint; 0249 0250 QMenu *_fileMenu; 0251 QMenu *_editMenu; 0252 QMenu *_viewMenu; 0253 QMenu *_createMenu; 0254 QMenu *_pluginsMenu; 0255 QMenu *_fitsPluginsMenu; 0256 QMenu *_filterPluginsMenu; 0257 QMenu *_modeMenu; 0258 QMenu *_rangeMenu; 0259 QMenu *_toolsMenu; 0260 QMenu *_settingsMenu; 0261 QMenu *_helpMenu; 0262 QMenu* _videoTutorialsMenu; 0263 0264 QToolBar *_fileToolBar; 0265 QToolBar *_editToolBar; 0266 QToolBar *_rangeToolBar; 0267 QToolBar *_modeToolBar; 0268 QToolBar *_plotLayoutToolBar; 0269 QToolBar *_toolsToolBar; 0270 QToolBar *_annotationToolBar; 0271 0272 QAction *_undoAct; 0273 QAction *_redoAct; 0274 QAction *_copyTabAct; 0275 0276 // FIXME: move these into each object, along with the creation slot? 0277 QAction *_createLabelAct; 0278 QAction *_createBoxAct; 0279 QAction *_createCircleAct; 0280 QAction *_createEllipseAct; 0281 QAction *_createLineAct; 0282 QAction *_createArrowAct; 0283 QAction *_createPictureAct; 0284 QAction *_createPlotAct; 0285 QAction *_insertPlotAct; 0286 #ifndef KST_NO_SVG 0287 QAction *_createSvgAct; 0288 #endif 0289 QAction *_createSharedAxisBoxAct; 0290 0291 QAction *_aboutAct; 0292 QAction *_showShortcutAct; 0293 QAction *_dataManagerAct; 0294 QAction *_debugDialogAct; 0295 QAction *_video1Act; 0296 QAction *_video2Act; 0297 QAction *_video3Act; 0298 QAction *_video4Act; 0299 QAction *_video5Act; 0300 QAction *_video6Act; 0301 QAction *_video7Act; 0302 QAction *_exitAct; 0303 QAction *_exportGraphicsAct; 0304 QAction *_exportVectorsAct; 0305 QAction *_logAct; 0306 QAction *_openAct; 0307 QAction *_saveAct; 0308 QAction *_saveAsAct; 0309 QAction *_closeAct; 0310 QAction *_printAct; 0311 QAction *_newTabAct; 0312 QAction *_closeTabAct; 0313 QAction *_scalarEditorAct; 0314 QAction *_vectorEditorAct; 0315 QAction *_matrixEditorAct; 0316 QAction *_stringEditorAct; 0317 0318 QAction *_layoutModeAct; 0319 QAction *_tiedZoomAct; 0320 QAction *_tabTiedAct; 0321 QAction *_highlightPointAct; 0322 QAction *_standardZoomAct; 0323 QAction *_xOnlyZoomAct; 0324 QAction *_yOnlyZoomAct; 0325 0326 QAction *_settingsDialogAct; 0327 QAction *_themeDialogAct; 0328 0329 QAction *_clearUISettings; 0330 QAction *_clearDataSourceSettings; 0331 QAction *_toggleStatusBar; 0332 0333 QAction *_differentiateCurvesDialogAct; 0334 QAction *_filterMultipleDialogAct; 0335 QAction *_chooseColorDialogAct; 0336 QAction *_changeDataSampleDialogAct; 0337 QAction *_changeFileDialogAct; 0338 QAction *_dataWizardAct; 0339 QAction *_bugReportWizardAct; 0340 0341 QAction *_readFromEndAct; 0342 QAction *_readToEndAct; 0343 QAction *_pauseAct; 0344 QAction *_backAct; 0345 QAction *_forwardAct; 0346 QAction *_backSmallAct; 0347 QAction *_forwardSmallAct; 0348 QAction *_reloadAct; 0349 0350 QAction *_newScalarAct; 0351 QAction *_newVectorAct; 0352 QAction *_newMatrixAct; 0353 QAction *_newStringAct; 0354 QAction *_newCurveAct; 0355 QAction *_newEquationAct; 0356 QAction *_newPSDAct; 0357 QAction *_newHistogramAct; 0358 QAction *_newImageAct; 0359 QAction *_newSpectrogramAct; 0360 QAction *_newEventMonitorAct; 0361 0362 QMenu* _recentKstFilesMenu; 0363 QMenu* _recentDataFilesMenu; 0364 QList<QAction*> _bottomRecentKstActions; 0365 QList<QAction*> _bottomRecentDataActions; 0366 QString _statusBarMessage; 0367 int _statusBarTimeout; 0368 #if defined(__QNX__) 0369 bool _qnxToolbarsVisible; 0370 QDateTime _qnxLastToolbarEvent; 0371 #endif // defined(__QNX__) 0372 0373 // autoExportGraphics fields 0374 QString _ae_filename; 0375 QString _ae_format; 0376 int _ae_width; 0377 int _ae_height; 0378 int _ae_display; 0379 bool _ae_export_all; 0380 int _ae_autosave_period; 0381 QTimer *_ae_Timer; 0382 QString _sessionFileName; 0383 0384 friend class ScriptServer; 0385 }; 0386 0387 } 0388 #endif 0389 0390 // vim: ts=2 sw=2 et