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 "actioninfodist2.h"
19 #include "rs_dialogfactory.h"
20 #include "graphicview.h"
21 #include "rs_preview.h"
23 ActionInfoDist2::ActionInfoDist2(RS_EntityContainer & container, GraphicView & graphicView):
24 ActionInterface("Info Dist2", container, graphicView)
28 ActionInfoDist2::~ActionInfoDist2()
32 void ActionInfoDist2::init(int status)
34 ActionInterface::init(status);
37 void ActionInfoDist2::trigger()
39 RS_DEBUG->print("ActionInfoDist2::trigger()");
42 if (point.valid && entity != NULL)
44 double dist = entity->getDistanceToPoint(point);
46 str.sprintf("%.6f", dist);
47 RS_DIALOGFACTORY->commandMessage(tr("Distance: %1").arg(str));
51 void ActionInfoDist2::mouseMoveEvent(QMouseEvent * e)
53 RS_DEBUG->print("ActionInfoDist2::mouseMoveEvent begin");
58 //entity = catchEntity(e);
71 RS_DEBUG->print("ActionInfoDist2::mouseMoveEvent end");
74 void ActionInfoDist2::mouseReleaseEvent(QMouseEvent * e)
76 if (e->button() == Qt::LeftButton)
81 entity = catchEntity(e);
89 Vector ce(snapPoint(e));
98 else if (e->button() == Qt::RightButton)
102 init(getStatus() - 1);
106 void ActionInfoDist2::coordinateEvent(Vector * e)
111 if (getStatus() == SetPoint && entity != NULL)
114 graphicView->moveRelativeZero(point);
116 setStatus(SetEntity);
120 void ActionInfoDist2::updateMouseButtonHints()
125 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify entity"), tr("Cancel"));
129 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"), tr("Back"));
133 RS_DIALOGFACTORY->updateMouseWidget("", "");
138 void ActionInfoDist2::updateMouseCursor()
140 graphicView->setMouseCursor(RS2::CadCursor);
143 void ActionInfoDist2::updateToolBar()
149 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
153 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);