]> Shamusworld >> Repos - architektonas/commitdiff
Fixed Arc to give continuous feedback like Line and Circle do.
authorShamus Hammons <jlhamm@acm.org>
Fri, 16 Aug 2013 18:37:42 +0000 (13:37 -0500)
committerShamus Hammons <jlhamm@acm.org>
Fri, 16 Aug 2013 18:37:42 +0000 (13:37 -0500)
src/arc.cpp
src/arc.h
src/baseunittab.cpp
src/baseunittab.h
src/circle.cpp
src/circle.h
src/generaltab.cpp
src/line.cpp
src/line.h

index 89a46f3dab1e0ca12cd6e65acb4abeed92ef3250..ad08a572979dc651c6a13592a8126a3001b06d9b 100644 (file)
@@ -10,6 +10,7 @@
 // ---  ----------  ------------------------------------------------------------
 // JLH  03/30/2011  Created this file
 // JLH  04/03/2011  Added information panel (angles) rendering
+// JLH  08/16/2013  Added continuous user feedack like for Line and Circle
 //
 
 #include "arc.h"
 
 
 Arc::Arc(Vector p1, double r, double a1, double a2, Object * p/*= NULL*/):
-       Object(p1, p), /*type(OTArc),*/ radius(r), startAngle(a1), angleSpan(a2)
+       Object(p1, p), /*type(OTArc),*/ radius(r), startAngle(a1), angleSpan(a2),
+       draggingCenter(false), draggingEdge(false), draggingRotate(false),
+       draggingSpan(false),
+       hitCenter(false), hitArc(false), hitRotate(false), hitSpan(false)
 {
        // This is in the base class, why can't we use the contructor to fill it???
        type = OTArc;
+       state = OSInactive;
 }
 
 
