]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Issue 0020166: EDF 957 VISU : shrink gauss points
authorouv <ouv@opencascade.com>
Thu, 6 Aug 2009 13:02:12 +0000 (13:02 +0000)
committerouv <ouv@opencascade.com>
Thu, 6 Aug 2009 13:02:12 +0000 (13:02 +0000)
doc/salome/gui/VISU/input/viewing_3d_presentations.doc
src/OBJECT/VISU_GaussPtsAct.cxx
src/OBJECT/VISU_GaussPtsAct.h
src/PIPELINE/VISU_GaussPointsPL.cxx
src/PIPELINE/VISU_GaussPointsPL.hxx
src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx
src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx

index f25da5b9c42f522a211a6d447c67bb08e93c5ecf..3ff84ce3b6b06d1cca3e9c3ce4574f974356333e 100644 (file)
@@ -108,7 +108,15 @@ arcs.</li>
 \image html viewing13.png
 <ul>
 <li>\b Opacity - allows to set the value of opacity of the
-presentation between 0 (transparent) and 100 (opaque).</li>
+presentation between 0 (transparent) and 100 (opaque).
+\note For \ref gauss_points_presentations_page "Gauss Points"
+presentation, displayed by <b>Point Sprites</b> or <b>OpenGL Points</b>
+\ref primitive_types_page "primitives" this property allows only to
+switch between transparent and opaque modes. Textures are drawn in
+opaque mode as long as the opacity level is equal 100% and in
+transparent mode when opacity level is lower that 100% (note that
+they become invisible when the level is equal 0%).
+</li>
 <li><b>Line Width</b> - allows to set the width of lines representing
 edges of the presentation between 1 (thin) and 100 (thick).</li>
 </ul>
index 58272e97cd34d1b2031534cdedb1771e46fc1e73..fbf86d5e006048390d76c50914054d0af8eb5d9b 100644 (file)
@@ -520,6 +520,16 @@ VISU_GaussPtsAct
 }
 
 
+//----------------------------------------------------------------------------
+void
+VISU_GaussPtsAct
+::SetOpacity(vtkFloatingPointType theValue)
+{
+  GetGaussPointsPL()->SetOpacity(theValue);
+  Superclass::SetOpacity(theValue);
+}
+
+
 //----------------------------------------------------------------------------
 void
 VISU_GaussPtsAct
index 6e255ab0985270cc14312cb2bc972d5a44a82764..48155c84ee40f161433ae13fa840a64e08f24549 100644 (file)
@@ -127,6 +127,11 @@ class VISU_OBJECT_EXPORT VISU_GaussPtsAct : public VISU_Actor
   unsigned long int
   GetMemorySize();
  
+  //----------------------------------------------------------------------------
+  virtual
+  void
+  SetOpacity(vtkFloatingPointType theValue);
+
   //----------------------------------------------------------------------------
   virtual
   void
index 766c910e04b5ba4f749629c8c68a04ef1dd18a94..bad800c68913a72d8dfa99105dd67981aff0f5b7 100644 (file)
@@ -617,6 +617,24 @@ VISU_GaussPointsPL
 }
 
 
+//----------------------------------------------------------------------------
+void
+VISU_GaussPointsPL
+::SetOpacity(vtkFloatingPointType theOpacity)
+{
+  GetPointSpriteMapper()->SetPointSpriteOpacity( theOpacity );
+}
+
+
+//----------------------------------------------------------------------------
+vtkFloatingPointType
+VISU_GaussPointsPL
+::GetOpacity()
+{
+  return GetPointSpriteMapper()->GetPointSpriteOpacity();
+}
+
+
 //----------------------------------------------------------------------------
 void
 VISU_GaussPointsPL
index e86217fa509fbff9f5362fce780c6e1703d4d267..327ae38c5a04e83699092f5492caba48444189de 100644 (file)
@@ -211,6 +211,14 @@ public:
   vtkFloatingPointType
   GetAlphaThreshold();
 
