]> Shamusworld >> Repos - architektonas/blobdiff - src/arc.cpp
Fix object selection to work while in snap mode.
[architektonas] / src / arc.cpp
index ad08a572979dc651c6a13592a8126a3001b06d9b..030e293a70a20697f9575d893585894a71643e72 100644 (file)
@@ -71,7 +71,8 @@ Arc::~Arc()
                        Vector oldLine = (p3 * (radius * 1.25)) + position;
                        pen = QPen(QColor(0x80, 0x80, 0x80), 1.0, Qt::DashLine);
                        painter->SetPen(pen);
-                       painter->DrawLine((int)position.x, (int)position.y, (int)oldLine.x, (int)oldLine.y);
+//                     painter->DrawLine((int)position.x, (int)position.y, (int)oldLine.x, (int)oldLine.y);
+                       painter->DrawLine(position, oldLine);
                }
 
                // In rotating and setting the span, we draw a line showing where
@@ -147,52 +148,16 @@ Also: should put the snap logic into the Object base class (as a static method).
 /*virtual*/ bool Arc::Collided(Vector point)
 {
        objectWasDragged = false;
-//     Vector v1 = point - position;                   // Head minus tail (vector points at "point")
-
-#if 1
        bool hitSomething = HitTest(point);
        draggingCenter = hitCenter;
        draggingEdge   = hitArc;
        draggingRotate = hitRotate;
        draggingSpan   = hitSpan;
-#else
-       // Check for collision with various things...
-       hitHandle1 = false;     // Moving
-       hitHandle2 = false;     // Rotation
-       hitHandle3 = false;     // Setting span of the arc
-       hitHandle4 = false;     // Resizing
-/*
-What we have:
-the center of the arc
-the starting angle
-the span of the arc
-The point on a unit circle given an angle a is x = cos(a), y = sin(a)
-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")
-       Point p1(cos(startAngle), sin(startAngle));
-       Point p2(cos(startAngle + angleSpan), sin(startAngle + angleSpan));
-       Vector handle2 = (p1 * radius) + position;
-       Vector handle3 = (p2 * radius) + position;
-       double pointerAngle = v1.Angle();
 
-#if 1
-       // Center handle
-       if (v1.Magnitude() < 10.0)
-               hitHandle1 = true;
-       // Span handle
-       else if (Vector(handle3 - point).Magnitude() < 10.0)
-               hitHandle3 = true;
-       // Rotate handle
-       else if (Vector(handle2 - point).Magnitude() < 10.0)
-               hitHandle2 = true;
-       // Resize handle (the arc itself)
-       else if ((v1.Magnitude() < radius + 3.0) && (v1.Magnitude() > radius - 3.0)
-               && AngleInArcSpan(pointerAngle))
-               hitHandle4 = true;
-#endif
-#endif
+       // Now that we've done our hit testing on the non-snapped point, snap it if
+       // necessary...
+       if (snapToGrid)
+               point = SnapPointToGrid(point);
 
 /*
 State Management:
@@ -226,7 +191,6 @@ Selected|  |  |  |
 
 so let's do like this:
 */
-//     if (hitCenter || hitArc || hitRotate || hitSpan)
        if (hitSomething)
        {
                oldState = state;