]> Shamusworld >> Repos - architektonas/blobdiff - src/line.cpp
Fixed Arc to give continuous feedback like Line and Circle do.
[architektonas] / src / line.cpp
index a3d745aa3da32908a53b3f45c47d6076af07ef24..e80e988797c28004cd84d45c7ba76411bbad1049 100644 (file)
@@ -75,29 +75,22 @@ Line::~Line()
                Vector current(point2 - point1);
                Vector v = current.Unit() * length;
                Vector v2 = point1 + v;
-//             painter->DrawLine((int)point1.x, (int)point1.y, (int)v2.x, (int)v2.y);
                painter->DrawLine(point1, v2);
 
                if (current.Magnitude() > length)
                {
                        painter->SetPen(QPen(QColor(128, 0, 0), 1.0, Qt::DashLine));
-//                     painter->DrawLine((int)v2.x, (int)v2.y, (int)point2.x, (int)point2.y);
                        painter->DrawLine(v2, point2);
                }
        }
-// Problem: when drawing at large zoom levels, this throws away precision thus
-//          causing the line to rendered too short. !!! FIX !!! [DONE]
        else
-//             painter->DrawLine((int)position.x, (int)position.y, (int)endpoint.x, (int)endpoint.y);
                painter->DrawLine(position, endpoint);
 
-       // If we're rotating or setting the span, draw an information panel
-       // showing both absolute and relative angles being set.
+       // If we're dragging an endpoint, draw an information panel showing both
+       // the length and angle being set.
        if (draggingHandle1 || draggingHandle2)
        {
                double absAngle = (Vector(endpoint - position).Angle()) * RADIANS_TO_DEGREES;
-//             double relAngle = (startAngle >= oldAngle ? startAngle - oldAngle :
-//                     startAngle - oldAngle + (2.0 * PI)) * RADIANS_TO_DEGREES;
                double absLength = Vector(position - endpoint).Magnitude();
 
                QString text;
@@ -108,16 +101,14 @@ Line::~Line()
                QPen pen = QPen(QColor(0x00, 0xFF, 0x00), 1.0, Qt::SolidLine);
                painter->SetPen(pen);
                painter->SetBrush(QBrush(QColor(0x40, 0xFF, 0x40, 0x9F)));
-               QRectF textRect(10.0, 10.0, 270.0, 70.0);       // x, y, w, h
+               QRectF textRect(10.0, 10.0, 270.0, 70.0);       // x, y, w, h (in Qt coords)
                painter->DrawRoundedRect(textRect, 7.0, 7.0);
 
                textRect.setLeft(textRect.left() + 14);
                painter->SetFont(*Object::font);
-//                     pen = QPen(QColor(0xDF, 0x5F, 0x00), 1.0, Qt::SolidLine);
                pen = QPen(QColor(0x00, 0x5F, 0xDF));
                painter->SetPen(pen);
                painter->DrawText(textRect, Qt::AlignVCenter, text);
-//             painter->SetPen(QPen(QColor(0xDF, 0x5F, 0x00)));
        }
 }
 
@@ -132,9 +123,9 @@ Line::~Line()
 {
        // We can assume this, since this is a mouse down event here.
        objectWasDragged = false;
-       SaveState();
+//     SaveHitState();
        HitTest(point);
-//     return StateChanged();
+//     return HitStateChanged();
 
 // this is shite. this should be checked for in the Container, not here!
        // If we're part of a non-top-level container, send this signal to it
@@ -317,9 +308,9 @@ Like so:
 
        // Hit test tells us what we hit (if anything) through boolean variables. (It
        // also tells us whether or not the state changed. --not any more)
-       SaveState();
+       SaveHitState();
        HitTest(point);
-       needUpdate = StateChanged();
+       needUpdate = HitStateChanged();
 
        objectWasDragged = (draggingLine | draggingHandle1 | draggingHandle2);
 
@@ -451,7 +442,7 @@ the horizontal line or vertical line that intersects from the current mouse posi
 
 /*virtual*/ bool Line::HitTest(Point point)
 {
-//     SaveState();
+//     SaveHitState();
 
        hitPoint1 = hitPoint2 = hitLine = false;
        Vector lineSegment = endpoint - position;
@@ -501,8 +492,8 @@ the horizontal line or vertical line that intersects from the current mouse posi
        else if ((distance * Painter::zoom) < 5.0)
                hitLine = true;
 
-       return (hitPoint1 | hitPoint2 | hitLine ? true : false);
-//     return StateChanged();
+       return (hitPoint1 || hitPoint2 || hitLine ? true : false);
+//     return HitStateChanged();
 }
 
 
@@ -640,7 +631,7 @@ Object * Line::FindAttachedDimension(void)
 }
 
 
-void Line::SaveState(void)
+void Line::SaveHitState(void)
 {
        oldHitPoint1 = hitPoint1;
        oldHitPoint2 = hitPoint2;
@@ -648,7 +639,7 @@ void Line::SaveState(void)
 }
 
 
-bool Line::StateChanged(void)
+bool Line::HitStateChanged(void)
 {
        if ((hitPoint1 != oldHitPoint1) || (hitPoint2 != oldHitPoint2) || (hitLine != oldHitLine))
                return true;