From e40929afcafa572ef6e2fdde830f64ac71acb9eb Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 6 Jul 2015 05:20:18 +0300 Subject: [PATCH] Add a shortcut for adding a reference dimension or angle. This is equivalent to adding a constraint, then making it a reference. The benefits are that: * it's quicker; * it avoids having an over-constrained system, with an associated angry red flash and a regeneration delay. The latter in particular is a very substantial usability improvement. The reference distance command is useful most of the time, but the reference angle one is also added for consistency. --- src/constraint.cpp | 15 +++++++++++++-- src/graphicswin.cpp | 2 ++ src/ui.h | 2 ++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/constraint.cpp b/src/constraint.cpp index 933f52e..8a02397 100644 --- a/src/constraint.cpp +++ b/src/constraint.cpp @@ -124,7 +124,8 @@ void Constraint::MenuConstrain(int id) { #define gs (SS.GW.gs) switch(id) { - case GraphicsWindow::MNU_DISTANCE_DIA: { + case GraphicsWindow::MNU_DISTANCE_DIA: + case GraphicsWindow::MNU_REF_DISTANCE: { if(gs.points == 2 && gs.n == 2) { c.type = PT_PT_DISTANCE; c.ptA = gs.point[0]; @@ -177,6 +178,10 @@ void Constraint::MenuConstrain(int id) { c.disp.offset = Vector::From(0, 0, 0); } + if(id == GraphicsWindow::MNU_REF_DISTANCE) { + c.reference = true; + } + c.valA = 0; c.ModifyToSatisfy(); AddConstraint(&c); @@ -535,7 +540,8 @@ void Constraint::MenuConstrain(int id) { Error("Must select a constraint with associated label."); return; - case GraphicsWindow::MNU_ANGLE: { + case GraphicsWindow::MNU_ANGLE: + case GraphicsWindow::MNU_REF_ANGLE: { if(gs.vectors == 2 && gs.n == 2) { c.type = ANGLE; c.entityA = gs.vector[0]; @@ -568,6 +574,11 @@ void Constraint::MenuConstrain(int id) { // no shared point; not clear which intersection to draw } } + + if(id == GraphicsWindow::MNU_REF_ANGLE) { + c.reference = true; + } + c.ModifyToSatisfy(); AddConstraint(&c); break; diff --git a/src/graphicswin.cpp b/src/graphicswin.cpp index 4a4576e..33fe9b5 100644 --- a/src/graphicswin.cpp +++ b/src/graphicswin.cpp @@ -126,7 +126,9 @@ const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = { { 0, "&Constrain", 0, 0, IN, NULL }, { 1, "&Distance / Diameter", MNU_DISTANCE_DIA, 'D', IN, mCon }, +{ 1, "Re&ference Dimension", MNU_REF_DISTANCE, S|'D', IN, mCon }, { 1, "A&ngle", MNU_ANGLE, 'N', IN, mCon }, +{ 1, "Reference An&gle", MNU_REF_ANGLE, S|'N', IN, mCon }, { 1, "Other S&upplementary Angle", MNU_OTHER_ANGLE, 'U', IN, mCon }, { 1, "Toggle R&eference Dim", MNU_REFERENCE, 'E', IN, mCon }, { 1, NULL, 0, 0, IN, NULL }, diff --git a/src/ui.h b/src/ui.h index 69c13f9..42d727e 100644 --- a/src/ui.h +++ b/src/ui.h @@ -396,7 +396,9 @@ public: MNU_GROUP_RECENT, // Constrain MNU_DISTANCE_DIA, + MNU_REF_DISTANCE, MNU_ANGLE, + MNU_REF_ANGLE, MNU_OTHER_ANGLE, MNU_REFERENCE, MNU_EQUAL,