From: mpv Date: Thu, 5 Nov 2015 12:37:31 +0000 (+0300) Subject: Empty transaction in the sketch sub-feature edit, even if there is empty sub-feature... X-Git-Tag: V_2.0.0_alfa1~6^2~4 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=91461ddbd32a0edd1705f2ccf77a62680c66389e;p=modules%2Fshaper.git Empty transaction in the sketch sub-feature edit, even if there is empty sub-feature created for the internal validator. --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index ecd12cf45..e3ff4e04c 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -23,9 +23,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -360,7 +362,7 @@ static bool isEqualContent(Handle(TDF_Attribute) theAttr1, Handle(TDF_Attribute) return false; if (anArr1->Lower() == anArr2->Lower() && anArr1->Upper() == anArr2->Upper()) { for(int a = anArr1->Lower(); a <= anArr1->Upper(); a++) - if (anArr1->Value(a) != anArr2->Value(a)) + if (a != 1 && anArr1->Value(a) != anArr2->Value(a)) // second is for display return false; return true; } @@ -382,6 +384,42 @@ static bool isEqualContent(Handle(TDF_Attribute) theAttr1, Handle(TDF_Attribute) } return true; } + } else if (Standard_GUID::IsEqual(theAttr1->ID(), TDataStd_ReferenceArray::GetID())) { + Handle(TDataStd_ReferenceArray) anArr1 = Handle(TDataStd_ReferenceArray)::DownCast(theAttr1); + Handle(TDataStd_ReferenceArray) anArr2 = Handle(TDataStd_ReferenceArray)::DownCast(theAttr2); + if (anArr1.IsNull() && anArr2.IsNull()) + return true; + if (anArr1.IsNull() || anArr2.IsNull()) + return false; + if (anArr1->Lower() == anArr2->Lower() && anArr1->Upper() == anArr2->Upper()) { + for(int a = anArr1->Lower(); a <= anArr1->Upper(); a++) + if (anArr1->Value(a) != anArr2->Value(a)) { + // avoid the transaction ID checking + if (a == 2 && anArr1->Upper() == 2 && anArr2->Label().Tag() == 1 && + (anArr2->Label().Depth() == 4 || anArr2->Label().Depth() == 6)) + continue; + return false; + } + return true; + } + } else if (Standard_GUID::IsEqual(theAttr1->ID(), TDataStd_ReferenceList::GetID())) { + Handle(TDataStd_ReferenceList) aList1 = Handle(TDataStd_ReferenceList)::DownCast(theAttr1); + Handle(TDataStd_ReferenceList) aList2= Handle(TDataStd_ReferenceList)::DownCast(theAttr2); + if (aList1.IsNull() && aList2.IsNull()) + return true; + if (aList1.IsNull() || aList2.IsNull()) + return false; + const TDF_LabelList& aLList1 = aList1->List(); + const TDF_LabelList& aLList2 = aList2->List(); + TDF_ListIteratorOfLabelList aLIter1(aLList1); + TDF_ListIteratorOfLabelList aLIter2(aLList2); + for(; aLIter1.More() && aLIter2.More(); aLIter1.Next(), aLIter2.Next()) { + if (aLIter1.Value() != aLIter2.Value()) + return false; + } + return !aLIter1.More() && !aLIter2.More(); // both lists are with the same size + } else if (Standard_GUID::IsEqual(theAttr1->ID(), TDF_TagSource::GetID())) { + return true; // it just for created and removed feature: nothing is changed } return false; } @@ -406,6 +444,8 @@ static bool isEmptyTransaction(const Handle(TDocStd_Document)& theDoc) { if (isEqualContent(anADelta->Attribute(), aCurrentAttr)) { continue; // attribute is not changed actually } + } else if (Standard_GUID::IsEqual(anADelta->Attribute()->ID(), TDataStd_AsciiString::GetID())) { + continue; // error message is disappeared } } return false; diff --git a/src/SketchPlugin/SketchPlugin_Sketch.cpp b/src/SketchPlugin/SketchPlugin_Sketch.cpp index 3f6c91b59..a63344e58 100644 --- a/src/SketchPlugin/SketchPlugin_Sketch.cpp +++ b/src/SketchPlugin/SketchPlugin_Sketch.cpp @@ -145,9 +145,15 @@ void SketchPlugin_Sketch::removeFeature(std::shared_ptr theFea { if (!data()->isValid()) // sketch is already removed (case on undo of sketch), sync is not needed return; - // to keep the persistent sub-elements indexing, do not remove elements from list, - // but substitute by nulls - reflist(SketchPlugin_Sketch::FEATURES_ID())->substitute(theFeature, ObjectPtr()); + AttributeRefListPtr aList = reflist(SketchPlugin_Sketch::FEATURES_ID()); + // if the object is last, remove it from the list (needed to skip empty transaction on edit of sketch feature) + if (aList->object(aList->size(true) - 1, true) == theFeature) { + aList->remove(theFeature); + } else { + // to keep the persistent sub-elements indexing, do not remove elements from list, + // but substitute by nulls + aList->substitute(theFeature, ObjectPtr()); + } } int SketchPlugin_Sketch::numberOfSubs(bool forTree) const