From 3b7daf293873e4ad639f24f994ffdc9f35236bd7 Mon Sep 17 00:00:00 2001 From: mpv Date: Tue, 15 Jul 2014 18:54:43 +0400 Subject: [PATCH] Make results stable: new objects are created for new features or serious changes of results (changed type, number, etc) --- .../ConstructionPlugin_Point.cpp | 4 ++- src/Model/Model_Document.cpp | 36 +++++++++++++++---- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp index 1838d32d9..5a879d49d 100644 --- a/src/ConstructionPlugin/ConstructionPlugin_Point.cpp +++ b/src/ConstructionPlugin/ConstructionPlugin_Point.cpp @@ -27,7 +27,9 @@ void ConstructionPlugin_Point::initAttributes() void ConstructionPlugin_Point::execute() { boost::shared_ptr aPnt(new GeomAPI_Pnt( - data()->real(POINT_ATTR_X)->value(), data()->real(POINT_ATTR_Y)->value(), data()->real(POINT_ATTR_Z)->value())); + data()->real(POINT_ATTR_X)->value(), + data()->real(POINT_ATTR_Y)->value(), + data()->real(POINT_ATTR_Z)->value())); boost::shared_ptr aConstr = document()->createConstruction(data()); aConstr->setShape(GeomAlgoAPI_PointBuilder::point(aPnt)); diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 210195844..bd5abc228 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -750,24 +750,48 @@ void Model_Document::storeResult(boost::shared_ptr theFeatureData boost::shared_ptr Model_Document::createConstruction( const boost::shared_ptr& theFeatureData, const int theIndex) { - boost::shared_ptr aResult(new Model_ResultConstruction()); - storeResult(theFeatureData, aResult); + ObjectPtr anOldObject = object(boost::dynamic_pointer_cast(theFeatureData)-> + label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theIndex + 1)); + boost::shared_ptr aResult; + if (anOldObject) { + aResult = boost::dynamic_pointer_cast(anOldObject); + } + if (!aResult) { + aResult = boost::shared_ptr(new Model_ResultConstruction); + storeResult(theFeatureData, aResult); + } return aResult; } boost::shared_ptr Model_Document::createBody( const boost::shared_ptr& theFeatureData, const int theIndex) { - boost::shared_ptr aResult(new Model_ResultBody()); - storeResult(theFeatureData, aResult); + ObjectPtr anOldObject = object(boost::dynamic_pointer_cast(theFeatureData)-> + label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theIndex + 1)); + boost::shared_ptr aResult; + if (anOldObject) { + aResult = boost::dynamic_pointer_cast(anOldObject); + } + if (!aResult) { + aResult = boost::shared_ptr(new Model_ResultBody); + storeResult(theFeatureData, aResult); + } return aResult; } boost::shared_ptr Model_Document::createPart( const boost::shared_ptr& theFeatureData, const int theIndex) { - boost::shared_ptr aResult(new Model_ResultPart()); - storeResult(theFeatureData, aResult); + ObjectPtr anOldObject = object(boost::dynamic_pointer_cast(theFeatureData)-> + label().Father().FindChild(TAG_FEATURE_RESULTS).FindChild(theIndex + 1)); + boost::shared_ptr aResult; + if (anOldObject) { + aResult = boost::dynamic_pointer_cast(anOldObject); + } + if (!aResult) { + aResult = boost::shared_ptr(new Model_ResultPart); + storeResult(theFeatureData, aResult); + } return aResult; } -- 2.39.2