1 // rs_actioninfodist2.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_actioninfodist2.h"
17 #include "rs_dialogfactory.h"
18 #include "graphicview.h"
19 #include "rs_preview.h"
21 RS_ActionInfoDist2::RS_ActionInfoDist2(RS_EntityContainer & container, GraphicView & graphicView):
22 RS_PreviewActionInterface("Info Dist2", container, graphicView)
26 RS_ActionInfoDist2::~RS_ActionInfoDist2()
30 void RS_ActionInfoDist2::init(int status)
32 RS_ActionInterface::init(status);
35 void RS_ActionInfoDist2::trigger()
37 RS_DEBUG->print("RS_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 RS_ActionInfoDist2::mouseMoveEvent(QMouseEvent * e)
51 RS_DEBUG->print("RS_ActionInfoDist2::mouseMoveEvent begin");
56 //entity = catchEntity(e);
69 RS_DEBUG->print("RS_ActionInfoDist2::mouseMoveEvent end");
72 void RS_ActionInfoDist2::mouseReleaseEvent(QMouseEvent * e)
74 if (e->button() == Qt::LeftButton)
79 entity = catchEntity(e);
86 Vector ce(snapPoint(e));
95 else if (e->button() == Qt::RightButton)
99 init(getStatus() - 1);
103 void RS_ActionInfoDist2::coordinateEvent(Vector * e)
108 if (getStatus() == SetPoint && entity != NULL)
111 graphicView->moveRelativeZero(point);
113 setStatus(SetEntity);
117 void RS_ActionInfoDist2::updateMouseButtonHints()
122 RS_DIALOGFACTORY->updateMouseWidget(
123 tr("Specify entity"),
128 RS_DIALOGFACTORY->updateMouseWidget(
134 RS_DIALOGFACTORY->updateMouseWidget("", "");
139 void RS_ActionInfoDist2::updateMouseCursor()
141 graphicView->setMouseCursor(RS2::CadCursor);
144 void RS_ActionInfoDist2::updateToolBar()
150 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
154 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);