1 // rs_actionmodifyrotate2.cpp
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 // (C) 2010 Underground Software
8 // JLH = James L. Hammons <jlhamm@acm.org>
11 // --- ---------- -----------------------------------------------------------
12 // JLH 06/04/2010 Added this text. :-)
15 #include "rs_actionmodifyrotate2.h"
17 #include "rs_dialogfactory.h"
19 RS_ActionModifyRotate2::RS_ActionModifyRotate2(
20 RS_EntityContainer & container, RS_GraphicView & graphicView):
21 RS_PreviewActionInterface("Rotate Entities around two centers", container, graphicView)
25 RS_ActionModifyRotate2::~RS_ActionModifyRotate2()
29 void RS_ActionModifyRotate2::init(int status)
31 RS_ActionInterface::init(status);
34 void RS_ActionModifyRotate2::trigger()
36 RS_DEBUG->print("RS_ActionModifyRotate2::trigger()");
38 RS_Modification m(*container, graphicView);
43 RS_DIALOGFACTORY->updateSelectionWidget(container->countSelected());
46 void RS_ActionModifyRotate2::mouseMoveEvent(QMouseEvent * e)
48 RS_DEBUG->print("RS_ActionModifyRotate2::mouseMoveEvent begin");
50 if (getStatus() == SetReferencePoint1
51 || getStatus() == SetReferencePoint2)
53 Vector mouse = snapPoint(e);
57 case SetReferencePoint1:
61 case SetReferencePoint2:
63 if (data.center1.valid)
65 //data.offset = data.center2-data.center1;
69 preview->addSelectionFrom(*container);
70 preview->rotate(data.center1, data.angle);
71 preview->move(data.offset);
81 RS_DEBUG->print("RS_ActionModifyRotate2::mouseMoveEvent end");
84 void RS_ActionModifyRotate2::mouseReleaseEvent(QMouseEvent * e)
86 if (e->button() == Qt::LeftButton)
88 Vector ce(snapPoint(e));
91 else if (e->button() == Qt::RightButton)
95 init(getStatus() - 1);
99 void RS_ActionModifyRotate2::coordinateEvent(Vector * e)
108 case SetReferencePoint1:
110 setStatus(SetReferencePoint2);
113 case SetReferencePoint2:
115 setStatus(ShowDialog);
117 if (RS_DIALOGFACTORY->requestRotate2Dialog(data))
127 void RS_ActionModifyRotate2::commandEvent(RS_CommandEvent * /*e*/)
131 QStringList RS_ActionModifyRotate2::getAvailableCommands()
137 void RS_ActionModifyRotate2::updateMouseButtonHints()
141 case SetReferencePoint1:
142 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify absolute reference point"),
146 case SetReferencePoint2:
147 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify relative reference point"),
152 RS_DIALOGFACTORY->updateMouseWidget("", "");
157 void RS_ActionModifyRotate2::updateMouseCursor()
159 graphicView->setMouseCursor(RS2::CadCursor);
162 void RS_ActionModifyRotate2::updateToolBar()
166 case SetReferencePoint1:
167 case SetReferencePoint2:
168 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
172 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);