]> Shamusworld >> Repos - architektonas/blobdiff - src/circle.cpp
Fixed Arc to give continuous feedback like Line and Circle do.
[architektonas] / src / circle.cpp
index 77ea95a6290e5ca87dbe8ba9477bac561fce7bef..909d30416bac3676beaf8d6d8cbe905184f04eb7 100644 (file)
@@ -53,6 +53,25 @@ Circle::~Circle()
 
        if (state == OSSelected && draggingEdge && objectWasDragged)
                painter->DrawHandle(dragPoint);
+
+       // If resizing the circle, draw an information panel showing the new radius.
+       if (draggingEdge)
+       {
+               QString text = QObject::tr("Radius: %1\nScale: %2%");
+               text = text.arg(radius, 0, 'd', 4).arg(radius / oldRadius * 100.0, 0, 'd', 0);
+
+               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
+               painter->DrawRoundedRect(textRect, 7.0, 7.0);
+
+               textRect.setLeft(textRect.left() + 14);
+               painter->SetFont(*Object::font);
+               pen = QPen(QColor(0x00, 0x5F, 0xDF));
+               painter->SetPen(pen);
+               painter->DrawText(textRect, Qt::AlignVCenter, text);
+       }
 }
 
 
@@ -76,6 +95,7 @@ Circle::~Circle()
                dragPoint = point;
                oldState = state;
                state = OSSelected;
+               oldRadius = radius;
                return true;
        }
 
@@ -90,7 +110,8 @@ Circle::~Circle()
        if (selectionInProgress)
        {
                // Check for whether or not the rect contains this circle
-               if (selection.normalized().contains(Extents()))
+//             if (selection.normalized().contains(Extents()))
+               if (selection.contains(Extents()))
                        state = OSSelected;
                else
                        state = OSInactive;
@@ -100,9 +121,14 @@ Circle::~Circle()
 
        // Hit test tells us what we hit (if anything) through boolean variables. It
        // also tells us whether or not the state changed.
-       needUpdate = HitTest(point);
+       SaveHitState();
+       HitTest(point);
+       needUpdate = HitStateChanged();
        objectWasDragged = (draggingEdge | draggingCenter);
 
+       if (objectWasDragged)
+               needUpdate = true;
+
        if (draggingEdge)
                radius = Vector::Magnitude(point, position);
        else if (draggingCenter)
@@ -128,7 +154,7 @@ Circle::~Circle()
 
 /*virtual*/ bool Circle::HitTest(Point point)
 {
-       SaveState();
+//     SaveHitState();
        hitCenter = hitCircle = false;
        double length = Vector::Magnitude(position, point);
 //printf("Circle::length = %lf, radius = %lf\n", length, radius);
@@ -155,7 +181,8 @@ pointed at length with our on screen length.
        else if ((fabs(length - radius) * Painter::zoom) < 2.0)
                hitCircle = true;
 
-       return StateChanged();
+//     return HitStateChanged();
+       return (hitCenter || hitCircle ? true : false);
 }
 
 
@@ -165,14 +192,14 @@ pointed at length with our on screen length.
 }
 
 
-void Circle::SaveState(void)
+void Circle::SaveHitState(void)
 {
        oldHitCenter = hitCenter;
        oldHitCircle = hitCircle;
 }
 
 
-bool Circle::StateChanged(void)
+bool Circle::HitStateChanged(void)
 {
        if ((hitCenter != oldHitCenter) || (hitCircle != oldHitCircle))
                return true;