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 8.45 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, 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 Universität München
//      Boltzmannstr. 3, 85748 Garching b. München, Germany
schultezub's avatar
schultezub committed
10
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 
// The licensing of this softare is not yet resolved. Until then, redistribution in source or
// binary forms outside the CAMP chair is not permitted, unless explicitly stated in legal form.
// However, the names of the original authors and the above copyright notice must retain in its
// original state in any case.
// 
// Legal disclaimer provided by the BSD license:
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
// 
// ================================================================================================

schultezub's avatar
schultezub committed
30
31
#ifndef CAMPVISMAINWINDOW_H__
#define CAMPVISMAINWINDOW_H__
32
33

#include "sigslot/sigslot.h"
schultezub's avatar
schultezub committed
34
#include "application/campvisapplication.h"
35
#include "application/gui/mdi/mdidockarea.h"
36
#include "application/gui/pipelinetreewidget.h"
schultezub's avatar
schultezub committed
37
#include "application/gui/properties/propertycollectionwidget.h"
38
#include "application/gui/logviewerwidget.h"
39
40
#include "application/tools/qtexteditlog.h"
#include "application/ui_mainwindow.h"
41
42

#include <QMainWindow>
43
44
#include <QVBoxLayout>
#include <QHBoxLayout>
45
#include <QPushButton>
Christian Schulte zu Berge's avatar
Christian Schulte zu Berge committed
46
#include <QComboBox>
47
#include <QScrollArea>
48
49
#include <vector>

schultezub's avatar
schultezub committed
50
namespace campvis {
51
    class DataContainerInspectorWidget;
52
    class DataContainerInspectorCanvas;
53

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

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

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

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

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

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

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

97
98
99
100
101
102
103
104
    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);

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

109
        /// Qt signal for updating the PropertyCollectionWidget
110
        void updatePropCollectionWidget(HasPropertyCollection*, DataContainer*);
111

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

119
120
121
122
123
124
125
126
127
128
        /**
         * Slot to be called when _btnExecute was clicked.
         */
        void onBtnExecuteClicked();

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

129
130
131
        /// Slot to be called when _btnPipelineFactory was clicked;
        void onBtnPipelineFactoryClicked();

132
    private:
133
134
135
136
137
138
139
140
141
142
143

        /**
         * 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
144
145
146
        /**
         * Setup Qt GUI stuff
         */
147
148
        void setup();

149
150
151
152
153
        /**
         * Create and populate the application's main menu.
         */
        void populateMainMenu();

154
155
156
157
158
159
160
161
162
163
164
165
        /**
         * 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);

166
167
        Ui::MainWindow ui;                                  ///< Interface definition of the MainWindow

168
        CampVisApplication* _application;                    ///< Pointer to the application hosting the whole stuff
169

170
        MdiDockArea* _mdiArea;                              ///< MDI area (the window's central widget)
171
172
173
        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
174
        PipelineTreeWidget* _pipelineWidget;                ///< Widget for browsing the active pipelines
175
176
        QWidget* _pipelinePropertiesWidget;                 ///< Widget showing the selected pipeline's properties
        QScrollArea* _pipelinePropertiesScrollArea;         ///< Scroll area for _pipelinePropertiesWidget
177
        PropertyCollectionWidget* _propCollectionWidget;    ///< Widget for brosing the PropertyCollection of the selected pipeline/processor
178
        DataContainerInspectorWidget* _dcInspectorWidget;   ///< Widget for inspecting the DataContainer of the selected pipeline.
179
        QDockWidget* _dcInspectorDock;                      ///< Dock storing the above DataContainerInspectorWidget instance.
180
181
182
183
184
185

        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
186
187
        DataContainer* _selectedDataContainer;              ///< currently selected DataContainer

188
189
        LogViewerWidget* _logViewer;                        ///< Widget displaying log messages
        std::vector<QDockWidget*> _primaryDocks;            ///< Docks located in top docking area of the main window
190
191
192
    };
}

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