X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fline.cpp;h=880a79d60bc48254645794628ce1cb69dbe246fb;hb=baf67656b97e3d61e9223e66ebe4f554e364cd4a;hp=2ffb03ff0addf1cda99dfbd343914c24b8b125ad;hpb=043ecf4d074909ba2f7f53237962f9eaa72f19c2;p=architektonas diff --git a/src/line.cpp b/src/line.cpp index 2ffb03f..880a79d 100644 --- a/src/line.cpp +++ b/src/line.cpp @@ -65,16 +65,21 @@ 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((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((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((int)position.x, (int)position.y, (int)endpoint.x, (int)endpoint.y); + painter->DrawLine(position, endpoint); } /*virtual*/ Vector Line::Center(void) @@ -127,7 +132,7 @@ level container, it won't get drawn... But we can fix that by making this object call any attached object's (like a dimension only) Draw() function... :-/ */ - attachedDimension = new Dimension(&position, &endpoint, this); + attachedDimension = new Dimension(&position, &endpoint, DTLinear, this); if (parent != NULL) parent->Add(attachedDimension); @@ -355,6 +360,18 @@ about keeping track of old states... state = oldState; } +// Check to see if the point passed in coincides with any we have. If so, return a +// pointer to it; otherwise, return NULL. +/*virtual*/ Vector * Line::GetPointAt(Vector v) +{ + if (v == position) + return &position; + else if (v == endpoint) + return &endpoint; + + return 0; +} + #if 0 void Line::SetDimensionOnPoint1(Dimension * dimension) { @@ -377,7 +394,7 @@ void Line::SetDimensionOnLine(Dimension * dimension/*=NULL*/) // If they don't pass one in, create it for the caller. if (dimension == NULL) { - dimension = new Dimension(&position, &endpoint, this); + dimension = new Dimension(&position, &endpoint, DTLinear, this); if (parent) parent->Add(dimension); @@ -436,12 +453,13 @@ bool Line::HitTest(Point point) // simplifies the calculation of the determinant. //How do we determine distance here? Especially if zoomed in or out??? -#warning "!!! Distances tested for may not be valid if zoomed in or out !!!" - if (v1.Magnitude() < 8.0) +//#warning "!!! Distances tested for may not be valid if zoomed in or out !!!" +// [FIXED] + if ((v1.Magnitude() * Painter::zoom) < 8.0) hitPoint1 = true; - else if (v2.Magnitude() < 8.0) + else if ((v2.Magnitude() * Painter::zoom) < 8.0) hitPoint2 = true; - else if (distance < 5.0) + else if ((distance * Painter::zoom) < 5.0) hitLine = true; return StateChanged(); @@ -502,7 +520,7 @@ rearranging we get: t(d1x) - s(d2x) = p2x - p0x t(d1y) - s(d2y) = p2y - p0y -Determinant D is ad - bc where the matrix look like: +Determinant D is ad - bc where the matrix looks like: a b c d