X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesAPI%2FFeaturesAPI_Translation.cpp;h=fea7313260ff10b4d6aa221677e805ad120496f0;hb=fe8cab988ae59927f68da8e184cce6767e052206;hp=e70df5b8c24c0846ea519b6702a85201ba415e2e;hpb=d34842c50d5f335cca443c78910c16c54139c7d0;p=modules%2Fshaper.git diff --git a/src/FeaturesAPI/FeaturesAPI_Translation.cpp b/src/FeaturesAPI/FeaturesAPI_Translation.cpp index e70df5b8c..fea731326 100644 --- a/src/FeaturesAPI/FeaturesAPI_Translation.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Translation.cpp @@ -10,23 +10,53 @@ #include //================================================================================================== -FeaturesAPI_Translation::FeaturesAPI_Translation(const std::shared_ptr& theFeature) +FeaturesAPI_Translation::FeaturesAPI_Translation( + const std::shared_ptr& theFeature) : ModelHighAPI_Interface(theFeature) { initialize(); } //================================================================================================== -FeaturesAPI_Translation::FeaturesAPI_Translation(const std::shared_ptr& theFeature, - const std::list& theMainObjects, - const ModelHighAPI_Selection& theAxisObject, - const ModelHighAPI_Double& theDistance) +FeaturesAPI_Translation::FeaturesAPI_Translation( + const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theAxisObject, + const ModelHighAPI_Double& theDistance) : ModelHighAPI_Interface(theFeature) { if(initialize()) { fillAttribute(theMainObjects, mymainObjects); - fillAttribute(theAxisObject, myaxisObject); - setDistance(theDistance); + setAxisAndDistance(theAxisObject, theDistance); + } +} + +//================================================================================================== +FeaturesAPI_Translation::FeaturesAPI_Translation( + const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const ModelHighAPI_Double& theDx, + const ModelHighAPI_Double& theDy, + const ModelHighAPI_Double& theDz) +: ModelHighAPI_Interface(theFeature) +{ + if(initialize()) { + fillAttribute(theMainObjects, mymainObjects); + setDimensions(theDx, theDy, theDz); + } +} + +//================================================================================================== +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); } } @@ -37,7 +67,8 @@ FeaturesAPI_Translation::~FeaturesAPI_Translation() } //================================================================================================== -void FeaturesAPI_Translation::setMainObjects(const std::list& theMainObjects) +void FeaturesAPI_Translation::setMainObjects( + const std::list& theMainObjects) { fillAttribute(theMainObjects, mymainObjects); @@ -45,17 +76,36 @@ void FeaturesAPI_Translation::setMainObjects(const std::listdocument()); - AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Translation::OBJECTS_LIST_ID()); - AttributeSelectionPtr anAttrAxis = aBase->selection(FeaturesPlugin_Translation::AXIS_OBJECT_ID()); - AttributeDoublePtr anAttrDistance = aBase->real(FeaturesPlugin_Translation::DISTANCE_ID()); + AttributeSelectionListPtr anAttrObjects = + aBase->selectionList(FeaturesPlugin_Translation::OBJECTS_LIST_ID()); + theDumper << aBase << " = model.addTranslation(" << aDocName << ", " << anAttrObjects; + + std::string aCreationMethod = + aBase->string(FeaturesPlugin_Translation::CREATION_METHOD())->value(); + + if (aCreationMethod == FeaturesPlugin_Translation::CREATION_METHOD_BY_DISTANCE()) { + AttributeSelectionPtr anAttrAxis = + aBase->selection(FeaturesPlugin_Translation::AXIS_OBJECT_ID()); + AttributeDoublePtr anAttrDistance = + aBase->real(FeaturesPlugin_Translation::DISTANCE_ID()); + theDumper << ", " << anAttrAxis << ", " << anAttrDistance; + } else if (aCreationMethod == FeaturesPlugin_Translation::CREATION_METHOD_BY_DIMENSIONS()) { + AttributeDoublePtr anAttrDx = aBase->real(FeaturesPlugin_Translation::DX_ID()); + 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 << aBase << " = model.addTranslation(" << aDocName << ", " - << anAttrObjects << ", " << anAttrAxis << ", " << anAttrDistance << ")" << std::endl; + theDumper << ")" << std::endl; } //================================================================================================== @@ -81,5 +152,28 @@ TranslationPtr addTranslation(const std::shared_ptr& thePart, const ModelHighAPI_Double& theDistance) { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Translation::ID()); - return TranslationPtr(new FeaturesAPI_Translation(aFeature, theMainObjects, theAxisObject, theDistance)); + return TranslationPtr(new FeaturesAPI_Translation(aFeature, theMainObjects, + theAxisObject, theDistance)); +} + +//================================================================================================== +TranslationPtr addTranslation(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const ModelHighAPI_Double& theDx, + const ModelHighAPI_Double& theDy, + const ModelHighAPI_Double& theDz) +{ + 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)); }