From: vsv Date: Mon, 11 Nov 2019 13:25:54 +0000 (+0300) Subject: Issue #17958: Sketch displayed in edit mode after sketch feature has been closed X-Git-Tag: V9_5_0a1~174 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2b2238833fe47e943c540a31dbb8ed941d1155f3;p=modules%2Fshaper.git Issue #17958: Sketch displayed in edit mode after sketch feature has been closed --- diff --git a/src/PartSet/PartSet_MenuMgr.cpp b/src/PartSet/PartSet_MenuMgr.cpp index 06ebaefa6..5756d13d6 100644 --- a/src/PartSet/PartSet_MenuMgr.cpp +++ b/src/PartSet/PartSet_MenuMgr.cpp @@ -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(); } diff --git a/src/PartSet/PartSet_TreeNodes.cpp b/src/PartSet/PartSet_TreeNodes.cpp index b49acbb10..e886365e2 100644 --- a/src/PartSet/PartSet_TreeNodes.cpp +++ b/src/PartSet/PartSet_TreeNodes.cpp @@ -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(myChildren.at(i)); - if (aStepNode->object() != aStep) { - aStepNode->setObject(aStep); + if (aStep.get()) { + if (i < myChildren.size()) { + PartSet_StepNode* aStepNode = static_cast(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(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(myChildren.at(i)); - if (aStepNode->object() != aStep) { - aStepNode->setObject(aStep); + if (aStep.get()) { + if (i < myChildren.size()) { + PartSet_StepNode* aStepNode = static_cast(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); } } } diff --git a/src/SHAPERGUI/SHAPERGUI.cpp b/src/SHAPERGUI/SHAPERGUI.cpp index 5b69d3593..0ac188e11 100644 --- a/src/SHAPERGUI/SHAPERGUI.cpp +++ b/src/SHAPERGUI/SHAPERGUI.cpp @@ -500,6 +500,7 @@ void SHAPERGUI::onScriptLoaded() SUIT_DataBrowser* aBrowser = getApp()->objectBrowser(); if (aBrowser) delete aBrowser; + myWorkshop->displayer()->updateViewer(); } //****************************************************** diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 24e7954fc..f97e58aa6 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -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(aObj); - if (aRes.get() && (!aRes->shape().get() || aRes->shape()->isNull())) - continue; - ResultBodyPtr aResBody = std::dynamic_pointer_cast(aObj); - if (aResBody.get()) - synchronizeResultTree(aResBody, false); - else - myDisplayer->display(aObj, false); + aFeature = theDoc->internalFeature(i); + const std::list& aResults = aFeature->results(); + std::list::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(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) diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index 982758244..8f524f3cb 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -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);