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