X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSetPlugin%2FPartSetPlugin_Duplicate.cpp;h=4e900e8c492c2b50fb599f441793ac33ac1a1569;hb=21a0c85b52bb93f94680e2342370764e6510e387;hp=a2f006fa42880133ca20e36835d2a5f534517cf3;hpb=502bedefb19a894ef71c5117ee658fd76042a5e9;p=modules%2Fshaper.git diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index a2f006fa4..4e900e8c4 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@ -1,30 +1,25 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: PartSetPlugin_Duplicate.cxx // Created: 20 May 2014 // Author: Mikhail PONIKAROV #include "PartSetPlugin_Duplicate.h" +#include "PartSetPlugin_Part.h" #include #include #include #include #include +#include -using namespace std; - -PartSetPlugin_Duplicate::PartSetPlugin_Duplicate() -{ -} - -void PartSetPlugin_Duplicate::initAttributes() +void PartSetPlugin_Duplicate::execute() { - PartSetPlugin_Part::initAttributes(); - data()->addAttribute(ORIGIN_REF(), ModelAPI_AttributeRefAttr::type()); - - boost::shared_ptr aPManager = ModelAPI_Session::get(); - boost::shared_ptr aRoot = aPManager->moduleDocument(); - boost::shared_ptr aSource; // searching for source document attribute + std::shared_ptr aPManager = ModelAPI_Session::get(); + std::shared_ptr aRoot = aPManager->moduleDocument(); + std::shared_ptr aSource; // searching for source document attribute for (int a = aRoot->size(getGroup()) - 1; a >= 0; a--) { - aSource = boost::dynamic_pointer_cast(aRoot->object(getGroup(), a)); + aSource = std::dynamic_pointer_cast(aRoot->object(getGroup(), a)); if (aSource && aSource->data() && aSource->data()->document(ModelAPI_ResultPart::DOC_REF())->value() == aPManager->activeDocument()) @@ -32,14 +27,12 @@ void PartSetPlugin_Duplicate::initAttributes() aSource.reset(); } if (aSource) { - boost::shared_ptr aCopy = aPManager->copy( - aSource->data()->document(ModelAPI_ResultPart::DOC_REF())->value(), data()->name()); - data()->refattr(ORIGIN_REF())->setObject(aSource); - } -} + // create a new Part feature + FeaturePtr aNewPart = aRoot->addFeature(PartSetPlugin_Part::ID(), false); + aNewPart->execute(); // to make result and generate a unique name -void PartSetPlugin_Duplicate::execute() -{ - if (data()->refattr(ORIGIN_REF())->object()) - PartSetPlugin_Part::execute(); + std::shared_ptr aCopy = aPManager->copy( + aSource->data()->document(ModelAPI_ResultPart::DOC_REF())->value(), + std::dynamic_pointer_cast(aNewPart->firstResult())->partDoc()->id()); + } }