CustusX  15.3.4-beta
An IGT application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cxMainWindow.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) 2008-2014, SINTEF Department of Medical Technology
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9 
10 1. Redistributions of source code must retain the above copyright notice,
11  this list of conditions and the following disclaimer.
12 
13 2. Redistributions in binary form must reproduce the above copyright notice,
14  this list of conditions and the following disclaimer in the documentation
15  and/or other materials provided with the distribution.
16 
17 3. Neither the name of the copyright holder nor the names of its contributors
18  may be used to endorse or promote products derived from this software
19  without specific prior written permission.
20 
21 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 =========================================================================*/
32 
33 #ifndef CXMAINWINDOW_H_
34 #define CXMAINWINDOW_H_
35 
36 #include "cxGuiExport.h"
37 
38 #include <QMainWindow>
39 #include <map>
40 #include <set>
41 #include "boost/shared_ptr.hpp"
42 #include "cxGUIExtenderService.h"
43 #include <QPointer>
45 
46 class QAction;
47 class QMenu;
48 class QActionGroup;
49 class QDockWidget;
50 class QScrollArea;
51 
52 namespace cx
53 {
54 class LayoutData;
55 class GUIExtenderService;
56 class ConsoleWidget;
58 
59 typedef boost::shared_ptr<class CameraControl> CameraControlPtr;
60 typedef boost::shared_ptr<class LayoutInteractor> LayoutInteractorPtr;
61 typedef boost::shared_ptr<class VisServices> VisServicesPtr;
62 typedef boost::shared_ptr<class ProcessWrapper> ProcessWrapperPtr;
63 
64 
76 class cxGui_EXPORT MainWindow: public QMainWindow
77 {
78  Q_OBJECT
79 
80 public:
81  MainWindow(std::vector<GUIExtenderServicePtr> guiExtenders=std::vector<GUIExtenderServicePtr>());
82  virtual ~MainWindow();
83 
84  virtual QMenu* createPopupMenu();
85 
86 protected slots:
87  void patientChangedSlot();
88 
89  //application menu
90  void aboutSlot();
91  void preferencesSlot();
92  void quitSlot();
93  void toggleFullScreenSlot();
94 
95  // File menu
96  void newPatientSlot();
97  void loadPatientFileSlot();
98  void savePatientFileSlot();
99  void clearPatientSlot();
100 
101  void showControlPanelActionSlot();
102  void showSecondaryViewLayoutWindowActionSlot();
103 
104  // application
105  void onApplicationStateChangedSlot();
106 
107  //workflow
108  void onWorkflowStateChangedSlot();
109  void saveDesktopSlot();
110  void resetDesktopSlot();
111 
112  //data menu
113  void exportDataSlot();
114  void importDataSlot();
115  void deleteDataSlot();
116 
117  void togglePointPickerActionSlot();
118  void updatePointPickerActionSlot();
119 
120  //tool menu
121  void configureSlot();
122 
123  // navigation
124  void centerToImageCenterSlot();
125  void centerToTooltipSlot();
126 
127  void updateTrackingActionSlot();
128  void toggleTrackingSlot();
129  void toggleStreamingSlot();
130  void updateStreamingActionSlot();
131 
132  void shootScreen();
133  void shootWindow();
134  void recordFullscreen();
135 
136  void onStartLogConsole();
137  void dockWidgetVisibilityChanged(bool val);
138  void focusChanged(QWidget * old, QWidget * now);
139 
140  void onPluginBaseAdded(GUIExtenderService* service);
141  void onPluginBaseRemoved(GUIExtenderService* service);
142  void onPluginBaseModified(GUIExtenderService* service);
143 
144 protected:
145  void changeEvent(QEvent * event);
146 
147 private:
148  void focusInsideDockWidget(QObject* dockWidget);
149  LayoutInteractorPtr mLayoutInteractor;
150  void saveScreenShot(QPixmap pixmap, QString id="");
151  void saveScreenShotThreaded(QImage pixmap, QString filename);
152  void updateWindowTitle();
153  void createActions();
154  void createMenus();
155  void createToolBars();
156 
157  void registerToolBar(QToolBar* toolbar, QString groupname = "");
158  void addToWidgetGroupMap(QAction* action, QString groupname);
159  void addGUIExtender(GUIExtenderService* service);
160  QWidget *addCategorizedWidget(GUIExtenderService::CategorizedWidget categorizedWidget);
161  void removeGUIExtender(GUIExtenderService* service);
162  void setupGUIExtenders();
163 
164  void closeEvent(QCloseEvent *event);
165  QDockWidget* addAsDockWidget(QWidget* widget, QString groupname);
166  QString getExistingSessionFolder();
167 
168  //menus
169  QMenu* mFileMenu;
170  QMenu* mWorkflowMenu;
171  QMenu* mToolMenu;
172  QMenu* mLayoutMenu;
173  QMenu* mNavigationMenu;
174  QMenu* mHelpMenu;
175  QAction* mHelpMenuAction;
176 
177  //actions and actiongroups
178  QAction* mAboutAction;
179  QAction* mPreferencesAction;
180  QAction* mStartLogConsoleAction;
181  QAction* mFullScreenAction;
182  QAction* mQuitAction;
183 
184  QAction* mShootScreenAction;
185  QAction* mShootWindowAction;
186  QAction* mRecordFullscreenAction;
187 
188  QAction* mNewPatientAction;
189  QAction* mLoadFileAction;
190  QAction* mSaveFileAction;
191  QAction* mClearPatientAction;
192  QAction* mExportPatientAction;
193  QAction* mShowControlPanelAction;
194  QAction* mSecondaryViewLayoutWindowAction;
195 
196  QActionGroup* mStandard3DViewActions;
197  QAction* mShowPointPickerAction;
198 
199  QAction* mImportDataAction;
200  QAction* mDeleteDataAction;
201 
202  QAction* mConfigureToolsAction;
203  QAction* mInitializeToolsAction;
204  QAction* mTrackingToolsAction;
205 // QAction* mSaveToolsPositionsAction; ///< action for saving the tool positions
206  QAction* mStartStreamingAction;
207  QActionGroup* mToolsActionGroup;
208 
209  // actions for image navigation
210  QAction* mCenterToImageCenterAction;
211  QAction* mCenterToTooltipAction;
212  QActionGroup* mInteractorStyleActionGroup;
213 
214  //desktop actions
215  QAction* mSaveDesktopAction;
216  QAction* mResetDesktopAction;
217 
218  //toolbars
219  QToolBar* mDataToolBar;
220  QToolBar* mToolToolBar;
221  QToolBar* mNavigationToolBar;
222  QToolBar* mInteractorStyleToolBar;
223  QToolBar* mWorkflowToolBar;
224  QToolBar* mDesktopToolBar;
225  QToolBar* mHelpToolBar;
226  QToolBar* mScreenshotToolBar;
227 
228  std::map<QString, QActionGroup*> mWidgetGroupsMap;
229 
230  QString mLastImportDataFolder;
231 
232  boost::shared_ptr<ServiceTrackerListener<GUIExtenderService> > mServiceListener;
233  std::map<GUIExtenderService*, std::vector<QWidget*> > mWidgetsByPlugin;
234 
235  //widgets
236  QPointer<class SecondaryMainWindow> mControlPanel;
237  QPointer<class SecondaryViewLayoutWindow> mSecondaryViewLayoutWindow;
238  ProcessWrapperPtr mLocalVideoServerProcess;
239 
240  DockWidgets* mDockWidgets;
241  std::set<QToolBar*> mToolbars;
242 
243  VisServicesPtr mServices;
244 };
245 
246 }//namespace cx
247 
248 #endif /* CXMAINWINDOW_H_ */
boost::shared_ptr< class VisServices > VisServicesPtr
Definition: cxMainWindow.h:61
This is the main gui class which controls the workflow.
Definition: cxMainWindow.h:76
Handles dock widgets for main window.
Definition: cxDockWidgets.h:25
boost::shared_ptr< class LayoutInteractor > LayoutInteractorPtr
boost::shared_ptr< class ProcessWrapper > ProcessWrapperPtr
Definition: cxMainWindow.h:62
boost::shared_ptr< class CameraControl > CameraControlPtr
Definition: cxMainWindow.h:57