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
// 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);

View File

@ -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));
}

View File

@ -545,27 +545,31 @@ public:
DRAGGING_NEW_RADIUS = 0x0f000008,
DRAGGING_MARQUEE = 0x0f000009
};
struct {
int operation;
hRequest request;
hEntity point;
List<hEntity> 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<hEntity> 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);