OpenWalnut  1.5.0dev
WMColormapper.cpp
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 #include <memory>
26 #include <string>
27 #include <vector>
28 
29 #include <osg/Geode>
30 #include <osg/Projection>
31 
32 #include "WMColormapper.h"
33 #include "WMColormapper.xpm"
34 #include "core/dataHandler/WDataTexture3D.h"
35 #include "core/graphicsEngine/WGEColormapping.h"
36 #include "core/graphicsEngine/WGEGeodeUtils.h"
37 #include "core/graphicsEngine/callbacks/WGEFunctorCallback.h"
38 #include "core/graphicsEngine/callbacks/WGENodeMaskCallback.h"
39 #include "core/graphicsEngine/shaders/WGEShader.h"
40 #include "core/graphicsEngine/widgets/labeling/WGELabel.h"
41 #include "core/kernel/WKernel.h"
42 
43 // This line is needed by the module loader to actually find your module.
44 W_LOADABLE_MODULE( WMColormapper )
45 
47  WModule(),
48  m_windowLevel( 0, 1 )
49 {
50  // initialize
51 }
52 
54 {
55  // cleanup
57 }
58 
59 std::shared_ptr< WModule > WMColormapper::factory() const
60 {
61  return std::shared_ptr< WModule >( new WMColormapper() );
62 }
63 
64 const char** WMColormapper::getXPMIcon() const
65 {
66  return WMColormapper_xpm;
67 }
68 
69 const std::string WMColormapper::getName() const
70 {
71  return "Colormapper";
72 }
73 
74 const std::string WMColormapper::getDescription() const
75 {
76  return "Can use the input as a texture that can be mapped to the navslices and so on.";
77 }
78 
80 {
81  m_input = WModuleInputData< WDataSetSingle >::createAndAdd( shared_from_this(), "input", "Input to apply as texture." );
82 
83  // call WModules initialization
85 }
86 
88 {
89  m_propCondition = std::shared_ptr< WCondition >( new WCondition() );
90 
91  m_defaultName = m_properties->addProperty( "Default Name", "This specifies the name to use for textures which are not yet named.",
92  std::string( "Unnamed" ), true );
93 
94  WPropGroup colorBarGroup = m_properties->addPropertyGroup( "Colorbar", "The colorbar with several properties." );
95  m_showColorbar = colorBarGroup->addProperty( "Show Colorbar", "If true, a colorbar is shown for the current colormap.", false );
96 
97  WPropGroup colorBarBorderGroup = colorBarGroup->addPropertyGroup( "Border", "The colorbar border properties." );
98  WPropGroup colorBarNameLabelGroup = colorBarGroup->addPropertyGroup( "Name Label", "The colorbar name label properties." );
99  WPropGroup colorBarLabelsGroup = colorBarGroup->addPropertyGroup( "Labels", "The colorbar label properties." );
100 
101  m_colorBarBorder = colorBarBorderGroup->addProperty( "Show Border", "If true, a thin white border is shown around the colorbar.", true );
102  m_colorBarBorderColor = colorBarBorderGroup->addProperty( "Border Color", "Color of the border around the colorbar.",
103  WColor( 1.0, 1.0, 1.0, 1.0 ) );
104 
105  m_colorBarName = colorBarNameLabelGroup->addProperty( "Show Name", "If true, a shortened version of the data name is shown.", true );
106  m_colorBarNameSize = colorBarNameLabelGroup->addProperty( "Text Size", "This defines the size of a character in normalized screen coordinates."
107  "A value of 1 means the char is as large as the view.", 0.015 );
108  m_colorBarNameSize->setMin( 0.0 );
109  m_colorBarNameSize->setMax( 0.25 );
110 
111  m_colorBarNameColor = colorBarNameLabelGroup->addProperty( "Name Color", "Color of the name text", WColor( 0.9, 0.9, 0.9, 1.0 ) );
112  m_colorBarNameOutlineColor = colorBarNameLabelGroup->addProperty( "Name Outline Color", "Color of the name outline", defaultColor::BLACK );
113 
114  m_possibleNamePositions = std::shared_ptr< WItemSelection >( new WItemSelection() );
115  m_possibleNamePositions->addItem( "Side", "On the side." );
116  m_possibleNamePositions->addItem( "Below", "Below the colorbar." ); // NOTE: you can add XPM images here.
117  m_possibleNamePositions->addItem( "Above", "Above the colorbar." );
118  m_colorbarNamePosition = colorBarNameLabelGroup->addProperty( "Colorbar Name Position", "Where to place the name.",
119  m_possibleNamePositions->getSelectorFirst(),
120  m_propCondition );
123 
124  m_colorBarLabels = colorBarLabelsGroup->addProperty( "Colorbar Labels", "This defines the number of labels.", 10 );
125  m_colorBarLabels->setMin( 2 );
126  m_colorBarLabels->setMax( 100 );
127  m_colorBarLabelsSize = colorBarLabelsGroup->addProperty( "Text Size", "This defines the size of a character in normalized screen coordinates."
128  "A value of 1 means the char is as large as the view.", 0.015 );
129  m_colorBarLabelsSize->setMin( 0.0 );
130  m_colorBarLabelsSize->setMax( 0.25 );
131  m_colorBarLabelsColor = colorBarLabelsGroup->addProperty( "Label Color", "Color of the label text", WColor( 0.9, 0.9, 0.9, 1.0 ) );
132  m_colorBarLabelsOutlineColor = colorBarLabelsGroup->addProperty( "Label Outline Color", "Color of the label outline.", defaultColor::BLACK );
133  m_colorBarLabelsBarColor = colorBarLabelsGroup->addProperty( "Label Bar Color", "Color of the small bar for each label.", defaultColor::WHITE );
134 
136 }
137 
138 /**
139  * Formats a given string to have the specified maximum length.
140  *
141  * \param str the string
142  * \param maxLen max length
143  *
144  * \return formatted string
145  */
146 std::string format( std::string str, size_t maxLen = 45 )
147 {
148  // string will be at least 9 chars long: because of " [...] " + first and last char.
149  WAssert( maxLen >= 9, "MaxLen has to be 9 or more." );
150  std::ostringstream ss;
151 
152  // cut away some stuff
153  if( str.length() > maxLen )
154  {
155  size_t keep = maxLen - 3; // how much chars to keep?
156  size_t keepFront = keep / 2;
157  size_t keepEnd = keep - keepFront;
158 
159  ss << str.substr( 0, keepFront ) << " [...] " << str.substr( str.length() - keepEnd, keepEnd );
160  }
161  else
162  {
163  ss << str;
164  }
165  return ss.str();
166 }
167 
168 /**
169  * Formats a number properly to be usable as label
170  *
171  * \tparam T the type of value.
172  * \param number the number to format
173  *
174  * \return the formated number
175  */
176 template< typename T >
177 std::string format( T number )
178 {
179  std::ostringstream ss;
180  ss.precision( 3 );
181  ss << number;
182  return ss.str();
183 }
184 
186 {
187  // let the main loop awake if the data changes or the properties changed.
188  m_moduleState.setResetable( true, true );
189  m_moduleState.add( m_input->getDataChangedCondition() );
191 
192  osg::ref_ptr< WGEShader > colormapShader = osg::ref_ptr< WGEShader > ( new WGEShader( "WMColormapper", m_localPath ) );
193 
194  // signal ready state
195  ready();
196 
197  // loop until the module container requests the module to quit
198  while( !m_shutdownFlag() )
199  {
200  // Now, the moduleState variable comes into play. The module can wait for the condition, which gets fired whenever the input receives data
201  // or an property changes. The main loop now waits until something happens.
202  debugLog() << "Waiting ...";
204 
205  // woke up since the module is requested to finish
206  if( m_shutdownFlag() )
207  {
208  break;
209  }
210 
211  // has the data changed?
212  if( m_input->handledUpdate() )
213  {
214  WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_barProjection );
215  colormapShader->deactivate( m_colorBar );
216 
217  std::shared_ptr< WDataSetSingle > dataSet = m_input->getData();
218 
219  // add a colorbar
220  if( dataSet && dataSet->isTexture() )
221  {
222  // create camera oriented 2d projection
223  m_barProjection = new osg::Projection();
224  m_barProjection->addUpdateCallback( new WGENodeMaskCallback( m_showColorbar ) );
225  m_barProjection->addUpdateCallback( new WGENodeMaskCallback( m_active ) );
226  m_barProjection->setMatrix( osg::Matrix::ortho2D( 0, 1.0, 0, 1.0 ) );
227  m_barProjection->getOrCreateStateSet()->setRenderBinDetails( 15, "RenderBin" );
228  m_barProjection->getOrCreateStateSet()->setDataVariance( osg::Object::DYNAMIC );
229  m_barProjection->getOrCreateStateSet()->setMode( GL_DEPTH_TEST, osg::StateAttribute::OFF );
230  m_barProjection->getOrCreateStateSet()->setMode( GL_LIGHTING, osg::StateAttribute::OFF );
231 
232  float borderWidth = 0.001;
233 
234  // create a colorbar geode
235  m_colorBar = wge::genFinitePlane( osg::Vec3( 0.025, 0.1, 0.0 ), osg::Vec3( 0.025, 0.0, 0.0 ), osg::Vec3( 0.0, 0.8, 0.0 ) );
236  osg::ref_ptr< osg::Geode > colorBarBorder = wge::genFinitePlane( osg::Vec3( 0.025 - borderWidth, 0.1 - borderWidth, -0.1 ),
237  osg::Vec3( 0.025 + 2.0 * borderWidth, 0.0, -0.1 ),
238  osg::Vec3( 0.0, 0.8 + 2.0 * borderWidth, -0.1 ) );
239  colorBarBorder->getDrawable( 0 )->setUpdateCallback( new WGEFunctorCallback< osg::Drawable >(
240  boost::bind( &WMColormapper::updateColorbarBorder, this, boost::placeholders::_1 ) )
241  );
242 
243  m_colorBar->getOrCreateStateSet()->addUniform( new WGEPropertyUniform< WPropSelection >( "u_colormap",
244  dataSet->getTexture()->colormap() ) );
245  colormapShader->apply( m_colorBar );
246 
247  // add the name label
248  osg::ref_ptr< WGELabel > nameLabel = new WGELabel();
249  nameLabel->setText( format( dataSet->getTexture()->name()->get() ) );
250  nameLabel->setPosition( osg::Vec3( 0.015, 0.93, 0.0 ) );
251  nameLabel->setCharacterSize( 0.020 );
252  nameLabel->setLayout( osgText::TextBase::LEFT_TO_RIGHT );
253  nameLabel->setAlignment( osgText::Text::BASE_LINE );
254  nameLabel->setUpdateCallback( new WGEFunctorCallback< osg::Drawable >(
255  boost::bind( &WMColormapper::updateColorbarName, this, boost::placeholders::_1 ) )
256  );
257 
258  // the bar and the labels need to be added in an identity modelview matrix node
259  osg::ref_ptr< osg::MatrixTransform > matrix = new osg::MatrixTransform();
260  matrix->setMatrix( osg::Matrix::identity() );
261  matrix->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
262 
263  // this geode contains the labels
264  m_needScaleUpdate = true;
265  osg::ref_ptr< osg::Geode > labels = new osg::Geode();
266  labels->addDrawable( nameLabel );
267  m_scaleLabels = new osg::Geode();
268  m_scaleLabels->addUpdateCallback( new WGEFunctorCallback< osg::Node >(
269  boost::bind( &WMColormapper::updateColorbarScale, this, boost::placeholders::_1 )
270  ) );
271 
272  // we need to adapt the labels to the window level
273  // we therefore watch the window level properties
274  m_windowLevelEnabled = dataSet->getTexture()->windowEnabled()->get();
275  m_windowLevel = dataSet->getTexture()->window()->get();
276 
277  // set some callbacks
278  colorBarBorder->addUpdateCallback( new WGENodeMaskCallback( m_colorBarBorder ) );
279  labels->addUpdateCallback( new WGENodeMaskCallback( m_colorBarName ) );
280 
281  // build pipeline
282  matrix->addChild( colorBarBorder );
283  matrix->addChild( m_colorBar );
284  matrix->addChild( m_scaleLabels );
285  matrix->addChild( labels );
286  m_barProjection->addChild( matrix );
287 
288  m_valueMin = dataSet->getTexture()->minimum()->get();
289  m_valueScale = dataSet->getTexture()->scale()->get();
290 
291  // add
292  WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_barProjection );
293  }
294 
295  // if the texture has no name, use the default name property value
296  if( dataSet && dataSet->isTexture() && ( dataSet->getTexture()->name()->get() == std::string( "Unnamed" ) ) )
297  {
298  dataSet->getTexture()->name()->setRecommendedValue( m_defaultName->get() );
299  }
300 
301  // replace texture instead of removing it?
302  if( dataSet && dataSet->isTexture() && m_lastDataSet )
303  {
304  debugLog() << "Replacing texture \"" << m_lastDataSet->getTexture()->name()->get() << "\" with \"" <<
305  dataSet->getTexture()->name()->get() << "\".";
306 
307  // set the _recommended_ values from the previous ones
308  // to avoid a critical issue ( #237 ) with the minimum and scaler properties of the texture, we explicitly exclude them here.
309  std::vector< std::string > excludes;
310  excludes.push_back( "Minimum" );
311  excludes.push_back( "Scale" );
312  dataSet->getTexture()->getProperties()->set( m_lastDataSet->getTexture()->getProperties(), excludes, true );
313 
314  // finally, set the new properties (and remove the old props)
315  m_properties->removeProperty( m_lastDataSet->getTexture()->getProperties() );
316  m_infoProperties->removeProperty( m_lastDataSet->getTexture()->getInformationProperties() );
317  m_properties->addProperty( dataSet->getTexture()->getProperties() );
318  m_infoProperties->addProperty( dataSet->getTexture()->getInformationProperties() );
319 
320  // tell the colormapper about it
321  WGEColormapping::replaceTexture( m_lastDataSet->getTexture(), dataSet->getTexture() );
322  m_lastDataSet = dataSet;
323  }
324  else
325  {
326  // de-register last input
327  if( m_lastDataSet )
328  {
329  debugLog() << "Removing previous texture \"" << m_lastDataSet->getTexture()->name()->get() << "\".";
330  m_properties->removeProperty( m_lastDataSet->getTexture()->getProperties() );
331  m_infoProperties->removeProperty( m_lastDataSet->getTexture()->getInformationProperties() );
333  m_lastDataSet.reset();
334  }
335 
336  // register only valid data
337  if( dataSet && dataSet->isTexture() )
338  {
339  m_lastDataSet = dataSet;
340 
341  // register new
342  debugLog() << "Registering new texture \"" << m_lastDataSet->getTexture()->name()->get() << "\".";
343  m_properties->addProperty( m_lastDataSet->getTexture()->getProperties() );
344  m_infoProperties->addProperty( m_lastDataSet->getTexture()->getInformationProperties() );
346  }
347  }
348  }
349  }
350 
351  // remove if module is removed
352  if( m_lastDataSet )
353  {
354  debugLog() << "Removing previous texture \"" << m_lastDataSet->getTexture()->name()->get() << "\".";
356  // NOTE: the props get removed automatically
357  }
358 
359  // remove colorbar and its labels
360  WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_barProjection );
361 }
362 
364 {
365  // deactivate the output if wanted
366  if( m_lastDataSet )
367  {
368  m_lastDataSet->getTexture()->active()->set( m_active->get( true ) );
369  }
370 
371  // Always call WModule's activate!
373 }
374 
375 void WMColormapper::updateColorbarBorder( osg::Drawable* border )
376 {
377  osg::ref_ptr< osg::Vec4Array > colors = new osg::Vec4Array;
378  colors->push_back( m_colorBarBorderColor->get() );
379  dynamic_cast< osg::Geometry* >( border )->setColorArray( colors );
380 }
381 
382 void WMColormapper::updateColorbarName( osg::Drawable* label )
383 {
384  WGELabel* l = dynamic_cast< WGELabel* >( label );
385 
386  if( m_lastDataSet )
387  {
388  l->setText( format( m_lastDataSet->getTexture()->name()->get() ) );
389  }
390 
391  if( m_colorbarNamePosition->changed() || m_colorBarNameSize->changed( true ) )
392  {
393  switch( m_colorbarNamePosition->get( true ) )
394  {
395  case 0: // side
396  l->setPosition( osg::Vec3( 0.015, 0.9, 0.0 ) );
397  l->setCharacterSize( m_colorBarNameSize->get() );
398  l->setLayout( osgText::TextBase::VERTICAL );
399  break;
400  case 1: // below
401  l->setPosition( osg::Vec3( 0.015, 0.06, 0.0 ) );
402  l->setCharacterSize( m_colorBarNameSize->get() );
403  l->setLayout( osgText::TextBase::LEFT_TO_RIGHT );
404  break;
405  case 2: // above
406  l->setPosition( osg::Vec3( 0.015, 0.93, 0.0 ) );
407  l->setCharacterSize( m_colorBarNameSize->get() );
408  l->setLayout( osgText::TextBase::LEFT_TO_RIGHT );
409  break;
410  default:
411  break;
412  }
413  }
414  l->setColor( m_colorBarNameColor->get() );
415  l->setBackdropColor( m_colorBarNameOutlineColor->get() );
416 }
417 
418 void WMColormapper::updateColorbarScale( osg::Node* scaleLabels )
419 {
420  if( m_needScaleUpdate || m_colorBarLabels->changed( true ) ||
421  m_colorBarLabelsColor->changed( true ) ||
422  m_colorBarLabelsOutlineColor->changed( true ) ||
423  m_colorBarLabelsBarColor->changed( true ) ||
424  m_colorBarLabelsSize->changed( true ) ||
425  ( m_windowLevelEnabled != m_lastDataSet->getTexture()->windowEnabled()->get() ) ||
426  ( m_windowLevel != m_lastDataSet->getTexture()->window()->get() )
427  )
428  {
429  m_needScaleUpdate = false;
430  m_windowLevelEnabled = m_lastDataSet->getTexture()->windowEnabled()->get();
431  m_windowLevel = m_lastDataSet->getTexture()->window()->get();
432 
433  const double labelXPos = 0.060;
434  osg::Geode* g = scaleLabels->asGeode();
435  g->removeDrawables( 0, g->getNumDrawables() );
436 
437  size_t num = m_colorBarLabels->get( true );
438  double coordStep = 0.8 / static_cast< double >( num - 1 );
439  double valueStep = m_valueScale / static_cast< double >( num - 1 );
440  double valueMin = m_valueMin;
441 
443  {
444  valueStep = m_windowLevel.getLength() / static_cast< double >( num - 1 );
445  valueMin = m_windowLevel.getLower();
446  }
447 
448  // less than 2 labels is useless
449  if( num < 2 )
450  {
451  return;
452  }
453 
454  osg::Vec3Array* lineVerts = new osg::Vec3Array();
455 
456  // create enough labels.
457  for( size_t i = 0; i < num; ++i )
458  {
459  double value = valueMin + ( valueStep * i );
460 
461  // create the label
462  osg::ref_ptr< WGELabel > label = new WGELabel();
463  label->setPosition( osg::Vec3( labelXPos, 0.1 + i * coordStep, 0.0 ) ); // bar goes from 0.1 to 0.9 in our coordinate system
464  label->setText( format( value ) );
465  label->setCharacterSize( m_colorBarLabelsSize->get() );
466  label->setAlignment( osgText::Text::LEFT_CENTER );
467  label->setColor( m_colorBarLabelsColor->get() );
468  label->setBackdropColor( m_colorBarLabelsOutlineColor->get() );
469 
470  g->addDrawable( label );
471 
472  // create the line next to the label
473  lineVerts->push_back( osg::Vec3( labelXPos - 0.010, 0.1 + i * coordStep, 0.0 ) );
474  lineVerts->push_back( osg::Vec3( labelXPos - 0.005, 0.1 + i * coordStep, 0.0 ) );
475  }
476 
477  // create the line drawable
478  osg::Geometry* lines = new osg::Geometry();
479  lines->setVertexArray( lineVerts );
480  osg::Vec4Array* color = new osg::Vec4Array();
481  color->push_back( m_colorBarLabelsBarColor->get() );
482  lines->setColorArray( color );
483  lines->setColorBinding( osg::Geometry::BIND_OVERALL );
484  lines->addPrimitiveSet( new osg::DrawArrays( GL_LINES, 0, lineVerts->size() ) );
485  g->addDrawable( lines );
486  }
487 }
488 
virtual void wait() const
Wait for the condition.
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
virtual void add(std::shared_ptr< WCondition > condition)
Adds another condition to the set of conditions to wait for.
Class to encapsulate boost::condition_variable_any.
Definition: WCondition.h:42
static void replaceTexture(osg::ref_ptr< WGETexture3D > old, osg::ref_ptr< WGETexture3D > newTex, std::string name="")
Replaces the specified texture with the given new one.
static void registerTexture(osg::ref_ptr< WGETexture3D > texture, std::string name="")
Register the specified texture to the colormapper.
static void deregisterTexture(osg::ref_ptr< WGETexture3D > texture)
De-register the specified texture to the colormapper.
This callback allows you a simple usage of callbacks in your module.
Label layout-item.
Definition: WGELabel.h:39
This callback is useful to en-/disable nodes using the node mask based on properties.
Class implementing a uniform which can be controlled by a property instance.
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader.
Definition: WGEShader.h:48
T getLength() const
The length of the interval.
Definition: WInterval.h:269
const T & getLower() const
Get the lower value of the interval.
Definition: WInterval.h:257
A class containing a list of named items.
static WKernel * getRunningKernel()
Returns pointer to the currently running kernel.
Definition: WKernel.cpp:117
std::shared_ptr< WGraphicsEngine > getGraphicsEngine() const
Returns pointer to currently running instance of graphics engine.
Definition: WKernel.cpp:122
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.
static PtrType createAndAdd(std::shared_ptr< WModule > module, std::string name="", std::string description="")
Convenience method to create a new instance of this in data connector with proper type and add it to ...
Class representing a single module of OpenWalnut.
Definition: WModule.h:72
boost::filesystem::path m_localPath
The path where the module binary resides in.
Definition: WModule.h:734
virtual void properties()
Initialize properties in this function.
Definition: WModule.cpp:212
wlog::WStreamedLogger debugLog() const
Logger instance for comfortable debug logging.
Definition: WModule.cpp:575
void removeConnectors()
Removes all connectors properly.
Definition: WModule.cpp:194
std::shared_ptr< WProperties > m_properties
The property object for the module.
Definition: WModule.h:640
std::shared_ptr< WProperties > m_infoProperties
The property object for the module containing only module whose purpose is "PV_PURPOSE_INFORMNATION".
Definition: WModule.h:647
void ready()
Call this whenever your module is ready and can react on property changes.
Definition: WModule.cpp:505
WConditionSet m_moduleState
The internal state of the module.
Definition: WModule.h:703
virtual void activate()
Callback for m_active.
Definition: WModule.cpp:220
WPropBool m_active
True whenever the module should be active.
Definition: WModule.h:723
virtual void connectors()
Initialize connectors in this function.
Definition: WModule.cpp:208
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.
osg::ref_ptr< osg::Geode > genFinitePlane(double xSize, double ySize, const WPlane &p, const WColor &color=WColor(0.0, 0.7, 0.7, 1.0), bool border=false)
Generates a geode out of a Plane with a fixed size in direction of the vectors which span that plane.