X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSetPlugin%2FPartSetPlugin_Duplicate.cpp;h=7b3e303d7e9738a94e5d6a467ca71dac4933c272;hb=5c7800057bef826f4dfcd151a05b18ca5c69a08a;hp=35134c64b7aa2a43603aebea9975e7d6bc8f2b5c;hpb=dc158ea248a9bbd70675887f494388c93e1b3b4d;p=modules%2Fshaper.git diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index 35134c64b..7b3e303d7 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@ -5,6 +5,7 @@ // Author: Mikhail PONIKAROV #include "PartSetPlugin_Duplicate.h" +#include "PartSetPlugin_Part.h" #include #include #include @@ -14,14 +15,8 @@ using namespace std; -PartSetPlugin_Duplicate::PartSetPlugin_Duplicate() -{ -} - -void PartSetPlugin_Duplicate::initAttributes() +void PartSetPlugin_Duplicate::execute() { - PartSetPlugin_Part::initAttributes(); - std::shared_ptr aPManager = ModelAPI_Session::get(); std::shared_ptr aRoot = aPManager->moduleDocument(); std::shared_ptr aSource; // searching for source document attribute @@ -34,15 +29,12 @@ void PartSetPlugin_Duplicate::initAttributes() aSource.reset(); } if (aSource) { + // create a new Part feature + FeaturePtr aNewPart = aRoot->addFeature(PartSetPlugin_Part::ID(), false); + aNewPart->execute(); // to make result and generate a unique name + std::shared_ptr aCopy = aPManager->copy( - aSource->data()->document(ModelAPI_ResultPart::DOC_REF())->value(), data()->name()); - } else { // invalid part copy: do nothing, keep this in empty name - data()->setName(""); + aSource->data()->document(ModelAPI_ResultPart::DOC_REF())->value(), + std::dynamic_pointer_cast(aNewPart->firstResult())->partDoc()->id()); } } - -void PartSetPlugin_Duplicate::execute() -{ - if (!data()->name().empty()) - PartSetPlugin_Part::execute(); -}