1 // Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
3 // File: FeaturesAPI_Scale.cpp
4 // Created: 24 Jan 2017
5 // Author: Clarisse Genrault (CEA)
7 #include "FeaturesAPI_Scale.h"
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
12 //==================================================================================================
13 FeaturesAPI_Scale::FeaturesAPI_Scale(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
19 //==================================================================================================
20 FeaturesAPI_Scale::FeaturesAPI_Scale(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21 const std::list<ModelHighAPI_Selection>& theMainObjects,
22 const ModelHighAPI_Selection& theCenterPoint,
23 const ModelHighAPI_Double& theScaleFactor)
24 : ModelHighAPI_Interface(theFeature)
27 fillAttribute(theMainObjects, mainObjects());
28 fillAttribute(theCenterPoint, centerPoint());
29 setScaleFactor(theScaleFactor);
33 //==================================================================================================
34 FeaturesAPI_Scale::~FeaturesAPI_Scale()
38 //==================================================================================================
39 void FeaturesAPI_Scale::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
41 fillAttribute(theMainObjects, mainObjects());
45 //==================================================================================================
46 void FeaturesAPI_Scale::setCenterPoint(const ModelHighAPI_Selection& theCenterPoint)
48 fillAttribute(theCenterPoint, centerPoint());
52 //==================================================================================================
53 void FeaturesAPI_Scale::setScaleFactor(const ModelHighAPI_Double& theScaleFactor)
55 fillAttribute(theScaleFactor, scaleFactor());
59 //==================================================================================================
60 void FeaturesAPI_Scale::dump(ModelHighAPI_Dumper& theDumper) const
62 FeaturePtr aBase = feature();
63 const std::string& aDocName = theDumper.name(aBase->document());
65 AttributeSelectionListPtr anAttrObjects =
66 aBase->selectionList(FeaturesPlugin_Scale::OBJECTS_LIST_ID());
67 theDumper << aBase << " = model.addScale(" << aDocName << ", " << anAttrObjects;
69 AttributeSelectionPtr anAttrPoint =
70 aBase->selection(FeaturesPlugin_Scale::CENTER_POINT_ID());
71 theDumper << " , " << anAttrPoint;
73 AttributeDoublePtr anAttrScaleFactor =
74 aBase->real(FeaturesPlugin_Scale::SCALE_FACTOR_ID());
75 theDumper << ", " << anAttrScaleFactor;
77 theDumper << ")" << std::endl;
80 //==================================================================================================
81 ScalePtr addScale(const std::shared_ptr<ModelAPI_Document>& thePart,
82 const std::list<ModelHighAPI_Selection>& theMainObjects,
83 const ModelHighAPI_Selection& theCenterPoint,
84 const ModelHighAPI_Double& theScaleFactor)
86 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Scale::ID());
87 return ScalePtr(new FeaturesAPI_Scale(aFeature, theMainObjects, theCenterPoint, theScaleFactor));