mainwindow.h 8.3 KB
Newer Older
1
2
// ================================================================================================
// 
schultezub's avatar
schultezub committed
3
// This file is part of the CAMPVis Software Framework.
4
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
schultezub's avatar
schultezub committed
6
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
7
//      Chair for Computer Aided Medical Procedures
8
9
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
10
// 
schultezub's avatar
schultezub committed
11
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
12
// 
13
14
15
16
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 
// except in compliance with the License. You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
17
// 
18
19
20
21
// Unless required by applicable law or agreed to in writing, software distributed under the 
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific language governing permissions 
// and limitations under the License.
22
23
24
// 
// ================================================================================================

schultezub's avatar
schultezub committed
25
26
#ifndef CAMPVISMAINWINDOW_H__
#define CAMPVISMAINWINDOW_H__
27
28

#include "sigslot/sigslot.h"
schultezub's avatar
schultezub committed
29
#include "application/campvisapplication.h"
30
#include "application/gui/mdi/mdidockarea.h"
31
#include "application/gui/pipelinetreewidget.h"
schultezub's avatar
schultezub committed
32
#include "application/gui/properties/propertycollectionwidget.h"
33
#include "application/gui/logviewerwidget.h"
34
#include "application/gui/scriptingwidget.h"
35
36
#include "application/tools/qtexteditlog.h"
#include "application/ui_mainwindow.h"
37
38

#include <QMainWindow>
39
40
#include <QVBoxLayout>
#include <QHBoxLayout>
41
#include <QPushButton>
Christian Schulte zu Berge's avatar
Christian Schulte zu Berge committed
42
#include <QComboBox>
43
#include <QScrollArea>
44
45
#include <vector>

schultezub's avatar
schultezub committed
46
namespace campvis {
47
    class DataContainerInspectorWidget;
48
    class DataContainerInspectorCanvas;
49
    class MdiDockableWindow;
50

schultezub's avatar
schultezub committed
51
    /**
schultezub's avatar
schultezub committed
52
     * Main Window for the CAMPVis application.
53
     * Wraps a nice Qt GUI around the CampVisApplication instance given during creation.
schultezub's avatar
schultezub committed
54
     */
55
    class MainWindow : public QMainWindow, public sigslot::has_slots {
56
        Q_OBJECT
57
58

    public:
schultezub's avatar
schultezub committed
59
60
        /**
         * Creates a new TumVis Main window for \a application.
61
         * \param   application     CampVisApplication to create a GUI for.
schultezub's avatar
schultezub committed
62
         */
63
        explicit MainWindow(CampVisApplication* application);
64

schultezub's avatar
schultezub committed
65
66
67
        /**
         * Destructor, make sure to call before destroying the application
         */
68
69
        ~MainWindow();

70
71
72
73
74
75
76
77
78
79
        
        /**
         * Initializes all OpenGL related stuff
         */
        void init();

        /**
         * Deinitializes all OpenGL related stuff
         */
        void deinit();
80

81
82
83
84
        /**
         * Size hint for the default window size
         * \return QSize(800, 450)
         */
85
86
        QSize sizeHint() const;

87
88
        /**
         * Adds a widget of a visualization pipeline to the main window.
89
90
         * \param   name       the name of the visualization pipeline
         * \param   canvas     the pipeline's canvas
91
         */
92
        MdiDockableWindow * addVisualizationPipelineWidget(const std::string& name, QWidget* canvas);
93

94
95
96
97
98
99
100
101
    protected:
        /**
         * Listens to resize events on _pipelinePropertiesWidget and resizes _pipelinePropertiesScrollArea accordingly
         * \param   watched    the object that caused the event
         * \param   event      the event to be filtered
         */
        bool eventFilter(QObject* watched, QEvent* event);

102
    signals:
103
        /// Qt signal for updating the PipelineWidget.
104
105
        void updatePipelineWidget(const std::vector<DataContainer*>&, const std::vector<AbstractPipeline*>&);

106
        /// Qt signal for updating the PropertyCollectionWidget
107
        void updatePropCollectionWidget(HasPropertyCollection*, DataContainer*);
108

109
    public slots:
110
111
112
113
114
        /**
         * Slot to be called by the PipelineWidget when the selected item changes.
         * \param   index   Index of the selected item
         */
        void onPipelineWidgetItemClicked(const QModelIndex& index);
115

116
117
118
119
120
121
122
123
124
125
        /**
         * Slot to be called when _btnExecute was clicked.
         */
        void onBtnExecuteClicked();