+  //! Redirect the request to VISU_OpenGLPointSpriteMapper::SetPointSpriteOpacity.
+  void
+  SetOpacity(vtkFloatingPointType theOpacity);
+
+  //! Redirect the request to VISU_OpenGLPointSpriteMapper.vtkGetMacro(PointSpriteOpacity, vtkFloatingPointType).
+  vtkFloatingPointType
+  GetOpacity();
+
   //! Set resolution of the Geometrical Sphere.
   void
   SetResolution(int theResolution);
index 6662b6bd94d53b612fa2f2a428cae6308aa1ca36..e667bc244cb19c95bcfe3bbba0a6ccf2c135157b 100755 (executable)
@@ -244,6 +244,7 @@ VISU_OpenGLPointSpriteMapper::VISU_OpenGLPointSpriteMapper()
   this->PointSpriteMagnification = 1.0;
 
   this->PointSpriteAlphaThreshold = 0.5;
+  this->PointSpriteOpacity       = 1.0;
   this->PointSpriteTexture       = 0;
 
   this->UseOpenGLMapper          = false;
@@ -653,11 +654,16 @@ void VISU_OpenGLPointSpriteMapper::InitPointSprites()
   glEnable( GL_POINT_SPRITE_ARB );
   glEnable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB );
 
+  glPushAttrib( GL_COLOR_BUFFER_BIT | GL_CURRENT_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_LIGHTING_BIT );
+
+  this->RenderMode = this->PointSpriteOpacity < 1.0 ? VISU_OpenGLPointSpriteMapper::Accumulate : VISU_OpenGLPointSpriteMapper::Occlude;
+
   switch (this->RenderMode)
   {
     case VISU_OpenGLPointSpriteMapper::Accumulate:
     {
-      glDisable(GL_DEPTH_TEST);
+      glDepthFunc( GL_LESS );
+      glEnable( GL_DEPTH_TEST );
 
       glEnable( GL_BLEND );
       glBlendFunc( GL_SRC_ALPHA, GL_ONE );
@@ -695,13 +701,7 @@ void VISU_OpenGLPointSpriteMapper::InitPointSprites()
 void VISU_OpenGLPointSpriteMapper::CleanupPointSprites()
 {
   // Set GL params back to normal to stop other vtkMappers displaying wrongly
-  glDisable( GL_ALPHA_TEST );
-
-  glEnable( GL_BLEND );
-
-  glEnable( GL_DEPTH_TEST );
-  glEnable( GL_LIGHTING );
-  glEnable( GL_COLOR_MATERIAL );
+  glPopAttrib();
 
   glDisable( GL_VERTEX_PROGRAM_POINT_SIZE_ARB );
   glDisable( GL_POINT_SPRITE_ARB );
@@ -977,13 +977,9 @@ int VISU_OpenGLPointSpriteMapper::Draw(vtkRenderer *theRenderer, vtkActor *theAc
   vtkPoints            *points;
   int noAbort = 1;
   int cellScalars = 0;
-  float  tran;
-
-  // get the transparency
-  tran = theActor->GetProperty()->GetOpacity();
 
   // if the primitives are invisable then get out of here
-  if (tran <= 0.0)
+  if (this->PointSpriteOpacity <= 0.0)
   {
     return noAbort;
   }
index 080461c32c3752d341d33a8ea0b4c5888497de29..94fa3b2311e831f6e890a9aaee400f334a2c46a6 100755 (executable)
@@ -206,6 +206,12 @@ public:
   //! Get Point Sprite AlphaThreshold.
   vtkGetMacro(PointSpriteAlphaThreshold, float);
 
+  //! Set Point Sprite Opacity
+  vtkSetMacro(PointSpriteOpacity, float);
+
+  //! Get Point Sprite Opacity
+  vtkGetMacro(PointSpriteOpacity, float);
+
   //! Set ImageData for Point Sprite Texture.
   void SetImageData(vtkImageData* theImageData);
 
@@ -264,6 +270,7 @@ private:
 
   GLuint            PointSpriteTexture;
   float             PointSpriteAlphaThreshold;
+  float             PointSpriteOpacity;
 
   float             AverageCellSize;