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 "actioninfodist.h"
20 #include "dialogfactory.h"
21 #include "graphicview.h"
24 ActionInfoDist::ActionInfoDist(EntityContainer & container, GraphicView & graphicView): ActionInterface("Info Dist",
25 container, graphicView)
29 ActionInfoDist::~ActionInfoDist()
33 void ActionInfoDist::init(int status)
35 ActionInterface::init(status);
38 void ActionInfoDist::trigger()
40 DEBUG->print("ActionInfoDist::trigger()");
42 if (point1.valid && point2.valid)
44 double dist = point1.distanceTo(point2);
46 str.sprintf("%.6f", dist);
47 DIALOGFACTORY->commandMessage(tr("Distance: %1").arg(str));
51 void ActionInfoDist::mouseMoveEvent(QMouseEvent * e)
53 DEBUG->print("ActionInfoDist::mouseMoveEvent begin");
55 if (getStatus() == SetPoint1
56 || getStatus() == SetPoint2)
58 Vector mouse = snapPoint(e);
73 // preview->addEntity(new Line(preview, LineData(point1, point2)));
83 DEBUG->print("ActionInfoDist::mouseMoveEvent end");
86 void ActionInfoDist::mouseReleaseEvent(QMouseEvent * e)
88 if (e->button() == Qt::LeftButton)
90 Vector ce(snapPoint(e));
93 else if (e->button() == Qt::RightButton)
97 init(getStatus() - 1);
101 void ActionInfoDist::coordinateEvent(Vector * e)
112 graphicView->moveRelativeZero(point1);
113 setStatus(SetPoint2);
123 graphicView->moveRelativeZero(point2);
125 setStatus(SetPoint1);
134 void ActionInfoDist::updateMouseButtonHints()
139 DIALOGFACTORY->updateMouseWidget(
140 tr("Specify first point of distance"),
145 DIALOGFACTORY->updateMouseWidget(
146 tr("Specify second point of distance"),
151 DIALOGFACTORY->updateMouseWidget("", "");
156 void ActionInfoDist::updateMouseCursor()
158 graphicView->setMouseCursor(RS2::CadCursor);
161 void ActionInfoDist::updateToolBar()
167 DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
171 DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);