24.09., 9:00 - 11:00: Due to updates GitLab will be unavailable for some minutes between 09:00 and 11:00.

geometry1dtransferfunctioneditor.h 5.83 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
         */
Jakob Weiss's avatar
Jakob Weiss committed
73
        virtual void repaint() override;
74

75
        /// \see cgt::Painter::sizeChanged
Jakob Weiss's avatar
Jakob Weiss committed
76
        virtual void sizeChanged(const cgt::ivec2&) override;
77

78
        /// \see cgt::EventListener::mousePressEvent
Jakob Weiss's avatar
Jakob Weiss committed
79
        virtual void mousePressEvent(cgt::MouseEvent* e) override;
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
    signals:
        /**
        * To be called when the canvas is invalidated, issues new paint job.
        */
        void s_invalidated();

103 104 105 106 107 108 109 110 111 112 113
    protected slots:
        /**
         * Slot to be called when _btnAddGeometry was clicked.
         */
        void onBtnAddGeometryClicked();

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

114 115 116 117 118 119
        /**
         * Slot to be called when _cbLogScale's check state has changed.
         * \param state the checkbox's new Qt::CheckState.
         */
        void onCbLogScaleStateChanged(int state);

120 121 122 123 124 125 126 127 128 129
        /**
         * Slot to be called when the TF save button is clicked.
         */
        void onBtnSaveTFClicked();

        /**
         * Slot to be called when the TF load button is clicked.
         */
        void onBtnLoadTFClicked();

130 131 132 133 134
        /**
         * Slot reacting to the invalidated signal, issueing a new paint job
         */
        void onInvalidated();

135
    protected:
136 137 138 139 140
        /**
         * Disconnects this editor from the handled TF and cleans up everything.
         */
        void disconnectFromTf();

141 142 143
        /**
         * Performs the painting.
         */
Jakob Weiss's avatar
Jakob Weiss committed
144
        virtual void paint() override;
145

146 147 148
        /**
         * Gets called when the property has changed, so that widget can update its state.
         */
Jakob Weiss's avatar
Jakob Weiss committed
149
        virtual void updateWidgetFromProperty() override;
150

151 152 153 154 155 156 157 158 159 160
        /**
         * Updates the GeometryManipulator vector. 
         * Invalidates all of its iterators.
         */
        void updateManipulators();

        /**
         * Sets up the GUI stuff.
         */
        void setupGUI();
161

162
        std::vector<AbstractTFGeometryManipulator*> _manipulators;
163
        tbb::atomic<WholeTFGeometryManipulator*> _selectedGeometry;
164
        bool _logScale;
165
        tbb::mutex _localMutex;
166 167 168

        QGridLayout* _layout;

169
        cgt::QtThreadedCanvas* _canvas;
170 171
        QLabel* _lblIntensityLeft;
        QLabel* _lblIntensityRight;
172 173
        QPushButton* _btnAddGeometry;
        QPushButton* _btnRemoveGeometry;
174
        QCheckBox* _cbLogScale;
175 176
        QPushButton* _btnSaveTF;
        QPushButton* _btnLoadTF;
177 178 179
    };
}

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