OpenWalnut  1.5.0dev
WMColormapper.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 WMCOLORMAPPER_H
26 #define WMCOLORMAPPER_H
27 
28 #include <memory>
29 #include <string>
30 
31 #include <osg/Projection>
32 
33 #include "core/common/WItemSelection.h"
34 #include "core/common/WItemSelector.h"
35 #include "core/common/WPropertyVariable.h"
36 #include "core/common/math/WInterval.h"
37 #include "core/dataHandler/WDataSetSingle.h"
38 #include "core/kernel/WModule.h"
39 #include "core/kernel/WModuleInputData.h"
40 
41 /**
42  * This module simply registers the given dataset to the texture handling mechanism. This allows all outputs to be shown as a texture.
43  *
44  * \ingroup modules
45  */
46 class WMColormapper: public WModule
47 {
48 public:
49  /**
50  * Standard constructor.
51  */
52  WMColormapper();
53 
54  /**
55  * Destructor.
56  */
58 
59  /**
60  * Gives back the name of this module.
61  * \return the module's name.
62  */
63  virtual const std::string getName() const;
64 
65  /**
66  * Gives back a description of this module.
67  * \return description of module.
68  */
69  virtual const std::string getDescription() const;
70 
71  /**
72  * Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
73  * should never be initialized or modified in some other way. A simple new instance is required.
74  *
75  * \return the prototype used to create every module in OpenWalnut.
76  */
77  virtual std::shared_ptr< WModule > factory() const;
78 
79  /**
80  * Get the icon for this module in XPM format.
81  * \return The icon.
82  */
83  virtual const char** getXPMIcon() const;
84 
85 protected:
86  /**
87  * Entry point after loading the module. Runs in separate thread.
88  */
89  virtual void moduleMain();
90 
91  /**
92  * Initialize the connectors this module is using.
93  */
94  virtual void connectors();
95 
96  /**
97  * Initialize the properties for this module.
98  */
99  virtual void properties();
100 
101  /**
102  * Callback for m_active. Overwrite this in your modules to handle m_active changes separately.
103  */
104  virtual void activate();
105 private:
106  /**
107  * A condition used to notify about changes in several properties.
108  */
109  std::shared_ptr< WCondition > m_propCondition;
110 
111  std::shared_ptr< WModuleInputData< WDataSetSingle > > m_input; //!< Input connector required by this module.
112 
113  /**
114  * This is a pointer to the dataset the module is currently working on.
115  */
116  std::shared_ptr< WDataSetSingle > m_lastDataSet;
117 
118  /**
119  * The min of the current dataset. We store them here to avoid many calls to getTexture()->minimum()->get() and scale()->get().
120  */
121  double m_valueMin;
122 
123  /**
124  * The scaling factor of the current dataset. We store them here to avoid many calls to getTexture()->minimum()->get() and scale()->get().
125  */
126  double m_valueScale;
127 
128  /**
129  * If true, a colorbar is shown.
130  */
131  WPropBool m_showColorbar;
132 
133  /**
134  * The number of colorbar labels
135  */
137 
138  /**
139  * Show colorbar name?
140  */
141  WPropBool m_colorBarName;
142 
143  /**
144  * Show the border?
145  */
146  WPropBool m_colorBarBorder;
147 
148  /**
149  * Color bar color: border.
150  */
152 
153  /**
154  * Color bar color: name text.
155  */
157 
158  /**
159  * Color bar color: name outline color.
160  */
162 
163  /**
164  * Color bar color: labels text.
165  */
167 
168  /**
169  * Color bar color: labels outline color.
170  */
172 
173  /**
174  * Color bar color: labels bar color.
175  */
177 
178  /**
179  * Character size of the labels.
180  */
181  WPropDouble m_colorBarLabelsSize;
182 
183  /**
184  * Character size of the name label.
185  */
186  WPropDouble m_colorBarNameSize;
187 
188  /**
189  * This property holds the name of the texture to use if the texture itself is unnamed.
190  */
191  WPropString m_defaultName;
192 
193  /**
194  * The projection node for the colorbar and labels
195  */
196  osg::ref_ptr< osg::Projection > m_barProjection;
197 
198  /**
199  * The colorbar.
200  */
201  osg::ref_ptr< osg::Geode > m_colorBar;
202 
203  /**
204  * Updates the label for the dataset name
205  *
206  * \param label the label to update
207  */
208  void updateColorbarName( osg::Drawable* label );
209 
210  /**
211  * The colorbar scale labels
212  */
213  osg::ref_ptr< osg::Geode > m_scaleLabels;
214 
215  /**
216  * Callback which adds/removes scale labels to the colorbar.
217  *
218  * \param scaleLabels the geode containing the labels.
219  */
220  void updateColorbarScale( osg::Node* scaleLabels );
221 
222  /**
223  * Callback for updating the border of the colorbar.
224  *
225  * \param border border geometry.
226  */
227  void updateColorbarBorder( osg::Drawable* border );
228 
229  /**
230  * True if window leveling is active
231  */
233 
234  /**
235  * Window level.
236  */
238 
239  /**
240  * If true, the labels get re-drawn
241  */
243 
244  /**
245  * Position of the colorbar name.
246  */
247  WPropSelection m_colorbarNamePosition;
248 
249  /**
250  * A list of colorbar name positions
251  */
252  std::shared_ptr< WItemSelection > m_possibleNamePositions;
253 };
254 
255 #endif // WMCOLORMAPPER_H
This module simply registers the given dataset to the texture handling mechanism.
Definition: WMColormapper.h:47
virtual const std::string getDescription() const
Gives back a description of this module.
osg::ref_ptr< osg::Geode > m_colorBar
The colorbar.
std::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
WPropDouble m_colorBarNameSize
Character size of the name label.
std::shared_ptr< WModuleInputData< WDataSetSingle > > m_input
Input connector required by this module.
WIntervalDouble m_windowLevel
Window level.
WPropColor m_colorBarLabelsColor
Color bar color: labels text.
bool m_windowLevelEnabled
True if window leveling is active.
std::shared_ptr< WDataSetSingle > m_lastDataSet
This is a pointer to the dataset the module is currently working on.
virtual void moduleMain()
Entry point after loading the module.
osg::ref_ptr< osg::Projection > m_barProjection
The projection node for the colorbar and labels.
WPropDouble m_colorBarLabelsSize
Character size of the labels.
void updateColorbarScale(osg::Node *scaleLabels)
Callback which adds/removes scale labels to the colorbar.
std::shared_ptr< WItemSelection > m_possibleNamePositions
A list of colorbar name positions.
virtual void connectors()
Initialize the connectors this module is using.
virtual void activate()
Callback for m_active.
WPropInt m_colorBarLabels
The number of colorbar labels.
virtual const std::string getName() const
Gives back the name of this module.
WPropColor m_colorBarNameColor
Color bar color: name text.
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...
WPropBool m_showColorbar
If true, a colorbar is shown.
WPropBool m_colorBarBorder
Show the border?
bool m_needScaleUpdate
If true, the labels get re-drawn.
virtual void properties()
Initialize the properties for this module.
WPropSelection m_colorbarNamePosition
Position of the colorbar name.
double m_valueMin
The min of the current dataset.
WPropColor m_colorBarBorderColor
Color bar color: border.
WPropString m_defaultName
This property holds the name of the texture to use if the texture itself is unnamed.
double m_valueScale
The scaling factor of the current dataset.
virtual const char ** getXPMIcon() const
Get the icon for this module in XPM format.
WPropBool m_colorBarName
Show colorbar name?
osg::ref_ptr< osg::Geode > m_scaleLabels
The colorbar scale labels.
void updateColorbarBorder(osg::Drawable *border)
Callback for updating the border of the colorbar.
WPropColor m_colorBarLabelsOutlineColor
Color bar color: labels outline color.
~WMColormapper()
Destructor.
WMColormapper()
Standard constructor.
WPropColor m_colorBarLabelsBarColor
Color bar color: labels bar color.
void updateColorbarName(osg::Drawable *label)
Updates the label for the dataset name.
WPropColor m_colorBarNameOutlineColor
Color bar color: name outline color.
Class representing a single module of OpenWalnut.
Definition: WModule.h:72