visualizationpipeline.h 4.57 KB
Newer Older
1
2
3
#ifndef VISUALIZATIONPIPELINE_H__
#define VISUALIZATIONPIPELINE_H__

schultezub's avatar
schultezub committed
4
#include "sigslot/sigslot.h"
schultezub's avatar
schultezub committed
5
#include "tgt/vector.h"
6
7
8
#include "tgt/event/eventlistener.h"
#include "core/eventhandlers/abstracteventhandler.h"
#include "core/pipeline/abstractpipeline.h"
schultezub's avatar
schultezub committed
9
#include "core/properties/genericproperty.h"
10
11
12

#include <vector>

schultezub's avatar
schultezub committed
13
14
15
16
namespace tgt {
    class GLCanvas;
}

17
namespace TUMVis {
schultezub's avatar
schultezub committed
18
    class ImageDataRenderTarget;
19
20
21
22
23

    /**
     * Abstract base class for TUMVis Pipelines.
     * 
     */
schultezub's avatar
schultezub committed
24
    class VisualizationPipeline : public AbstractPipeline, public tgt::EventListener {
25
26
27
28
    public:
        /**
         * Creates a VisualizationPipeline.
         */
29
        VisualizationPipeline();
30
31
32
33
34
35
36
37
38

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


        /**
         * Initializes the OpenGL context of the pipeline and its processors.
39
         * Pipeline must have a valid canvas set before calling this method.
40
41
42
43
         * \note    When overwriting this method, make sure to call the base class version first.
         */
        virtual void init();

44
45
46
47
48
49
        /**
         * Deinitializes this pipeline and all of its processors.
         * \note    When overwriting this method, make sure to call the base class version first.
         */
        virtual void deinit();

50
51
        /**
         * Execute this pipeline.
52
         * Pipeline must have a valid canvas set before calling this method.
53
54
55
56
57
58
59
60
61
62
63
         **/
        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
64
65
         * Returns the PropertyCollection of this processor.
         * \return _properties
66
         */
schultezub's avatar
schultezub committed
67
        PropertyCollection& getPropertyCollection();
68

69
70
71
72
73
74
        /**
         * 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);

75
        /**
schultezub's avatar
schultezub committed
76
         * Sets the size of the render target
77
78
         * \param size  New viewport dimensions
         */
schultezub's avatar
schultezub committed
79
        void setRenderTargetSize(const tgt::ivec2& size);
80
81

        /**
schultezub's avatar
schultezub committed
82
83
         * Returns the viewport size of the target canvas
         * \return _renderTargetSize
84
         */
schultezub's avatar
schultezub committed
85
        const tgt::ivec2& getRenderTargetSize() const;
86
87

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

schultezub's avatar
schultezub committed
93
        /**
schultezub's avatar
schultezub committed
94
95
96
         * Gets called when the data collection of this pipeline has changed and thus has notified its observers.
         * The default behaviour is to do nothing
         * \param poa   DataContainerObserverArgs   ObserverArgument struct containing the emitting DataContainer and hints to its changes
schultezub's avatar
schultezub committed
97
         */
schultezub's avatar
schultezub committed
98
99
        void onDataContainerDataAdded(const std::string& name, const DataHandle* dh);

100
101
102
103
104
105
106
        /**
         * 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);

107
        /// Signal emitted when the pipeline's render target has changed
schultezub's avatar
schultezub committed
108
        sigslot::signal0<> s_renderTargetChanged;
schultezub's avatar
schultezub committed
109

110
    protected:
111
112
113
114
115
116
117
        /**
         * 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
118
        GenericProperty<tgt::ivec2> _renderTargetSize;      ///< Viewport size of target canvas
schultezub's avatar
schultezub committed
119
        StringProperty _renderTargetID;                     ///< ID of the render target image to be rendered to the canvas
120
121
        std::vector<AbstractEventHandler*> _eventHandlers;  ///< List of registered event handlers for the pipeline

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

124
125
126
127
128
129
        static const std::string loggerCat_;
    };

}

#endif // VISUALIZATIONPIPELINE_H__