WMainWindow.h 9.51 KB
Newer Older
1 2
//---------------------------------------------------------------------------
//
3
// Project: OpenWalnut ( http://www.openwalnut.org )
4
//
5 6
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
wiebel's avatar
wiebel committed
7
//
wiebel's avatar
wiebel committed
8
// This file is part of OpenWalnut.
wiebel's avatar
wiebel committed
9
//
wiebel's avatar
wiebel committed
10
// OpenWalnut is free software: you can redistribute it and/or modify
wiebel's avatar
wiebel committed
11 12 13 14
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
wiebel's avatar
wiebel committed
15
// OpenWalnut is distributed in the hope that it will be useful,
wiebel's avatar
wiebel committed
16 17 18 19 20
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
wiebel's avatar
wiebel committed
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
wiebel's avatar
wiebel committed
22
//
23
//---------------------------------------------------------------------------
wiebel's avatar
wiebel committed
24

25 26
#ifndef WMAINWINDOW_H
#define WMAINWINDOW_H
27

28
#include <map>
29 30
#include <string>
#include <vector>
Sebastian Eichelbaum's avatar
Sebastian Eichelbaum committed
31

32 33
//#include <boost/program_options.hpp>
//#include <boost/shared_ptr.hpp>
Sebastian Eichelbaum's avatar
[STYLE]  
Sebastian Eichelbaum committed
34
#include <boost/signals2/signal.hpp>
35
#include <boost/thread.hpp>
Sebastian Eichelbaum's avatar
Sebastian Eichelbaum committed
36

37 38
#include <QtGui/QMainWindow>

Mathias Goldau's avatar
Mathias Goldau committed
39
#include "WIconManager.h"
40
#include "WQtToolBar.h"
41
#include "WQtGLWidget.h"
42
#include "networkEditor/WQtNetworkEditor.h"
43
#include "commandPrompt/WQtCommandPromptToolbar.h"
44

45
// forward declarations
46
class QMenuBar;
47 48 49 50 51 52
class WModule;
class WProjectFileIO;
class WQtCombinerToolbar;
class WQtControlPanel;
class WQtCustomDockWidget;
class WQtNavGLWidget;
53
class WQtPropertyBoolAction;
54 55
class WPropertyBase;
class WQtControlPanel;
56

57
/**
Mathias Goldau's avatar
Mathias Goldau committed
58
 * This class contains the main window and the layout of the widgets within the window.
wiebel's avatar
wiebel committed
59
 * \ingroup gui
60
 */
