1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "FeaturesAPI_Placement.h"
23 #include <ModelHighAPI_Dumper.h>
24 #include <ModelHighAPI_Tools.h>
26 //==================================================================================================
27 FeaturesAPI_Placement::FeaturesAPI_Placement(const std::shared_ptr<ModelAPI_Feature>& theFeature)
28 : ModelHighAPI_Interface(theFeature)
33 //==================================================================================================
34 FeaturesAPI_Placement::FeaturesAPI_Placement(const std::shared_ptr<ModelAPI_Feature>& theFeature,
35 const std::list<ModelHighAPI_Selection>& theObjects,
36 const ModelHighAPI_Selection& theStartShape,
37 const ModelHighAPI_Selection& theEndShape,
38 const bool theReverseDirection,
39 const bool theCentering)
40 : ModelHighAPI_Interface(theFeature)
43 fillAttribute(theObjects, myobjects);
44 fillAttribute(theStartShape, mystartShape);
45 fillAttribute(theEndShape, myendShape);
46 fillAttribute(theReverseDirection, myreverseDirection);
47 setCentering(theCentering);
51 //==================================================================================================
52 FeaturesAPI_Placement::~FeaturesAPI_Placement()
57 //==================================================================================================
58 void FeaturesAPI_Placement::setObjects(const std::list<ModelHighAPI_Selection>& theObjects)
60 fillAttribute(theObjects, myobjects);
65 //==================================================================================================
66 void FeaturesAPI_Placement::setStartShape(const ModelHighAPI_Selection& theStartShape)
68 fillAttribute(theStartShape, mystartShape);
73 //==================================================================================================
74 void FeaturesAPI_Placement::setEndShape(const ModelHighAPI_Selection& theEndShape)
76 fillAttribute(theEndShape, myendShape);
81 //==================================================================================================
82 void FeaturesAPI_Placement::setReverseDirection(const bool theReverseDirection)
84 fillAttribute(theReverseDirection, myreverseDirection);
89 //==================================================================================================
90 void FeaturesAPI_Placement::setCentering(const bool theCentering)
92 fillAttribute(theCentering, mycentering);
97 //==================================================================================================
98 void FeaturesAPI_Placement::dump(ModelHighAPI_Dumper& theDumper) const
100 FeaturePtr aBase = feature();
101 const std::string& aDocName = theDumper.name(aBase->document());
103 AttributeSelectionListPtr anAttrObjects =
104 aBase->selectionList(FeaturesPlugin_Placement::OBJECTS_LIST_ID());
105 AttributeSelectionPtr anAttrStartShape =
106 aBase->selection(FeaturesPlugin_Placement::START_SHAPE_ID());
107 AttributeSelectionPtr anAttrEndShape = aBase->selection(FeaturesPlugin_Placement::END_SHAPE_ID());
108 AttributeBooleanPtr anAttrReverse = aBase->boolean(FeaturesPlugin_Placement::REVERSE_ID());
109 AttributeBooleanPtr anAttrCentering = aBase->boolean(FeaturesPlugin_Placement::CENTERING_ID());
111 theDumper << aBase << " = model.addPlacement(" << aDocName << ", "
112 << anAttrObjects << ", " << anAttrStartShape << ", " << anAttrEndShape << ", "
113 << anAttrReverse << ", " << anAttrCentering << ")" << std::endl;
116 //==================================================================================================
117 PlacementPtr addPlacement(const std::shared_ptr<ModelAPI_Document>& thePart,
118 const std::list<ModelHighAPI_Selection>& theObjects,
119 const ModelHighAPI_Selection& theStartShape,
120 const ModelHighAPI_Selection& theEndShape,
121 const bool theReverseDirection,
122 const bool theCentering)
124 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Placement::ID());
125 return PlacementPtr(new FeaturesAPI_Placement(aFeature,