Currently job artifacts in CI/CD pipelines on LRZ GitLab never expire. Starting from Wed 26.1.2022 the default expiration time will be 30 days (GitLab default). Currently existing artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

datacontainerinspectorcanvas.h 9.11 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-2015, 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
25
26
27
28
// 
// ================================================================================================

#ifndef DATACONTAINERINSPECTORCANVAS_H__
#define DATACONTAINERINSPECTORCANVAS_H__

#include "sigslot/sigslot.h"
29
30
31
32
33
#include "cgt/painter.h"
#include "cgt/event/eventlistener.h"
#include "cgt/event/mouseevent.h"
#include "cgt/glcontextmanager.h"
#include "cgt/qt/qtthreadedcanvas.h"
schultezub's avatar
schultezub committed
34
#include "tbb/mutex.h"
35

36
#include "application/applicationapi.h"
37
38
#include "application/gui/qtdatahandle.h"

39
#include "core/properties/metaproperty.h"
40
#include "core/properties/numericproperty.h"
41
#include "core/properties/propertycollection.h"
42
#include "core/properties/transferfunctionproperty.h"
43
44

#include "modules/base/processors/lightsourceprovider.h"
45
#include "modules/base/processors/trackballcameraprovider.h"
46
#include "modules/vis/processors/geometryrenderer.h"
47

48
49
#include <memory>

50

51
namespace cgt {
52
53
    class Shader;
    class Texture;
54
    class TextureUnit;
55
56
}

schultezub's avatar
schultezub committed
57
namespace campvis {
58
59
60
61
    class AbstractPipeline;
    class DataContainer;
    class DataContainerTreeWidget;
    class DataHandle;
62
    class FaceGeometry;
63
    class GeometryData;
64
    class DataContainerInspectorWidget;
65

66
    class CAMPVIS_APPLICATION_API DataContainerInspectorCanvas : public cgt::QtThreadedCanvas, cgt::Painter, public cgt::EventListener, public HasPropertyCollection {
67
68
69
70
71
72
73
        Q_OBJECT;

    public:
        /**
         * Creates a new DataContainerInspectorCanvas.
         * \param   parent          Parent Qt widget, may be 0 (default)
         */
74
        explicit DataContainerInspectorCanvas(QWidget* parent = 0);
75
76
77
78
79
80
81
82
83
84

        /**
         * Destructor.
         */
        ~DataContainerInspectorCanvas();

        /**
         * Initializes the OpenGL stuff (e.g. shaders).
         * Must be called with a valid and locked OpenGL context.
         */
85
        virtual void init();
86
87
88
89
90
91
92

        /**
         * Deinitializes the OpenGL stuff (e.g. shaders).
         * Must be called with a valid and locked OpenGL context.
         */
        void deinit();

93
94
95
96
        /**
         * Set the DataHandles to show in the canvas to those in \a handles.
         * \param   handles vector of name-DataHandle pairs to show in the canvas.
         */
97
        void setDataHandles(const std::vector< std::pair<QString, QtDataHandle> >& handles);
98
99
100
101
102
103
104
105

        /**
         * Size hint for the default window size
         * \return QSize(640, 480)
         */
        QSize sizeHint() const;

        /**
106
         * Schedule a repaint job for the inspector's render target
107
         */
108
        void repaint();
109

110
        /// This is meant be overridden to adjust camera settings to new canvas dimensions
111
        virtual void sizeChanged(const cgt::ivec2&);
112

113
        /**
114
115
116
         * Called on mouse move event on this canvas
         * \param   e   Mouse event arguments
         */
117
        virtual void mouseMoveEvent(cgt::MouseEvent* e);
118

119
        virtual void onEvent(cgt::Event* e);
120
        
121
122
        IntProperty p_currentSlice;                     ///< Currently selected slice to show
        TransferFunctionProperty p_transferFunction;    ///< Transfer function
123

124
125
126
127
        BoolProperty p_renderRChannel;                  ///< Flag whether to render Red channel
        BoolProperty p_renderGChannel;                  ///< Flag whether to render Green channel
        BoolProperty p_renderBChannel;                  ///< Flag whether to render Blue channel
        BoolProperty p_renderAChannel;                  ///< Flag whether to render Alpha channel
128

129
        MetaProperty p_geometryRendererProperties;      ///< MetaProperty for the GeometryRenderer
130
131

