1 // rs_actioninfodist.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_actioninfodist.h"
17 #include "rs_dialogfactory.h"
18 #include "graphicview.h"
19 #include "rs_preview.h"
21 RS_ActionInfoDist::RS_ActionInfoDist(RS_EntityContainer & container, GraphicView & graphicView): RS_PreviewActionInterface("Info Dist",
22 container, graphicView)
26 RS_ActionInfoDist::~RS_ActionInfoDist()
30 void RS_ActionInfoDist::init(int status)
32 RS_ActionInterface::init(status);
35 void RS_ActionInfoDist::trigger()
37 RS_DEBUG->print("RS_ActionInfoDist::trigger()");
39 if (point1.valid && point2.valid)
41 double dist = point1.distanceTo(point2);
43 str.sprintf("%.6f", dist);
44 RS_DIALOGFACTORY->commandMessage(tr("Distance: %1").arg(str));
48 void RS_ActionInfoDist::mouseMoveEvent(QMouseEvent * e)
50 RS_DEBUG->print("RS_ActionInfoDist::mouseMoveEvent begin");
52 if (getStatus() == SetPoint1
53 || getStatus() == SetPoint2)
55 Vector mouse = snapPoint(e);
71 preview->addEntity(new RS_Line(preview,
84 RS_DEBUG->print("RS_ActionInfoDist::mouseMoveEvent end");
87 void RS_ActionInfoDist::mouseReleaseEvent(QMouseEvent * e)
89 if (e->button() == Qt::LeftButton)
91 Vector ce(snapPoint(e));
94 else if (e->button() == Qt::RightButton)
98 init(getStatus() - 1);
102 void RS_ActionInfoDist::coordinateEvent(Vector * e)
113 graphicView->moveRelativeZero(point1);
114 setStatus(SetPoint2);
124 graphicView->moveRelativeZero(point2);
126 setStatus(SetPoint1);
135 void RS_ActionInfoDist::updateMouseButtonHints()
140 RS_DIALOGFACTORY->updateMouseWidget(
141 tr("Specify first point of distance"),
146 RS_DIALOGFACTORY->updateMouseWidget(
147 tr("Specify second point of distance"),
152 RS_DIALOGFACTORY->updateMouseWidget("", "");
157 void RS_ActionInfoDist::updateMouseCursor()
159 graphicView->setMouseCursor(RS2::CadCursor);
162 void RS_ActionInfoDist::updateToolBar()
168 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
172 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarInfo);