]> Shamusworld >> Repos - architektonas/blobdiff - src/dimension.cpp
Added UI feedback to Dimension object.
[architektonas] / src / dimension.cpp
index 63e1ba2e7f50b9b38778974d467e78b5a24c56e6..c9777e50bd673688bc5d06dee646c6a4753cd19d 100644 (file)
@@ -69,10 +69,19 @@ all objects move as a unified whole.
        if (point2.object)
                endpoint = point2.object->GetPointAtParameter(point2.t);
 
+       painter->SetPen(QPen(Qt::magenta, 2.0, Qt::DotLine));
+
+       if ((state == OSSelected) || ((state == OSInactive) && hitPoint1))
+               painter->DrawHandle(position);
+
+       if ((state == OSSelected) || ((state == OSInactive) && hitPoint2))
+               painter->DrawHandle(endpoint);
+#if 0
        if (state == OSSelected)
                painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
        else
 //             painter->SetPen(QPen(Qt::blue, 1.0, Qt::SolidLine));
+#endif
                painter->SetPen(QPen(Qt::blue, 1.0 * Painter::zoom * size, Qt::SolidLine));
 
        painter->SetBrush(QBrush(QColor(Qt::blue)));
@@ -186,16 +195,16 @@ I believe they are pixels.
 
        if (hitPoint1)
        {
-//             oldState = state;
-//             state = OSSelected;
+               oldState = state;
+               state = OSSelected;
                oldPoint = position;
                draggingHandle1 = true;
                return true;
        }
        else if (hitPoint2)
        {
-//             oldState = state;
-//             state = OSSelected;
+               oldState = state;
+               state = OSSelected;
                oldPoint = endpoint;
                draggingHandle2 = true;
                return true;
@@ -208,6 +217,7 @@ I believe they are pixels.
 
 /*virtual*/ void Dimension::PointerMoved(Vector point)
 {
+#if 0
        // We know this is true because mouse move messages don't come here unless
        // the object was actually clicked on--therefore we *know* we're being
        // dragged...
@@ -244,6 +254,29 @@ I believe they are pixels.
        }
        else
                needUpdate = false;
+#else
+       // 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)
+       SaveHitState();
+       HitTest(point);
+       needUpdate = HitStateChanged();
+
+       objectWasDragged = (/*draggingLine |*/ draggingHandle1 | draggingHandle2);
+
+       if (objectWasDragged)
+       {
+               Vector delta = point - oldPoint;
+
+               if (draggingHandle1)// || draggingLine)
+                       position += delta;
+
+               if (draggingHandle2)// || draggingLine)
+                       endpoint += delta;
+
+               oldPoint = point;
+               needUpdate = true;
+       }
+#endif
 }
 
 
@@ -316,6 +349,23 @@ about keeping track of old states...
 }
 
 
+void Dimension::SaveHitState(void)
+{
+       oldHitPoint1 = hitPoint1;
+       oldHitPoint2 = hitPoint2;
+//     oldHitLine = hitLine;
+}
+
+
+bool Dimension::HitStateChanged(void)
+{
+       if ((hitPoint1 != oldHitPoint1) || (hitPoint2 != oldHitPoint2))
+               return true;
+
+       return false;
+}
+
+
 /*virtual*/ void Dimension::Enumerate(FILE * file)
 {
        fprintf(file, "DIMENSION %i (%lf,%lf) (%lf,%lf) %i\n", layer, position.x, position.y, endpoint.x, endpoint.y, type);