Swap arc endpoints when pasting transformed with negative scale.

This commit is contained in:
whitequark 2017-04-12 04:51:23 +00:00
parent 5d67b42842
commit e5259d7a3e
2 changed files with 21 additions and 3 deletions

View File

@ -82,6 +82,7 @@ Bugs fixed:
on top of all other geometry. on top of all other geometry.
* A step rotate/translate group using a group forced to triangle mesh * A step rotate/translate group using a group forced to triangle mesh
as a source group also gets forced to triangle mesh. as a source group also gets forced to triangle mesh.
* Paste Transformed with a negative scale does not invert arcs.
2.3 2.3
--- ---

View File

@ -161,6 +161,23 @@ void GraphicsWindow::PasteClipboard(Vector trans, double theta, double scale) {
n = wrkpln->NormalN(), n = wrkpln->NormalN(),
p = SK.GetEntity(wrkpl->point[0])->PointGetNum(); p = SK.GetEntity(wrkpl->point[0])->PointGetNum();
// For arcs, reflection involves swapping the endpoints, or otherwise
// the arc gets inverted.
auto mapPoint = [scale](hEntity he) {
if(scale < 0) {
hRequest hr = he.request();
Request *r = SK.GetRequest(hr);
if(r->type == Request::Type::ARC_OF_CIRCLE) {
if(he.v == hr.entity(2).v) {
return hr.entity(3);
} else if(he.v == hr.entity(3).v) {
return hr.entity(2);
}
}
}
return he;
};
ClipboardRequest *cr; ClipboardRequest *cr;
for(cr = SS.clipboard.r.First(); cr; cr = SS.clipboard.r.NextAfter(cr)) { for(cr = SS.clipboard.r.First(); cr; cr = SS.clipboard.r.NextAfter(cr)) {
hRequest hr = AddRequest(cr->type, /*rememberForUndo=*/false); hRequest hr = AddRequest(cr->type, /*rememberForUndo=*/false);
@ -194,7 +211,7 @@ void GraphicsWindow::PasteClipboard(Vector trans, double theta, double scale) {
pt = pt.RotatedAbout(n, theta); pt = pt.RotatedAbout(n, theta);
pt = pt.Plus(trans); pt = pt.Plus(trans);
int j = (r->type == Request::Type::DATUM_POINT) ? i : i + 1; int j = (r->type == Request::Type::DATUM_POINT) ? i : i + 1;
SK.GetEntity(hr.entity(j))->PointForceTo(pt); SK.GetEntity(mapPoint(hr.entity(j)))->PointForceTo(pt);
} }
if(hasDistance) { if(hasDistance) {
SK.GetEntity(hr.entity(64))->DistanceForceTo( SK.GetEntity(hr.entity(64))->DistanceForceTo(
@ -216,8 +233,8 @@ void GraphicsWindow::PasteClipboard(Vector trans, double theta, double scale) {
c.workplane = SS.GW.ActiveWorkplane(); c.workplane = SS.GW.ActiveWorkplane();
c.type = cc->type; c.type = cc->type;
c.valA = cc->valA; c.valA = cc->valA;
c.ptA = SS.clipboard.NewEntityFor(cc->ptA); c.ptA = SS.clipboard.NewEntityFor(mapPoint(cc->ptA));
c.ptB = SS.clipboard.NewEntityFor(cc->ptB); c.ptB = SS.clipboard.NewEntityFor(mapPoint(cc->ptB));
c.entityA = SS.clipboard.NewEntityFor(cc->entityA); c.entityA = SS.clipboard.NewEntityFor(cc->entityA);
c.entityB = SS.clipboard.NewEntityFor(cc->entityB); c.entityB = SS.clipboard.NewEntityFor(cc->entityB);
c.entityC = SS.clipboard.NewEntityFor(cc->entityC); c.entityC = SS.clipboard.NewEntityFor(cc->entityC);