X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSetPlugin%2FPartSetPlugin_Duplicate.cpp;h=2cfcc177b46bfa480d9b2401a4746c93478c80ed;hb=a94fc319f2aa64b43c9a73b5ff7063923648faec;hp=f92c0e912a895a79b195896df95811709a704f39;hpb=35a88fdd724349275bbff32b9596a44e7cd422e2;p=modules%2Fshaper.git diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index f92c0e912..2cfcc177b 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@ -1,8 +1,25 @@ -// File: PartSetPlugin_Duplicate.cxx -// Created: 20 May 2014 -// Author: Mikhail PONIKAROV +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// #include "PartSetPlugin_Duplicate.h" +#include "PartSetPlugin_Part.h" #include #include #include @@ -10,17 +27,8 @@ #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()); - std::shared_ptr aPManager = ModelAPI_Session::get(); std::shared_ptr aRoot = aPManager->moduleDocument(); std::shared_ptr aSource; // searching for source document attribute @@ -33,14 +41,12 @@ void PartSetPlugin_Duplicate::initAttributes() aSource.reset(); } if (aSource) { + // 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(), data()->name()); - data()->refattr(ORIGIN_REF())->setObject(aSource); + aSource->data()->document(ModelAPI_ResultPart::DOC_REF())->value(), + std::dynamic_pointer_cast(aNewPart->firstResult())->partDoc()->id()); } } - -void PartSetPlugin_Duplicate::execute() -{ - if (data()->refattr(ORIGIN_REF())->object()) - PartSetPlugin_Part::execute(); -}