2.12.2021, 9:00 - 11:00: Due to updates GitLab may be unavailable for some minutes between 09:00 and 11:00.

mainwindow.h 9.38 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
#include "application/gui/workflowcontrollerwidget.h"
36
37
#include "application/tools/qtexteditlog.h"
#include "application/ui_mainwindow.h"
38
39

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

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

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

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

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

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

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

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

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

95
96
97
98
99
100
101

        /**
         * Sets the workflow of this Mainwindow to \a w.
         * \param   w   The workflow to display for this window.
         */
        void setWorkflow(AbstractWorkflow* w);

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

110
    signals:
111
        /// Qt signal for updating the PipelineWidget.
112
113
        void updatePipelineWidget(const std::vector<DataContainer*>&, const std::vector<AbstractPipeline*>&);

114
        /// Qt signal for updating the PropertyCollectionWidget
115
        void updatePropCollectionWidget(HasPropertyCollection*, DataContainer*);
116

117
    public slots:
118
119
120
121
122
        /**
         * Slot to be called by the PipelineWidget when the selected item changes.
         * \param   index   Index of the selected item
         */
        void onPipelineWidgetItemClicked(const QModelIndex& index);
Hossain Mahmud's avatar
stuck!    
Hossain Mahmud committed
123
        
124
125
126
127
128
129
130
131
132
133
        /**
         * Slot to be called when _btnExecute was clicked.
         */
        void onBtnExecuteClicked();

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

Hossain Mahmud's avatar
stuck!    
Hossain Mahmud committed
134
135
136
137
138
139
140
141
142
143
        /**
         * Slot to be called when _btnExecute was clicked.
         */
        void onBtnLuaLoadClicked();

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

144
145
146
        /// Slot to be called when _btnPipelineFactory was clicked;
        void onBtnPipelineFactoryClicked();

147
148
149
        /// Slot to be called when _btnProcessorFactory was clicked;
        void onBtnProcessorFactoryClicked();

150
151
152
        /// Slot to be called when all shaders shall be rebuilt.
        void onRebuildShadersClicked();

153
154
155
        /// Slot to be called when a Lua command shall be executed.
        void onLuaCommandExecuted(const QString& cmd);

156
    private:
157
158
159
160
161
162
163
164
165
166
167

        /**
         * 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
168
169
170
        /**
         * Setup Qt GUI stuff
         */
171
172
        void setup();

173
174
175
176
177
        /**
         * Create and populate the application's main menu.
         */
        void populateMainMenu();

178
179
180
181
182
183
184
185
186
187
188
189
        /**
         * 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);

190
191
        Ui::MainWindow ui;                                  ///< Interface definition of the MainWindow

192
        CampVisApplication* _application;                    ///< Pointer to the application hosting the whole stuff
193

194
        MdiDockArea* _mdiArea;                              ///< MDI area (the window's central widget)
195
196
197
        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
198
        PipelineTreeWidget* _pipelineWidget;                ///< Widget for browsing the active pipelines
199
200
        QWidget* _pipelinePropertiesWidget;                 ///< Widget showing the selected pipeline's properties
        QScrollArea* _pipelinePropertiesScrollArea;         ///< Scroll area for _pipelinePropertiesWidget
201
        PropertyCollectionWidget* _propCollectionWidget;    ///< Widget for brosing the PropertyCollection of the selected pipeline/processor
202
        DataContainerInspectorWidget* _dcInspectorWidget;   ///< Widget for inspecting the DataContainer of the selected pipeline.
203
        MdiDockableWindow* _dcInspectorWindow;              ///< Window displaying the above DataContainerInspectorWidget instance.
204
205
206
207
208
209

        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
210
211
        DataContainer* _selectedDataContainer;              ///< currently selected DataContainer

212
        LogViewerWidget* _logViewer;                        ///< Widget displaying log messages
213
        ScriptingWidget* _scriptingConsoleWidget;           ///< Widget showing the scripting console (if available)
214
        WorkflowControllerWidget* _workflowWidget;          ///< Widget showing the workflow controller
215
216
217
        
        QComboBox* _cbProcessorFactory;                      ///< Combobox for selecting the Processor from the ProcessorFactory
        QPushButton* _btnProcessorFactory;                   ///< Button to add a Processor from the factory to the selected Pipeline
218

Hossain Mahmud's avatar
stuck!    
Hossain Mahmud committed
219
220
221
        QPushButton* _btnLuaLoad;
        QPushButton* _btnLuaSave;

222
        std::vector<QDockWidget*> _primaryDocks;            ///< Docks located in top docking area of the main window
223
224
225
    };
}

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