visualizationpipeline.h 3.99 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
    public:
        /**
         * Creates a VisualizationPipeline.
26
         * \param   canvas  Canvas hosting the OpenGL context for this pipeline.
27
         */
28
        VisualizationPipeline(tgt::GLCanvas* canvas);
29
30
31
32
33
34
35
36
37
38
39
40
41

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


        /**
         * Initializes the OpenGL context of the pipeline and its processors.
         * \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
50
51
52
53
54
55
56
57
58
59
60
        /**
         * Execute this pipeline.
         **/
        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
61
62
         * Returns the PropertyCollection of this processor.
         * \return _properties
63
         */
schultezub's avatar
schultezub committed
64
        PropertyCollection& getPropertyCollection();
65
66

        /**
schultezub's avatar
schultezub committed
67
         * Sets the size of the render target
68
69
         * \param size  New viewport dimensions
         */
schultezub's avatar
schultezub committed
70
        void setRenderTargetSize(const tgt::ivec2& size);
71
72

        /**
schultezub's avatar
schultezub committed
73
74
         * Returns the viewport size of the target canvas
         * \return _renderTargetSize
75
         */
schultezub's avatar
schultezub committed
76
        const tgt::ivec2& getRenderTargetSize() const;
77
78

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

schultezub's avatar
schultezub committed
84
        /**
schultezub's avatar
schultezub committed
85
86
87
         * 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
88
         */
schultezub's avatar
schultezub committed
89
90
        void onDataContainerDataAdded(const std::string& name, const DataHandle* dh);

91
        /// Signal emitted when the pipeline's render target has changed
schultezub's avatar
schultezub committed
92
        sigslot::signal0<> s_renderTargetChanged;
schultezub's avatar
schultezub committed
93

94
    protected:
95
96
97
98
99
100
101
        /**
         * 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
102
        GenericProperty<tgt::ivec2> _renderTargetSize;      ///< Viewport size of target canvas
schultezub's avatar
schultezub committed
103
        GenericProperty<std::string> _renderTargetID;       ///< ID of the render target image to be rendered to the canvas
104
105
        std::vector<AbstractEventHandler*> _eventHandlers;  ///< List of registered event handlers for the pipeline

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

108
109
110
111
112
113
        static const std::string loggerCat_;
    };

}

#endif // VISUALIZATIONPIPELINE_H__