volumeexplorer.h 7.57 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
29
30
31
32
#include "tgt/event/eventlistener.h"

#include "core/eventhandlers/mwheeltonumericpropertyeventlistener.h"
#include "core/eventhandlers/trackballnavigationeventlistener.h"
#include "core/eventhandlers/transfuncwindowingeventlistener.h"
33

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

schultezub's avatar
schultezub committed
37
38
#include "core/properties/datanameproperty.h"
#include "core/properties/numericproperty.h"
39
#include "core/properties/metaproperty.h"
schultezub's avatar
schultezub committed
40
41
42
43
44
45
46
47

#include "modules/vis/processors/volumerenderer.h"
#include "modules/vis/processors/sliceextractor.h"

namespace tgt {
    class Shader;
}

schultezub's avatar
schultezub committed
48
49
class FaceGeometry;

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

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

        /**
         * 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."; };
86
87
88
        /// \see AbstractProcessor::getAuthor()
        virtual const std::string getAuthor() const { return "Christian Schulte zu Berge <christian.szb@in.tum.de>"; };
        /// \see AbstractProcessor::getProcessorState()
89
        virtual ProcessorState getProcessorState() const { return AbstractProcessor::EXPERIMENTAL; };
90
        
91
92
        /// \see tgt::EventListener::onEvent()
        virtual void onEvent(tgt::Event* e);
93

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

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

106
107
108
        DataNameProperty p_inputVolume;     ///< image ID for first input image
        DataNameProperty p_outputImage;     ///< image ID for output image

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

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


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

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

schultezub's avatar
schultezub committed
129
130
131
132
133
134
135
136
137
138
139
140
        /**
         * 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);

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

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

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

        tgt::Shader* _shader;                           ///< Shader for slice rendering
        FaceGeometry* _quad;

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
166
        MWheelToNumericPropertyEventListener _xSliceHandler;
        MWheelToNumericPropertyEventListener _ySliceHandler;
        MWheelToNumericPropertyEventListener _zSliceHandler;
        TransFuncWindowingEventListener _windowingHandler;
        TrackballNavigationEventListener* _trackballEH;
167
168
        bool _mousePressedInRaycaster;                  ///< Flag whether mouse was pressed in raycaster

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

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

177
178
        tgt::ivec3 _cachedImageSize;

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

}

#endif // VOLUMEEXPLORER_H__