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 | // |
973c2be1 |
6 | // This library is free software; you can redistribute it and / or modify it |
7 | // under the terms of the GNU Lesser General Public 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. |
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); |
fe83e1ea |
47 | myArrowAspect->SetAngle (M_PI * 20.0 / 180.0); |
d7bffd44 |
48 | myArrowAspect->SetLength (6.0); |
60bf98ae |
49 | myExtensionSize = 6.0; |
50 | myValueStringFormat = "%g"; |
51 | myToDisplayUnits = Standard_False; |
a6eb515f |
52 | } |
53 | |
54 | //======================================================================= |
55 | //function : SetCommonColor |
56 | //purpose : Sets the same color for all parts of dimension: |
57 | // lines, arrows and text. |
58 | //======================================================================= |
a6eb515f |
59 | void Prs3d_DimensionAspect::SetCommonColor (const Quantity_Color& theColor) |
60 | { |
61 | myLineAspect->SetColor (theColor); |
62 | myTextAspect->SetColor (theColor); |
63 | myArrowAspect->SetColor (theColor); |
64 | } |
65 | |
66 | //======================================================================= |
67 | //function : LineAspect |
68 | //purpose : |
69 | //======================================================================= |
a6eb515f |
70 | Handle(Prs3d_LineAspect) Prs3d_DimensionAspect::LineAspect () const |
71 | { |
72 | return myLineAspect; |
73 | } |
74 | |
75 | //======================================================================= |
76 | //function : SetLineAspect |
77 | //purpose : |
78 | //======================================================================= |
a6eb515f |
79 | void Prs3d_DimensionAspect::SetLineAspect(const Handle(Prs3d_LineAspect)& theAspect) |
80 | { |
81 | myLineAspect = theAspect; |
82 | } |
83 | |
84 | //======================================================================= |
85 | //function : TextAspect |
86 | //purpose : |
87 | //======================================================================= |
a6eb515f |
88 | Handle(Prs3d_TextAspect) Prs3d_DimensionAspect::TextAspect () const |
89 | { |
90 | return myTextAspect; |
91 | } |
92 | |
93 | //======================================================================= |
94 | //function : SetTextAspect |
95 | //purpose : |
96 | //======================================================================= |
a6eb515f |
97 | void Prs3d_DimensionAspect::SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect) |
98 | { |
99 | myTextAspect = theAspect; |
100 | } |
101 | |
102 | //======================================================================= |
103 | //function : MakeArrows3D |
104 | //purpose : |
105 | //======================================================================= |
a6eb515f |
106 | void Prs3d_DimensionAspect::MakeArrows3d (const Standard_Boolean isArrows3d) |
107 | { |
108 | myIsArrows3d = isArrows3d; |
109 | } |
60bf98ae |
110 | |
a6eb515f |
111 | //======================================================================= |
112 | //function : IsArrows3D |
113 | //purpose : |
114 | //======================================================================= |
115 | Standard_Boolean Prs3d_DimensionAspect::IsArrows3d () const |
116 | { |
117 | return myIsArrows3d; |
118 | } |
119 | |
120 | //======================================================================= |
121 | //function : MakeText3D |
122 | //purpose : |
123 | //======================================================================= |
a6eb515f |
124 | void Prs3d_DimensionAspect::MakeText3d (const Standard_Boolean isText3d) |
125 | { |
126 | myIsText3d = isText3d; |
127 | } |
60bf98ae |
128 | |
a6eb515f |
129 | //======================================================================= |
130 | //function : IsText3D |
131 | //purpose : |
132 | //======================================================================= |
133 | Standard_Boolean Prs3d_DimensionAspect::IsText3d () const |
134 | { |
135 | return myIsText3d; |
136 | } |
137 | |
60bf98ae |
138 | //======================================================================= |
139 | //function : IsUnitsDisplayed |
140 | //purpose : |
141 | //======================================================================= |
142 | Standard_Boolean Prs3d_DimensionAspect::IsUnitsDisplayed () const |
143 | { |
144 | return myToDisplayUnits; |
145 | } |
146 | |
147 | //======================================================================= |
148 | //function : MakeUnitsDisplayed |
149 | //purpose : |
150 | //======================================================================= |
151 | void Prs3d_DimensionAspect::MakeUnitsDisplayed (const Standard_Boolean theIsDisplayed) |
152 | { |
153 | myToDisplayUnits = theIsDisplayed; |
154 | } |
155 | |
a6eb515f |
156 | //======================================================================= |
157 | //function : IsTextShaded |
158 | //purpose : |
159 | //======================================================================= |
160 | Standard_Boolean Prs3d_DimensionAspect::IsTextShaded () const |
161 | { |
162 | return myIsTextShaded; |
163 | } |
164 | |
165 | //======================================================================= |
166 | //function : MakeTextShaded |
167 | //purpose : |
168 | //======================================================================= |
a6eb515f |
169 | void Prs3d_DimensionAspect::MakeTextShaded (const Standard_Boolean isTextShaded) |
170 | { |
171 | myIsTextShaded = isTextShaded; |
172 | } |
173 | |
174 | //======================================================================= |
175 | //function : SetArrowOrientation |
176 | //purpose : |
177 | //======================================================================= |
a6eb515f |
178 | void Prs3d_DimensionAspect::SetArrowOrientation (const Prs3d_DimensionArrowOrientation theArrowOrient) |
179 | { |
180 | myArrowOrientation = theArrowOrient; |
181 | } |
182 | |
183 | //======================================================================= |
184 | //function : GetArrowOrientation |
185 | //purpose : |
186 | //======================================================================= |
d7bffd44 |
187 | Prs3d_DimensionArrowOrientation Prs3d_DimensionAspect::ArrowOrientation() const |
a6eb515f |
188 | { |
189 | return myArrowOrientation; |
190 | } |
191 | |
192 | //======================================================================= |
d7bffd44 |
193 | //function : SetTextVerticalPosition |
194 | //purpose : |
195 | //======================================================================= |
d7bffd44 |
196 | void Prs3d_DimensionAspect::SetTextVerticalPosition (const Prs3d_DimensionTextVerticalPosition thePosition) |
a6eb515f |
197 | { |
d7bffd44 |
198 | myTextVPosition = thePosition; |
a6eb515f |
199 | } |
d7bffd44 |
200 | |
a6eb515f |
201 | //======================================================================= |
d7bffd44 |
202 | //function : TextVerticalPosition |
203 | //purpose : |
204 | //======================================================================= |
d7bffd44 |
205 | Prs3d_DimensionTextVerticalPosition Prs3d_DimensionAspect::TextVerticalPosition() const |
a6eb515f |
206 | { |
d7bffd44 |
207 | return myTextVPosition; |
a6eb515f |
208 | } |
209 | |
210 | //======================================================================= |
d7bffd44 |
211 | //function : SetTextHorizontalPosition |
a6eb515f |
212 | //purpose : |
d7bffd44 |
213 | //======================================================================= |
d7bffd44 |
214 | void Prs3d_DimensionAspect::SetTextHorizontalPosition (const Prs3d_DimensionTextHorizontalPosition thePosition) |
a6eb515f |
215 | { |
d7bffd44 |
216 | myTextHPosition = thePosition; |
a6eb515f |
217 | } |
d7bffd44 |
218 | |
a6eb515f |
219 | //======================================================================= |
d7bffd44 |
220 | //function : TextHorizontalPosition |
a6eb515f |
221 | //purpose : |
d7bffd44 |
222 | //======================================================================= |
d7bffd44 |
223 | Prs3d_DimensionTextHorizontalPosition Prs3d_DimensionAspect::TextHorizontalPosition() const |
a6eb515f |
224 | { |
d7bffd44 |
225 | return myTextHPosition; |
a6eb515f |
226 | } |
227 | |
228 | //======================================================================= |
229 | //function : ArrowAspect |
230 | //purpose : |
231 | //======================================================================= |
a6eb515f |
232 | Handle(Prs3d_ArrowAspect) Prs3d_DimensionAspect::ArrowAspect () const |
233 | { |
234 | return myArrowAspect; |
235 | } |
236 | |
237 | //======================================================================= |
238 | //function : SetArrowAspect |
239 | //purpose : |
240 | //======================================================================= |
a6eb515f |
241 | void Prs3d_DimensionAspect::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect) |
242 | { |
243 | myArrowAspect = theAspect; |
244 | } |
d7bffd44 |
245 | |
246 | //======================================================================= |
247 | //function : SetExtensioSize |
248 | //purpose : |
249 | //======================================================================= |
d7bffd44 |
250 | void Prs3d_DimensionAspect::SetExtensionSize (const Standard_Real theSize) |
251 | { |
252 | myExtensionSize = theSize; |
253 | } |
254 | |
255 | //======================================================================= |
256 | //function : ExtensionSize |
257 | //purpose : |
258 | //======================================================================= |
d7bffd44 |
259 | Standard_Real Prs3d_DimensionAspect::ExtensionSize() const |
260 | { |
261 | return myExtensionSize; |
262 | } |
60bf98ae |
263 | |
264 | //======================================================================= |
265 | //function : SetValueStringFormat |
266 | //purpose : |
267 | //======================================================================= |
268 | void Prs3d_DimensionAspect::SetValueStringFormat (const TCollection_AsciiString& theFormat) |
269 | { |
270 | myValueStringFormat = theFormat; |
271 | } |
272 | |
273 | //======================================================================= |
274 | //function : ValueStringFormat |
275 | //purpose : |
276 | //======================================================================= |
277 | TCollection_AsciiString Prs3d_DimensionAspect::ValueStringFormat() const |
278 | { |
279 | return myValueStringFormat; |
280 | } |