OpenWalnut  1.5.0dev
WMTransferFunctionColorBar.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WMTRANSFERFUNCTIONCOLORBAR_H
26 #define WMTRANSFERFUNCTIONCOLORBAR_H
27 
28 #include <memory>
29 #include <string>
30 
31 #include <osg/Projection>
32 
33 #include "core/common/WPropertyVariable.h"
34 #include "core/dataHandler/WDataSetSingle.h"
35 #include "core/kernel/WModule.h"
36 #include "core/kernel/WModuleInputData.h"
37 
38 /**
39  * This module simply registers the given dataset to the texture handling mechanism. This allows all outputs to be shown as a texture.
40  *
41  * \ingroup modules
42  */
44 {
45 public:
46  /**
47  * Standard constructor.
48  */
50 
51  /**
52  * Destructor.
53  */
55 
56  /**
57  * Gives back the name of this module.
58  * \return the module's name.
59  */
60  virtual const std::string getName() const;
61 
62  /**
63  * Gives back a description of this module.
64  * \return description of module.
65  */
66  virtual const std::string getDescription() const;
67 
68  /**
69  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
70  * should never be initialized or modified in some other way. A simple new instance is required.
71  *
72  * \return the prototype used to create every module in OpenWalnut.
73  */
74  virtual std::shared_ptr< WModule > factory() const;
75 
76  /**
77  * Get the icon for this module in XPM format.
78  * \return The icon.
79  */
80  virtual const char** getXPMIcon() const;
81 
82 protected:
83  /**
84  * Entry point after loading the module. Runs in separate thread.
85  */
86  virtual void moduleMain();
87 
88  /**
89  * Initialize the connectors this module is using.
90  */
91  virtual void connectors();
92 
93  /**
94  * Initialize the properties for this module.
95  */
96  virtual void properties();
97 
98  /**
99  * Callback for m_active. Overwrite this in your modules to handle m_active changes separately.
100  */
101  virtual void activate();
102 private:
103  /**
104  * A condition used to notify about changes in several properties.
105  */
106  std::shared_ptr< WCondition > m_propCondition;
107 
108  /**
109  * Input connector required by this module.
110  */
111  std::shared_ptr< WModuleInputData< WDataSetSingle > > m_input;
112 
113  /**
114  * The min of the current dataset. We store them here to avoid many calls to getTexture()->minimum()->get() and scale()->get().
115  */
116  double m_valueMin;
117 
118  /**
119  * The scaling factor of the current dataset. We store them here to avoid many calls to getTexture()->minimum()->get() and scale()->get().
120  */
121  double m_valueScale;
122 
123  /**
124  * The number of colorbar labels
125  */
127 
128  /**
129  * Show colorbar name?
130  */
131  WPropBool m_colorBarName;
132 
133  /**
134  * Show the border?
135  */
136  WPropBool m_colorBarBorder;
137 
138  /**
139  * Maximum scaling factor of the current dataset.
140  */
141  WPropDouble m_maxScaleValue;
142 
143  /**
144  * Minimum scaling factor of the current dataset.
145  */
146  WPropDouble m_minScaleValue;
147 
148  /**
149  * Description of the color bar.
150  */
152 
153  /**
154  * The projection node for the colorbar and labels
155  */
156  osg::ref_ptr< osg::Projection > m_barProjection;
157 
158  /**
159  * The colorbar.
160  */
161  osg::ref_ptr< osg::Geode > m_colorBar;
162 
163  /**
164  * The colorbar scale labels
165  */
166  osg::ref_ptr< osg::Geode > m_scaleLabels;
167 
168  /**
169  * Whether a custom min max was set.
170  */
172 
173  /**
174  * Callback which adds/removes scale labels to the colorbar.
175  *
176  * \param scaleLabels the geode containing the labels.
177  */
178  void updateColorbarScale( osg::Node* scaleLabels );
179 };
180 
181 #endif // WMTRANSFERFUNCTIONCOLORBAR_H
This module simply registers the given dataset to the texture handling mechanism.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
WPropDouble m_maxScaleValue
Maximum scaling factor of the current dataset.
std::shared_ptr< WModuleInputData< WDataSetSingle > > m_input
Input connector required by this module.
osg::ref_ptr< osg::Geode > m_scaleLabels
The colorbar scale labels.
WPropBool m_colorBarName
Show colorbar name?
WPropString m_colorBarDescription
Description of the color bar.
WMTransferFunctionColorBar()
Standard constructor.
virtual void moduleMain()
Entry point after loading the module.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
osg::ref_ptr< osg::Projection > m_barProjection
The projection node for the colorbar and labels.
virtual const std::string getDescription() const
Gives back a description of this module.
osg::ref_ptr< osg::Geode > m_colorBar
The colorbar.
WPropInt m_colorBarLabels
The number of colorbar labels.
bool m_customScale
Whether a custom min max was set.
double m_valueMin
The min of the current dataset.
virtual void activate()
Callback for m_active.
virtual void connectors()
Initialize the connectors this module is using.
virtual void properties()
Initialize the properties for this module.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
void updateColorbarScale(osg::Node *scaleLabels)
Callback which adds/removes scale labels to the colorbar.
double m_valueScale
The scaling factor of the current dataset.
WPropDouble m_minScaleValue
Minimum scaling factor of the current dataset.
WPropBool m_colorBarBorder
Show the border?
virtual const std::string getName() const
Gives back the name of this module.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72