X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchAPI%2FSketchAPI_Circle.cpp;h=8085f6603f9b01fa0f726af5c6ffb16610f99f43;hb=0c1aba245957ea388718557b9be063d1c92cbf5f;hp=d8a07f13b787bcf4e9948b1b901221b2e00558ab;hpb=f98f887290d4e2b4bd6618389911e82b6b9674f3;p=modules%2Fshaper.git diff --git a/src/SketchAPI/SketchAPI_Circle.cpp b/src/SketchAPI/SketchAPI_Circle.cpp index d8a07f13b..8085f6603 100644 --- a/src/SketchAPI/SketchAPI_Circle.cpp +++ b/src/SketchAPI/SketchAPI_Circle.cpp @@ -1,14 +1,29 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> - -// File: SketchAPI_Circle.cpp -// Created: 09 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 "SketchAPI_Circle.h" #include #include +#include #include #include @@ -42,30 +57,6 @@ SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr& theF } } -//================================================================================================== -SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr& theFeature, - double theX1, double theY1, - double theX2, double theY2, - double theX3, double theY3) -: SketchAPI_SketchEntity(theFeature) -{ - if (initialize()) { - setByThreePoints(theX1, theY1, theX2, theY2, theX3, theY3); - } -} - -//================================================================================================== -SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr& theFeature, - const std::shared_ptr& thePoint1, - const std::shared_ptr& thePoint2, - const std::shared_ptr& thePoint3) -: SketchAPI_SketchEntity(theFeature) -{ - if (initialize()) { - setByThreePoints(thePoint1, thePoint2, thePoint3); - } -} - //================================================================================================== SketchAPI_Circle::SketchAPI_Circle(const std::shared_ptr& theFeature, const ModelHighAPI_Selection& theExternal) @@ -95,7 +86,6 @@ SketchAPI_Circle::~SketchAPI_Circle() //================================================================================================== void SketchAPI_Circle::setByCenterAndRadius(double theCenterX, double theCenterY, double theRadius) { - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType); fillAttribute(center(), theCenterX, theCenterY); fillAttribute(theRadius, myradius); @@ -106,39 +96,12 @@ void SketchAPI_Circle::setByCenterAndRadius(double theCenterX, double theCenterY void SketchAPI_Circle::setByCenterAndRadius(const std::shared_ptr& theCenter, double theRadius) { - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType); fillAttribute(theCenter, mycenter); fillAttribute(theRadius, myradius); execute(); } -//================================================================================================== -void SketchAPI_Circle::setByThreePoints(double theX1, double theY1, - double theX2, double theY2, - double theX3, double theY3) -{ - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType); - fillAttribute(firstPoint(), theX1, theY1); - fillAttribute(secondPoint(), theX2, theY2); - fillAttribute(thirdPoint(), theX3, theY3); - - execute(); -} - -//================================================================================================== -void SketchAPI_Circle::setByThreePoints(const std::shared_ptr& thePoint1, - const std::shared_ptr& thePoint2, - const std::shared_ptr& thePoint3) -{ - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType); - fillAttribute(thePoint1, myfirstPoint); - fillAttribute(thePoint2, mysecondPoint); - fillAttribute(thePoint3, mythirdPoint); - - execute(); -} - //================================================================================================== void SketchAPI_Circle::setByExternal(const ModelHighAPI_Selection & theExternal) { @@ -158,7 +121,6 @@ void SketchAPI_Circle::setByExternalName(const std::string & theExternalName) //================================================================================================== void SketchAPI_Circle::setCenter(double theX, double theY) { - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType); fillAttribute(center(), theX, theY); execute(); @@ -167,7 +129,6 @@ void SketchAPI_Circle::setCenter(double theX, double theY) //================================================================================================== void SketchAPI_Circle::setCenter(const std::shared_ptr & theCenter) { - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType); fillAttribute(theCenter, mycenter); execute(); @@ -176,62 +137,29 @@ void SketchAPI_Circle::setCenter(const std::shared_ptr & theCente //================================================================================================== void SketchAPI_Circle::setRadius(double theRadius) { - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_CENTER_AND_RADIUS(), mycircleType); fillAttribute(ModelHighAPI_Double(theRadius), myradius); execute(); } //================================================================================================== -void SketchAPI_Circle::setFirstPoint(double theX, double theY) -{ - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType); - fillAttribute(firstPoint(), theX, theY); - - execute(); -} - -//================================================================================================== -void SketchAPI_Circle::setFirstPoint(const std::shared_ptr& thePoint) -{ - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType); - fillAttribute(thePoint, myfirstPoint); - - execute(); -} - -//================================================================================================== -void SketchAPI_Circle::setSecondPoint(double theX, double theY) -{ - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType); - fillAttribute(secondPoint(), theX, theY); - - execute(); -} - -//================================================================================================== -void SketchAPI_Circle::setSecondPoint(const std::shared_ptr& thePoint) +void SketchAPI_Circle::dump(ModelHighAPI_Dumper& theDumper) const { - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType); - fillAttribute(thePoint, mysecondPoint); - - execute(); -} + if (isCopy()) + return; // no need to dump copied feature -//================================================================================================== -void SketchAPI_Circle::setThirdPoint(double theX, double theY) -{ - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType); - fillAttribute(thirdPoint(), theX, theY); + FeaturePtr aBase = feature(); + const std::string& aSketchName = theDumper.parentName(aBase); - execute(); -} - -//================================================================================================== -void SketchAPI_Circle::setThirdPoint(const std::shared_ptr& thePoint) -{ - fillAttribute(SketchPlugin_Circle::CIRCLE_TYPE_THREE_POINTS(), mycircleType); - fillAttribute(thePoint, mythirdPoint); - - execute(); + AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID()); + if (anExternal->context()) { + // circle is external + theDumper << aBase << " = " << aSketchName << ".addCircle(" << anExternal << ")" << std::endl; + } else { + // circle given by center and radius + theDumper << aBase << " = " << aSketchName << ".addCircle(" + << center() << ", " << radius() << ")" << std::endl; + } + // dump "auxiliary" flag if necessary + SketchAPI_SketchEntity::dump(theDumper); }