b311480e |
1 | // Copyright (c) 1998-1999 Matra Datavision |
2 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
3 | // |
4 | // The content of this file is subject to the Open CASCADE Technology Public |
5 | // License Version 6.5 (the "License"). You may not use the content of this file |
6 | // except in compliance with the License. Please obtain a copy of the License |
7 | // at http://www.opencascade.org and read it completely before using this file. |
8 | // |
9 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
10 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
11 | // |
12 | // The Original Code and all software distributed under the License is |
13 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
14 | // Initial Developer hereby disclaims all such warranties, including without |
15 | // limitation, any warranties of merchantability, fitness for a particular |
16 | // purpose or non-infringement. Please see the License for the specific terms |
17 | // and conditions governing the rights and limitations under the License. |
18 | |
7fd59977 |
19 | #include <AIS_Drawer.ixx> |
20 | #include <Standard_ProgramError.hxx> |
21 | |
60bf98ae |
22 | // ======================================================================= |
23 | // function : AIS_Drawer |
24 | // purpose : |
25 | // ======================================================================= |
26 | AIS_Drawer::AIS_Drawer() |
27 | : myLink (new Prs3d_Drawer()), |
28 | hasLocalAttributes (Standard_False), |
29 | myhasOwnDeviationCoefficient (Standard_False), |
30 | myPreviousDeviationCoefficient (0.1), |
31 | myhasOwnHLRDeviationCoefficient (Standard_False), |
32 | myhasOwnDeviationAngle (Standard_False), |
33 | myhasOwnHLRDeviationAngle (Standard_False), |
34 | myHasOwnFaceBoundaryDraw (Standard_False) |
7fd59977 |
35 | { |
60bf98ae |
36 | SetMaximalParameterValue (500000.0); |
37 | myLink->SetMaximalParameterValue (500000.0); |
0a768f56 |
38 | SetTypeOfHLR (Prs3d_TOH_NotSet); |
60bf98ae |
39 | } |
7fd59977 |
40 | |
41 | Aspect_TypeOfDeflection AIS_Drawer::TypeOfDeflection () const |
42 | { |
43 | return myLink->TypeOfDeflection(); |
44 | } |
45 | |
46 | Standard_Boolean AIS_Drawer::IsoOnPlane() const |
47 | { |
48 | return myLink->IsoOnPlane(); |
49 | } |
50 | |
51 | Standard_Integer AIS_Drawer::Discretisation() const |
52 | { |
53 | return myLink->Discretisation(); |
54 | } |
55 | |
56 | Quantity_Length AIS_Drawer::MaximalChordialDeviation() const |
57 | { |
58 | return myLink->MaximalChordialDeviation(); |
59 | } |
60 | |
61 | |
62 | //======================================================================= |
63 | //function : SetDeviationCoefficient |
64 | //purpose : |
65 | //======================================================================= |
66 | |
67 | void AIS_Drawer::SetDeviationCoefficient ( const Standard_Real aCoefficient ) |
68 | { |
69 | myPreviousDeviationCoefficient = DeviationCoefficient() ; |
70 | myOwnDeviationCoefficient = aCoefficient ; |
71 | myhasOwnDeviationCoefficient = Standard_True; |
72 | } |
73 | |
74 | |
75 | //======================================================================= |
76 | //function : SetHLRDeviationCoefficient |
77 | //purpose : |
78 | //======================================================================= |
79 | |
80 | void AIS_Drawer::SetHLRDeviationCoefficient ( const Standard_Real aCoefficient ) |
81 | { |
82 | myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient() ; |
83 | myOwnHLRDeviationCoefficient = aCoefficient ; |
84 | myhasOwnHLRDeviationCoefficient = Standard_True; |
85 | } |
86 | |
87 | //======================================================================= |
88 | //function : SetDeviationAngle |
89 | //purpose : |
90 | //======================================================================= |
91 | |
92 | void AIS_Drawer::SetDeviationAngle ( const Standard_Real anAngle ) |
93 | { |
94 | myPreviousDeviationAngle = DeviationAngle() ; |
95 | myOwnDeviationAngle = anAngle ; |
96 | myhasOwnDeviationAngle = Standard_True; |
97 | } |
98 | |
99 | //======================================================================= |
100 | //function : SetHLRAngle |
101 | //purpose : |
102 | //======================================================================= |
103 | |
104 | void AIS_Drawer::SetHLRAngle ( const Standard_Real anAngle ) |
105 | { |
106 | myPreviousHLRDeviationAngle = HLRAngle() ; |
107 | myOwnHLRDeviationAngle = anAngle ; |
108 | myhasOwnHLRDeviationAngle = Standard_True; |
109 | } |
110 | |
7fd59977 |
111 | /////// Get |
112 | //======================================================================= |
113 | //function : DeviationCoefficient |
114 | //purpose : |
115 | //======================================================================= |
116 | |
117 | Standard_Real AIS_Drawer::DeviationCoefficient () const |
118 | { |
119 | return myhasOwnDeviationCoefficient? myOwnDeviationCoefficient :myLink->DeviationCoefficient(); |
120 | } |
121 | |
122 | //======================================================================= |
123 | //function : HLRDeviationCoefficient |
124 | //purpose : |
125 | //======================================================================= |
126 | |
127 | Standard_Real AIS_Drawer::HLRDeviationCoefficient () const |
128 | { |
129 | return myhasOwnHLRDeviationCoefficient?myOwnHLRDeviationCoefficient : myLink->HLRDeviationCoefficient() ; |
130 | } |
131 | |
132 | //======================================================================= |
133 | //function : DeviationAngle |
134 | //purpose : |
135 | //======================================================================= |
136 | |
137 | Standard_Real AIS_Drawer::DeviationAngle () const |
138 | { |
139 | return myhasOwnDeviationAngle ? myOwnDeviationAngle : myLink->DeviationAngle(); |
140 | } |
141 | |
142 | //======================================================================= |
143 | //function : HLRAngle |
144 | //purpose : |
145 | //======================================================================= |
146 | |
147 | Standard_Real AIS_Drawer::HLRAngle () const |
148 | { |
149 | |
150 | return myhasOwnHLRDeviationAngle ? myOwnHLRDeviationAngle : myLink->HLRAngle(); |
151 | } |
152 | |
153 | Standard_Real AIS_Drawer::MaximalParameterValue () const |
154 | { return myLink->MaximalParameterValue();} |
155 | |
156 | Handle (Prs3d_IsoAspect) AIS_Drawer::UIsoAspect () |
157 | { return myUIsoAspect.IsNull() ? myLink->UIsoAspect (): myUIsoAspect;} |
158 | |
159 | Handle (Prs3d_IsoAspect) AIS_Drawer::VIsoAspect () |
160 | { return myVIsoAspect.IsNull() ? myLink->VIsoAspect (): myVIsoAspect;} |
161 | |
162 | Handle (Prs3d_LineAspect) AIS_Drawer::FreeBoundaryAspect () |
163 | {return myFreeBoundaryAspect.IsNull() ? myLink->FreeBoundaryAspect (): myFreeBoundaryAspect;} |
164 | |
165 | Standard_Boolean AIS_Drawer::FreeBoundaryDraw () const |
166 | {return myLink->FreeBoundaryDraw();} |
167 | |
168 | Handle (Prs3d_LineAspect) AIS_Drawer::UnFreeBoundaryAspect () |
169 | {return myUnFreeBoundaryAspect.IsNull() ? myLink->UnFreeBoundaryAspect (): myUnFreeBoundaryAspect;} |
170 | |
171 | Standard_Boolean AIS_Drawer::UnFreeBoundaryDraw () const |
172 | {return myLink->UnFreeBoundaryDraw ();} |
173 | |
174 | Handle (Prs3d_LineAspect) AIS_Drawer::WireAspect () |
175 | { return myWireAspect.IsNull()? myLink->WireAspect (): myWireAspect;} |
176 | |
177 | Standard_Boolean AIS_Drawer::WireDraw () const |
178 | { return myLink->WireDraw();} |
179 | |
180 | Handle (Prs3d_LineAspect) AIS_Drawer::LineAspect () |
181 | { return myLineAspect.IsNull() ? myLink->LineAspect (): myLineAspect;} |
182 | |
183 | Handle (Prs3d_TextAspect) AIS_Drawer::TextAspect () |
184 | { return myTextAspect.IsNull() ? myLink->TextAspect () : myTextAspect ;} |
185 | |
186 | Handle (Prs3d_ShadingAspect) AIS_Drawer::ShadingAspect () |
187 | { |
188 | return myShadingAspect.IsNull() ? myLink->ShadingAspect () : myShadingAspect ; |
189 | } |
190 | |
191 | Standard_Boolean AIS_Drawer::ShadingAspectGlobal() const |
192 | { return myLink->ShadingAspectGlobal();} |
193 | |
194 | |
195 | Standard_Boolean AIS_Drawer::LineArrowDraw () const |
196 | { return myLink->LineArrowDraw();} |
197 | |
198 | Handle (Prs3d_ArrowAspect) AIS_Drawer::ArrowAspect() |
199 | {return myArrowAspect.IsNull()? myLink->ArrowAspect () : myArrowAspect;} |
200 | |
201 | Handle (Prs3d_PointAspect) AIS_Drawer::PointAspect() |
202 | {return myPointAspect.IsNull()? myLink->PointAspect () : myPointAspect;} |
203 | |
204 | Standard_Boolean AIS_Drawer::DrawHiddenLine () const |
205 | {return myLink->DrawHiddenLine();} |
206 | |
207 | Handle (Prs3d_LineAspect) AIS_Drawer::HiddenLineAspect () |
208 | {return myHiddenLineAspect.IsNull()? myLink->HiddenLineAspect () : myHiddenLineAspect;} |
209 | |
210 | Handle (Prs3d_LineAspect) AIS_Drawer::SeenLineAspect () |
211 | { return mySeenLineAspect.IsNull() ? myLink->SeenLineAspect (): mySeenLineAspect ;} |
212 | |
213 | Handle (Prs3d_LineAspect) AIS_Drawer::VectorAspect () |
214 | {return myVectorAspect.IsNull()? myLink->VectorAspect () : myVectorAspect;} |
215 | |
216 | Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect () |
217 | {return myDatumAspect.IsNull()? myLink->DatumAspect () : myDatumAspect; } |
218 | |
219 | Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect () |
220 | {return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;} |
221 | |
60bf98ae |
222 | // ======================================================================= |
223 | // function : DimensionAspect |
224 | // purpose : |
225 | // ======================================================================= |
226 | Handle (Prs3d_DimensionAspect) AIS_Drawer::DimensionAspect() |
227 | { |
228 | return myDimensionAspect.IsNull()? myLink->DimensionAspect () : myDimensionAspect; |
229 | } |
230 | |
231 | // ======================================================================= |
232 | // function : DimAngleModelUnits |
233 | // purpose : |
234 | // ======================================================================= |
235 | const TCollection_AsciiString& AIS_Drawer::DimAngleModelUnits() const |
236 | { |
237 | return myHasOwnDimAngleModelUnits |
238 | ? Prs3d_Drawer::DimAngleModelUnits() |
239 | : myLink->DimAngleModelUnits(); |
240 | } |
241 | |
242 | // ======================================================================= |
243 | // function : DimensionModelUnits |
244 | // purpose : |
245 | // ======================================================================= |
246 | const TCollection_AsciiString& AIS_Drawer::DimLengthModelUnits() const |
247 | { |
248 | return myHasOwnDimLengthModelUnits |
249 | ? Prs3d_Drawer::DimLengthModelUnits() |
250 | : myLink->DimLengthModelUnits(); |
251 | } |
252 | // ======================================================================= |
253 | // function : SetDimLengthModelUnits |
254 | // purpose : |
255 | // ======================================================================= |
256 | void AIS_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits) |
257 | { |
258 | myHasOwnDimLengthModelUnits = Standard_True; |
259 | Prs3d_Drawer::SetDimLengthDisplayUnits (theUnits); |
260 | } |
261 | |
262 | // ======================================================================= |
263 | // function : SetDimAngleModelUnits |
264 | // purpose : |
265 | // ======================================================================= |
266 | void AIS_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits) |
267 | { |
268 | myHasOwnDimAngleModelUnits = Standard_True; |
269 | Prs3d_Drawer::SetDimAngleDisplayUnits (theUnits); |
270 | } |
271 | |
272 | // ======================================================================= |
273 | // function : DimAngleDisplayUnits |
274 | // purpose : |
275 | // ======================================================================= |
276 | const TCollection_AsciiString& AIS_Drawer::DimAngleDisplayUnits() const |
277 | { |
278 | return myHasOwnDimAngleDisplayUnits |
279 | ? Prs3d_Drawer::DimAngleDisplayUnits() |
280 | : myLink->DimAngleDisplayUnits(); |
281 | } |
282 | |
283 | // ======================================================================= |
284 | // function : DimLengthDisplayUnits |
285 | // purpose : |
286 | // ======================================================================= |
287 | const TCollection_AsciiString& AIS_Drawer::DimLengthDisplayUnits() const |
288 | { |
289 | return myHasOwnDimLengthDisplayUnits |
290 | ? Prs3d_Drawer::DimLengthDisplayUnits() |
291 | : myLink->DimLengthDisplayUnits(); |
292 | } |
293 | |
294 | // ======================================================================= |
295 | // function : SetDimLengthDisplayUnits |
296 | // purpose : |
297 | // ======================================================================= |
298 | void AIS_Drawer::SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits) |
299 | { |
300 | myHasOwnDimLengthDisplayUnits = Standard_True; |
301 | Prs3d_Drawer::SetDimLengthDisplayUnits (theUnits); |
302 | } |
303 | |
304 | // ======================================================================= |
305 | // function : SetDimAngleDisplayUnits |
306 | // purpose : |
307 | // ======================================================================= |
308 | void AIS_Drawer::SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits) |
309 | { |
310 | myHasOwnDimAngleDisplayUnits = Standard_True; |
311 | Prs3d_Drawer::SetDimAngleDisplayUnits (theUnits); |
312 | } |
7fd59977 |
313 | |
314 | Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect () |
315 | {return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;} |
316 | |
317 | const Handle (Prs3d_Drawer)& AIS_Drawer::Link() |
318 | { |
319 | if(myLink.IsNull()) myLink = new Prs3d_Drawer(); |
320 | return myLink; |
321 | } |
322 | |
323 | void AIS_Drawer::ClearLocalAttributes() |
324 | { |
325 | if(myLink.IsNull()) return; |
326 | // attention pas beau.... |
327 | // The Handles |
328 | |
329 | if(!myUIsoAspect.IsNull()) myUIsoAspect.Nullify(); |
330 | if(!myVIsoAspect.IsNull()) myVIsoAspect.Nullify(); |
331 | if(!myFreeBoundaryAspect.IsNull()) myFreeBoundaryAspect.Nullify(); |
332 | if(!myUnFreeBoundaryAspect.IsNull()) myUnFreeBoundaryAspect.Nullify(); |
333 | if(!myWireAspect.IsNull()) myWireAspect.Nullify(); |
334 | if(!myLineAspect.IsNull()) myLineAspect.Nullify(); |
335 | if(!myTextAspect.IsNull()) myTextAspect.Nullify(); |
336 | if(!myShadingAspect.IsNull()) myShadingAspect.Nullify(); |
337 | if(!myPointAspect.IsNull()) myPointAspect.Nullify(); |
338 | if(!myPlaneAspect.IsNull()) myPlaneAspect.Nullify(); |
339 | if(!myArrowAspect.IsNull()) myArrowAspect.Nullify(); |
340 | if(!myHiddenLineAspect.IsNull()) myHiddenLineAspect.Nullify(); |
341 | if(!mySeenLineAspect.IsNull()) mySeenLineAspect.Nullify(); |
342 | if(!myVectorAspect.IsNull()) myVectorAspect .Nullify(); |
343 | if(!myDatumAspect.IsNull()) myDatumAspect.Nullify(); |
a6eb515f |
344 | if(!myDimensionAspect.IsNull()) myDimensionAspect.Nullify(); |
7fd59977 |
345 | if(!mySectionAspect.IsNull()) mySectionAspect.Nullify(); |
346 | if( myhasOwnHLRDeviationCoefficient ) myhasOwnHLRDeviationCoefficient = Standard_False; |
a2d5ab2e |
347 | if(myhasOwnHLRDeviationAngle ) myhasOwnHLRDeviationAngle = Standard_False; |
348 | if (!myFaceBoundaryAspect.IsNull()) myFaceBoundaryAspect.Nullify(); |
7fd59977 |
349 | |
a2d5ab2e |
350 | myHasOwnFaceBoundaryDraw = Standard_False; |
60bf98ae |
351 | myHasOwnDimLengthModelUnits = Standard_False; |
352 | myHasOwnDimLengthDisplayUnits = Standard_False; |
353 | myHasOwnDimAngleModelUnits = Standard_False; |
354 | myHasOwnDimAngleDisplayUnits = Standard_False; |
a2d5ab2e |
355 | |
7fd59977 |
356 | hasLocalAttributes = Standard_False; |
357 | |
358 | } |
359 | |
a2d5ab2e |
360 | // ======================================================================= |
361 | // function : SetFaceBoundaryDraw |
362 | // purpose : |
363 | // ======================================================================= |
364 | void AIS_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled) |
365 | { |
366 | myHasOwnFaceBoundaryDraw = Standard_True; |
367 | myFaceBoundaryDraw = theIsEnabled; |
368 | } |
369 | |
370 | // ======================================================================= |
371 | // function : IsFaceBoundaryDraw |
372 | // purpose : |
373 | // ======================================================================= |
374 | Standard_Boolean AIS_Drawer::IsFaceBoundaryDraw() const |
375 | { |
376 | if (!IsOwnFaceBoundaryDraw ()) |
377 | { |
378 | return myLink->IsFaceBoundaryDraw (); |
379 | } |
380 | |
381 | return myFaceBoundaryDraw; |
382 | } |
7fd59977 |
383 | |
a2d5ab2e |
384 | // ======================================================================= |
385 | // function : SetFaceBoundaryAspect |
386 | // purpose : |
387 | // ======================================================================= |
388 | void AIS_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect) |
389 | { |
390 | myFaceBoundaryAspect = theAspect; |
391 | } |
392 | |
393 | // ======================================================================= |
394 | // function : FaceBoundaryAspect |
395 | // purpose : |
396 | // ======================================================================= |
397 | Handle_Prs3d_LineAspect AIS_Drawer::FaceBoundaryAspect() |
398 | { |
399 | if (!IsOwnFaceBoundaryAspect ()) |
400 | { |
401 | return myLink->FaceBoundaryAspect (); |
402 | } |
403 | |
404 | return myFaceBoundaryAspect; |
405 | } |