a6eb515f |
1 | // Copyright (c) 1998-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
a6eb515f |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
a6eb515f |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
a6eb515f |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
a6eb515f |
14 | |
15 | #include <Prs3d_DimensionAspect.hxx> |
16 | |
d7bffd44 |
17 | #include <Prs3d_ArrowAspect.hxx> |
18 | #include <Prs3d_TextAspect.hxx> |
19 | #include <Prs3d_LineAspect.hxx> |
20 | |
a6eb515f |
21 | #include <Aspect_TypeOfLine.hxx> |
22 | #include <Graphic3d_AspectText3d.hxx> |
a6eb515f |
23 | #include <Quantity_Color.hxx> |
24 | |
25 | IMPLEMENT_STANDARD_HANDLE (Prs3d_DimensionAspect, Prs3d_BasicAspect) |
26 | IMPLEMENT_STANDARD_RTTIEXT (Prs3d_DimensionAspect, Prs3d_BasicAspect) |
27 | |
28 | //======================================================================= |
29 | //function : Constructor |
30 | //purpose : |
31 | //======================================================================= |
32 | |
d7bffd44 |
33 | Prs3d_DimensionAspect::Prs3d_DimensionAspect() |
a6eb515f |
34 | { |
d7bffd44 |
35 | myTextHPosition = Prs3d_DTHP_Fit; |
36 | myTextVPosition = Prs3d_DTVP_Center; |
37 | myArrowOrientation = Prs3d_DAO_Fit; |
38 | |
a6eb515f |
39 | myLineAspect = new Prs3d_LineAspect (Quantity_NOC_LAWNGREEN,Aspect_TOL_SOLID,1.); |
40 | myTextAspect = new Prs3d_TextAspect; |
41 | myTextAspect->Aspect()->SetTextZoomable (Standard_False); |
42 | myTextAspect->SetColor (Quantity_NOC_LAWNGREEN); |
43 | myTextAspect->SetHorizontalJustification (Graphic3d_HTA_CENTER); |
44 | myTextAspect->SetVerticalJustification (Graphic3d_VTA_CENTER); |
45 | myArrowAspect = new Prs3d_ArrowAspect; |
46 | myArrowAspect->SetColor (Quantity_NOC_LAWNGREEN); |
0499eb06 |
47 | myArrowAspect->SetAngle (M_PI * 12.0 / 180.0); |
d7bffd44 |
48 | myArrowAspect->SetLength (6.0); |
af203d54 |
49 | myExtensionSize = 6.0; |
50 | myArrowTailSize = 6.0; |
51 | myValueStringFormat = "%g"; |
52 | myToDisplayUnits = Standard_False; |
a6eb515f |
53 | } |
54 | |
55 | //======================================================================= |
56 | //function : SetCommonColor |
57 | //purpose : Sets the same color for all parts of dimension: |
58 | // lines, arrows and text. |
59 | //======================================================================= |
a6eb515f |
60 | void Prs3d_DimensionAspect::SetCommonColor (const Quantity_Color& theColor) |
61 | { |
62 | myLineAspect->SetColor (theColor); |
63 | myTextAspect->SetColor (theColor); |
64 | myArrowAspect->SetColor (theColor); |
65 | } |
66 | |
67 | //======================================================================= |
68 | //function : LineAspect |
69 | //purpose : |
70 | //======================================================================= |
a6eb515f |
71 | Handle(Prs3d_LineAspect) Prs3d_DimensionAspect::LineAspect () const |
72 | { |
73 | return myLineAspect; |
74 | } |
75 | |
76 | //======================================================================= |
77 | //function : SetLineAspect |
78 | //purpose : |
79 | //======================================================================= |
a6eb515f |
80 | void Prs3d_DimensionAspect::SetLineAspect(const Handle(Prs3d_LineAspect)& theAspect) |
81 | { |
82 | myLineAspect = theAspect; |
83 | } |
84 | |
85 | //======================================================================= |
86 | //function : TextAspect |
87 | //purpose : |
88 | //======================================================================= |
a6eb515f |
89 | Handle(Prs3d_TextAspect) Prs3d_DimensionAspect::TextAspect () const |
90 | { |
91 | return myTextAspect; |
92 | } |
93 | |
94 | //======================================================================= |
95 | //function : SetTextAspect |
96 | //purpose : |
97 | //======================================================================= |
a6eb515f |
98 | void Prs3d_DimensionAspect::SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect) |
99 | { |
100 | myTextAspect = theAspect; |
101 | } |
102 | |
103 | //======================================================================= |
104 | //function : MakeArrows3D |
105 | //purpose : |
106 | //======================================================================= |
a6eb515f |
107 | void Prs3d_DimensionAspect::MakeArrows3d (const Standard_Boolean isArrows3d) |
108 | { |
109 | myIsArrows3d = isArrows3d; |
110 | } |
60bf98ae |
111 | |
a6eb515f |
112 | //======================================================================= |
113 | //function : IsArrows3D |
114 | //purpose : |
115 | //======================================================================= |
116 | Standard_Boolean Prs3d_DimensionAspect::IsArrows3d () const |
117 | { |
118 | return myIsArrows3d; |
119 | } |
120 | |
121 | //======================================================================= |
122 | //function : MakeText3D |
123 | //purpose : |
124 | //======================================================================= |
a6eb515f |
125 | void Prs3d_DimensionAspect::MakeText3d (const Standard_Boolean isText3d) |
126 | { |
127 | myIsText3d = isText3d; |
128 | } |
60bf98ae |
129 | |
a6eb515f |
130 | //======================================================================= |
131 | //function : IsText3D |
132 | //purpose : |
133 | //======================================================================= |
134 | Standard_Boolean Prs3d_DimensionAspect::IsText3d () const |
135 | { |
136 | return myIsText3d; |
137 | } |
138 | |
60bf98ae |
139 | //======================================================================= |
140 | //function : IsUnitsDisplayed |
141 | //purpose : |
142 | //======================================================================= |
143 | Standard_Boolean Prs3d_DimensionAspect::IsUnitsDisplayed () const |
144 | { |
145 | return myToDisplayUnits; |
146 | } |
147 | |
148 | //======================================================================= |
149 | //function : MakeUnitsDisplayed |
150 | //purpose : |
151 | //======================================================================= |
152 | void Prs3d_DimensionAspect::MakeUnitsDisplayed (const Standard_Boolean theIsDisplayed) |
153 | { |
154 | myToDisplayUnits = theIsDisplayed; |
155 | } |
156 | |
a6eb515f |
157 | //======================================================================= |
158 | //function : IsTextShaded |
159 | //purpose : |
160 | //======================================================================= |
161 | Standard_Boolean Prs3d_DimensionAspect::IsTextShaded () const |
162 | { |
163 | return myIsTextShaded; |
164 | } |
165 | |
166 | //======================================================================= |
167 | //function : MakeTextShaded |
168 | //purpose : |
169 | //======================================================================= |
a6eb515f |
170 | void Prs3d_DimensionAspect::MakeTextShaded (const Standard_Boolean isTextShaded) |
171 | { |
172 | myIsTextShaded = isTextShaded; |
173 | } |
174 | |
175 | //======================================================================= |
176 | //function : SetArrowOrientation |
177 | //purpose : |
178 | //======================================================================= |
a6eb515f |
179 | void Prs3d_DimensionAspect::SetArrowOrientation (const Prs3d_DimensionArrowOrientation theArrowOrient) |
180 | { |
181 | myArrowOrientation = theArrowOrient; |
182 | } |
183 | |
184 | //======================================================================= |
185 | //function : GetArrowOrientation |
186 | //purpose : |
187 | //======================================================================= |
d7bffd44 |
188 | Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::ArrowOrientation() const |
a6eb515f |
189 | { |
190 | return myArrowOrientation; |
191 | } |
192 | |
193 | //======================================================================= |
d7bffd44 |
194 | //function : SetTextVerticalPosition |
195 | //purpose : |
196 | //======================================================================= |
d7bffd44 |
197 | void Prs3d_DimensionAspect::SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition) |
a6eb515f |
198 | { |
d7bffd44 |
199 | myTextVPosition = thePosition; |
a6eb515f |
200 | } |
d7bffd44 |
201 | |
a6eb515f |
202 | //======================================================================= |
d7bffd44 |
203 | //function : TextVerticalPosition |
204 | //purpose : |
205 | //======================================================================= |
d7bffd44 |
206 | Prs3d_DimensionTextVerticalPosition Prs3d_DimensionAspect::TextVerticalPosition() const |
a6eb515f |
207 | { |
d7bffd44 |
208 | return myTextVPosition; |
a6eb515f |
209 | } |
210 | |
211 | //======================================================================= |
d7bffd44 |
212 | //function : SetTextHorizontalPosition |
a6eb515f |
213 | //purpose : |
d7bffd44 |
214 | //======================================================================= |
d7bffd44 |
215 | void Prs3d_DimensionAspect::SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition) |
a6eb515f |
216 | { |
d7bffd44 |
217 | myTextHPosition = thePosition; |
a6eb515f |
218 | } |
d7bffd44 |
219 | |
a6eb515f |
220 | //======================================================================= |
d7bffd44 |
221 | //function : TextHorizontalPosition |
a6eb515f |
222 | //purpose : |
d7bffd44 |
223 | //======================================================================= |
d7bffd44 |
224 | Prs3d_DimensionTextHorizontalPosition Prs3d_DimensionAspect::TextHorizontalPosition() const |
a6eb515f |
225 | { |
d7bffd44 |
226 | return myTextHPosition; |
a6eb515f |
227 | } |
228 | |
229 | //======================================================================= |
230 | //function : ArrowAspect |
231 | //purpose : |
232 | //======================================================================= |
a6eb515f |
233 | Handle(Prs3d_ArrowAspect) Prs3d_DimensionAspect::ArrowAspect () const |
234 | { |
235 | return myArrowAspect; |
236 | } |
237 | |
238 | //======================================================================= |
239 | //function : SetArrowAspect |
240 | //purpose : |
241 | //======================================================================= |
a6eb515f |
242 | void Prs3d_DimensionAspect::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect) |
243 | { |
244 | myArrowAspect = theAspect; |
245 | } |
d7bffd44 |
246 | |
247 | //======================================================================= |
248 | //function : SetExtensioSize |
249 | //purpose : |
250 | //======================================================================= |
d7bffd44 |
251 | void Prs3d_DimensionAspect::SetExtensionSize (const Standard_Real theSize) |
252 | { |
253 | myExtensionSize = theSize; |
254 | } |
255 | |
256 | //======================================================================= |
257 | //function : ExtensionSize |
258 | //purpose : |
259 | //======================================================================= |
d7bffd44 |
260 | Standard_Real Prs3d_DimensionAspect::ExtensionSize() const |
261 | { |
262 | return myExtensionSize; |
263 | } |
60bf98ae |
264 | |
af203d54 |
265 | //======================================================================= |
266 | //function : SetShortExtensionSize |
267 | //purpose : |
268 | //======================================================================= |
269 | void Prs3d_DimensionAspect::SetArrowTailSize (const Standard_Real theSize) |
270 | { |
271 | myArrowTailSize = theSize; |
272 | } |
273 | |
274 | //======================================================================= |
275 | //function : ShortExtensionSize |
276 | //purpose : |
277 | //======================================================================= |
278 | Standard_Real Prs3d_DimensionAspect::ArrowTailSize() const |
279 | { |
280 | return myArrowTailSize; |
281 | } |
282 | |
60bf98ae |
283 | //======================================================================= |
284 | //function : SetValueStringFormat |
285 | //purpose : |
286 | //======================================================================= |
287 | void Prs3d_DimensionAspect::SetValueStringFormat (const TCollection_AsciiString& theFormat) |
288 | { |
289 | myValueStringFormat = theFormat; |
290 | } |
291 | |
292 | //======================================================================= |
293 | //function : ValueStringFormat |
294 | //purpose : |
295 | //======================================================================= |
296 | TCollection_AsciiString Prs3d_DimensionAspect::ValueStringFormat() const |
297 | { |
298 | return myValueStringFormat; |
299 | } |