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.
This commit is contained in:
whitequark 2015-07-06 05:20:18 +03:00
parent 4b02bf1e81
commit e40929afca
3 changed files with 17 additions and 2 deletions

View File

@ -124,7 +124,8 @@ void Constraint::MenuConstrain(int id) {
#define gs (SS.GW.gs) #define gs (SS.GW.gs)
switch(id) { switch(id) {
case GraphicsWindow::MNU_DISTANCE_DIA: { case GraphicsWindow::MNU_DISTANCE_DIA:
case GraphicsWindow::MNU_REF_DISTANCE: {
if(gs.points == 2 && gs.n == 2) { if(gs.points == 2 && gs.n == 2) {
c.type = PT_PT_DISTANCE; c.type = PT_PT_DISTANCE;
c.ptA = gs.point[0]; c.ptA = gs.point[0];
@ -177,6 +178,10 @@ void Constraint::MenuConstrain(int id) {
c.disp.offset = Vector::From(0, 0, 0); c.disp.offset = Vector::From(0, 0, 0);
} }
if(id == GraphicsWindow::MNU_REF_DISTANCE) {
c.reference = true;
}
c.valA = 0; c.valA = 0;
c.ModifyToSatisfy(); c.ModifyToSatisfy();
AddConstraint(&c); AddConstraint(&c);
@ -535,7 +540,8 @@ void Constraint::MenuConstrain(int id) {
Error("Must select a constraint with associated label."); Error("Must select a constraint with associated label.");
return; return;
case GraphicsWindow::MNU_ANGLE: { case GraphicsWindow::MNU_ANGLE:
case GraphicsWindow::MNU_REF_ANGLE: {
if(gs.vectors == 2 && gs.n == 2) { if(gs.vectors == 2 && gs.n == 2) {
c.type = ANGLE; c.type = ANGLE;
c.entityA = gs.vector[0]; c.entityA = gs.vector[0];
@ -568,6 +574,11 @@ void Constraint::MenuConstrain(int id) {
// no shared point; not clear which intersection to draw // no shared point; not clear which intersection to draw
} }
} }
if(id == GraphicsWindow::MNU_REF_ANGLE) {
c.reference = true;
}
c.ModifyToSatisfy(); c.ModifyToSatisfy();
AddConstraint(&c); AddConstraint(&c);
break; break;

View File

@ -126,7 +126,9 @@ const GraphicsWindow::MenuEntry GraphicsWindow::menu[] = {
{ 0, "&Constrain", 0, 0, IN, NULL }, { 0, "&Constrain", 0, 0, IN, NULL },
{ 1, "&Distance / Diameter", MNU_DISTANCE_DIA, 'D', IN, mCon }, { 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, "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, "Other S&upplementary Angle", MNU_OTHER_ANGLE, 'U', IN, mCon },
{ 1, "Toggle R&eference Dim", MNU_REFERENCE, 'E', IN, mCon }, { 1, "Toggle R&eference Dim", MNU_REFERENCE, 'E', IN, mCon },
{ 1, NULL, 0, 0, IN, NULL }, { 1, NULL, 0, 0, IN, NULL },

View File

@ -396,7 +396,9 @@ public:
MNU_GROUP_RECENT, MNU_GROUP_RECENT,
// Constrain // Constrain
MNU_DISTANCE_DIA, MNU_DISTANCE_DIA,
MNU_REF_DISTANCE,
MNU_ANGLE, MNU_ANGLE,
MNU_REF_ANGLE,
MNU_OTHER_ANGLE, MNU_OTHER_ANGLE,
MNU_REFERENCE, MNU_REFERENCE,
MNU_EQUAL, MNU_EQUAL,