From: mpv Date: Fri, 18 Jul 2014 07:08:34 +0000 (+0400) Subject: Duplication and removing of part X-Git-Tag: V_0.4.4~170 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5a4f0bcfb2d42d602051884072c9c8e539b60a2e;p=modules%2Fshaper.git Duplication and removing of part --- diff --git a/src/Model/Model_Document.cpp b/src/Model/Model_Document.cpp index 1d693b73c..30bd5e293 100644 --- a/src/Model/Model_Document.cpp +++ b/src/Model/Model_Document.cpp @@ -456,7 +456,7 @@ ObjectPtr Model_Document::object(TDF_Label theLabel) for(; aRIter != aResults.cend(); aRIter++) { boost::shared_ptr aResData = boost::dynamic_pointer_cast((*aRIter)->data()); - if (aResData->label().IsEqual(theLabel)) + if (aResData->label().Father().IsEqual(theLabel)) return *aRIter; } } @@ -735,7 +735,7 @@ boost::shared_ptr Model_Document::feature( { boost::shared_ptr aData = boost::dynamic_pointer_cast(theResult->data()); if (aData) { - TDF_Label aFeatureLab = aData->label().Father().Father(); + TDF_Label aFeatureLab = aData->label().Father().Father().Father(); return feature(aFeatureLab); } return FeaturePtr(); diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index b02ae41f8..28c8ce3de 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@ -35,5 +35,12 @@ void PartSetPlugin_Duplicate::initAttributes() boost::shared_ptr aCopy = aPManager->copy( aSource->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value(), data()->name()); + data()->refattr(ORIGIN_REF())->setObject(aSource); } } + +void PartSetPlugin_Duplicate::execute() +{ + if (data()->refattr(ORIGIN_REF())->object()) + PartSetPlugin_Part::execute(); +} diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.h b/src/PartSetPlugin/PartSetPlugin_Duplicate.h index cecac0505..57117a813 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.h +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.h @@ -25,6 +25,9 @@ public: /// Request for initialization of data model of the feature: adding all attributes PARTSETPLUGIN_EXPORT virtual void initAttributes(); + + /// doesn't call creation of new document, just does nothing if document was not copied + PARTSETPLUGIN_EXPORT virtual void execute(); }; #endif diff --git a/src/PartSetPlugin/PartSetPlugin_Remove.cpp b/src/PartSetPlugin/PartSetPlugin_Remove.cpp index da0dd7ee1..d7dbf434c 100644 --- a/src/PartSetPlugin/PartSetPlugin_Remove.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Remove.cpp @@ -15,18 +15,17 @@ void PartSetPlugin_Remove::execute() boost::shared_ptr aRoot = aPManager->rootDocument(); boost::shared_ptr aCurrent; boost::shared_ptr a; - for(int a = aRoot->size(ModelAPI_Feature::group()) - 1; a >= 0; a--) { - FeaturePtr aFeature = boost::dynamic_pointer_cast( - aRoot->object(ModelAPI_Feature::group(), a)); - if (aFeature->getKind() == PartSetPlugin_Part::ID()) { - boost::shared_ptr aPart = - boost::static_pointer_cast(aFeature); - if (aPart && aPart->firstResult() && - aPart->firstResult()->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value() == - aPManager->currentDocument()) { + for(int a = aRoot->size(ModelAPI_ResultPart::group()) - 1; a >= 0; a--) { + ResultPartPtr aPart = boost::dynamic_pointer_cast( + aRoot->object(ModelAPI_ResultPart::group(), a)); + if (aPart && aPart->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value() == + aPManager->currentDocument()) + { + FeaturePtr aFeature = aRoot->feature(aPart); + if (aFeature) { // do remove - aPart->firstResult()->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value()->close(); - aRoot->removeFeature(aPart); + aPart->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value()->close(); + aRoot->removeFeature(aFeature); } } }