From a81b458302c330ba359253522c7403082a7d1c50 Mon Sep 17 00:00:00 2001 From: mpv Date: Mon, 21 Dec 2015 11:46:09 +0300 Subject: [PATCH] Fix for the issue #1103 --- src/Model/Model_Data.cpp | 6 +--- src/Model/Model_ResultBody.cpp | 16 +++++++++ src/Model/Model_ResultBody.h | 4 +++ src/Model/Model_ResultCompSolid.cpp | 54 ++++++++++++++++++++--------- 4 files changed, 58 insertions(+), 22 deletions(-) diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index ed612e518..47f27eaad 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -427,14 +427,10 @@ void Model_Data::updateConcealmentFlag() } } } - // thus, no concealment references anymore => make not-concealed std::shared_ptr aRes = std::dynamic_pointer_cast(myObject); if (aRes.get()) { - // if compsolid result has subs, do nothing directly: it depends on the sub's status (#1100) - ResultCompSolidPtr aComp = std::dynamic_pointer_cast(myObject); - if (!aComp || aComp->numberOfSubs() == 0 || aComp->ModelAPI_ResultCompSolid::isConcealed()) - aRes->setIsConcealed(false); + aRes->setIsConcealed(false); } } diff --git a/src/Model/Model_ResultBody.cpp b/src/Model/Model_ResultBody.cpp index 8418ba22f..c4abb777c 100644 --- a/src/Model/Model_ResultBody.cpp +++ b/src/Model/Model_ResultBody.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include // DEB //#include @@ -46,3 +47,18 @@ bool Model_ResultBody::isLatestEqual(const std::shared_ptr& theSh { return myBuilder->isLatestEqual(theShape); } + +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; + } + } + return false; +} diff --git a/src/Model/Model_ResultBody.h b/src/Model/Model_ResultBody.h index 3c4b0f9ca..282c07047 100644 --- a/src/Model/Model_ResultBody.h +++ b/src/Model/Model_ResultBody.h @@ -41,6 +41,10 @@ public: MODEL_EXPORT virtual bool setDisabled(std::shared_ptr theThis, const bool theFlag); + /// The compsolid is concealed if at least one of the sub is concealed, + /// so, sub is Concealed if at least one sub is concealed + MODEL_EXPORT virtual bool isConcealed(); + /// Returns true if the latest modification of this body in the naming history // is equal to the given shape MODEL_EXPORT virtual bool isLatestEqual(const std::shared_ptr& theShape); diff --git a/src/Model/Model_ResultCompSolid.cpp b/src/Model/Model_ResultCompSolid.cpp index 96cdf32fc..902290298 100755 --- a/src/Model/Model_ResultCompSolid.cpp +++ b/src/Model/Model_ResultCompSolid.cpp @@ -103,36 +103,56 @@ bool Model_ResultCompSolid::isConcealed() aResult = true; } else { std::vector >::const_iterator aSubIter = mySubs.cbegin(); - for(; aSubIter != mySubs.cend(); aSubIter++) - if ((*aSubIter)->isConcealed()) + for(; aSubIter != mySubs.cend(); aSubIter++) { + if ((*aSubIter)->ModelAPI_ResultBody::isConcealed()) { aResult = true; + break; + } + } } if (myLastConcealed != aResult) { myLastConcealed = aResult; - setIsConcealed(aResult); // set for all subs the same result + //setIsConcealed(aResult); // set for all subs the same result + std::vector >::const_iterator aSubIter = mySubs.cbegin(); + for(; aSubIter != mySubs.cend(); aSubIter++) { // update the visualization status of each sub + if ((*aSubIter)->ModelAPI_ResultBody::isConcealed() != aResult) { + if (aResult) { // hidden unit must be redisplayed (hidden) + ModelAPI_EventCreator::get()->sendDeleted(document(), (*aSubIter)->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(*aSubIter, EVENT_DISP); + } else { // was not concealed become concealed => delete event + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); + ModelAPI_EventCreator::get()->sendUpdated(*aSubIter, anEvent); + } + } + } } return aResult; } void Model_ResultCompSolid::setIsConcealed(const bool theValue) { - ModelAPI_ResultCompSolid::setIsConcealed(theValue); - std::vector >::const_iterator aSubIter = mySubs.cbegin(); - for(; aSubIter != mySubs.cend(); aSubIter++) { - if ((*aSubIter)->isConcealed() != theValue) { - (*aSubIter)->setIsConcealed(theValue); - if (theValue) { // hidden unit must be redisplayed (hidden) - ModelAPI_EventCreator::get()->sendDeleted(document(), (*aSubIter)->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(*aSubIter, EVENT_DISP); - } else { // was not concealed become concealed => delete event - static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); - ModelAPI_EventCreator::get()->sendUpdated(*aSubIter, anEvent); + if (theValue != ModelAPI_ResultCompSolid::isConcealed()) { + std::vector >::const_iterator aSubIter = mySubs.cbegin(); + for(; aSubIter != mySubs.cend(); aSubIter++) { + if ((*aSubIter)->ModelAPI_ResultBody::isConcealed() != theValue) { + if (theValue) { // hidden unit must be redisplayed (hidden) + ModelAPI_EventCreator::get()->sendDeleted(document(), (*aSubIter)->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(*aSubIter, EVENT_DISP); + } else { // was not concealed become concealed => delete event + static Events_ID anEvent = Events_Loop::eventByName(EVENT_OBJECT_CREATED); + ModelAPI_EventCreator::get()->sendUpdated(*aSubIter, anEvent); + } } } + ModelAPI_ResultCompSolid::setIsConcealed(theValue); } + myLastConcealed = theValue; } void Model_ResultCompSolid::updateSubs(const std::shared_ptr& theThisShape) -- 2.39.2