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