]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Optimizing selection highlighting
authorsan <san@opencascade.com>
Fri, 20 Mar 2009 16:30:48 +0000 (16:30 +0000)
committersan <san@opencascade.com>
Fri, 20 Mar 2009 16:30:48 +0000 (16:30 +0000)
Invoking ModifiedEvent for the selector when its selection mode changes

src/SVTK/SVTK_Functor.h
src/SVTK/SVTK_Selector.cxx
src/SVTK/SVTK_View.cxx

index d76a9354898900d22a5bcfef791af36c7db2f183..84548a429ca0871c50981f3085c6161f49da5755 100644 (file)
@@ -26,6 +26,9 @@
 #include <VTKViewer_Functor.h>
 
 #include "SALOME_InteractiveObject.hxx"
+#include "SALOME_ListIO.hxx"
+
+#include <TColStd_MapOfTransient.hxx>
 
 /*!
   \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<class TActor> 
+  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;
+    }
+  };
+
 
   //----------------------------------------------------------------
   /*!
index 906574ca788e04f654cf0562956b895ebc18d305..1945fbc1761c025ddf37c9e02256f6852f1c0d38 100644 (file)
@@ -125,6 +125,8 @@ SVTK_SelectorDef
     mySelectionMode = theMode;
     myMapIOSubIndex.clear();
     this->EndPickCallback();
+    // Let everybody process selection mode change
+    this->Modified();
   }
 }
 
index 57e6e49eb3dd27fc82f03e32c86860f0e35209ea..676df5cc2711c957af206f967e4a01ab793497d9 100644 (file)
@@ -40,6 +40,8 @@
 #include <vtkActorCollection.h>
 #include <vtkRenderer.h>
 
+#include <set>
+
 /*!
   Constructor
 */
@@ -134,6 +136,22 @@ namespace SVTK
       }
     }
   };
+
+  struct TAddAction
+  {
+    std::set<SALOME_Actor*>* myActors;
+    TAddAction( std::set<SALOME_Actor*>* 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<SALOME_Actor>(anActors,
-                       THighlightAction( false ));
   SVTK_Selector* aSelector = myMainWindow->GetSelector();
   const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
-  SALOME_ListIteratorOfListIO anIter(aListIO);
-  for(; anIter.More(); anIter.Next()){
-    ForEachIf<SALOME_Actor>(anActors,
-                           TIsSameIObject<SALOME_Actor>(anIter.Value()),
-                           THighlightAction(true));
-  }
+
+  ForEachIfElse<SALOME_Actor>(anActors,
+                              TIsInList<SALOME_Actor>(aListIO),
+                              THighlightAction(true),
+                              THighlightAction(false));
 
   myMainWindow->Repaint(false);
 }