Skip to content

Commit

Permalink
Make pasting mirrored tangent entities independent of end point knowl…
Browse files Browse the repository at this point in the history
…edge

The functions Constraint::
	ConstrainArcLineTangent
	ConstrainCubicLineTangent
	ConstrainCurveCurveTangent
were introduced in 96958f4 in order to
properly paste arcs tangent to other objects when mirrored. See the original
pull request for details solvespace#833
and test files.

However these functions use the original logic in constraint.cpp that
relies on the two entities sharing an end point. This will interfere
implementing tangents on entities without coincident points so I changed
the logic to remove the dependency. As a side benefit it makes it cleaner
and it's intent more obvious.
See solvespace#937
  • Loading branch information
ruevs committed Nov 6, 2024
1 parent bb16066 commit dedc6d4
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions src/clipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,28 +258,31 @@ void GraphicsWindow::PasteClipboard(Vector trans, double theta, double scale) {
c.valA *= fabs(scale);
break;
case Constraint::Type::ARC_LINE_TANGENT: {
Entity *line = SK.GetEntity(c.entityB),
*arc = SK.GetEntity(c.entityA);
if(line->type == Entity::Type::ARC_OF_CIRCLE) {
swap(line, arc);
if(scale < 0) {
// When mirroring swap the end point of the arc. The reason is that arcs are
// defined as counter-clockwise from the start point to the end point. And we
// swapped its points in mapPoint above to avoid inverting it.
c.other = !c.other;
}
Constraint::ConstrainArcLineTangent(&c, line, arc);
break;
}
case Constraint::Type::CUBIC_LINE_TANGENT: {
Entity *line = SK.GetEntity(c.entityB),
*cubic = SK.GetEntity(c.entityA);
if(line->type == Entity::Type::CUBIC) {
swap(line, cubic);
}
Constraint::ConstrainCubicLineTangent(&c, line, cubic);
// Nothing to do for CUBIC unlike the ARC_OF_CIRCLE above and below.
break;
}
case Constraint::Type::CURVE_CURVE_TANGENT: {
Entity *eA = SK.GetEntity(c.entityA),
*eB = SK.GetEntity(c.entityB);
Constraint::ConstrainCurveCurveTangent(&c, eA, eB);
break;
if(scale < 0) {
// When mirroring swap the end points of arcs. The reason is that arcs are
// defined as counter-clockwise from the start point to the end point. And we
// swapped their points in mapPoint above to avoid inverting them.
// CUBIC splines do not need this.
if(EntityBase::Type::ARC_OF_CIRCLE == SK.GetEntity(c.entityA)->type) {
c.other = !c.other;
}
if(EntityBase::Type::ARC_OF_CIRCLE == SK.GetEntity(c.entityB)->type) {
c.other2 = !c.other2;
}
}
}
case Constraint::Type::HORIZONTAL:
case Constraint::Type::VERTICAL:
Expand Down

0 comments on commit dedc6d4

Please sign in to comment.