@@ -35,93 +40,87 @@ Arc::~Arc()
 /*virtual*/ void Arc::Draw(Painter * painter)
 {
        QPen pen;
+       painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
 
-       if (state == OSSelected)
-       {
-               Point p1(cos(startAngle), sin(startAngle));
-               Point p2(cos(startAngle + angleSpan), sin(startAngle + angleSpan));
-               Vector handle2 = (p1 * radius) + position;
-               Vector handle3 = (p2 * radius) + position;
+       Point p1(cos(startAngle), sin(startAngle));
+       Point p2(cos(startAngle + angleSpan), sin(startAngle + angleSpan));
+       Vector handle2 = (p1 * radius) + position;
+       Vector handle3 = (p2 * radius) + position;
 
-               if ((hitHandle2 || hitHandle3) && objectWasDragged)
-               {
-                       if (hitHandle2)
-                       {
-                               // If we rotating, we draw a guideline showing the angle we're
-                               // moving it from.
-                               Point p3(cos(oldAngle), sin(oldAngle));
-                               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);
-                       }
-
-                       // In rotating and setting the span, we draw a line showing where
-                       // we angle/span is that we're setting.
-                       pen = QPen(QColor(0x00, 0xC0, 0x80), 1.0, Qt::DashLine);
-                       painter->SetPen(pen);
-                       painter->DrawLine((int)position.x, (int)position.y, (int)oldPoint.x, (int)oldPoint.y);
-               }
+       if ((state == OSSelected) || ((state == OSInactive) && hitRotate))
+               painter->DrawHandle(handle2);
+
+       if ((state == OSSelected) || ((state == OSInactive) && hitSpan))
+               painter->DrawHandle(handle3);
 
-               // Draw the center point of the arc
-               painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
+       if ((state == OSSelected) || ((state == OSInactive) && hitCenter))
                painter->DrawHandle(position);
 
-               // Draw the rotation & span setting handles
-               painter->DrawHandle(handle2);
-               painter->DrawHandle(handle3);
+       if ((state == OSInactive) && !hitArc)
+               painter->SetPen(QPen(Qt::black, 1.0, Qt::SolidLine));
+
+       painter->DrawArc(position, radius, startAngle, angleSpan);
 
-               // If we're rotating or setting the span, draw an information panel
-               // showing both absolute and relative angles being set.
-               if ((hitHandle2 || hitHandle3 || hitHandle4) && objectWasDragged)
+       if (draggingRotate || draggingSpan)
+       {
+               if (draggingRotate)
                {
-                       double absAngle = (Vector(oldPoint - position).Angle()) * RADIANS_TO_DEGREES;
-                       double relAngle = (startAngle >= oldAngle ? startAngle - oldAngle :
-                               startAngle - oldAngle + (2.0 * PI)) * RADIANS_TO_DEGREES;
-
-                       QString text;
-
-                       if (hitHandle2)
-                       {
-                               text = QObject::tr("Abs ") + QChar(0x2221) + ": %1" + QChar(0x00B0)
-                                       + QObject::tr("\nRel ") + QChar(0x2221) + ": %2" + QChar(0x00B0);
-                               text = text.arg(absAngle, 0, 'd', 4).arg(relAngle, 0, 'd', 4);
-                       }
-                       else if (hitHandle3)
-                       {
-                               text = QObject::tr("Abs ") + QChar(0x2221) + ": %1" + QChar(0x00B0)
-                                       + QObject::tr("\nSpan: %2") + QChar(0x00B0);
-                               text = text.arg(absAngle, 0, 'd', 4).arg(angleSpan * RADIANS_TO_DEGREES, 0, 'd', 4);
-                       }
-                       else if (hitHandle4)
-                       {
-                               text = QObject::tr("Radius: %1\nScale: %2%");
-                               text = text.arg(radius, 0, 'd', 4).arg(radius / oldRadius * 100.0, 0, 'd', 0);
-                       }
-
-                       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(0xDF, 0x5F, 0x00), 1.0, Qt::SolidLine);
-                       pen = QPen(QColor(0x00, 0x5F, 0xDF));
+                       // If we rotating, we draw a guideline showing the angle we're
+                       // moving it from.
+                       Point p3(cos(oldAngle), sin(oldAngle));
+                       Vector oldLine = (p3 * (radius * 1.25)) + position;
+                       pen = QPen(QColor(0x80, 0x80, 0x80), 1.0, Qt::DashLine);
                        painter->SetPen(pen);
-                       painter->DrawText(textRect, Qt::AlignVCenter, text);
-                       painter->SetPen(QPen(QColor(0xDF, 0x5F, 0x00)));
+                       painter->DrawLine((int)position.x, (int)position.y, (int)oldLine.x, (int)oldLine.y);
                }
+
+               // In rotating and setting the span, we draw a line showing where
+               // we angle/span is that we're setting.
+               pen = QPen(QColor(0x00, 0xC0, 0x80), 1.0, Qt::DashLine);
+               painter->SetPen(pen);
+               painter->DrawLine((int)position.x, (int)position.y, (int)oldPoint.x, (int)oldPoint.y);
        }
-       else
+
+       // If we're rotating or setting the span, draw an information panel
+       // showing both absolute and relative angles being set.
+       if (draggingRotate || draggingSpan || draggingEdge)
        {
-               pen = QPen(Qt::black, 1.0, Qt::SolidLine);
+               double absAngle = (Vector(oldPoint - position).Angle()) * RADIANS_TO_DEGREES;
+               double relAngle = (startAngle >= oldAngle ? startAngle - oldAngle :
+                       startAngle - oldAngle + (2.0 * PI)) * RADIANS_TO_DEGREES;
+
+               QString text;
+
+               if (draggingRotate)
+               {
+                       text = QObject::tr("Abs ") + QChar(0x2221) + ": %1" + QChar(0x00B0)
+                               + QObject::tr("\nRel ") + QChar(0x2221) + ": %2" + QChar(0x00B0);
+                       text = text.arg(absAngle, 0, 'd', 4).arg(relAngle, 0, 'd', 4);
+               }
+               else if (draggingSpan)
+               {
+                       text = QObject::tr("Abs ") + QChar(0x2221) + ": %1" + QChar(0x00B0)
+                               + QObject::tr("\nSpan: %2") + QChar(0x00B0);
+                       text = text.arg(absAngle, 0, 'd', 4).arg(angleSpan * RADIANS_TO_DEGREES, 0, 'd', 4);
+               }
+               else if (draggingEdge)
+               {
+                       text = QObject::tr("Radius: %1\nScale: %2%");
+                       text = text.arg(radius, 0, 'd', 4).arg(radius / oldRadius * 100.0, 0, 'd', 0);
+               }
+
+               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);
 
