visualizationpipeline.h 3.92 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
42
43
44
45
46
47
48
49
50
51
52
53
54

        /**
         * 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();

        /**
         * 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
55
56
         * Returns the PropertyCollection of this processor.
         * \return _properties
57
         */
schultezub's avatar
schultezub committed
58
        PropertyCollection& getPropertyCollection();
59
60

        /**
schultezub's avatar
schultezub committed
61
         * Sets the size of the render target
62
63
         * \param size  New viewport dimensions
         */
schultezub's avatar
schultezub committed
64
        void setRenderTargetSize(const tgt::ivec2& size);
65
66

        /**
schultezub's avatar
schultezub committed
67
68
         * Returns the viewport size of the target canvas
         * \return _renderTargetSize
69
         */
schultezub's avatar
schultezub committed
70
        const tgt::ivec2& getRenderTargetSize() const;
71
72

        /**
schultezub's avatar
schultezub committed
73
74
75
76
77
78
         * 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.
79
         */
schultezub's avatar
schultezub committed
80
        const ImageDataRenderTarget* getRenderTarget() const;
81

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


        sigslot::signal0<> s_renderTargetChanged;
schultezub's avatar
schultezub committed
91

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

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

106
107
108
109
110
111
        static const std::string loggerCat_;
    };

}

#endif // VISUALIZATIONPIPELINE_H__