1 // drawdimensionaction.cpp: Action class for drawing dimensions
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 03/15/2013 Created this file
14 #include "drawdimensionaction.h"
15 #include "dimension.h"
19 enum { FIRST_POINT, NEXT_POINT };
22 DrawDimensionAction::DrawDimensionAction(): state(0), dimension(NULL)
27 DrawDimensionAction::~DrawDimensionAction()
32 /*virtual*/ void DrawDimensionAction::Draw(Painter * painter)
34 painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
36 // I think stuff like crosshairs should be done in the DrawingView, tho
37 if (state == FIRST_POINT)
39 painter->DrawHandle(p1);
43 painter->DrawLine(p1, p2);
44 painter->DrawHandle(p2);
49 /*virtual*/ void DrawDimensionAction::MouseDown(Vector point)
51 if (state == FIRST_POINT)
58 /*virtual*/ void DrawDimensionAction::MouseMoved(Vector point)
60 if (state == FIRST_POINT)
67 /*virtual*/ void DrawDimensionAction::MouseReleased(void)
69 if (state == FIRST_POINT)
74 else if (state == NEXT_POINT)
76 // We create the new object here, and then pass it off to the
77 // DrawingView which stuffs it into the document.
78 dimension = new Dimension(p1, p2);
79 // We don't need no stinkin' sentinels, when we have signals & slots!
80 emit ObjectReady(dimension);
87 /*virtual*/ void DrawDimensionAction::KeyDown(int /*key*/)
92 /*virtual*/ void DrawDimensionAction::KeyReleased(int /*key*/)