From 87739b4db142b2fe3fe1a89bf55c76c38f05d58b Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 3 Oct 2005 06:22:02 +0000 Subject: [PATCH] To improve highlight functionality (to use data from selector) --- src/SVTK/SALOME_Actor.cxx | 23 +++++++++++++++++------ src/SVTK/SALOME_Actor.h | 5 +++++ src/SVTK/SVTK_View.cxx | 24 +++++++++++++++++++++--- 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/src/SVTK/SALOME_Actor.cxx b/src/SVTK/SALOME_Actor.cxx index d06d6e9c8..16ea3da80 100644 --- a/src/SVTK/SALOME_Actor.cxx +++ b/src/SVTK/SALOME_Actor.cxx @@ -258,7 +258,7 @@ void SALOME_Actor ::highlight(bool theHighlight) { - highlight(theHighlight,ActorSelection); + highlight(theHighlight,mySelectionMode); } bool @@ -867,7 +867,7 @@ SALOME_Actor vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer(); // - int aSelectionMode = theSelectionEvent->mySelectionMode; + Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode; float x1 = theSelectionEvent->myX; float y1 = theSelectionEvent->myY; float z1 = 0.0; @@ -1052,10 +1052,22 @@ SALOME_Actor } } + mySelectionMode = aSelectionMode; + + highlight(theIsHighlight,theSelector); + + return true; +} + +void +SALOME_Actor +::highlight(bool theIsHighlight, + SVTK_Selector* theSelector) +{ TColStd_IndexedMapOfInteger aMapIndex; theSelector->GetIndex( getIO(), aMapIndex ); - switch( aSelectionMode ) + switch( mySelectionMode ) { case NodeSelection: myHighlightProperty->SetRepresentationToPoints(); @@ -1076,11 +1088,10 @@ SALOME_Actor break; } - highlight( theIsHighlight, aSelectionMode ); - - return true; + highlight( theIsHighlight, mySelectionMode ); } + //---------------------------------------------------------------------------- void SALOME_Actor diff --git a/src/SVTK/SALOME_Actor.h b/src/SVTK/SALOME_Actor.h index bfe943b62..870f327a1 100644 --- a/src/SVTK/SALOME_Actor.h +++ b/src/SVTK/SALOME_Actor.h @@ -109,6 +109,11 @@ class SVTK_EXPORT SALOME_Actor : public VTKViewer_Actor highlight(bool theHighlight, Selection_Mode theSelectionMode); + virtual + void + highlight(bool theHighlight, + SVTK_Selector* theSelector); + virtual void highlight(bool theHighlight); diff --git a/src/SVTK/SVTK_View.cxx b/src/SVTK/SVTK_View.cxx index f20f1c0ef..98d158291 100644 --- a/src/SVTK/SVTK_View.cxx +++ b/src/SVTK/SVTK_View.cxx @@ -141,6 +141,25 @@ struct THighlightAction } }; +struct TSelectionAction +{ + bool myIsHighlight; + SVTK_Selector* mySelector; + TSelectionAction( bool theIsHighlight, + SVTK_Selector* theSelector ): + myIsHighlight( theIsHighlight ), + mySelector( theSelector ) + {} + + void + operator()( SALOME_Actor* theActor) + { + if(theActor->GetMapper()){ + theActor->highlight( myIsHighlight, mySelector ); + } + } +}; + void SVTK_SignalHandler ::onSelectionChanged() @@ -153,14 +172,13 @@ SVTK_SignalHandler SVTK_Selector* aSelector = myMainWindow->GetSelector(); const SALOME_ListIO& aListIO = aSelector->StoredIObjects(); SALOME_ListIteratorOfListIO anIter(aListIO); - Selection_Mode aSelectionMode = aSelector->SelectionMode(); for(; anIter.More(); anIter.Next()){ ForEachIf(anActors, TIsSameIObject(anIter.Value()), - THighlightAction(true,aSelectionMode)); + TSelectionAction(true,aSelector)); } - myMainWindow->Repaint(); + myMainWindow->Repaint(false); } -- 2.39.2