From 3d334d153d7444756ba3e4a60f4852de08929a95 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Sat, 2 Apr 2016 14:29:32 +0600 Subject: [PATCH] Disable autoconstrainer while Ctrl is held. --- src/draw.cpp | 6 ++---- src/mouse.cpp | 18 ++++++++++-------- src/ui.h | 34 +++++++++++++++++++--------------- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/draw.cpp b/src/draw.cpp index 09981c2..7a0961f 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -719,13 +719,11 @@ nogrid:; // Draw the "pending" constraint, i.e. a constraint that would be // placed on a line that is almost horizontal or vertical if(SS.GW.pending.operation == DRAGGING_NEW_LINE_POINT) { - SuggestedConstraint suggested = - SS.GW.SuggestLineConstraint(SS.GW.pending.request); - if(suggested != GraphicsWindow::SUGGESTED_NONE) { + if(SS.GW.pending.suggestion != GraphicsWindow::SUGGESTED_NONE) { Constraint c = {}; c.group = SS.GW.activeGroup; c.workplane = SS.GW.ActiveWorkplane(); - c.type = suggested; + c.type = SS.GW.pending.suggestion; c.ptA = Entity::NO_ENTITY; c.ptB = Entity::NO_ENTITY; c.entityA = SS.GW.pending.request.entity(0); diff --git a/src/mouse.cpp b/src/mouse.cpp index 8adce35..e44b143 100644 --- a/src/mouse.cpp +++ b/src/mouse.cpp @@ -280,6 +280,12 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown, } case DRAGGING_NEW_LINE_POINT: + if(!ctrlDown) { + SS.GW.pending.suggestion = + SS.GW.SuggestLineConstraint(SS.GW.pending.request); + } else { + SS.GW.pending.suggestion = SUGGESTED_NONE; + } case DRAGGING_NEW_POINT: UpdateDraggedPoint(pending.point, x, y); HitTestMakeSelection(mp); @@ -506,10 +512,8 @@ void GraphicsWindow::MouseRightUp(double x, double y) { if(context.active) return; if(pending.operation == DRAGGING_NEW_LINE_POINT) { - SuggestedConstraint suggested = - SS.GW.SuggestLineConstraint(SS.GW.pending.request); - if(suggested != SUGGESTED_NONE) { - Constraint::Constrain(suggested, + if(SS.GW.pending.suggestion != SUGGESTED_NONE) { + Constraint::Constrain(SS.GW.pending.suggestion, Entity::NO_ENTITY, Entity::NO_ENTITY, pending.request.entity(0)); } } @@ -1033,10 +1037,8 @@ void GraphicsWindow::MouseLeftDown(double mx, double my) { case DRAGGING_NEW_LINE_POINT: { // Constrain the line segment horizontal or vertical if close enough - SuggestedConstraint suggested = - SS.GW.SuggestLineConstraint(SS.GW.pending.request); - if(suggested != SUGGESTED_NONE) { - Constraint::Constrain(suggested, + if(SS.GW.pending.suggestion != SUGGESTED_NONE) { + Constraint::Constrain(SS.GW.pending.suggestion, Entity::NO_ENTITY, Entity::NO_ENTITY, pending.request.entity(0)); } diff --git a/src/ui.h b/src/ui.h index b5a1720..3e4cce8 100644 --- a/src/ui.h +++ b/src/ui.h @@ -545,27 +545,31 @@ public: DRAGGING_NEW_RADIUS = 0x0f000008, DRAGGING_MARQUEE = 0x0f000009 }; - struct { - int operation; - - hRequest request; - hEntity point; - List points; - hEntity circle; - hEntity normal; - hConstraint constraint; - - const char *description; - } pending; - void ClearPending(void); - // The constraint that is being edited with the on-screen textbox. - hConstraint constraintBeingEdited; enum SuggestedConstraint { SUGGESTED_NONE = 0, SUGGESTED_HORIZONTAL = Constraint::HORIZONTAL, SUGGESTED_VERTICAL = Constraint::VERTICAL, }; + + struct { + int operation; + + hRequest request; + hEntity point; + List points; + hEntity circle; + hEntity normal; + hConstraint constraint; + + const char *description; + + SuggestedConstraint suggestion; + } pending; + void ClearPending(void); + // The constraint that is being edited with the on-screen textbox. + hConstraint constraintBeingEdited; + SuggestedConstraint SuggestLineConstraint(hRequest lineSegment); Vector SnapToGrid(Vector p);