From: azv Date: Tue, 1 Oct 2019 09:32:48 +0000 (+0300) Subject: Task 2.12. New entities: ellipses and arcs of ellipses (issue #3003) X-Git-Tag: V9_4_0a2~4^2~43 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1094e3d37abe41c23dc21a3c02d6da218061cf7b;p=modules%2Fshaper.git Task 2.12. New entities: ellipses and arcs of ellipses (issue #3003) Constraints on-the-fly for elliptic arcs. --- diff --git a/src/SketchPlugin/SketchPlugin_MacroEllipticArc.cpp b/src/SketchPlugin/SketchPlugin_MacroEllipticArc.cpp index ab87ca57f..984a75926 100644 --- a/src/SketchPlugin/SketchPlugin_MacroEllipticArc.cpp +++ b/src/SketchPlugin/SketchPlugin_MacroEllipticArc.cpp @@ -83,6 +83,7 @@ void SketchPlugin_MacroEllipticArc::initAttributes() void SketchPlugin_MacroEllipticArc::execute() { FeaturePtr anEllipse = createEllipticArcFeature(); + constraintsForEllipticArc(anEllipse); // message to init reentrant operation static Events_ID anId = SketchPlugin_MacroArcReentrantMessage::eventId(); @@ -301,6 +302,32 @@ FeaturePtr SketchPlugin_MacroEllipticArc::createEllipticArcFeature() return aEllipseFeature; } +void SketchPlugin_MacroEllipticArc::constraintsForEllipticArc(FeaturePtr theEllipticArc) +{ + // tangency on-the-fly is not applicable for elliptic arcs + static const bool isTangencyApplicable = false; + // Create constraints. + SketchPlugin_Tools::createCoincidenceOrTangency( + this, CENTER_REF_ID(), + theEllipticArc->attribute(SketchPlugin_EllipticArc::CENTER_ID()), + ObjectPtr(), isTangencyApplicable); + // make coincidence only if PASSED_POINT_REF_ID() refers a point but not an object + if (!refattr(MAJOR_AXIS_POINT_REF_ID())->isObject()) { + SketchPlugin_Tools::createCoincidenceOrTangency( + this, MAJOR_AXIS_POINT_REF_ID(), + AttributePtr(), + theEllipticArc->lastResult(), isTangencyApplicable); + } + SketchPlugin_Tools::createCoincidenceOrTangency( + this, START_POINT_REF_ID(), + theEllipticArc->attribute(SketchPlugin_EllipticArc::START_POINT_ID()), + ObjectPtr(), isTangencyApplicable); + SketchPlugin_Tools::createCoincidenceOrTangency( + this, END_POINT_REF_ID(), + theEllipticArc->attribute(SketchPlugin_EllipticArc::END_POINT_ID()), + ObjectPtr(), isTangencyApplicable); +} + AISObjectPtr SketchPlugin_MacroEllipticArc::getAISObject(AISObjectPtr thePrevious) { SketchPlugin_Sketch* aSketch = sketch(); diff --git a/src/SketchPlugin/SketchPlugin_MacroEllipticArc.h b/src/SketchPlugin/SketchPlugin_MacroEllipticArc.h index 5c43f6784..296d43173 100644 --- a/src/SketchPlugin/SketchPlugin_MacroEllipticArc.h +++ b/src/SketchPlugin/SketchPlugin_MacroEllipticArc.h @@ -36,7 +36,7 @@ class SketchPlugin_MacroEllipticArc: public SketchPlugin_SketchEntity, public GeomAPI_IPresentable, public ModelAPI_IReentrant { - public: +public: /// Elliptic arc feature kind inline static const std::string& ID() { @@ -159,6 +159,7 @@ private: std::shared_ptr getArcShape(); FeaturePtr createEllipticArcFeature(); + void constraintsForEllipticArc(FeaturePtr theEllipticArc); private: std::shared_ptr myCenter;