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

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

#include <vector>

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

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

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


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

42
43
44
45
46
47
        /**
         * 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();

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

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

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

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

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

schultezub's avatar
schultezub committed
91
        /**
schultezub's avatar
schultezub committed
92
93
94
         * 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
95
         */
schultezub's avatar
schultezub committed
96
97
        void onDataContainerDataAdded(const std::string& name, const DataHandle* dh);

98
        /// Signal emitted when the pipeline's render target has changed
schultezub's avatar
schultezub committed
99
        sigslot::signal0<> s_renderTargetChanged;
schultezub's avatar
schultezub committed
100

101
    protected:
102
103
104
105
106
107
108
        /**
         * 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
109
        GenericProperty<tgt::ivec2> _renderTargetSize;      ///< Viewport size of target canvas
schultezub's avatar
schultezub committed
110
        GenericProperty<std::string> _renderTargetID;       ///< ID of the render target image to be rendered to the canvas
111
112
        std::vector<AbstractEventHandler*> _eventHandlers;  ///< List of registered event handlers for the pipeline

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

115
116
117
118
119
120
        static const std::string loggerCat_;
    };

}

#endif // VISUALIZATIONPIPELINE_H__