        /**
         * Slot to be called when _btnShowDataContainerInspector was clicked.
         */
        void onBtnShowDataContainerInspectorClicked();

126
127
128
        /// Slot to be called when _btnPipelineFactory was clicked;
        void onBtnPipelineFactoryClicked();

129
130
131
        /// Slot to be called when all shaders shall be rebuilt.
        void onRebuildShadersClicked();

132
133
134
        /// Slot to be called when a Lua command shall be executed.
        void onLuaCommandExecuted(const QString& cmd);

135
    private:
136
137
138
139
140
141
142
143
144
145
146

        /**
         * Slot to be called by the application when its collection of pipelines has changed.
         */
        void onPipelinesChanged();

        /**
         * Slot to be called by the application when its collection of DataContainers has changed.
         */
        void onDataContainersChanged();

schultezub's avatar
schultezub committed
147
148
149
        /**
         * Setup Qt GUI stuff
         */
150
151
        void setup();

152
153
154
155
156
        /**
         * Create and populate the application's main menu.
         */
        void populateMainMenu();

157
158
159
160
161
162
163
164
165
166
167
168
        /**
         * Adds a widget to the top docking area of the main window.
         * This method creates a new dock with the specified name,
         * sets its widget to the given widget, and docks it in top
         * docking area of the main window. If there are already
         * other docks there, they're tabified with the new dock.
         * \param   name       the name that will be given to the created dock
         * \param   widget     the widget to add to the top docking area of the main window
         * \return  the dock created to store the provided widget
         */
        QDockWidget* dockPrimaryWidget(const std::string& name, QWidget* widget);

169
170
        Ui::MainWindow ui;                                  ///< Interface definition of the MainWindow

171
        CampVisApplication* _application;                    ///< Pointer to the application hosting the whole stuff
172

173
        MdiDockArea* _mdiArea;                              ///< MDI area (the window's central widget)
174
175
176
        QWidget* _containerWidget;                          ///< Widget to manage the app's DataContainers and pipelines
        QComboBox* _cbPipelineFactory;                      ///< Combobox for selecting the Pipelines from the PipelineFactory
        QPushButton* _btnPipelineFactory;                   ///< Button to add a Pipeline from the factory
177
        PipelineTreeWidget* _pipelineWidget;                ///< Widget for browsing the active pipelines
178
179
        QWidget* _pipelinePropertiesWidget;                 ///< Widget showing the selected pipeline's properties
        QScrollArea* _pipelinePropertiesScrollArea;         ///< Scroll area for _pipelinePropertiesWidget
180
        PropertyCollectionWidget* _propCollectionWidget;    ///< Widget for brosing the PropertyCollection of the selected pipeline/processor
181
        DataContainerInspectorWidget* _dcInspectorWidget;   ///< Widget for inspecting the DataContainer of the selected pipeline.
182
        MdiDockableWindow* _dcInspectorWindow;              ///< Window displaying the above DataContainerInspectorWidget instance.
183
184
185
186
187
188

        QPushButton* _btnExecute;                           ///< Button to execute the selected pipeline/processor
        QPushButton* _btnShowDataContainerInspector;        ///< Button to show the DataContainerInspector for the selected pipeline

        AbstractPipeline* _selectedPipeline;                ///< currently selected pipeline
        AbstractProcessor* _selectedProcessor;              ///< currently selected processor
189
190
        DataContainer* _selectedDataContainer;              ///< currently selected DataContainer

191
        LogViewerWidget* _logViewer;                        ///< Widget displaying log messages
192
193
        ScriptingWidget* _scriptingConsoleWidget;           ///< Widget showing the scripting console (if available)

194
        std::vector<QDockWidget*> _primaryDocks;            ///< Docks located in top docking area of the main window
195
196
197
    };
}

schultezub's avatar
schultezub committed
198
#endif // CAMPVISMAINWINDOW_H__