From be8e5ac338f4509463404cd79f4b8222bf2573bf Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 6 Dec 2020 10:53:37 +0100 Subject: [PATCH] GCS: Simple refactor magic numbers into enum ============================================ A new enum to remove magic numbers for constraint tags. A previous version of the commit introduced more magic numbers, which demonstrated not to be up for the task. About the Tag numbers: - Positive Tags identify a higher level constraint form which the solver constraint originates - Negative Tags represent temporary constraints, used for example in moving operations, these have a different handling in component splitting, see GCS::initSolution. Lifetime is defined by the container object via GCS::clearByTag - Hardcoded value -1 is used for these constraints.The effect is parameters are not truly enforced (it gives a nice effect when dragging the edge of an unconstrained circle, that the center won't move if the edge can be dragged, and only when/if the edge cannot be dragged, e.g. radius constraint, the center is moved). --- src/Mod/Sketcher/App/planegcs/GCS.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/Mod/Sketcher/App/planegcs/GCS.h b/src/Mod/Sketcher/App/planegcs/GCS.h index bd6484a93c..85a5fd7130 100644 --- a/src/Mod/Sketcher/App/planegcs/GCS.h +++ b/src/Mod/Sketcher/App/planegcs/GCS.h @@ -69,6 +69,19 @@ namespace GCS IterationLevel = 2 }; + // Magic numbers for Constraint tags + // - Positive Tags identify a higher level constraint form which the solver constraint originates + // - Negative Tags represent temporary constraints, used for example in moving operations, these + // have a different handling in component splitting, see GCS::initSolution. Lifetime is defined by + // the container object via GCS::clearByTag. + // - -1 is typically used as tag for these temporary constraints, its parameters are enforced with + // a lower priority than the main system (real sketcher constraints). It gives a nice effect when + // dragging the edge of an unconstrained circle, that the center won't move if the edge can be dragged, + // and only when/if the edge cannot be dragged, e.g. radius constraint, the center is moved). + enum SpecialTag { + DefaultTemporaryConstraint = -1 + }; + class System { // This is the main class. It holds all constraints and information