]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #17958: Sketch displayed in edit mode after sketch feature has been closed
authorvsv <vsv@opencascade.com>
Mon, 11 Nov 2019 13:25:54 +0000 (16:25 +0300)
committervsv <vsv@opencascade.com>
Mon, 11 Nov 2019 13:26:09 +0000 (16:26 +0300)
src/PartSet/PartSet_MenuMgr.cpp
src/PartSet/PartSet_TreeNodes.cpp
src/SHAPERGUI/SHAPERGUI.cpp
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h

index 06ebaefa6e65416f6446c1cf7f57f9cc7b581cd6..5756d13d6ac0bed9fe297b7adfec9b362aa0ae31 100644 (file)
@@ -516,7 +516,8 @@ void PartSet_MenuMgr::activatePartSet() const
   if (isNewTransaction)
     aMgr->startOperation("Activation");
   aMgr->setActiveDocument(aMgr->moduleDocument());
-  if (isNewTransaction) aMgr->finishOperation();
+  if (isNewTransaction)
+    aMgr->finishOperation();
 
   myModule->workshop()->updateCommandStatus();
 }
index b49acbb10ec811917d19510e29b8c50fdb1684ba..e886365e2b28a63e4b789b5108d2b33b4cba15e3 100644 (file)
@@ -232,6 +232,9 @@ void PartSet_ObjectNode::update()
 
     // If the object is a field result then delete extra sub-objects
     if (aFieldRes.get()) {
+      // Call shape in order to update content of Field.
+      // It is necessary to do for cases when field was created by script when module is inactive.
+      aFieldRes->shape();
       while (myChildren.size() > aNb) {
         ModuleBase_ITreeNode* aNode = myChildren.last();
         myChildren.removeAll(aNode);
@@ -274,15 +277,17 @@ void PartSet_ObjectNode::update()
       }
       else if (aFieldRes.get()) {
         FieldStepPtr aStep = aFieldRes->step(i);
-        if (i < myChildren.size()) {
-          PartSet_StepNode* aStepNode = static_cast<PartSet_StepNode*>(myChildren.at(i));
-          if (aStepNode->object() != aStep) {
-            aStepNode->setObject(aStep);
+        if (aStep.get()) {
+          if (i < myChildren.size()) {
+            PartSet_StepNode* aStepNode = static_cast<PartSet_StepNode*>(myChildren.at(i));
+            if (aStepNode->object() != aStep) {
+              aStepNode->setObject(aStep);
+            }
+          }
+          else {
+            aNode = new PartSet_StepNode(aStep, this);
+            myChildren.append(aNode);
           }
-        }
-        else {
-          aNode = new PartSet_StepNode(aStep, this);
-          myChildren.append(aNode);
         }
       }
     }
@@ -309,6 +314,10 @@ QTreeNodesList PartSet_ObjectNode::objectCreated(const QObjectPtrList& theObject
     ResultFieldPtr aFieldRes = std::dynamic_pointer_cast<ModelAPI_ResultField>(myObject);
     ObjectPtr aBody;
     int i;
+    // Call shape in order to update content of Field.
+    // It is necessary to do for cases when field was created by script when module is inactive.
+    if (aFieldRes.get())
+      aFieldRes->shape();
     for (i = 0; i < aNb; i++) {
       aBody = subObject(i);
       if (aBody.get()) {
@@ -328,15 +337,17 @@ QTreeNodesList PartSet_ObjectNode::objectCreated(const QObjectPtrList& theObject
       }
       else {
         FieldStepPtr aStep = aFieldRes->step(i);
-        if (i < myChildren.size()) {
-          PartSet_StepNode* aStepNode = static_cast<PartSet_StepNode*>(myChildren.at(i));
-          if (aStepNode->object() != aStep) {
-            aStepNode->setObject(aStep);
+        if (aStep.get()) {
+          if (i < myChildren.size()) {
+            PartSet_StepNode* aStepNode = static_cast<PartSet_StepNode*>(myChildren.at(i));
+            if (aStepNode->object() != aStep) {
+              aStepNode->setObject(aStep);
+            }
+          }
+          else {
+            aNode = new PartSet_StepNode(aStep, this);
+            myChildren.append(aNode);
           }
-        }
-        else {
-          aNode = new PartSet_StepNode(aStep, this);
-          myChildren.append(aNode);
         }
       }
     }
index 5b69d3593ffb8e02830a296173cbdf0abf0185bb..0ac188e119a9146604c8bf955da901dc15ef4daa 100644 (file)
@@ -500,6 +500,7 @@ void SHAPERGUI::onScriptLoaded()
   SUIT_DataBrowser* aBrowser = getApp()->objectBrowser();
   if (aBrowser)
     delete aBrowser;
+  myWorkshop->displayer()->updateViewer();
 }
 
 //******************************************************
index 24e7954fc1b970e335c4d486a3c2f28208e62292..f97e58aa6254e88dbb5d7538b812a2ee41cc5775 100644 (file)
@@ -2791,33 +2791,43 @@ void XGUI_Workshop::synchronizeViewer()
   aDocs.append(aMgr->moduleDocument());
 
   foreach(DocumentPtr aDoc, aDocs) {
-    synchronizeGroupInViewer(aDoc, ModelAPI_ResultConstruction::group(), false);
-    synchronizeGroupInViewer(aDoc, ModelAPI_ResultBody::group(), false);
-    synchronizeGroupInViewer(aDoc, ModelAPI_ResultPart::group(), false);
-    synchronizeGroupInViewer(aDoc, ModelAPI_ResultGroup::group(), false);
+    synchronizeGroupInViewer(aDoc, false);
   }
 }
 
 //******************************************************
 void XGUI_Workshop::synchronizeGroupInViewer(const DocumentPtr& theDoc,
-                                             const std::string& theGroup,
                                              bool theUpdateViewer)
 {
-  ObjectPtr aObj;
-  int aSize = theDoc->size(theGroup);
+  FeaturePtr aFeature;
+  ResultPtr aRes;
+  int aSize = theDoc->numInternalFeatures();
   for (int i = 0; i < aSize; i++) {
-    aObj = theDoc->object(theGroup, i);
-    if (aObj->isDisplayed()) {
-      // Hide the presentation with an empty shape. But isDisplayed state of the object should not
-      // be changed to the object becomes visible when the shape becomes not empty
-      ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
-      if (aRes.get() && (!aRes->shape().get() || aRes->shape()->isNull()))
-        continue;
-      ResultBodyPtr aResBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aObj);
-      if (aResBody.get())
-        synchronizeResultTree(aResBody, false);
-      else
-        myDisplayer->display(aObj, false);
+    aFeature = theDoc->internalFeature(i);
+    const std::list<ResultPtr>& aResults = aFeature->results();
+    std::list<ResultPtr>::const_iterator aIt;
+    aFeature->setDisplayed(false);
+    for (aIt = aResults.cbegin(); aIt != aResults.cend(); aIt++) {
+      aRes = (*aIt);
+      if (aRes->isDisplayed() && !aRes->isConcealed()) {
+        // Hide the presentation with an empty shape. But isDisplayed state of the object should not
+        // be changed to the object becomes visible when the shape becomes not empty
+        if (!aRes->shape().get() || aRes->shape()->isNull())
+          continue;
+        ResultBodyPtr aResBody = std::dynamic_pointer_cast<ModelAPI_ResultBody>(aRes);
+        if (aResBody.get())
+          synchronizeResultTree(aResBody, false);
+        else {
+          if (aRes->isInHistory()) {
+            if (aRes->isDisplayed())
+              myDisplayer->display(aRes, false);
+            else
+              myDisplayer->erase(aRes, false);
+          }
+          else
+            aRes->setDisplayed(false);
+        }
+      }
     }
   }
   if (theUpdateViewer)
index 982758244fa3eecb338fcb879d0e8d3b037573fc..8f524f3cb5d92244bc573f7356c612d00d989f52 100644 (file)
@@ -282,10 +282,8 @@ Q_OBJECT
   /// Has to be called in order to display objects from a specifed group
   /// with visibility status = true
   /// \param theDoc the document for objects synchronisation
-  /// \param theGroup the group name
   /// \param theUpdateViewer update viewer flag
   void synchronizeGroupInViewer(const DocumentPtr& theDoc,
-                                const std::string& theGroup,
                                 bool theUpdateViewer);
 
   void synchronizeResultTree(const ResultBodyPtr& theRes, bool theUpdateViewer);