X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSetPlugin%2FPartSetPlugin_Duplicate.cpp;h=462a7366bdab45a2b9ebef798aa12ccf0bc41bdf;hb=7b4a6a2a335d41a647e0f6a6becb7c23df042be1;hp=b8919426b1f77c567129fdc3c7f980a6a4a11c2c;hpb=7b76b534d04e5d50f1ad319e58e0e22c6bb742a3;p=modules%2Fshaper.git diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index b8919426b..462a7366b 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: PartSetPlugin_Duplicate.cxx // Created: 20 May 2014 // Author: Mikhail PONIKAROV @@ -8,6 +10,7 @@ #include #include #include +#include using namespace std; @@ -18,28 +21,34 @@ PartSetPlugin_Duplicate::PartSetPlugin_Duplicate() void PartSetPlugin_Duplicate::initAttributes() { 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()->docRef(ModelAPI_ResultPart::DOC_REF())->value() + && 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()); - data()->refattr(ORIGIN_REF())->setObject(aSource); + 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(""); } } void PartSetPlugin_Duplicate::execute() { - if (data()->refattr(ORIGIN_REF())->object()) + if (!data()->name().empty()) PartSetPlugin_Part::execute(); } + +const std::string& PartSetPlugin_Duplicate::documentToAdd() +{ + // part must be added only to the module document + return ModelAPI_Session::get()->moduleDocument()->kind(); +}