From: mpv Date: Tue, 16 Aug 2016 14:45:45 +0000 (+0300) Subject: Fix for the issue #1605 : optimization of undo/redo and abort processing X-Git-Tag: V_2.5.0~137^2~35 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=471cc7b52168016a3b6fff7e64cdd800cd7d8f91;p=modules%2Fshaper.git Fix for the issue #1605 : optimization of undo/redo and abort processing --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index ebc4de9d8..c392492fc 100755 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -16,7 +16,6 @@ #include #include #include - #include #include @@ -33,18 +32,21 @@ #include #include #include -#include -#include #include #include #include #include -#include +#include #include #include #include #include + #include +#include + +#include +#include #include #ifndef WIN32 @@ -366,7 +368,7 @@ void Model_Document::compactNested() } } -/// Compares the content ofthe given attributes, returns true if equal. +/// Compares the content of the given attributes, returns true if equal. /// This method is used to avoid empty transactions when only "current" is changed /// to some value and then comes back in this transaction, so, it compares only /// references and Boolean and Integer Arrays for the current moment. @@ -575,8 +577,28 @@ static void modifiedLabels(const Handle(TDocStd_Document)& theDoc, TDF_LabelList } // add also label of the modified attributes const TDF_AttributeDeltaList& anAttrs = aDelta->AttributeDeltas(); + TDF_LabelMap anExcludedInt; /// named shape evolution also modifies integer on this label: exclude it for (TDF_ListIteratorOfAttributeDeltaList anAttr(anAttrs); anAttr.More(); anAttr.Next()) { - theDelta.Append(anAttr.Value()->Label()); + if (anAttr.Value()->Attribute()->ID() == TDataStd_BooleanArray::GetID()) { + continue; // Boolean array is used for feature auxiliary attributes only, feature args are not modified + } + if (anAttr.Value()->Attribute()->ID() == TNaming_NamedShape::GetID()) { + anExcludedInt.Add(anAttr.Value()->Label()); + continue; // named shape evolution is changed in history update => skip them, they are not the features arguents + } + if (anAttr.Value()->Attribute()->ID() == TDataStd_Integer::GetID()) { + if (anExcludedInt.Contains(anAttr.Value()->Label())) + continue; + } + theDelta.Append(anAttr.Value()->Label()); + } + TDF_ListIteratorOfLabelList aDeltaIter(theDelta); + for(; aDeltaIter.More(); aDeltaIter.Next()) { + if (anExcludedInt.Contains(aDeltaIter.Value())) { + theDelta.Remove(aDeltaIter); + if (!aDeltaIter.More()) + break; + } } } @@ -1025,9 +1047,10 @@ void Model_Document::setCurrentFeature( } if (anIter->setDisabled(aDisabledFlag)) { - // state of feature is changed => so feature become updated static Events_ID anUpdateEvent = aLoop->eventByName(EVENT_OBJECT_UPDATED); - ModelAPI_EventCreator::get()->sendUpdated(anIter, anUpdateEvent); + // state of feature is changed => so inform that it must be updated if it has such state + if (!aDisabledFlag && anIter->data()->execState() == ModelAPI_StateMustBeUpdated) + ModelAPI_EventCreator::get()->sendUpdated(anIter, anUpdateEvent); // flush is in the end of this method ModelAPI_EventCreator::get()->sendUpdated(anIter, aRedispEvent /*, false*/); aWasChanged = true; diff --git a/src/Model/Model_Update.cpp b/src/Model/Model_Update.cpp index 1f6c8319f..c081fbd70 100755 --- a/src/Model/Model_Update.cpp +++ b/src/Model/Model_Update.cpp @@ -185,6 +185,7 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag static const Events_ID kPreviewBlockedEvent = aLoop->eventByName(EVENT_PREVIEW_BLOCKED); static const Events_ID kPreviewRequestedEvent = aLoop->eventByName(EVENT_PREVIEW_REQUESTED); static const Events_ID kReorderEvent = aLoop->eventByName(EVENT_ORDER_UPDATED); + static const Events_ID kRedisplayEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY); #ifdef DEB_UPDATE std::cout<<"****** Event "<eventID().eventText()<& theMessag const std::set& anObjs = aMsg->objects(); std::set::const_iterator anObjIter = anObjs.cbegin(); for(; anObjIter != anObjs.cend(); anObjIter++) { - if (std::dynamic_pointer_cast((*anObjIter)->document())->executeFeatures()) - ModelAPI_EventCreator::get()->sendUpdated(*anObjIter, kUpdatedEvent); + if (std::dynamic_pointer_cast((*anObjIter)->document())->executeFeatures()) { + if ((*anObjIter)->groupName() == ModelAPI_Feature::group()) { // results creation means enabling, not update + ModelAPI_EventCreator::get()->sendUpdated(*anObjIter, kUpdatedEvent); + } else { + ModelAPI_EventCreator::get()->sendUpdated(*anObjIter, kRedisplayEvent); + } + } } return; } @@ -296,7 +302,7 @@ void Model_Update::processEvent(const std::shared_ptr& theMessag // the redisplay signal should be flushed in order to erase the feature presentation in the viewer // if should be done after removeFeature() of document, // by this reason, upper processFeatures() do not perform this flush - Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)); + Events_Loop::loop()->flush(kRedisplayEvent); // in the end of transaction everything is updated, so clear the old objects myIsParamUpdated = false;