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 "actioninfodist2.h"
17 #include "rs_dialogfactory.h"
18 #include "graphicview.h"
19 #include "rs_preview.h"
21 ActionInfoDist2::ActionInfoDist2(RS_EntityContainer & container, GraphicView & graphicView):
22 ActionInterface("Info Dist2", container, graphicView)
26 ActionInfoDist2::~ActionInfoDist2()
30 void ActionInfoDist2::init(int status)
32 ActionInterface::init(status);
35 void ActionInfoDist2::trigger()
37 RS_DEBUG->print("ActionInfoDist2::trigger()");
40 if (point.valid && entity != NULL)
42 double dist = entity->getDistanceToPoint(point);
44 str.sprintf("%.6f", dist);
45 RS_DIALOGFACTORY->commandMessage(tr("Distance: %1").arg(str));
49 void ActionInfoDist2::mouseMoveEvent(QMouseEvent * e)
51 RS_DEBUG->print("ActionInfoDist2::mouseMoveEvent begin");
56 //entity = catchEntity(e);
69 RS_DEBUG->print("ActionInfoDist2::mouseMoveEvent end");
72 void ActionInfoDist2::mouseReleaseEvent(QMouseEvent * e)
74 if (e->button() == Qt::LeftButton)
79 entity = catchEntity(e);
87 Vector ce(snapPoint(e));
96 else if (e->button() == Qt::RightButton)
100 init(getStatus() - 1);
104 void ActionInfoDist2::coordinateEvent(Vector * e)
109 if (getStatus() == SetPoint && entity != NULL)
112 graphicView->moveRelativeZero(point);
114 setStatus(SetEntity);
118 void ActionInfoDist2::updateMouseButtonHints()
123 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify entity"), tr("Cancel"));
127 RS_DIALOGFACTORY->updateMouseWidget(tr("Specify point"), tr("Back"));
131 RS_DIALOGFACTORY->updateMouseWidget("", "");
136 void ActionInfoDist2::updateMouseCursor()
138 graphicView->setMouseCursor(RS2::CadCursor);
141 void ActionInfoDist2::updateToolBar()
147 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
151 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);