]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actionmodifyrotate2.cpp
Scrubbed out all references to RS2::qtToRsButton(). Gone!
[architektonas] / src / actions / rs_actionmodifyrotate2.cpp
1 // rs_actionmodifyrotate2.cpp
2 //
3 // Part of the Architektonas Project
4 // Originally part of QCad Community Edition by Andrew Mustun
5 // Extensively rewritten and refactored by James L. Hammons
6 // (C) 2010 Underground Software
7 //
8 // JLH = James L. Hammons <jlhamm@acm.org>
9 //
10 // Who  When        What
11 // ---  ----------  -----------------------------------------------------------
12 // JLH  06/04/2010  Added this text. :-)
13 //
14
15 #include "rs_actionmodifyrotate2.h"
16
17 #include "rs_dialogfactory.h"
18
19 RS_ActionModifyRotate2::RS_ActionModifyRotate2(
20         RS_EntityContainer & container, RS_GraphicView & graphicView):
21         RS_PreviewActionInterface("Rotate Entities around two centers", container, graphicView)
22 {
23 }
24
25 RS_ActionModifyRotate2::~RS_ActionModifyRotate2()
26 {
27 }
28
29 void RS_ActionModifyRotate2::init(int status)
30 {
31         RS_ActionInterface::init(status);
32 }
33
34 void RS_ActionModifyRotate2::trigger()
35 {
36         RS_DEBUG->print("RS_ActionModifyRotate2::trigger()");
37
38         RS_Modification m(*container, graphicView);
39         m.rotate2(data);
40
41         finish();
42
43         RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
44 }
45
46 void RS_ActionModifyRotate2::mouseMoveEvent(QMouseEvent * e)
47 {
48         RS_DEBUG->print("RS_ActionModifyRotate2::mouseMoveEvent begin");
49
50         if (getStatus() == SetReferencePoint1
51             || getStatus() == SetReferencePoint2)
52         {
53                 Vector mouse = snapPoint(e);
54
55                 switch (getStatus())
56                 {
57                 case SetReferencePoint1:
58                         data.center1 = mouse;
59                         break;
60
61                 case SetReferencePoint2:
62
63                         if (data.center1.valid)
64                                 data.center2 = mouse;
65                                 //data.offset = data.center2-data.center1;
66
67                                 /*deletePreview();
68                                    clearPreview();
69                                    preview->addSelectionFrom(*container);
70                                    preview->rotate(data.center1, data.angle);
71                                    preview->move(data.offset);
72                                    drawPreview();
73                                  */
74                         break;
75
76                 default:
77                         break;
78                 }
79         }
80
81         RS_DEBUG->print("RS_ActionModifyRotate2::mouseMoveEvent end");
82 }
83
84 void RS_ActionModifyRotate2::mouseReleaseEvent(QMouseEvent * e)
85 {
86         if (e->button() == Qt::LeftButton)
87         {
88                 Vector ce(snapPoint(e));
89                 coordinateEvent(&ce);
90         }
91         else if (e->button() == Qt::RightButton)
92         {
93                 deletePreview();
94                 deleteSnapper();
95                 init(getStatus() - 1);
96         }
97 }
98
99 void RS_ActionModifyRotate2::coordinateEvent(Vector * e)
100 {
101         if (e == NULL)
102                 return;
103
104         Vector pos = *e;
105
106         switch (getStatus())
107         {
108         case SetReferencePoint1:
109                 data.center1 = pos;
110                 setStatus(SetReferencePoint2);
111                 break;
112
113         case SetReferencePoint2:
114                 data.center2 = pos;
115                 setStatus(ShowDialog);
116
117                 if (RS_DIALOGFACTORY->requestRotate2Dialog(data))
118                         trigger();
119                         //finish();
120                 break;
121
122         default:
123                 break;
124         }
125 }
126
127 void RS_ActionModifyRotate2::commandEvent(RS_CommandEvent * /*e*/)
128 {
129 }
130
131 QStringList RS_ActionModifyRotate2::getAvailableCommands()
132 {
133         QStringList cmd;
134         return cmd;
135 }
136
137 void RS_ActionModifyRotate2::updateMouseButtonHints()
138 {
139         switch (getStatus())
140         {
141         case SetReferencePoint1:
142                 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify absolute reference point"),
143                         tr("Cancel"));
144                 break;
145
146         case SetReferencePoint2:
147                 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify relative reference point"),
148                         tr("Back"));
149                 break;
150
151         default:
152                 RS_DIALOGFACTORY->updateMouseWidget("", "");
153                 break;
154         }
155 }
156
157 void RS_ActionModifyRotate2::updateMouseCursor()
158 {
159         graphicView->setMouseCursor(RS2::CadCursor);
160 }
161
162 void RS_ActionModifyRotate2::updateToolBar()
163 {
164         switch (getStatus())
165         {
166         case SetReferencePoint1:
167         case SetReferencePoint2:
168                 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
169                 break;
170
171         default:
172                 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
173                 break;
174         }
175 }
176
177 // EOF