1 // actionmodifymove.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 // Portions copyright (C) 2001-2003 RibbonSoft
7 // Copyright (C) 2010 Underground Software
8 // See the README and GPLv2 files for licensing and warranty information
10 // JLH = James L. Hammons <jlhamm@acm.org>
13 // --- ---------- -----------------------------------------------------------
14 // JLH 06/04/2010 Added this text. :-)
17 #include "actionmodifymove.h"
20 #include "dialogfactory.h"
23 ActionModifyMove::ActionModifyMove(EntityContainer & container,
24 GraphicView & graphicView):
25 ActionInterface("Move Entities", container, graphicView)
29 ActionModifyMove::~ActionModifyMove()
33 void ActionModifyMove::init(int status)
35 ActionInterface::init(status);
38 void ActionModifyMove::trigger()
40 DEBUG->print("ActionModifyMove::trigger()");
42 Modification m(*container, graphicView);
45 DIALOGFACTORY->updateSelectionWidget(container->countSelected());
48 void ActionModifyMove::mouseMoveEvent(QMouseEvent * e)
50 DEBUG->print("ActionModifyMove::mouseMoveEvent begin");
52 if (getStatus() == SetReferencePoint
53 || getStatus() == SetTargetPoint)
55 Vector mouse = snapPoint(e);
59 case SetReferencePoint:
60 referencePoint = mouse;
65 if (referencePoint.valid)
71 /* preview->addSelectionFrom(*container);
72 preview->move(targetPoint - referencePoint);*/
82 DEBUG->print("ActionModifyMove::mouseMoveEvent end");
85 void ActionModifyMove::mouseReleaseEvent(QMouseEvent * e)
87 if (e->button() == Qt::LeftButton)
89 Vector ce(snapPoint(e));
92 else if (e->button() == Qt::RightButton)
96 init(getStatus() - 1);
100 void ActionModifyMove::coordinateEvent(Vector * e)
109 case SetReferencePoint:
110 referencePoint = pos;
111 graphicView->moveRelativeZero(referencePoint);
112 setStatus(SetTargetPoint);
117 graphicView->moveRelativeZero(targetPoint);
118 setStatus(ShowDialog);
120 if (DIALOGFACTORY->requestMoveDialog(data))
122 data.offset = targetPoint - referencePoint;
133 void ActionModifyMove::updateMouseButtonHints()
138 DIALOGFACTORY->updateMouseWidget(tr("Pick entities to move"),
141 case SetReferencePoint:
142 DIALOGFACTORY->updateMouseWidget(tr("Specify reference point"),
147 DIALOGFACTORY->updateMouseWidget(tr("Specify target point"),
152 DIALOGFACTORY->updateMouseWidget("", "");
157 void ActionModifyMove::updateMouseCursor()
159 graphicView->setMouseCursor(RS2::CadCursor);
162 void ActionModifyMove::updateToolBar()
167 DIALOGFACTORY->requestToolBar(RS2::ToolBarSelect);
169 case SetReferencePoint:
171 DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
175 DIALOGFACTORY->requestToolBar(RS2::ToolBarModify);