From: mpv Date: Tue, 12 Apr 2016 10:24:00 +0000 (+0300) Subject: Issue #1383 Preview button: implementation on the Updater level X-Git-Tag: V_2.3.0~243 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c549e1f27fbeb398fe73cb2afa62823be2c4abab;p=modules%2Fshaper.git Issue #1383 Preview button: implementation on the Updater level --- diff --git a/src/Model/Model_Data.cpp b/src/Model/Model_Data.cpp index f292ccc75..351f2e4d1 100644 --- a/src/Model/Model_Data.cpp +++ b/src/Model/Model_Data.cpp @@ -303,17 +303,19 @@ void Model_Data::blockSendAttributeUpdated(const bool theBlock) void Model_Data::erase() { if (!myLab.IsNull()) { - // remove in order to clear back references in other objects - std::list > > aRefs; - referencesToObjects(aRefs); - std::list > >::iterator anAttrIter = aRefs.begin(); - for(; anAttrIter != aRefs.end(); anAttrIter++) { - std::list::iterator aReferenced = anAttrIter->second.begin(); - for(; aReferenced != anAttrIter->second.end(); aReferenced++) { - if (aReferenced->get() && (*aReferenced)->data()->isValid()) { - std::shared_ptr aData = - std::dynamic_pointer_cast((*aReferenced)->data()); - aData->removeBackReference(myAttrs[anAttrIter->first]); + if (myLab.HasAttribute()) { + // remove in order to clear back references in other objects + std::list > > aRefs; + referencesToObjects(aRefs); + std::list > >::iterator anAttrIter = aRefs.begin(); + for(; anAttrIter != aRefs.end(); anAttrIter++) { + std::list::iterator aReferenced = anAttrIter->second.begin(); + for(; aReferenced != anAttrIter->second.end(); aReferenced++) { + if (aReferenced->get() && (*aReferenced)->data()->isValid()) { + std::shared_ptr aData = + std::dynamic_pointer_cast((*aReferenced)->data()); + aData->removeBackReference(myAttrs[anAttrIter->first]); + } } } } diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index d421d2161..e2eeeea2e 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -691,8 +691,7 @@ void Model_Objects::synchronizeFeatures( // redisplay also removed feature (used for sketch and AISObject) ModelAPI_EventCreator::get()->sendUpdated(aFeature, aRedispEvent); updateHistory(aFeature); - // don't call this because it will ask the internal attributes - //aFeature->erase(); + aFeature->erase(); // unbind after the "erase" call: on abort sketch is removes sub-objects that corrupts aFIter myFeatures.UnBind(aFIter.Key()); diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 2daf3f645..afe7e7c41 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -52,11 +52,16 @@ Model_Update::Model_Update() aLoop->registerListener(this, kOpStartEvent); static const Events_ID kStabilityEvent = aLoop->eventByName(EVENT_STABILITY_CHANGED); aLoop->registerListener(this, kStabilityEvent); + static const Events_ID kPreviewBlockedEvent = aLoop->eventByName(EVENT_PREVIEW_BLOCKED); + aLoop->registerListener(this, kPreviewBlockedEvent); + static const Events_ID kPreviewRequestedEvent = aLoop->eventByName(EVENT_PREVIEW_REQUESTED); + aLoop->registerListener(this, kPreviewRequestedEvent); // Config_PropManager::findProp("Model update", "automatic_rebuild")->value() == "true"; myIsParamUpdated = false; myIsFinish = false; myIsProcessed = false; + myIsPreviewBlocked = false; } bool Model_Update::addModified(FeaturePtr theFeature, FeaturePtr theReason) { @@ -158,6 +163,9 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag 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); + static const Events_ID kPreviewBlockedEvent = aLoop->eventByName(EVENT_PREVIEW_BLOCKED); + static const Events_ID kPreviewRequestedEvent = aLoop->eventByName(EVENT_PREVIEW_REQUESTED); + #ifdef DEB_UPDATE std::cout<<"****** Event "<eventID().eventText()<& theMessag updateStability(theMessage->sender()); return; } + if (theMessage->eventID() == kPreviewBlockedEvent) { + myIsPreviewBlocked = true; + return; + } + if (theMessage->eventID() == kPreviewRequestedEvent) { + if (myIsPreviewBlocked) { + myIsPreviewBlocked = false; + processFeatures(); + myIsPreviewBlocked = true; + } + return; + } // creation is added to "update" to avoid recomputation twice: on create and immediately after on update if (theMessage->eventID() == kCreatedEvent) { std::shared_ptr aMsg = @@ -217,6 +237,7 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag } } else if (theMessage->eventID() == kOpFinishEvent || theMessage->eventID() == kOpAbortEvent || theMessage->eventID() == kOpStartEvent) { + myIsPreviewBlocked = false; if (theMessage->eventID() == kOpFinishEvent) { myIsFinish = true; @@ -260,7 +281,8 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag void Model_Update::processFeatures() { - if (!myIsProcessed) { // perform update of everything if it is not performed right now + // perform update of everything if it is not performed right now or any preview is blocked + if (!myIsProcessed && !myIsPreviewBlocked) { myIsProcessed = true; #ifdef DEB_UPDATE std::cout<<"****** Start processing"< > myProcessOnFinish; /// to avoid infinitive cycling: feature -> count of the processing periods during this update std::map, int > myProcessed; + /// if preview in hte property panel is blocked and any update is postponed until the end of operation + bool myIsPreviewBlocked; public: /// Is called only once, on startup of the application diff --git a/src/ModelAPI/ModelAPI_CompositeFeature.cpp b/src/ModelAPI/ModelAPI_CompositeFeature.cpp index 34066ecd2..09b5919f3 100644 --- a/src/ModelAPI/ModelAPI_CompositeFeature.cpp +++ b/src/ModelAPI/ModelAPI_CompositeFeature.cpp @@ -20,11 +20,13 @@ void ModelAPI_CompositeFeature::exchangeIDs( void ModelAPI_CompositeFeature::erase() { // erase all sub-features - for(int a = numberOfSubs(); a > 0; a--) { - FeaturePtr aFeature = subFeature(a - 1); - if (aFeature.get()) { - // subs are referenced from sketch, but must be removed for sure, so not checkings - aFeature->document()->removeFeature(aFeature); + if (data()->isValid()) { + for(int a = numberOfSubs(); a > 0; a--) { + FeaturePtr aFeature = subFeature(a - 1); + if (aFeature.get()) { + // subs are referenced from sketch, but must be removed for sure, so not checkings + aFeature->document()->removeFeature(aFeature); + } } } ModelAPI_Feature::erase();