~ubuntu-branches/ubuntu/raring/openwalnut/raring

« back to all changes in this revision

Viewing changes to src/qt4gui/qt4/WMainWindow.h

  • Committer: Package Import Robot
  • Author(s): Sebastian Eichelbaum
  • Date: 2012-12-12 11:26:32 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20121212112632-xhiuwkxuz5h0idkh
Tags: 1.3.1+hg5849-1
* Minor changes compared to 1.3.0 but included several bug fixes.
* See http://www.openwalnut.org/versions/4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//---------------------------------------------------------------------------
2
 
//
3
 
// Project: OpenWalnut ( http://www.openwalnut.org )
4
 
//
5
 
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
 
// For more information see http://www.openwalnut.org/copying
7
 
//
8
 
// This file is part of OpenWalnut.
9
 
//
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.
14
 
//
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.
19
 
//
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/>.
22
 
//
23
 
//---------------------------------------------------------------------------
24
 
 
25
 
#ifndef WMAINWINDOW_H
26
 
#define WMAINWINDOW_H
27
 
 
28
 
#include <map>
29
 
#include <string>
30
 
#include <vector>
31
 
 
32
 
//#include <boost/program_options.hpp>
33
 
//#include <boost/shared_ptr.hpp>
34
 
#include <boost/signals2/signal.hpp>
35
 
#include <boost/thread.hpp>
36
 
 
37
 
#include <QtGui/QMainWindow>
38
 
#include <QtCore/QSettings>
39
 
 
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"
46
 
 
47
 
// forward declarations
48
 
class QMenuBar;
49
 
class WModule;
50
 
class WProjectFileIO;
51
 
class WQtCombinerToolbar;
52
 
class WQtControlPanel;
53
 
class WQtCustomDockWidget;
54
 
class WQtNavGLWidget;
55
 
class WQtGLDockWidget;
56
 
class WQtPropertyBoolAction;
57
 
class WPropertyBase;
58
 
class WQtControlPanel;
59
 
 
60
 
/**
61
 
 * This class contains the main window and the layout of the widgets within the window.
62
 
 * \ingroup gui
63
 
 */
64
 
class WMainWindow : public QMainWindow
65
 
