X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSetPlugin%2FPartSetPlugin_Duplicate.cpp;h=971d6913023e1cba36f00bd17626eaf9d5481d2b;hb=fdd802da7683f66ca609cf12b1e11be9642149d6;hp=462a7366bdab45a2b9ebef798aa12ccf0bc41bdf;hpb=5297856d2148995c4dcb0561f895a6a22db7086b;p=modules%2Fshaper.git diff --git a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp index 462a7366b..971d69130 100644 --- a/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp +++ b/src/PartSetPlugin/PartSetPlugin_Duplicate.cpp @@ -1,10 +1,24 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PartSetPlugin_Duplicate.cxx -// Created: 20 May 2014 -// Author: Mikhail PONIKAROV +// Copyright (C) 2014-2020 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 @@ -12,16 +26,8 @@ #include #include -using namespace std; - -PartSetPlugin_Duplicate::PartSetPlugin_Duplicate() -{ -} - -void PartSetPlugin_Duplicate::initAttributes() +void PartSetPlugin_Duplicate::execute() { - PartSetPlugin_Part::initAttributes(); - std::shared_ptr aPManager = ModelAPI_Session::get(); std::shared_ptr aRoot = aPManager->moduleDocument(); std::shared_ptr aSource; // searching for source document attribute @@ -34,21 +40,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()); - } else { // invalid part copy: do nothing, keep this in empty name - data()->setName(""); + aSource->data()->document(ModelAPI_ResultPart::DOC_REF())->value(), + std::dynamic_pointer_cast(aNewPart->firstResult())->partDoc()->id()); } } - -void PartSetPlugin_Duplicate::execute() -{ - 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(); -}