volumeexplorer.h 7.87 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
#include "modules/vis/processors/volumerenderer.h"
#include "modules/vis/processors/sliceextractor.h"
Hossain Mahmud's avatar
Hossain Mahmud committed
41
#include "../../processorfactory.h"
schultezub's avatar
schultezub committed
42

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

schultezub's avatar
schultezub committed
47
48
class FaceGeometry;

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

schultezub's avatar
schultezub committed
63
64
        /**
         * Constructs a new VolumeExplorer Processor
65
66
         * \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
67
         **/
68
        VolumeExplorer(IVec2Property* viewportSizeProp, SliceRenderProcessor* sliceRenderer = new SliceExtractor(0), RaycastingProcessor* raycaster = new SimpleRaycaster(0));
schultezub's avatar
schultezub committed
69
70
71
72
73
74
75
76
77
78
79
80

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

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

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

Hossain Mahmud's avatar
Hossain Mahmud committed
81
82
83
84
        /** 
         * To be used in ProcessorFactory static methods
         */
        static const std::string getId() { return "VolumeExplorer"; };
schultezub's avatar
schultezub committed
85
        /// \see AbstractProcessor::getName()
Hossain Mahmud's avatar
Hossain Mahmud committed
86
        virtual const std::string getName() const { return getId(); };
schultezub's avatar
schultezub committed
87
88
        /// \see AbstractProcessor::getDescription()
        virtual const std::string getDescription() const { return "Combines a volume raycaster and 3 slice views for explorative volume visualization."; };
89
90
91
        /// \see AbstractProcessor::getAuthor()
        virtual const std::string getAuthor() const { return "Christian Schulte zu Berge <christian.szb@in.tum.de>"; };
        /// \see AbstractProcessor::getProcessorState()
92
        virtual ProcessorState getProcessorState() const { return AbstractProcessor::EXPERIMENTAL; };
93
        
94
95
        /// \see cgt::EventListener::onEvent()
        virtual void onEvent(cgt::Event* e);
96

97
98
99
100
101
102
103
104
105
106
107
108
        /**
         * Returns the VolumeRenderer processor.
         * \return	&_raycaster
         */
        VolumeRenderer* getVolumeRenderer();

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

109
110
111
        DataNameProperty p_inputVolume;     ///< image ID for first input image
        DataNameProperty p_outputImage;     ///< image ID for output image

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

115
116
        MetaProperty p_seProperties;        ///< MetaProperty for SliceExtractor properties
        MetaProperty p_vrProperties;        ///< MetaProperty for Raycaster properties
schultezub's avatar
schultezub committed
117
118
119
120
121
122


    protected:
        /// Additional invalidation levels for this processor.
        /// Not the most beautiful design though.
        enum ProcessorInvalidationLevel {
123
124
125
126
127
            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
128
129
        };

130
131
132
        /// \see AbstractProcessor::updateResult
        virtual void updateResult(DataContainer& dataContainer);

schultezub's avatar
schultezub committed
133
134
135
136
137
138
139
140
141
142
143
144
        /**
         * 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);

145
146
147
148
        /**
         * Callback called from SliceExtractor when a scribble has been painted.
         * \param   voxel   Voxel position of scribble
         */
149
        void onSliceExtractorScribblePainted(cgt::vec3 voxel);
150

schultezub's avatar
schultezub committed
151
152
        void composeFinalRendering(DataContainer& data);

153
154
        /// \see    AbstractProcessor::updateProperties
        void updateProperties(DataContainer& dc);
schultezub's avatar
schultezub committed
155

156
        cgt::Shader* _shader;                           ///< Shader for slice rendering
schultezub's avatar
schultezub committed
157
158
        FaceGeometry* _quad;

159
        TrackballCameraProvider _tcp;
schultezub's avatar
schultezub committed
160
        VolumeRenderer _raycaster;
161
        SliceRenderProcessor* _sliceRenderer;
schultezub's avatar
schultezub committed
162

163
164
        IVec2Property p_smallRenderSize;
        IVec2Property p_largeRenderSize;
schultezub's avatar
schultezub committed
165

166

167
168
169
170
        MWheelToNumericPropertyEventListener _xSliceHandler;
        MWheelToNumericPropertyEventListener _ySliceHandler;
        MWheelToNumericPropertyEventListener _zSliceHandler;
        TransFuncWindowingEventListener _windowingHandler;
171
172
        bool _mousePressedInRaycaster;                  ///< Flag whether mouse was pressed in raycaster

173
        Views _viewUnderEvent;                          ///< View to apply events to
174
175
        cgt::ivec2 _eventPositionOffset;                ///< Offset to be added to mouse event position
        cgt::ivec2 _eventViewportSize;                  ///< Viewport of adjusted mouse event
176

177
178
179
        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
180

181
        cgt::ivec3 _cachedImageSize;
182

schultezub's avatar
schultezub committed
183
184
185
        static const std::string loggerCat_;
    };

Hossain Mahmud's avatar
Hossain Mahmud committed
186
187
    // Instantiate template to register the pipelines.
    template class ProcessorRegistrar<VolumeExplorer>;
schultezub's avatar
schultezub committed
188
189
190
}

#endif // VOLUMEEXPLORER_H__