volumeexplorer.h 7.58 KB
Newer Older
schultezub's avatar
schultezub committed
1
2
3
4
// ================================================================================================
// 
// This file is part of the CAMPVis Software Framework.
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
schultezub's avatar
schultezub committed
6
7
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      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
12
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// 
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
schultezub's avatar
schultezub committed
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.
schultezub's avatar
schultezub committed
22
23
24
25
26
27
// 
// ================================================================================================

#ifndef VOLUMEEXPLORER_H__
#define VOLUMEEXPLORER_H__

28
#include "cgt/event/eventlistener.h"
29
30
31

#include "core/eventhandlers/mwheeltonumericpropertyeventlistener.h"
#include "core/eventhandlers/transfuncwindowingeventlistener.h"
32

33
#include "core/pipeline/abstractprocessordecorator.h"
schultezub's avatar
schultezub committed
34
#include "core/pipeline/visualizationprocessor.h"
35
#include "core/properties/allproperties.h"
36

37
#include "modules/base/processors/trackballcameraprovider.h"
38
#include "modules/modulesapi.h"
schultezub's avatar
schultezub committed
39
40
41
#include "modules/vis/processors/volumerenderer.h"
#include "modules/vis/processors/sliceextractor.h"

42
namespace cgt {
schultezub's avatar
schultezub committed
43
44
45
    class Shader;
}

schultezub's avatar
schultezub committed
46
47
class FaceGeometry;

schultezub's avatar
schultezub committed
48
49
50
51
namespace campvis {
    /**
     * Combines a volume raycaster and 3 slice views for explorative volume visualization.
     */
52
    class CAMPVIS_MODULES_API VolumeExplorer : public VisualizationProcessor, public HasProcessorDecorators, public cgt::EventListener {
schultezub's avatar
schultezub committed
53
    public:
54
55
56
57
58
59
60
61
        /// Enumeration of the 4 views of the VolumeExplorer
        enum Views {
            XY_PLANE,
            XZ_PLANE,
            YZ_PLANE,
            VOLUME
        };

schultezub's avatar
schultezub committed
62
63
        /**
         * Constructs a new VolumeExplorer Processor
64
65
         * \param   viewportSizeProp    Pointer to the property defining the viewport size, must not be 0.
         * \param   raycaster           Raycaster to use for rendering, must not be 0, VolumeRenderer will take ownership.
schultezub's avatar
schultezub committed
66
         **/
67
        VolumeExplorer(IVec2Property* viewportSizeProp, SliceRenderProcessor* sliceRenderer = new SliceExtractor(0), RaycastingProcessor* raycaster = new SimpleRaycaster(0));
schultezub's avatar
schultezub committed
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83

        /**
         * Destructor
         **/
        virtual ~VolumeExplorer();

        /// \see AbstractProcessor::init
        virtual void init();

        /// \see AbstractProcessor::deinit
        virtual void deinit();

        /// \see AbstractProcessor::getName()
        virtual const std::string getName() const { return "VolumeExplorer"; };
        /// \see AbstractProcessor::getDescription()
        virtual const std::string getDescription() const { return "Combines a volume raycaster and 3 slice views for explorative volume visualization."; };
84
85
86
        /// \see AbstractProcessor::getAuthor()
        virtual const std::string getAuthor() const { return "Christian Schulte zu Berge <christian.szb@in.tum.de>"; };
        /// \see AbstractProcessor::getProcessorState()
87
        virtual ProcessorState getProcessorState() const { return AbstractProcessor::EXPERIMENTAL; };
88
        
89
90
        /// \see cgt::EventListener::onEvent()
        virtual void onEvent(cgt::Event* e);
91

92
93
94
95
96
97
98
99
100
101
102
103
        /**
         * Returns the VolumeRenderer processor.
         * \return	&_raycaster
         */
        VolumeRenderer* getVolumeRenderer();

