From 8ab0ae98e90b50e4bc2d8280f5734a1fad142a76 Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 28 Dec 2015 16:43:56 +0300 Subject: [PATCH] Fix for the issue #1196 --- src/Model/Model_Document.cpp | 13 ++++++++---- src/Model/Model_Objects.cpp | 10 +++++++++ src/Model/Model_ResultBody.cpp | 37 +++++++++++++++++++++++++--------- src/Model/Model_ResultBody.h | 4 ++++ 4 files changed, 51 insertions(+), 13 deletions(-) diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index ec071b403..645291f72 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -979,13 +979,18 @@ void Model_Document::setCurrentFeature( } // update for everyone the concealment flag immideately: on edit feature in the midle of history if (aWasChanged) { - const std::list >& aResList = anIter->results(); - std::list >::const_iterator aRes = aResList.begin(); - for(; aRes != aResList.end(); aRes++) { + std::list aResults; + ModelAPI_Tools::allResults(anIter, aResults); + std::list::const_iterator aRes = aResults.begin(); + for(; aRes != aResults.end(); aRes++) { if ((*aRes).get() && (*aRes)->data()->isValid() && !(*aRes)->isDisabled()) std::dynamic_pointer_cast((*aRes)->data())->updateConcealmentFlag(); } - + // update the concealment status for disply in isConcealed of ResultBody + for(aRes = aResults.begin(); aRes != aResults.end(); aRes++) { + if ((*aRes).get() && (*aRes)->data()->isValid() && !(*aRes)->isDisabled()) + (*aRes)->isConcealed(); + } } } // unblock the flush signals and up them after this diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index f8ea0099e..aa8e2751c 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -820,6 +820,16 @@ void Model_Objects::synchronizeBackRefs() } } } + for(aFeatures.Initialize(myFeatures); aFeatures.More(); aFeatures.Next()) { + FeaturePtr aFeature = aFeatures.Value(); + std::list aResults; + ModelAPI_Tools::allResults(aFeature, aResults); + // update the concealment status for disply in isConcealed of ResultBody + std::list::iterator aRIter = aResults.begin(); + for(; aRIter != aResults.cend(); aRIter++) { + (*aRIter)->isConcealed(); + } + } } TDF_Label Model_Objects::resultLabel( diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index c4abb777c..5fb26d843 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -9,6 +9,7 @@ #include #include #include +#include // DEB //#include //#include @@ -17,6 +18,7 @@ Model_ResultBody::Model_ResultBody() { myBuilder = new Model_BodyBuilder(this); + myWasConcealed = false; } void Model_ResultBody::initAttributes() @@ -50,15 +52,32 @@ bool Model_ResultBody::isLatestEqual(const std::shared_ptr& theSh bool Model_ResultBody::isConcealed() { - if (ModelAPI_ResultBody::isConcealed()) - return true; - ResultPtr aThis = std::dynamic_pointer_cast(data()->owner()); - if (aThis.get()) { - ResultCompSolidPtr aParent = ModelAPI_Tools::compSolidOwner(aThis); - if (aParent.get()) { - if (aParent->isConcealed()) - return true; + bool aResult = false; + if (ModelAPI_ResultBody::isConcealed()) { + aResult = true; + } else { + ResultPtr aThis = std::dynamic_pointer_cast(data()->owner()); + if (aThis.get()) { + ResultCompSolidPtr aParent = ModelAPI_Tools::compSolidOwner(aThis); + if (aParent.get()) { + if (aParent->isConcealed()) + aResult = true; + } } } - return false; + if (myWasConcealed != aResult) { + myWasConcealed = aResult; + if (aResult) { // hidden unit must be redisplayed (hidden) + ModelAPI_EventCreator::get()->sendDeleted(document(), this->groupName()); + // redisplay for the viewer (it must be disappeared also) + static Events_ID EVENT_DISP = + Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY); + ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), EVENT_DISP); + } else { // was not concealed become concealed => delete event + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); + ModelAPI_EventCreator::get()->sendUpdated(data()->owner(), anEvent); + } + } + + return aResult; } diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h index 282c07047..bbb23da35 100644 --- a/src/Model/Model_ResultBody.h +++ b/src/Model/Model_ResultBody.h @@ -28,6 +28,10 @@ class Model_ResultBody : public ModelAPI_ResultBody /// builders that tores the naming history: one per label to allow store several shapes to one /// label; index in vector corresponds to the label tag //std::vector myBuilders; + + /// Flag that stores the previous state of "concealed": if it is changed, + /// The event is used to redisplay the body. + bool myWasConcealed; public: /// Request for initialization of data model of the result: adding all attributes virtual void initAttributes(); -- 2.39.2