X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSetPlugin%2FPartSetPlugin_Duplicate.cpp;h=f92c0e912a895a79b195896df95811709a704f39;hb=9e869ede4d8c56262bb20534543c2bf56cd6a91b;hp=3526f9db125b0f78fc45fd7dc6847071fdb76b9b;hpb=329d73a7dbce38e38063ff41186be492e3529ab5;p=modules%2Fshaper.git diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index 3526f9db1..f92c0e912 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@ -7,6 +7,8 @@ #include #include #include +#include +#include using namespace std; @@ -17,24 +19,28 @@ PartSetPlugin_Duplicate::PartSetPlugin_Duplicate() void PartSetPlugin_Duplicate::initAttributes() { PartSetPlugin_Part::initAttributes(); - data()->addAttribute(PART_DUPLICATE_ATTR_REF, ModelAPI_AttributeRefAttr::type()); + data()->addAttribute(ORIGIN_REF(), ModelAPI_AttributeRefAttr::type()); - boost::shared_ptr aRef = data()->refattr(PART_DUPLICATE_ATTR_REF); - if (!aRef->attr()) { // create a copy: if not created yet attribute is not initialized - 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(ModelAPI_Feature::group(), a)); - if (aSource->data()->docRef(PART_ATTR_DOC_REF)->value() == aPManager->currentDocument()) - break; - aSource.reset(); - } - if (aSource) { - boost::shared_ptr aCopy = - aPManager->copy(aSource->data()->docRef(PART_ATTR_DOC_REF)->value(), data()->name()); - aRef->setObject(aSource); - } + 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) { + std::shared_ptr aCopy = aPManager->copy( + aSource->data()->document(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(); }