e7beea19f1d74ca78737cf93364f2f45d36f19fb
[occt.git] / src / Prs3d / Prs3d_Drawer.cxx
1 // Copyright (c) 1995-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_Drawer.hxx>
16 #include <Prs3d_ArrowAspect.hxx>
17 #include <Prs3d_DatumAspect.hxx>
18 #include <Prs3d_DimensionAspect.hxx>
19 #include <Prs3d_IsoAspect.hxx>
20 #include <Prs3d_LineAspect.hxx>
21 #include <Prs3d_PlaneAspect.hxx>
22 #include <Prs3d_PointAspect.hxx>
23 #include <Prs3d_ShadingAspect.hxx>
24 #include <Prs3d_TextAspect.hxx>
25
26
27 // =======================================================================
28 // function : Prs3d_Drawer
29 // purpose  :
30 // =======================================================================
31 Prs3d_Drawer::Prs3d_Drawer()
32 : myNbPoints                      (30),
33   myHasOwnNbPoints                (Standard_False),
34   myMaximalParameterValue         (500000.),
35   myHasOwnMaximalParameterValue   (Standard_False),
36   myChordialDeviation             (0.0001),
37   myHasOwnChordialDeviation       (Standard_False),
38   myTypeOfDeflection              (Aspect_TOD_RELATIVE),
39   myHasOwnTypeOfDeflection        (Standard_False),
40   myTypeOfHLR                     (Prs3d_TOH_NotSet),
41   myDeviationCoefficient          (0.001),
42   myHasOwnDeviationCoefficient    (Standard_False),
43   myHLRDeviationCoefficient       (0.02),
44   myHasOwnHLRDeviationCoefficient (Standard_False),
45   myDeviationAngle                (12.0 * M_PI / 180.0),
46   myHasOwnDeviationAngle          (Standard_False),
47   myHLRAngle                      (20.0 * M_PI / 180.0),
48   myHasOwnHLRDeviationAngle       (Standard_False),
49   myIsoOnPlane                    (Standard_False),
50   myHasOwnIsoOnPlane              (Standard_False),
51   myIsAutoTriangulated            (Standard_True),
52   myHasOwnIsAutoTriangulated      (Standard_False),
53
54   myHasOwnUIsoAspect          (Standard_False),
55   myHasOwnVIsoAspect          (Standard_False),
56   myHasOwnWireAspect          (Standard_False),
57   myWireDraw                  (Standard_True),
58   myHasOwnWireDraw            (Standard_False),
59   myHasOwnPointAspect         (Standard_False),
60   myHasOwnLineAspect          (Standard_False),
61   myHasOwnTextAspect          (Standard_False),
62   myHasOwnShadingAspect       (Standard_False),
63   myShadingAspectGlobal       (Standard_True),
64   myHasOwnShadingAspectGlobal (Standard_False),
65   myHasOwnPlaneAspect         (Standard_False),
66   myHasOwnSeenLineAspect      (Standard_False),
67   myHasOwnArrowAspect         (Standard_False),
68   myLineArrowDraw             (Standard_False),
69   myHasOwnLineArrowDraw       (Standard_False),
70   myHasOwnHiddenLineAspect    (Standard_False),
71   myDrawHiddenLine            (Standard_False),
72   myHasOwnDrawHiddenLine      (Standard_False),
73   myHasOwnVectorAspect        (Standard_False),
74   myVertexDrawMode            (Prs3d_VDM_Inherited),
75   myHasOwnDatumAspect         (Standard_False),
76   myHasOwnSectionAspect       (Standard_False),
77
78   myHasOwnFreeBoundaryAspect   (Standard_False),
79   myFreeBoundaryDraw           (Standard_True),
80   myHasOwnFreeBoundaryDraw     (Standard_False),
81   myHasOwnUnFreeBoundaryAspect (Standard_False),
82   myUnFreeBoundaryDraw         (Standard_True),
83   myHasOwnUnFreeBoundaryDraw   (Standard_False),
84   myHasOwnFaceBoundaryAspect   (Standard_False),
85   myFaceBoundaryDraw           (Standard_False),
86   myHasOwnFaceBoundaryDraw     (Standard_False),
87
88   myHasOwnDimensionAspect       (Standard_False),
89   myHasOwnDimLengthModelUnits   (Standard_False),
90   myHasOwnDimAngleModelUnits    (Standard_False),
91   myHasOwnDimLengthDisplayUnits (Standard_False),
92   myHasOwnDimAngleDisplayUnits  (Standard_False)
93 {
94   myDimensionModelUnits.SetLengthUnits ("m");
95   myDimensionModelUnits.SetAngleUnits ("rad");
96   myDimensionDisplayUnits.SetLengthUnits ("m");
97   myDimensionDisplayUnits.SetAngleUnits ("deg");
98 }
99
100 // =======================================================================
101 // function : SetTypeOfDeflection
102 // purpose  :
103 // =======================================================================
104
105 void Prs3d_Drawer::SetTypeOfDeflection (const Aspect_TypeOfDeflection theTypeOfDeflection)
106 {
107   myHasOwnTypeOfDeflection = Standard_True;
108   myTypeOfDeflection       = theTypeOfDeflection;
109 }
110
111 // =======================================================================
112 // function : SetMaximalChordialDeviation
113 // purpose  :
114 // =======================================================================
115
116 void Prs3d_Drawer::SetMaximalChordialDeviation (const Quantity_Length theChordialDeviation)
117 {
118   myHasOwnChordialDeviation = Standard_True;
119   myChordialDeviation       = theChordialDeviation;
120 }
121
122 // =======================================================================
123 // function : SetTypeOfHLR
124 // purpose  : set type of HLR algorithm
125 // =======================================================================
126
127 void Prs3d_Drawer::SetTypeOfHLR (const Prs3d_TypeOfHLR theTypeOfHLR)
128 {
129   myTypeOfHLR = theTypeOfHLR;
130 }
131
132 // =======================================================================
133 // function : TypeOfHLR
134 // purpose  : gets type of HLR algorithm
135 // =======================================================================
136
137 Prs3d_TypeOfHLR Prs3d_Drawer::TypeOfHLR()
138 {
139   if (!HasOwnTypeOfHLR())
140   {
141     if (!myLink.IsNull())
142     {
143       return myLink->TypeOfHLR();
144     }
145     // Prs3d_TOH_PolyAlgo is default value for this setting.
146     myTypeOfHLR = Prs3d_TOH_PolyAlgo;
147   }
148   return myTypeOfHLR;
149 }
150
151 // =======================================================================
152 // function : SetMaximalParameterValue
153 // purpose  :
154 // =======================================================================
155
156 void Prs3d_Drawer::SetMaximalParameterValue (const Standard_Real theValue)
157 {
158   myHasOwnMaximalParameterValue = Standard_True;
159   myMaximalParameterValue       = theValue;
160 }
161
162 // =======================================================================
163 // function : SetIsoOnPlane
164 // purpose  :
165 // =======================================================================
166
167 void Prs3d_Drawer::SetIsoOnPlane (const Standard_Boolean theIsEnabled)
168 {
169   myHasOwnIsoOnPlane = Standard_True;
170   myIsoOnPlane       = theIsEnabled;
171 }
172
173 // =======================================================================
174 // function : SetDiscretisation
175 // purpose  :
176 // =======================================================================
177
178 void Prs3d_Drawer::SetDiscretisation (const Standard_Integer theValue) 
179 {
180   myHasOwnNbPoints = Standard_True;
181   myNbPoints       = theValue;
182 }
183
184 //=======================================================================
185 //function : SetDeviationCoefficient
186 //purpose  : 
187 //=======================================================================
188
189 void Prs3d_Drawer::SetDeviationCoefficient (const Standard_Real theCoefficient)
190 {
191   myPreviousDeviationCoefficient = DeviationCoefficient();
192   myDeviationCoefficient         = theCoefficient;
193   myHasOwnDeviationCoefficient   = Standard_True;
194 }
195
196 //=======================================================================
197 //function : SetHLRDeviationCoefficient
198 //purpose  : 
199 //=======================================================================
200
201 void Prs3d_Drawer::SetHLRDeviationCoefficient (const Standard_Real theCoefficient)
202 {
203   myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient();
204   myHLRDeviationCoefficient         = theCoefficient;
205   myHasOwnHLRDeviationCoefficient   = Standard_True;
206 }
207
208 //=======================================================================
209 //function : SetDeviationAngle
210 //purpose  : 
211 //=======================================================================
212
213 void Prs3d_Drawer::SetDeviationAngle (const Standard_Real theAngle)
214 {
215   myPreviousDeviationAngle = DeviationAngle();
216   myDeviationAngle         = theAngle;
217   myHasOwnDeviationAngle   = Standard_True;
218 }
219
220 //=======================================================================
221 //function : SetHLRAngle
222 //purpose  : 
223 //=======================================================================
224
225 void Prs3d_Drawer::SetHLRAngle (const Standard_Real theAngle)
226 {
227   myPreviousHLRDeviationAngle = HLRAngle();
228   myHLRAngle                  = theAngle;
229   myHasOwnHLRDeviationAngle   = Standard_True;
230 }
231
232 // =======================================================================
233 // function : SetAutoTriangulation
234 // purpose  :
235 // =======================================================================
236
237 void Prs3d_Drawer::SetAutoTriangulation (const Standard_Boolean theIsEnabled)
238 {
239   myHasOwnIsAutoTriangulated = Standard_True;
240   myIsAutoTriangulated       = theIsEnabled;
241 }
242
243 // =======================================================================
244 // function : FreeBoundaryAspect
245 // purpose  :
246 // =======================================================================
247
248 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FreeBoundaryAspect()
249 {
250   if (!HasOwnFreeBoundaryAspect())
251   {
252     if (!myLink.IsNull())
253     {
254       return myLink->FreeBoundaryAspect();
255     }
256     if (myFreeBoundaryAspect.IsNull())
257     {
258       myFreeBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1.0);
259     }
260   }
261   return myFreeBoundaryAspect;
262 }
263
264 // =======================================================================
265 // function : FreeBoundaryAspect
266 // purpose  :
267 // =======================================================================
268
269 void Prs3d_Drawer::SetFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
270 {
271   myFreeBoundaryAspect = theAspect;
272   myHasOwnFreeBoundaryAspect = !myFreeBoundaryAspect.IsNull();
273 }
274
275 // =======================================================================
276 // function : SetFreeBoundaryDraw
277 // purpose  :
278 // =======================================================================
279
280 void Prs3d_Drawer::SetFreeBoundaryDraw (const Standard_Boolean theIsEnabled)
281 {
282   myHasOwnFreeBoundaryDraw = Standard_True;
283   myFreeBoundaryDraw       = theIsEnabled;
284 }
285
286 // =======================================================================
287 // function : UnFreeBoundaryAspect
288 // purpose  :
289 // =======================================================================
290
291 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::UnFreeBoundaryAspect()
292 {
293   if (!HasOwnUnFreeBoundaryAspect())
294   {
295     if (!myLink.IsNull())
296     {
297       return myLink->UnFreeBoundaryAspect();
298     }
299     if (myUnFreeBoundaryAspect.IsNull())
300     {
301       myUnFreeBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
302     }
303   }
304   return myUnFreeBoundaryAspect;
305 }
306
307 // =======================================================================
308 // function : SetUnFreeBoundaryAspect
309 // purpose  :
310 // =======================================================================
311
312 void Prs3d_Drawer::SetUnFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
313 {
314   myUnFreeBoundaryAspect = theAspect;
315   myHasOwnUnFreeBoundaryAspect = !myUnFreeBoundaryAspect.IsNull();
316 }
317
318 // =======================================================================
319 // function : SetUnFreeBoundaryDraw
320 // purpose  :
321 // =======================================================================
322
323 void Prs3d_Drawer::SetUnFreeBoundaryDraw (const Standard_Boolean theIsEnabled)
324 {
325   myHasOwnUnFreeBoundaryDraw = Standard_True;
326   myUnFreeBoundaryDraw       = theIsEnabled;
327 }
328
329 // =======================================================================
330 // function : FaceBoundaryAspect
331 // purpose  :
332 // =======================================================================
333
334 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FaceBoundaryAspect()
335 {
336   if (!HasOwnFaceBoundaryAspect())
337   {
338     if (!myLink.IsNull())
339     {
340       return myLink->FaceBoundaryAspect();
341     }
342     if (myFaceBoundaryAspect.IsNull())
343     {
344       myFaceBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0);
345     }
346   }
347   return myFaceBoundaryAspect;
348 }
349
350 // =======================================================================
351 // function : SetFaceBoundaryAspect
352 // purpose  :
353 // =======================================================================
354
355 void Prs3d_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
356 {
357   myFaceBoundaryAspect = theAspect;
358   myHasOwnFaceBoundaryAspect = !myFaceBoundaryAspect.IsNull();
359 }
360
361 // =======================================================================
362 // function : SetFaceBoundaryDraw
363 // purpose  :
364 // =======================================================================
365
366 void Prs3d_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
367 {
368   myHasOwnFaceBoundaryDraw = Standard_True;
369   myFaceBoundaryDraw       = theIsEnabled;
370 }
371
372 // =======================================================================
373 // function : DimensionAspect
374 // purpose  :
375 // =======================================================================
376
377 const Handle(Prs3d_DimensionAspect)& Prs3d_Drawer::DimensionAspect()
378 {
379   if (!HasOwnDimensionAspect())
380   {
381     if (!myLink.IsNull())
382     {
383       return myLink->DimensionAspect();
384     }
385     if (myDimensionAspect.IsNull())
386     {
387       myDimensionAspect = new Prs3d_DimensionAspect;
388     }
389   }
390   return myDimensionAspect;
391 }
392
393 // =======================================================================
394 // function : SetDimensionAspect
395 // purpose  :
396 // =======================================================================
397
398 void Prs3d_Drawer::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theAspect)
399 {
400   myDimensionAspect = theAspect;
401   myHasOwnDimensionAspect = !myDimensionAspect.IsNull();
402 }
403
404 // =======================================================================
405 // function : SetDimLengthModelUnits
406 // purpose  :
407 // =======================================================================
408
409 void Prs3d_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
410 {
411   myHasOwnDimLengthModelUnits = Standard_True;
412   myDimensionModelUnits.SetLengthUnits (theUnits);
413 }
414
415 // =======================================================================
416 // function : SetDimAngleModelUnits
417 // purpose  :
418 // =======================================================================
419
420 void Prs3d_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
421 {
422   myHasOwnDimAngleModelUnits = Standard_True;
423   myDimensionModelUnits.SetAngleUnits (theUnits);
424 }
425
426 // =======================================================================
427 // function : SetDimLengthDisplayUnits
428 // purpose  :
429 // =======================================================================
430
431 void Prs3d_Drawer::SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits)
432 {
433   myHasOwnDimLengthDisplayUnits = Standard_True;
434   myDimensionDisplayUnits.SetLengthUnits (theUnits);
435 }
436
437 // =======================================================================
438 // function : SetDimAngleDisplayUnits
439 // purpose  :
440 // =======================================================================
441
442 void Prs3d_Drawer::SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits)
443 {
444   myHasOwnDimAngleDisplayUnits = Standard_True;
445   myDimensionDisplayUnits.SetAngleUnits (theUnits);
446 }
447
448 // =======================================================================
449 // function : UIsoAspect
450 // purpose  :
451 // =======================================================================
452
453 const Handle(Prs3d_IsoAspect)& Prs3d_Drawer::UIsoAspect()
454 {
455   if (!HasOwnUIsoAspect())
456   {
457     if (!myLink.IsNull())
458     {
459       return myLink->UIsoAspect();
460     }
461     if (myUIsoAspect.IsNull())
462     {
463       myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5, 1);
464     }
465   }
466   return myUIsoAspect;
467 }
468
469 // =======================================================================
470 // function : SetUIsoAspect
471 // purpose  :
472 // =======================================================================
473
474 void Prs3d_Drawer::SetUIsoAspect (const Handle(Prs3d_IsoAspect)& theAspect)
475 {
476   myUIsoAspect = theAspect;
477   myHasOwnUIsoAspect = !myUIsoAspect.IsNull();
478 }
479
480 // =======================================================================
481 // function : VIsoAspect
482 // purpose  :
483 // =======================================================================
484
485 const Handle(Prs3d_IsoAspect)& Prs3d_Drawer::VIsoAspect()
486 {
487   if (!HasOwnVIsoAspect())
488   {
489     if (!myLink.IsNull())
490     {
491       return myLink->VIsoAspect();
492     }
493     if (myVIsoAspect.IsNull())
494     {
495       myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5, 1);
496     }
497   }
498   return myVIsoAspect;
499 }
500
501 // =======================================================================
502 // function : SetVIsoAspect
503 // purpose  :
504 // =======================================================================
505
506 void Prs3d_Drawer::SetVIsoAspect (const Handle(Prs3d_IsoAspect)& theAspect)
507 {
508   myVIsoAspect = theAspect;
509   myHasOwnVIsoAspect= !myVIsoAspect.IsNull();
510 }
511
512 // =======================================================================
513 // function : WireAspect
514 // purpose  :
515 // =======================================================================
516
517 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::WireAspect()
518 {
519   if (!HasOwnWireAspect())
520   {
521     if (!myLink.IsNull())
522     {
523       return myLink->WireAspect();
524     }
525     if (myWireAspect.IsNull())
526     {
527       myWireAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
528     }
529   }
530   return myWireAspect;
531 }
532
533 // =======================================================================
534 // function : SetWireAspect
535 // purpose  :
536 // =======================================================================
537
538 void Prs3d_Drawer::SetWireAspect (const Handle(Prs3d_LineAspect)& theAspect)
539 {
540   myWireAspect = theAspect;
541   myHasOwnWireAspect = !myWireAspect.IsNull();
542 }
543
544 // =======================================================================
545 // function : SetWireDraw
546 // purpose  :
547 // =======================================================================
548
549 void Prs3d_Drawer::SetWireDraw (const Standard_Boolean theIsEnabled)
550 {
551   myHasOwnWireDraw = Standard_True;
552   myWireDraw       = theIsEnabled;
553 }
554
555 // =======================================================================
556 // function : PointAspect
557 // purpose  :
558 // =======================================================================
559
560 const Handle(Prs3d_PointAspect)& Prs3d_Drawer::PointAspect()
561 {
562   if (!HasOwnPointAspect())
563   {
564     if (!myLink.IsNull())
565     {
566       return myLink->PointAspect();
567     }
568     if (myPointAspect.IsNull())
569     {
570       myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
571     }
572   }
573   return myPointAspect;
574 }
575
576 // =======================================================================
577 // function : SetPointAspect
578 // purpose  :
579 // =======================================================================
580
581 void Prs3d_Drawer::SetPointAspect (const Handle(Prs3d_PointAspect)& theAspect)
582 {
583   myPointAspect = theAspect;
584   myHasOwnPointAspect = !myPointAspect.IsNull();
585 }
586
587 // =======================================================================
588 // function : LineAspect
589 // purpose  :
590 // =======================================================================
591
592 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::LineAspect()
593 {
594   if (!HasOwnLineAspect())
595   {
596     if (!myLink.IsNull())
597     {
598       return myLink->LineAspect();
599     }
600     if (myLineAspect.IsNull())
601     {
602       myLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
603     }
604   }
605   return myLineAspect;
606 }
607
608 // =======================================================================
609 // function : SetLineAspect
610 // purpose  :
611 // =======================================================================
612
613 void Prs3d_Drawer::SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
614 {
615   myLineAspect = theAspect;
616   myHasOwnLineAspect = !myLineAspect.IsNull();
617 }
618
619 // =======================================================================
620 // function : TextAspect
621 // purpose  :
622 // =======================================================================
623
624 const Handle(Prs3d_TextAspect)& Prs3d_Drawer::TextAspect()
625 {
626   if (!HasOwnTextAspect())
627   {
628     if (!myLink.IsNull())
629     {
630       return myLink->TextAspect();
631     }
632     if (myTextAspect.IsNull())
633     {
634       myTextAspect = new Prs3d_TextAspect();
635     }
636   }
637   return myTextAspect;
638 }
639
640 // =======================================================================
641 // function : SetTextAspect
642 // purpose  :
643 // =======================================================================
644
645 void Prs3d_Drawer::SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect)
646 {
647   myTextAspect = theAspect;
648   myHasOwnTextAspect = !myTextAspect.IsNull();
649 }
650
651 // =======================================================================
652 // function : ShadingAspect
653 // purpose  :
654 // =======================================================================
655
656 const Handle(Prs3d_ShadingAspect)& Prs3d_Drawer::ShadingAspect()
657 {
658   if (!HasOwnShadingAspect())
659   {
660     if (!myLink.IsNull())
661     {
662       return myLink->ShadingAspect();
663     }
664     if (myShadingAspect.IsNull())
665     {
666       myShadingAspect = new Prs3d_ShadingAspect();
667     }
668   }
669   return myShadingAspect;
670 }
671
672 // =======================================================================
673 // function : SetShadingAspect
674 // purpose  :
675 // =======================================================================
676
677 void Prs3d_Drawer::SetShadingAspect (const Handle(Prs3d_ShadingAspect)& theAspect)
678 {
679   myShadingAspect = theAspect;
680   myHasOwnShadingAspect = !myShadingAspect.IsNull();
681 }
682
683 // =======================================================================
684 // function : SetShadingAspectGlobal
685 // purpose  :
686 // =======================================================================
687
688 void Prs3d_Drawer::SetShadingAspectGlobal (const Standard_Boolean theValue)
689 {
690   myHasOwnShadingAspectGlobal = Standard_True;
691   myShadingAspectGlobal       = theValue;
692 }
693
694 // =======================================================================
695 // function : PlaneAspect
696 // purpose  :
697 // =======================================================================
698
699 const Handle(Prs3d_PlaneAspect)& Prs3d_Drawer::PlaneAspect()
700 {
701   if (!HasOwnPlaneAspect())
702   {
703     if (!myLink.IsNull())
704     {
705       return myLink->PlaneAspect();
706     }
707     if (myPlaneAspect.IsNull())
708     {
709       myPlaneAspect = new Prs3d_PlaneAspect();
710     }
711   }
712   return myPlaneAspect;
713 }
714
715 // =======================================================================
716 // function : SetPlaneAspect
717 // purpose  :
718 // =======================================================================
719
720 void Prs3d_Drawer::SetPlaneAspect (const Handle(Prs3d_PlaneAspect)& theAspect)
721 {
722   myPlaneAspect = theAspect;
723   myHasOwnPlaneAspect = !myPlaneAspect.IsNull();
724 }
725
726 // =======================================================================
727 // function : SeenLineAspect
728 // purpose  :
729 // =======================================================================
730
731 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SeenLineAspect()
732 {
733   if (!HasOwnSeenLineAspect())
734   {
735     if (!myLink.IsNull())
736     {
737       return myLink->SeenLineAspect();
738     }
739     if (mySeenLineAspect.IsNull())
740     {
741       mySeenLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
742     }
743   }
744   return mySeenLineAspect;
745 }
746
747 // =======================================================================
748 // function : SetSeenLineAspect
749 // purpose  :
750 // =======================================================================
751
752 void Prs3d_Drawer::SetSeenLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
753 {
754   mySeenLineAspect = theAspect;
755   myHasOwnSeenLineAspect = !mySeenLineAspect.IsNull();
756 }
757
758 // =======================================================================
759 // function : ArrowAspect
760 // purpose  :
761 // =======================================================================
762
763 const Handle(Prs3d_ArrowAspect)& Prs3d_Drawer::ArrowAspect()
764 {
765   if (!HasOwnArrowAspect())
766   {
767     if (!myLink.IsNull())
768     {
769       return myLink->ArrowAspect();
770     }
771     if (myArrowAspect.IsNull())
772     {
773       myArrowAspect = new Prs3d_ArrowAspect();
774     }
775   }
776   return myArrowAspect;
777 }
778
779 // =======================================================================
780 // function : SetArrowAspect
781 // purpose  :
782 // =======================================================================
783
784 void Prs3d_Drawer::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect)
785 {
786   myArrowAspect = theAspect;
787   myHasOwnArrowAspect = !myArrowAspect.IsNull();
788 }
789
790 // =======================================================================
791 // function : SetLineArrowDraw
792 // purpose  :
793 // =======================================================================
794
795 void Prs3d_Drawer::SetLineArrowDraw (const Standard_Boolean theIsEnabled)
796 {
797   myHasOwnLineArrowDraw = Standard_True;
798   myLineArrowDraw       = theIsEnabled;
799 }
800
801 // =======================================================================
802 // function : HiddenLineAspect
803 // purpose  :
804 // =======================================================================
805
806 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::HiddenLineAspect()
807 {
808   if (!HasOwnHiddenLineAspect())
809   {
810     if (!myLink.IsNull())
811     {
812       return myLink->HiddenLineAspect();
813     }
814     if (myHiddenLineAspect.IsNull())
815     {
816       myHiddenLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_DASH, 0.5);
817     }
818   }
819   return myHiddenLineAspect;
820 }
821
822 // =======================================================================
823 // function : SetHiddenLineAspect
824 // purpose  :
825 // =======================================================================
826
827 void Prs3d_Drawer::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
828 {
829   myHiddenLineAspect = theAspect;
830   myHasOwnHiddenLineAspect = !myHiddenLineAspect.IsNull();
831 }
832
833 // =======================================================================
834 // function : EnableDrawHiddenLineDraw
835 // purpose  :
836 // =======================================================================
837
838 void Prs3d_Drawer::EnableDrawHiddenLine()
839 {
840     myHasOwnDrawHiddenLine = Standard_True;
841     myDrawHiddenLine       = Standard_True;
842 }
843
844 // =======================================================================
845 // function : DisableDrawHiddenLine
846 // purpose  :
847 // =======================================================================
848
849 void Prs3d_Drawer::DisableDrawHiddenLine()
850 {
851     myHasOwnDrawHiddenLine = Standard_True;
852     myDrawHiddenLine       = Standard_False;
853 }
854
855 // =======================================================================
856 // function : VectorAspect
857 // purpose  :
858 // =======================================================================
859
860 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::VectorAspect()
861 {
862   if (!HasOwnVectorAspect())
863   {
864     if (!myLink.IsNull())
865     {
866       return myLink->VectorAspect();
867     }
868     if (myVectorAspect.IsNull())
869     {
870       myVectorAspect = new Prs3d_LineAspect (Quantity_NOC_SKYBLUE, Aspect_TOL_SOLID, 1.0);
871     }
872   }
873   return myVectorAspect;
874 }
875
876 // =======================================================================
877 // function : SetVectorAspect
878 // purpose  :
879 // =======================================================================
880
881 void Prs3d_Drawer::SetVectorAspect (const Handle(Prs3d_LineAspect)& theAspect)
882 {
883   myVectorAspect = theAspect;
884   myHasOwnVectorAspect = !myVectorAspect.IsNull();
885 }
886
887 // =======================================================================
888 // function : SetVertexDrawMode
889 // purpose  :
890 // =======================================================================
891
892 void Prs3d_Drawer::SetVertexDrawMode (const Prs3d_VertexDrawMode theMode)
893 {
894   // Prs3d_VDM_Inherited is default value and means
895   // that correct value should be taken from the Link if it exists.
896   myVertexDrawMode = theMode;
897 }
898
899 // =======================================================================
900 // function : VertexDrawMode
901 // purpose  :
902 // =======================================================================
903
904 Prs3d_VertexDrawMode Prs3d_Drawer::VertexDrawMode()
905 {
906   if (!HasOwnVertexDrawMode())
907   {
908       if (!myLink.IsNull())
909       {
910           return myLink->VertexDrawMode();
911       }
912       // Prs3d_VDM_Isolated is default value for this setting.
913       myVertexDrawMode = Prs3d_VDM_Isolated;
914   }
915   return myVertexDrawMode;
916 }
917
918 // =======================================================================
919 // function : DatumAspect
920 // purpose  :
921 // =======================================================================
922
923 const Handle(Prs3d_DatumAspect)& Prs3d_Drawer::DatumAspect()
924 {
925   if (!HasOwnDatumAspect())
926   {
927     if (!myLink.IsNull())
928     {
929       return myLink->DatumAspect();
930     }
931     if (myDatumAspect.IsNull())
932     {
933       myDatumAspect = new Prs3d_DatumAspect();
934     }
935   }
936   return myDatumAspect;
937 }
938
939 // =======================================================================
940 // function : SetDatumAspect
941 // purpose  :
942 // =======================================================================
943
944 void Prs3d_Drawer::SetDatumAspect (const Handle(Prs3d_DatumAspect)& theAspect)
945 {
946   myDatumAspect = theAspect;
947   myHasOwnDatumAspect = !myDatumAspect.IsNull();
948 }
949
950 // =======================================================================
951 // function : SectionAspect
952 // purpose  :
953 // =======================================================================
954
955 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SectionAspect()
956 {
957   if (!HasOwnSectionAspect())
958   {
959     if (!myLink.IsNull())
960     {
961       return myLink->SectionAspect();
962     }
963     if (mySectionAspect.IsNull())
964     {
965       mySectionAspect = new Prs3d_LineAspect (Quantity_NOC_ORANGE, Aspect_TOL_SOLID, 1.0);
966     }
967   }
968   return mySectionAspect;
969 }
970
971 // =======================================================================
972 // function : SetSectionAspect
973 // purpose  :
974 // =======================================================================
975
976 void Prs3d_Drawer::SetSectionAspect (const Handle(Prs3d_LineAspect)& theAspect)
977 {
978   mySectionAspect = theAspect;
979   myHasOwnSectionAspect = !mySectionAspect.IsNull();
980 }
981
982 // =======================================================================
983 // function : SetSectionAspect
984 // purpose  :
985 // =======================================================================
986
987 void Prs3d_Drawer::ClearLocalAttributes()
988 {
989   if (myLink.IsNull())
990   {
991     return;
992   }
993
994   myUIsoAspect.Nullify();
995   myVIsoAspect.Nullify();
996   myFreeBoundaryAspect.Nullify();
997   myUnFreeBoundaryAspect.Nullify();
998   myFaceBoundaryAspect.Nullify();
999   myWireAspect.Nullify();
1000   myLineAspect.Nullify();
1001   myTextAspect.Nullify();
1002   myShadingAspect.Nullify();
1003   myPointAspect.Nullify();
1004   myPlaneAspect.Nullify();
1005   myArrowAspect.Nullify();
1006   myHiddenLineAspect.Nullify();
1007   mySeenLineAspect.Nullify();
1008   myVectorAspect .Nullify();
1009   myDatumAspect.Nullify();
1010   myDimensionAspect.Nullify();
1011   mySectionAspect.Nullify();
1012
1013   myHasOwnUIsoAspect           = Standard_False;
1014   myHasOwnVIsoAspect           = Standard_False;
1015   myHasOwnWireAspect           = Standard_False;
1016   myHasOwnPointAspect          = Standard_False;
1017   myHasOwnLineAspect           = Standard_False;
1018   myHasOwnTextAspect           = Standard_False;
1019   myHasOwnShadingAspect        = Standard_False;
1020   myHasOwnPlaneAspect          = Standard_False;
1021   myHasOwnSeenLineAspect       = Standard_False;
1022   myHasOwnArrowAspect          = Standard_False;
1023   myHasOwnHiddenLineAspect     = Standard_False;
1024   myHasOwnVectorAspect         = Standard_False;
1025   myHasOwnDatumAspect          = Standard_False;
1026   myHasOwnSectionAspect        = Standard_False;
1027   myHasOwnFreeBoundaryAspect   = Standard_False;
1028   myHasOwnUnFreeBoundaryAspect = Standard_False;
1029   myHasOwnFaceBoundaryAspect   = Standard_False;
1030   myHasOwnDimensionAspect      = Standard_False;
1031
1032   myHasOwnNbPoints                = Standard_False;
1033   myHasOwnMaximalParameterValue   = Standard_False;
1034   myHasOwnTypeOfDeflection        = Standard_False;
1035   myHasOwnChordialDeviation       = Standard_False;
1036   myHasOwnDeviationCoefficient    = Standard_False;
1037   myHasOwnHLRDeviationCoefficient = Standard_False;
1038   myHasOwnDeviationAngle          = Standard_False;
1039   myHasOwnHLRDeviationAngle       = Standard_False;
1040   myHasOwnIsoOnPlane              = Standard_False;
1041   myHasOwnIsAutoTriangulated      = Standard_False;
1042   myHasOwnWireDraw                = Standard_False;
1043   myHasOwnShadingAspectGlobal     = Standard_False;
1044   myHasOwnLineArrowDraw           = Standard_False;
1045   myHasOwnDrawHiddenLine          = Standard_False;
1046   myHasOwnFreeBoundaryDraw        = Standard_False;
1047   myHasOwnUnFreeBoundaryDraw      = Standard_False;
1048   myHasOwnFaceBoundaryDraw        = Standard_False;
1049   myHasOwnDimLengthModelUnits     = Standard_False;
1050   myHasOwnDimLengthDisplayUnits   = Standard_False;
1051   myHasOwnDimAngleModelUnits      = Standard_False;
1052   myHasOwnDimAngleDisplayUnits    = Standard_False;
1053
1054   myVertexDrawMode = Prs3d_VDM_Inherited;
1055   myTypeOfHLR      = Prs3d_TOH_NotSet;
1056 }