1 /****************************************************************************
2 ** $Id: rs_actionmodifyrotate2.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_actionmodifyrotate2.h"
29 #include "rs_snapper.h"
31 RS_ActionModifyRotate2::RS_ActionModifyRotate2(
32 RS_EntityContainer& container, RS_GraphicView& graphicView):
33 RS_PreviewActionInterface("Rotate Entities around two centers", container, graphicView)
37 QAction* RS_ActionModifyRotate2::createGUIAction(RS2::ActionType /*type*/, QObject* /*parent*/)
39 QAction * action = new QAction(tr("Rotate T&wo"), 0);
40 // QAction* action = new QAction(tr("Rotate Two"), tr("Rotate T&wo"),
41 // QKeySequence(), NULL);
42 action->setStatusTip(tr("Rotate Entities around two centers"));
46 void RS_ActionModifyRotate2::init(int status)
48 RS_ActionInterface::init(status);
53 void RS_ActionModifyRotate2::trigger() {
55 RS_DEBUG->print("RS_ActionModifyRotate2::trigger()");
57 RS_Modification m(*container, graphicView);
62 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
67 void RS_ActionModifyRotate2::mouseMoveEvent(QMouseEvent* e) {
68 RS_DEBUG->print("RS_ActionModifyRotate2::mouseMoveEvent begin");
70 if (getStatus()==SetReferencePoint1 ||
71 getStatus()==SetReferencePoint2) {
73 Vector mouse = snapPoint(e);
74 switch (getStatus()) {
75 case SetReferencePoint1:
79 case SetReferencePoint2:
80 if (data.center1.valid) {
82 //data.offset = data.center2-data.center1;
86 preview->addSelectionFrom(*container);
87 preview->rotate(data.center1, data.angle);
88 preview->move(data.offset);
99 RS_DEBUG->print("RS_ActionModifyRotate2::mouseMoveEvent end");
104 void RS_ActionModifyRotate2::mouseReleaseEvent(QMouseEvent* e) {
105 if (RS2::qtToRsButtonState(e->button())==RS2::LeftButton) {
106 RS_CoordinateEvent ce(snapPoint(e));
107 coordinateEvent(&ce);
108 } else if (RS2::qtToRsButtonState(e->button())==RS2::RightButton) {
117 void RS_ActionModifyRotate2::coordinateEvent(RS_CoordinateEvent* e) {
122 Vector pos = e->getCoordinate();
124 switch (getStatus()) {
125 case SetReferencePoint1:
127 setStatus(SetReferencePoint2);
130 case SetReferencePoint2:
132 setStatus(ShowDialog);
133 if (RS_DIALOGFACTORY->requestRotate2Dialog(data)) {
145 void RS_ActionModifyRotate2::commandEvent(RS_CommandEvent* /*e*/) {
150 QStringList RS_ActionModifyRotate2::getAvailableCommands() {
158 void RS_ActionModifyRotate2::updateMouseButtonHints() {
159 switch (getStatus()) {
160 case SetReferencePoint1:
161 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify absolute reference point"),
164 case SetReferencePoint2:
165 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify relative reference point"),
169 RS_DIALOGFACTORY->updateMouseWidget("", "");
176 void RS_ActionModifyRotate2::updateMouseCursor() {
177 graphicView->setMouseCursor(RS2::CadCursor);
182 void RS_ActionModifyRotate2::updateToolBar() {
183 switch (getStatus()) {
184 case SetReferencePoint1:
185 case SetReferencePoint2:
186 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
189 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);