]> Shamusworld >> Repos - architektonas/blob - src/actions/actiondimension.cpp
Initial removal of unnecessary rs_ prefixes from files.
[architektonas] / src / actions / actiondimension.cpp
1 // actiondimension.cpp
2 //
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
9 //
10 // JLH = James L. Hammons <jlhamm@acm.org>
11 //
12 // Who  When        What
13 // ---  ----------  -----------------------------------------------------------
14 // JLH  06/03/2010  Added this text. :-)
15 //
16
17 #include "actiondimension.h"
18
19 #include "dialogfactory.h"
20 #include "graphicview.h"
21
22 ActionDimension::ActionDimension(const char * name, RS_EntityContainer & container, GraphicView & graphicView):
23         ActionInterface(name, container, graphicView)
24 {
25         reset();
26 }
27
28 ActionDimension::~ActionDimension()
29 {
30 }
31
32 void ActionDimension::reset()
33 {
34         data = RS_DimensionData(Vector(false), Vector(false), RS2::VAlignMiddle,
35                 RS2::HAlignCenter, RS2::Exact, 1.0, "", "Standard", 0.0);
36         diameter = false;
37 }
38
39 void ActionDimension::init(int status)
40 {
41         ActionInterface::init(status);
42 }
43
44 void ActionDimension::hideOptions()
45 {
46         ActionInterface::hideOptions();
47
48         if (RS_DIALOGFACTORY)
49                 RS_DIALOGFACTORY->requestOptions(this, false);
50 }
51
52 void ActionDimension::showOptions()
53 {
54         ActionInterface::showOptions();
55
56         if (RS_DIALOGFACTORY)
57                 RS_DIALOGFACTORY->requestOptions(this, true, true);
58 }
59
60 void ActionDimension::updateMouseCursor()
61 {
62         graphicView->setMouseCursor(RS2::CadCursor);
63 }
64
65 void ActionDimension::updateToolBar()
66 {
67         if (!RS_DIALOGFACTORY)
68                 return;
69
70         if (!isFinished())
71                 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarSnap);
72         else
73                 RS_DIALOGFACTORY->requestToolBar(RS2::ToolBarDim);
74 }
75
76 QString ActionDimension::getText()
77 {
78         if (!data.text.isEmpty())
79                 return data.text;
80
81         QString l = label;
82
83         if (l.isEmpty() && (diameter || !tol1.isEmpty() || !tol2.isEmpty()))
84                 l = "<>";
85
86         if (diameter)
87                 l = QChar(0x2205) + l;
88
89         if (!tol1.isEmpty() || !tol2.isEmpty())
90                 l += QString("\\S%1\\%2;").arg(tol1).arg(tol2);
91
92         return l;
93 }
94
95 void ActionDimension::setText(const QString & t)
96 {
97         data.text = t;
98 }
99
100 QString ActionDimension::getLabel()
101 {
102         return label;
103 }
104
105 void ActionDimension::setLabel(const QString & t)
106 {
107         label = t;
108 }
109
110 QString ActionDimension::getTol1()
111 {
112         return tol1;
113 }
114
115 void ActionDimension::setTol1(const QString & t)
116 {
117         tol1 = t;
118 }
119
120 QString ActionDimension::getTol2()
121 {
122         return tol2;
123 }
124
125 void ActionDimension::setTol2(const QString & t)
126 {
127         tol2 = t;
128 }
129
130 bool ActionDimension::getDiameter()
131 {
132         return diameter;
133 }
134
135 void ActionDimension::setDiameter(bool d)
136 {
137         diameter = d;
138 }
139
140 /*static*/ bool ActionDimension::isDimensionAction(RS2::ActionType type)
141 {
142         return (type == RS2::ActionDimAligned
143                 || type == RS2::ActionDimLinear
144                 || type == RS2::ActionDimAngular
145                 || type == RS2::ActionDimDiametric
146                 || type == RS2::ActionDimRadial);
147 }