X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdrawlineaction.cpp;h=d4b35db336ae70c35bc8f7c6e69ca199d7e7426f;hb=143b369c0308a8cd524cb0ed51c5d67d6be69603;hp=867970df4d62685e1b87831fe1467d3865d81508;hpb=fc498c685147e3173130e2df8953cc52705553e9;p=architektonas diff --git a/src/drawlineaction.cpp b/src/drawlineaction.cpp index 867970d..d4b35db 100644 --- a/src/drawlineaction.cpp +++ b/src/drawlineaction.cpp @@ -4,7 +4,7 @@ // (C) 2011 Underground Software // See the README and GPLv3 files for licensing and warranty information // -// JLH = James L. Hammons +// JLH = James Hammons // // WHO WHEN WHAT // --- ---------- ------------------------------------------------------------ @@ -26,6 +26,7 @@ DrawLineAction::DrawLineAction(): state(0), line(NULL) { } + DrawLineAction::~DrawLineAction() { } @@ -33,17 +34,25 @@ DrawLineAction::~DrawLineAction() /*virtual*/ void DrawLineAction::Draw(Painter * painter) { - // Need to fix pen colors, etc... + painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine)); + + // I think stuff like crosshairs should be done in the DrawingView, tho if (state == FIRST_POINT) { - painter->DrawPoint(p1.x, p1.y); + painter->DrawHandle(p1); } else { painter->DrawLine(p1, p2); + painter->DrawHandle(p2); + + QString text = tr("Length: %1 in."); + text = text.arg(Vector::Magnitude(p1, p2)); + painter->DrawInformativeText(text); } } + /*virtual*/ void DrawLineAction::MouseDown(Vector point) { if (state == FIRST_POINT) @@ -52,6 +61,7 @@ DrawLineAction::~DrawLineAction() p2 = point; } + /*virtual*/ void DrawLineAction::MouseMoved(Vector point) { if (state == FIRST_POINT) @@ -60,17 +70,24 @@ DrawLineAction::~DrawLineAction() p2 = point; } + /*virtual*/ void DrawLineAction::MouseReleased(void) { if (state == FIRST_POINT) + { + p2 = p1; state = NEXT_POINT; + } else if (state == NEXT_POINT) { - // We create the new object here, and then pass it off to the document. + // We create the new object here, and then pass it off to the + // DrawingView which stuffs it into the document. line = new Line(p1, p2); // We don't need no stinkin' sentinels, when we have signals & slots! emit ObjectReady(line); - - p1 = p2; + +// p1 = p2; + state = FIRST_POINT; } } +