X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesAPI%2FFeaturesAPI_Translation.cpp;h=2a23db4f6242990edf0771f9ae8637b609f3c413;hb=f60dc9dd94d5d4b0ea07e3e3cbfd5b3028f0942d;hp=6b09954827301b2285e1c18aaed76ad1b2d77691;hpb=423c10234142d14d0d5de89383f2f96a4ec5930f;p=modules%2Fshaper.git diff --git a/src/FeaturesAPI/FeaturesAPI_Translation.cpp b/src/FeaturesAPI/FeaturesAPI_Translation.cpp index 6b0995482..2a23db4f6 100644 --- a/src/FeaturesAPI/FeaturesAPI_Translation.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Translation.cpp @@ -1,8 +1,22 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -// File: FeaturesAPI_Translation.cpp -// Created: 07 June 2016 -// Author: Dmitry Bobylev +// Copyright (C) 2014-2017 CEA/DEN, EDF R&D +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or +// email : webmaster.salome@opencascade.com +// #include "FeaturesAPI_Translation.h" @@ -27,8 +41,36 @@ FeaturesAPI_Translation::FeaturesAPI_Translation( { 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); } } @@ -48,17 +90,36 @@ void FeaturesAPI_Translation::setMainObjects( } //================================================================================================== -void FeaturesAPI_Translation::setAxisObject(const ModelHighAPI_Selection& theAxisObject) +void FeaturesAPI_Translation::setAxisAndDistance(const ModelHighAPI_Selection& theAxisObject, + const ModelHighAPI_Double& theDistance) { + fillAttribute(FeaturesPlugin_Translation::CREATION_METHOD_BY_DISTANCE(), mycreationMethod); fillAttribute(theAxisObject, myaxisObject); + fillAttribute(theDistance, mydistance); execute(); } //================================================================================================== -void FeaturesAPI_Translation::setDistance(const ModelHighAPI_Double& theDistance) +void FeaturesAPI_Translation::setDimensions(const ModelHighAPI_Double& theDx, + const ModelHighAPI_Double& theDy, + const ModelHighAPI_Double& theDz) { - fillAttribute(theDistance, mydistance); + fillAttribute(FeaturesPlugin_Translation::CREATION_METHOD_BY_DIMENSIONS(), mycreationMethod); + fillAttribute(theDx, mydx); + fillAttribute(theDy, mydy); + fillAttribute(theDz, mydz); + + 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(); } @@ -71,12 +132,31 @@ void FeaturesAPI_Translation::dump(ModelHighAPI_Dumper& theDumper) const 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()); + 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; } //================================================================================================== @@ -89,3 +169,25 @@ TranslationPtr addTranslation(const std::shared_ptr& thePart, 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)); +}