1 /****************************************************************************
2 ** $Id: rs_actionmodifyrotate.cpp 1161 2004-12-09 23:10:09Z andrew $
4 ** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
6 ** This file is part of the qcadlib Library project.
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.
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.
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.
20 ** See http://www.ribbonsoft.com for further details.
22 ** Contact info@ribbonsoft.com if any conditions of this licensing are
25 **********************************************************************/
27 #include "rs_actionmodifyrotate.h"
29 #include "rs_snapper.h"
33 RS_ActionModifyRotate::RS_ActionModifyRotate(RS_EntityContainer& container,
34 RS_GraphicView& graphicView)
35 :RS_PreviewActionInterface("Rotate Entities",
36 container, graphicView) {}
39 QAction* RS_ActionModifyRotate::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
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"));
48 void RS_ActionModifyRotate::init(int status) {
49 RS_ActionInterface::init(status);
54 void RS_ActionModifyRotate::trigger() {
56 RS_DEBUG->print("RS_ActionModifyRotate::trigger()");
58 RS_Modification m(*container, graphicView);
61 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
66 void RS_ActionModifyRotate::mouseMoveEvent(QMouseEvent* e) {
67 RS_DEBUG->print("RS_ActionModifyRotate::mouseMoveEvent begin");
69 if (getStatus()==SetReferencePoint) {
70 Vector mouse = snapPoint(e);
71 switch (getStatus()) {
72 case SetReferencePoint:
73 referencePoint = mouse;
81 RS_DEBUG->print("RS_ActionModifyRotate::mouseMoveEvent end");
86 void RS_ActionModifyRotate::mouseReleaseEvent(QMouseEvent* e) {
87 if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
88 RS_CoordinateEvent ce(snapPoint(e));
90 } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
99 void RS_ActionModifyRotate::coordinateEvent(RS_CoordinateEvent* e) {
104 Vector pos = e->getCoordinate();
106 switch (getStatus()) {
107 case SetReferencePoint:
108 referencePoint = pos;
109 setStatus(ShowDialog);
110 if (RS_DIALOGFACTORY->requestRotateDialog(data)) {
111 data.center = referencePoint;
124 void RS_ActionModifyRotate::updateMouseButtonHints() {
125 switch (getStatus()) {
126 case SetReferencePoint:
127 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
131 RS_DIALOGFACTORY->updateMouseWidget("", "");
138 void RS_ActionModifyRotate::updateMouseCursor() {
139 graphicView->setMouseCursor(RS2::CadCursor);
144 void RS_ActionModifyRotate::updateToolBar() {
145 switch (getStatus()) {
146 case SetReferencePoint:
147 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
150 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);