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