From 5264a2bcac399b5ac51a1838a9ffb10c68f03a31 Mon Sep 17 00:00:00 2001 From: mpv Date: Fri, 9 Oct 2015 09:06:55 +0300 Subject: [PATCH] Make not-stable features lose the concealment ability --- src/Model/Model_Data.cpp | 2 +- src/Model/Model_Update.cpp | 17 +++++++++++++++++ src/Model/Model_Update.h | 2 ++ src/ModelAPI/ModelAPI_Events.h | 3 +++ src/ModelAPI/ModelAPI_Feature.cpp | 5 +++++ 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index 8d21b7a78..64574892c 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -388,7 +388,7 @@ void Model_Data::addBackReference(FeaturePtr theFeature, std::string theAttrID, return; myRefsToMe.insert(theFeature->data()->attribute(theAttrID)); - if (theApplyConcealment && + if (theApplyConcealment && theFeature->isStable() && ModelAPI_Session::get()->validators()->isConcealed(theFeature->getKind(), theAttrID)) { std::shared_ptr aRes = std::dynamic_pointer_cast(myObject); diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 69a10d745..21e38c5a4 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -54,6 +54,8 @@ Model_Update::Model_Update() aLoop->registerListener(this, kOpAbortEvent); static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation"); aLoop->registerListener(this, kOpStartEvent); + static const Events_ID kStabilityEvent = aLoop->eventByName(EVENT_STABILITY_CHANGED); + aLoop->registerListener(this, kStabilityEvent); /* not needed now with history line Config_PropManager::registerProp("Model update", "automatic_rebuild", "Rebuild immediately", @@ -76,9 +78,12 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag static const Events_ID kOpFinishEvent = aLoop->eventByName("FinishOperation"); static const Events_ID kOpAbortEvent = aLoop->eventByName("AbortOperation"); static const Events_ID kOpStartEvent = aLoop->eventByName("StartOperation"); + static const Events_ID kStabilityEvent = aLoop->eventByName(EVENT_STABILITY_CHANGED); #ifdef DEB_UPDATE std::cout<<"****** Event "<eventID().eventText()<eventID() == kStabilityEvent) + updateStability(theMessage->sender()); if (theMessage->eventID() == kChangedEvent) { // automatic and manual rebuild flag is changed /*bool aPropVal = Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true"; @@ -669,6 +674,18 @@ void Model_Update::executeFeature(FeaturePtr theFeature) redisplayWithResults(theFeature, aState); } +void Model_Update::updateStability(void* theSender) +{ + ModelAPI_Object* aSender = static_cast(theSender); + if (aSender && aSender->document()) { + Model_Objects* aDocObjects = + std::dynamic_pointer_cast(aSender->document())->objects(); + if (aDocObjects) { + aDocObjects->synchronizeBackRefs(); + } + } +} + ///////////////// Updated items iterator //////////////////////// Model_Update::IterationItem::IterationItem(std::shared_ptr theFeature) { diff --git a/src/Model/Model_Update.h b/src/Model/Model_Update.h index 862a078ce..3b543c1f5 100644 --- a/src/Model/Model_Update.h +++ b/src/Model/Model_Update.h @@ -125,6 +125,8 @@ protected: /// Returns true if the feature is older that the argument and it must be updated bool isOlder(std::shared_ptr theFeature, std::shared_ptr theArgument); + /// Updates the properties of object because of stability state changes + void updateStability(void* theSender); }; #endif diff --git a/src/ModelAPI/ModelAPI_Events.h b/src/ModelAPI/ModelAPI_Events.h index 45349a52c..f4fee024a 100644 --- a/src/ModelAPI/ModelAPI_Events.h +++ b/src/ModelAPI/ModelAPI_Events.h @@ -56,6 +56,9 @@ static const char * EVENT_SOLVER_REPAIRED = "SolverRepaired"; /// Event ID that order of objects in group is changed, so, tree must be fully rectreated (movement of feature) static const char * EVENT_ORDER_UPDATED = "OrderUpdated"; +/// Event ID that informs that some object has changed the stability +static const char * EVENT_STABILITY_CHANGED = "StabilityChanged"; + /// Message that feature was changed (used for Object Browser update): moved, updated and deleted class MODELAPI_EXPORT ModelAPI_ObjectUpdatedMessage : public Events_MessageGroup { diff --git a/src/ModelAPI/ModelAPI_Feature.cpp b/src/ModelAPI/ModelAPI_Feature.cpp index 6d17254bc..5b9d7e3d4 100644 --- a/src/ModelAPI/ModelAPI_Feature.cpp +++ b/src/ModelAPI/ModelAPI_Feature.cpp @@ -203,6 +203,11 @@ bool ModelAPI_Feature::setStable(const bool theFlag) { if (myIsStable != theFlag) { myIsStable = theFlag; + // send an event about the stability change (editing is started/finished) + static Events_Loop* aLoop = Events_Loop::loop(); + static Events_ID EVENT_STAB = aLoop->eventByName(EVENT_STABILITY_CHANGED); + std::shared_ptr aMessage(new Events_Message(EVENT_STAB, this)); + aLoop->send(aMessage, false); return true; } return false; -- 2.39.2