visualizationpipeline.h 6.38 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// ================================================================================================
// 
// This file is part of the TUMVis Visualization Framework.
// 
// If not explicitly stated otherwise: Copyright (C) 2012, all rights reserved,
//      Christian Schulte zu Berge (christian.szb@in.tum.de)
//      Chair for Computer Aided Medical Procedures
//      Technische Universität München
//      Boltzmannstr. 3, 85748 Garching b. München, Germany
// 
// 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.
// 
// ================================================================================================

29
30
31
#ifndef VISUALIZATIONPIPELINE_H__
#define VISUALIZATIONPIPELINE_H__

schultezub's avatar
schultezub committed
32
#include "sigslot/sigslot.h"
schultezub's avatar
schultezub committed
33
#include "tgt/vector.h"
34
35
36
#include "tgt/event/eventlistener.h"
#include "core/eventhandlers/abstracteventhandler.h"
#include "core/pipeline/abstractpipeline.h"
schultezub's avatar
schultezub committed
37
#include "core/properties/genericproperty.h"
38
39
40

#include <vector>

schultezub's avatar
schultezub committed
41
42
43
44
namespace tgt {
    class GLCanvas;
}

45
namespace TUMVis {
schultezub's avatar
schultezub committed
46
    class ImageDataRenderTarget;
47
48
49
50
51

    /**
     * Abstract base class for TUMVis Pipelines.
     * 
     */
schultezub's avatar
schultezub committed
52
    class VisualizationPipeline : public AbstractPipeline, public tgt::EventListener {
53
54
55
56
    public:
        /**
         * Creates a VisualizationPipeline.
         */
57
        VisualizationPipeline();
58
59
60
61
62
63
64
65
66

        /**
         * Virtual Destructor
         **/
        virtual ~VisualizationPipeline();


        /**
         * Initializes the OpenGL context of the pipeline and its processors.
67
         * Must be called with a valid and locked OpenGL context.
68
69
70
71
         * \note    When overwriting this method, make sure to call the base class version first.
         */
        virtual void init();

72
73
        /**
         * Deinitializes this pipeline and all of its processors.
74
         * Must be called with a valid and locked OpenGL context.
75
76
77
78
         * \note    When overwriting this method, make sure to call the base class version first.
         */
        virtual void deinit();

79
80
        /**
         * Execute this pipeline.
81
         * Pipeline must have a valid canvas set before calling this method.
82
83
84
85
86
87
88
89
90
91
92
         **/
        virtual void execute() = 0;

        /**
         * Performs the event handling for the assigned canvas.
         * Default behaviour is to execute all assigned EventHandlers, may be overwritten by subclasses.
         * \param e     event parameters
         */
        virtual void onEvent(tgt::Event* e);

        /**
schultezub's avatar
schultezub committed
93
94
         * Returns the PropertyCollection of this processor.
         * \return _properties
95
         */
schultezub's avatar
schultezub committed
96
        PropertyCollection& getPropertyCollection();
97

98
99
100
101
102
103
        /**
         * Sets the Canvas hosting the OpenGL context for this pipeline.
         * \param   canvas  Canvas hosting the OpenGL context for this pipeline
         */
        void setCanvas(tgt::GLCanvas* canvas);

104
        /**
schultezub's avatar
schultezub committed
105
         * Sets the size of the render target
106
107
         * \param size  New viewport dimensions
         */
schultezub's avatar
schultezub committed
108
        void setRenderTargetSize(const tgt::ivec2& size);
109
110

        /**
schultezub's avatar
schultezub committed
111
112
         * Returns the viewport size of the target canvas
         * \return _renderTargetSize
113
         */
schultezub's avatar
schultezub committed
114
        const tgt::ivec2& getRenderTargetSize() const;
115
116

        /**
117
         * Returns the ID of the render target image to be rendered to the canvas
schultezub's avatar
schultezub committed
118
         * \return  The DataHandle named _renderTargetID in the pipeline's DataContainer, 0 if no such handle exists.
119
         */
120
        const std::string& getRenderTargetID() const;
121

schultezub's avatar
schultezub committed
122
123
124
125
        /// Signal emitted when the pipeline's render target has changed
        sigslot::signal0<> s_renderTargetChanged;

    protected:
schultezub's avatar
schultezub committed
126
        /**
schultezub's avatar
schultezub committed
127
         * Gets called when the data collection of this pipeline has changed and thus has notified its observers.
schultezub's avatar
schultezub committed
128
129
130
         * 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.
schultezub's avatar
schultezub committed
131
         */
schultezub's avatar
schultezub committed
132
133
        void onDataContainerDataAdded(const std::string& name, const DataHandle* dh);

134
135
136
137
138
139
140
        /**
         * Slot getting called when one of the observed properties changed and notifies its observers.
         * If \a prop equals _renderTargetID, the s_renderTargetChanged is emitted.
         * \param   prop    Property that emitted the signal
         */
        virtual void onPropertyChanged(const AbstractProperty* prop);

141
142
143
144
145
146
147
        /**
         * Acquires and locks the OpenGL context, executes the processor \a processor on the pipeline's data 
         * and locks its properties meanwhile.
         * \param   processor   Processor to execute.
         */
        void lockGLContextAndExecuteProcessor(AbstractProcessor& processor);

schultezub's avatar
schultezub committed
148
        GenericProperty<tgt::ivec2> _renderTargetSize;      ///< Viewport size of target canvas
schultezub's avatar
schultezub committed
149
        StringProperty _renderTargetID;                     ///< ID of the render target image to be rendered to the canvas
150
151
        std::vector<AbstractEventHandler*> _eventHandlers;  ///< List of registered event handlers for the pipeline

152
153
        tgt::GLCanvas* _canvas;                             ///< Canvas hosting the OpenGL context for this pipeline.

154
155
156
157
158
159
        static const std::string loggerCat_;
    };

}

#endif // VISUALIZATIONPIPELINE_H__