X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Farc.cpp;h=36245b43dc70a2f3cdf160ca80155384bfcddfe2;hb=4d6ba8a6eb781dbee818b6a55d21df7b52468936;hp=b0e3b720148bd502f6cc1eb425972d6e111a8cfc;hpb=11cff81f10ccca1b31288fce04d696e715b922b0;p=architektonas diff --git a/src/arc.cpp b/src/arc.cpp index b0e3b72..36245b4 100644 --- a/src/arc.cpp +++ b/src/arc.cpp @@ -16,6 +16,7 @@ #include "arc.h" #include +#include "geometry.h" #include "mathconstants.h" #include "painter.h" @@ -151,6 +152,10 @@ Also: should put the snap logic into the Object base class (as a static method). /*virtual*/ bool Arc::Collided(Vector point) { + // Someone told us to fuck off, so we'll fuck off. :-) + if (ignoreClicks) + return false; + objectWasDragged = false; bool hitSomething = HitTest(point); draggingCenter = hitCenter; @@ -297,7 +302,8 @@ This vector is already unitized, so all we need to do to get our point is to multiply it by radius (to get the length correct) and add it to the center point (to get the correct position). */ - Vector v1(point, position); // Head minus tail (vector points at "point") +// Vector v1(point, position); // Head minus tail (vector points at "point") + Vector v1(position, point); // Head minus tail (vector points at "point") Point p1(cos(startAngle), sin(startAngle)); Point p2(cos(startAngle + angleSpan), sin(startAngle + angleSpan)); Vector handle2 = (p1 * radius) + position; @@ -450,3 +456,45 @@ same reference number. return new Arc(position, radius, startAngle, angleSpan, parent); } + +/*virtual*/ void Arc::Rotate(Point point, double angle) +{ + Point c1 = Geometry::RotatePointAroundPoint(position, point, angle); + Point ap1(cos(startAngle), sin(startAngle)); + Point angleStartPoint = (ap1 * radius) + position; + Point c2 = Geometry::RotatePointAroundPoint(angleStartPoint, point, angle); + + position = c1; + startAngle = Vector(c2, c1).Angle(); +} + + +/*virtual*/ void Arc::Mirror(Point p1, Point p2) +{ + Point c1 = Geometry::MirrorPointAroundLine(position, p1, p2); + Point ap1(cos(startAngle + angleSpan), sin(startAngle + angleSpan)); + Point angleEndPoint = (ap1 * radius) + position; + Point c2 = Geometry::MirrorPointAroundLine(angleEndPoint, p1, p2); + + position = c1; + startAngle = Vector(c2, c1).Angle(); +} + + +/*virtual*/ void Arc::Save(void) +{ + Object::Save(); + oldRadius2 = radius; + oldStartAngle = startAngle; + oldAngleSpan = angleSpan; +} + + +/*virtual*/ void Arc::Restore(void) +{ + Object::Restore(); + radius = oldRadius2; + startAngle = oldStartAngle; + angleSpan = oldAngleSpan; +} +