1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "FeaturesAPI_RemoveSubShapes.h"
22 #include <ModelHighAPI_Dumper.h>
23 #include <ModelHighAPI_Tools.h>
25 //==================================================================================================
26 FeaturesAPI_RemoveSubShapes::FeaturesAPI_RemoveSubShapes(
27 const std::shared_ptr<ModelAPI_Feature>& theFeature)
28 : ModelHighAPI_Interface(theFeature)
33 //==================================================================================================
34 FeaturesAPI_RemoveSubShapes::FeaturesAPI_RemoveSubShapes(
35 const std::shared_ptr<ModelAPI_Feature>& theFeature,
36 const ModelHighAPI_Selection& theBase)
37 : ModelHighAPI_Interface(theFeature)
46 //==================================================================================================
47 FeaturesAPI_RemoveSubShapes::~FeaturesAPI_RemoveSubShapes()
52 //==================================================================================================
53 void FeaturesAPI_RemoveSubShapes::setBase(const ModelHighAPI_Selection& theBase)
55 fillAttribute(theBase, mybase);
60 //==================================================================================================
61 void FeaturesAPI_RemoveSubShapes::setSubShapesToKeep(
62 const std::list<ModelHighAPI_Selection>& theSubShapes)
64 fillAttribute(FeaturesPlugin_RemoveSubShapes::CREATION_METHOD_BY_KEEP_SUBSHAPES(),
66 fillAttribute(theSubShapes, mysubshapesToKeep);
71 //==================================================================================================
72 void FeaturesAPI_RemoveSubShapes::setSubShapesToRemove(
73 const std::list<ModelHighAPI_Selection>& theSubShapes)
75 fillAttribute(FeaturesPlugin_RemoveSubShapes::CREATION_METHOD_BY_REMOVE_SUBSHAPES(),
77 fillAttribute(theSubShapes, mysubshapesToRemove);
82 //==================================================================================================
83 void FeaturesAPI_RemoveSubShapes::dump(ModelHighAPI_Dumper& theDumper) const
85 FeaturePtr aBase = feature();
86 const std::string& aDocName = theDumper.name(aBase->document());
88 AttributeSelectionPtr anAttrBaseShape =
89 aBase->selection(FeaturesPlugin_RemoveSubShapes::BASE_SHAPE_ID());
91 std::string aCreationMethod =
92 aBase->string(FeaturesPlugin_RemoveSubShapes::CREATION_METHOD())->value();
94 AttributeSelectionListPtr anAttrSubShapes;
97 aCreationMethod == FeaturesPlugin_RemoveSubShapes::CREATION_METHOD_BY_KEEP_SUBSHAPES();
100 aBase->selectionList(FeaturesPlugin_RemoveSubShapes::SUBSHAPES_TO_KEEP_ID());
104 aBase->selectionList(FeaturesPlugin_RemoveSubShapes::SUBSHAPES_TO_REMOVE_ID());
107 theDumper << aBase << " = model.addRemoveSubShapes("
108 << aDocName << ", " << anAttrBaseShape << ")"
110 << theDumper.name(aBase)
111 << (isKeepSubs ? ".setSubShapesToKeep(" : ".setSubShapesToRemove(")
112 << anAttrSubShapes << ")" << std::endl;
115 //==================================================================================================
116 RemoveSubShapesPtr addRemoveSubShapes(const std::shared_ptr<ModelAPI_Document>& thePart,
117 const ModelHighAPI_Selection& theBase)
119 std::shared_ptr<ModelAPI_Feature> aFeature =
120 thePart->addFeature(FeaturesAPI_RemoveSubShapes::ID());
121 return RemoveSubShapesPtr(new FeaturesAPI_RemoveSubShapes(aFeature, theBase));