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 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)
30 DrawLineAction::~DrawLineAction()
35 /*virtual*/ void DrawLineAction::Draw(Painter * painter)
37 painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
39 // I think stuff like crosshairs should be done in the DrawingView, tho
40 if (state == FIRST_POINT)
42 painter->DrawHandle(p1);
46 painter->DrawLine(p1, p2);
47 painter->DrawHandle(p2);
52 /*virtual*/ void DrawLineAction::MouseDown(Vector point)
54 if (state == FIRST_POINT)
61 /*virtual*/ void DrawLineAction::MouseMoved(Vector point)
63 if (state == FIRST_POINT)
70 /*virtual*/ void DrawLineAction::MouseReleased(void)
72 if (state == FIRST_POINT)
77 else if (state == NEXT_POINT)
79 // We create the new object here, and then pass it off to the
80 // DrawingView which stuffs it into the document.
81 line = new Line(p1, p2);
82 // We don't need no stinkin' sentinels, when we have signals & slots!
83 emit ObjectReady(line);