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/03/2010 Added this text. :-)
17 #include "actiondimension.h"
19 #include "dialogfactory.h"
20 #include "graphicview.h"
22 ActionDimension::ActionDimension(const char * name, EntityContainer & container, GraphicView & graphicView):
23 ActionInterface(name, container, graphicView)
28 ActionDimension::~ActionDimension()
32 void ActionDimension::reset()
34 data = DimensionData(Vector(false), Vector(false), RS2::VAlignMiddle,
35 RS2::HAlignCenter, RS2::Exact, 1.0, "", "Standard", 0.0);
39 void ActionDimension::init(int status)
41 ActionInterface::init(status);
44 void ActionDimension::hideOptions()
46 ActionInterface::hideOptions();
49 DIALOGFACTORY->requestOptions(this, false);
52 void ActionDimension::showOptions()
54 ActionInterface::showOptions();
57 DIALOGFACTORY->requestOptions(this, true, true);
60 void ActionDimension::updateMouseCursor()
62 graphicView->setMouseCursor(RS2::CadCursor);
65 void ActionDimension::updateToolBar()
71 DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
73 DIALOGFACTORY->requestToolBar(RS2::ToolBarDim);
76 QString ActionDimension::getText()
78 if (!data.text.isEmpty())
83 if (l.isEmpty() && (diameter || !tol1.isEmpty() || !tol2.isEmpty()))
87 l = QChar(0x2205) + l;
89 if (!tol1.isEmpty() || !tol2.isEmpty())
90 l += QString("\\S%1\\%2;").arg(tol1).arg(tol2);
95 void ActionDimension::setText(const QString & t)
100 QString ActionDimension::getLabel()
105 void ActionDimension::setLabel(const QString & t)
110 QString ActionDimension::getTol1()
115 void ActionDimension::setTol1(const QString & t)
120 QString ActionDimension::getTol2()
125 void ActionDimension::setTol2(const QString & t)
130 bool ActionDimension::getDiameter()
135 void ActionDimension::setDiameter(bool d)
140 /*static*/ bool ActionDimension::isDimensionAction(RS2::ActionType type)
142 return (type == RS2::ActionDimAligned
143 || type == RS2::ActionDimLinear
144 || type == RS2::ActionDimAngular
145 || type == RS2::ActionDimDiametric
146 || type == RS2::ActionDimRadial);