WMainWindow.h 8.21 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

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

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

37
#include <QtGui/QIcon>
38
#include <QtGui/QMainWindow>
39
#include <QtGui/QSlider>
40
#include <QtGui/QWidget>
41
#include <QtGui/QCloseEvent>
42

43
#include "WQtNavGLWidget.h"
44
#include "WQtConfigWidget.h"
45
#include "ribbonMenu/WQtRibbonMenu.h"
46
#include "WQtCustomDockWidget.h"
47
#include "WQtToolBar.h"
48
#include "WQtCombinerToolbar.h"
49

50
#include "WIconManager.h"
51
#include "datasetbrowser/WQtDatasetBrowser.h"
52 53

#include "../../kernel/WModule.h"
54
#include "../../common/WProjectFileIO.h"
55

56
// forward declarations
57
class QMenuBar;
58
class WQtGLWidget;
59

60 61 62
/**
 * This class contains the main window and the layout
 * of the widgets within the window.
wiebel's avatar
wiebel committed
63
 * \ingroup gui
64
 */
65
class WMainWindow : public QMainWindow
66
{
67 68
    Q_OBJECT

69
public:
70 71 72
    /**
     * Constructor of the main window
     */
73
    explicit WMainWindow();
wiebel's avatar
wiebel committed
74

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

80
    /**
81
     * returns a pointer to the dataset browser object
82 83 84
     */
    WQtDatasetBrowser* getDatasetBrowser();

85
    /**
86
     *  returns a pointer to the ribbon menu object
87
     */
88
    WQtRibbonMenu* getRibbonMenu();
89

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

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

102 103 104 105 106 107 108 109 110
    /**
     * 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 );

111 112 113 114 115 116 117
    /**
     * 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 );

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

125 126 127 128 129 130 131
    /**
     * Returns the preferred position of toolbars.
     *
     * \return QT Position for the toolbars used as default for all toolbars.
     */
    static Qt::ToolBarArea getToolbarPos();

132
    /**
133
     * This method removes the old compatibles toolbar and sets the specified one.
134
     *
135
     * \param toolbar the toolbar to set. If NULL, the toolbar gets reset.
136
     */
137
    void setCompatiblesToolbar( WQtCombinerToolbar* toolbar = NULL );
138

139 140
protected:

141 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
    /**
     * We want to react on close events.
150
     *
151 152 153 154
     * \param e the close event.
     */
    void closeEvent( QCloseEvent* e );

155 156
    /**
     * Handle custom events.
157
     * Currently only WOpenCustomDockWidgetEvent.
158 159 160 161 162
     *
     * \param event the custom event
     */
    virtual void customEvent( QEvent* event );

163 164 165 166 167 168 169 170 171 172 173
    /**
     * 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 );

174 175 176 177 178 179 180
    /**
     * 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 );

181
public slots:
182
    /**
183
     * gets called when menu option or toolbar button load is activated
184
     */
185 186
    void openLoadDialog();

187 188 189 190 191
    /**
     * gets called when menu entry "About OpenWalnut" is activated
     */
    void openAboutDialog();

192 193 194 195 196
    /**
     * Gets called when a menu entry that has no functionality yet is activated.
     */
    void openNotImplementedDialog();

schurade's avatar
schurade committed
197 198 199 200 201
    /**
     * gets called when the button new roi is pressed
     */
    void newRoi();

202 203 204 205 206
    /**
     * Gets called whenever the user presses the project button.
     */
    void projectLoad();

207 208 209
    /**
     * Gets called whenever the user presses the project save button.
     */
210 211 212 213 214 215 216 217 218 219 220
    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();
221

222 223 224 225 226
    /**
     * Gets called by the save menu to only save the Module settings
     */
    void projectSaveModuleOnly();

227 228 229 230 231
    /**
     * Sets that a fiber data set has already been loaded. Thi shelps to prevent multiple fiber data sets to be loaded.
     */
    void setFibersLoaded();

232
    /**
233 234
     * Gets called when menu option or toolbar button load is activated
     */
235
    void openConfigDialog();
236

237
private:
238
    /**
239
     * Sets up the permanent tool bar.
240
     */
241
    void setupPermanentToolBar();
242

243
    /**
244
     * The currently set compatibles toolbar
245
     */
246
    WQtCombinerToolbar* m_currentCompatiblesToolbar;
247

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

250 251 252
    QMenuBar* m_menuBar; //!< The main menu bar of the GUI.

    QWidget* m_centralwidget; //!< the central widget of the docking facility. This can not be moved.
schurade's avatar
schurade committed
253

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

schurade's avatar
schurade committed
256
    WQtDatasetBrowser* m_datasetBrowser; //!< dataset browser
wiebel's avatar
wiebel committed
257

258 259 260 261
    boost::shared_ptr<WQtGLWidget> m_mainGLWidget; //!< the main GL widget of the GUI
    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
262
    QDockWidget* m_dummyWidget; //!< The dummywidget serves as spacer in the dockwidget area;
263

264 265 266
    /**
    * shared pointer for the configuration widget
    */
267 268
    boost::shared_ptr< WQtConfigWidget > m_configWidget;

269 270
    bool m_fibLoaded; //!< Indicates whether a fiber data set is already loaded.

271 272 273 274 275 276 277 278 279 280
    /**
     * 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
281
    boost::signals2::signal1< void, std::vector< std::string > > m_loaderSignal; //!< boost signal for open file dialog
282

283 284 285 286 287 288 289
    /**
     * 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 );
290 291
};

292
#endif  // WMAINWINDOW_H