1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
23
//---------------------------------------------------------------------------
32
//#include <boost/program_options.hpp>
33
//#include <boost/shared_ptr.hpp>
34
#include <boost/signals2/signal.hpp>
35
#include <boost/thread.hpp>
37
#include <QtGui/QMainWindow>
38
#include <QtCore/QSettings>
40
#include "WIconManager.h"
41
#include "WQtToolBar.h"
42
#include "WQtGLWidget.h"
43
#include "WSettingAction.h"
44
#include "networkEditor/WQtNetworkEditor.h"
45
#include "commandPrompt/WQtCommandPromptToolbar.h"
47
// forward declarations
51
class WQtCombinerToolbar;
52
class WQtControlPanel;
53
class WQtCustomDockWidget;
55
class WQtGLDockWidget;
56
class WQtPropertyBoolAction;
58
class WQtControlPanel;
61
* This class contains the main window and the layout of the widgets within the window.
64
class WMainWindow : public QMainWindow
70
* Constructor of the main window
75
* Destructor. Stores window state.
77
virtual ~WMainWindow();
80
* Set up all widgets menus an buttons in the main window.
85
* Returns a pointer to the network editor object.
87
* \return the network editor instance
89
WQtNetworkEditor* getNetworkEditor();
92
* Returns a pointer to the control panel object.
94
* \return the control panel instance
96
WQtControlPanel* getControlPanel();
101
* \return the icon manager instance
103
WIconManager* getIconManager();
106
* Returns a pointer to a signal object which signals a list of filenames to load
110
boost::signals2::signal1< void, std::vector< std::string > >* getLoaderSignal();
113
* Searches for a custom dock widget with a given name and returns it, if
116
* \param name the name of the widget
117
* \returns a shared pointer to the widget or NULL if not found
119
boost::shared_ptr< WQtCustomDockWidget > getCustomDockWidget( std::string name );
122
* Close one of the custom dock widget saved in the map of customDockWidgets
124
* \param title the title of the widget to close
126
void closeCustomDockWidget( std::string title );
129
* This method removes the old compatibles toolbar and sets the specified one.
131
* \param toolbar the toolbar to set. If NULL, the toolbar gets reset.
133
void setCompatiblesToolbar( WQtCombinerToolbar* toolbar = NULL );
136
* This method returns the a pointer to the current compatibles toolbar.
138
* \return a pointer to the current compatibles toolbar.
140
WQtCombinerToolbar* getCompatiblesToolbar();
143
* Returns the settings object.
145
* \return settings object.
147
static QSettings& getSettings();
152
* Setup the GUI by handling special modules. NavSlices for example setup several toolbar buttons.
154
* \param module the module to setup the GUI for.
156
void moduleSpecificSetup( boost::shared_ptr< WModule > module );
158
* Cleanup the GUI by handling special modules. NavSlices for example remove several toolbar buttons.
160
* \param module the module to setup the GUI for.
162
void moduleSpecificCleanup( boost::shared_ptr< WModule > module );
165
* We want to react on close events.
167
* \param e the close event.
169
virtual void closeEvent( QCloseEvent* e );
172
* Handle custom events.
173
* Currently only WOpenCustomDockWidgetEvent.
175
* \param event the custom event
177
virtual void customEvent( QEvent* event );
180
* Custom event dispatcher. Gets called by QT's Event system every time an event got sent to this widget. This event handler
181
* processes several custom events, like WModuleAssocEvent.
183
* \note QT Doc says: use event() for custom events.
184
* \param event the event that got transmitted.
186
* \return true if the event got handled properly.
188
virtual bool event( QEvent* event );
191
* Called for each project save request.
193
* \param writer the list of writers to use.
195
virtual void projectSave( const std::vector< boost::shared_ptr< WProjectFileIO > >& writer );
199
* gets called when menu option or toolbar button load is activated
201
void openLoadDialog();
204
* gets called when menu entry "About OpenWalnut" is activated
206
void openAboutDialog();
209
* Gets called when menu entry "About Qt" is activated
211
void openAboutQtDialog();
214
* Gets called when menu entry "OpenWalnut Help" is activated
216
void openOpenWalnutHelpDialog();
219
* Sets the left preset view of the main viewer.
221
void setPresetViewLeft();
224
* Sets the right preset view of the main viewer.
226
void setPresetViewRight();
229
* Sets the superior preset view of the main viewer.
231
void setPresetViewSuperior();
234
* Sets the inferior preset view of the main viewer.
236
void setPresetViewInferior();
239
* Sets the anterior preset view of the main viewer.
241
void setPresetViewAnterior();
244
* Sets the posterior preset view of the main viewer.
246
void setPresetViewPosterior();
249
* Gets called when a menu entry that has no functionality yet is activated.
251
void openNotImplementedDialog();
254
* gets called when the button new roi is pressed
259
* Gets called whenever the user presses the project button.
264
* Gets called whenever the user presses the project save button.
266
void projectSaveAll();
269
* Gets called by the save menu to only save the camera settings
271
void projectSaveCameraOnly();
274
* Gets called by the save menu to only save the ROI settings
276
void projectSaveROIOnly();
279
* Gets called by the save menu to only save the Module settings
281
void projectSaveModuleOnly();
284
* Is able to handle updates in the log-level setting.
286
* \param logLevel the new loglevel to set
288
void handleLogLevelUpdate( unsigned int logLevel );
292
* The currently set compatibles toolbar
294
WQtCombinerToolbar* m_currentCompatiblesToolbar;
296
WIconManager m_iconManager; //!< manager to provide icons in the gui thread
298
QMenuBar* m_menuBar; //!< The main menu bar of the GUI.
300
WQtToolBar* m_permanentToolBar; //!< The permanent toolbar of the main window.
302
QAction* m_loadButton; //!< the load Data Button
304
WQtControlPanel* m_controlPanel; //!< control panel
306
WQtNetworkEditor* m_networkEditor; //!< network editor
308
WQtCommandPromptToolbar* m_commandPrompt; //!< command prompt
310
boost::shared_ptr< WQtGLWidget > m_mainGLWidget; //!< the main GL widget of the GUI
311
boost::shared_ptr< WQtNavGLWidget > m_navAxial; //!< the axial view widget GL widget of the GUI
312
boost::shared_ptr< WQtNavGLWidget > m_navCoronal; //!< the coronal view widget GL widget of the GUI
313
boost::shared_ptr< WQtNavGLWidget > m_navSagittal; //!< the sgittal view widget GL widget of the GUI
314
QMainWindow* m_glDock; //!< the dock that is used for gl widgets
315
QDockWidget* m_dummyWidget; //!< The dummywidget serves as spacer in the dockwidget area;
318
* All registered WQtCustomDockWidgets.
320
std::map< std::string, boost::shared_ptr< WQtCustomDockWidget > > m_customDockWidgets;
323
* Mutex used to lock the map of WQtCustomDockWidgets.
325
boost::mutex m_customDockWidgetsLock;
327
boost::signals2::signal1< void, std::vector< std::string > > m_loaderSignal; //!< boost signal for open file dialog
330
* Combine a module with a prototype only if the module is available. Else, nothing happens.
332
* \param module the module to be combined.
333
* \param proto the prototype to combine with the module.
335
void autoAdd( boost::shared_ptr< WModule > module, std::string proto );
337
bool m_navSlicesAlreadyLoaded; //!< if true, the navslices have been loaded already
340
* Loads the window states and geometries from a file.
342
void restoreSavedState();
345
* Saves the current window states and geometries to a file.
347
void saveWindowState();
350
* The action controlling the auto-display feature.
352
WSettingAction* m_autoDisplaySetting;
356
* Handles some special GL vendors and shows the user a dialog.
358
void handleGLVendor();
361
* Shows startup info messages
363
void handleStartMessages();
366
#endif // WMAINWINDOW_H