X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesAPI%2FFeaturesAPI_Translation.cpp;h=fea7313260ff10b4d6aa221677e805ad120496f0;hb=fe8cab988ae59927f68da8e184cce6767e052206;hp=bfcd5bdfc61524bbfc848111331f032ea5d00413;hpb=47fd852173321d7333c37ab439c1e75688fe7f72;p=modules%2Fshaper.git diff --git a/src/FeaturesAPI/FeaturesAPI_Translation.cpp b/src/FeaturesAPI/FeaturesAPI_Translation.cpp index bfcd5bdfc..fea731326 100644 --- a/src/FeaturesAPI/FeaturesAPI_Translation.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Translation.cpp @@ -46,6 +46,20 @@ FeaturesAPI_Translation::FeaturesAPI_Translation( } } +//================================================================================================== +FeaturesAPI_Translation::FeaturesAPI_Translation( + const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theStartPoint, + const ModelHighAPI_Selection& theEndPoint) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + fillAttribute(theMainObjects, mymainObjects); + setPoints(theStartPoint, theEndPoint); + } +} + //================================================================================================== FeaturesAPI_Translation::~FeaturesAPI_Translation() { @@ -85,6 +99,17 @@ void FeaturesAPI_Translation::setDimensions(const ModelHighAPI_Double& theDx, execute(); } +//================================================================================================== +void FeaturesAPI_Translation::setPoints(const ModelHighAPI_Selection& theStartPoint, + const ModelHighAPI_Selection& theEndPoint) +{ + fillAttribute(FeaturesPlugin_Translation::CREATION_METHOD_BY_TWO_POINTS(), mycreationMethod); + fillAttribute(theStartPoint, mystartPoint); + fillAttribute(theEndPoint, myendPoint); + + execute(); +} + //================================================================================================== void FeaturesAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const { @@ -98,7 +123,7 @@ void FeaturesAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const std::string aCreationMethod = aBase->string(FeaturesPlugin_Translation::CREATION_METHOD())->value(); - if(aCreationMethod == FeaturesPlugin_Translation::CREATION_METHOD_BY_DISTANCE()) { + if (aCreationMethod == FeaturesPlugin_Translation::CREATION_METHOD_BY_DISTANCE()) { AttributeSelectionPtr anAttrAxis = aBase->selection(FeaturesPlugin_Translation::AXIS_OBJECT_ID()); AttributeDoublePtr anAttrDistance = @@ -109,9 +134,15 @@ void FeaturesAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const AttributeDoublePtr anAttrDy = aBase->real(FeaturesPlugin_Translation::DY_ID()); AttributeDoublePtr anAttrDz = aBase->real(FeaturesPlugin_Translation::DZ_ID()); theDumper << ", " << anAttrDx << ", " << anAttrDy << ", " << anAttrDz; + } else if (aCreationMethod == FeaturesPlugin_Translation::CREATION_METHOD_BY_TWO_POINTS()) { + AttributeSelectionPtr anAttrStartPoint = + aBase->selection(FeaturesPlugin_Translation::START_POINT_ID()); + AttributeSelectionPtr anAttrEndPoint = + aBase->selection(FeaturesPlugin_Translation::END_POINT_ID()); + theDumper << ", " << anAttrStartPoint << ", " << anAttrEndPoint; } - theDumper << ")" << std::endl; + theDumper << ")" << std::endl; } //================================================================================================== @@ -135,3 +166,14 @@ TranslationPtr addTranslation(const std::shared_ptr& thePart, std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Translation::ID()); return TranslationPtr(new FeaturesAPI_Translation(aFeature, theMainObjects, theDx, theDy, theDz)); } + +//================================================================================================== +TranslationPtr addTranslation(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theStartPoint, + const ModelHighAPI_Selection& theEndPoint) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Translation::ID()); + return TranslationPtr(new FeaturesAPI_Translation(aFeature, theMainObjects, + theStartPoint, theEndPoint)); +}