From 93734cc9fd26b29a340e45e78f34331b5bc87923 Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 17 Aug 2016 10:12:37 +0300 Subject: [PATCH] Issue #1648 : make unit tests for sketch more stable (null sub-features and order in sketch are not important, on abort/undo/redo reset the attributes state to restore "initialization" flag correctly) --- src/Model/Model_Objects.cpp | 5 +++++ src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp | 17 ++++++++++++----- .../SketchPlugin_ConstraintFillet.cpp | 1 - .../SketchPlugin_ConstraintSplit.cpp | 6 ------ src/SketchPlugin/SketchPlugin_Feature.cpp | 1 - 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/Model/Model_Objects.cpp b/src/Model/Model_Objects.cpp index 9484a1f4a..f1edf57aa 100644 --- a/src/Model/Model_Objects.cpp +++ b/src/Model/Model_Objects.cpp @@ -663,6 +663,11 @@ void Model_Objects::synchronizeFeatures( aFeature = myFeatures.Find(aFeatureLabel); aKeptFeatures.insert(aFeature); if (anUpdatedMap.Contains(aFeatureLabel)) { + if (!theOpen) { // on abort/undo/redo reinitialize attributes is something is changed + std::shared_ptr aD = std::dynamic_pointer_cast(aFeature->data()); + aD->myAttrs.clear(); + aFeature->initAttributes(); + } ModelAPI_EventCreator::get()->sendUpdated(aFeature, anUpdateEvent); if (aFeature->getKind() == "Parameter") { // if parameters are changed, update the results (issue 937) const std::list >& aResults = aFeature->results(); diff --git a/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp b/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp index 917af05ba..f45f90017 100644 --- a/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp +++ b/src/ModelHighAPI/ModelHighAPI_FeatureStore.cpp @@ -187,16 +187,23 @@ std::string ModelHighAPI_FeatureStore::dumpAttr(const AttributePtr& theAttr) { } else if (aType == ModelAPI_AttributeRefList::typeId()) { AttributeRefListPtr anAttr = std::dynamic_pointer_cast(theAttr); + // for sketch sub-features the empty values may be skipped and order is not important + bool isSketchFeatures = anAttr->id() == "Features" && + std::dynamic_pointer_cast(anAttr->owner())->getKind() == "Sketch"; std::list aList = anAttr->list(); + std::list aResList; // list of resulting strings for(std::list::iterator aL = aList.begin(); aL != aList.end(); aL++) { - if (aL != aList.begin()) - aResult<<" "; if (aL->get()) { - aResult<<(*aL)->data()->name(); - } else { - aResult<<"__empty__"; + aResList.push_back((*aL)->data()->name()); + } else if (!isSketchFeatures) { + aResList.push_back("__empty__"); } } + if (isSketchFeatures) + aResList.sort(); + for(std::list::iterator aR = aResList.begin(); aR != aResList.end(); aR++) { + aResult<<*aR<<" "; + } } else if (aType == ModelAPI_AttributeRefAttrList::typeId()) { AttributeRefAttrListPtr anAttr = std::dynamic_pointer_cast(theAttr); diff --git a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp index 530895f30..0481c4a14 100644 --- a/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintFillet.cpp @@ -13,7 +13,6 @@ #include #include #include -#include #include #include #include diff --git a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp index 4e6cdfd62..e53185f41 100755 --- a/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp +++ b/src/SketchPlugin/SketchPlugin_ConstraintSplit.cpp @@ -6,16 +6,10 @@ #include "SketchPlugin_ConstraintSplit.h" -//#include -//#include -//#include #include -//#include #include -//#include #include #include -//#include #include #include diff --git a/src/SketchPlugin/SketchPlugin_Feature.cpp b/src/SketchPlugin/SketchPlugin_Feature.cpp index 5842df8a0..436cc5e7b 100644 --- a/src/SketchPlugin/SketchPlugin_Feature.cpp +++ b/src/SketchPlugin/SketchPlugin_Feature.cpp @@ -5,7 +5,6 @@ #include #include #include -#include #include /// It is important. -- 2.39.2