1 // drawlineaction.cpp: Action class for drawing lines
3 // Part of the Architektonas Project
4 // (C) 2011 Underground Software
5 // See the README and GPLv3 files for licensing and warranty information
7 // JLH = James L. Hammons <jlhamm@acm.org>
10 // --- ---------- ------------------------------------------------------------
11 // JLH 10/04/2011 Created this file
12 // JLH 11/07/2011 Made it so this class actually does something ;-)
15 #include "drawlineaction.h"
25 DrawLineAction::DrawLineAction(): state(0), line(NULL)
29 DrawLineAction::~DrawLineAction()
34 /*virtual*/ void DrawLineAction::Draw(Painter * painter)
36 // Need to fix pen colors, etc...
37 if (state == FIRST_POINT)
39 painter->DrawPoint(p1.x, p1.y);
43 painter->DrawLine(p1, p2);
47 /*virtual*/ void DrawLineAction::MouseDown(Vector point)
49 if (state == FIRST_POINT)
55 /*virtual*/ void DrawLineAction::MouseMoved(Vector point)
57 if (state == FIRST_POINT)
63 /*virtual*/ void DrawLineAction::MouseReleased(void)
65 if (state == FIRST_POINT)
67 else if (state == NEXT_POINT)
69 // We create the new object here, and then pass it off to the document.
70 line = new Line(p1, p2);
71 // We don't need no stinkin' sentinels, when we have signals & slots!
72 emit ObjectReady(line);