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"
20 #include "dialogfactory.h"
21 #include "graphicview.h"
24 ActionInfoDist2::ActionInfoDist2(EntityContainer & container, GraphicView & graphicView):
25 ActionInterface("Info Dist2", container, graphicView)
29 ActionInfoDist2::~ActionInfoDist2()
33 void ActionInfoDist2::init(int status)
35 ActionInterface::init(status);
38 void ActionInfoDist2::trigger()
40 DEBUG->print("ActionInfoDist2::trigger()");
43 if (point.valid && entity != NULL)
45 double dist = entity->getDistanceToPoint(point);
47 str.sprintf("%.6f", dist);
48 DIALOGFACTORY->commandMessage(tr("Distance: %1").arg(str));
52 void ActionInfoDist2::mouseMoveEvent(QMouseEvent * e)
54 DEBUG->print("ActionInfoDist2::mouseMoveEvent begin");
59 //entity = catchEntity(e);
72 DEBUG->print("ActionInfoDist2::mouseMoveEvent end");
75 void ActionInfoDist2::mouseReleaseEvent(QMouseEvent * e)
77 if (e->button() == Qt::LeftButton)
82 entity = catchEntity(e);
90 Vector ce(snapPoint(e));
99 else if (e->button() == Qt::RightButton)
103 init(getStatus() - 1);
107 void ActionInfoDist2::coordinateEvent(Vector * e)
112 if (getStatus() == SetPoint && entity != NULL)
115 graphicView->moveRelativeZero(point);
117 setStatus(SetEntity);
121 void ActionInfoDist2::updateMouseButtonHints()
126 DIALOGFACTORY->updateMouseWidget(tr("Specify entity"), tr("Cancel"));
130 DIALOGFACTORY->updateMouseWidget(tr("Specify point"), tr("Back"));
134 DIALOGFACTORY->updateMouseWidget("", "");
139 void ActionInfoDist2::updateMouseCursor()
141 graphicView->setMouseCursor(RS2::CadCursor);
144 void ActionInfoDist2::updateToolBar()
150 DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
154 DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);