]> Shamusworld >> Repos - architektonas/blob - src/drawarcaction.cpp
Various fixes to Container/Group handling, added DrawArcAction.
[architektonas] / src / drawarcaction.cpp
1 // drawarcaction.cpp: Draw arc object
2 //
3 // Part of the Architektonas Project
4 // (C) 2011 Underground Software
5 // See the README and GPLv3 files for licensing and warranty information
6 //
7 // JLH = James Hammons <jlhamm@acm.org>
8 //
9 // WHO  WHEN        WHAT
10 // ---  ----------  ------------------------------------------------------------
11 // JLH  08/13/2013  Created this file
12 //
13
14 #include "drawarcaction.h"
15 #include "painter.h"
16 #include "arc.h"
17 //#include "vector.h"
18
19
20 enum { FIRST_POINT, SECOND_POINT, THIRD_POINT };
21 //#define FIRST_POINT 0
22 //#define SECOND_POINT 1
23 #define NEXT_POINT 2
24
25
26 DrawArcAction::DrawArcAction(): state(FIRST_POINT), arc(NULL)
27 {
28 }
29
30
31 DrawArcAction::~DrawArcAction()
32 {
33 }
34
35
36 /*virtual*/ void DrawArcAction::Draw(Painter * painter)
37 {
38         painter->SetPen(QPen(Qt::red, 2.0, Qt::DotLine));
39
40         // I think stuff like crosshairs should be done in the DrawingView, tho
41         if (state == FIRST_POINT)
42         {
43                 painter->DrawHandle(p1);
44         }
45         else
46         {
47 //              painter->DrawLine(p1, p2);
48 //              painter->DrawHandle(p2);
49         }
50 }
51
52
53 /*virtual*/ void DrawArcAction::MouseDown(Vector point)
54 {
55         if (state == FIRST_POINT)
56                 p1 = point;
57 //      else
58 //              p2 = point;
59 }
60
61
62 /*virtual*/ void DrawArcAction::MouseMoved(Vector point)
63 {
64         if (state == FIRST_POINT)
65                 p1 = point;
66 //      else
67 //              p2 = point;
68 }
69
70
71 /*virtual*/ void DrawArcAction::MouseReleased(void)
72 {
73         if (state == FIRST_POINT)
74         {
75 //              p2 = p1;
76                 state = NEXT_POINT;
77         }
78         else if (state == NEXT_POINT)
79         {
80                 // We create the new object here, and then pass it off to the
81                 // DrawingView which stuffs it into the document.
82 //              text = new Text(p1, p2);
83 //              arc = new Arc(...);
84                 // We don't need no stinkin' sentinels, when we have signals & slots!
85                 emit ObjectReady(arc);
86         }
87 }
88