        /**
         * Returns the SliceRenderProcessor.
         * \return	_sliceRenderer
         */
        SliceRenderProcessor* getSliceRenderer();

104
105
106
        DataNameProperty p_inputVolume;     ///< image ID for first input image
        DataNameProperty p_outputImage;     ///< image ID for output image

107
        GenericOptionProperty<Views> p_largeView;   ///< View to be shown in the large render target
108
        BoolProperty p_enableScribbling;    ///< Enable Scribbling in Slice Views
schultezub's avatar
schultezub committed
109

110
111
        MetaProperty p_seProperties;        ///< MetaProperty for SliceExtractor properties
        MetaProperty p_vrProperties;        ///< MetaProperty for Raycaster properties
schultezub's avatar
schultezub committed
112
113
114
115
116
117


    protected:
        /// Additional invalidation levels for this processor.
        /// Not the most beautiful design though.
        enum ProcessorInvalidationLevel {
118
119
120
121
122
            CAMERA_INVALID = FIRST_FREE_TO_USE_INVALIDATION_LEVEL,
            VR_INVALID = FIRST_FREE_TO_USE_INVALIDATION_LEVEL << 1,
            SLICES_INVALID = FIRST_FREE_TO_USE_INVALIDATION_LEVEL << 2,
            SCRIBBLE_INVALID = FIRST_FREE_TO_USE_INVALIDATION_LEVEL << 3,
            LARGE_VIEW_INVALID = FIRST_FREE_TO_USE_INVALIDATION_LEVEL << 4
schultezub's avatar
schultezub committed
123
124
        };

125
126
127
        /// \see AbstractProcessor::updateResult
        virtual void updateResult(DataContainer& dataContainer);

schultezub's avatar
schultezub committed
128
129
130
131
132
133
134
135
136
137
138
139
        /**
         * Slot getting called when one of the observed processors got invalidated.
         * Invalidates this meta-processor with the corresponding level.
         * \param   processor   The processor that emitted the signal
         */
        virtual void onProcessorInvalidated(AbstractProcessor* processor);

        /**
         * \see VisualizationProcessor::onPropertyChanged
         */
        virtual void onPropertyChanged(const AbstractProperty* prop);

140
141
142
143
        /**
         * Callback called from SliceExtractor when a scribble has been painted.
         * \param   voxel   Voxel position of scribble
         */
144
        void onSliceExtractorScribblePainted(cgt::vec3 voxel);
145

schultezub's avatar
schultezub committed
146
147
        void composeFinalRendering(DataContainer& data);

148
149
        /// \see    AbstractProcessor::updateProperties
        void updateProperties(DataContainer& dc);
schultezub's avatar
schultezub committed
150

151
        cgt::Shader* _shader;                           ///< Shader for slice rendering
schultezub's avatar
schultezub committed
152
153
        FaceGeometry* _quad;

154
        TrackballCameraProvider _tcp;
schultezub's avatar
schultezub committed
155
        VolumeRenderer _raycaster;
156
        SliceRenderProcessor* _sliceRenderer;
schultezub's avatar
schultezub committed
157

158
159
        IVec2Property p_smallRenderSize;
        IVec2Property p_largeRenderSize;
schultezub's avatar
schultezub committed
160

161

162
163
164
165
        MWheelToNumericPropertyEventListener _xSliceHandler;
        MWheelToNumericPropertyEventListener _ySliceHandler;
        MWheelToNumericPropertyEventListener _zSliceHandler;
        TransFuncWindowingEventListener _windowingHandler;
166
167
        bool _mousePressedInRaycaster;                  ///< Flag whether mouse was pressed in raycaster

168
        Views _viewUnderEvent;                          ///< View to apply events to
169
170
        cgt::ivec2 _eventPositionOffset;                ///< Offset to be added to mouse event position
        cgt::ivec2 _eventViewportSize;                  ///< Viewport of adjusted mouse event
171

172
173
174
        std::vector<cgt::vec3>* _scribblePointer;       ///< Pointer encoding whether the mouse was pressed (!= nullptr) and whether we have yes-scribbles or no-scribbles.
        std::vector<cgt::vec3> _yesScribbles;           ///< All voxels of the current yes-scribbles
        std::vector<cgt::vec3> _noScribbles;            ///< All voxels of the current no-scribbles
175

176
        cgt::ivec3 _cachedImageSize;
177

schultezub's avatar
schultezub committed
178
179
180
181
182
183
        static const std::string loggerCat_;
    };

}

#endif // VOLUMEEXPLORER_H__