From b32f5492725ec07a7121880281a120e63e8c5f5b Mon Sep 17 00:00:00 2001 From: ouv Date: Fri, 13 Nov 2009 09:15:26 +0000 Subject: [PATCH] Bug IPAL18657 - VTK 3D Viewer: Bad representation of Local Coordinate systems. --- src/GEOMGUI/GEOM_Displayer.cxx | 2 +- src/OBJECT/GEOM_VTKTrihedron.cxx | 68 ++++++++++++++++++++++++++------ src/OBJECT/GEOM_VTKTrihedron.hxx | 15 ++++++- 3 files changed, 70 insertions(+), 15 deletions(-) diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 57d7252a2..7cbc862c3 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -822,7 +822,7 @@ void GEOM_Displayer::Update( SALOME_VTKPrs* prs ) if ( myType == GEOM_MARKER && myShape.ShapeType() == TopAbs_FACE ) { - myToActivate = false; + //myToActivate = false; // ouv: commented to make the trihedron pickable (see IPAL18657) GEOM_VTKTrihedron* aTrh = GEOM_VTKTrihedron::New(); if ( HasColor() ) diff --git a/src/OBJECT/GEOM_VTKTrihedron.cxx b/src/OBJECT/GEOM_VTKTrihedron.cxx index bc05f288e..b88a14528 100644 --- a/src/OBJECT/GEOM_VTKTrihedron.cxx +++ b/src/OBJECT/GEOM_VTKTrihedron.cxx @@ -200,9 +200,18 @@ GEOM_VTKTrihedron::GEOM_VTKTrihedron() myMapper = vtkPolyDataMapper::New(); myAxis[ 0 ] = myAxis[ 1 ] = myAxis[ 2 ] = 0; mySize = 100; - SetInfinitive( true ); - myColor[ 0 ] = myColor[ 1 ] = myColor[ 1 ] = -1; - SetInfinitive( true ); + + myColor[ 0 ] = myColor[ 1 ] = myColor[ 2 ] = -1; + + myDefaultColor[ 0 ] = myDefaultColor[ 1 ] = myDefaultColor[ 2 ] = 1; + + myPreHighlightColor[ 0 ] = 0; + myPreHighlightColor[ 1 ] = myPreHighlightColor[ 2 ] = 1; + + myHighlightColor[ 0 ] = myHighlightColor[ 1 ] = myHighlightColor[ 2 ] = 1; + + //SetInfinitive( true ); + SetPickable( true ); } GEOM_VTKTrihedron::~GEOM_VTKTrihedron() @@ -254,6 +263,12 @@ void GEOM_VTKTrihedron::SetSize( vtkFloatingPointType theSize ) aRes->Delete(); } +void GEOM_VTKTrihedron::SetVisibility( int theVisibility ) +{ + Superclass::SetVisibility( theVisibility ); + SetVisibility( theVisibility == 1 ? VTKViewer_Trihedron::eOn : VTKViewer_Trihedron::eOff ); +} + void GEOM_VTKTrihedron::SetVisibility( VTKViewer_Trihedron::TVisibility theVis ) { for ( int i = 0; i < 3; i++ ) @@ -368,21 +383,48 @@ bool GEOM_VTKTrihedron::IsSetCamera() const bool GEOM_VTKTrihedron::IsResizable() const { - return true; + return false; } +void GEOM_VTKTrihedron::Highlight( bool theIsHighlight ) +{ + if( theIsHighlight ) + SetAxesColors( myHighlightColor ); + else + ResetAxesColors(); + Superclass::Highlight( theIsHighlight ); +} +bool GEOM_VTKTrihedron::PreHighlight( vtkInteractorStyle *theInteractorStyle, + SVTK_SelectionEvent* theSelectionEvent, + bool theIsHighlight ) +{ + if ( !GetPickable() ) + return false; + if ( !isHighlighted() ) + { + if( theIsHighlight ) + SetAxesColors( myPreHighlightColor ); + else + ResetAxesColors(); + } + return Superclass::PreHighlight( theInteractorStyle, theSelectionEvent, theIsHighlight ); +} +void GEOM_VTKTrihedron::ResetAxesColors() +{ + if( myColor[0] != -1 ) + SetAxesColors( myColor ); + else + SetAxesColors( myDefaultColor, true ); +} - - - - - - - - - +void GEOM_VTKTrihedron::SetAxesColors( vtkFloatingPointType theColor[3], bool theIsDiffuse ) +{ + myAxis[ 0 ]->SetColor( theColor[0], theIsDiffuse ? 0.0 : theColor[1], theIsDiffuse ? 0.0 : theColor[2] ); + myAxis[ 1 ]->SetColor( theIsDiffuse ? 0.0 : theColor[0], theColor[1], theIsDiffuse ? 0.0 : theColor[2] ); + myAxis[ 2 ]->SetColor( theIsDiffuse ? 0.0 : theColor[0], theIsDiffuse ? 0.0 : theColor[1], theColor[2] ); +} diff --git a/src/OBJECT/GEOM_VTKTrihedron.hxx b/src/OBJECT/GEOM_VTKTrihedron.hxx index 9dde2edd4..7808b0b60 100644 --- a/src/OBJECT/GEOM_VTKTrihedron.hxx +++ b/src/OBJECT/GEOM_VTKTrihedron.hxx @@ -57,6 +57,7 @@ public: virtual vtkFloatingPointType GetSize() { return mySize;} + virtual void SetVisibility( int theVisibility ); virtual void SetVisibility( VTKViewer_Trihedron::TVisibility theVis ); virtual void VisibilityOff() { SetVisibility( VTKViewer_Trihedron::eOff ); } virtual void VisibilityOn() { SetVisibility( VTKViewer_Trihedron::eOn ); } @@ -79,7 +80,16 @@ public: void SetColor( vtkFloatingPointType r, vtkFloatingPointType g, vtkFloatingPointType b ); void GetColor( vtkFloatingPointType& r, vtkFloatingPointType& g, vtkFloatingPointType& b ); - virtual bool hasHighlight() { return false; } + virtual bool hasHighlight() { return true; } + + virtual void Highlight( bool theHighlight ); + virtual bool PreHighlight( vtkInteractorStyle* theInteractorStyle, + SVTK_SelectionEvent* theSelectionEvent, + bool theIsHighlight ); + +protected: + virtual void ResetAxesColors(); + virtual void SetAxesColors( vtkFloatingPointType theColor[3], bool theIsDiffuse = false ); protected: VTKViewer_Axis* myAxis[3]; @@ -88,6 +98,9 @@ protected: gp_Pnt myLocation; gp_Dir myDirX, myDirY, myDirZ; vtkFloatingPointType myColor[ 3 ]; + vtkFloatingPointType myDefaultColor[ 3 ]; + vtkFloatingPointType myPreHighlightColor[ 3 ]; + vtkFloatingPointType myHighlightColor[ 3 ]; }; #endif -- 2.39.2