61
class WMainWindow : public QMainWindow
62
{
63 64
    Q_OBJECT

65
public:
66 67 68
    /**
     * Constructor of the main window
     */
69 70 71 72 73 74
    WMainWindow();

    /**
     * Destructor. Stores window state.
     */
    virtual ~WMainWindow();
wiebel's avatar
wiebel committed
75

76 77 78
    /**
     * Set up all widgets menus an buttons in the main window.
     */
79
    void setupGUI();
wiebel's avatar
wiebel committed
80

81 82 83 84
    /**
     * returns a pointer to the network editor object
     */
    WQtNetworkEditor* getNetworkEditor();
85

86
    /**
87
     * returns a pointer to the control panel object
88
     */
89
    WQtControlPanel* getControlPanel();
90

91 92 93 94 95
    /**
     * Return icon manager
     */
    WIconManager* getIconManager();

96
    /**
schurade's avatar
schurade committed
97
     * Returns a pointer to a signal object which signals a list of filenames to load
98
     *
schurade's avatar
schurade committed
99
     * \return the signal
100
     */
schurade's avatar
schurade committed
101 102
    boost::signals2::signal1< void, std::vector< std::string > >* getLoaderSignal();

103 104 105 106 107 108 109 110 111
    /**
     * Searches for a custom dock widget with a given name and returns it, if
     * found.
     *
     * \param name the name of the widget
     * \returns a shared pointer to the widget or NULL if not found
     */
    boost::shared_ptr< WQtCustomDockWidget > getCustomDockWidget( std::string name );

112 113 114 115 116 117 118
    /**
     * Close one of the custom dock widget saved in the map of customDockWidgets
     *
     * \param title the title of the widget to close
     */
    void closeCustomDockWidget( std::string title );

119 120 121 122 123 124 125 126
    /**
     * This method returns the default style for ALL toolbars.
     *
     * \return the toolbar style
     */
    Qt::ToolButtonStyle getToolbarStyle() const;

    /**
127
     * This method removes the old compatibles toolbar and sets the specified one.
128
     *
129
     * \param toolbar the toolbar to set. If NULL, the toolbar gets reset.
130
     */
131
    void setCompatiblesToolbar( WQtCombinerToolbar* toolbar = NULL );
132

133 134 135 136 137 138 139
    /**
     * This method returns the a pointer to the current compatibles toolbar.
     *
     * \return a pointer to the current compatibles toolbar.
     */
    WQtCombinerToolbar* getCompatiblesToolbar();

140 141
protected:

142 143 144 145 146 147
    /**
     * Setup the GUI by handling special modules. NavSlices for example setup several toolbar buttons.
     *
     * \param module the module to setup the GUI for.
     */
    void moduleSpecificSetup( boost::shared_ptr< WModule > module );
148 149 150 151 152 153
    /**
     * Cleanup the GUI by handling special modules. NavSlices for example remove several toolbar buttons.
     *
     * \param module the module to setup the GUI for.
     */
    void moduleSpecificCleanup( boost::shared_ptr< WModule > module );
154

155 156
    /**
     * We want to react on close events.
157
     *
158 159 160 161
     * \param e the close event.
     */
    void closeEvent( QCloseEvent* e );

162 163
    /**
     * Handle custom events.
164
     * Currently only WOpenCustomDockWidgetEvent.
165 166 167 168 169
     *
     * \param event the custom event
     */
    virtual void customEvent( QEvent* event );

170 171 172 173 174 175 176 177 178 179 180
    /**
     * Custom event dispatcher. Gets called by QT's Event system every time an event got sent to this widget. This event handler
     * processes several custom events, like WModuleAssocEvent.
     *
     * \note QT Doc says: use event() for custom events.
     * \param event the event that got transmitted.
     *
     * \return true if the event got handled properly.
     */
    virtual bool event( QEvent* event );

181 182 183 184 185 186 187
    /**
     * Called for each project save request.
     *
     * \param writer the list of writers to use.
     */
    virtual void projectSave( const std::vector< boost::shared_ptr< WProjectFileIO > >& writer );

188
public slots:
189
    /**
190
     * gets called when menu option or toolbar button load is activated
191
     */
192 193
    void openLoadDialog();

194 195 196 197 198
    /**
     * gets called when menu entry "About OpenWalnut" is activated
     */
    void openAboutDialog();

199 200 201 202 203 204
    /**
     * Gets called when menu entry "About Qt" is activated
     */
    void openAboutQtDialog();

    /**
205
     * Gets called when menu entry "OpenWalnut Help" is activated
206
     */
207
    void openOpenWalnutHelpDialog();
208

209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
    /**
     * Sets the left preset view of the main viewer.
     */
    void setPresetViewLeft();

    /**
     * Sets the right preset view of the main viewer.
     */
    void setPresetViewRight();

    /**
     * Sets the superior preset view of the main viewer.
     */
    void setPresetViewSuperior();

    /**
     * Sets the inferior preset view of the main viewer.
     */
    void setPresetViewInferior();

    /**
     * Sets the anterior preset view of the main viewer.
     */
    void setPresetViewAnterior();

    /**
     * Sets the posterior preset view of the main viewer.
     */
    void setPresetViewPosterior();

239 240 241 242 243
    /**
     * Gets called when a menu entry that has no functionality yet is activated.
     */
    void openNotImplementedDialog();

schurade's avatar
schurade committed
244 245 246 247 248
    /**
     * gets called when the button new roi is pressed
     */
    void newRoi();

249 250 251 252 253
    /**
     * Gets called whenever the user presses the project button.
     */
    void projectLoad();

254 255 256
    /**
     * Gets called whenever the user presses the project save button.
     */
257 258 259 260 261 262 263 264 265 266 267
    void projectSaveAll();

    /**
     * Gets called by the save menu to only save the camera settings
     */
    void projectSaveCameraOnly();

    /**
     * Gets called by the save menu to only save the ROI settings
     */
    void projectSaveROIOnly();
268

269 270 271 272 273
    /**
     * Gets called by the save menu to only save the Module settings
     */
    void projectSaveModuleOnly();

274
    /**
275 276
     * Gets called when menu option or toolbar button load is activated
     */
277
    void openConfigDialog();
278

279
private:
280
    /**
281
     * Sets up the permanent tool bar.
282
     */
283
    void setupPermanentToolBar();
284

285
    /**
286
     * The currently set compatibles toolbar
287
     */
288
    WQtCombinerToolbar* m_currentCompatiblesToolbar;
289

schurade's avatar
schurade committed
290
    WIconManager m_iconManager; //!< manager to provide icons in the gui thread
291

292 293 294
    QMenuBar* m_menuBar; //!< The main menu bar of the GUI.

    WQtToolBar* m_permanentToolBar; //!< The permanent toolbar of the main window.
wiebel's avatar
wiebel committed
295

296 297
    WQtPushButton* m_loadButton; //!< the load Data Button

298
    WQtControlPanel* m_controlPanel; //!< control panel
wiebel's avatar
wiebel committed
299

300 301
    WQtNetworkEditor* m_networkEditor; //!< network editor

302 303
    WQtCommandPromptToolbar* m_commandPrompt; //!< command prompt

304
    boost::shared_ptr< WQtGLWidget > m_mainGLWidget; //!< the main GL widget of the GUI
305 306 307
    boost::shared_ptr< WQtNavGLWidget > m_navAxial; //!< the axial view widget GL widget of the GUI
    boost::shared_ptr< WQtNavGLWidget > m_navCoronal; //!< the coronal view widget GL widget of the GUI
    boost::shared_ptr< WQtNavGLWidget > m_navSagittal; //!< the sgittal view widget GL widget of the GUI
Mathias Goldau's avatar
[MERGE]  
Mathias Goldau committed
308
    QDockWidget* m_dummyWidget; //!< The dummywidget serves as spacer in the dockwidget area;
309

310 311 312 313 314 315 316 317 318 319
    /**
     * All registered WQtCustomDockWidgets.
     */
    std::map< std::string, boost::shared_ptr< WQtCustomDockWidget > > m_customDockWidgets;

    /**
     * Mutex used to lock the map of WQtCustomDockWidgets.
     */
    boost::mutex m_customDockWidgetsLock;

schurade's avatar
schurade committed
320
    boost::signals2::signal1< void, std::vector< std::string > > m_loaderSignal; //!< boost signal for open file dialog
321

322 323 324 325 326 327 328
    /**
     * Combine a module with a prototype only if the module is available. Else, nothing happens.
     *
     * \param module the module to be combined.
     * \param proto the prototype to combine with the module.
     */
    void autoAdd( boost::shared_ptr< WModule > module, std::string proto );
329 330 331 332 333 334

    /**
     * Map holding the actions for module properties added automatically. So they can be removed again automatically
     * if the module is removed.
     */
    std::map< boost::shared_ptr< WPropertyBase >, WQtPropertyBoolAction* > propertyActionMap;
335 336 337 338 339 340 341 342 343 344

    /**
     * Loads the window states and geometries from a file.
     */
    void restoreSavedState();

    /**
     * Saves the current window states and geometries to a file.
     */
    void saveWindowState();
345 346
};

347
#endif  // WMAINWINDOW_H