]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actionmodifyscale.cpp
Initial import
[architektonas] / src / actions / rs_actionmodifyscale.cpp
1 /****************************************************************************
2 ** $Id: rs_actionmodifyscale.cpp 1161 2004-12-09 23:10:09Z andrew $
3 **
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
5 **
6 ** This file is part of the qcadlib Library project.
7 **
8 ** This file may be distributed and/or modified under the terms of the
9 ** GNU General Public License version 2 as published by the Free Software
10 ** Foundation and appearing in the file LICENSE.GPL included in the
11 ** packaging of this file.
12 **
13 ** Licensees holding valid qcadlib Professional Edition licenses may use
14 ** this file in accordance with the qcadlib Commercial License
15 ** Agreement provided with the Software.
16 **
17 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
18 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19 **
20 ** See http://www.ribbonsoft.com for further details.
21 **
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
23 ** not clear to you.
24 **
25 **********************************************************************/
26
27 #include "rs_actionmodifyscale.h"
28
29 #include "rs_snapper.h"
30
31
32
33 RS_ActionModifyScale::RS_ActionModifyScale(RS_EntityContainer& container,
34         RS_GraphicView& graphicView)
35         :RS_PreviewActionInterface("Scale Entities",
36                            container, graphicView) {}
37
38
39 QAction* RS_ActionModifyScale::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
40 {
41         QAction * action = new QAction(tr("&Scale"), 0);
42 //      QAction* action = new QAction(tr("Scale"), tr("&Scale"),
43 //                                                                      QKeySequence(), NULL);
44         action->setStatusTip(tr("Scale Entities"));
45         return action;
46 }
47
48 void RS_ActionModifyScale::init(int status) {
49     RS_ActionInterface::init(status);
50
51 }
52
53
54
55 void RS_ActionModifyScale::trigger() {
56
57     RS_DEBUG->print("RS_ActionModifyScale::trigger()");
58
59     RS_Modification m(*container, graphicView);
60     m.scale(data);
61
62     RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
63 }
64
65
66
67 void RS_ActionModifyScale::mouseMoveEvent(QMouseEvent* e) {
68     RS_DEBUG->print("RS_ActionModifyScale::mouseMoveEvent begin");
69
70     if (getStatus()==SetReferencePoint) {
71
72         Vector mouse = snapPoint(e);
73         switch (getStatus()) {
74         case SetReferencePoint:
75             referencePoint = mouse;
76             break;
77
78         default:
79             break;
80         }
81     }
82
83     RS_DEBUG->print("RS_ActionModifyScale::mouseMoveEvent end");
84 }
85
86
87
88 void RS_ActionModifyScale::mouseReleaseEvent(QMouseEvent* e) {
89     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
90         Vector mouse = snapPoint(e);
91
92         switch (getStatus()) {
93         case SetReferencePoint:
94             setStatus(ShowDialog);
95             if (RS_DIALOGFACTORY->requestScaleDialog(data)) {
96                 data.referencePoint = referencePoint;
97                 trigger();
98                 finish();
99             }
100             break;
101
102         default:
103             break;
104         }
105     } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
106         deletePreview();
107         deleteSnapper();
108         init(getStatus()-1);
109     }
110 }
111
112
113
114 void RS_ActionModifyScale::updateMouseButtonHints() {
115     switch (getStatus()) {
116         /*case Select:
117             RS_DIALOGFACTORY->updateMouseWidget(tr("Pick entities to scale"),
118                                            tr("Cancel"));
119             break;*/
120     case SetReferencePoint:
121         RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
122                                             tr("Cancel"));
123         break;
124     default:
125         RS_DIALOGFACTORY->updateMouseWidget("", "");
126         break;
127     }
128 }
129
130
131
132 void RS_ActionModifyScale::updateMouseCursor() {
133     graphicView->setMouseCursor(RS2::CadCursor);
134 }
135
136
137
138 void RS_ActionModifyScale::updateToolBar() {
139     switch (getStatus()) {
140         /*case Select:
141             RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
142             break;*/
143     case SetReferencePoint:
144         RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
145         break;
146     default:
147         RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
148         break;
149     }
150 }
151
152
153 // EOF