advdvrvis.cpp 3.81 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// ================================================================================================
// 
// This file is part of the CAMPVis Software Framework.
// 
// If not explicitly stated otherwise: Copyright (C) 2012-2013, all rights reserved,
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
//      Chair for Computer Aided Medical Procedures
//      Technische Universität München
//      Boltzmannstr. 3, 85748 Garching b. München, Germany
// 
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
// 
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file 
// except in compliance with the License. You may obtain a copy of the License at
// 
// http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software distributed under the 
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 
// either express or implied. See the License for the specific language governing permissions 
// and limitations under the License.
// 
// ================================================================================================

25
#include "advdvrvis.h"
26

27
#include "cgt/event/keyevent.h"
28
29
30
31
32
#include "core/datastructures/imagedata.h"

#include "core/classification/geometry1dtransferfunction.h"
#include "core/classification/tfgeometry1d.h"

33
#include "modules/vis/processors/advoptimizedraycaster.h"
34

35
36
37
38
39
namespace campvis {

    AdvDVRVis::AdvDVRVis(DataContainer* dc)
        : AutoEvaluationPipeline(dc)
        , _camera("camera", "Camera")
40
        , _lsp()
41
        , _imageReader()
42
        , _vr(&_canvasSize, new AdvOptimizedRaycaster(&_canvasSize))
43
44
        , _trackballEH(0)
    {
45
        addProperty(_camera);
46
47

        _trackballEH = new TrackballNavigationEventListener(&_camera, &_canvasSize);
48
        _trackballEH->addLqModeProcessor(&_vr);
49
50
        addEventListenerToBack(_trackballEH);

51
        addProcessor(&_lsp);
52
        addProcessor(&_imageReader);
53
        addProcessor(&_vr);
54
55
56
57
58
59
60
61
62
    }

    AdvDVRVis::~AdvDVRVis() {
        delete _trackballEH;
    }

    void AdvDVRVis::init() {
        AutoEvaluationPipeline::init();

63
        _imageReader.s_validated.connect(this, &AdvDVRVis::onProcessorValidated);
64

65
66
        _camera.addSharedProperty(&_vr.p_camera);
        _vr.p_outputImage.setValue("combine");
67
68
        _renderTargetID.setValue("combine");

69
70
71
72
73
74
75
76
77
78
        _imageReader.p_url.setValue(ShdrMgr.completePath("/modules/vis/sampledata/smallHeart.mhd"));
        _imageReader.p_targetImageID.setValue("reader.output");
        _imageReader.p_targetImageID.addSharedProperty(&_vr.p_inputVolume);

        Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, tgt::vec2(0.f, .05f));
        dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.12f, .15f), tgt::col4(85, 0, 0, 128), tgt::col4(255, 0, 0, 128)));
        dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.19f, .28f), tgt::col4(89, 89, 89, 155), tgt::col4(89, 89, 89, 155)));
        dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.41f, .51f), tgt::col4(170, 170, 128, 64), tgt::col4(192, 192, 128, 64)));
        static_cast<TransferFunctionProperty*>(_vr.getNestedProperty("RaycasterProps::TransferFunction"))->replaceTF(dvrTF);
        static_cast<FloatProperty*>(_vr.getNestedProperty("RaycasterProps::SamplingRate"))->setValue(4.f);
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
    }

    void AdvDVRVis::deinit() {
        _canvasSize.s_changed.disconnect(this);
        AutoEvaluationPipeline::deinit();
    }

    void AdvDVRVis::onProcessorValidated(AbstractProcessor* processor) {
        if (processor == &_imageReader) {
            // update camera
            ScopedTypedData<ImageData> img(*_data, _imageReader.p_targetImageID.getValue());
            if (img != 0) {
                _trackballEH->reinitializeCamera(img);
            }
        }
    }


}