From: mpv Date: Tue, 15 Jul 2014 14:54:43 +0000 (+0400) Subject: Make results stable: new objects are created for new features or serious changes... X-Git-Tag: V_0.4.4~183^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3b7daf293873e4ad639f24f994ffdc9f35236bd7;p=modules%2Fshaper.git Make results stable: new objects are created for new features or serious changes of results (changed type, number, etc) --- 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; }