]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
CCAR: optimize method isVisible of SOCC viewer by using entry2aisobjects map
authorcaremoli <caremoli>
Mon, 10 Jan 2011 10:29:13 +0000 (10:29 +0000)
committercaremoli <caremoli>
Mon, 10 Jan 2011 10:29:13 +0000 (10:29 +0000)
src/SOCC/SOCC_ViewModel.cxx

index ab5e2829f17111efb1a81680ce85ae107d57299a..32487ea434db6d4bec1caca0da826b1c8968fb60 100755 (executable)
@@ -182,17 +182,19 @@ bool SOCC_Viewer::isInViewer( const Handle(SALOME_InteractiveObject)& obj,
 */
 bool SOCC_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& obj )
 {
-  AIS_ListOfInteractive List;
-  getAISContext()->DisplayedObjects( List );
 
-  AIS_ListIteratorOfListOfInteractive ite( List );
-  for ( ; ite.More(); ite.Next() )
-  {
-    Handle(SALOME_InteractiveObject) anObj =
-      Handle(SALOME_InteractiveObject)::DownCast( ite.Value()->GetOwner() );
-
-    if ( !anObj.IsNull() && anObj->hasEntry() && anObj->isSame( obj ) )
-      return getAISContext()->IsDisplayed( ite.Value() );
+  std::map< std::string , std::vector<Handle(AIS_InteractiveObject)> >::iterator it=entry2aisobjects.find(obj->getEntry());
+  if(it != entry2aisobjects.end())
+    {
+      // get context
+      Handle (AIS_InteractiveContext) ic = getAISContext();
+      std::vector<Handle(AIS_InteractiveObject)>& List = it->second;
+      for( unsigned int ind = 0; ind < List.size(); ind++ )
+        {
+          Handle(AIS_InteractiveObject) anAIS=List[ind];
+          if(ic->IsDisplayed(anAIS))
+            return true;
+        }
   }
   
   return false;