-       painter->DrawArc(position, radius, startAngle, angleSpan);
-//     painter->DrawRect(Extents());
+               textRect.setLeft(textRect.left() + 14);
+               painter->SetFont(*Object::font);
+               pen = QPen(QColor(0x00, 0x5F, 0xDF));
+               painter->SetPen(pen);
+               painter->DrawText(textRect, Qt::AlignVCenter, text);
+       }
 }
 
 
@@ -148,8 +147,15 @@ 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")
+//     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
@@ -164,6 +170,7 @@ 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;
@@ -185,6 +192,7 @@ radius (to get the length correct) and add it to the center point (to get the co
                && AngleInArcSpan(pointerAngle))
                hitHandle4 = true;
 #endif
+#endif
 
 /*
 State Management:
@@ -218,7 +226,8 @@ Selected|  |  |  |
 
 so let's do like this:
 */
-       if (hitHandle1 || hitHandle2 || hitHandle3 || hitHandle4)
+//     if (hitCenter || hitArc || hitRotate || hitSpan)
+       if (hitSomething)
        {
                oldState = state;
                state = OSSelected;
@@ -226,7 +235,6 @@ so let's do like this:
                oldPoint = position;
                oldAngle = startAngle;
                oldRadius = radius;
-
                return true;
        }
 
@@ -237,10 +245,13 @@ so let's do like this:
 
 /*virtual*/ void 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
        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;
@@ -252,23 +263,29 @@ so let's do like this:
        // So we have to be careful with our assumptions here.
        // This is actually untrue in that case, we need to come up with something better
        // here...
-       objectWasDragged = true;
-       needUpdate = false;
+//     objectWasDragged = true;
+//     needUpdate = false;
+       SaveHitState();
+       HitTest(point);
+       needUpdate = HitStateChanged();
+       objectWasDragged = (draggingCenter | draggingEdge | draggingRotate | draggingSpan);
 
-       if (!(hitHandle1 || hitHandle2 || hitHandle3 || hitHandle4))
-               return;
+       if (objectWasDragged)
+               needUpdate = true;
+//     if (!(hitHandle1 || hitHandle2 || hitHandle3 || hitHandle4))
+//             return;
 
-       Vector delta = point - oldPoint;
+//     Vector delta = point - oldPoint;
 
-       if (hitHandle1)                 // Move arc
-       {
-               position += delta;
-       }
-       else if (hitHandle2)    // Rotate arc
+       if (draggingCenter)
+               position = point;
+       else if (draggingEdge)
+               radius = Vector::Magnitude(point, position);
+       else if (draggingRotate)
        {
                startAngle = Vector(point - position).Angle();
        }
-       else if (hitHandle3)    // Set arc span
+       else if (draggingSpan)
        {
                double angle = Vector(point - position).Angle();
 
@@ -277,39 +294,75 @@ so let's do like this:
 
                angleSpan = angle - startAngle;
        }
-       else if (hitHandle4)    // Resize the radius of the arc
-       {
-               radius = Vector(point - position).Magnitude();
-       }
 
+       // Why save this? For rendering code?
        oldPoint = point;
