OpenWalnut  1.4.0
WGETexture.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 WGETEXTURE_H
26 #define WGETEXTURE_H
27 
28 #include <string>
29 #include <limits>
30 
31 #ifndef Q_MOC_RUN
32 #include <boost/shared_ptr.hpp>
33 #endif
34 
35 #include <osg/Node>
36 #include <osg/StateSet>
37 #include <osg/Texture>
38 #include <osg/Texture1D>
39 #include <osg/Texture2D>
40 #include <osg/Texture3D>
41 
42 #include "callbacks/WGEFunctorCallback.h"
43 #include "../common/WBoundingBox.h"
44 #include "../common/WProperties.h"
45 #include "../common/WPropertyTypes.h"
46 #include "../common/WPropertyHelper.h"
47 
48 #include "WGETextureUtils.h"
49 
50 /**
51  * This calls serves a simple purpose: have a texture and its scaling information together which allows very easy binding of textures to nodes
52  * with associated shaders. When this texture gets bind using the bindTo methods, uniforms get added containing needed scaling information.
53  */
54 template < typename TextureType = osg::Texture >
55 class WGETexture: public TextureType
56 {
57 public:
58  /**
59  * Convenience type for OSG reference pointer on WGETextures.
60  */
61  typedef osg::ref_ptr< WGETexture< TextureType > > RPtr;
62 
63  //! We support only 8 textures because some known hardware does not support more texture coordinates.
64  static std::size_t const MAX_NUMBER_OF_TEXTURES = 8;
65 
66  //! The maximum texture dimension.
67  static std::size_t const MAX_TEXTURE_DIMENSION = 2048;
68 
69  /**
70  * Default constructor. Creates an empty instance of the texture.
71  *
72  * \param scale the scaling factor needed for de-scaling the texture values
73  * \param min the minimum value allowing negative values too.
74  */
75  WGETexture( double scale = 1.0, double min = 0.0 );
76 
77  /**
78  * Creates texture from given image. Scaling is set to identity.
79  *
80  * \param image the image to use as texture
81  * \param scale the scaling factor needed for de-scaling the texture values
82  * \param min the minimum value allowing negative values too.
83  */
84  WGETexture( osg::Image* image, double scale = 1.0, double min = 0.0 );
85 
86  /**
87  * Copy the texture.
88  *
89  * \param texture the texture to copy
90  * \param copyop
91  */
92  WGETexture( const WGETexture< TextureType >& texture, const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY );
93 
94  /**
95  * Destructor.
96  */
97  virtual ~WGETexture();
98 
99  /**
100  * Returns the name property of the texture. You should set it if you create a texture.
101  *
102  * \return texture name property
103  */
104  WPropString name() const;
105 
106  /**
107  * The sorting index in the colormapper's texture list.
108  *
109  * \return the property.
110  */
111  WPropInt sortIndex() const;
112 
113  /**
114  * Get the index used to refer to an unset sort index.
115  *
116  * \return the value.
117  */
119 
120  /**
121  * Get the minimum in the de-scaled value space. The property can be changed. A change affects all colormaps using this texture. But be
122  * careful as the texture creating depends on these values.
123  *
124  * \return the minimum
125  */
126  WPropDouble minimum() const;
127 
128  /**
129  * Get the scaling factor for de-scaling the texture. The property can be changed. A change affects all colormaps using this texture. But be
130  * careful as the texture creating depends on these values.
131  *
132  * \return the scale
133  */
134  WPropDouble scale() const;
135 
136  /**
137  * Returns the alpha property. The property can be changed. A change affects all colormaps using this texture.
138  *
139  * \return alpha property
140  */
141  WPropDouble alpha() const;
142 
143  /**
144  * Clip the values assumed to be zero.
145  *
146  * \return true to clip.
147  */
148  WPropBool clipZero() const;
149 
150  /**
151  * Returns the threshold property. The property can be changed. A change affects all colormaps using this texture.
152  *
153  * \return threshold property
154  */
155  WPropDouble thresholdLower() const;
156 
157  /**
158  * Returns the threshold property. The property can be changed. A change affects all colormaps using this texture.
159  *
160  * \return threshold property
161  */
162  WPropDouble thresholdUpper() const;
163 
164  /**
165  * Returns the property responsible for enabling threshold based clipping. If this is false, the threshold is ignored.
166  *
167  * \return threshold-enable property.
168  */
169  WPropBool thresholdEnabled() const;
170 
171  /**
172  * Returns the interpolation property. The property can be changed. A change affects all colormaps using this texture.
173  *
174  * \return interpolation property
175  */
176  WPropBool interpolation() const;
177 
178  /**
179  * Returns the colormap property. The property can be changed. A change affects all colormaps using this texture.
180  *
181  * \return colormap property
182  */
183  WPropSelection colormap() const;
184 
185  /**
186  * Returns the active property. The property can be changed. A change affects all colormaps using this texture.
187  *
188  * \return active property
189  */
190  WPropBool active() const;
191 
192  /**
193  * Returns the window level definition for the colormap. The property can be changed. A change affects all colormaps using this texture.
194  *
195  * \return window colormap
196  */
197  WPropInterval window() const;
198 
199  /**
200  * Returns the property responsible for enabling window based interval scaling. If this is false, the window setting is ignored.
201  *
202  * \return windowing-enable property.
203  */
204  WPropBool windowEnabled() const;
205 
206  /**
207  * Returns the texture transformation matrix. The property can be changed. A change affects all colormaps using this texture. This matrix
208  * converts an world-space coordinate to an texture coordinate! This can be seen as a scaled inverse matrix of the grid's transformation.
209  *
210  * \return the matrix
211  */
212  WPropMatrix4X4 transformation() const;
213 
214  /**
215  * Binds the texture to the specified node and texture unit. It also adds two uniforms: u_textureXMin and u_textureXScale, where X
216  * is the unit number. This can be used in shaders to unscale it.
217  *
218  * \param node the node where to bind the texture to
219  * \param unit the unit, by default 0
220  */
221  void bind( osg::ref_ptr< osg::Node > node, size_t unit = 0 );
222 
223  /**
224  * Return a pointer to the properties object of the dataset. Add all the modifiable settings here. This allows the user to modify several
225  * properties of a dataset.
226  *
227  * \return the properties.
228  */
229  boost::shared_ptr< WProperties > getProperties() const;
230 
231  /**
232  * Return a pointer to the information properties object of the dataset. The dataset intends these properties to not be modified.
233  *
234  * \return the properties.
235  */
236  boost::shared_ptr< WProperties > getInformationProperties() const;
237 
238  /**
239  * Applies some custom uniforms to the specified state-set which directly relate to this texture
240  *
241  * \param prefix the prefix used for the uniforms
242  * \param states the state where to add the uniforms
243  */
244  virtual void applyUniforms( std::string prefix, osg::StateSet* states ) const;
245 
246  /**
247  * For all the lazy guys to set the filter MIN and MAG at once.
248  *
249  * \param mode the new mode for MIN_FILTER and MAG_FILTER.
250  */
251  void setFilterMinMag( osg::Texture::FilterMode mode );
252 
253  /**
254  * For all the lazy guys to set the wrapping for s,t and r directions at once.
255  *
256  * \param mode the new mode for WRAP_S, WRAP_T and WRAP_R.
257  */
258  void setWrapSTR( osg::Texture::WrapMode mode );
259 
260  /**
261  * Returns the texture's bounding box. This is const. Although there exists the transformation() property, it is an information property and
262  * can't be changed.
263  *
264  * \return the bounding box.
265  */
266  virtual WBoundingBox getBoundingBox() const;
267 
268 protected:
269  /**
270  * Handles all property updates. Called by m_propCondition.
271  */
272  virtual void handleUpdate();
273 
274  /**
275  * Creates the texture data. Overwrite this method if you want to provide a custom texture creation procedure.
276  */
277  virtual void create();
278 
279  /**
280  * This method implements an update callback which updates the texture image if needed and several other properties like texture matrix.
281  *
282  * \param state the state to update
283  */
284  virtual void updateCallback( osg::StateAttribute* state );
285 
286  /**
287  * Initialize the size of the texture properly according to real texture type (1D,2D,3D).
288  * \note This is needed because osg::Texture::setImage is not virtual and does not set the size from the image.
289  *
290  * \param texture the texture where to set the size
291  * \param width the new width
292  * \param height the new height
293  * \param depth the new depth
294  */
295  static void initTextureSize( osg::Texture1D* texture, int width, int height, int depth );
296 
297  /**
298  * Initialize the size of the texture properly according to real texture type (1D,2D,3D).
299  * \note This is needed because osg::Texture::setImage is not virtual and does not set the size from the image.
300  *
301  * \param texture the texture where to set the size
302  * \param width the new width
303  * \param height the new height
304  * \param depth the new depth
305  */
306  static void initTextureSize( osg::Texture2D* texture, int width, int height, int depth );
307 
308  /**
309  * Initialize the size of the texture properly according to real texture type (1D,2D,3D).
310  * \note This is needed because osg::Texture::setImage is not virtual and does not set the size from the image.
311  *
312  * \param texture the texture where to set the size
313  * \param width the new width
314  * \param height the new height
315  * \param depth the new depth
316  */
317  static void initTextureSize( osg::Texture3D* texture, int width, int height, int depth );
318 
319 private:
320  /**
321  * Creates and assigns all properties.
322  *
323  * \param min the min value of the texture
324  * \param scale the scale value of the texture
325  */
326  void setupProperties( double scale, double min );
327 
328  /**
329  * A condition used to notify about changes in several properties.
330  */
331  boost::shared_ptr< WCondition > m_propCondition;
332 
333  /**
334  * The property object for the dataset.
335  */
336  boost::shared_ptr< WProperties > m_properties;
337 
338  /**
339  * The property object for the dataset containing only props whose purpose is "PV_PURPOSE_INFORMNATION". It is useful to define some property
340  * to only be of informational nature. The GUI does not modify them. As it is a WProperties instance, you can use it the same way as
341  * m_properties.
342  */
343  boost::shared_ptr< WProperties > m_infoProperties;
344 
345  /**
346  * If true, the texture gets created. This is used to create texture on demand.
347  */
349 
350  /**
351  * The texture name. This might be useful to identify textures.
352  */
353  WPropString m_name;
354 
355  /**
356  * The sort index of the texture. This is important for restoring and saving the colormapper's sorting.
357  */
358  WPropInt m_sortIdx;
359 
360  /**
361  * The minimum of each value in the texture in unscaled space.
362  */
363  WPropDouble m_min;
364 
365  /**
366  * The scaling factor to de-scale a [0-1] texture to original space.
367  */
368  WPropDouble m_scale;
369 
370  /**
371  * A list of color map selection types
372  */
373  boost::shared_ptr< WItemSelection > m_colorMapSelectionsList;
374 
375  /**
376  * Selection property for color map
377  */
378  WPropSelection m_colorMap;
379 
380  /**
381  * Alpha blending value.
382  */
383  WPropDouble m_alpha;
384 
385  /**
386  * If set to true, zero values are clipped by making them transparent
387  */
388  WPropBool m_clipZero;
389 
390  /**
391  * Threshold for clipping areas.
392  */
393  WPropDouble m_thresholdLower;
394 
395  /**
396  * Threshold for clipping areas.
397  */
398  WPropDouble m_thresholdUpper;
399 
400  /**
401  * Threshold-enable flag.
402  */
404 
405  /**
406  * True if interpolation should be used.
407  */
408  WPropBool m_interpolation;
409 
410  /**
411  * True if the texture is active.
412  */
413  WPropBool m_active;
414 
415  /**
416  * The texture transformation matrix.
417  */
418  WPropMatrix4X4 m_texMatrix;
419 
420  /**
421  * Window level setting for the current colormap
422  */
423  WPropInterval m_window;
424 
425  /**
426  * Window-Level-Setting-enable flag.
427  */
428  WPropBool m_windowEnabled;
429 };
430 
431 // Some convenience typedefs
432 
433 /**
434  * OSG's Texture1D with scaling features
435  */
437 
438 /**
439  * OSG's Texture2D with scaling features
440  */
442 
443 /**
444  * OSG's Texture3D with scaling features
445  */
447 
448 
449 template < typename TextureType >
450 WGETexture< TextureType >::WGETexture( double scale, double min ):
451  TextureType(),
452  m_propCondition( boost::shared_ptr< WCondition >( new WCondition() ) ),
453  m_properties( boost::shared_ptr< WProperties >( new WProperties( "Texture Properties", "Properties of a texture." ) ) ),
454  m_infoProperties( boost::shared_ptr< WProperties >( new WProperties( "Texture Info Properties", "Texture's information properties." ) ) ),
455  m_needCreate( true )
456 {
457  setupProperties( scale, min );
458 }
459 
460 template < typename TextureType >
461 WGETexture< TextureType >::WGETexture( osg::Image* image, double scale, double min ):
462  TextureType( image ),
463  m_propCondition( boost::shared_ptr< WCondition >( new WCondition() ) ),
464  m_properties( boost::shared_ptr< WProperties >( new WProperties( "Texture Properties", "Properties of a texture." ) ) ),
465  m_infoProperties( boost::shared_ptr< WProperties >( new WProperties( "Texture Info Properties", "Texture's information properties." ) ) ),
466  m_needCreate( true )
467 {
468  setupProperties( scale, min );
469  WGETexture< TextureType >::initTextureSize( this, image->s(), image->t(), image->r() );
470 }
471 
472 template < typename TextureType >
473 WGETexture< TextureType >::WGETexture( const WGETexture< TextureType >& texture, const osg::CopyOp& copyop ):
474  TextureType( texture, copyop ),
475  m_min( texture.m_min ),
476  m_scale( texture.m_scale )
477 {
478  // initialize members
479 }
480 
481 template < typename TextureType >
482 void WGETexture< TextureType >::setupProperties( double scale, double min )
483 {
484  m_propCondition->subscribeSignal( boost::bind( &WGETexture< TextureType >::handleUpdate, this ) );
485 
486  m_name = m_properties->addProperty( "Name", "The name of the texture.", std::string( "Unnamed" ) );
487 
488  m_sortIdx = m_properties->addProperty( "Sort Index",
489  "The index specifies the index in the colormapper, used to restore colormapper sorting on load.",
490  getUnsetSortIndex() );
491  m_sortIdx->setHidden( true );
492 
493  // initialize members
494  m_min = m_properties->addProperty( "Minimum", "The minimum value in the original space.", min, true );
495  m_min->removeConstraint( m_min->getMin() );
496  m_min->removeConstraint( m_min->getMax() );
497 
498  m_scale = m_properties->addProperty( "Scale", "The scaling factor to un-scale the texture values to the original space.", scale, true );
499  m_scale->removeConstraint( m_scale->getMin() );
500  m_scale->removeConstraint( m_scale->getMax() );
501 
502  m_alpha = m_properties->addProperty( "Alpha", "The alpha blending value.", 1.0 );
503  m_alpha->setMin( 0.0 );
504  m_alpha->setMax( 1.0 );
505 
506  m_clipZero = m_properties->addProperty( "Enable Zero Clip", "If enabled, zero values are clipped.", true );
507 
508  m_thresholdEnabled = m_properties->addProperty( "Enable Threshold",
509  "If enabled, threshold based clipping is used. If not, threshold is ignored.", false );
510 
511  m_thresholdLower = m_properties->addProperty( "Lower Threshold", "The threshold used to clip areas below the specified value.", 0.0 );
512  m_thresholdLower->setMin( min );
513  m_thresholdLower->setMax( min + scale );
514 
515  m_thresholdUpper = m_properties->addProperty( "Upper Threshold", "The threshold used to clip areas above the specified value.", 1.0 );
516  m_thresholdUpper->setMin( min );
517  m_thresholdUpper->setMax( min + scale );
518 
519  m_windowEnabled = m_properties->addProperty( "Enable Windowing", "If enabled, window level settings are applied.", false );
520  m_window = m_properties->addProperty( "Window Level", "Define the interval in the data which is mapped to the colormap.",
521  make_interval( 0.0, 1.0 ) );
522 
523  m_interpolation = m_properties->addProperty( "Interpolate", "Interpolation of the volume data.", true, m_propCondition );
524 
525  m_colorMapSelectionsList = boost::shared_ptr< WItemSelection >( new WItemSelection() );
526  m_colorMapSelectionsList->addItem( "Grayscale", "" );
527  m_colorMapSelectionsList->addItem( "Rainbow", "" );
528  m_colorMapSelectionsList->addItem( "Hot iron", "" );
529  m_colorMapSelectionsList->addItem( "Negative to positive", "" );
530  m_colorMapSelectionsList->addItem( "Atlas", "" );
531  m_colorMapSelectionsList->addItem( "Blue-Green-Purple", "" );
532  m_colorMapSelectionsList->addItem( "Vector", "" );
533 
534  m_colorMap = m_properties->addProperty( "Colormap", "The colormap of this texture.", m_colorMapSelectionsList->getSelectorFirst() );
536 
537  m_active = m_properties->addProperty( "Active", "Can dis-enable a texture.", true );
538 
540  m_texMatrix = m_properties->addProperty( "Texture Transformation", "Usable to transform the texture.", m );
541  m_texMatrix->setHidden();
542  m_texMatrix->setPurpose( PV_PURPOSE_INFORMATION );
543 
544  TextureType::setResizeNonPowerOfTwoHint( false );
545  TextureType::setUpdateCallback( new WGEFunctorCallback< osg::StateAttribute >(
546  boost::bind( &WGETexture< TextureType >::updateCallback, this, _1 ) )
547  );
548 
549  // init filters
550  TextureType::setFilter( osg::Texture::MIN_FILTER, m_interpolation->get( true ) ? osg::Texture::LINEAR : osg::Texture::NEAREST );
551  TextureType::setFilter( osg::Texture::MAG_FILTER, m_interpolation->get( true ) ? osg::Texture::LINEAR : osg::Texture::NEAREST );
552 }
553 
554 template < typename TextureType >
556 {
557  // cleanup.
558 }
559 
560 template < typename TextureType >
561 boost::shared_ptr< WProperties > WGETexture< TextureType >::getProperties() const
562 {
563  return m_properties;
564 }
565 
566 template < typename TextureType >
567 boost::shared_ptr< WProperties > WGETexture< TextureType >::getInformationProperties() const
568 {
569  return m_infoProperties;
570 }
571 
572 template < typename TextureType >
573 inline WPropString WGETexture< TextureType >::name() const
574 {
575  return m_name;
576 }
577 
578 template < typename TextureType >
580 {
581  return m_sortIdx;
582 }
583 
584 template < typename TextureType >
585 inline WPropDouble WGETexture< TextureType >::minimum() const
586 {
587  return m_min;
588 }
589 
590 template < typename TextureType >
591 inline WPropDouble WGETexture< TextureType >::scale() const
592 {
593  return m_scale;
594 }
595 
596 template < typename TextureType >
597 inline WPropDouble WGETexture< TextureType >::alpha() const
598 {
599  return m_alpha;
600 }
601 
602 template < typename TextureType >
603 inline WPropBool WGETexture< TextureType >::clipZero() const
604 {
605  return m_clipZero;
606 }
607 
608 template < typename TextureType >
610 {
611  return m_thresholdLower;
612 }
613 
614 template < typename TextureType >
616 {
617  return m_thresholdUpper;
618 }
619 
620 template < typename TextureType >
622 {
623  return m_thresholdEnabled;
624 }
625 
626 template < typename TextureType >
628 {
629  return m_interpolation;
630 }
631 
632 template < typename TextureType >
633 inline WPropSelection WGETexture< TextureType >::colormap() const
634 {
635  return m_colorMap;
636 }
637 
638 template < typename TextureType >
639 inline WPropBool WGETexture< TextureType >::active() const
640 {
641  return m_active;
642 }
643 
644 template < typename TextureType >
646 {
647  return m_windowEnabled;
648 }
649 
650 template < typename TextureType >
651 inline WPropInterval WGETexture< TextureType >::window() const
652 {
653  return m_window;
654 }
655 
656 template < typename TextureType >
657 inline WPropMatrix4X4 WGETexture< TextureType >::transformation() const
658 {
659  return m_texMatrix;
660 }
661 
662 template < typename TextureType >
664 {
665  if( m_interpolation->changed() )
666  {
667  TextureType::setFilter( osg::Texture::MIN_FILTER, m_interpolation->get( true ) ? osg::Texture::LINEAR : osg::Texture::NEAREST );
668  TextureType::setFilter( osg::Texture::MAG_FILTER, m_interpolation->get( true ) ? osg::Texture::LINEAR : osg::Texture::NEAREST );
669  }
670 }
671 
672 template < typename TextureType >
673 void WGETexture< TextureType >::applyUniforms( std::string prefix, osg::StateSet* states ) const
674 {
675  states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "Min", minimum() ) );
676  states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "Scale", scale() ) );
677  states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "Alpha", alpha() ) );
678  states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "ClipZeroEnabled", clipZero() ) );
679  states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "ThresholdEnabled", thresholdEnabled() ) );
680  states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "ThresholdLower", thresholdLower() ) );
681  states->addUniform( new WGEPropertyUniform< WPropDouble >( prefix + "ThresholdUpper", thresholdUpper() ) );
682  states->addUniform( new WGEPropertyUniform< WPropSelection >( prefix + "Colormap", colormap() ) );
683  states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "Active", active() ) );
684  states->addUniform( new WGEPropertyUniform< WPropBool >( prefix + "WindowEnabled", windowEnabled() ) );
685  states->addUniform( new WGEPropertyUniform< WPropInterval >( prefix + "Window", window() ) );
686 }
687 
688 template < typename TextureType >
689 void WGETexture< TextureType >::bind( osg::ref_ptr< osg::Node > node, size_t unit )
690 {
691  // let our utilities do the work
692  wge::bindTexture( node, osg::ref_ptr< WGETexture< TextureType > >( this ), unit ); // to avoid recursive stuff -> explicitly specify the type
693 }
694 
695 template < typename TextureType >
697 {
698  // do nothing. Derived classes may implement this.
699 }
700 
701 template < typename TextureType >
702 void WGETexture< TextureType >::updateCallback( osg::StateAttribute* /*state*/ )
703 {
704  // create if not done yet
705  if( m_needCreate )
706  {
707  m_needCreate = false;
708  create();
709  TextureType::dirtyTextureObject();
710  }
711 }
712 
713 template < typename TextureType >
714 void WGETexture< TextureType >::setFilterMinMag( osg::Texture::FilterMode mode )
715 {
716  this->setFilter( osg::Texture2D::MIN_FILTER, mode );
717  this->setFilter( osg::Texture2D::MAG_FILTER, mode );
718 }
719 
720 template < typename TextureType >
721 void WGETexture< TextureType >::setWrapSTR( osg::Texture::WrapMode mode )
722 {
723  this->setWrap( osg::Texture2D::WRAP_S, mode );
724  this->setWrap( osg::Texture2D::WRAP_T, mode );
725  this->setWrap( osg::Texture2D::WRAP_R, mode );
726 }
727 
728 template < typename TextureType >
729 void WGETexture< TextureType >::initTextureSize( osg::Texture1D* texture, int width, int /*height*/, int /*depth*/ )
730 {
731  texture->setTextureWidth( width );
732 }
733 
734 template < typename TextureType >
735 void WGETexture< TextureType >::initTextureSize( osg::Texture2D* texture, int width, int height, int /*depth*/ )
736 {
737  texture->setTextureSize( width, height );
738 }
739 
740 template < typename TextureType >
741 void WGETexture< TextureType >::initTextureSize( osg::Texture3D* texture, int width, int height, int depth )
742 {
743  texture->setTextureSize( width, height, depth );
744 }
745 
746 template < typename TextureType >
748 {
749  return WBoundingBox( 0.0, 0.0, 0.0, 1.0, 1.0, 1.0 );
750 }
751 
752 template < typename TextureType >
754 {
755  return std::numeric_limits< WPVBaseTypes::PV_INT >::max();
756 }
757 
758 #endif // WGETEXTURE_H
759 
boost::shared_ptr< WCondition > m_propCondition
A condition used to notify about changes in several properties.
Definition: WGETexture.h:331
boost::shared_ptr< WItemSelection > m_colorMapSelectionsList
A list of color map selection types.
Definition: WGETexture.h:373
int32_t PV_INT
base type used for every WPVInt
virtual void handleUpdate()
Handles all property updates.
Definition: WGETexture.h:663
static WPVBaseTypes::PV_INT getUnsetSortIndex()
Get the index used to refer to an unset sort index.
Definition: WGETexture.h:753
WGETexture(double scale=1.0, double min=0.0)
Default constructor.
Definition: WGETexture.h:450
WPropInterval window() const
Returns the window level definition for the colormap.
Definition: WGETexture.h:651
Class implementing a uniform which can be controlled by a property instance.
WPropBool thresholdEnabled() const
Returns the property responsible for enabling threshold based clipping.
Definition: WGETexture.h:621
WPropBool m_active
True if the texture is active.
Definition: WGETexture.h:413
WPropDouble m_thresholdUpper
Threshold for clipping areas.
Definition: WGETexture.h:398
WPropInterval m_window
Window level setting for the current colormap.
Definition: WGETexture.h:423
boost::shared_ptr< WProperties > m_properties
The property object for the dataset.
Definition: WGETexture.h:336
WPropBool clipZero() const
Clip the values assumed to be zero.
Definition: WGETexture.h:603
WPropDouble thresholdUpper() const
Returns the threshold property.
Definition: WGETexture.h:615
virtual void create()
Creates the texture data.
Definition: WGETexture.h:696
virtual ~WGETexture()
Destructor.
Definition: WGETexture.h:555
WPropBool windowEnabled() const
Returns the property responsible for enabling window based interval scaling.
Definition: WGETexture.h:645
This callback allows you a simple usage of callbacks in your module.
This calls serves a simple purpose: have a texture and its scaling information together which allows ...
Definition: WGETexture.h:55
WPropInt sortIndex() const
The sorting index in the colormapper's texture list.
Definition: WGETexture.h:579
WPropString name() const
Returns the name property of the texture.
Definition: WGETexture.h:573
WPropBool m_clipZero
If set to true, zero values are clipped by making them transparent.
Definition: WGETexture.h:388
WPropMatrix4X4 m_texMatrix
The texture transformation matrix.
Definition: WGETexture.h:418
WPropBool m_windowEnabled
Window-Level-Setting-enable flag.
Definition: WGETexture.h:428
WPropBool interpolation() const
Returns the interpolation property.
Definition: WGETexture.h:627
boost::shared_ptr< WProperties > m_infoProperties
The property object for the dataset containing only props whose purpose is "PV_PURPOSE_INFORMNATION"...
Definition: WGETexture.h:343
WPropString m_name
The texture name.
Definition: WGETexture.h:353
osg::ref_ptr< WGETexture< TextureType > > RPtr
Convenience type for OSG reference pointer on WGETextures.
Definition: WGETexture.h:61
WPropDouble minimum() const
Get the minimum in the de-scaled value space.
Definition: WGETexture.h:585
boost::shared_ptr< WProperties > getInformationProperties() const
Return a pointer to the information properties object of the dataset.
Definition: WGETexture.h:567
WPropSelection colormap() const
Returns the colormap property.
Definition: WGETexture.h:633
void setWrapSTR(osg::Texture::WrapMode mode)
For all the lazy guys to set the wrapping for s,t and r directions at once.
Definition: WGETexture.h:721
Class to manage properties of an object and to provide convenience methods for easy access and manipu...
A class containing a list of named items.
WPropDouble thresholdLower() const
Returns the threshold property.
Definition: WGETexture.h:609
void setupProperties(double scale, double min)
Creates and assigns all properties.
Definition: WGETexture.h:482
static MatrixType identity()
Returns an identity matrix.
Definition: WMatrixFixed.h:314
virtual WBoundingBox getBoundingBox() const
Returns the texture's bounding box.
Definition: WGETexture.h:747
void bind(osg::ref_ptr< osg::Node > node, size_t unit=0)
Binds the texture to the specified node and texture unit.
Definition: WGETexture.h:689
Class to encapsulate boost::condition_variable_any.
Definition: WCondition.h:47
WPropDouble alpha() const
Returns the alpha property.
Definition: WGETexture.h:597
WPropDouble m_scale
The scaling factor to de-scale a [0-1] texture to original space.
Definition: WGETexture.h:368
WPropInt m_sortIdx
The sort index of the texture.
Definition: WGETexture.h:358
WPropDouble scale() const
Get the scaling factor for de-scaling the texture.
Definition: WGETexture.h:591
boost::shared_ptr< WProperties > getProperties() const
Return a pointer to the properties object of the dataset.
Definition: WGETexture.h:561
WPropDouble m_thresholdLower
Threshold for clipping areas.
Definition: WGETexture.h:393
WPropSelection m_colorMap
Selection property for color map.
Definition: WGETexture.h:378
WPropBool active() const
Returns the active property.
Definition: WGETexture.h:639
bool m_needCreate
If true, the texture gets created.
Definition: WGETexture.h:348
virtual void applyUniforms(std::string prefix, osg::StateSet *states) const
Applies some custom uniforms to the specified state-set which directly relate to this texture...
Definition: WGETexture.h:673
WPropBool m_interpolation
True if interpolation should be used.
Definition: WGETexture.h:408
virtual void updateCallback(osg::StateAttribute *state)
This method implements an update callback which updates the texture image if needed and several other...
Definition: WGETexture.h:702
WPropBool m_thresholdEnabled
Threshold-enable flag.
Definition: WGETexture.h:403
static std::size_t const MAX_TEXTURE_DIMENSION
The maximum texture dimension.
Definition: WGETexture.h:67
void bindTexture(osg::ref_ptr< osg::Node > node, osg::ref_ptr< WDataTexture3D > texture, size_t unit=0, std::string prefix="")
Binds the specified texture to the specified unit.
static std::size_t const MAX_NUMBER_OF_TEXTURES
We support only 8 textures because some known hardware does not support more texture coordinates...
Definition: WGETexture.h:64
static void initTextureSize(osg::Texture1D *texture, int width, int height, int depth)
Initialize the size of the texture properly according to real texture type (1D,2D,3D).
Definition: WGETexture.h:729
void setFilterMinMag(osg::Texture::FilterMode mode)
For all the lazy guys to set the filter MIN and MAG at once.
Definition: WGETexture.h:714
WPropDouble m_alpha
Alpha blending value.
Definition: WGETexture.h:383
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.
WPropMatrix4X4 transformation() const
Returns the texture transformation matrix.
Definition: WGETexture.h:657
WPropDouble m_min
The minimum of each value in the texture in unscaled space.
Definition: WGETexture.h:363