From 76524262f8549117008d42a65852c29ed7fb230a Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 10 Nov 2015 14:52:13 +0300 Subject: [PATCH] Fix the Macro Box update problem and general updating mechanism to be more stable --- src/Model/Model_Update.cpp | 42 ++++++++----------- src/Model/Model_Update.h | 4 ++ .../SketchPlugin_ConstraintFillet.cpp | 5 ++- 3 files changed, 26 insertions(+), 25 deletions(-) diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 496577676..e9cec6c46 100644 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -65,6 +65,7 @@ Model_Update::Model_Update() myIsParamUpdated = false; myIsFinish = false; myModification = 0; + myModificationInStartProcessing = 0; } void Model_Update::processEvent(const std::shared_ptr& theMessage) @@ -109,6 +110,8 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag if ((*anObjIter)->groupName() == ModelAPI_ResultParameter::group()) { myIsParamUpdated = true; } + if (myIsExecuted) // modifications from outside are with never IDs to take them into account in the current updates + myModification++; // on undo/redo, abort do not update persisten features FeaturePtr anUpdated = std::dynamic_pointer_cast(*anObjIter); if (std::dynamic_pointer_cast((*anObjIter)->document())->executeFeatures() || @@ -223,33 +226,13 @@ void Model_Update::iterateUpdateBreak(std::shared_ptr theFeatu void Model_Update::processOperation(const bool theTotalUpdate, const bool theFinish) { - /* cancel hardcode due to issue 948 - if (theFinish) { - // the hardcode (DBC asked): hide the sketch referenced by extrusion on apply - std::set >::iterator aFIter; - for(aFIter = myWaitForFinish.begin(); aFIter != myWaitForFinish.end(); aFIter++) - { - FeaturePtr aF = std::dynamic_pointer_cast(*aFIter); - if (aF && aF->data()->isValid() && - (aF->getKind() == "Extrusion" || aF->getKind() == "Revolution")) { - AttributeSelectionListPtr aBase = aF->selectionList("base"); - if (aBase.get()) { - for(int a = aBase->size() - 1; a >= 0; a--) { - ResultPtr aSketchRes = aBase->value(a)->context(); - if (aSketchRes) { - aSketchRes->setDisplayed(false); - } - } - } - } - } - } */ // perform update of everything if needed if (!myIsExecuted) { #ifdef DEB_UPDATE std::cout<<"****** Start processing"<eventByName(EVENT_OBJECT_UPDATED); + aLoop->flush(kUpdatedEvent); myModification++; // flush to update display - static Events_Loop* aLoop = Events_Loop::loop(); static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); aLoop->flush(EVENT_DISP); #ifdef DEB_UPDATE @@ -274,6 +262,12 @@ void Model_Update::processOperation(const bool theTotalUpdate, const bool theFin } } +bool Model_Update::isProcessed(const int theModificationID) +{ + return theModificationID >= myModificationInStartProcessing && + theModificationID <= myModification; +} + void Model_Update::updateFeature(FeaturePtr theFeature) { // check all features this feature depended on (recursive call of updateFeature) @@ -303,7 +297,7 @@ void Model_Update::updateFeature(FeaturePtr theFeature) // If automatice update is not needed and feature attributes were not updated right now, // do not execute it and do not update arguments. if (!myIsAutomatic && - (myUpdated.find(theFeature) == myUpdated.end() || myUpdated[theFeature] != myModification) + (myUpdated.find(theFeature) == myUpdated.end() || !isProcessed(myUpdated[theFeature])) && !aCompos.get()) { // execute will be performed later, but some features may have not-result // presentations, so call update for them (like coincidence in the sketcher) @@ -338,7 +332,7 @@ void Model_Update::updateFeature(FeaturePtr theFeature) if (aJustUpdated) { // if preview is not needed, the created feature was not updated before, so, myModification is not actual for this if (theFeature->isPreviewNeeded()) { - aJustUpdated = myUpdated[theFeature] == myModification; + aJustUpdated = isProcessed(myUpdated[theFeature]); } } diff --git a/src/Model/Model_Update.h b/src/Model/Model_Update.h index 3b543c1f5..2e44ea321 100644 --- a/src/Model/Model_Update.h +++ b/src/Model/Model_Update.h @@ -30,6 +30,8 @@ class Model_Update : public Events_Listener std::map, int > myUpdated; /// current id of modification inside of the current transaction int myModification; + /// id of modification inside of the current transaction on start of processing + int myModificationInStartProcessing; /// features that must be additionally processed after execution of finish operation std::set > myWaitForFinish; /// to know that all next updates are caused by this execution @@ -127,6 +129,8 @@ protected: std::shared_ptr theArgument); /// Updates the properties of object because of stability state changes void updateStability(void* theSender); + /// Returns true if the feature is the given modification ID is processed in the current processOperation + bool isProcessed(const int theModificationID); }; #endif diff --git a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp index f55e46ceb..a870ff02b 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp @@ -216,7 +216,9 @@ void SketchPlugin_ConstraintFillet::execute() aNewFeatureB->attribute(aFeatAttributes[2 + (isStart[1] ? 0 : 1)]))->setValue( aTangentPntB->x(), aTangentPntB->y()); aNewFeatureB->execute(); - // update fillet arc + // update fillet arc: make the arc correct for sure, so, it is not needed to process the "attribute updated" + // by arc; moreover, it may cause cyclicity in hte mechanism of updater + aNewArc->data()->blockSendAttributeUpdated(true); std::dynamic_pointer_cast( aNewArc->attribute(SketchPlugin_Arc::CENTER_ID()))->setValue( aCenter->x(), aCenter->y()); @@ -229,6 +231,7 @@ void SketchPlugin_ConstraintFillet::execute() aNewArc->attribute(SketchPlugin_Arc::START_ID()))->setValue(aTangentPntA->x(), aTangentPntA->y()); std::dynamic_pointer_cast( aNewArc->attribute(SketchPlugin_Arc::END_ID()))->setValue(aTangentPntB->x(), aTangentPntB->y()); + aNewArc->data()->blockSendAttributeUpdated(false); aNewArc->execute(); if (needNewObjects) { -- 2.39.2