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