]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actionmodifyscale.cpp
Refactoring: Moved RS_GraphicView to GraphicView.
[architektonas] / src / actions / rs_actionmodifyscale.cpp
1 // rs_actionmodifyscale.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_actionmodifyscale.h"
16
17 #include "rs_dialogfactory.h"
18
19 RS_ActionModifyScale::RS_ActionModifyScale(RS_EntityContainer & container, GraphicView & graphicView):
20         RS_PreviewActionInterface("Scale Entities",
21                 container, graphicView)
22 {
23 }
24
25 RS_ActionModifyScale::~RS_ActionModifyScale()
26 {
27 }
28
29 void RS_ActionModifyScale::init(int status)
30 {
31         RS_ActionInterface::init(status);
32 }
33
34 void RS_ActionModifyScale::trigger()
35 {
36         RS_DEBUG->print("RS_ActionModifyScale::trigger()");
37
38         RS_Modification m(*container, graphicView);
39         m.scale(data);
40
41         RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
42 }
43
44 void RS_ActionModifyScale::mouseMoveEvent(QMouseEvent * e)
45 {
46         RS_DEBUG->print("RS_ActionModifyScale::mouseMoveEvent begin");
47
48         if (getStatus() == SetReferencePoint)
49         {
50                 Vector mouse = snapPoint(e);
51
52                 switch (getStatus())
53                 {
54                 case SetReferencePoint:
55                         referencePoint = mouse;
56                         break;
57
58                 default:
59                         break;
60                 }
61         }
62
63         RS_DEBUG->print("RS_ActionModifyScale::mouseMoveEvent end");
64 }
65
66 void RS_ActionModifyScale::mouseReleaseEvent(QMouseEvent * e)
67 {
68         if (e->button() == Qt::LeftButton)
69         {
70                 Vector mouse = snapPoint(e);
71
72                 switch (getStatus())
73                 {
74                 case SetReferencePoint:
75                         setStatus(ShowDialog);
76
77                         if (RS_DIALOGFACTORY->requestScaleDialog(data))
78                         {
79                                 data.referencePoint = referencePoint;
80                                 trigger();
81                                 finish();
82                         }
83                         break;
84
85                 default:
86                         break;
87                 }
88         }
89         else if (e->button() == Qt::RightButton)
90         {
91                 deletePreview();
92                 deleteSnapper();
93                 init(getStatus() - 1);
94         }
95 }
96
97 void RS_ActionModifyScale::updateMouseButtonHints()
98 {
99         switch (getStatus())
100         {
101         /*case Select:
102             RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entities to scale"),
103                                            tr("Cancel"));
104             break;*/
105         case SetReferencePoint:
106                 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
107                         tr("Cancel"));
108                 break;
109
110         default:
111                 RS_DIALOGFACTORY->updateMouseWidget("", "");
112                 break;
113         }
114 }
115
116 void RS_ActionModifyScale::updateMouseCursor()
117 {
118         graphicView->setMouseCursor(RS2::CadCursor);
119 }
120
121 void RS_ActionModifyScale::updateToolBar()
122 {
123         switch (getStatus())
124         {
125         /*case Select:
126             RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
127             break;*/
128         case SetReferencePoint:
129                 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
130                 break;
131
132         default:
133                 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
134                 break;
135         }
136 }
137
138 // EOF