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/03/2010 Added this text. :-)
15 #include "actiondimension.h"
17 #include "rs_dialogfactory.h"
18 #include "graphicview.h"
20 ActionDimension::ActionDimension(const char * name, RS_EntityContainer & container, GraphicView & graphicView):
21 ActionInterface(name, container, graphicView)
26 ActionDimension::~ActionDimension()
30 void ActionDimension::reset()
32 data = RS_DimensionData(Vector(false), Vector(false), RS2::VAlignMiddle,
33 RS2::HAlignCenter, RS2::Exact, 1.0, "", "Standard", 0.0);
37 void ActionDimension::init(int status)
39 ActionInterface::init(status);
42 void ActionDimension::hideOptions()
44 ActionInterface::hideOptions();
47 RS_DIALOGFACTORY->requestOptions(this, false);
50 void ActionDimension::showOptions()
52 ActionInterface::showOptions();
55 RS_DIALOGFACTORY->requestOptions(this, true, true);
58 void ActionDimension::updateMouseCursor()
60 graphicView->setMouseCursor(RS2::CadCursor);
63 void ActionDimension::updateToolBar()
65 if (!RS_DIALOGFACTORY)
69 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
71 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarDim);
74 QString ActionDimension::getText()
76 if (!data.text.isEmpty())
81 if (l.isEmpty() && (diameter || !tol1.isEmpty() || !tol2.isEmpty()))
85 l = QChar(0x2205) + l;
87 if (!tol1.isEmpty() || !tol2.isEmpty())
88 l += QString("\\S%1\\%2;").arg(tol1).arg(tol2);
93 void ActionDimension::setText(const QString & t)
98 QString ActionDimension::getLabel()
103 void ActionDimension::setLabel(const QString & t)
108 QString ActionDimension::getTol1()
113 void ActionDimension::setTol1(const QString & t)
118 QString ActionDimension::getTol2()
123 void ActionDimension::setTol2(const QString & t)
128 bool ActionDimension::getDiameter()
133 void ActionDimension::setDiameter(bool d)
138 /*static*/ bool ActionDimension::isDimensionAction(RS2::ActionType type)
140 return (type == RS2::ActionDimAligned
141 || type == RS2::ActionDimLinear
142 || type == RS2::ActionDimAngular
143 || type == RS2::ActionDimDiametric
144 || type == RS2::ActionDimRadial);