X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Farc.cpp;h=6391eaecd0d813cfe14928996025081a9b28ae37;hb=4bc000ba003a53fb11428a2eb71e3b4471a15c7a;hp=e4a6b6f4788de7b89f1196fa75a8018217fad421;hpb=921bf050ffe5fc81a9ab377e634180e659ee5d5d;p=architektonas diff --git a/src/arc.cpp b/src/arc.cpp index e4a6b6f..6391eae 100644 --- a/src/arc.cpp +++ b/src/arc.cpp @@ -168,6 +168,9 @@ Also: should put the snap logic into the Object base class (as a static method). if (snapToGrid) point = SnapPointToGrid(point); + if (snapPointIsValid) + point = snapPoint; + /* State Management: We want the arc to go into OSSelected mode if we click on it but don't drag. @@ -216,7 +219,7 @@ so let's do like this: } -/*virtual*/ void Arc::PointerMoved(Vector point) +/*virtual*/ bool Arc::PointerMoved(Vector point) { // one other thing to check here for is if a modifier key is being held as well, // to allow for multi-selection @@ -229,7 +232,7 @@ so let's do like this: else state = OSInactive; - return; + return false; } // The TLC will send these messages if the object is selected but not clicked on. @@ -239,8 +242,15 @@ so let's do like this: // objectWasDragged = true; // needUpdate = false; SaveHitState(); - HitTest(point); + bool hovered = HitTest(point); needUpdate = HitStateChanged(); + + if (snapToGrid) + point = SnapPointToGrid(point); + + if (snapPointIsValid) + point = snapPoint; + objectWasDragged = (draggingCenter | draggingEdge | draggingRotate | draggingSpan); if (objectWasDragged) @@ -271,6 +281,7 @@ so let's do like this: // Why save this? For rendering code? oldPoint = point; // needUpdate = true; + return hovered; } @@ -302,7 +313,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; @@ -322,14 +334,26 @@ point (to get the correct position). hitArc = true; #else if ((length * Painter::zoom) < 8.0) + { hitCenter = true; + snapPoint = position; + snapPointIsValid = true; + } else if (((fabs(length - radius) * Painter::zoom) < 2.0) && AngleInArcSpan(pointerAngle)) hitArc = true; else if ((Vector::Magnitude(handle2, point) * Painter::zoom) < 8.0) + { hitRotate = true; + snapPoint = handle2; + snapPointIsValid = true; + } else if ((Vector::Magnitude(handle3, point) * Painter::zoom) < 8.0) + { hitSpan = true; + snapPoint = handle3; + snapPointIsValid = true; + } #endif return (hitCenter || hitArc || hitRotate || hitSpan ? true : false); @@ -344,6 +368,7 @@ point (to get the correct position). QPointF p2(cos(end), sin(end)); QRectF bounds(p1, p2); +#if 0 // Swap X/Y coordinates if they're backwards... if (bounds.left() > bounds.right()) { @@ -358,6 +383,9 @@ point (to get the correct position). bounds.setBottom(bounds.top()); bounds.setTop(temp); } +#else + bounds = bounds.normalized(); +#endif // If the end of the arc is before the beginning, add 360 degrees to it if (end < start) @@ -464,7 +492,7 @@ same reference number. Point c2 = Geometry::RotatePointAroundPoint(angleStartPoint, point, angle); position = c1; - startAngle = Vector(c2, c1).Angle(); + startAngle = Vector(c1, c2).Angle(); }