]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Fix for the issue #1605 : optimization of undo/redo and abort processing
authormpv <mpv@opencascade.com>
Tue, 16 Aug 2016 14:45:45 +0000 (17:45 +0300)
committermpv <mpv@opencascade.com>
Tue, 16 Aug 2016 14:45:45 +0000 (17:45 +0300)
src/Model/Model_Document.cpp
src/Model/Model_Update.cpp

index ebc4de9d8871ea39ed8d1e4d6e4a0bf84057ee93..c392492fcebbe13ff8c2da96774ffa9a817d452a 100755 (executable)
@@ -16,7 +16,6 @@
 #include <ModelAPI_AttributeSelectionList.h>
 #include <ModelAPI_Tools.h>
 #include <ModelAPI_ResultBody.h>
-
 #include <Events_Loop.h>
 #include <Events_InfoMessage.h>
 
 #include <TDF_ChildIDIterator.hxx>
 #include <TDF_LabelMapHasher.hxx>
 #include <TDF_Delta.hxx>
-#include <OSD_File.hxx>
-#include <OSD_Path.hxx>
 #include <TDF_AttributeDelta.hxx>
 #include <TDF_AttributeDeltaList.hxx>
 #include <TDF_ListIteratorOfAttributeDeltaList.hxx>
 #include <TDF_ListIteratorOfLabelList.hxx>
-#include <TopoDS_Shape.hxx>
+#include <TDF_LabelMap.hxx>
 #include <TNaming_SameShapeIterator.hxx>
 #include <TNaming_Iterator.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TNaming_Tool.hxx>
+
 #include <TopExp_Explorer.hxx>
+#include <TopoDS_Shape.hxx>
+
+#include <OSD_File.hxx>
+#include <OSD_Path.hxx>
 
 #include <climits>
 #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;
index 1f6c8319f6e7950e42d4505e79a2bafee60ca786..c081fbd7079b1dd1691ccb4a116d7452dad0d93e 100755 (executable)
@@ -185,6 +185,7 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& 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 "<<theMessage->eventID().eventText()<<std::endl;
@@ -212,8 +213,13 @@ void Model_Update::processEvent(const std::shared_ptr<Events_Message>& theMessag
     const std::set<ObjectPtr>& anObjs = aMsg->objects();
     std::set<ObjectPtr>::const_iterator anObjIter = anObjs.cbegin();
     for(; anObjIter != anObjs.cend(); anObjIter++) {
-      if (std::dynamic_pointer_cast<Model_Document>((*anObjIter)->document())->executeFeatures())
-        ModelAPI_EventCreator::get()->sendUpdated(*anObjIter, kUpdatedEvent);
+      if (std::dynamic_pointer_cast<Model_Document>((*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<Events_Message>& 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;