visualizationpipeline.h 4.21 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

        /**
schultezub's avatar
schultezub committed
79
80
81
82
83
84
         * Returns the DataHandle with the render target of this VisualizationPipeline in its current state.
         * 
         * \todo    This is not thread-safe, the object might be destroyed at any time. 
         *          Time for implementing reference counting?
         *          
         * \return  The DataHandle named _renderTargetID in the pipeline's DataContainer, 0 if no such handle exists.
85
         */
schultezub's avatar
schultezub committed
86
        const ImageDataRenderTarget* getRenderTarget() const;
87

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

95
        /// Signal emitted when the pipeline's render target has changed
schultezub's avatar
schultezub committed
96
        sigslot::signal0<> s_renderTargetChanged;
schultezub's avatar
schultezub committed
97

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

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

112
113
114
115
116
117
        static const std::string loggerCat_;
    };

}

#endif // VISUALIZATIONPIPELINE_H__