transferfunctionproperty.h 5.68 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-2013, 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 Universität München
//      Boltzmannstr. 3, 85748 Garching b. München, 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
// 
// ================================================================================================

25
26
27
28
29
30
31
#ifndef TRANSFERFUNCTIONPROPERTY_H__
#define TRANSFERFUNCTIONPROPERTY_H__

#include "sigslot/sigslot.h"
#include "core/properties/abstractproperty.h"
#include "core/classification/abstracttransferfunction.h"

schultezub's avatar
schultezub committed
32
namespace campvis {
33

34
35
36
    /**
     * \todo    Implement correct behavior if the TF changes during locked property state.
     */
37
    class TransferFunctionProperty : public AbstractProperty {
38
39
40
41
42
    public:
        /**
         * Creates a new TransferFunctionProperty
         * \param name      Property name (unchangable!)
         * \param title     Property title (e.g. used for GUI)
schultezub's avatar
schultezub committed
43
         * \param tf        Transfer function to initialize the property with.
44
         * \param invalidationLevel  Invalidation level that this property triggers
45
         */
46
        TransferFunctionProperty(const std::string& name, const std::string& title, AbstractTransferFunction* tf, int invalidationLevel = AbstractProcessor::INVALID_RESULT);
47
48
49
50
51
52

        /**
         * Virtual Destructor
         **/
        virtual ~TransferFunctionProperty();

53
        /// \see AbstractProperty::deinit()
schultezub's avatar
schultezub committed
54
        virtual void deinit();
55
56
57
        /// \see AbstractProperty::addSharedProperty()
        virtual void addSharedProperty(AbstractProperty* prop);

58

schultezub's avatar
schultezub committed
59
60
61
62
63
        /**
         * Gets the TransferFunction of this property.
         * \note    This is a non-const pointer, if you mess with it be sure you know what you're doing!
         * \return  _transferFunction
         */
64
65
        AbstractTransferFunction* getTF();

66
67
        /**
         * Replaces the transfer function with \a tf.
68
         * TransferFunctionProperty takes ownership of \a tf.
69
70
         * \note    First triggers s_BeforeTFReplace, then deletes the current TF, replaces it with
         *          \a tf and finally triffers s_AfterTFReplace.
71
         * \param   tf  The new transfer function for this property. TransferFunctionProperty takes ownership.
72
73
74
         */
        void replaceTF(AbstractTransferFunction* tf);

schultezub's avatar
schultezub committed
75
76
77
        /**
         * Slot being called when \a _transferFunction has changed.
         */
78
        void onTFChanged();
79
80
81
82
83
84
85
        
        /**
         * Returns a DataHandle to the image for this transfer function, its pointer may be 0.
         * \note    If the data in \a imageHandle is not 0, it points to a valid ImageData object.
         * \return  _imageHandle, its pointer may be 0.
         */
        DataHandle getImageHandle() const;
86

87
88
89
90
91
92
93
        /**
         * Sets the DataHandle for this transfer function, its pointer may be 0.
         * \note    If the data in \a imageHandle is not 0, it must point to a valid ImageData object.
         * \param   imageHandle     The new DataHandle for this transfer function, if its pointer is 
         *                          not 0 it must point to a valid ImageData object.
         */
        void setImageHandle(DataHandle imageHandle);
94

95
96
97
98
99
100
101
102
103
104
105
106
107
        /**
         * Returns the flag whether to automatically fit the TF window to the data in the image handle.
         * \return  _autoFitWindowToData
         */
        bool getAutoFitWindowToData() const;

        /**
         * Sets the flag whether to automatically fit the TF window to the data in the image handle.
         * \param   newValue    New value of the flag whether to automatically fit the TF window to the data in the image handle.
         */
        void setAutoFitWindowToData(bool newValue);

        /// Signal emmitted directly before replacing the entire transfer function
108
        sigslot::signal1<AbstractTransferFunction*> s_BeforeTFReplace;
109
        /// Signal emmitted directly after replacing the entire transfer function
110
111
        sigslot::signal1<AbstractTransferFunction*> s_AfterTFReplace;

112
113
114
115
116
        /// Signal emitted when the image DataHandle for this TF has changed.
        sigslot::signal0<> s_imageHandleChanged;
        /// Signal emitted when the flag whether to automatically fit the TF window to the data in the image handle.
        sigslot::signal0<> s_autoFitWindowToDataChanged;

117
    protected:
schultezub's avatar
schultezub committed
118
        AbstractTransferFunction* _transferFunction;    ///< Transfer function of this property
119
120
        DataHandle _imageHandle;                        ///< DataHandle to the image for this transfer function. May be 0.
        bool _autoFitWindowToData;                      ///< Flag whether to automatically fit the TF window to the data in the image handle.
121
122
123
124
125
126
127

        static const std::string loggerCat_;
    };

}

#endif // TRANSFERFUNCTIONPROPERTY_H__