-       needUpdate = true;
+//     needUpdate = true;
 }
 
 
 /*virtual*/ void Arc::PointerReleased(void)
 {
-       hitHandle1 = hitHandle2 = hitHandle3 = hitHandle4 = false;
-       // Here we check for just a click: If object was clicked and dragged, then
-       // revert to the old state (OSInactive). Otherwise, keep the new state that
-       // we set.
-/*
-Maybe it would be better to just check for "object was dragged" state and not
-have to worry about keeping track of old states...
-Well, we can't know if it was dragged from Inactive or not, that's the problem.
-We could make a variable called "needToRevertToInactive" instead
+       // Mouse went up, so our dragging is done (if any *was* done, that is)
+//     hitHandle1 = hitHandle2 = hitHandle3 = hitHandle4 = false;
+       draggingCenter = draggingEdge = draggingRotate = draggingSpan = false;
+       hitCenter = hitArc = hitRotate = hitSpan = false;
 
-I mean, we could write like:
-       if (objectWasDragged && oldState == OSInactive)
-               state = OSInactive;
-
-but this is actually more compact and cleaner.
-*/
+       // If the object was dragged, then revert to the old state.
+       // Otherwise, we were probably just clicked, and want to stay in the selected state.
        if (objectWasDragged)
                state = oldState;
 }
 
 
+/*virtual*/ bool Arc::HitTest(Point point)
+{
+       hitCenter = hitArc = hitRotate = hitSpan = false;
+
+/*
+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();
+       double length = v1.Magnitude();
+
+#if 0
+       if (v1.Magnitude() < 10.0)
+               hitCenter = true;
+       else if (Vector(handle3 - point).Magnitude() < 10.0)
+               hitSpan = true;
+       else if (Vector(handle2 - point).Magnitude() < 10.0)
+               hitRotate = true;
+       else if ((v1.Magnitude() < radius + 3.0) && (v1.Magnitude() > radius - 3.0)
+               && AngleInArcSpan(pointerAngle))
+               hitArc = true;
+#else
+       if ((length * Painter::zoom) < 8.0)
+               hitCenter = 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;
+       else if ((Vector::Magnitude(handle3, point) * Painter::zoom) < 8.0)
+               hitSpan = true;
+#endif
+
+       return (hitCenter || hitArc || hitRotate || hitSpan ? true : false);
+}
+
+
 /*virtual*/ QRectF Arc::Extents(void)
 {
        double start = startAngle;
@@ -366,14 +419,6 @@ but this is actually more compact and cleaner.
 }
 
 
-#if 0
-/*virtual*/ bool Arc::NeedsUpdate(void)
-{
-       return needUpdate;
-}
-#endif
-
-
 /*
 start = 350, span = 20, end = 10, angle = 5
 angle < start, so angle = 365
@@ -395,6 +440,27 @@ bool Arc::AngleInArcSpan(double angle)
 }
 
 
+void Arc::SaveHitState(void)
+{
+       oldHitCenter = hitCenter;
+       oldHitArc    = hitArc;
+       oldHitRotate = hitRotate;
+       oldHitSpan   = hitSpan;
+}
+
+
+bool Arc::HitStateChanged(void)
+{
+       if ((hitCenter != oldHitCenter)
+               || (hitArc != oldHitArc)
+               || (hitRotate != oldHitRotate)
+               || (hitSpan != oldHitSpan))
+               return true;
+
+       return false;
+}
+
+
 /*virtual*/ void Arc::Enumerate(FILE * file)
 {
        fprintf(file, "ARC (%lf,%lf) %lf, %lf, %lf\n", position.x, position.y, radius, startAngle, angleSpan);
index 6419750e2afe7debde0af17b59096ff497faf44b..a05a259bd640951ed9530d1d4cc020d1cb98d800 100644 (file)
--- a/src/arc.h
+++ b/src/arc.h
@@ -14,28 +14,38 @@ class Arc: public Object
                virtual bool Collided(Vector);
                virtual void PointerMoved(Vector);
                virtual void PointerReleased(void);
+               virtual bool HitTest(Point);
                virtual void Enumerate(FILE *);
                virtual Object * Copy(void);
                virtual QRectF Extents(void);
-//             virtual ObjectType Type(void);
 
        private:
                bool AngleInArcSpan(double angle);
 
+       protected:
+               void SaveHitState(void);
+               bool HitStateChanged(void);
+
        protected:
                double radius;                                          // Center is Object::position
                double startAngle;                                      // Starting angle in radians
                double angleSpan;                                       // # of degrees the arc spans in radians
 
        private:
-               bool hitHandle1;        // Moving
-               bool hitHandle2;        // Rotation
-               bool hitHandle3;        // Setting span of the arc
-               bool hitHandle4;        // Resizing
+//             bool hitHandle1;        // Moving
+//             bool hitHandle2;        // Rotation
+//             bool hitHandle3;        // Setting span of the arc
+//             bool hitHandle4;        // Resizing
+               bool draggingCenter;
+               bool draggingEdge;
+               bool draggingRotate;
+               bool draggingSpan;
                bool objectWasDragged;
                Vector oldPoint;                                        // Used for dragging
                double oldAngle;                                        // Used for user feedback
                double oldRadius;                                       // Used for user feedback
+               bool hitCenter, hitArc, hitRotate, hitSpan;
+               bool oldHitCenter, oldHitArc, oldHitRotate, oldHitSpan;
 };
 
 #endif // __ARC_H__
index f9ea41f2fc016ebb7e377d40ef9a1485c0e7ac22..00bcc9b7aca6f787f51aa93262118ab1680a2313 100644 (file)
 // WHO  WHEN        WHAT
 // ---  ----------  ------------------------------------------------------------
 // JLH  08/15/2011  Created this file
+//
 
 #include "baseunittab.h"
 
 
 BaseUnitTab::BaseUnitTab(QWidget * parent/*= 0*/): QWidget(parent)
 {
-       antialiasChk = new QCheckBox(tr("Use Qt's built-in antialiasing"));
+       unitInch = new QRadioButton(tr("Inches"));
+       unitFoot = new QRadioButton(tr("Feet"));
+       unitYard = new QRadioButton(tr("Yards"));
 
        QVBoxLayout * layout = new QVBoxLayout;
-       layout->addWidget(antialiasChk);
+       layout->addWidget(unitInch);
+       layout->addWidget(unitFoot);
+       layout->addWidget(unitYard);
        setLayout(layout);
 }
 
index 022317c1c6f5078fa988dd40bcc27764bc6c4c84..d3a01bad496bf79d5a3179dbba4f571bf493e59b 100644 (file)
@@ -12,7 +12,10 @@ class BaseUnitTab: public QWidget
                ~BaseUnitTab();
 
        public:
-               QCheckBox * antialiasChk;
+//             QCheckBox * antialiasChk;
+               QRadioButton * unitInch;
+               QRadioButton * unitFoot;
+               QRadioButton * unitYard;
 };
 
 #endif // __BASEUNITTAB_H__
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;
index eb86957df4a43bc1c9c05994fef1f728dda5bf55..b12ae99d44b1346f36c9ed16d76ec627de537f4a 100644 (file)
@@ -18,11 +18,10 @@ class Circle: public Object
                virtual void Enumerate(FILE *);
                virtual Object * Copy(void);
                virtual QRectF Extents(void);
