From 02e370d392ecb7e71177c0d99be99a45e86d6fda Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Mon, 27 Feb 2017 15:44:11 +0100 Subject: [PATCH] Sketcher: Enable reuse of constraint helper functions in other toolbars ======================================================================= bool checkBothExternal(int GeoId1, int GeoId2); void getIdsFromName(const std::string &name, const Sketcher::SketchObject* Obj, int &GeoId, Sketcher::PointPos &PosId); bool inline isVertex(int GeoId, Sketcher::PointPos PosId); bool inline isEdge(int GeoId, Sketcher::PointPos PosId); bool isSimpleVertex(const Sketcher::SketchObject* Obj, int GeoId, Sketcher::PointPos PosId); bool IsPointAlreadyOnCurve(int GeoIdCurve, int GeoIdPoint, Sketcher::PointPos PosIdPoint, Sketcher::SketchObject* Obj); --- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 12 ++++++------ src/Mod/Sketcher/Gui/CommandConstraints.h | 16 ++++++++++++++++ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 3a629ba05b..8251967e4b 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -249,7 +249,7 @@ void showNoConstraintBetweenExternal() QObject::tr("Cannot add a constraint between two external geometries!")); } -bool checkBothExternal(int GeoId1, int GeoId2) +bool SketcherGui::checkBothExternal(int GeoId1, int GeoId2) { if (GeoId1 == Constraint::GeoUndef || GeoId2 == Constraint::GeoUndef) return false; @@ -257,7 +257,7 @@ bool checkBothExternal(int GeoId1, int GeoId2) return (GeoId1 < 0 && GeoId2 < 0); } -void getIdsFromName(const std::string &name, const Sketcher::SketchObject* Obj, +void SketcherGui::getIdsFromName(const std::string &name, const Sketcher::SketchObject* Obj, int &GeoId, PointPos &PosId) { GeoId = Constraint::GeoUndef; @@ -282,17 +282,17 @@ void getIdsFromName(const std::string &name, const Sketcher::SketchObject* Obj, } } -bool inline isVertex(int GeoId, PointPos PosId) +bool inline SketcherGui::isVertex(int GeoId, PointPos PosId) { return (GeoId != Constraint::GeoUndef && PosId != Sketcher::none); } -bool inline isEdge(int GeoId, PointPos PosId) +bool inline SketcherGui::isEdge(int GeoId, PointPos PosId) { return (GeoId != Constraint::GeoUndef && PosId == Sketcher::none); } -bool isSimpleVertex(const Sketcher::SketchObject* Obj, int GeoId, PointPos PosId) +bool SketcherGui::isSimpleVertex(const Sketcher::SketchObject* Obj, int GeoId, PointPos PosId) { if (PosId == Sketcher::start && (GeoId == Sketcher::GeoEnum::HAxis || GeoId == Sketcher::GeoEnum::VAxis)) return true; @@ -305,7 +305,7 @@ bool isSimpleVertex(const Sketcher::SketchObject* Obj, int GeoId, PointPos PosId return false; } -bool IsPointAlreadyOnCurve(int GeoIdCurve, int GeoIdPoint, Sketcher::PointPos PosIdPoint, Sketcher::SketchObject* Obj) +bool SketcherGui::IsPointAlreadyOnCurve(int GeoIdCurve, int GeoIdPoint, Sketcher::PointPos PosIdPoint, Sketcher::SketchObject* Obj) { //This func is a "smartness" behind three-element tangent-, perp.- and angle-via-point. //We want to find out, if the point supplied by user is already on diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.h b/src/Mod/Sketcher/Gui/CommandConstraints.h index 2b25ac95f6..9efb6a6cab 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.h +++ b/src/Mod/Sketcher/Gui/CommandConstraints.h @@ -24,8 +24,24 @@ #ifndef SKETCHERGUI_CommandConstraints_H #define SKETCHERGUI_CommandConstraints_H +#include +#include + namespace SketcherGui { +bool checkBothExternal(int GeoId1, int GeoId2); + +void getIdsFromName(const std::string &name, const Sketcher::SketchObject* Obj, int &GeoId, Sketcher::PointPos &PosId); + +bool inline isVertex(int GeoId, Sketcher::PointPos PosId); + +bool inline isEdge(int GeoId, Sketcher::PointPos PosId); + +bool isSimpleVertex(const Sketcher::SketchObject* Obj, int GeoId, Sketcher::PointPos PosId); + +bool IsPointAlreadyOnCurve(int GeoIdCurve, int GeoIdPoint, Sketcher::PointPos PosIdPoint, Sketcher::SketchObject* Obj); + + // These functions are declared here to promote code reuse from other modules /// Makes a tangency constraint using external construction line between