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(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
19 //==================================================================================================
20 FeaturesAPI_Translation::FeaturesAPI_Translation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21 const std::list<ModelHighAPI_Selection>& theMainObjects,
22 const ModelHighAPI_Selection& theAxisObject,
23 const ModelHighAPI_Double& theDistance)
24 : ModelHighAPI_Interface(theFeature)
27 fillAttribute(theMainObjects, mymainObjects);
28 fillAttribute(theAxisObject, myaxisObject);
29 setDistance(theDistance);
33 //==================================================================================================
34 FeaturesAPI_Translation::~FeaturesAPI_Translation()
39 //==================================================================================================
40 void FeaturesAPI_Translation::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
42 fillAttribute(theMainObjects, mymainObjects);
47 //==================================================================================================
48 void FeaturesAPI_Translation::setAxisObject(const ModelHighAPI_Selection& theAxisObject)
50 fillAttribute(theAxisObject, myaxisObject);
55 //==================================================================================================
56 void FeaturesAPI_Translation::setDistance(const ModelHighAPI_Double& theDistance)
58 fillAttribute(theDistance, mydistance);
63 //==================================================================================================
64 void FeaturesAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const
66 FeaturePtr aBase = feature();
67 const std::string& aDocName = theDumper.name(aBase->document());
69 AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Translation::OBJECTS_LIST_ID());
70 AttributeSelectionPtr anAttrAxis = aBase->selection(FeaturesPlugin_Translation::AXIS_OBJECT_ID());
71 AttributeDoublePtr anAttrDistance = aBase->real(FeaturesPlugin_Translation::DISTANCE_ID());
73 theDumper << aBase << " = model.addTranslation(" << aDocName << ", "
74 << anAttrObjects << ", " << anAttrAxis << ", " << anAttrDistance << ")" << std::endl;
77 //==================================================================================================
78 TranslationPtr addTranslation(const std::shared_ptr<ModelAPI_Document>& thePart,
79 const std::list<ModelHighAPI_Selection>& theMainObjects,
80 const ModelHighAPI_Selection& theAxisObject,
81 const ModelHighAPI_Double& theDistance)
83 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Translation::ID());
84 return TranslationPtr(new FeaturesAPI_Translation(aFeature, theMainObjects, theAxisObject, theDistance));