{
66
 
    Q_OBJECT
67
 
 
68
 
public:
69
 
    /**
70
 
     * Constructor of the main window
71
 
     */
72
 
    WMainWindow();
73
 
 
74
 
    /**
75
 
     * Destructor. Stores window state.
76
 
     */
77
 
    virtual ~WMainWindow();
78
 
 
79
 
    /**
80
 
     * Set up all widgets menus an buttons in the main window.
81
 
     */
82
 
    void setupGUI();
83
 
 
84
 
    /**
85
 
     * Returns a pointer to the network editor object.
86
 
     *
87
 
     * \return the network editor instance
88
 
     */
89
 
    WQtNetworkEditor* getNetworkEditor();
90
 
 
91
 
    /**
92
 
     * Returns a pointer to the control panel object.
93
 
     *
94
 
     * \return the control panel instance
95
 
     */
96
 
    WQtControlPanel* getControlPanel();
97
 
 
98
 
    /**
99
 
     * Return icon manager
100
 
     *
101
 
     * \return the icon manager instance
102
 
     */
103
 
    WIconManager* getIconManager();
104
 
 
105
 
    /**
106
 
     * Returns a pointer to a signal object which signals a list of filenames to load
107
 
     *
108
 
     * \return the signal
109
 
     */
110
 
    boost::signals2::signal1< void, std::vector< std::string > >* getLoaderSignal();
111
 
 
112
 
    /**
113
 
     * Searches for a custom dock widget with a given name and returns it, if
114
 
     * found.
115
 
     *
116
 
     * \param name the name of the widget
117
 
     * \returns a shared pointer to the widget or NULL if not found
118
 
     */
119
 
    boost::shared_ptr< WQtCustomDockWidget > getCustomDockWidget( std::string name );
120
 
 
121
 
    /**
122
 
     * Close one of the custom dock widget saved in the map of customDockWidgets
123
 
     *
124
 
     * \param title the title of the widget to close
125
 
     */
126
 
    void closeCustomDockWidget( std::string title );
127
 
 
128
 
    /**
129
 
     * This method removes the old compatibles toolbar and sets the specified one.
130
 
     *
131
 
     * \param toolbar the toolbar to set. If NULL, the toolbar gets reset.
132
 
     */
133
 
    void setCompatiblesToolbar( WQtCombinerToolbar* toolbar = NULL );
134
 
 
135
 
    /**
136
 
     * This method returns the a pointer to the current compatibles toolbar.
137
 
     *
138
 
     * \return a pointer to the current compatibles toolbar.
139
 
     */
140
 
    WQtCombinerToolbar* getCompatiblesToolbar();
141
 
 
142
 
    /**
143
 
     * Returns the settings object.
144
 
     *
145
 
     * \return settings object.
146
 
     */
147
 
    static QSettings& getSettings();
148
 
 
149
 
protected:
150
 
 
151
 
    /**
152
 
     * Setup the GUI by handling special modules. NavSlices for example setup several toolbar buttons.
153
 
     *
154
 
     * \param module the module to setup the GUI for.
155
 
     */
156
 
    void moduleSpecificSetup( boost::shared_ptr< WModule > module );
157
 
    /**
158
 
     * Cleanup the GUI by handling special modules. NavSlices for example remove several toolbar buttons.
159
 
     *
160
 
     * \param module the module to setup the GUI for.
161
 
     */
162
 
    void moduleSpecificCleanup( boost::shared_ptr< WModule > module );
163
 
 
164
 
    /**
165
 
     * We want to react on close events.
166
 
     *
167
 
     * \param e the close event.
168
 
     */
169
 
    virtual void closeEvent( QCloseEvent* e );
170
 
 
171
 
    /**
172
 
     * Handle custom events.
173
 
     * Currently only WOpenCustomDockWidgetEvent.
174
 
     *
175
 
     * \param event the custom event
176
 
     */
177
 
    virtual void customEvent( QEvent* event );
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
181
 
     * processes several custom events, like WModuleAssocEvent.
182
 
     *
183
 
     * \note QT Doc says: use event() for custom events.
184
 
     * \param event the event that got transmitted.
185
 
     *
186
 
     * \return true if the event got handled properly.
187
 
     */
188
 
    virtual bool event( QEvent* event );
189
 
 
190
 
    /**
191
 
     * Called for each project save request.
192
 
     *
193
 
     * \param writer the list of writers to use.
194
 
     */
195
 
    virtual void projectSave( const std::vector< boost::shared_ptr< WProjectFileIO > >& writer );
196
 
 
197
 
public slots:
198
 
    /**
199
 
     * gets called when menu option or toolbar button load is activated
200
 
     */
201
 
    void openLoadDialog();
202
 
 
203
 
    /**
204
 
     * gets called when menu entry "About OpenWalnut" is activated
205
 
     */
206
 
    void openAboutDialog();
207
 
 
208
 
    /**
209
 
     * Gets called when menu entry "About Qt" is activated
210
 
     */
211
 
    void openAboutQtDialog();
212
 
 
213
 
    /**
214
 
     * Gets called when menu entry "OpenWalnut Help" is activated
215
 
     */
216
 
    void openOpenWalnutHelpDialog();
217
 
 
218
 
    /**
219
 
     * Sets the left preset view of the main viewer.
220
 
     */
221
 
    void setPresetViewLeft();
222
 
 
223
 
    /**
224
 
     * Sets the right preset view of the main viewer.
225
 
     */
226
 
    void setPresetViewRight();
227
 
 
228
 
    /**
229
 
     * Sets the superior preset view of the main viewer.
230
 
     */
231
 
    void setPresetViewSuperior();
232
 
 
233
 
    /**
234
 
     * Sets the inferior preset view of the main viewer.
235
 
     */
236
 
    void setPresetViewInferior();
237
 
 
238
 
    /**
239
 
     * Sets the anterior preset view of the main viewer.
240
 
     */
241
 
    void setPresetViewAnterior();
242
 
 
243
 
    /**
244
 
     * Sets the posterior preset view of the main viewer.
245
 
     */
246
 
    void setPresetViewPosterior();
247
 
 
248
 
    /**
249
 
     * Gets called when a menu entry that has no functionality yet is activated.
250
 
     */
251
 
    void openNotImplementedDialog();
252
 
 
253
 
    /**
254
 
     * gets called when the button new roi is pressed
255
 
     */
256
 
    void newRoi();
257
 
 
258
 
    /**
259
 
     * Gets called whenever the user presses the project button.
260
 
     */
261
 
    void projectLoad();
262
 
 
263
 
    /**
264
 
     * Gets called whenever the user presses the project save button.
265
 
     */
266
 
    void projectSaveAll();
267
 
 
268
 
    /**
269
 
     * Gets called by the save menu to only save the camera settings
270
 
     */
271
 
    void projectSaveCameraOnly();
272
 
 
273
 
    /**
274
 
     * Gets called by the save menu to only save the ROI settings
275
 
     */
276
 
    void projectSaveROIOnly();
277
 
 
278
 
    /**
279
 
     * Gets called by the save menu to only save the Module settings
280
 
     */
281
 
    void projectSaveModuleOnly();
282
 
 
283
 
    /**
284
 
     * Is able to handle updates in the log-level setting.
285
 
     *
286
 
     * \param logLevel the new loglevel to set
287
 
     */
288
 
    void handleLogLevelUpdate( unsigned int logLevel );
289
 
 
290
 
private:
291
 
    /**
292
 
     * The currently set compatibles toolbar
293
 
     */
294
 
    WQtCombinerToolbar* m_currentCompatiblesToolbar;
295
 
 
296
 
    WIconManager m_iconManager; //!< manager to provide icons in the gui thread
297
 
 
298
 
    QMenuBar* m_menuBar; //!< The main menu bar of the GUI.
299
 
 
300
 
    WQtToolBar* m_permanentToolBar; //!< The permanent toolbar of the main window.
301
 
 
302
 
    QAction* m_loadButton; //!< the load Data Button
303
 
 
304
 
    WQtControlPanel* m_controlPanel; //!< control panel
305
 
 
306
 
    WQtNetworkEditor* m_networkEditor; //!< network editor
307
 
 
308
 
    WQtCommandPromptToolbar* m_commandPrompt; //!< command prompt
309
 
 
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;
316
 
 
317
 
    /**
318
 
     * All registered WQtCustomDockWidgets.
319
 
     */
320
 
    std::map< std::string, boost::shared_ptr< WQtCustomDockWidget > > m_customDockWidgets;
321
 
 
322
 
    /**
323
 
     * Mutex used to lock the map of WQtCustomDockWidgets.
324
 
     */
325
 
    boost::mutex m_customDockWidgetsLock;
326
 
 
327
 
    boost::signals2::signal1< void, std::vector< std::string > > m_loaderSignal; //!< boost signal for open file dialog
328
 
 
329
 
    /**
330
 
     * Combine a module with a prototype only if the module is available. Else, nothing happens.
331
 
     *
332
 
     * \param module the module to be combined.
333
 
     * \param proto the prototype to combine with the module.
334
 
     */
335
 
    void autoAdd( boost::shared_ptr< WModule > module, std::string proto );
336
 
 
337
 
    bool m_navSlicesAlreadyLoaded; //!< if true, the navslices have been loaded already
338
 
 
339
 
    /**
340
 
     * Loads the window states and geometries from a file.
341
 
     */
342
 
    void restoreSavedState();
343
 
 
344
 
    /**
345
 
     * Saves the current window states and geometries to a file.
346
 
     */
347
 
    void saveWindowState();
348
 
 
349
 
    /**
350
 
     * The action controlling the auto-display feature.
351
 
     */
352
 
    WSettingAction* m_autoDisplaySetting;
353
 
 
354
 
private slots:
355
 
    /**
356
 
     * Handles some special GL vendors and shows the user a dialog.
357
 
     */
358
 
    void handleGLVendor();
359
 
 
360
 
    /**
361
 
     * Shows startup info messages
362
 
     */
363
 
    void handleStartMessages();
364
 
};
365
 
 
366
 
#endif  // WMAINWINDOW_H