X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FFeaturesAPI%2FFeaturesAPI_Scale.cpp;h=fcb4d331a8dd6eeca8bfd4ed17a68bf028532789;hb=0dbe381518ba8993c2c4fa0fcb3ddd8fe5b8479b;hp=d402713bc1e5729f84132de2da9a2e11cbeb0e25;hpb=9552f8739e93d153cde510b2cbaeddbfe68d3ee3;p=modules%2Fshaper.git diff --git a/src/FeaturesAPI/FeaturesAPI_Scale.cpp b/src/FeaturesAPI/FeaturesAPI_Scale.cpp index d402713bc..fcb4d331a 100644 --- a/src/FeaturesAPI/FeaturesAPI_Scale.cpp +++ b/src/FeaturesAPI/FeaturesAPI_Scale.cpp @@ -1,8 +1,21 @@ -// Copyright (C) 2014-201x CEA/DEN, EDF R&D --> - -// File: FeaturesAPI_Scale.cpp -// Created: 24 Jan 2017 -// Author: Clarisse Genrault (CEA) +// Copyright (C) 2014-2019 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_Scale.h" @@ -30,6 +43,22 @@ FeaturesAPI_Scale::FeaturesAPI_Scale(const std::shared_ptr& th } } +//================================================================================================== +FeaturesAPI_Scale::FeaturesAPI_Scale(const std::shared_ptr& theFeature, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theCenterPoint, + const ModelHighAPI_Double& theScaleFactorX, + const ModelHighAPI_Double& theScaleFactorY, + const ModelHighAPI_Double& theScaleFactorZ) +: ModelHighAPI_Interface(theFeature) +{ + if (initialize()) { + fillAttribute(theMainObjects, mainObjects()); + fillAttribute(theCenterPoint, centerPoint()); + setDimensions(theScaleFactorX, theScaleFactorY, theScaleFactorZ); + } +} + //================================================================================================== FeaturesAPI_Scale::~FeaturesAPI_Scale() { @@ -52,10 +81,23 @@ void FeaturesAPI_Scale::setCenterPoint(const ModelHighAPI_Selection& theCenterPo //================================================================================================== void FeaturesAPI_Scale::setScaleFactor(const ModelHighAPI_Double& theScaleFactor) { + fillAttribute(FeaturesPlugin_Scale::CREATION_METHOD_BY_FACTOR(), creationMethod()); fillAttribute(theScaleFactor, scaleFactor()); execute(); } +//================================================================================================== +void FeaturesAPI_Scale::setDimensions(const ModelHighAPI_Double& theScaleFactorX, + const ModelHighAPI_Double& theScaleFactorY, + const ModelHighAPI_Double& theScaleFactorZ) +{ + fillAttribute(FeaturesPlugin_Scale::CREATION_METHOD_BY_DIMENSIONS(), creationMethod()); + fillAttribute(theScaleFactorX, scaleFactorX()); + fillAttribute(theScaleFactorY, scaleFactorY()); + fillAttribute(theScaleFactorZ, scaleFactorZ()); + execute(); +} + //================================================================================================== void FeaturesAPI_Scale::dump(ModelHighAPI_Dumper& theDumper) const { @@ -70,9 +112,23 @@ void FeaturesAPI_Scale::dump(ModelHighAPI_Dumper& theDumper) const aBase->selection(FeaturesPlugin_Scale::CENTER_POINT_ID()); theDumper << " , " << anAttrPoint; - AttributeDoublePtr anAttrScaleFactor = + std::string aCreationMethod = + aBase->string(FeaturesPlugin_Scale::CREATION_METHOD())->value(); + + if (aCreationMethod == FeaturesPlugin_Scale::CREATION_METHOD_BY_FACTOR()) { + AttributeDoublePtr anAttrScaleFactor = aBase->real(FeaturesPlugin_Scale::SCALE_FACTOR_ID()); theDumper << ", " << anAttrScaleFactor; + } else if (aCreationMethod == FeaturesPlugin_Scale::CREATION_METHOD_BY_DIMENSIONS()) { + AttributeDoublePtr anAttrScaleFactorX = + aBase->real(FeaturesPlugin_Scale::SCALE_FACTOR_X_ID()); + AttributeDoublePtr anAttrScaleFactorY = + aBase->real(FeaturesPlugin_Scale::SCALE_FACTOR_Y_ID()); + AttributeDoublePtr anAttrScaleFactorZ = + aBase->real(FeaturesPlugin_Scale::SCALE_FACTOR_Z_ID()); + theDumper << ", " << anAttrScaleFactorX << " , " << anAttrScaleFactorY; + theDumper << ", " << anAttrScaleFactorZ; + } theDumper << ")" << std::endl; } @@ -85,4 +141,17 @@ ScalePtr addScale(const std::shared_ptr& thePart, { std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Scale::ID()); return ScalePtr(new FeaturesAPI_Scale(aFeature, theMainObjects, theCenterPoint, theScaleFactor)); +} + +//================================================================================================== +ScalePtr addScale(const std::shared_ptr& thePart, + const std::list& theMainObjects, + const ModelHighAPI_Selection& theCenterPoint, + const ModelHighAPI_Double& theScaleFactorX, + const ModelHighAPI_Double& theScaleFactorY, + const ModelHighAPI_Double& theScaleFactorZ) +{ + std::shared_ptr aFeature = thePart->addFeature(FeaturesAPI_Scale::ID()); + return ScalePtr(new FeaturesAPI_Scale(aFeature, theMainObjects, theCenterPoint, + theScaleFactorX, theScaleFactorY, theScaleFactorZ)); } \ No newline at end of file