From e8f0ca0778637c7540b9c76cf2121c0d94999fd7 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 17 Oct 2005 06:17:22 +0000 Subject: [PATCH] To improve selection management. 1. All SALOME_Actor share the same instances of pickers and highlight/prehighlight properties that is stored into SVTK_Renderer. 2. SVTK_Selector now invoke selection changed event on selection mode changing 3. Remove useless highlight calls and selection changed event invockation --- src/SVTK/SVTK_InteractorStyle.cxx | 2 -- src/SVTK/SVTK_Selector.cxx | 6 +++++- src/SVTK/SVTK_View.cxx | 33 ++++++++----------------------- 3 files changed, 13 insertions(+), 28 deletions(-) diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 5781c9933..b457ebb81 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -890,8 +890,6 @@ SVTK_InteractorStyle fitRect(x1, y1, x2, y2); } else { - VTK::ForEach(GetCurrentRenderer()->GetActors(), - VTK::THighlight(false)); if (myPoint == myOtherPoint) { // process point selection this->FindPokedRenderer(aSelectionEvent->myX, aSelectionEvent->myY); diff --git a/src/SVTK/SVTK_Selector.cxx b/src/SVTK/SVTK_Selector.cxx index 4d8fd1a7a..90fa0b06f 100644 --- a/src/SVTK/SVTK_Selector.cxx +++ b/src/SVTK/SVTK_Selector.cxx @@ -78,7 +78,11 @@ void SVTK_SelectorDef ::SetSelectionMode(Selection_Mode theMode) { - mySelectionMode = theMode; + if(mySelectionMode != theMode){ + mySelectionMode = theMode; + myMapIOSubIndex.clear(); + this->EndPickCallback(); + } } void diff --git a/src/SVTK/SVTK_View.cxx b/src/SVTK/SVTK_View.cxx index ad1a00c24..d7a91ca7d 100644 --- a/src/SVTK/SVTK_View.cxx +++ b/src/SVTK/SVTK_View.cxx @@ -202,12 +202,10 @@ void SVTK_View ::unHighlightAll() { - if(SVTK_Selector* aSelector = myMainWindow->GetSelector()){ - using namespace VTK; - ForEach(getRenderer()->GetActors(), - THighlightAction( false )); - Repaint(); - } + using namespace VTK; + ForEach(getRenderer()->GetActors(), + THighlightAction( false )); + Repaint(); } //---------------------------------------------------------------- @@ -221,7 +219,7 @@ SVTK_View using namespace VTK; ForEachIf(getRenderer()->GetActors(), TIsSameIObject( theIO ), - THighlightAction( theIsHighlight, aSelector->SelectionMode() )); + TSelectionAction(theIsHighlight,aSelector)); Repaint(); } } @@ -234,12 +232,7 @@ SVTK_View const double& theBlue, const int& theWidth) { - vtkActorCollection* anActors = getRenderer()->GetActors(); - anActors->InitTraversal(); - while(vtkActor* anActor = anActors->GetNextActor()){ - if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(anActor)) - aSActor->SetSelectionProp(theRed,theGreen,theBlue,theWidth); - } + GetRenderer()->SetSelectionProp(theRed,theGreen,theBlue,theWidth); } //---------------------------------------------------------------------------- @@ -250,12 +243,7 @@ SVTK_View const double& theBlue, const int& theWidth) { - vtkActorCollection* anActors = getRenderer()->GetActors(); - anActors->InitTraversal(); - while(vtkActor* anActor = anActors->GetNextActor()){ - if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(anActor)) - aSActor->SetPreselectionProp(theRed,theGreen,theBlue,theWidth); - } + GetRenderer()->SetSelectionProp(theRed,theGreen,theBlue,theWidth); } //---------------------------------------------------------------------------- @@ -264,12 +252,7 @@ SVTK_View ::SetSelectionTolerance(const double& theTolNodes, const double& theTolCell) { - vtkActorCollection* anActors = getRenderer()->GetActors(); - anActors->InitTraversal(); - while(vtkActor* anActor = anActors->GetNextActor()){ - if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast(anActor)) - aSActor->SetSelectionTolerance(theTolNodes,theTolCell); - } + GetRenderer()->SetSelectionTolerance(theTolNodes,theTolCell); } //---------------------------------------------------------------------------- -- 2.39.2