From f1d8372542026cc2a74d536cd9622cec01445718 Mon Sep 17 00:00:00 2001 From: ouv Date: Thu, 6 Aug 2009 13:02:12 +0000 Subject: [PATCH] Issue 0020166: EDF 957 VISU : shrink gauss points --- .../VISU/input/viewing_3d_presentations.doc | 10 ++++++++- src/OBJECT/VISU_GaussPtsAct.cxx | 10 +++++++++ src/OBJECT/VISU_GaussPtsAct.h | 5 +++++ src/PIPELINE/VISU_GaussPointsPL.cxx | 18 +++++++++++++++ src/PIPELINE/VISU_GaussPointsPL.hxx | 8 +++++++ src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx | 22 ++++++++----------- src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx | 7 ++++++ 7 files changed, 66 insertions(+), 14 deletions(-) diff --git a/doc/salome/gui/VISU/input/viewing_3d_presentations.doc b/doc/salome/gui/VISU/input/viewing_3d_presentations.doc index f25da5b9..3ff84ce3 100644 --- a/doc/salome/gui/VISU/input/viewing_3d_presentations.doc +++ b/doc/salome/gui/VISU/input/viewing_3d_presentations.doc @@ -108,7 +108,15 @@ arcs. \image html viewing13.png diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index 58272e97..fbf86d5e 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -520,6 +520,16 @@ VISU_GaussPtsAct } +//---------------------------------------------------------------------------- +void +VISU_GaussPtsAct +::SetOpacity(vtkFloatingPointType theValue) +{ + GetGaussPointsPL()->SetOpacity(theValue); + Superclass::SetOpacity(theValue); +} + + //---------------------------------------------------------------------------- void VISU_GaussPtsAct diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index 6e255ab0..48155c84 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -127,6 +127,11 @@ class VISU_OBJECT_EXPORT VISU_GaussPtsAct : public VISU_Actor unsigned long int GetMemorySize(); + //---------------------------------------------------------------------------- + virtual + void + SetOpacity(vtkFloatingPointType theValue); + //---------------------------------------------------------------------------- virtual void diff --git a/src/PIPELINE/VISU_GaussPointsPL.cxx b/src/PIPELINE/VISU_GaussPointsPL.cxx index 766c910e..bad800c6 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.cxx +++ b/src/PIPELINE/VISU_GaussPointsPL.cxx @@ -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 diff --git a/src/PIPELINE/VISU_GaussPointsPL.hxx b/src/PIPELINE/VISU_GaussPointsPL.hxx index e86217fa..327ae38c 100644 --- a/src/PIPELINE/VISU_GaussPointsPL.hxx +++ b/src/PIPELINE/VISU_GaussPointsPL.hxx @@ -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); diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx index 6662b6bd..e667bc24 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.cxx @@ -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; } diff --git a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx index 080461c3..94fa3b23 100755 --- a/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx +++ b/src/PIPELINE/VISU_OpenGLPointSpriteMapper.hxx @@ -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; -- 2.39.2