geometry1dtransferfunctioneditor.h 5.32 KB
Newer Older
1
2
// ================================================================================================
// 
schultezub's avatar
schultezub committed
3
// This file is part of the CAMPVis Software Framework.
4
// 
5
// If not explicitly stated otherwise: Copyright (C) 2012-2015, all rights reserved,
schultezub's avatar
schultezub committed
6
//      Christian Schulte zu Berge <christian.szb@in.tum.de>
7
//      Chair for Computer Aided Medical Procedures
8
9
//      Technische Universitaet Muenchen
//      Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
10
// 
schultezub's avatar
schultezub committed
11
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
12
// 
13
14
15
16
// 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
17
// 
18
19
20
21
// 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.
22
23
24
// 
// ================================================================================================

schultezub's avatar
schultezub committed
25
26
#ifndef GEOMETRY1DTRANSFERFUNCTIONEDITOR_H__
#define GEOMETRY1DTRANSFERFUNCTIONEDITOR_H__
27

schultezub's avatar
schultezub committed
28
#include "tbb/mutex.h"
29
30
#include "cgt/painter.h"
#include "cgt/event/eventlistener.h"
schultezub's avatar
schultezub committed
31
#include "core/classification/tfgeometry1d.h"
32
33
#include "application/gui/properties/abstracttransferfunctioneditor.h"

34
class QCheckBox;
35
36
class QGridLayout;
class QLabel;
37
class QPushButton;
38

39
namespace cgt {
40
41
42
43
    class QtThreadedCanvas;
    class Shader;
}

schultezub's avatar
schultezub committed
44
namespace campvis {
45
    class ColorPickerWidget;
schultezub's avatar
schultezub committed
46
    class Geometry1DTransferFunction;
47
    class AbstractTFGeometryManipulator;
48
    class WholeTFGeometryManipulator;
49
50

    /**
schultezub's avatar
schultezub committed
51
     * Editor widget for a Geometry1DTransferFunction.
52
     */
53
    class CAMPVIS_APPLICATION_API Geometry1DTransferFunctionEditor : public AbstractTransferFunctionEditor, public cgt::EventListener, public cgt::Painter {
54
55
56
57
58
        Q_OBJECT;

    public:
        /**
         * Creates a new editor widget for the for the TransferFunctionProperty \a property.
59
         * \param   prop        TransferFunctionProperty to generate the editor for.
60
61
62
         * \param   tf          The transfer function the editor shall handle.
         * \param   parent      Parent Qt widget
         */
63
        Geometry1DTransferFunctionEditor(TransferFunctionProperty* prop, Geometry1DTransferFunction* tf, QWidget* parent = 0);
64
65
66
67

        /**
         * Destructor
         */
schultezub's avatar
schultezub committed
68
        virtual ~Geometry1DTransferFunctionEditor();
69
70

        /**
71
         * Schedule a repaint job for the editor's render target
72
         */
73
        virtual void repaint();
74

75
76
        /// \see cgt::Painter::sizeChanged
        virtual void sizeChanged(const cgt::ivec2&);
77

78
79
        /// \see cgt::EventListener::mousePressEvent
        virtual void mousePressEvent(cgt::MouseEvent* e);
80

81
82
83
84
85
        /**
         * Slot to be called when the geometry vector of the transfer function has changed.
         */
        void onGeometryCollectionChanged();

86
87
88
89
90
        /**
         * Slot to be called when the handled TF is about to be deleted.
         */
        void onTfAboutToBeDeleted();

91
92
93
94
95
        /**
         * Slot tp be called when a WholeTFGeometryManipulator was selected.
         * \param   the selected WholeTFGeometryManipulator
         */
        void onWholeTFGeometryManipulatorSelected(WholeTFGeometryManipulator* wtf /* :) */);
96

97
98
99
100
101
102
103
104
105
106
107
    protected slots:
        /**
         * Slot to be called when _btnAddGeometry was clicked.
         */
        void onBtnAddGeometryClicked();

        /**
         * Slot to be called when _btnRemoveGeometry was clicked.
         */
        void onBtnRemoveGeometryClicked();

108
109
110
111
112
113
        /**
         * Slot to be called when _cbLogScale's check state has changed.
         * \param state the checkbox's new Qt::CheckState.
         */
        void onCbLogScaleStateChanged(int state);

114
    protected:
115
116
117
118
119
        /**
         * Disconnects this editor from the handled TF and cleans up everything.
         */
        void disconnectFromTf();

120
121
122
123
124
        /**
         * Performs the painting.
         */
        virtual void paint();

125
126
127
128
129
        /**
         * Gets called when the property has changed, so that widget can update its state.
         */
        virtual void updateWidgetFromProperty();

130
131
132
133
134
135
        /**
         * Updates the GeometryManipulator vector. 
         * Invalidates all of its iterators.
         */
        void updateManipulators();

136
137
138
139
140
        /**
         * To be called when the canvas is invalidated, issues new paint job.
         */
        void invalidate();

141
142
143
144
        /**
         * Sets up the GUI stuff.
         */
        void setupGUI();
145

146
        std::vector<AbstractTFGeometryManipulator*> _manipulators;
147
        tbb::atomic<WholeTFGeometryManipulator*> _selectedGeometry;
148
        bool _logScale;
149
        tbb::mutex _localMutex;
150
151
152

        QGridLayout* _layout;

153
        cgt::QtThreadedCanvas* _canvas;
154
155
        QLabel* _lblIntensityLeft;
        QLabel* _lblIntensityRight;
156
157
        QPushButton* _btnAddGeometry;
        QPushButton* _btnRemoveGeometry;
158
        QCheckBox* _cbLogScale;
159
160
161
    };
}

schultezub's avatar
schultezub committed
162
#endif // GEOMETRY1DTRANSFERFUNCTIONEDITOR_H__