From 8b467e4cd9bc09b1378314784ee01d9646022a30 Mon Sep 17 00:00:00 2001 From: dbv Date: Thu, 23 Mar 2017 17:44:10 +0300 Subject: [PATCH] Issue #2024: Redesign of circle and arc of circle Initial arc redesign commit. --- src/SketchPlugin/CMakeLists.txt | 2 + src/SketchPlugin/SketchPlugin_MacroArc.cpp | 333 ++++++++++++++++++ src/SketchPlugin/SketchPlugin_MacroArc.h | 194 ++++++++++ src/SketchPlugin/SketchPlugin_MacroCircle.cpp | 47 ++- src/SketchPlugin/SketchPlugin_MacroCircle.h | 2 - src/SketchPlugin/SketchPlugin_Plugin.cpp | 4 + src/SketchPlugin/SketchPlugin_Tools.cpp | 9 + src/SketchPlugin/SketchPlugin_Tools.h | 2 + src/SketchPlugin/plugin-Sketch.xml | 151 ++++++-- 9 files changed, 688 insertions(+), 56 deletions(-) create mode 100644 src/SketchPlugin/SketchPlugin_MacroArc.cpp create mode 100644 src/SketchPlugin/SketchPlugin_MacroArc.h diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index 614dd0d29..c264c5192 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -30,6 +30,7 @@ SET(PROJECT_HEADERS SketchPlugin_Feature.h SketchPlugin_IntersectionPoint.h SketchPlugin_Line.h + SketchPlugin_MacroArc.h SketchPlugin_MacroCircle.h SketchPlugin_MultiRotation.h SketchPlugin_MultiTranslation.h @@ -69,6 +70,7 @@ SET(PROJECT_SOURCES SketchPlugin_Feature.cpp SketchPlugin_IntersectionPoint.cpp SketchPlugin_Line.cpp + SketchPlugin_MacroArc.cpp SketchPlugin_MacroCircle.cpp SketchPlugin_MultiRotation.cpp SketchPlugin_MultiTranslation.cpp diff --git a/src/SketchPlugin/SketchPlugin_MacroArc.cpp b/src/SketchPlugin/SketchPlugin_MacroArc.cpp new file mode 100644 index 000000000..381326476 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_MacroArc.cpp @@ -0,0 +1,333 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: SketchPlugin_MacroArc.cpp +// Created: 26 Apr 2014 +// Author: Artem ZHIDKOV + +#include "SketchPlugin_MacroArc.h" + +#include "SketchPlugin_Sketch.h" +#include "SketchPlugin_Tools.h" + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +// for sqrt on Linux +#include + +const double tolerance = 1e-7; +const double paramTolerance = 1.e-4; +const double PI = 3.141592653589793238463; + + +SketchPlugin_MacroArc::SketchPlugin_MacroArc() +: SketchPlugin_SketchEntity(), + myIsInversed(false), + myParamBefore(0.0) +{ +} + +void SketchPlugin_MacroArc::initAttributes() +{ + data()->addAttribute(ARC_TYPE(), ModelAPI_AttributeString::typeId()); + + data()->addAttribute(CENTER_POINT_ID(), GeomDataAPI_Point2D::typeId()); + data()->addAttribute(START_POINT_1_ID(), GeomDataAPI_Point2D::typeId()); + data()->addAttribute(END_POINT_1_ID(), GeomDataAPI_Point2D::typeId()); + + data()->addAttribute(START_POINT_2_ID(), GeomDataAPI_Point2D::typeId()); + data()->addAttribute(END_POINT_2_ID(), GeomDataAPI_Point2D::typeId()); + data()->addAttribute(PASSED_POINT_ID(), GeomDataAPI_Point2D::typeId()); + + data()->addAttribute(TANGENT_POINT_ID(), ModelAPI_AttributeRefAttr::typeId()); + data()->addAttribute(END_POINT_3_ID(), GeomDataAPI_Point2D::typeId()); + + data()->addAttribute(RADIUS_ID(), ModelAPI_AttributeDouble::typeId()); + data()->addAttribute(ANGLE_ID(), ModelAPI_AttributeDouble::typeId()); + + data()->addAttribute(AUXILIARY_ID(), ModelAPI_AttributeBoolean::typeId()); + + data()->addAttribute(CENTER_POINT_REF_ID(), ModelAPI_AttributeRefAttr::typeId()); + data()->addAttribute(START_POINT_REF_ID(), ModelAPI_AttributeRefAttr::typeId()); + data()->addAttribute(END_POINT_REF_ID(), ModelAPI_AttributeRefAttr::typeId()); + data()->addAttribute(PASSED_POINT_REF_ID(), ModelAPI_AttributeRefAttr::typeId()); + + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), CENTER_POINT_REF_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), START_POINT_REF_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), END_POINT_REF_ID()); + ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), PASSED_POINT_REF_ID()); +} + +void SketchPlugin_MacroArc::attributeChanged(const std::string& theID) +{ + std::string anArcType = string(ARC_TYPE())->value(); + + // If arc type switched reset according attributes. + if(theID == ARC_TYPE()) { + std::string aType = string(ARC_TYPE())->value(); + if(aType == ARC_TYPE_BY_CENTER_AND_POINTS()) { + SketchPlugin_Tools::resetAttribute(this, CENTER_POINT_ID()); + SketchPlugin_Tools::resetAttribute(this, CENTER_POINT_REF_ID()); + SketchPlugin_Tools::resetAttribute(this, START_POINT_1_ID()); + SketchPlugin_Tools::resetAttribute(this, START_POINT_REF_ID()); + SketchPlugin_Tools::resetAttribute(this, END_POINT_1_ID()); + SketchPlugin_Tools::resetAttribute(this, END_POINT_REF_ID()); + } else if(aType == ARC_TYPE_BY_THREE_POINTS()) { + SketchPlugin_Tools::resetAttribute(this, START_POINT_2_ID()); + SketchPlugin_Tools::resetAttribute(this, START_POINT_REF_ID()); + SketchPlugin_Tools::resetAttribute(this, END_POINT_2_ID()); + SketchPlugin_Tools::resetAttribute(this, END_POINT_REF_ID()); + SketchPlugin_Tools::resetAttribute(this, PASSED_POINT_ID()); + SketchPlugin_Tools::resetAttribute(this, PASSED_POINT_REF_ID()); + } else if(aType == ARC_TYPE_BY_TANGENT_EDGE()) { + SketchPlugin_Tools::resetAttribute(this, TANGENT_POINT_ID()); + SketchPlugin_Tools::resetAttribute(this, END_POINT_3_ID()); + SketchPlugin_Tools::resetAttribute(this, END_POINT_REF_ID()); + } + + myCenter.reset(); + myStart.reset(); + myEnd.reset(); + myIsInversed = false; + myParamBefore = 0.0; + } else if(anArcType == ARC_TYPE_BY_CENTER_AND_POINTS()) { + std::shared_ptr aCenterPointAttr = + std::dynamic_pointer_cast(attribute(CENTER_POINT_ID())); + if(!aCenterPointAttr->isInitialized()) { + return; + } + std::shared_ptr aStartPointAttr = + std::dynamic_pointer_cast(attribute(START_POINT_1_ID())); + if(!aStartPointAttr->isInitialized()) { + return; + } + + myCenter = aCenterPointAttr->pnt(); + myStart = aStartPointAttr->pnt(); + myEnd = myStart; + + std::shared_ptr anEndPointAttr = + std::dynamic_pointer_cast(attribute(END_POINT_1_ID())); + if(anEndPointAttr->isInitialized()) { + // End point should be a projection on circle. + GeomAPI_Circ2d aCircleForArc(myCenter, myStart); + std::shared_ptr aProjection = aCircleForArc.project(anEndPointAttr->pnt()); + if(aProjection.get()) { + bool aWasBlocked = data()->blockSendAttributeUpdated(true); + anEndPointAttr->setValue(aProjection); + data()->blockSendAttributeUpdated(aWasBlocked, false); + } + myEnd = anEndPointAttr->pnt(); + + double aParameterNew = 0.0; + if(aCircleForArc.parameter(myEnd, paramTolerance, aParameterNew)) { + if(myParamBefore <= PI / 2.0 && aParameterNew >= PI * 1.5) { + myIsInversed = true; + } else if(myParamBefore >= PI * 1.5 && aParameterNew <= PI / 2.0) { + myIsInversed = false; + } + } + myParamBefore = aParameterNew; + } + } else if(anArcType == ARC_TYPE_BY_THREE_POINTS()) { + std::shared_ptr aStartPointAttr = + std::dynamic_pointer_cast(attribute(START_POINT_2_ID())); + if(!aStartPointAttr->isInitialized()) { + return; + } + std::shared_ptr anEndPointAttr = + std::dynamic_pointer_cast(attribute(END_POINT_2_ID())); + if(!anEndPointAttr->isInitialized()) { + return; + } + + myStart = aStartPointAttr->pnt(); + myEnd = anEndPointAttr->pnt(); + + std::shared_ptr aPassedPointAttr = + std::dynamic_pointer_cast(attribute(PASSED_POINT_ID())); + if(aPassedPointAttr->isInitialized()) { + std::shared_ptr aPassed = aPassedPointAttr->pnt(); + GeomAPI_Circ2d aCircle(myStart, myEnd, aPassed); + myCenter = aCircle.center(); + aCircle = GeomAPI_Circ2d(myCenter, myStart); + double anEndParam, aPassedParam; + aCircle.parameter(myEnd, paramTolerance, anEndParam); + aCircle.parameter(aPassed, paramTolerance, aPassedParam); + if(aPassedParam > anEndParam) { + myIsInversed = true; + } else { + myIsInversed = false; + } + } else { + std::shared_ptr aDir = myEnd->xy()->decreased(myStart->xy())->multiplied(0.5); + double x = aDir->x(); + double y = aDir->y(); + aDir->setX(x - y); + aDir->setY(y + x); + myCenter.reset(new GeomAPI_Pnt2d(myStart->xy()->added(aDir))); + } + } else if(anArcType == ARC_TYPE_BY_TANGENT_EDGE()) { + AttributeRefAttrPtr aTangentAttr = refattr(TANGENT_POINT_ID()); + if(!aTangentAttr->isInitialized()) { + return; + } + std::shared_ptr aTangentPointAttr = + std::dynamic_pointer_cast(aTangentAttr->attr()); + if(!aTangentPointAttr->isInitialized()) { + return; + } + std::shared_ptr anEndPointAttr = + std::dynamic_pointer_cast(attribute(END_POINT_3_ID())); + if(!anEndPointAttr->isInitialized()) { + return; + } + + myStart = aTangentPointAttr->pnt(); + myEnd = anEndPointAttr->pnt(); + + if(myStart->isEqual(myEnd)) { + return; + } + + SketchPlugin_Sketch* aSketch = sketch(); + if(!aSketch) { + return; + } + + std::shared_ptr anOrthoDir; + FeaturePtr aTangFeature = ModelAPI_Feature::feature(aTangentPointAttr->owner()); + std::shared_ptr aTangEdge = + std::dynamic_pointer_cast(aTangFeature->lastResult()->shape()); + if(aTangEdge->isLine()) { + std::shared_ptr aDir = aTangEdge->line()->direction(); + std::shared_ptr aPnt(new GeomAPI_Pnt(aDir->x(), aDir->y(), aDir->z())); + std::shared_ptr aPnt2d = aSketch->to2D(aPnt); + anOrthoDir = std::shared_ptr(new GeomAPI_Dir2d(-aPnt2d->y(), aPnt2d->x())); + } + else if (aTangEdge->isArc()) { + std::shared_ptr aCenter = aTangEdge->circle()->center(); + std::shared_ptr aCenter2d = aSketch->to2D(aCenter); + anOrthoDir = std::shared_ptr( + new GeomAPI_Dir2d(myStart->xy()->decreased(aCenter2d->xy()))); + } + + // compute parameters of the middle perpendicular + std::shared_ptr aEndPntCoord = myEnd->xy(); + std::shared_ptr aTempDir = aEndPntCoord->decreased(myStart->xy()); + std::shared_ptr aMidDir(new GeomAPI_Dir2d(-aTempDir->y(), aTempDir->x())); + std::shared_ptr aMidPnt( + new GeomAPI_Pnt2d(aEndPntCoord->added(myStart->xy())->multiplied(0.5))); + + // compute center of arc by calculating intersection of + // orthogonal line and middle perpendicular + std::shared_ptr anOrthoLine(new GeomAPI_Lin2d(myStart, anOrthoDir)); + std::shared_ptr aMiddleLine(new GeomAPI_Lin2d(aMidPnt, aMidDir)); + std::shared_ptr aCenter = anOrthoLine->intersect(aMiddleLine); + if(aCenter) { + myCenter = aCenter; + } + + GeomAPI_Circ2d aCircleForArc(myCenter, myStart); + double aParameterNew = 0.0; + if(aCircleForArc.parameter(myEnd, paramTolerance, aParameterNew)) { + if(myParamBefore <= PI / 2.0 && aParameterNew >= PI * 1.5) { + if(!myIsInversed) { + myIsInversed = true; + } + } else if(myParamBefore >= PI * 1.5 && aParameterNew <= PI / 2.0) { + if(myIsInversed) { + myIsInversed = false; + } + } + } + myParamBefore = aParameterNew; + } + + double aRadius = 0; + double anAngle = 0; + if(myCenter.get() && myStart.get()) { + aRadius = myCenter->distance(myStart); + if(myEnd.get()) { + if(myStart->isEqual(myEnd)) { + anAngle = 360; + } else { + GeomAPI_Circ2d aCircleForArc(myCenter, myStart); + double aStartParam, anEndParam; + aCircleForArc.parameter(myStart, paramTolerance, aStartParam); + aCircleForArc.parameter(myEnd, paramTolerance, anEndParam); + anAngle = (anEndParam - aStartParam) / PI * 180.0; + if(myIsInversed) anAngle = 360.0 - anAngle; + } + } + } + + bool aWasBlocked = data()->blockSendAttributeUpdated(true); + real(RADIUS_ID())->setValue(aRadius); + real(ANGLE_ID())->setValue(anAngle); + data()->blockSendAttributeUpdated(aWasBlocked, false); +} + +AISObjectPtr SketchPlugin_MacroArc::getAISObject(AISObjectPtr thePrevious) +{ + if(!myStart.get() || !myEnd.get() || !myCenter.get()) { + return AISObjectPtr(); + } + + SketchPlugin_Sketch* aSketch = sketch(); + if(!aSketch) { + return AISObjectPtr(); + } + + std::shared_ptr aStart = aSketch->to3D(myStart->x(), myStart->y()); + std::shared_ptr anEnd = aSketch->to3D(myEnd->x(), myEnd->y()); + std::shared_ptr aCenter = aSketch->to3D(myCenter->x(), myCenter->y());; + + std::shared_ptr aNDir = + std::dynamic_pointer_cast( + aSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID())); + std::shared_ptr aNormal = aNDir->dir(); + GeomShapePtr anArcShape = myIsInversed ? + GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, anEnd, aStart, aNormal) + : GeomAlgoAPI_EdgeBuilder::lineCircleArc(aCenter, aStart, anEnd, aNormal); + GeomShapePtr aCenterPointShape = GeomAlgoAPI_PointBuilder::vertex(aCenter); + + if(!anArcShape.get() || !aCenterPointShape.get()) { + return AISObjectPtr(); + } + + std::list > aShapes; + aShapes.push_back(anArcShape); + aShapes.push_back(aCenterPointShape); + + std::shared_ptr aCompound = GeomAlgoAPI_CompoundBuilder::compound(aShapes); + AISObjectPtr anAIS = thePrevious; + if(!anAIS.get()) { + anAIS.reset(new GeomAPI_AISObject()); + } + anAIS->createShape(aCompound); + return anAIS; +} + +void SketchPlugin_MacroArc::execute() +{ +} diff --git a/src/SketchPlugin/SketchPlugin_MacroArc.h b/src/SketchPlugin/SketchPlugin_MacroArc.h new file mode 100644 index 000000000..a082c64a3 --- /dev/null +++ b/src/SketchPlugin/SketchPlugin_MacroArc.h @@ -0,0 +1,194 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D --> + +// File: SketchPlugin_MacroArc.h +// Created: 26 May 2014 +// Author: Artem ZHIDKOV + +#ifndef SketchPlugin_MacroArc_H_ +#define SketchPlugin_MacroArc_H_ + +#include "SketchPlugin.h" +#include +#include +#include + +/**\class SketchPlugin_MacroArc + * \ingroup Plugins + * \brief Feature for creation of the new arc of circle in PartSet. + * The visualization of this object is separated in two parts. The first one is an AIS object + * calculated when there is non-initialized attributes of the arc. The second is a result and + * it is calculated if all attributes are initialized. + */ +class SketchPlugin_MacroArc: public SketchPlugin_SketchEntity, + public GeomAPI_IPresentable +{ + public: + /// Arc feature kind + inline static const std::string& ID() + { + static const std::string ID("SketchMacroArc"); + return ID; + } + + inline static const std::string& ARC_TYPE() + { + static const std::string ID("arc_type"); + return ID; + } + + static const std::string& ARC_TYPE_BY_CENTER_AND_POINTS() + { + static const std::string ID("by_center_and_points"); + return ID; + } + static const std::string& ARC_TYPE_BY_THREE_POINTS() + { + static const std::string ID("by_three_points"); + return ID; + } + + inline static const std::string& ARC_TYPE_BY_TANGENT_EDGE() + { + static const std::string ID("by_tangent_edge"); + return ID; + } + + /// Central 2D point of the circle which contains the arc + inline static const std::string& CENTER_POINT_ID() + { + static const std::string ID = "center_point"; + return ID; + } + + inline static const std::string& CENTER_POINT_REF_ID() + { + static const std::string ID = "center_point_ref"; + return ID; + } + + /// Start 2D point of the arc + inline static const std::string& START_POINT_1_ID() + { + static const std::string ID = "start_point_1"; + return ID; + } + + /// Start 2D point of the arc + inline static const std::string& START_POINT_2_ID() + { + static const std::string ID = "start_point_2"; + return ID; + } + + inline static const std::string& START_POINT_REF_ID() + { + static const std::string ID = "start_point_ref"; + return ID; + } + + /// End 2D point of the arc + inline static const std::string& END_POINT_1_ID() + { + static const std::string ID = "end_point_1"; + return ID; + } + + /// End 2D point of the arc + inline static const std::string& END_POINT_2_ID() + { + static const std::string ID = "end_point_2"; + return ID; + } + + /// End 2D point of the arc + inline static const std::string& END_POINT_3_ID() + { + static const std::string ID = "end_point_3"; + return ID; + } + + inline static const std::string& END_POINT_REF_ID() + { + static const std::string ID = "end_point_ref"; + return ID; + } + + /// Passed point of the arc. + static const std::string& PASSED_POINT_ID() + { + static const std::string ID("passed_point"); + return ID; + } + + static const std::string& PASSED_POINT_REF_ID() + { + static const std::string ID("passed_point_ref"); + return ID; + } + + static const std::string& TANGENT_POINT_ID() + { + static const std::string ID("tangent_point"); + return ID; + } + + /// Arc radius. + static const std::string& RADIUS_ID() + { + static const std::string ID("radius"); + return ID; + } + + /// Arc angle. + static const std::string& ANGLE_ID() + { + static const std::string ID("angle"); + return ID; + } + + /// Returns the kind of a feature + SKETCHPLUGIN_EXPORT virtual const std::string& getKind() + { + static std::string MY_KIND = SketchPlugin_MacroArc::ID(); + return MY_KIND; + } + + /// \brief Request for initialization of data model of the feature: adding all attributes. + SKETCHPLUGIN_EXPORT virtual void initAttributes(); + + /// Called on change of any argument-attribute of this object + /// \param theID identifier of changed attribute + SKETCHPLUGIN_EXPORT virtual void attributeChanged(const std::string& theID); + + /// Returns the AIS preview + virtual AISObjectPtr getAISObject(AISObjectPtr thePrevious); + + /// Creates an arc-shape + SKETCHPLUGIN_EXPORT virtual void execute(); + + /// Moves the feature + /// \param theDeltaX the delta for X coordinate is moved + /// \param theDeltaY the delta for Y coordinate is moved + SKETCHPLUGIN_EXPORT virtual void move(const double theDeltaX, const double theDeltaY) + { + }; + + /// Reimplemented from ModelAPI_Feature::isMacro(). + SKETCHPLUGIN_EXPORT virtual bool isMacro() const {return true;}; + + SKETCHPLUGIN_EXPORT virtual bool isPreviewNeeded() const {return false;}; + + /// Use plugin manager for features creation. + SketchPlugin_MacroArc(); + +private: + std::shared_ptr myCenter; + std::shared_ptr myStart; + std::shared_ptr myEnd; + + /// To define in which direction draw arc. + bool myIsInversed; + double myParamBefore; +}; + +#endif diff --git a/src/SketchPlugin/SketchPlugin_MacroCircle.cpp b/src/SketchPlugin/SketchPlugin_MacroCircle.cpp index 375fec588..b545ccdd2 100644 --- a/src/SketchPlugin/SketchPlugin_MacroCircle.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroCircle.cpp @@ -7,29 +7,27 @@ #include "SketchPlugin_MacroCircle.h" #include "SketchPlugin_Circle.h" -//#include "SketchPlugin_ConstraintCoincidence.h" #include "SketchPlugin_Point.h" #include "SketchPlugin_Tools.h" -#include -#include -#include -#include -#include #include #include #include #include +#include + +#include +#include +#include #include #include #include #include -#include -#include -#include -#include + #include +#include +#include const double tolerance = 1e-7; @@ -38,9 +36,9 @@ namespace { static const std::string& POINT_ID(int theIndex) { switch (theIndex) { - case 1: return SketchPlugin_MacroCircle::FIRST_POINT_ID(); - case 2: return SketchPlugin_MacroCircle::SECOND_POINT_ID(); - case 3: return SketchPlugin_MacroCircle::THIRD_POINT_ID(); + case 1: return SketchPlugin_MacroCircle::FIRST_POINT_ID(); + case 2: return SketchPlugin_MacroCircle::SECOND_POINT_ID(); + case 3: return SketchPlugin_MacroCircle::THIRD_POINT_ID(); } static const std::string DUMMY; @@ -241,12 +239,17 @@ void SketchPlugin_MacroCircle::attributeChanged(const std::string& theID) { if(theID == CIRCLE_TYPE()) { std::string aType = string(CIRCLE_TYPE())->value(); if(aType == CIRCLE_TYPE_BY_CENTER_AND_PASSED_POINTS()) { - resetAttribute(CENTER_POINT_ID()); - resetAttribute(PASSED_POINT_ID()); + SketchPlugin_Tools::resetAttribute(this, CENTER_POINT_ID()); + SketchPlugin_Tools::resetAttribute(this, CENTER_POINT_REF_ID()); + SketchPlugin_Tools::resetAttribute(this, PASSED_POINT_ID()); + SketchPlugin_Tools::resetAttribute(this, PASSED_POINT_REF_ID()); } else if(aType == CIRCLE_TYPE_BY_THREE_POINTS()) { - resetAttribute(FIRST_POINT_ID()); - resetAttribute(SECOND_POINT_ID()); - resetAttribute(THIRD_POINT_ID()); + SketchPlugin_Tools::resetAttribute(this, FIRST_POINT_ID()); + SketchPlugin_Tools::resetAttribute(this, FIRST_POINT_REF_ID()); + SketchPlugin_Tools::resetAttribute(this, SECOND_POINT_ID()); + SketchPlugin_Tools::resetAttribute(this, SECOND_POINT_REF_ID()); + SketchPlugin_Tools::resetAttribute(this, THIRD_POINT_ID()); + SketchPlugin_Tools::resetAttribute(this, THIRD_POINT_REF_ID()); } myCenter.reset(); myRadius = 0; @@ -296,11 +299,3 @@ void SketchPlugin_MacroCircle::attributeChanged(const std::string& theID) { aRadiusAttr->setValue(myRadius); data()->blockSendAttributeUpdated(aWasBlocked, false); } - -void SketchPlugin_MacroCircle::resetAttribute(const std::string& theId) -{ - AttributePtr anAttr = attribute(theId); - if(anAttr.get()) { - anAttr->reset(); - } -} diff --git a/src/SketchPlugin/SketchPlugin_MacroCircle.h b/src/SketchPlugin/SketchPlugin_MacroCircle.h index bc387acd5..05a2d301b 100644 --- a/src/SketchPlugin/SketchPlugin_MacroCircle.h +++ b/src/SketchPlugin/SketchPlugin_MacroCircle.h @@ -163,8 +163,6 @@ class SketchPlugin_MacroCircle: public SketchPlugin_SketchEntity, SketchPlugin_MacroCircle(); private: - void resetAttribute(const std::string& theId); - void createCircleByCenterAndPassed(); void createCircleByThreePoints(); diff --git a/src/SketchPlugin/SketchPlugin_Plugin.cpp b/src/SketchPlugin/SketchPlugin_Plugin.cpp index e5d4771a6..586176f31 100644 --- a/src/SketchPlugin/SketchPlugin_Plugin.cpp +++ b/src/SketchPlugin/SketchPlugin_Plugin.cpp @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -178,6 +179,8 @@ FeaturePtr SketchPlugin_Plugin::createFeature(std::string theFeatureID) return FeaturePtr(new SketchPlugin_ConstraintAngle); } else if (theFeatureID == SketchPlugin_Trim::ID()) { return FeaturePtr(new SketchPlugin_Trim); + } else if (theFeatureID == SketchPlugin_MacroArc::ID()) { + return FeaturePtr(new SketchPlugin_MacroArc); } else if (theFeatureID == SketchPlugin_MacroCircle::ID()) { return FeaturePtr(new SketchPlugin_MacroCircle); } @@ -243,6 +246,7 @@ std::shared_ptr SketchPlugin_Plugin aMsg->setState(SketchPlugin_MultiRotation::ID(), aHasSketchPlane); aMsg->setState(SketchPlugin_MultiTranslation::ID(), aHasSketchPlane); aMsg->setState(SketchPlugin_Trim::ID(), aHasSketchPlane); + aMsg->setState(SketchPlugin_MacroArc::ID(), aHasSketchPlane); aMsg->setState(SketchPlugin_MacroCircle::ID(), aHasSketchPlane); // SketchRectangle is a python feature, so its ID is passed just as a string aMsg->setState("SketchRectangle", aHasSketchPlane); diff --git a/src/SketchPlugin/SketchPlugin_Tools.cpp b/src/SketchPlugin/SketchPlugin_Tools.cpp index 7af4e9af1..9a4d82f84 100644 --- a/src/SketchPlugin/SketchPlugin_Tools.cpp +++ b/src/SketchPlugin/SketchPlugin_Tools.cpp @@ -106,6 +106,15 @@ void findCoincidences(const FeaturePtr theStartCoin, } } +void resetAttribute(SketchPlugin_Feature* theFeature, + const std::string& theId) +{ + AttributePtr anAttr = theFeature->attribute(theId); + if(anAttr.get()) { + anAttr->reset(); + } +} + void createConstraint(SketchPlugin_Feature* theFeature, const std::string& theId, const AttributePtr theAttr, diff --git a/src/SketchPlugin/SketchPlugin_Tools.h b/src/SketchPlugin/SketchPlugin_Tools.h index ef26d67c0..6d588b5d3 100644 --- a/src/SketchPlugin/SketchPlugin_Tools.h +++ b/src/SketchPlugin/SketchPlugin_Tools.h @@ -31,6 +31,8 @@ void findCoincidences(const FeaturePtr theStartCoin, const std::string& theAttr, std::set& theList); +void resetAttribute(SketchPlugin_Feature* theFeature, const std::string& theId); + /// Creates coincidence or tangent constraint. /// \param[in] theFeature to get selected attribute or object /// \param[in] theId ID of attribute where selection is. diff --git a/src/SketchPlugin/plugin-Sketch.xml b/src/SketchPlugin/plugin-Sketch.xml index 6ad5fdc9a..0667afb9b 100644 --- a/src/SketchPlugin/plugin-Sketch.xml +++ b/src/SketchPlugin/plugin-Sketch.xml @@ -6,7 +6,7 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - @@ -419,15 +514,15 @@ - + - + - - + +