1 // drawcircleaction.cpp: Action class for drawing circles
3 // Part of the Architektonas Project
4 // (C) 2012 Underground Software
5 // See the README and GPLv3 files for licensing and warranty information
7 // JLH = James Hammons <jlhamm@acm.org>
10 // --- ---------- ------------------------------------------------------------
11 // JLH 02/01/2012 Created this file
14 #include "drawcircleaction.h"
24 DrawCircleAction::DrawCircleAction(): state(0), circle(NULL)
28 DrawCircleAction::~DrawCircleAction()
33 /*virtual*/ void DrawCircleAction::Draw(Painter * painter)
35 painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
37 // I think stuff like crosshairs should be done in the DrawingView, tho
38 if (state == FIRST_POINT)
40 painter->DrawHandle(p1);
44 painter->DrawHandle(p1);
45 double radius = Vector::Magnitude(p1, p2);
46 painter->DrawEllipse(p1, radius, radius);
50 /*virtual*/ void DrawCircleAction::MouseDown(Vector point)
52 if (state == FIRST_POINT)
58 /*virtual*/ void DrawCircleAction::MouseMoved(Vector point)
60 if (state == FIRST_POINT)
66 /*virtual*/ void DrawCircleAction::MouseReleased(void)
68 if (state == FIRST_POINT)
73 else if (state == NEXT_POINT)
75 // We create the new object here, and then pass it off to the
76 // DrawingView which stuffs it into the document.
77 circle = new Circle(p1, Vector::Magnitude(p1, p2));
78 // We don't need no stinkin' sentinels, when we have signals & slots!
79 emit ObjectReady(circle);