From: san Date: Fri, 20 Mar 2009 16:30:48 +0000 (+0000) Subject: Optimizing selection highlighting X-Git-Tag: V2_1_0_beta~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=069fc2a596c62425df49499ec18f2cb53123f4c6;p=modules%2Fgui.git Optimizing selection highlighting Invoking ModifiedEvent for the selector when its selection mode changes --- diff --git a/src/SVTK/SVTK_Functor.h b/src/SVTK/SVTK_Functor.h index d76a93548..84548a429 100644 --- a/src/SVTK/SVTK_Functor.h +++ b/src/SVTK/SVTK_Functor.h @@ -26,6 +26,9 @@ #include #include "SALOME_InteractiveObject.hxx" +#include "SALOME_ListIO.hxx" + +#include /*! \file SVTK_Functor.h @@ -82,6 +85,34 @@ namespace SVTK } }; + //---------------------------------------------------------------- + //! This functor check, if the actor's #SALOME_InteractiveObject is in the given list + template + struct TIsInList + { + TColStd_MapOfTransient myIObjects; + //! To construct the functor + TIsInList( const SALOME_ListIO& theObjList ) + { + SALOME_ListIteratorOfListIO anIter( theObjList ); + for(; anIter.More(); anIter.Next() ){ + if ( !myIObjects.Contains( anIter.Value() ) ) + myIObjects.Add( anIter.Value() ); + } + } + + //! To calculate the functor + bool operator()(TActor* theActor) + { + if(theActor->hasIO()) + { + Handle(SALOME_InteractiveObject) anIO = theActor->getIO(); + return myIObjects.Contains( anIO ); + } + return false; + } + }; + //---------------------------------------------------------------- /*! diff --git a/src/SVTK/SVTK_Selector.cxx b/src/SVTK/SVTK_Selector.cxx index 906574ca7..1945fbc17 100644 --- a/src/SVTK/SVTK_Selector.cxx +++ b/src/SVTK/SVTK_Selector.cxx @@ -125,6 +125,8 @@ SVTK_SelectorDef mySelectionMode = theMode; myMapIOSubIndex.clear(); this->EndPickCallback(); + // Let everybody process selection mode change + this->Modified(); } } diff --git a/src/SVTK/SVTK_View.cxx b/src/SVTK/SVTK_View.cxx index 57e6e49eb..676df5cc2 100644 --- a/src/SVTK/SVTK_View.cxx +++ b/src/SVTK/SVTK_View.cxx @@ -40,6 +40,8 @@ #include #include +#include + /*! Constructor */ @@ -134,6 +136,22 @@ namespace SVTK } } }; + + struct TAddAction + { + std::set* myActors; + TAddAction( std::set* actors ): + myActors( actors ) + {} + + void + operator()( SALOME_Actor* theActor) + { + if(myActors && theActor->GetMapper() && theActor->hasIO()){ + myActors->insert( theActor ); + } + } + }; } /*! @@ -146,16 +164,13 @@ SVTK_SignalHandler vtkActorCollection* anActors = myMainWindow->getRenderer()->GetActors(); using namespace SVTK; - ForEach(anActors, - THighlightAction( false )); SVTK_Selector* aSelector = myMainWindow->GetSelector(); const SALOME_ListIO& aListIO = aSelector->StoredIObjects(); - SALOME_ListIteratorOfListIO anIter(aListIO); - for(; anIter.More(); anIter.Next()){ - ForEachIf(anActors, - TIsSameIObject(anIter.Value()), - THighlightAction(true)); - } + + ForEachIfElse(anActors, + TIsInList(aListIO), + THighlightAction(true), + THighlightAction(false)); myMainWindow->Repaint(false); }