Slicer  5.0
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
qSlicerMainWindow.h
Go to the documentation of this file.
1 /*==============================================================================
2 
3  Program: 3D Slicer
4 
5  Copyright (c) Kitware Inc.
6 
7  See COPYRIGHT.txt
8  or http://www.slicer.org/copyright/copyright.txt for details.
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16  This file was originally developed by Jean-Christophe Fillion-Robin, Kitware Inc.
17  and was partially funded by NIH grant 3P41RR013218-12S1
18 
19 ==============================================================================*/
20 
21 #ifndef __qSlicerMainWindow_h
22 #define __qSlicerMainWindow_h
23 
24 // Qt includes
25 #include <QMainWindow>
26 #include <QVariantMap>
27 
28 // CTK includes
29 #include <ctkErrorLogModel.h>
30 
31 // Slicer includes
32 #include "qSlicerBaseQTAppExport.h"
33 #include "qSlicerIO.h"
34 #include "vtkSlicerConfigure.h" // For Slicer_BUILD_DICOM_SUPPORT, Slicer_USE_PYTHONQT, Slicer_USE_QtTesting
35 
36 class ctkErrorLogWidget;
37 class ctkPythonConsole;
39 class qSlicerMainWindowPrivate;
41 class vtkObject;
42 
43 class Q_SLICER_BASE_QTAPP_EXPORT qSlicerMainWindow : public QMainWindow
44 {
45  Q_OBJECT
46 public:
47  typedef QMainWindow Superclass;
48 
49  qSlicerMainWindow(QWidget *parent=nullptr);
50  ~qSlicerMainWindow() override;
51 
55  Q_INVOKABLE qSlicerModuleSelectorToolBar* moduleSelector()const;
56 
57 #ifdef Slicer_USE_PYTHONQT
58  Q_INVOKABLE ctkPythonConsole* pythonConsole()const;
61 #endif
62  Q_INVOKABLE ctkErrorLogWidget* errorLogWidget()const;
65 
67  Q_INVOKABLE vtkMRMLAbstractViewNode* layoutMaximizedViewNode();
68 
69 public slots:
70  virtual void setHomeModuleCurrent();
71  virtual void restoreToolbars();
72 
73  virtual void on_FileFavoriteModulesAction_triggered();
74  virtual void on_FileAddDataAction_triggered();
75  virtual void on_FileLoadDataAction_triggered();
76  virtual void on_FileImportSceneAction_triggered();
77  virtual void on_FileLoadSceneAction_triggered();
78  virtual void on_FileAddVolumeAction_triggered();
79  virtual void on_FileAddTransformAction_triggered();
80  virtual void on_FileSaveSceneAction_triggered();
81  virtual void on_FileExitAction_triggered();
82  virtual void onFileRecentLoadedActionTriggered();
83  virtual void on_SDBSaveToDirectoryAction_triggered();
84  virtual void on_SDBSaveToMRBAction_triggered();
85  virtual void on_FileCloseSceneAction_triggered();
86  virtual void on_LoadDICOMAction_triggered();
87 
88  virtual void on_EditRecordMacroAction_triggered();
89  virtual void on_EditPlayMacroAction_triggered();
90  virtual void on_EditUndoAction_triggered();
91  virtual void on_EditRedoAction_triggered();
92 
93  virtual void on_ModuleHomeAction_triggered();
94 
95  virtual void onLayoutActionTriggered(QAction* action);
96  virtual void onLayoutCompareActionTriggered(QAction* action);
97  virtual void onLayoutCompareWidescreenActionTriggered(QAction* action);
98  virtual void onLayoutCompareGridActionTriggered(QAction* action);
99 
101  virtual void setLayout(int);
102 
105  virtual void setLayoutMaximizedViewNode(vtkMRMLAbstractViewNode*);
106 
107  virtual void setLayoutNumberOfCompareViewRows(int);
108  virtual void setLayoutNumberOfCompareViewColumns(int);
109 
110  virtual void onPythonConsoleToggled(bool);
111 
112  virtual void on_WindowErrorLogAction_triggered();
113  virtual void on_WindowToolbarsResetToDefaultAction_triggered();
114 
115  virtual void on_EditApplicationSettingsAction_triggered();
116  virtual void on_CutAction_triggered();
117  virtual void on_CopyAction_triggered();
118  virtual void on_PasteAction_triggered();
119  virtual void on_ViewExtensionsManagerAction_triggered();
120 
121  virtual void on_ShowStatusBarAction_triggered(bool);
122 
133  virtual void saveGUIState(bool force=false);
134 
137  virtual void restoreGUIState(bool force=false);
138 
139  virtual void addFileToRecentFiles(const qSlicerIO::IOProperties& fileProperties);
140 
141 signals:
144  void initialWindowShown();
145 
146 protected slots:
147  virtual void onModuleLoaded(const QString& moduleName);
148  virtual void onModuleAboutToBeUnloaded(const QString& moduleName);
149  virtual void onNewFileLoaded(const qSlicerIO::IOProperties &fileProperties);
150  virtual void onFileSaved(const qSlicerIO::IOProperties& fileProperties);
151 
152  virtual void onMRMLSceneModified(vtkObject*);
153  virtual void onLayoutChanged(int);
154  virtual void onWarningsOrErrorsOccurred(ctkErrorLogLevel::LogLevel logLevel);
155 
156  // Show/hide update indicator on Extensions Manager toolbar icon
157  void setExtensionUpdatesAvailable(bool updateAvailable);
158 
159 #ifdef Slicer_USE_PYTHONQT
160  virtual void onPythonConsoleUserInput(const QString&);
161 #endif
162 
163 protected:
165  virtual void setupMenuActions();
166 
168  virtual void pythonConsoleInitialDisplay();
169 
171  virtual void disclaimer();
172 
176  void dragEnterEvent(QDragEnterEvent *event) override;
177 
180  void dropEvent(QDropEvent *event) override;
181 
188  bool eventFilter(QObject* object, QEvent* event) override;
189 
190  void closeEvent(QCloseEvent *event) override;
191  void showEvent(QShowEvent *event) override;
192 
193  void changeEvent(QEvent* event) override;
194 
195 protected:
196  QScopedPointer<qSlicerMainWindowPrivate> d_ptr;
197 
198  qSlicerMainWindow(qSlicerMainWindowPrivate* pimpl, QWidget* parent);
199 
200 private:
201  Q_DECLARE_PRIVATE(qSlicerMainWindow);
202  Q_DISABLE_COPY(qSlicerMainWindow);
203 };
204 
205 #endif
Abstract MRML node to represent a view. The class holds the properties common to any view type (3D...
QMainWindow Superclass
QScopedPointer< qSlicerMainWindowPrivate > d_ptr