-//             virtual ObjectType Type(void);
 
        protected:
-               void SaveState(void);
-               bool StateChanged(void);
+               void SaveHitState(void);
+               bool HitStateChanged(void);
 
        protected:
                double radius;                                          // Center is Object::position
@@ -34,6 +33,7 @@ class Circle: public Object
                bool objectWasDragged;
                bool hitCenter, hitCircle;
                bool oldHitCenter, oldHitCircle;
+               double oldRadius;
 };
 
 #endif // __CIRCLE_H__
index 358c2a1136e2f63063317548b35d96c1c35c19e1..48a9ffdb5436fc7d86e742d21f7b4e8efba69d92 100644 (file)
@@ -10,6 +10,7 @@
 // WHO  WHEN        WHAT
 // ---  ----------  ------------------------------------------------------------
 // JLH  06/04/2011  Created this file
+//
 
 #include "generaltab.h"
 
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;
index 3d46551d6d1bedb7fe19a66fe5b2711068c8feaa..a8dc8c88a8d624fc8b615fa46a04976345f55488 100644 (file)
@@ -30,8 +30,8 @@ class Line: public Object
                Object * FindAttachedDimension(void);
 
        protected:
-               void SaveState(void);
-               bool StateChanged(void);
+               void SaveHitState(void);
+               bool HitStateChanged(void);
 
        protected:
                Vector endpoint;                                        // Starting point is Object::position