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