visualizationpipeline.cpp 2.32 KB
Newer Older
1
#include "visualizationpipeline.h"
schultezub's avatar
schultezub committed
2
#include "tgt/camera.h"
schultezub's avatar
schultezub committed
3
#include "tgt/quadrenderer.h"
schultezub's avatar
schultezub committed
4
#include "tgt/quadric.h"
5
#include "tgt/glcontext.h"
schultezub's avatar
schultezub committed
6
#include "core/datastructures/imagedatarendertarget.h"
7
8
9
10

namespace TUMVis {
    const std::string VisualizationPipeline::loggerCat_ = "TUMVis.core.datastructures.VisualizationPipeline";

11
    VisualizationPipeline::VisualizationPipeline(tgt::GLCanvas* canvas) 
schultezub's avatar
schultezub committed
12
        : AbstractPipeline()
schultezub's avatar
schultezub committed
13
14
        , tgt::EventListener()
        , _renderTargetSize("canvasSize", "Canvas Size", tgt::ivec2(128, 128))
schultezub's avatar
schultezub committed
15
        , _renderTargetID("renderTargetID", "Render Target ID", "VisualizationPipeline.renderTarget")
16
        , _canvas(canvas)
17
    {
18
        tgtAssert(canvas != 0, "Canvas must not be 0.");
schultezub's avatar
schultezub committed
19
        _data.s_dataAdded.connect(this, &VisualizationPipeline::onDataContainerDataAdded);
20
21
22
    }

    VisualizationPipeline::~VisualizationPipeline() {
schultezub's avatar
schultezub committed
23
        _data.s_dataAdded.disconnect(this);
24
25
26
27
    }

    void VisualizationPipeline::onEvent(tgt::Event* e) {
        // cycle through event handlers, ask each one if it handles the event and if so, execute it.
schultezub's avatar
schultezub committed
28
        for (std::vector<AbstractEventHandler*>::iterator it = _eventHandlers.begin(); it != _eventHandlers.end() && e->isAccepted(); ++it) {
29
30
31
32
            if ((*it)->accept(e)) {
                (*it)->execute(e);
            }
        }
schultezub's avatar
schultezub committed
33
34
35
36

        if (e->isAccepted()) {
            EventListener::onEvent(e);
        }
37
38
39
40
41
42
43
    }

    PropertyCollection& VisualizationPipeline::getPropertyCollection() {
        return _properties;
    }

    void VisualizationPipeline::init() {
44
        tgt::GLContextScopedLock lock(_canvas->getContext());
45
46
47
        AbstractPipeline::init();
    }

schultezub's avatar
schultezub committed
48
49
50
    const tgt::ivec2& VisualizationPipeline::getRenderTargetSize() const {
        return _renderTargetSize.getValue();
    }
schultezub's avatar
schultezub committed
51

schultezub's avatar
schultezub committed
52
53
54
    void VisualizationPipeline::onDataContainerDataAdded(const std::string& name, const DataHandle* dh) {
        if (name == _renderTargetID.getValue()) {
            s_renderTargetChanged();
schultezub's avatar
schultezub committed
55
        }
56
57
    }

schultezub's avatar
schultezub committed
58
59
    const ImageDataRenderTarget* VisualizationPipeline::getRenderTarget() const {
        return _data.getTypedData<ImageDataRenderTarget>(_renderTargetID.getValue());
60
61
    }

schultezub's avatar
schultezub committed
62
63
    void VisualizationPipeline::setRenderTargetSize(const tgt::ivec2& size) {
        _renderTargetSize.setValue(size);
schultezub's avatar
schultezub committed
64
65
    }

66
}