Sketcher: GeoId, GeoElementId and GeoUndef refactor

===================================================

This commit is an independent refactor of the identifications used at Sketcher level.

It introduces a new type "GeoElementId" as a combination of GeoId and PointPos.

It moves the Undefined GeoId, previous Constraint::GeoUndef to GeoEnum, together with all
other fixed values of GeoIds.
This commit is contained in:
Abdullah Tahiri
2021-12-11 14:40:21 +01:00
parent 56d86df5bb
commit bb76be1371
20 changed files with 277 additions and 192 deletions

View File

@@ -317,7 +317,8 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
int preSelPnt = sketchgui->getPreselectPoint();
int preSelCrv = sketchgui->getPreselectCurve();
int preSelCrs = sketchgui->getPreselectCross();
int GeoId = Constraint::GeoUndef;
int GeoId = GeoEnum::GeoUndef;
Sketcher::PointPos PosId = Sketcher::none;
if (preSelPnt != -1)
sketchgui->getSketchObject()->getGeoVertexIndex(preSelPnt, GeoId, PosId);
@@ -345,7 +346,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
hitShapeDir = Base::Vector3d(0,1,0);
}
if (GeoId != Constraint::GeoUndef) {
if (GeoId != GeoEnum::GeoUndef) {
const Part::Geometry * hitobject = sketchgui->getSketchObject()->getGeometry(GeoId);
@@ -392,7 +393,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
AutoConstraint constr;
constr.Type = Sketcher::None;
constr.GeoId = Constraint::GeoUndef;
constr.GeoId = GeoEnum::GeoUndef;
constr.PosId = Sketcher::none;
double angle = std::abs(atan2(Dir.y, Dir.x));
if (angle < angleDevRad || (M_PI - angle) < angleDevRad )
@@ -410,7 +411,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
// Find if there are tangent constraints (currently arcs and circles)
int tangId = Constraint::GeoUndef;
int tangId = GeoEnum::GeoUndef;
// Do not consider if distance is more than that.
// Decrease this value when a candidate is found.
@@ -552,7 +553,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
}
}
if (tangId != Constraint::GeoUndef) {
if (tangId != GeoEnum::GeoUndef) {
if (tangId > getHighestCurveIndex()) // external Geometry
tangId = getHighestCurveIndex() - tangId;
// Suggest vertical constraint
@@ -608,11 +609,11 @@ void DrawSketchHandler::createAutoConstraints(const std::vector<AutoConstraint>
// In this case the caller as to set geoId2, then it will be used as target instead of geoId2
case Sketcher::Horizontal: {
Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Horizontal',%i)) ",
geoId2 != Constraint::GeoUndef ? geoId2 : geoId1);
geoId2 != GeoEnum::GeoUndef ? geoId2 : geoId1);
} break;
case Sketcher::Vertical: {
Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Vertical',%i)) ",
geoId2 != Constraint::GeoUndef ? geoId2 : geoId1);
geoId2 != GeoEnum::GeoUndef ? geoId2 : geoId1);
} break;
case Sketcher::Tangent: {
Sketcher::SketchObject* Obj = static_cast<Sketcher::SketchObject*>(sketchgui->getObject());