Better rotating

This commit is contained in:
Koen Schmeets 2020-11-28 12:27:26 +01:00 committed by phkahler
parent aa78043fa2
commit 6b91ab5778

View File

@ -245,6 +245,7 @@ void GraphicsWindow::PasteClipboard(Vector trans, double theta, double scale) {
c.reference = cc->reference; c.reference = cc->reference;
c.disp = cc->disp; c.disp = cc->disp;
c.comment = cc->comment; c.comment = cc->comment;
bool removeConstraint = false;
switch(c.type) { switch(c.type) {
case Constraint::Type::COMMENT: case Constraint::Type::COMMENT:
c.disp.offset = c.disp.offset.Plus(trans); c.disp.offset = c.disp.offset.Plus(trans);
@ -259,21 +260,25 @@ void GraphicsWindow::PasteClipboard(Vector trans, double theta, double scale) {
case Constraint::Type::HORIZONTAL: case Constraint::Type::HORIZONTAL:
case Constraint::Type::VERTICAL: case Constraint::Type::VERTICAL:
// When rotating 90 or 270 degrees, swap the vertical / horizontal constaints // When rotating 90 or 270 degrees, swap the vertical / horizontal constaints
if (theta == PI/2 || theta == PI*1.5) { dbp("Remainder: %f", fmod(theta + (PI / 2), PI));
if (fmod(theta + (PI/2), PI) == 0) {
if(c.type == Constraint::Type::HORIZONTAL) { if(c.type == Constraint::Type::HORIZONTAL) {
c.type = Constraint::Type::VERTICAL; c.type = Constraint::Type::VERTICAL;
} else { } else {
c.type = Constraint::Type::HORIZONTAL; c.type = Constraint::Type::HORIZONTAL;
} }
} else if (fmod(theta, PI/2) != 0) {
removeConstraint = true;
} }
break; break;
default: default:
break; break;
} }
if (!removeConstraint) {
hConstraint hc = Constraint::AddConstraint(&c, /*rememberForUndo=*/false); hConstraint hc = Constraint::AddConstraint(&c, /*rememberForUndo=*/false);
if(c.type == Constraint::Type::COMMENT) { if(c.type == Constraint::Type::COMMENT) {
MakeSelected(hc); MakeSelected(hc);
}
} }
} }
} }