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