X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSetPlugin%2FPartSetPlugin_Duplicate.cpp;h=7b3e303d7e9738a94e5d6a467ca71dac4933c272;hb=5c7800057bef826f4dfcd151a05b18ca5c69a08a;hp=b02ae41f83810e9400f5293793bdf5d91be21861;hpb=0c10db12692c21f2ce38b9eebd27981a8eee6b41;p=modules%2Fshaper.git diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index b02ae41f8..7b3e303d7 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@ -1,39 +1,40 @@ +// 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_PluginManager::get(); - boost::shared_ptr aRoot = aPManager->rootDocument(); - boost::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)); - if (aSource && aSource->data() && - aSource->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value() == - aPManager->currentDocument()) + 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 = std::dynamic_pointer_cast(aRoot->object(getGroup(), a)); + if (aSource && aSource->data() + && aSource->data()->document(ModelAPI_ResultPart::DOC_REF())->value() + == aPManager->activeDocument()) break; aSource.reset(); } if (aSource) { - boost::shared_ptr aCopy = aPManager->copy( - aSource->data()->docRef(ModelAPI_ResultPart::DOC_REF())->value(), - data()->name()); + // 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(), + std::dynamic_pointer_cast(aNewPart->firstResult())->partDoc()->id()); } }