1 // mirroraction.cpp: Action class for mirroring selected objects
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 08/27/2011 Created this file
14 #include "mirroraction.h"
20 //#define FIRST_POINT 0
21 //#define NEXT_POINT 1
22 enum { FIRST_POINT, NEXT_POINT };
25 MirrorAction::MirrorAction(): state(FIRST_POINT), line(NULL),
26 shiftWasPressedOnNextPoint(false)
31 MirrorAction::~MirrorAction()
36 /*virtual*/ void MirrorAction::Draw(Painter * painter)
38 painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
40 // I think stuff like crosshairs should be done in the DrawingView, tho
41 // (and it's done there now...)
42 if (state == FIRST_POINT)
44 painter->DrawHandle(p1);
48 painter->DrawLine(p1, p2);
49 painter->DrawHandle(p2);
51 QString text = tr("Length: %1 in.");
52 text = text.arg(Vector::Magnitude(p1, p2));
53 painter->DrawInformativeText(text);
58 /*virtual*/ void MirrorAction::MouseDown(Vector point)
60 // Clear our override...
61 shiftWasPressedOnNextPoint = false;
63 if (state == FIRST_POINT)
70 /*virtual*/ void MirrorAction::MouseMoved(Vector point)
72 if (state == FIRST_POINT)
79 /*virtual*/ void MirrorAction::MouseReleased(void)
81 if (state == FIRST_POINT)
86 else if (state == NEXT_POINT)
88 // We create the new object here, and then pass it off to the
89 // DrawingView which stuffs it into the document.
90 // line = new Line(p1, p2);
91 // We don't need no stinkin' sentinels, when we have signals & slots!
92 // emit ObjectReady(line);
100 /*virtual*/ bool MirrorAction::KeyDown(int key)
102 if ((key == Qt::Key_Shift) && (state == NEXT_POINT))
104 shiftWasPressedOnNextPoint = true;
115 /*virtual*/ bool MirrorAction::KeyReleased(int key)
117 if ((key == Qt::Key_Shift) && shiftWasPressedOnNextPoint)
119 shiftWasPressedOnNextPoint = false;