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)
{
}
/*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
//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)
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;
}