Disable autoconstrainer while Ctrl is held.

This commit is contained in:
EvilSpirit 2016-04-02 14:29:32 +06:00 committed by whitequark
parent 6f67ec2d48
commit 3d334d153d
3 changed files with 31 additions and 27 deletions

View File

@ -719,13 +719,11 @@ nogrid:;
// Draw the "pending" constraint, i.e. a constraint that would be // Draw the "pending" constraint, i.e. a constraint that would be
// placed on a line that is almost horizontal or vertical // placed on a line that is almost horizontal or vertical
if(SS.GW.pending.operation == DRAGGING_NEW_LINE_POINT) { if(SS.GW.pending.operation == DRAGGING_NEW_LINE_POINT) {
SuggestedConstraint suggested = if(SS.GW.pending.suggestion != GraphicsWindow::SUGGESTED_NONE) {
SS.GW.SuggestLineConstraint(SS.GW.pending.request);
if(suggested != GraphicsWindow::SUGGESTED_NONE) {
Constraint c = {}; Constraint c = {};
c.group = SS.GW.activeGroup; c.group = SS.GW.activeGroup;
c.workplane = SS.GW.ActiveWorkplane(); c.workplane = SS.GW.ActiveWorkplane();
c.type = suggested; c.type = SS.GW.pending.suggestion;
c.ptA = Entity::NO_ENTITY; c.ptA = Entity::NO_ENTITY;
c.ptB = Entity::NO_ENTITY; c.ptB = Entity::NO_ENTITY;
c.entityA = SS.GW.pending.request.entity(0); c.entityA = SS.GW.pending.request.entity(0);

View File

@ -280,6 +280,12 @@ void GraphicsWindow::MouseMoved(double x, double y, bool leftDown,
} }
case DRAGGING_NEW_LINE_POINT: 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: case DRAGGING_NEW_POINT:
UpdateDraggedPoint(pending.point, x, y); UpdateDraggedPoint(pending.point, x, y);
HitTestMakeSelection(mp); HitTestMakeSelection(mp);
@ -506,10 +512,8 @@ void GraphicsWindow::MouseRightUp(double x, double y) {
if(context.active) return; if(context.active) return;
if(pending.operation == DRAGGING_NEW_LINE_POINT) { if(pending.operation == DRAGGING_NEW_LINE_POINT) {
SuggestedConstraint suggested = if(SS.GW.pending.suggestion != SUGGESTED_NONE) {
SS.GW.SuggestLineConstraint(SS.GW.pending.request); Constraint::Constrain(SS.GW.pending.suggestion,
if(suggested != SUGGESTED_NONE) {
Constraint::Constrain(suggested,
Entity::NO_ENTITY, Entity::NO_ENTITY, pending.request.entity(0)); 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: { case DRAGGING_NEW_LINE_POINT: {
// Constrain the line segment horizontal or vertical if close enough // Constrain the line segment horizontal or vertical if close enough
SuggestedConstraint suggested = if(SS.GW.pending.suggestion != SUGGESTED_NONE) {
SS.GW.SuggestLineConstraint(SS.GW.pending.request); Constraint::Constrain(SS.GW.pending.suggestion,
if(suggested != SUGGESTED_NONE) {
Constraint::Constrain(suggested,
Entity::NO_ENTITY, Entity::NO_ENTITY, pending.request.entity(0)); Entity::NO_ENTITY, Entity::NO_ENTITY, pending.request.entity(0));
} }

View File

@ -545,6 +545,13 @@ public:
DRAGGING_NEW_RADIUS = 0x0f000008, DRAGGING_NEW_RADIUS = 0x0f000008,
DRAGGING_MARQUEE = 0x0f000009 DRAGGING_MARQUEE = 0x0f000009
}; };
enum SuggestedConstraint {
SUGGESTED_NONE = 0,
SUGGESTED_HORIZONTAL = Constraint::HORIZONTAL,
SUGGESTED_VERTICAL = Constraint::VERTICAL,
};
struct { struct {
int operation; int operation;
@ -556,16 +563,13 @@ public:
hConstraint constraint; hConstraint constraint;
const char *description; const char *description;
SuggestedConstraint suggestion;
} pending; } pending;
void ClearPending(void); void ClearPending(void);
// The constraint that is being edited with the on-screen textbox. // The constraint that is being edited with the on-screen textbox.
hConstraint constraintBeingEdited; hConstraint constraintBeingEdited;
enum SuggestedConstraint {
SUGGESTED_NONE = 0,
SUGGESTED_HORIZONTAL = Constraint::HORIZONTAL,
SUGGESTED_VERTICAL = Constraint::VERTICAL,
};
SuggestedConstraint SuggestLineConstraint(hRequest lineSegment); SuggestedConstraint SuggestLineConstraint(hRequest lineSegment);
Vector SnapToGrid(Vector p); Vector SnapToGrid(Vector p);