Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 30 additions & 28 deletions src/constraint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,8 @@ void Constraint::MenuConstrain(Command id) {

c.valA = 0;
c.ModifyToSatisfy();
AddConstraint(&c);
newcons.push_back(c);
for (auto&& nc:newcons)
AddConstraint(&nc);
break;
}

Expand Down Expand Up @@ -301,8 +300,8 @@ void Constraint::MenuConstrain(Command id) {
" * a point and a plane face (point on face)\n"));
return;
}
newcons.push_back(c);
AddConstraint(&c);
newcons.push_back(c);
break;

case Command::EQUAL:
Expand Down Expand Up @@ -385,6 +384,7 @@ void Constraint::MenuConstrain(Command id) {
"(line segment length equals arc length)\n"));
return;
}
SS.UndoRemember();
for (auto&& nc : newcons){
if(nc.type == Type::EQUAL_ANGLE) {
// Infer the nearest supplementary angle from the sketch.
Expand All @@ -398,7 +398,7 @@ void Constraint::MenuConstrain(Command id) {
nc.other = true;
}
}
AddConstraint(&nc);
AddConstraint(&nc, /*rememberForUndo=*/false);
}
break;

Expand Down Expand Up @@ -433,8 +433,8 @@ void Constraint::MenuConstrain(Command id) {

c.valA = 0;
c.ModifyToSatisfy();
newcons.push_back(c);
AddConstraint(&c);
newcons.push_back(c);
break;

case Command::DIFFERENCE:
Expand Down Expand Up @@ -468,8 +468,8 @@ void Constraint::MenuConstrain(Command id) {

c.valA = 0;
c.ModifyToSatisfy();
newcons.push_back(c);
AddConstraint(&c);
newcons.push_back(c);
break;

case Command::AT_MIDPOINT:
Expand All @@ -482,16 +482,16 @@ void Constraint::MenuConstrain(Command id) {
// it on-line; so auto-remove that. Handle as one undo group.
SS.UndoRemember();
DeleteAllConstraintsFor(Type::PT_ON_LINE, c.entityA, c.ptA);
newcons.push_back(c);
AddConstraint(&c, /*rememberForUndo=*/false);
newcons.push_back(c);
break;
} else if(gs.lineSegments == 1 && gs.workplanes == 1 && gs.n == 2) {
c.type = Type::AT_MIDPOINT;
int i = SK.GetEntity(gs.entity[0])->IsWorkplane() ? 1 : 0;
c.entityA = gs.entity[i];
c.entityB = gs.entity[1-i];
newcons.push_back(c);
AddConstraint(&c);
newcons.push_back(c);
} else {
Error(_("Bad selection for at midpoint constraint. This "
"constraint can apply to:\n\n"
Expand Down Expand Up @@ -594,13 +594,17 @@ void Constraint::MenuConstrain(Command id) {
break;
}
}
newcons.push_back(c);
AddConstraint(&c);
newcons.push_back(c);
break;

case Command::VERTICAL:
case Command::HORIZONTAL: {
hEntity ha, hb;
if(id == Command::HORIZONTAL) {
c.type = Type::HORIZONTAL;
} else {
c.type = Type::VERTICAL;
}
if(c.workplane == Entity::FREE_IN_3D) {
Error(_("Activate a workplane (with Sketch -> In Workplane) before "
"applying a horizontal or vertical constraint."));
Expand All @@ -609,28 +613,24 @@ void Constraint::MenuConstrain(Command id) {
if(gs.lineSegments > 0 && gs.lineSegments == gs.n) {
for (auto enti : gs.entity){
c.entityA = enti;
if(id == Command::HORIZONTAL) {
c.type = Type::HORIZONTAL;
} else {
c.type = Type::VERTICAL;
}
newcons.push_back(c);
}
Entity *e = SK.GetEntity(c.entityA);
ha = e->point[0];
hb = e->point[1];
} else if(gs.points == 2 && gs.n == 2) {
ha = c.ptA = gs.point[0];
hb = c.ptB = gs.point[1];
} else if(gs.points >= 2 && gs.n == gs.points) {
c.ptA = gs.point[0];
for (int k = 1; k<gs.points; k++) {
c.ptB = gs.point[k];
newcons.push_back(c);
}
} else {
Error(_("Bad selection for horizontal / vertical constraint. "
"This constraint can apply to:\n\n"
" * two points\n"
" * a line segment\n"));
return;
}
SS.UndoRemember();
for (auto && nc: newcons)
AddConstraint(&nc);
AddConstraint(&nc, /*rememberForUndo=*/false);
break;
}

Expand Down Expand Up @@ -670,8 +670,8 @@ void Constraint::MenuConstrain(Command id) {

nfree->NormalForceTo(Quaternion::From(fu, fv));
}
newcons.push_back(c);
AddConstraint(&c, /*rememberForUndo=*/false);
newcons.push_back(c);
break;
}

Expand Down Expand Up @@ -747,8 +747,8 @@ void Constraint::MenuConstrain(Command id) {
}

c.ModifyToSatisfy();
newcons.push_back(c);
AddConstraint(&c);
newcons.push_back(c);
break;
}

Expand All @@ -757,6 +757,7 @@ void Constraint::MenuConstrain(Command id) {
c.type = Type::PARALLEL;
c.entityA = gs.face[0];
c.entityB = gs.face[1];
newcons.push_back(c);
} else if(gs.vectors > 1 && gs.vectors == gs.n) {
c.type = Type::PARALLEL;
c.entityA = gs.vector[0];
Expand Down Expand Up @@ -815,8 +816,9 @@ void Constraint::MenuConstrain(Command id) {
"an endpoint (tangent)\n"));
return;
}
SS.UndoRemember();
for (auto&& nc:newcons)
AddConstraint(&nc);
AddConstraint(&nc, /*rememberForUndo=*/false);
break;

case Command::PERPENDICULAR:
Expand All @@ -837,8 +839,8 @@ void Constraint::MenuConstrain(Command id) {
" * two normals\n"));
return;
}
newcons.push_back(c);
AddConstraint(&c);
newcons.push_back(c);
break;

case Command::WHERE_DRAGGED:
Expand All @@ -851,8 +853,8 @@ void Constraint::MenuConstrain(Command id) {
" * a point\n"));
return;
}
newcons.push_back(c);
AddConstraint(&c);
newcons.push_back(c);
break;

case Command::COMMENT:
Expand All @@ -862,8 +864,8 @@ void Constraint::MenuConstrain(Command id) {
c.group = SS.GW.activeGroup;
c.workplane = SS.GW.ActiveWorkplane();
c.comment = _("NEW COMMENT -- DOUBLE-CLICK TO EDIT");
newcons.push_back(c);
AddConstraint(&c);
newcons.push_back(c);
} else {
SS.GW.pending.operation = GraphicsWindow::Pending::COMMAND;
SS.GW.pending.command = Command::COMMENT;
Expand Down