]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #388: Synchronize list of displayed objects on activation of module
authorvsv <vitaly.smetannikov@opencascade.com>
Fri, 17 Apr 2015 15:45:40 +0000 (18:45 +0300)
committervsv <vitaly.smetannikov@opencascade.com>
Fri, 17 Apr 2015 15:45:40 +0000 (18:45 +0300)
src/NewGeom/NewGeom_Module.cpp

index 50279350e19f198496233c71ed9cde0bcdc72db3..a569af01598bb1939a8d8caf16033dc602fbc2cd 100644 (file)
@@ -33,6 +33,9 @@
 #include <Config_PropManager.h>
 #include <Config_ModuleReader.h>
 
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+
 #include <QDockWidget>
 #include <QAction>
 #include <QTimer>
@@ -178,6 +181,33 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
   // switch off in this module
   aResMgr->setValue("Study", "store_positions", false);
 
+  // Synchronize displayed objects
+  if (mySelector && mySelector->viewer()) {
+    Handle(AIS_InteractiveContext) aContext = mySelector->viewer()->getAISContext();
+    XGUI_Displayer* aDisp = myWorkshop->displayer();
+    QObjectPtrList aObjList = aDisp->displayedObjects();
+
+    AIS_ListOfInteractive aList;
+    aContext->DisplayedObjects(aList);
+    AIS_ListIteratorOfListOfInteractive aLIt;
+    Handle(AIS_InteractiveObject) anAISIO;
+    foreach (ObjectPtr aObj, aObjList) {
+      AISObjectPtr aPrs = aDisp->getAISObject(aObj);
+      Handle(AIS_InteractiveObject) aAIS = aPrs->impl<Handle(AIS_InteractiveObject)>();
+      bool aFound = false;
+      for (aLIt.Initialize(aList); aLIt.More(); aLIt.Next()) {
+        anAISIO = aLIt.Value();
+        if (anAISIO.Access() == aAIS.Access()) {
+          aFound = true;
+          break;
+        }
+      }
+      if (!aFound) {
+        aDisp->erase(aObj, false);
+      }
+    }
+  }
+
   return isDone;
 }