From a625d1b8303e6643c45e2356ef529c4d98b1ac50 Mon Sep 17 00:00:00 2001 From: vsr Date: Fri, 27 Oct 2006 12:44:39 +0000 Subject: [PATCH] Fix a bug: if custom vtk actors are displayed in the viewer (not SALOME_Actor based) the viewer operations like FitAll work incorrectly --- src/SVTK/SVTK_Trihedron.cxx | 8 ++++-- src/VTKViewer/VTKViewer_Trihedron.cxx | 35 +++++++++++++++++++++++++-- src/VTKViewer/VTKViewer_Trihedron.h | 12 +++++++++ 3 files changed, 51 insertions(+), 4 deletions(-) diff --git a/src/SVTK/SVTK_Trihedron.cxx b/src/SVTK/SVTK_Trihedron.cxx index ac0bbd4d8..45751cfec 100644 --- a/src/SVTK/SVTK_Trihedron.cxx +++ b/src/SVTK/SVTK_Trihedron.cxx @@ -46,9 +46,13 @@ SVTK_Trihedron int aCount = 0; while(vtkActor* aProp = aCollection->GetNextActor()) { if(aProp->GetVisibility()) - if(SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(aProp)) + if(SALOME_Actor* anActor = SALOME_Actor::SafeDownCast(aProp)) { if(!anActor->IsInfinitive()) - aCount++; + aCount++; + } + else if ( !OwnActor( anActor ) ) { + aCount++; + } } return aCount; } diff --git a/src/VTKViewer/VTKViewer_Trihedron.cxx b/src/VTKViewer/VTKViewer_Trihedron.cxx index c426e0280..9caa0606a 100755 --- a/src/VTKViewer/VTKViewer_Trihedron.cxx +++ b/src/VTKViewer/VTKViewer_Trihedron.cxx @@ -259,6 +259,17 @@ void VTKViewer_Axis::SetSize(vtkFloatingPointType theSize) myLabelActor->AddPosition(aPosition); } +/*! Check if actor belongs to the axis object + * \param theActor - vtkActor pointer + * \retval Return true if the actor belongs to the axis object + */ +bool VTKViewer_Axis::OwnActor(const vtkActor* theActor) +{ + return theActor == myLineActor || + theActor == myArrowActor || + theActor == myLabelActor; +} + /*! \class VTKViewer_XAxis * \brief X Axis actor */ @@ -425,11 +436,31 @@ int VTKViewer_Trihedron::GetVisibleActorCount(vtkRenderer* theRenderer) int aCount = 0; while(vtkActor* prop = aCollection->GetNextActor()) { if( prop->GetVisibility()) - if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(prop)) + if(VTKViewer_Actor* anActor = VTKViewer_Actor::SafeDownCast(prop)) { if(!anActor->IsInfinitive()) - aCount++; + aCount++; + } + else if ( !OwnActor( anActor ) ) { + aCount++; + } //int aCount = theRenderer->VisibleActorCount(); //SetVisibility(aVis); } return aCount; } + +/*! Check if actor belongs to the axis object + * \param theActor - vtkActor pointer + * \retval Return true if the actor belongs to the axis object + */ +bool VTKViewer_Trihedron::OwnActor(const vtkActor* theActor) +{ + myPresent->InitTraversal(); + while(vtkActor* anActor = myPresent->GetNextActor()) { + if ( anActor == theActor ) return true; + } + for(int i = 0; i < 3; i++) { + if ( myAxis[i]->OwnActor(theActor) ) return true; + } + return false; +} diff --git a/src/VTKViewer/VTKViewer_Trihedron.h b/src/VTKViewer/VTKViewer_Trihedron.h index 69b7074a3..70f2502c0 100755 --- a/src/VTKViewer/VTKViewer_Trihedron.h +++ b/src/VTKViewer/VTKViewer_Trihedron.h @@ -170,6 +170,12 @@ public: */ virtual int GetVisibleActorCount(vtkRenderer* theRenderer); + /*! Check if actor belongs to the trihedron object + * \param theActor - vtkActor pointer + * \retval Return true if the actor belongs to the trihedron object + */ + virtual bool OwnActor(const vtkActor* theActor); + protected: /*! Actor collection*/ vtkActorCollection* myPresent; @@ -234,6 +240,12 @@ public: * \retval Return myArrowActor */ virtual VTKViewer_UnScaledActor* GetArrow() { return myArrowActor; } + + /*! Check if actor belongs to the axis object + * \param theActor - vtkActor pointer + * \retval Return true if the actor belongs to the axis object + */ + virtual bool OwnActor(const vtkActor* theActor); protected: /*! Visibility flag. -- 2.39.2