0030949: Foundation Classes - Dump improvement for OCCT classes
[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
17 #include <Graphic3d_AspectFillArea3d.hxx>
18 #include <Graphic3d_AspectMarker3d.hxx>
19 #include <Graphic3d_AspectText3d.hxx>
20 #include <Prs3d_ArrowAspect.hxx>
21 #include <Prs3d_DatumAspect.hxx>
22 #include <Prs3d_DimensionAspect.hxx>
23 #include <Prs3d_IsoAspect.hxx>
24 #include <Prs3d_LineAspect.hxx>
25 #include <Prs3d_PlaneAspect.hxx>
26 #include <Prs3d_PointAspect.hxx>
27 #include <Prs3d_ShadingAspect.hxx>
28 #include <Prs3d_TextAspect.hxx>
29 #include <Standard_Dump.hxx>
30
31 IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Drawer, Graphic3d_PresentationAttributes)
32
33 namespace
34 {
35   static const Quantity_NameOfColor THE_DEF_COLOR_FreeBoundary   = Quantity_NOC_GREEN;
36   static const Quantity_NameOfColor THE_DEF_COLOR_UnFreeBoundary = Quantity_NOC_YELLOW;
37   static const Quantity_NameOfColor THE_DEF_COLOR_FaceBoundary   = Quantity_NOC_BLACK;
38   static const Quantity_NameOfColor THE_DEF_COLOR_Wire           = Quantity_NOC_RED;
39   static const Quantity_NameOfColor THE_DEF_COLOR_Line           = Quantity_NOC_YELLOW;
40   static const Quantity_NameOfColor THE_DEF_COLOR_SeenLine       = Quantity_NOC_YELLOW;
41   static const Quantity_NameOfColor THE_DEF_COLOR_HiddenLine     = Quantity_NOC_YELLOW;
42   static const Quantity_NameOfColor THE_DEF_COLOR_Vector         = Quantity_NOC_SKYBLUE;
43   static const Quantity_NameOfColor THE_DEF_COLOR_Section        = Quantity_NOC_ORANGE;
44 }
45
46 // =======================================================================
47 // function : Prs3d_Drawer
48 // purpose  :
49 // =======================================================================
50 Prs3d_Drawer::Prs3d_Drawer()
51 : myNbPoints                      (30),
52   myHasOwnNbPoints                (Standard_False),
53   myMaximalParameterValue         (500000.),
54   myHasOwnMaximalParameterValue   (Standard_False),
55   myChordialDeviation             (0.0001),
56   myHasOwnChordialDeviation       (Standard_False),
57   myTypeOfDeflection              (Aspect_TOD_RELATIVE),
58   myHasOwnTypeOfDeflection        (Standard_False),
59   myTypeOfHLR                     (Prs3d_TOH_NotSet),
60   myDeviationCoefficient          (0.001),
61   myHasOwnDeviationCoefficient    (Standard_False),
62   myHLRDeviationCoefficient       (0.02),
63   myHasOwnHLRDeviationCoefficient (Standard_False),
64   myDeviationAngle                (12.0 * M_PI / 180.0),
65   myHasOwnDeviationAngle          (Standard_False),
66   myHLRAngle                      (20.0 * M_PI / 180.0),
67   myHasOwnHLRDeviationAngle       (Standard_False),
68   myIsoOnPlane                    (Standard_False),
69   myHasOwnIsoOnPlane              (Standard_False),
70   myIsoOnTriangulation            (Standard_False),
71   myHasOwnIsoOnTriangulation      (Standard_False),
72   myIsAutoTriangulated            (Standard_True),
73   myHasOwnIsAutoTriangulated      (Standard_False),
74
75   myHasOwnUIsoAspect          (Standard_False),
76   myHasOwnVIsoAspect          (Standard_False),
77   myHasOwnWireAspect          (Standard_False),
78   myWireDraw                  (Standard_True),
79   myHasOwnWireDraw            (Standard_False),
80   myHasOwnPointAspect         (Standard_False),
81   myHasOwnLineAspect          (Standard_False),
82   myHasOwnTextAspect          (Standard_False),
83   myHasOwnShadingAspect       (Standard_False),
84   myHasOwnPlaneAspect         (Standard_False),
85   myHasOwnSeenLineAspect      (Standard_False),
86   myHasOwnArrowAspect         (Standard_False),
87   myLineArrowDraw             (Standard_False),
88   myHasOwnLineArrowDraw       (Standard_False),
89   myHasOwnHiddenLineAspect    (Standard_False),
90   myDrawHiddenLine            (Standard_False),
91   myHasOwnDrawHiddenLine      (Standard_False),
92   myHasOwnVectorAspect        (Standard_False),
93   myVertexDrawMode            (Prs3d_VDM_Inherited),
94   myHasOwnDatumAspect         (Standard_False),
95   myHasOwnSectionAspect       (Standard_False),
96
97   myHasOwnFreeBoundaryAspect   (Standard_False),
98   myFreeBoundaryDraw           (Standard_True),
99   myHasOwnFreeBoundaryDraw     (Standard_False),
100   myHasOwnUnFreeBoundaryAspect (Standard_False),
101   myUnFreeBoundaryDraw         (Standard_True),
102   myHasOwnUnFreeBoundaryDraw   (Standard_False),
103   myFaceBoundaryUpperContinuity(-1),
104   myHasOwnFaceBoundaryAspect   (Standard_False),
105   myFaceBoundaryDraw           (Standard_False),
106   myHasOwnFaceBoundaryDraw     (Standard_False),
107
108   myHasOwnDimensionAspect       (Standard_False),
109   myHasOwnDimLengthModelUnits   (Standard_False),
110   myHasOwnDimAngleModelUnits    (Standard_False),
111   myHasOwnDimLengthDisplayUnits (Standard_False),
112   myHasOwnDimAngleDisplayUnits  (Standard_False)
113 {
114   myDimensionModelUnits.SetLengthUnits ("m");
115   myDimensionModelUnits.SetAngleUnits ("rad");
116   myDimensionDisplayUnits.SetLengthUnits ("m");
117   myDimensionDisplayUnits.SetAngleUnits ("deg");
118 }
119
120 // =======================================================================
121 // function : SetTypeOfDeflection
122 // purpose  :
123 // =======================================================================
124
125 void Prs3d_Drawer::SetTypeOfDeflection (const Aspect_TypeOfDeflection theTypeOfDeflection)
126 {
127   myHasOwnTypeOfDeflection = Standard_True;
128   myTypeOfDeflection       = theTypeOfDeflection;
129 }
130
131 // =======================================================================
132 // function : SetMaximalChordialDeviation
133 // purpose  :
134 // =======================================================================
135
136 void Prs3d_Drawer::SetMaximalChordialDeviation (const Standard_Real theChordialDeviation)
137 {
138   myHasOwnChordialDeviation = Standard_True;
139   myChordialDeviation       = theChordialDeviation;
140 }
141
142 // =======================================================================
143 // function : SetTypeOfHLR
144 // purpose  : set type of HLR algorithm
145 // =======================================================================
146
147 void Prs3d_Drawer::SetTypeOfHLR (const Prs3d_TypeOfHLR theTypeOfHLR)
148 {
149   myTypeOfHLR = theTypeOfHLR;
150 }
151
152 // =======================================================================
153 // function : TypeOfHLR
154 // purpose  : gets type of HLR algorithm
155 // =======================================================================
156
157 Prs3d_TypeOfHLR Prs3d_Drawer::TypeOfHLR()
158 {
159   if (!HasOwnTypeOfHLR())
160   {
161     if (!myLink.IsNull())
162     {
163       return myLink->TypeOfHLR();
164     }
165     // Prs3d_TOH_PolyAlgo is default value for this setting.
166     myTypeOfHLR = Prs3d_TOH_PolyAlgo;
167   }
168   return myTypeOfHLR;
169 }
170
171 // =======================================================================
172 // function : SetIsoOnTriangulation
173 // purpose  :
174 // =======================================================================
175 void Prs3d_Drawer::SetIsoOnTriangulation (const Standard_Boolean theToEnable)
176 {
177   myHasOwnIsoOnTriangulation = Standard_True;
178   myIsoOnTriangulation = theToEnable;
179 }
180
181 // =======================================================================
182 // function : SetMaximalParameterValue
183 // purpose  :
184 // =======================================================================
185
186 void Prs3d_Drawer::SetMaximalParameterValue (const Standard_Real theValue)
187 {
188   myHasOwnMaximalParameterValue = Standard_True;
189   myMaximalParameterValue       = theValue;
190 }
191
192 // =======================================================================
193 // function : SetIsoOnPlane
194 // purpose  :
195 // =======================================================================
196
197 void Prs3d_Drawer::SetIsoOnPlane (const Standard_Boolean theIsEnabled)
198 {
199   myHasOwnIsoOnPlane = Standard_True;
200   myIsoOnPlane       = theIsEnabled;
201 }
202
203 // =======================================================================
204 // function : SetDiscretisation
205 // purpose  :
206 // =======================================================================
207
208 void Prs3d_Drawer::SetDiscretisation (const Standard_Integer theValue) 
209 {
210   myHasOwnNbPoints = Standard_True;
211   myNbPoints       = theValue;
212 }
213
214 //=======================================================================
215 //function : SetDeviationCoefficient
216 //purpose  : 
217 //=======================================================================
218
219 void Prs3d_Drawer::SetDeviationCoefficient (const Standard_Real theCoefficient)
220 {
221   myPreviousDeviationCoefficient = DeviationCoefficient();
222   myDeviationCoefficient         = theCoefficient;
223   myHasOwnDeviationCoefficient   = Standard_True;
224 }
225
226 //=======================================================================
227 //function : SetHLRDeviationCoefficient
228 //purpose  : 
229 //=======================================================================
230
231 void Prs3d_Drawer::SetHLRDeviationCoefficient (const Standard_Real theCoefficient)
232 {
233   myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient();
234   myHLRDeviationCoefficient         = theCoefficient;
235   myHasOwnHLRDeviationCoefficient   = Standard_True;
236 }
237
238 //=======================================================================
239 //function : SetDeviationAngle
240 //purpose  : 
241 //=======================================================================
242
243 void Prs3d_Drawer::SetDeviationAngle (const Standard_Real theAngle)
244 {
245   myPreviousDeviationAngle = DeviationAngle();
246   myDeviationAngle         = theAngle;
247   myHasOwnDeviationAngle   = Standard_True;
248 }
249
250 //=======================================================================
251 //function : SetHLRAngle
252 //purpose  : 
253 //=======================================================================
254
255 void Prs3d_Drawer::SetHLRAngle (const Standard_Real theAngle)
256 {
257   myPreviousHLRDeviationAngle = HLRAngle();
258   myHLRAngle                  = theAngle;
259   myHasOwnHLRDeviationAngle   = Standard_True;
260 }
261
262 // =======================================================================
263 // function : SetAutoTriangulation
264 // purpose  :
265 // =======================================================================
266
267 void Prs3d_Drawer::SetAutoTriangulation (const Standard_Boolean theIsEnabled)
268 {
269   myHasOwnIsAutoTriangulated = Standard_True;
270   myIsAutoTriangulated       = theIsEnabled;
271 }
272
273 // =======================================================================
274 // function : FreeBoundaryAspect
275 // purpose  :
276 // =======================================================================
277
278 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FreeBoundaryAspect()
279 {
280   if (!HasOwnFreeBoundaryAspect())
281   {
282     if (!myLink.IsNull())
283     {
284       return myLink->FreeBoundaryAspect();
285     }
286     if (myFreeBoundaryAspect.IsNull())
287     {
288       myFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FreeBoundary, Aspect_TOL_SOLID, 1.0);
289     }
290   }
291   return myFreeBoundaryAspect;
292 }
293
294 // =======================================================================
295 // function : FreeBoundaryAspect
296 // purpose  :
297 // =======================================================================
298
299 void Prs3d_Drawer::SetFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
300 {
301   myFreeBoundaryAspect = theAspect;
302   myHasOwnFreeBoundaryAspect = !myFreeBoundaryAspect.IsNull();
303 }
304
305 // =======================================================================
306 // function : SetFreeBoundaryDraw
307 // purpose  :
308 // =======================================================================
309
310 void Prs3d_Drawer::SetFreeBoundaryDraw (const Standard_Boolean theIsEnabled)
311 {
312   myHasOwnFreeBoundaryDraw = Standard_True;
313   myFreeBoundaryDraw       = theIsEnabled;
314 }
315
316 // =======================================================================
317 // function : UnFreeBoundaryAspect
318 // purpose  :
319 // =======================================================================
320
321 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::UnFreeBoundaryAspect()
322 {
323   if (!HasOwnUnFreeBoundaryAspect())
324   {
325     if (!myLink.IsNull())
326     {
327       return myLink->UnFreeBoundaryAspect();
328     }
329     if (myUnFreeBoundaryAspect.IsNull())
330     {
331       myUnFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_UnFreeBoundary, Aspect_TOL_SOLID, 1.0);
332     }
333   }
334   return myUnFreeBoundaryAspect;
335 }
336
337 // =======================================================================
338 // function : SetUnFreeBoundaryAspect
339 // purpose  :
340 // =======================================================================
341
342 void Prs3d_Drawer::SetUnFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
343 {
344   myUnFreeBoundaryAspect = theAspect;
345   myHasOwnUnFreeBoundaryAspect = !myUnFreeBoundaryAspect.IsNull();
346 }
347
348 // =======================================================================
349 // function : SetUnFreeBoundaryDraw
350 // purpose  :
351 // =======================================================================
352
353 void Prs3d_Drawer::SetUnFreeBoundaryDraw (const Standard_Boolean theIsEnabled)
354 {
355   myHasOwnUnFreeBoundaryDraw = Standard_True;
356   myUnFreeBoundaryDraw       = theIsEnabled;
357 }
358
359 // =======================================================================
360 // function : FaceBoundaryAspect
361 // purpose  :
362 // =======================================================================
363
364 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FaceBoundaryAspect()
365 {
366   if (!HasOwnFaceBoundaryAspect())
367   {
368     if (!myLink.IsNull())
369     {
370       return myLink->FaceBoundaryAspect();
371     }
372     if (myFaceBoundaryAspect.IsNull())
373     {
374       myFaceBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FaceBoundary, Aspect_TOL_SOLID, 1.0);
375     }
376   }
377   return myFaceBoundaryAspect;
378 }
379
380 // =======================================================================
381 // function : SetFaceBoundaryAspect
382 // purpose  :
383 // =======================================================================
384
385 void Prs3d_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
386 {
387   myFaceBoundaryAspect = theAspect;
388   myHasOwnFaceBoundaryAspect = !myFaceBoundaryAspect.IsNull();
389 }
390
391 // =======================================================================
392 // function : SetFaceBoundaryDraw
393 // purpose  :
394 // =======================================================================
395
396 void Prs3d_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
397 {
398   myHasOwnFaceBoundaryDraw = Standard_True;
399   myFaceBoundaryDraw       = theIsEnabled;
400 }
401
402 // =======================================================================
403 // function : DimensionAspect
404 // purpose  :
405 // =======================================================================
406
407 const Handle(Prs3d_DimensionAspect)& Prs3d_Drawer::DimensionAspect()
408 {
409   if (!HasOwnDimensionAspect())
410   {
411     if (!myLink.IsNull())
412     {
413       return myLink->DimensionAspect();
414     }
415     if (myDimensionAspect.IsNull())
416     {
417       myDimensionAspect = new Prs3d_DimensionAspect;
418     }
419   }
420   return myDimensionAspect;
421 }
422
423 // =======================================================================
424 // function : SetDimensionAspect
425 // purpose  :
426 // =======================================================================
427
428 void Prs3d_Drawer::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theAspect)
429 {
430   myDimensionAspect = theAspect;
431   myHasOwnDimensionAspect = !myDimensionAspect.IsNull();
432 }
433
434 // =======================================================================
435 // function : SetDimLengthModelUnits
436 // purpose  :
437 // =======================================================================
438
439 void Prs3d_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
440 {
441   myHasOwnDimLengthModelUnits = Standard_True;
442   myDimensionModelUnits.SetLengthUnits (theUnits);
443 }
444
445 // =======================================================================
446 // function : SetDimAngleModelUnits
447 // purpose  :
448 // =======================================================================
449
450 void Prs3d_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
451 {
452   myHasOwnDimAngleModelUnits = Standard_True;
453   myDimensionModelUnits.SetAngleUnits (theUnits);
454 }
455
456 // =======================================================================
457 // function : SetDimLengthDisplayUnits
458 // purpose  :
459 // =======================================================================
460
461 void Prs3d_Drawer::SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits)
462 {
463   myHasOwnDimLengthDisplayUnits = Standard_True;
464   myDimensionDisplayUnits.SetLengthUnits (theUnits);
465 }
466
467 // =======================================================================
468 // function : SetDimAngleDisplayUnits
469 // purpose  :
470 // =======================================================================
471
472 void Prs3d_Drawer::SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits)
473 {
474   myHasOwnDimAngleDisplayUnits = Standard_True;
475   myDimensionDisplayUnits.SetAngleUnits (theUnits);
476 }
477
478 // =======================================================================
479 // function : UIsoAspect
480 // purpose  :
481 // =======================================================================
482
483 const Handle(Prs3d_IsoAspect)& Prs3d_Drawer::UIsoAspect()
484 {
485   if (!HasOwnUIsoAspect())
486   {
487     if (!myLink.IsNull())
488     {
489       return myLink->UIsoAspect();
490     }
491     if (myUIsoAspect.IsNull())
492     {
493       myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
494     }
495   }
496   return myUIsoAspect;
497 }
498
499 // =======================================================================
500 // function : SetUIsoAspect
501 // purpose  :
502 // =======================================================================
503
504 void Prs3d_Drawer::SetUIsoAspect (const Handle(Prs3d_IsoAspect)& theAspect)
505 {
506   myUIsoAspect = theAspect;
507   myHasOwnUIsoAspect = !myUIsoAspect.IsNull();
508 }
509
510 // =======================================================================
511 // function : VIsoAspect
512 // purpose  :
513 // =======================================================================
514
515 const Handle(Prs3d_IsoAspect)& Prs3d_Drawer::VIsoAspect()
516 {
517   if (!HasOwnVIsoAspect())
518   {
519     if (!myLink.IsNull())
520     {
521       return myLink->VIsoAspect();
522     }
523     if (myVIsoAspect.IsNull())
524     {
525       myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
526     }
527   }
528   return myVIsoAspect;
529 }
530
531 // =======================================================================
532 // function : SetVIsoAspect
533 // purpose  :
534 // =======================================================================
535
536 void Prs3d_Drawer::SetVIsoAspect (const Handle(Prs3d_IsoAspect)& theAspect)
537 {
538   myVIsoAspect = theAspect;
539   myHasOwnVIsoAspect= !myVIsoAspect.IsNull();
540 }
541
542 // =======================================================================
543 // function : WireAspect
544 // purpose  :
545 // =======================================================================
546
547 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::WireAspect()
548 {
549   if (!HasOwnWireAspect())
550   {
551     if (!myLink.IsNull())
552     {
553       return myLink->WireAspect();
554     }
555     if (myWireAspect.IsNull())
556     {
557       myWireAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Wire, Aspect_TOL_SOLID, 1.0);
558     }
559   }
560   return myWireAspect;
561 }
562
563 // =======================================================================
564 // function : SetWireAspect
565 // purpose  :
566 // =======================================================================
567
568 void Prs3d_Drawer::SetWireAspect (const Handle(Prs3d_LineAspect)& theAspect)
569 {
570   myWireAspect = theAspect;
571   myHasOwnWireAspect = !myWireAspect.IsNull();
572 }
573
574 // =======================================================================
575 // function : SetWireDraw
576 // purpose  :
577 // =======================================================================
578
579 void Prs3d_Drawer::SetWireDraw (const Standard_Boolean theIsEnabled)
580 {
581   myHasOwnWireDraw = Standard_True;
582   myWireDraw       = theIsEnabled;
583 }
584
585 // =======================================================================
586 // function : PointAspect
587 // purpose  :
588 // =======================================================================
589
590 const Handle(Prs3d_PointAspect)& Prs3d_Drawer::PointAspect()
591 {
592   if (!HasOwnPointAspect())
593   {
594     if (!myLink.IsNull())
595     {
596       return myLink->PointAspect();
597     }
598     if (myPointAspect.IsNull())
599     {
600       myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
601     }
602   }
603   return myPointAspect;
604 }
605
606 // =======================================================================
607 // function : SetupOwnPointAspect
608 // purpose  :
609 // =======================================================================
610 Standard_Boolean Prs3d_Drawer::SetupOwnPointAspect (const Handle(Prs3d_Drawer)& theDefaults)
611 {
612   if (myHasOwnPointAspect)
613   {
614     return Standard_False;
615   }
616
617   myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
618   if (!theDefaults.IsNull() && theDefaults != this)
619   {
620     *myPointAspect->Aspect() = *theDefaults->PointAspect()->Aspect();
621   }
622   else if (!myLink.IsNull())
623   {
624     *myPointAspect->Aspect() = *myLink->PointAspect()->Aspect();
625   }
626   myHasOwnPointAspect = Standard_True;
627   return Standard_True;
628 }
629
630 // =======================================================================
631 // function : SetPointAspect
632 // purpose  :
633 // =======================================================================
634
635 void Prs3d_Drawer::SetPointAspect (const Handle(Prs3d_PointAspect)& theAspect)
636 {
637   myPointAspect = theAspect;
638   myHasOwnPointAspect = !myPointAspect.IsNull();
639 }
640
641 // =======================================================================
642 // function : LineAspect
643 // purpose  :
644 // =======================================================================
645
646 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::LineAspect()
647 {
648   if (!HasOwnLineAspect())
649   {
650     if (!myLink.IsNull())
651     {
652       return myLink->LineAspect();
653     }
654     if (myLineAspect.IsNull())
655     {
656       myLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Line, Aspect_TOL_SOLID, 1.0);
657     }
658   }
659   return myLineAspect;
660 }
661
662 // =======================================================================
663 // function : SetLineAspect
664 // purpose  :
665 // =======================================================================
666
667 void Prs3d_Drawer::SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
668 {
669   myLineAspect = theAspect;
670   myHasOwnLineAspect = !myLineAspect.IsNull();
671 }
672
673 // =======================================================================
674 // function : TextAspect
675 // purpose  :
676 // =======================================================================
677
678 const Handle(Prs3d_TextAspect)& Prs3d_Drawer::TextAspect()
679 {
680   if (!HasOwnTextAspect())
681   {
682     if (!myLink.IsNull())
683     {
684       return myLink->TextAspect();
685     }
686     if (myTextAspect.IsNull())
687     {
688       myTextAspect = new Prs3d_TextAspect();
689     }
690   }
691   return myTextAspect;
692 }
693
694 // =======================================================================
695 // function : SetTextAspect
696 // purpose  :
697 // =======================================================================
698
699 void Prs3d_Drawer::SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect)
700 {
701   myTextAspect = theAspect;
702   myHasOwnTextAspect = !myTextAspect.IsNull();
703 }
704
705 // =======================================================================
706 // function : ShadingAspect
707 // purpose  :
708 // =======================================================================
709
710 const Handle(Prs3d_ShadingAspect)& Prs3d_Drawer::ShadingAspect()
711 {
712   if (!HasOwnShadingAspect())
713   {
714     if (!myLink.IsNull())
715     {
716       return myLink->ShadingAspect();
717     }
718     if (myShadingAspect.IsNull())
719     {
720       myShadingAspect = new Prs3d_ShadingAspect();
721     }
722   }
723   return myShadingAspect;
724 }
725
726 // =======================================================================
727 // function : SetupOwnShadingAspect
728 // purpose  :
729 // =======================================================================
730 Standard_Boolean Prs3d_Drawer::SetupOwnShadingAspect (const Handle(Prs3d_Drawer)& theDefaults)
731 {
732   if (myHasOwnShadingAspect)
733   {
734     return Standard_False;
735   }
736
737   myShadingAspect = new Prs3d_ShadingAspect();
738   if (!theDefaults.IsNull() && theDefaults != this)
739   {
740     *myShadingAspect->Aspect() = *theDefaults->ShadingAspect()->Aspect();
741   }
742   else if (!myLink.IsNull())
743   {
744     *myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
745   }
746   myHasOwnShadingAspect = Standard_True;
747   return Standard_True;
748 }
749
750 // =======================================================================
751 // function : SetShadingAspect
752 // purpose  :
753 // =======================================================================
754
755 void Prs3d_Drawer::SetShadingAspect (const Handle(Prs3d_ShadingAspect)& theAspect)
756 {
757   myShadingAspect = theAspect;
758   myHasOwnShadingAspect = !myShadingAspect.IsNull();
759 }
760
761 // =======================================================================
762 // function : PlaneAspect
763 // purpose  :
764 // =======================================================================
765
766 const Handle(Prs3d_PlaneAspect)& Prs3d_Drawer::PlaneAspect()
767 {
768   if (!HasOwnPlaneAspect())
769   {
770     if (!myLink.IsNull())
771     {
772       return myLink->PlaneAspect();
773     }
774     if (myPlaneAspect.IsNull())
775     {
776       myPlaneAspect = new Prs3d_PlaneAspect();
777     }
778   }
779   return myPlaneAspect;
780 }
781
782 // =======================================================================
783 // function : SetPlaneAspect
784 // purpose  :
785 // =======================================================================
786
787 void Prs3d_Drawer::SetPlaneAspect (const Handle(Prs3d_PlaneAspect)& theAspect)
788 {
789   myPlaneAspect = theAspect;
790   myHasOwnPlaneAspect = !myPlaneAspect.IsNull();
791 }
792
793 // =======================================================================
794 // function : SeenLineAspect
795 // purpose  :
796 // =======================================================================
797
798 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SeenLineAspect()
799 {
800   if (!HasOwnSeenLineAspect())
801   {
802     if (!myLink.IsNull())
803     {
804       return myLink->SeenLineAspect();
805     }
806     if (mySeenLineAspect.IsNull())
807     {
808       mySeenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_SeenLine, Aspect_TOL_SOLID, 1.0);
809     }
810   }
811   return mySeenLineAspect;
812 }
813
814 // =======================================================================
815 // function : SetSeenLineAspect
816 // purpose  :
817 // =======================================================================
818
819 void Prs3d_Drawer::SetSeenLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
820 {
821   mySeenLineAspect = theAspect;
822   myHasOwnSeenLineAspect = !mySeenLineAspect.IsNull();
823 }
824
825 // =======================================================================
826 // function : ArrowAspect
827 // purpose  :
828 // =======================================================================
829
830 const Handle(Prs3d_ArrowAspect)& Prs3d_Drawer::ArrowAspect()
831 {
832   if (!HasOwnArrowAspect())
833   {
834     if (!myLink.IsNull())
835     {
836       return myLink->ArrowAspect();
837     }
838     if (myArrowAspect.IsNull())
839     {
840       myArrowAspect = new Prs3d_ArrowAspect();
841     }
842   }
843   return myArrowAspect;
844 }
845
846 // =======================================================================
847 // function : SetArrowAspect
848 // purpose  :
849 // =======================================================================
850
851 void Prs3d_Drawer::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect)
852 {
853   myArrowAspect = theAspect;
854   myHasOwnArrowAspect = !myArrowAspect.IsNull();
855 }
856
857 // =======================================================================
858 // function : SetLineArrowDraw
859 // purpose  :
860 // =======================================================================
861
862 void Prs3d_Drawer::SetLineArrowDraw (const Standard_Boolean theIsEnabled)
863 {
864   myHasOwnLineArrowDraw = Standard_True;
865   myLineArrowDraw       = theIsEnabled;
866 }
867
868 // =======================================================================
869 // function : HiddenLineAspect
870 // purpose  :
871 // =======================================================================
872
873 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::HiddenLineAspect()
874 {
875   if (!HasOwnHiddenLineAspect())
876   {
877     if (!myLink.IsNull())
878     {
879       return myLink->HiddenLineAspect();
880     }
881     if (myHiddenLineAspect.IsNull())
882     {
883       myHiddenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_HiddenLine, Aspect_TOL_DASH, 1.0);
884     }
885   }
886   return myHiddenLineAspect;
887 }
888
889 // =======================================================================
890 // function : SetHiddenLineAspect
891 // purpose  :
892 // =======================================================================
893
894 void Prs3d_Drawer::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
895 {
896   myHiddenLineAspect = theAspect;
897   myHasOwnHiddenLineAspect = !myHiddenLineAspect.IsNull();
898 }
899
900 // =======================================================================
901 // function : EnableDrawHiddenLineDraw
902 // purpose  :
903 // =======================================================================
904
905 void Prs3d_Drawer::EnableDrawHiddenLine()
906 {
907     myHasOwnDrawHiddenLine = Standard_True;
908     myDrawHiddenLine       = Standard_True;
909 }
910
911 // =======================================================================
912 // function : DisableDrawHiddenLine
913 // purpose  :
914 // =======================================================================
915
916 void Prs3d_Drawer::DisableDrawHiddenLine()
917 {
918     myHasOwnDrawHiddenLine = Standard_True;
919     myDrawHiddenLine       = Standard_False;
920 }
921
922 // =======================================================================
923 // function : VectorAspect
924 // purpose  :
925 // =======================================================================
926
927 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::VectorAspect()
928 {
929   if (!HasOwnVectorAspect())
930   {
931     if (!myLink.IsNull())
932     {
933       return myLink->VectorAspect();
934     }
935     if (myVectorAspect.IsNull())
936     {
937       myVectorAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Vector, Aspect_TOL_SOLID, 1.0);
938     }
939   }
940   return myVectorAspect;
941 }
942
943 // =======================================================================
944 // function : SetVectorAspect
945 // purpose  :
946 // =======================================================================
947
948 void Prs3d_Drawer::SetVectorAspect (const Handle(Prs3d_LineAspect)& theAspect)
949 {
950   myVectorAspect = theAspect;
951   myHasOwnVectorAspect = !myVectorAspect.IsNull();
952 }
953
954 // =======================================================================
955 // function : SetVertexDrawMode
956 // purpose  :
957 // =======================================================================
958
959 void Prs3d_Drawer::SetVertexDrawMode (const Prs3d_VertexDrawMode theMode)
960 {
961   // Prs3d_VDM_Inherited is default value and means
962   // that correct value should be taken from the Link if it exists.
963   myVertexDrawMode = theMode;
964 }
965
966 // =======================================================================
967 // function : VertexDrawMode
968 // purpose  :
969 // =======================================================================
970
971 Prs3d_VertexDrawMode Prs3d_Drawer::VertexDrawMode()
972 {
973   if (!HasOwnVertexDrawMode())
974   {
975       if (!myLink.IsNull())
976       {
977           return myLink->VertexDrawMode();
978       }
979       // Prs3d_VDM_Isolated is default value for this setting.
980       myVertexDrawMode = Prs3d_VDM_Isolated;
981   }
982   return myVertexDrawMode;
983 }
984
985 // =======================================================================
986 // function : DatumAspect
987 // purpose  :
988 // =======================================================================
989
990 const Handle(Prs3d_DatumAspect)& Prs3d_Drawer::DatumAspect()
991 {
992   if (!HasOwnDatumAspect())
993   {
994     if (!myLink.IsNull())
995     {
996       return myLink->DatumAspect();
997     }
998     if (myDatumAspect.IsNull())
999     {
1000       myDatumAspect = new Prs3d_DatumAspect();
1001     }
1002   }
1003   return myDatumAspect;
1004 }
1005
1006 // =======================================================================
1007 // function : SetDatumAspect
1008 // purpose  :
1009 // =======================================================================
1010
1011 void Prs3d_Drawer::SetDatumAspect (const Handle(Prs3d_DatumAspect)& theAspect)
1012 {
1013   myDatumAspect = theAspect;
1014   myHasOwnDatumAspect = !myDatumAspect.IsNull();
1015 }
1016
1017 // =======================================================================
1018 // function : SectionAspect
1019 // purpose  :
1020 // =======================================================================
1021
1022 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SectionAspect()
1023 {
1024   if (!HasOwnSectionAspect())
1025   {
1026     if (!myLink.IsNull())
1027     {
1028       return myLink->SectionAspect();
1029     }
1030     if (mySectionAspect.IsNull())
1031     {
1032       mySectionAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Section, Aspect_TOL_SOLID, 1.0);
1033     }
1034   }
1035   return mySectionAspect;
1036 }
1037
1038 // =======================================================================
1039 // function : SetSectionAspect
1040 // purpose  :
1041 // =======================================================================
1042
1043 void Prs3d_Drawer::SetSectionAspect (const Handle(Prs3d_LineAspect)& theAspect)
1044 {
1045   mySectionAspect = theAspect;
1046   myHasOwnSectionAspect = !mySectionAspect.IsNull();
1047 }
1048
1049 // =======================================================================
1050 // function : SetSectionAspect
1051 // purpose  :
1052 // =======================================================================
1053
1054 void Prs3d_Drawer::ClearLocalAttributes()
1055 {
1056   if (myLink.IsNull())
1057   {
1058     return;
1059   }
1060
1061   myUIsoAspect.Nullify();
1062   myVIsoAspect.Nullify();
1063   myFreeBoundaryAspect.Nullify();
1064   myUnFreeBoundaryAspect.Nullify();
1065   myFaceBoundaryAspect.Nullify();
1066   myWireAspect.Nullify();
1067   myLineAspect.Nullify();
1068   myTextAspect.Nullify();
1069   myShadingAspect.Nullify();
1070   myPointAspect.Nullify();
1071   myPlaneAspect.Nullify();
1072   myArrowAspect.Nullify();
1073   myHiddenLineAspect.Nullify();
1074   mySeenLineAspect.Nullify();
1075   myVectorAspect .Nullify();
1076   myDatumAspect.Nullify();
1077   myDimensionAspect.Nullify();
1078   mySectionAspect.Nullify();
1079
1080   myHasOwnUIsoAspect           = Standard_False;
1081   myHasOwnVIsoAspect           = Standard_False;
1082   myHasOwnWireAspect           = Standard_False;
1083   myHasOwnPointAspect          = Standard_False;
1084   myHasOwnLineAspect           = Standard_False;
1085   myHasOwnTextAspect           = Standard_False;
1086   myHasOwnShadingAspect        = Standard_False;
1087   myHasOwnPlaneAspect          = Standard_False;
1088   myHasOwnSeenLineAspect       = Standard_False;
1089   myHasOwnArrowAspect          = Standard_False;
1090   myHasOwnHiddenLineAspect     = Standard_False;
1091   myHasOwnVectorAspect         = Standard_False;
1092   myHasOwnDatumAspect          = Standard_False;
1093   myHasOwnSectionAspect        = Standard_False;
1094   myHasOwnFreeBoundaryAspect   = Standard_False;
1095   myHasOwnUnFreeBoundaryAspect = Standard_False;
1096   myHasOwnFaceBoundaryAspect   = Standard_False;
1097   myHasOwnDimensionAspect      = Standard_False;
1098
1099   myHasOwnNbPoints                = Standard_False;
1100   myHasOwnMaximalParameterValue   = Standard_False;
1101   myHasOwnTypeOfDeflection        = Standard_False;
1102   myHasOwnChordialDeviation       = Standard_False;
1103   myHasOwnDeviationCoefficient    = Standard_False;
1104   myHasOwnHLRDeviationCoefficient = Standard_False;
1105   myHasOwnDeviationAngle          = Standard_False;
1106   myHasOwnHLRDeviationAngle       = Standard_False;
1107   myHasOwnIsoOnPlane              = Standard_False;
1108   myHasOwnIsoOnTriangulation      = Standard_False;
1109   myHasOwnIsAutoTriangulated      = Standard_False;
1110   myHasOwnWireDraw                = Standard_False;
1111   myHasOwnLineArrowDraw           = Standard_False;
1112   myHasOwnDrawHiddenLine          = Standard_False;
1113   myHasOwnFreeBoundaryDraw        = Standard_False;
1114   myHasOwnUnFreeBoundaryDraw      = Standard_False;
1115   myHasOwnFaceBoundaryDraw        = Standard_False;
1116   myHasOwnDimLengthModelUnits     = Standard_False;
1117   myHasOwnDimLengthDisplayUnits   = Standard_False;
1118   myHasOwnDimAngleModelUnits      = Standard_False;
1119   myHasOwnDimAngleDisplayUnits    = Standard_False;
1120
1121   myVertexDrawMode = Prs3d_VDM_Inherited;
1122   myTypeOfHLR      = Prs3d_TOH_NotSet;
1123 }
1124
1125 // =======================================================================
1126 // function : SetupOwnFaceBoundaryAspect
1127 // purpose  :
1128 // =======================================================================
1129 Standard_Boolean Prs3d_Drawer::SetupOwnFaceBoundaryAspect (const Handle(Prs3d_Drawer)& theDefaults)
1130 {
1131   if (myHasOwnFaceBoundaryAspect)
1132   {
1133     return false;
1134   }
1135
1136   myFaceBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FaceBoundary, Aspect_TOL_SOLID, 1.0);
1137   myHasOwnFaceBoundaryAspect = true;
1138
1139   const Handle(Prs3d_Drawer)& aLink = (!theDefaults.IsNull() && theDefaults != this) ? theDefaults : myLink;
1140   if (!aLink.IsNull())
1141   {
1142     *myFaceBoundaryAspect->Aspect() = *aLink->FaceBoundaryAspect()->Aspect();
1143   }
1144   return true;
1145 }
1146
1147 // =======================================================================
1148 // function : SetOwnLineAspects
1149 // purpose  :
1150 // =======================================================================
1151 Standard_Boolean Prs3d_Drawer::SetOwnLineAspects (const Handle(Prs3d_Drawer)& theDefaults)
1152 {
1153   bool isUpdateNeeded = false;
1154   const Handle(Prs3d_Drawer)& aLink = (!theDefaults.IsNull() && theDefaults != this) ? theDefaults : myLink;
1155   if (!myHasOwnUIsoAspect)
1156   {
1157     isUpdateNeeded = true;
1158     myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
1159     if (!aLink.IsNull())
1160     {
1161       *myUIsoAspect->Aspect() = *aLink->UIsoAspect()->Aspect();
1162       myUIsoAspect->SetNumber (aLink->UIsoAspect()->Number());
1163     }
1164     myHasOwnUIsoAspect = true;
1165   }
1166   if (!myHasOwnVIsoAspect)
1167   {
1168     isUpdateNeeded = true;
1169     myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
1170     if (!aLink.IsNull())
1171     {
1172       *myVIsoAspect->Aspect() = *aLink->VIsoAspect()->Aspect();
1173       myUIsoAspect->SetNumber (aLink->VIsoAspect()->Number());
1174     }
1175     myHasOwnVIsoAspect = true;
1176   }
1177   if (!myHasOwnWireAspect)
1178   {
1179     isUpdateNeeded = true;
1180     myWireAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Wire, Aspect_TOL_SOLID, 1.0);
1181     myHasOwnWireAspect = true;
1182     if (!aLink.IsNull())
1183     {
1184       *myWireAspect->Aspect() = *aLink->WireAspect()->Aspect();
1185     }
1186   }
1187   if (!myHasOwnLineAspect)
1188   {
1189     isUpdateNeeded = true;
1190     myLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Line, Aspect_TOL_SOLID, 1.0);
1191     myHasOwnLineAspect = true;
1192     if (!aLink.IsNull())
1193     {
1194       *myLineAspect->Aspect() = *aLink->LineAspect()->Aspect();
1195     }
1196   }
1197   if (!myHasOwnSeenLineAspect)
1198   {
1199     isUpdateNeeded = true;
1200     mySeenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_SeenLine, Aspect_TOL_SOLID, 1.0);
1201     myHasOwnSeenLineAspect = true;
1202     if (!aLink.IsNull())
1203     {
1204       *mySeenLineAspect->Aspect() = *aLink->SeenLineAspect()->Aspect();
1205     }
1206   }
1207   if (!myHasOwnHiddenLineAspect)
1208   {
1209     isUpdateNeeded = true;
1210     myHiddenLineAspect = new Prs3d_LineAspect (THE_DEF_COLOR_HiddenLine, Aspect_TOL_DASH, 1.0);
1211     myHasOwnHiddenLineAspect = true;
1212     if (!aLink.IsNull())
1213     {
1214       *myHiddenLineAspect->Aspect() = *aLink->HiddenLineAspect()->Aspect();
1215     }
1216   }
1217   if (!myHasOwnFreeBoundaryAspect)
1218   {
1219     isUpdateNeeded = true;
1220     myFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_FreeBoundary, Aspect_TOL_SOLID, 1.0);
1221     myHasOwnFreeBoundaryAspect = true;
1222     if (!aLink.IsNull())
1223     {
1224       *myFreeBoundaryAspect->Aspect() = *aLink->FreeBoundaryAspect()->Aspect();
1225     }
1226   }
1227   if (!myHasOwnUnFreeBoundaryAspect)
1228   {
1229     isUpdateNeeded = true;
1230     myUnFreeBoundaryAspect = new Prs3d_LineAspect (THE_DEF_COLOR_UnFreeBoundary, Aspect_TOL_SOLID, 1.0);
1231     myHasOwnUnFreeBoundaryAspect = true;
1232     if (!aLink.IsNull())
1233     {
1234       *myUnFreeBoundaryAspect->Aspect() = *aLink->UnFreeBoundaryAspect()->Aspect();
1235     }
1236   }
1237   isUpdateNeeded = SetupOwnFaceBoundaryAspect (theDefaults) || isUpdateNeeded;
1238   return isUpdateNeeded;
1239 }
1240
1241 // =======================================================================
1242 // function : SetOwnDatumAspects
1243 // purpose  :
1244 // =======================================================================
1245 Standard_Boolean Prs3d_Drawer::SetOwnDatumAspects (const Handle(Prs3d_Drawer)& theDefaults)
1246 {
1247   bool isUpdateNeeded = false;
1248   const Handle(Prs3d_Drawer)& aLink = (!theDefaults.IsNull() && theDefaults != this) ? theDefaults : myLink;
1249   if (!myHasOwnVectorAspect)
1250   {
1251     isUpdateNeeded = true;
1252     myVectorAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Vector, Aspect_TOL_SOLID, 1.0);
1253     myHasOwnVectorAspect = true;
1254     if (!aLink.IsNull())
1255     {
1256       *myVectorAspect->Aspect() = *aLink->VectorAspect()->Aspect();
1257     }
1258   }
1259   if (!myHasOwnSectionAspect)
1260   {
1261     isUpdateNeeded = true;
1262     mySectionAspect = new Prs3d_LineAspect (THE_DEF_COLOR_Section, Aspect_TOL_SOLID, 1.0);
1263     myHasOwnSectionAspect = true;
1264     if (!aLink.IsNull())
1265     {
1266       *mySectionAspect->Aspect() = *aLink->SectionAspect()->Aspect();
1267     }
1268   }
1269   if (!myHasOwnPlaneAspect)
1270   {
1271     isUpdateNeeded = true;
1272     myPlaneAspect = new Prs3d_PlaneAspect();
1273     myHasOwnPlaneAspect = true;
1274   }
1275   if (!myHasOwnArrowAspect)
1276   {
1277     isUpdateNeeded = true;
1278     myArrowAspect = new Prs3d_ArrowAspect();
1279     myHasOwnArrowAspect = true;
1280   }
1281   if (!myHasOwnDatumAspect)
1282   {
1283     isUpdateNeeded = true;
1284     myDatumAspect = new Prs3d_DatumAspect();
1285     myHasOwnDatumAspect = true;
1286   }
1287   return isUpdateNeeded;
1288 }
1289
1290 //! Assign the shader program.
1291 template <typename T>
1292 inline void setAspectProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
1293                               bool theHasAspect,
1294                               T thePrsAspect)
1295 {
1296   if (!thePrsAspect.IsNull()
1297     && theHasAspect)
1298   {
1299     thePrsAspect->Aspect()->SetShaderProgram (theProgram);
1300   }
1301 }
1302
1303 // =======================================================================
1304 // function : SetShaderProgram
1305 // purpose  :
1306 // =======================================================================
1307 bool Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
1308                                      const Graphic3d_GroupAspect            theAspect,
1309                                      const bool                             theToOverrideDefaults)
1310 {
1311   bool isUpdateNeeded = false;
1312   switch (theAspect)
1313   {
1314     case Graphic3d_ASPECT_LINE:
1315     {
1316       if (theToOverrideDefaults)
1317       {
1318         isUpdateNeeded = SetOwnLineAspects()  || isUpdateNeeded;
1319         isUpdateNeeded = SetOwnDatumAspects() || isUpdateNeeded;
1320       }
1321
1322       setAspectProgram (theProgram, myHasOwnUIsoAspect, myUIsoAspect);
1323       setAspectProgram (theProgram, myHasOwnVIsoAspect, myVIsoAspect);
1324       setAspectProgram (theProgram, myHasOwnWireAspect, myWireAspect);
1325       setAspectProgram (theProgram, myHasOwnLineAspect, myLineAspect);
1326       setAspectProgram (theProgram, myHasOwnSeenLineAspect,       mySeenLineAspect);
1327       setAspectProgram (theProgram, myHasOwnHiddenLineAspect,     myHiddenLineAspect);
1328       setAspectProgram (theProgram, myHasOwnVectorAspect,         myVectorAspect);
1329       setAspectProgram (theProgram, myHasOwnSectionAspect,        mySectionAspect);
1330       setAspectProgram (theProgram, myHasOwnFreeBoundaryAspect,   myFreeBoundaryAspect);
1331       setAspectProgram (theProgram, myHasOwnUnFreeBoundaryAspect, myUnFreeBoundaryAspect);
1332       setAspectProgram (theProgram, myHasOwnFaceBoundaryAspect,   myFaceBoundaryAspect);
1333       if (myHasOwnPlaneAspect)
1334       {
1335         setAspectProgram (theProgram, true, myPlaneAspect->EdgesAspect());
1336         setAspectProgram (theProgram, true, myPlaneAspect->IsoAspect());
1337         setAspectProgram (theProgram, true, myPlaneAspect->ArrowAspect());
1338       }
1339       if (myHasOwnDatumAspect)
1340       {
1341         setAspectProgram (theProgram, true, myDatumAspect->LineAspect(Prs3d_DP_XAxis));
1342         setAspectProgram (theProgram, true, myDatumAspect->LineAspect(Prs3d_DP_YAxis));
1343         setAspectProgram (theProgram, true, myDatumAspect->LineAspect(Prs3d_DP_ZAxis));
1344       }
1345       setAspectProgram (theProgram, myHasOwnArrowAspect, myArrowAspect);
1346       return isUpdateNeeded;
1347     }
1348     case Graphic3d_ASPECT_TEXT:
1349     {
1350       if (theToOverrideDefaults
1351       && !myHasOwnTextAspect)
1352       {
1353         isUpdateNeeded = true;
1354         myTextAspect = new Prs3d_TextAspect();
1355         myHasOwnTextAspect = true;
1356         if (!myLink.IsNull())
1357         {
1358           *myTextAspect->Aspect() = *myLink->TextAspect()->Aspect();
1359         }
1360       }
1361
1362       setAspectProgram (theProgram, myHasOwnTextAspect, myTextAspect);
1363       return isUpdateNeeded;
1364     }
1365     case Graphic3d_ASPECT_MARKER:
1366     {
1367       if (theToOverrideDefaults
1368        && SetupOwnPointAspect())
1369       {
1370         isUpdateNeeded = true;
1371       }
1372
1373       setAspectProgram (theProgram, myHasOwnPointAspect, myPointAspect);
1374       return isUpdateNeeded;
1375     }
1376     case Graphic3d_ASPECT_FILL_AREA:
1377     {
1378       if (theToOverrideDefaults
1379        && SetupOwnShadingAspect())
1380       {
1381         isUpdateNeeded = true;
1382       }
1383       setAspectProgram (theProgram, myHasOwnShadingAspect, myShadingAspect);
1384       return isUpdateNeeded;
1385     }
1386   }
1387   return false;
1388 }
1389
1390 // =======================================================================
1391 // function : SetShadingModel
1392 // purpose  :
1393 // =======================================================================
1394 bool Prs3d_Drawer::SetShadingModel (Graphic3d_TypeOfShadingModel theModel,
1395                                     bool theToOverrideDefaults)
1396 {
1397   bool isUpdateNeeded = false;
1398
1399   if (theToOverrideDefaults
1400    && SetupOwnShadingAspect())
1401   {
1402     isUpdateNeeded  = true;
1403   }
1404
1405   if (!myShadingAspect.IsNull()
1406     && myHasOwnShadingAspect)
1407   {
1408     myShadingAspect->Aspect()->SetShadingModel (theModel);
1409   }
1410
1411   return isUpdateNeeded;
1412 }
1413
1414 // =======================================================================
1415 // function : DumpJson
1416 // purpose  :
1417 // =======================================================================
1418 void Prs3d_Drawer::DumpJson (Standard_OStream& theOStream, const Standard_Integer theDepth) const
1419 {
1420   DUMP_CLASS_BEGIN (theOStream, Prs3d_Drawer);
1421   DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myShadingAspect.get());
1422 }