    signals:
132
133
        void s_colorChanged(const cgt::svec3& texel, const cgt::vec4&);
        void s_depthChanged(const cgt::svec3& texel, float depth);
134

135
    private slots:
136
137
138
139
140
141
        /**
         * Slot being called when a QtDataHandle has been added to the DataContainer.
         * \param   key     Name of the QtDataHandle
         * \param   dh      The added QtDataHandle
         */
        void onDataContainerChanged(const QString& key, QtDataHandle dh);
142
143

    protected:
144
145
146
147
148
        /**
         * Performs the painting.
         */
        virtual void paint();

149
150
151
152
153
154
        /**
         * Gets called when the data collection of this pipeline has changed and thus has notified its observers.
         * If \a name equals the name of the renderTarget, the s_renderTargetChanged signal will be emitted.
         * \param   name    Name of the added data.
         * \param   dh      DataHandle to the newly added data.
         */
155
        void onDataContainerDataAdded(const std::string& name, DataHandle dh);
156

157
        /**
158
159
         * Slot getting called when one of the observed properties changed and notifies its observers.
         * \param   prop    Property that emitted the signal
160
         */
161
162
        virtual void onPropertyChanged(const AbstractProperty* prop);
        virtual void onGeometryRendererPropertyChanged(const AbstractProperty* prop);
163

164
        /**
165
         * Updates the textures vector.
166
167
         * \note Only call with acquired lock and valid OpenGL context!!
         */
168
        void updateTextures();
169

170
171
172
        /**
         * Resets the trackball and reinitializes the camera to the currently loaded geometries if necessary.
         */
173
174
        void resetTrackball();

175
176
177
178
179
        /**
         * To be called when the canvas is invalidated, issues new paint job.
         */
        void invalidate();

180
        /**
181
         * Renders the given 2D texture.
182
         * Binds the texture to the shader, sets the uniforms and renders the quad.
183
         * \param   texture     The texture to render. Must not be 0.
mostajab's avatar
mostajab committed
184
185
         * \param   uint2d      The texture unit that will be attached to rendering pipeline (2D for 2D textures).
         * \param   uint2d      The texture unit that will be attached to rendering pipeline (3D for 3D textures).
186
         */
187
        void paintTexture(const cgt::Texture* texture, const cgt::TextureUnit& unit2d, const cgt::TextureUnit& unit3d);
188

189
        /**
190
191
192
193
         * Renders \a geometry into a texture.
         * 
         * \param name 
         * \param geometry
194
         */
195
        void renderGeometryIntoTexture(const std::string& name, int textureIndex = -1);
196

197
198
199
200
        /**
         * Creates the quad used for rendering the textures.
         */
        void createQuad();
201

202
203
        
        std::map<QString, QtDataHandle> _handles;   ///< Map of DataHandles to show
204
205
206

        /// Vector of textures to render. Each DataHandle contains an ImageData that has an OpenGL representation.
        /// This ensures thread safety.
207
208
209
210
        std::vector<QtDataHandle> _textures;

        /// List of the names of all rendered geometries. This simplifies to update their rendering.
        std::vector< std::pair<std::string, int> > _geometryNames;
211

212
213
        bool _texturesDirty;                        ///< Flag that shows that the textures need update or not.
        bool _geometriesDirty;                      ///< Flag that shows that the rendered geometries need update or not.
214

mostajab's avatar
mostajab committed
215
216
        DataContainer* _dataContainer;              ///< The DataContainer this widget is inspecting
        tbb::mutex _localMutex;                     ///< Mutex protecting the local members
217

218
        cgt::Shader* _paintShader;                  ///< GLSL shader for rendering the textures
219
        std::unique_ptr<FaceGeometry> _quad;        ///< Quad used for rendering
220

221
222
        cgt::ivec2 _numTiles;                       ///< number of tiles on texture overview
        cgt::ivec2 _quadSize;                       ///< size in pixels for each tile in overview
223

224
225
        DataContainer _localDataContainer;          ///< Local DataContainer the GeometryRenderer works on
        IVec2Property p_viewportSize;
226
227

        TrackballCameraProvider _tcp;               ///< TrackballCameraProvider to do camera stuff
228
        GeometryRenderer _geometryRenderer;         ///< GeometryRenderer used to render geometries
229
230
231
    };
}

232
#endif // DATACONTAINERINSPECTORCANVAS_H__