X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fdrawlineaction.cpp;h=3dc9f7d240922b1c14f1122a9fa3d791941251a3;hb=9426a17d7752f82b27c47f12df0062b882df3077;hp=e14ba81ca1f440876c5e60dabba0cfe9b95c7962;hpb=64482766268cddae393da1277987de31e69ffdd9;p=architektonas diff --git a/src/drawlineaction.cpp b/src/drawlineaction.cpp index e14ba81..3dc9f7d 100644 --- a/src/drawlineaction.cpp +++ b/src/drawlineaction.cpp @@ -14,12 +14,10 @@ #include "drawlineaction.h" #include "line.h" +#include "mathconstants.h" #include "painter.h" -//#include "vector.h" -//#define FIRST_POINT 0 -//#define NEXT_POINT 1 enum { FIRST_POINT, NEXT_POINT }; @@ -49,8 +47,11 @@ DrawLineAction::~DrawLineAction() painter->DrawLine(p1, p2); painter->DrawHandle(p2); - QString text = tr("Length: %1 in."); - text = text.arg(Vector::Magnitude(p1, p2)); + Vector v(p1, p2); + double absAngle = v.Angle() * RADIANS_TO_DEGREES; + double absLength = v.Magnitude(); + QString text = tr("Length: %1 in.\n") + QChar(0x2221) + tr(": %2"); + text = text.arg(absLength).arg(absAngle); painter->DrawInformativeText(text); } } @@ -83,12 +84,22 @@ DrawLineAction::~DrawLineAction() { p2 = p1; state = NEXT_POINT; + line = NULL; } else if (state == NEXT_POINT) { + Line * oldLine = line; // 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); + + // Connect Lines by default + if (oldLine) + { + oldLine->Connect(line, 0); + line->Connect(oldLine, 1.0); + } + // We don't need no stinkin' sentinels, when we have signals & slots! emit ObjectReady(line); @@ -98,7 +109,7 @@ DrawLineAction::~DrawLineAction() } -/*virtual*/ bool DrawLineAction::KeyDown(int key) +/*virtual*/ void DrawLineAction::KeyDown(int key) { if ((key == Qt::Key_Shift) && (state == NEXT_POINT)) { @@ -106,14 +117,12 @@ DrawLineAction::~DrawLineAction() p1Save = p1; p1 = p2; state = FIRST_POINT; - return true; + emit NeedRefresh(); } - - return false; } -/*virtual*/ bool DrawLineAction::KeyReleased(int key) +/*virtual*/ void DrawLineAction::KeyReleased(int key) { if ((key == Qt::Key_Shift) && shiftWasPressedOnNextPoint) { @@ -121,9 +130,7 @@ DrawLineAction::~DrawLineAction() p2 = p1; p1 = p1Save; state = NEXT_POINT; - return true; + emit(NeedRefresh()); } - - return false; }