X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSetPlugin%2FPartSetPlugin_Duplicate.cpp;h=7b3e303d7e9738a94e5d6a467ca71dac4933c272;hb=5c7800057bef826f4dfcd151a05b18ca5c69a08a;hp=8c6e8cc0ae117285373734155090805ffa58069d;hpb=23bd046563358cc8654b0d084fb0f7135acc31f7;p=modules%2Fshaper.git diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index 8c6e8cc0a..7b3e303d7 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@ -1,8 +1,11 @@ +// 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 @@ -12,20 +15,13 @@ 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()) @@ -33,14 +29,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()); + } }