X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdimension.cpp;h=b9fc97620d8708afa2cbdd08b1fc1fd38d98dc81;hb=746443089f76c115245d1500b780d7d189b9b2af;hp=185b7e9645b360f6fef97d0cb2978eada8a45dce;hpb=b8c3c411826c1df00e54daeaf6cd820685f4f460;p=architektonas diff --git a/src/dimension.cpp b/src/dimension.cpp index 185b7e9..b9fc976 100644 --- a/src/dimension.cpp +++ b/src/dimension.cpp @@ -19,7 +19,14 @@ 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; }