1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesAPI_Translation.cpp
4 // Created: 07 June 2016
5 // Author: Dmitry Bobylev
7 #include "FeaturesAPI_Translation.h"
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
12 //==================================================================================================
13 FeaturesAPI_Translation::FeaturesAPI_Translation(
14 const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
20 //==================================================================================================
21 FeaturesAPI_Translation::FeaturesAPI_Translation(
22 const std::shared_ptr<ModelAPI_Feature>& theFeature,
23 const std::list<ModelHighAPI_Selection>& theMainObjects,
24 const ModelHighAPI_Selection& theAxisObject,
25 const ModelHighAPI_Double& theDistance)
26 : ModelHighAPI_Interface(theFeature)
29 fillAttribute(theMainObjects, mymainObjects);
30 fillAttribute(theAxisObject, myaxisObject);
31 setDistance(theDistance);
35 //==================================================================================================
36 FeaturesAPI_Translation::~FeaturesAPI_Translation()
41 //==================================================================================================
42 void FeaturesAPI_Translation::setMainObjects(
43 const std::list<ModelHighAPI_Selection>& theMainObjects)
45 fillAttribute(theMainObjects, mymainObjects);
50 //==================================================================================================
51 void FeaturesAPI_Translation::setAxisObject(const ModelHighAPI_Selection& theAxisObject)
53 fillAttribute(theAxisObject, myaxisObject);
58 //==================================================================================================
59 void FeaturesAPI_Translation::setDistance(const ModelHighAPI_Double& theDistance)
61 fillAttribute(theDistance, mydistance);
66 //==================================================================================================
67 void FeaturesAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const
69 FeaturePtr aBase = feature();
70 const std::string& aDocName = theDumper.name(aBase->document());
72 AttributeSelectionListPtr anAttrObjects =
73 aBase->selectionList(FeaturesPlugin_Translation::OBJECTS_LIST_ID());
74 AttributeSelectionPtr anAttrAxis =
75 aBase->selection(FeaturesPlugin_Translation::AXIS_OBJECT_ID());
76 AttributeDoublePtr anAttrDistance = aBase->real(FeaturesPlugin_Translation::DISTANCE_ID());
78 theDumper << aBase << " = model.addTranslation(" << aDocName << ", "
79 << anAttrObjects << ", " << anAttrAxis << ", " << anAttrDistance << ")" << std::endl;
82 //==================================================================================================
83 TranslationPtr addTranslation(const std::shared_ptr<ModelAPI_Document>& thePart,
84 const std::list<ModelHighAPI_Selection>& theMainObjects,
85 const ModelHighAPI_Selection& theAxisObject,
86 const ModelHighAPI_Double& theDistance)
88 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Translation::ID());
89 return TranslationPtr(new FeaturesAPI_Translation(aFeature, theMainObjects,
90 theAxisObject, theDistance));