]> Shamusworld >> Repos - architektonas/blobdiff - src/dimension.cpp
Added gratuitous About screen.
[architektonas] / src / dimension.cpp
index 185b7e9645b360f6fef97d0cb2978eada8a45dce..b9fc97620d8708afa2cbdd08b1fc1fd38d98dc81 100644 (file)
 
 Dimension::Dimension(Vector p1, Vector p2, Object * p/*= NULL*/): Object(p1, p), endpoint(p2),
        dragging(false), draggingHandle1(false), draggingHandle2(false),
-       length(p2.Magnitude())
+       length(p2.Magnitude()), point1(NULL), point2(NULL)
+{
+}
+
+// This is bad, p1 & p2 could be NULL, causing much consternation...
+Dimension::Dimension(Vector * p1, Vector * p2, Object * p/*= NULL*/): Object(*p1, p), endpoint(*p2),
+       dragging(false), draggingHandle1(false), draggingHandle2(false),
+       length(p2->Magnitude()), point1(p1), point2(p2)
 {
 }
 
@@ -29,6 +36,14 @@ Dimension::~Dimension()
 
 /*virtual*/ void Dimension::Draw(QPainter * painter)
 {
+       // If there are valid Vector pointers in here, use them to update the internal
+       // positions. Otherwise, we just use the internal positions by default.
+       if (point1)
+               position = *point1;
+
+       if (point2)
+               endpoint = *point2;
+
        if (state == OSSelected)
                painter->setPen(QPen(Qt::red, 2.0, Qt::DotLine));
        else
@@ -88,6 +103,14 @@ painter->scale(1.0, -1.0);
 //painter->drawLine(20, 0, -20, 0);
 //painter->drawLine(0, 20, 0, -20);
 painter->restore();
+
+/*
+All of the preceeding makes me think that rather than try to compensate for Qt's unbelieveably
+AWFUL decision to go with a wrong-handed graphics subsystem, it may be better to just stuff
+all of that crap into some kind of subclass that handles all the nastiness behind the scenes.
+I mean, really, all this crap just to get some proplerly rendered text on the screen? How
+retarded is that? :-/
+*/
 }
 
 /*virtual*/ Vector Dimension::Center(void)
@@ -279,22 +302,28 @@ about keeping track of old states...
                state = oldState;
 }
 
-void Dimension::SetPoint1(Vector v)
+void Dimension::SetPoint1(Vector v)
 {
-       position = v;
+       point1 = v;
        needUpdate = true;
 }
 
-void Dimension::SetPoint2(Vector v)
+void Dimension::SetPoint2(Vector v)
 {
-       endpoint = v;
+       point2 = v;
        needUpdate = true;
 }
 
 void Dimension::FlipSides(void)
 {
+#if 0
        Vector tmp = position;
        position = endpoint;
        endpoint = tmp;
+#else
+       Vector * tmp = point1;
+       point1 = point2;
+       point2 = tmp;
+#endif
        needUpdate = true;
 }