]> Shamusworld >> Repos - architektonas/blob - src/actions/rs_actionmodifyrotate.cpp
Initial import
[architektonas] / src / actions / rs_actionmodifyrotate.cpp
1 /****************************************************************************
2 ** $Id: rs_actionmodifyrotate.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_actionmodifyrotate.h"
28
29 #include "rs_snapper.h"
30
31
32
33 RS_ActionModifyRotate::RS_ActionModifyRotate(RS_EntityContainer& container,
34         RS_GraphicView& graphicView)
35         :RS_PreviewActionInterface("Rotate Entities",
36                            container, graphicView) {}
37
38
39 QAction* RS_ActionModifyRotate::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
40 {
41         QAction * action = new QAction(tr("&Rotate"), 0);
42 //      QAction* action = new QAction(tr("Rotate"), tr("&Rotate"),
43 //                                                                      QKeySequence(), NULL);
44         action->setStatusTip(tr("Rotate Entities"));
45         return action;
46 }
47
48 void RS_ActionModifyRotate::init(int status) {
49     RS_ActionInterface::init(status);
50 }
51
52
53
54 void RS_ActionModifyRotate::trigger() {
55
56     RS_DEBUG->print("RS_ActionModifyRotate::trigger()");
57
58     RS_Modification m(*container, graphicView);
59     m.rotate(data);
60
61     RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
62 }
63
64
65
66 void RS_ActionModifyRotate::mouseMoveEvent(QMouseEvent* e) {
67     RS_DEBUG->print("RS_ActionModifyRotate::mouseMoveEvent begin");
68
69     if (getStatus()==SetReferencePoint) {
70         Vector mouse = snapPoint(e);
71         switch (getStatus()) {
72         case SetReferencePoint:
73             referencePoint = mouse;
74             break;
75
76         default:
77             break;
78         }
79     }
80
81     RS_DEBUG->print("RS_ActionModifyRotate::mouseMoveEvent end");
82 }
83
84
85
86 void RS_ActionModifyRotate::mouseReleaseEvent(QMouseEvent* e) {
87     if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
88         RS_CoordinateEvent ce(snapPoint(e));
89         coordinateEvent(&ce);
90     } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
91         deletePreview();
92         deleteSnapper();
93         init(getStatus()-1);
94     }
95 }
96
97
98
99 void RS_ActionModifyRotate::coordinateEvent(RS_CoordinateEvent* e) {
100     if (e==NULL) {
101         return;
102     }
103
104     Vector pos = e->getCoordinate();
105
106     switch (getStatus()) {
107     case SetReferencePoint:
108         referencePoint = pos;
109         setStatus(ShowDialog);
110         if (RS_DIALOGFACTORY->requestRotateDialog(data)) {
111             data.center = referencePoint;
112             trigger();
113             finish();
114         }
115         break;
116
117     default:
118         break;
119     }
120 }
121
122
123
124 void RS_ActionModifyRotate::updateMouseButtonHints() {
125     switch (getStatus()) {
126     case SetReferencePoint:
127         RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
128                                             tr("Back"));
129         break;
130     default:
131         RS_DIALOGFACTORY->updateMouseWidget("", "");
132         break;
133     }
134 }
135
136
137
138 void RS_ActionModifyRotate::updateMouseCursor() {
139     graphicView->setMouseCursor(RS2::CadCursor);
140 }
141
142
143
144 void RS_ActionModifyRotate::updateToolBar() {
145     switch (getStatus()) {
146     case SetReferencePoint:
147         RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
148         break;
149     default:
150         RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);
151         break;
152     }
153 }
154
155
156 // EOF