Salome HOME
Fix for the issue #593: do not remove naming attribute, but use TNaming_Builder for...
[modules/shaper.git] / src / NewGeom / NewGeom_Module.cpp
index 56e7b52025dc11d1a6b1f34564284b38d473523f..8265e654c66668f3b30c4acf870cb8d99f3b802a 100644 (file)
@@ -35,6 +35,9 @@
 #include <Config_PropManager.h>
 #include <Config_ModuleReader.h>
 
+#include <AIS_ListOfInteractive.hxx>
+#include <AIS_ListIteratorOfListOfInteractive.hxx>
+
 #include <QDockWidget>
 #include <QAction>
 #include <QTimer>
@@ -162,7 +165,9 @@ bool NewGeom_Module::activateModule(SUIT_Study* theStudy)
       myWorkshop->objectBrowser()->rebuildDataTree();
       myWorkshop->updateCommandStatus();
       myIsOpened = false;
-      QTimer::singleShot(1000, myWorkshop, SLOT(displayAllResults()));
+      // the display all results is not necessary anymore, it was commented in XGUI_Workshop,
+      // so it should be commented here
+      //QTimer::singleShot(1000, myWorkshop, SLOT(displayAllResults()));
     }
     else
       myWorkshop->updateCommandStatus();
@@ -180,6 +185,35 @@ 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) {
+        aObj->setDisplayed(false);
+        //aDisp->erase(aObj, false);
+      }
+    }
+    Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+  }
+
   return isDone;
 }
 
@@ -239,7 +273,11 @@ void NewGeom_Module::onViewManagerRemoved(SUIT_ViewManager* theMgr)
     if (theMgr->getType() == OCCViewer_Viewer::Type()) {
       OCCViewer_Viewer* aViewer = static_cast<OCCViewer_Viewer*>(theMgr->getViewModel());
       if (mySelector->viewer() == aViewer) {
-        myWorkshop->displayer()->eraseAll(false);
+        XGUI_Displayer* aDisp = myWorkshop->displayer();
+        QObjectPtrList aObjects = aDisp->displayedObjects();
+        foreach(ObjectPtr aObj, aObjects)
+          aObj->setDisplayed(false);
+        Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
         myProxyViewer->setSelector(0);
         delete mySelector;
         mySelector = 0;
@@ -311,7 +349,8 @@ QAction* NewGeom_Module::addFeature(const QString& theWBName, const ActionInfo&
                     theInfo.text,
                     theInfo.toolTip,
                     theInfo.icon,
-                    theInfo.shortcut);
+                    theInfo.shortcut,
+                    theInfo.checkable);
 }
 
 //******************************************************
@@ -475,7 +514,7 @@ void NewGeom_Module::selectionChanged()
 //******************************************************
 void NewGeom_Module::contextMenuPopup(const QString& theClient, QMenu* theMenu, QString& theTitle)
 {
-  myWorkshop->contextMenuMgr()->addViewerItems(theMenu);
+  myWorkshop->contextMenuMgr()->addViewerMenu(theMenu);
   LightApp_Module::contextMenuPopup(theClient, theMenu, theTitle);
 }