Salome HOME
Merge branch 'Dev_1.2.0' of newgeom:newgeom into Dev_1.2.0
[modules/shaper.git] / src / XGUI / XGUI_Workshop.cpp
index dcf348ff61b4b7bf4349e4d8c397fa9c32b5fc95..646a41bfa8c070f70a6f183e566d8db0c59b2cb1 100644 (file)
@@ -468,17 +468,19 @@ void XGUI_Workshop::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectU
         // of redisplay is called. This modification is made in order to have the line is updated
         // by creation of a horizontal constraint on the line by preselection
         myDisplayer->redisplay(aObj, false);
-        if (myOperationMgr->hasOperation()) {
-          ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-          if (!aOperation->isEditOperation() &&
-              aOperation->hasObject(aObj) && myDisplayer->isActive(aObj))
+        //if (myOperationMgr->hasOperation()) {
+        //  ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+        //  if (!aOperation->isEditOperation() &&
+        //      aOperation->hasObject(aObj) && myDisplayer->isActive(aObj))
+        if (!myModule->canActivateSelection(aObj)) {
+          if (myDisplayer->isActive(aObj))
             myDisplayer->deactivate(aObj);
         }
       } else { // display object if the current operation has it
         if (displayObject(aObj)) {
-          ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
-          if (aOperation && aOperation->hasObject(aObj)) {
-            ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+          //ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+          //if (aOperation && aOperation->hasObject(aObj)) {
+          if (!myModule->canActivateSelection(aObj)) {
             #ifdef DEBUG_FEATURE_REDISPLAY
               QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
               qDebug(QString("  display object = %1").arg(anObjInfo).toStdString().c_str());
@@ -515,16 +517,17 @@ void XGUI_Workshop::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpd
     // the validity of the data should be checked here in order to avoid display of the objects,
     // which were created, then deleted, but flush for the creation event happens after that
     // we should not display disabled objects
-    if (!anObject->data() || !anObject->data()->isValid() || anObject->isDisabled())
-      continue;
-    //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
-    //if (aPart) {
-      //aHasPart = true;
-      // If a feature is created from the aplication's python console  
-      // it doesn't stored in the operation mgr and doesn't displayed
-    //} else {
-    isDisplayed = displayObject(*aIt);
-    //}
+    bool aHide = !anObject->data() || !anObject->data()->isValid() || 
+      anObject->isDisabled() || (!anObject->isDisplayed());
+    if (!aHide) {
+      // setDisplayed has to be called in order to synchronize internal state of the object 
+      // with list of displayed objects
+      if (myModule->canDisplayObject(anObject)) {
+        anObject->setDisplayed(true);
+        isDisplayed = displayObject(*aIt);
+      } else 
+        anObject->setDisplayed(false);
+    }
   }
   //if (myObjectBrowser)
   //  myObjectBrowser->processEvent(theMsg);
@@ -847,7 +850,7 @@ void XGUI_Workshop::onOpen()
   aSession->closeAll();
   aSession->load(myCurrentDir.toLatin1().constData());
   myObjectBrowser->rebuildDataTree();
-  displayAllResults();
+  //displayAllResults();
   updateCommandStatus();
   myIsLoadingData = false;
   QApplication::restoreOverrideCursor();
@@ -1267,7 +1270,7 @@ void XGUI_Workshop::deleteObjects()
   aDescription += tr(" %1");
   QStringList aObjectNames;
   foreach (ObjectPtr aObj, anObjects) {
-    if (!aObj->data().get())
+    if (!aObj->data()->isValid())
       continue;
     aObjectNames << QString::fromStdString(aObj->data()->name());
   }