Fix H/V constraints on points and allow more than 2 points

This commit is contained in:
phkahler 2023-01-02 15:00:47 -05:00 committed by Paul Kahler
parent a5809891d6
commit 0db1f6bacd

View File

@ -599,7 +599,11 @@ void Constraint::MenuConstrain(Command id) {
case Command::VERTICAL: case Command::VERTICAL:
case Command::HORIZONTAL: { 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) { if(c.workplane == Entity::FREE_IN_3D) {
Error(_("Activate a workplane (with Sketch -> In Workplane) before " Error(_("Activate a workplane (with Sketch -> In Workplane) before "
"applying a horizontal or vertical constraint.")); "applying a horizontal or vertical constraint."));
@ -608,19 +612,14 @@ void Constraint::MenuConstrain(Command id) {
if(gs.lineSegments > 0 && gs.lineSegments == gs.n) { if(gs.lineSegments > 0 && gs.lineSegments == gs.n) {
for (auto enti : gs.entity){ for (auto enti : gs.entity){
c.entityA = enti; c.entityA = enti;
if(id == Command::HORIZONTAL) {
c.type = Type::HORIZONTAL;
} else {
c.type = Type::VERTICAL;
}
newcons.push_back(c); newcons.push_back(c);
} }
Entity *e = SK.GetEntity(c.entityA); } else if(gs.points >= 2 && gs.n == gs.points) {
ha = e->point[0]; c.ptA = gs.point[0];
hb = e->point[1]; for (int k = 1; k<gs.points; k++) {
} else if(gs.points == 2 && gs.n == 2) { c.ptB = gs.point[k];
ha = c.ptA = gs.point[0]; newcons.push_back(c);
hb = c.ptB = gs.point[1]; }
} else { } else {
Error(_("Bad selection for horizontal / vertical constraint. " Error(_("Bad selection for horizontal / vertical constraint. "
"This constraint can apply to:\n\n" "This constraint can apply to:\n\n"
@ -628,8 +627,9 @@ void Constraint::MenuConstrain(Command id) {
" * a line segment\n")); " * a line segment\n"));
return; return;
} }
SS.UndoRemember();
for (auto && nc: newcons) for (auto && nc: newcons)
AddConstraint(&nc); AddConstraint(&nc, /*rememberForUndo=*/false);
break; break;
} }