1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <Prs3d_Drawer.hxx>
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>
30 IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Drawer,MMgt_TShared)
32 // =======================================================================
33 // function : Prs3d_Drawer
35 // =======================================================================
36 Prs3d_Drawer::Prs3d_Drawer()
38 myHasOwnNbPoints (Standard_False),
39 myMaximalParameterValue (500000.),
40 myHasOwnMaximalParameterValue (Standard_False),
41 myChordialDeviation (0.0001),
42 myHasOwnChordialDeviation (Standard_False),
43 myTypeOfDeflection (Aspect_TOD_RELATIVE),
44 myHasOwnTypeOfDeflection (Standard_False),
45 myTypeOfHLR (Prs3d_TOH_NotSet),
46 myDeviationCoefficient (0.001),
47 myHasOwnDeviationCoefficient (Standard_False),
48 myHLRDeviationCoefficient (0.02),
49 myHasOwnHLRDeviationCoefficient (Standard_False),
50 myDeviationAngle (12.0 * M_PI / 180.0),
51 myHasOwnDeviationAngle (Standard_False),
52 myHLRAngle (20.0 * M_PI / 180.0),
53 myHasOwnHLRDeviationAngle (Standard_False),
54 myIsoOnPlane (Standard_False),
55 myHasOwnIsoOnPlane (Standard_False),
56 myIsoOnTriangulation (Standard_False),
57 myHasOwnIsoOnTriangulation (Standard_False),
58 myIsAutoTriangulated (Standard_True),
59 myHasOwnIsAutoTriangulated (Standard_False),
61 myHasOwnUIsoAspect (Standard_False),
62 myHasOwnVIsoAspect (Standard_False),
63 myHasOwnWireAspect (Standard_False),
64 myWireDraw (Standard_True),
65 myHasOwnWireDraw (Standard_False),
66 myHasOwnPointAspect (Standard_False),
67 myHasOwnLineAspect (Standard_False),
68 myHasOwnTextAspect (Standard_False),
69 myHasOwnShadingAspect (Standard_False),
70 myHasOwnPlaneAspect (Standard_False),
71 myHasOwnSeenLineAspect (Standard_False),
72 myHasOwnArrowAspect (Standard_False),
73 myLineArrowDraw (Standard_False),
74 myHasOwnLineArrowDraw (Standard_False),
75 myHasOwnHiddenLineAspect (Standard_False),
76 myDrawHiddenLine (Standard_False),
77 myHasOwnDrawHiddenLine (Standard_False),
78 myHasOwnVectorAspect (Standard_False),
79 myVertexDrawMode (Prs3d_VDM_Inherited),
80 myHasOwnDatumAspect (Standard_False),
81 myHasOwnSectionAspect (Standard_False),
83 myHasOwnFreeBoundaryAspect (Standard_False),
84 myFreeBoundaryDraw (Standard_True),
85 myHasOwnFreeBoundaryDraw (Standard_False),
86 myHasOwnUnFreeBoundaryAspect (Standard_False),
87 myUnFreeBoundaryDraw (Standard_True),
88 myHasOwnUnFreeBoundaryDraw (Standard_False),
89 myHasOwnFaceBoundaryAspect (Standard_False),
90 myFaceBoundaryDraw (Standard_False),
91 myHasOwnFaceBoundaryDraw (Standard_False),
93 myHasOwnDimensionAspect (Standard_False),
94 myHasOwnDimLengthModelUnits (Standard_False),
95 myHasOwnDimAngleModelUnits (Standard_False),
96 myHasOwnDimLengthDisplayUnits (Standard_False),
97 myHasOwnDimAngleDisplayUnits (Standard_False),
99 myHasOwnHighlightStyle (Standard_False),
100 myHasOwnSelectionStyle (Standard_False)
102 myDimensionModelUnits.SetLengthUnits ("m");
103 myDimensionModelUnits.SetAngleUnits ("rad");
104 myDimensionDisplayUnits.SetLengthUnits ("m");
105 myDimensionDisplayUnits.SetAngleUnits ("deg");
108 // =======================================================================
109 // function : SetTypeOfDeflection
111 // =======================================================================
113 void Prs3d_Drawer::SetTypeOfDeflection (const Aspect_TypeOfDeflection theTypeOfDeflection)
115 myHasOwnTypeOfDeflection = Standard_True;
116 myTypeOfDeflection = theTypeOfDeflection;
119 // =======================================================================
120 // function : SetMaximalChordialDeviation
122 // =======================================================================
124 void Prs3d_Drawer::SetMaximalChordialDeviation (const Quantity_Length theChordialDeviation)
126 myHasOwnChordialDeviation = Standard_True;
127 myChordialDeviation = theChordialDeviation;
130 // =======================================================================
131 // function : SetTypeOfHLR
132 // purpose : set type of HLR algorithm
133 // =======================================================================
135 void Prs3d_Drawer::SetTypeOfHLR (const Prs3d_TypeOfHLR theTypeOfHLR)
137 myTypeOfHLR = theTypeOfHLR;
140 // =======================================================================
141 // function : TypeOfHLR
142 // purpose : gets type of HLR algorithm
143 // =======================================================================
145 Prs3d_TypeOfHLR Prs3d_Drawer::TypeOfHLR()
147 if (!HasOwnTypeOfHLR())
149 if (!myLink.IsNull())
151 return myLink->TypeOfHLR();
153 // Prs3d_TOH_PolyAlgo is default value for this setting.
154 myTypeOfHLR = Prs3d_TOH_PolyAlgo;
159 // =======================================================================
160 // function : SetIsoOnTriangulation
162 // =======================================================================
163 void Prs3d_Drawer::SetIsoOnTriangulation (const Standard_Boolean theToEnable)
165 myHasOwnIsoOnTriangulation = Standard_True;
166 myIsoOnTriangulation = theToEnable;
169 // =======================================================================
170 // function : SetMaximalParameterValue
172 // =======================================================================
174 void Prs3d_Drawer::SetMaximalParameterValue (const Standard_Real theValue)
176 myHasOwnMaximalParameterValue = Standard_True;
177 myMaximalParameterValue = theValue;
180 // =======================================================================
181 // function : SetIsoOnPlane
183 // =======================================================================
185 void Prs3d_Drawer::SetIsoOnPlane (const Standard_Boolean theIsEnabled)
187 myHasOwnIsoOnPlane = Standard_True;
188 myIsoOnPlane = theIsEnabled;
191 // =======================================================================
192 // function : SetDiscretisation
194 // =======================================================================
196 void Prs3d_Drawer::SetDiscretisation (const Standard_Integer theValue)
198 myHasOwnNbPoints = Standard_True;
199 myNbPoints = theValue;
202 //=======================================================================
203 //function : SetDeviationCoefficient
205 //=======================================================================
207 void Prs3d_Drawer::SetDeviationCoefficient (const Standard_Real theCoefficient)
209 myPreviousDeviationCoefficient = DeviationCoefficient();
210 myDeviationCoefficient = theCoefficient;
211 myHasOwnDeviationCoefficient = Standard_True;
214 //=======================================================================
215 //function : SetHLRDeviationCoefficient
217 //=======================================================================
219 void Prs3d_Drawer::SetHLRDeviationCoefficient (const Standard_Real theCoefficient)
221 myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient();
222 myHLRDeviationCoefficient = theCoefficient;
223 myHasOwnHLRDeviationCoefficient = Standard_True;
226 //=======================================================================
227 //function : SetDeviationAngle
229 //=======================================================================
231 void Prs3d_Drawer::SetDeviationAngle (const Standard_Real theAngle)
233 myPreviousDeviationAngle = DeviationAngle();
234 myDeviationAngle = theAngle;
235 myHasOwnDeviationAngle = Standard_True;
238 //=======================================================================
239 //function : SetHLRAngle
241 //=======================================================================
243 void Prs3d_Drawer::SetHLRAngle (const Standard_Real theAngle)
245 myPreviousHLRDeviationAngle = HLRAngle();
246 myHLRAngle = theAngle;
247 myHasOwnHLRDeviationAngle = Standard_True;
250 // =======================================================================
251 // function : SetAutoTriangulation
253 // =======================================================================
255 void Prs3d_Drawer::SetAutoTriangulation (const Standard_Boolean theIsEnabled)
257 myHasOwnIsAutoTriangulated = Standard_True;
258 myIsAutoTriangulated = theIsEnabled;
261 // =======================================================================
262 // function : FreeBoundaryAspect
264 // =======================================================================
266 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FreeBoundaryAspect()
268 if (!HasOwnFreeBoundaryAspect())
270 if (!myLink.IsNull())
272 return myLink->FreeBoundaryAspect();
274 if (myFreeBoundaryAspect.IsNull())
276 myFreeBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1.0);
279 return myFreeBoundaryAspect;
282 // =======================================================================
283 // function : FreeBoundaryAspect
285 // =======================================================================
287 void Prs3d_Drawer::SetFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
289 myFreeBoundaryAspect = theAspect;
290 myHasOwnFreeBoundaryAspect = !myFreeBoundaryAspect.IsNull();
293 // =======================================================================
294 // function : SetFreeBoundaryDraw
296 // =======================================================================
298 void Prs3d_Drawer::SetFreeBoundaryDraw (const Standard_Boolean theIsEnabled)
300 myHasOwnFreeBoundaryDraw = Standard_True;
301 myFreeBoundaryDraw = theIsEnabled;
304 // =======================================================================
305 // function : UnFreeBoundaryAspect
307 // =======================================================================
309 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::UnFreeBoundaryAspect()
311 if (!HasOwnUnFreeBoundaryAspect())
313 if (!myLink.IsNull())
315 return myLink->UnFreeBoundaryAspect();
317 if (myUnFreeBoundaryAspect.IsNull())
319 myUnFreeBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
322 return myUnFreeBoundaryAspect;
325 // =======================================================================
326 // function : SetUnFreeBoundaryAspect
328 // =======================================================================
330 void Prs3d_Drawer::SetUnFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
332 myUnFreeBoundaryAspect = theAspect;
333 myHasOwnUnFreeBoundaryAspect = !myUnFreeBoundaryAspect.IsNull();
336 // =======================================================================
337 // function : SetUnFreeBoundaryDraw
339 // =======================================================================
341 void Prs3d_Drawer::SetUnFreeBoundaryDraw (const Standard_Boolean theIsEnabled)
343 myHasOwnUnFreeBoundaryDraw = Standard_True;
344 myUnFreeBoundaryDraw = theIsEnabled;
347 // =======================================================================
348 // function : FaceBoundaryAspect
350 // =======================================================================
352 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FaceBoundaryAspect()
354 if (!HasOwnFaceBoundaryAspect())
356 if (!myLink.IsNull())
358 return myLink->FaceBoundaryAspect();
360 if (myFaceBoundaryAspect.IsNull())
362 myFaceBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0);
365 return myFaceBoundaryAspect;
368 // =======================================================================
369 // function : SetFaceBoundaryAspect
371 // =======================================================================
373 void Prs3d_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
375 myFaceBoundaryAspect = theAspect;
376 myHasOwnFaceBoundaryAspect = !myFaceBoundaryAspect.IsNull();
379 // =======================================================================
380 // function : SetFaceBoundaryDraw
382 // =======================================================================
384 void Prs3d_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
386 myHasOwnFaceBoundaryDraw = Standard_True;
387 myFaceBoundaryDraw = theIsEnabled;
390 // =======================================================================
391 // function : DimensionAspect
393 // =======================================================================
395 const Handle(Prs3d_DimensionAspect)& Prs3d_Drawer::DimensionAspect()
397 if (!HasOwnDimensionAspect())
399 if (!myLink.IsNull())
401 return myLink->DimensionAspect();
403 if (myDimensionAspect.IsNull())
405 myDimensionAspect = new Prs3d_DimensionAspect;
408 return myDimensionAspect;
411 // =======================================================================
412 // function : SetDimensionAspect
414 // =======================================================================
416 void Prs3d_Drawer::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theAspect)
418 myDimensionAspect = theAspect;
419 myHasOwnDimensionAspect = !myDimensionAspect.IsNull();
422 // =======================================================================
423 // function : SetDimLengthModelUnits
425 // =======================================================================
427 void Prs3d_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
429 myHasOwnDimLengthModelUnits = Standard_True;
430 myDimensionModelUnits.SetLengthUnits (theUnits);
433 // =======================================================================
434 // function : SetDimAngleModelUnits
436 // =======================================================================
438 void Prs3d_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
440 myHasOwnDimAngleModelUnits = Standard_True;
441 myDimensionModelUnits.SetAngleUnits (theUnits);
444 // =======================================================================
445 // function : SetDimLengthDisplayUnits
447 // =======================================================================
449 void Prs3d_Drawer::SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits)
451 myHasOwnDimLengthDisplayUnits = Standard_True;
452 myDimensionDisplayUnits.SetLengthUnits (theUnits);
455 // =======================================================================
456 // function : SetDimAngleDisplayUnits
458 // =======================================================================
460 void Prs3d_Drawer::SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits)
462 myHasOwnDimAngleDisplayUnits = Standard_True;
463 myDimensionDisplayUnits.SetAngleUnits (theUnits);
466 // =======================================================================
467 // function : UIsoAspect
469 // =======================================================================
471 const Handle(Prs3d_IsoAspect)& Prs3d_Drawer::UIsoAspect()
473 if (!HasOwnUIsoAspect())
475 if (!myLink.IsNull())
477 return myLink->UIsoAspect();
479 if (myUIsoAspect.IsNull())
481 myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
487 // =======================================================================
488 // function : SetUIsoAspect
490 // =======================================================================
492 void Prs3d_Drawer::SetUIsoAspect (const Handle(Prs3d_IsoAspect)& theAspect)
494 myUIsoAspect = theAspect;
495 myHasOwnUIsoAspect = !myUIsoAspect.IsNull();
498 // =======================================================================
499 // function : VIsoAspect
501 // =======================================================================
503 const Handle(Prs3d_IsoAspect)& Prs3d_Drawer::VIsoAspect()
505 if (!HasOwnVIsoAspect())
507 if (!myLink.IsNull())
509 return myLink->VIsoAspect();
511 if (myVIsoAspect.IsNull())
513 myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
519 // =======================================================================
520 // function : SetVIsoAspect
522 // =======================================================================
524 void Prs3d_Drawer::SetVIsoAspect (const Handle(Prs3d_IsoAspect)& theAspect)
526 myVIsoAspect = theAspect;
527 myHasOwnVIsoAspect= !myVIsoAspect.IsNull();
530 // =======================================================================
531 // function : WireAspect
533 // =======================================================================
535 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::WireAspect()
537 if (!HasOwnWireAspect())
539 if (!myLink.IsNull())
541 return myLink->WireAspect();
543 if (myWireAspect.IsNull())
545 myWireAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
551 // =======================================================================
552 // function : SetWireAspect
554 // =======================================================================
556 void Prs3d_Drawer::SetWireAspect (const Handle(Prs3d_LineAspect)& theAspect)
558 myWireAspect = theAspect;
559 myHasOwnWireAspect = !myWireAspect.IsNull();
562 // =======================================================================
563 // function : SetWireDraw
565 // =======================================================================
567 void Prs3d_Drawer::SetWireDraw (const Standard_Boolean theIsEnabled)
569 myHasOwnWireDraw = Standard_True;
570 myWireDraw = theIsEnabled;
573 // =======================================================================
574 // function : PointAspect
576 // =======================================================================
578 const Handle(Prs3d_PointAspect)& Prs3d_Drawer::PointAspect()
580 if (!HasOwnPointAspect())
582 if (!myLink.IsNull())
584 return myLink->PointAspect();
586 if (myPointAspect.IsNull())
588 myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
591 return myPointAspect;
594 // =======================================================================
595 // function : SetPointAspect
597 // =======================================================================
599 void Prs3d_Drawer::SetPointAspect (const Handle(Prs3d_PointAspect)& theAspect)
601 myPointAspect = theAspect;
602 myHasOwnPointAspect = !myPointAspect.IsNull();
605 // =======================================================================
606 // function : LineAspect
608 // =======================================================================
610 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::LineAspect()
612 if (!HasOwnLineAspect())
614 if (!myLink.IsNull())
616 return myLink->LineAspect();
618 if (myLineAspect.IsNull())
620 myLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
626 // =======================================================================
627 // function : SetLineAspect
629 // =======================================================================
631 void Prs3d_Drawer::SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
633 myLineAspect = theAspect;
634 myHasOwnLineAspect = !myLineAspect.IsNull();
637 // =======================================================================
638 // function : TextAspect
640 // =======================================================================
642 const Handle(Prs3d_TextAspect)& Prs3d_Drawer::TextAspect()
644 if (!HasOwnTextAspect())
646 if (!myLink.IsNull())
648 return myLink->TextAspect();
650 if (myTextAspect.IsNull())
652 myTextAspect = new Prs3d_TextAspect();
658 // =======================================================================
659 // function : SetTextAspect
661 // =======================================================================
663 void Prs3d_Drawer::SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect)
665 myTextAspect = theAspect;
666 myHasOwnTextAspect = !myTextAspect.IsNull();
669 // =======================================================================
670 // function : ShadingAspect
672 // =======================================================================
674 const Handle(Prs3d_ShadingAspect)& Prs3d_Drawer::ShadingAspect()
676 if (!HasOwnShadingAspect())
678 if (!myLink.IsNull())
680 return myLink->ShadingAspect();
682 if (myShadingAspect.IsNull())
684 myShadingAspect = new Prs3d_ShadingAspect();
687 return myShadingAspect;
690 // =======================================================================
691 // function : SetShadingAspect
693 // =======================================================================
695 void Prs3d_Drawer::SetShadingAspect (const Handle(Prs3d_ShadingAspect)& theAspect)
697 myShadingAspect = theAspect;
698 myHasOwnShadingAspect = !myShadingAspect.IsNull();
701 // =======================================================================
702 // function : PlaneAspect
704 // =======================================================================
706 const Handle(Prs3d_PlaneAspect)& Prs3d_Drawer::PlaneAspect()
708 if (!HasOwnPlaneAspect())
710 if (!myLink.IsNull())
712 return myLink->PlaneAspect();
714 if (myPlaneAspect.IsNull())
716 myPlaneAspect = new Prs3d_PlaneAspect();
719 return myPlaneAspect;
722 // =======================================================================
723 // function : SetPlaneAspect
725 // =======================================================================
727 void Prs3d_Drawer::SetPlaneAspect (const Handle(Prs3d_PlaneAspect)& theAspect)
729 myPlaneAspect = theAspect;
730 myHasOwnPlaneAspect = !myPlaneAspect.IsNull();
733 // =======================================================================
734 // function : SeenLineAspect
736 // =======================================================================
738 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SeenLineAspect()
740 if (!HasOwnSeenLineAspect())
742 if (!myLink.IsNull())
744 return myLink->SeenLineAspect();
746 if (mySeenLineAspect.IsNull())
748 mySeenLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
751 return mySeenLineAspect;
754 // =======================================================================
755 // function : SetSeenLineAspect
757 // =======================================================================
759 void Prs3d_Drawer::SetSeenLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
761 mySeenLineAspect = theAspect;
762 myHasOwnSeenLineAspect = !mySeenLineAspect.IsNull();
765 // =======================================================================
766 // function : ArrowAspect
768 // =======================================================================
770 const Handle(Prs3d_ArrowAspect)& Prs3d_Drawer::ArrowAspect()
772 if (!HasOwnArrowAspect())
774 if (!myLink.IsNull())
776 return myLink->ArrowAspect();
778 if (myArrowAspect.IsNull())
780 myArrowAspect = new Prs3d_ArrowAspect();
783 return myArrowAspect;
786 // =======================================================================
787 // function : SetArrowAspect
789 // =======================================================================
791 void Prs3d_Drawer::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect)
793 myArrowAspect = theAspect;
794 myHasOwnArrowAspect = !myArrowAspect.IsNull();
797 // =======================================================================
798 // function : SetLineArrowDraw
800 // =======================================================================
802 void Prs3d_Drawer::SetLineArrowDraw (const Standard_Boolean theIsEnabled)
804 myHasOwnLineArrowDraw = Standard_True;
805 myLineArrowDraw = theIsEnabled;
808 // =======================================================================
809 // function : HiddenLineAspect
811 // =======================================================================
813 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::HiddenLineAspect()
815 if (!HasOwnHiddenLineAspect())
817 if (!myLink.IsNull())
819 return myLink->HiddenLineAspect();
821 if (myHiddenLineAspect.IsNull())
823 myHiddenLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_DASH, 1.0);
826 return myHiddenLineAspect;
829 // =======================================================================
830 // function : SetHiddenLineAspect
832 // =======================================================================
834 void Prs3d_Drawer::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
836 myHiddenLineAspect = theAspect;
837 myHasOwnHiddenLineAspect = !myHiddenLineAspect.IsNull();
840 // =======================================================================
841 // function : EnableDrawHiddenLineDraw
843 // =======================================================================
845 void Prs3d_Drawer::EnableDrawHiddenLine()
847 myHasOwnDrawHiddenLine = Standard_True;
848 myDrawHiddenLine = Standard_True;
851 // =======================================================================
852 // function : DisableDrawHiddenLine
854 // =======================================================================
856 void Prs3d_Drawer::DisableDrawHiddenLine()
858 myHasOwnDrawHiddenLine = Standard_True;
859 myDrawHiddenLine = Standard_False;
862 // =======================================================================
863 // function : VectorAspect
865 // =======================================================================
867 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::VectorAspect()
869 if (!HasOwnVectorAspect())
871 if (!myLink.IsNull())
873 return myLink->VectorAspect();
875 if (myVectorAspect.IsNull())
877 myVectorAspect = new Prs3d_LineAspect (Quantity_NOC_SKYBLUE, Aspect_TOL_SOLID, 1.0);
880 return myVectorAspect;
883 // =======================================================================
884 // function : SetVectorAspect
886 // =======================================================================
888 void Prs3d_Drawer::SetVectorAspect (const Handle(Prs3d_LineAspect)& theAspect)
890 myVectorAspect = theAspect;
891 myHasOwnVectorAspect = !myVectorAspect.IsNull();
894 // =======================================================================
895 // function : SetVertexDrawMode
897 // =======================================================================
899 void Prs3d_Drawer::SetVertexDrawMode (const Prs3d_VertexDrawMode theMode)
901 // Prs3d_VDM_Inherited is default value and means
902 // that correct value should be taken from the Link if it exists.
903 myVertexDrawMode = theMode;
906 // =======================================================================
907 // function : VertexDrawMode
909 // =======================================================================
911 Prs3d_VertexDrawMode Prs3d_Drawer::VertexDrawMode()
913 if (!HasOwnVertexDrawMode())
915 if (!myLink.IsNull())
917 return myLink->VertexDrawMode();
919 // Prs3d_VDM_Isolated is default value for this setting.
920 myVertexDrawMode = Prs3d_VDM_Isolated;
922 return myVertexDrawMode;
925 // =======================================================================
926 // function : DatumAspect
928 // =======================================================================
930 const Handle(Prs3d_DatumAspect)& Prs3d_Drawer::DatumAspect()
932 if (!HasOwnDatumAspect())
934 if (!myLink.IsNull())
936 return myLink->DatumAspect();
938 if (myDatumAspect.IsNull())
940 myDatumAspect = new Prs3d_DatumAspect();
943 return myDatumAspect;
946 // =======================================================================
947 // function : SetDatumAspect
949 // =======================================================================
951 void Prs3d_Drawer::SetDatumAspect (const Handle(Prs3d_DatumAspect)& theAspect)
953 myDatumAspect = theAspect;
954 myHasOwnDatumAspect = !myDatumAspect.IsNull();
957 // =======================================================================
958 // function : SectionAspect
960 // =======================================================================
962 const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SectionAspect()
964 if (!HasOwnSectionAspect())
966 if (!myLink.IsNull())
968 return myLink->SectionAspect();
970 if (mySectionAspect.IsNull())
972 mySectionAspect = new Prs3d_LineAspect (Quantity_NOC_ORANGE, Aspect_TOL_SOLID, 1.0);
975 return mySectionAspect;
978 // =======================================================================
979 // function : SetSectionAspect
981 // =======================================================================
983 void Prs3d_Drawer::SetSectionAspect (const Handle(Prs3d_LineAspect)& theAspect)
985 mySectionAspect = theAspect;
986 myHasOwnSectionAspect = !mySectionAspect.IsNull();
989 // =======================================================================
990 // function : SetSectionAspect
992 // =======================================================================
994 void Prs3d_Drawer::ClearLocalAttributes()
1001 myUIsoAspect.Nullify();
1002 myVIsoAspect.Nullify();
1003 myFreeBoundaryAspect.Nullify();
1004 myUnFreeBoundaryAspect.Nullify();
1005 myFaceBoundaryAspect.Nullify();
1006 myWireAspect.Nullify();
1007 myLineAspect.Nullify();
1008 myTextAspect.Nullify();
1009 myShadingAspect.Nullify();
1010 myPointAspect.Nullify();
1011 myPlaneAspect.Nullify();
1012 myArrowAspect.Nullify();
1013 myHiddenLineAspect.Nullify();
1014 mySeenLineAspect.Nullify();
1015 myVectorAspect .Nullify();
1016 myDatumAspect.Nullify();
1017 myDimensionAspect.Nullify();
1018 mySectionAspect.Nullify();
1019 myHighlightStyle.Nullify();
1020 mySelectionStyle.Nullify();
1022 myHasOwnUIsoAspect = Standard_False;
1023 myHasOwnVIsoAspect = Standard_False;
1024 myHasOwnWireAspect = Standard_False;
1025 myHasOwnPointAspect = Standard_False;
1026 myHasOwnLineAspect = Standard_False;
1027 myHasOwnTextAspect = Standard_False;
1028 myHasOwnShadingAspect = Standard_False;
1029 myHasOwnPlaneAspect = Standard_False;
1030 myHasOwnSeenLineAspect = Standard_False;
1031 myHasOwnArrowAspect = Standard_False;
1032 myHasOwnHiddenLineAspect = Standard_False;
1033 myHasOwnVectorAspect = Standard_False;
1034 myHasOwnDatumAspect = Standard_False;
1035 myHasOwnSectionAspect = Standard_False;
1036 myHasOwnFreeBoundaryAspect = Standard_False;
1037 myHasOwnUnFreeBoundaryAspect = Standard_False;
1038 myHasOwnFaceBoundaryAspect = Standard_False;
1039 myHasOwnDimensionAspect = Standard_False;
1041 myHasOwnNbPoints = Standard_False;
1042 myHasOwnMaximalParameterValue = Standard_False;
1043 myHasOwnTypeOfDeflection = Standard_False;
1044 myHasOwnChordialDeviation = Standard_False;
1045 myHasOwnDeviationCoefficient = Standard_False;
1046 myHasOwnHLRDeviationCoefficient = Standard_False;
1047 myHasOwnDeviationAngle = Standard_False;
1048 myHasOwnHLRDeviationAngle = Standard_False;
1049 myHasOwnIsoOnPlane = Standard_False;
1050 myHasOwnIsoOnTriangulation = Standard_False;
1051 myHasOwnIsAutoTriangulated = Standard_False;
1052 myHasOwnWireDraw = Standard_False;
1053 myHasOwnLineArrowDraw = Standard_False;
1054 myHasOwnDrawHiddenLine = Standard_False;
1055 myHasOwnFreeBoundaryDraw = Standard_False;
1056 myHasOwnUnFreeBoundaryDraw = Standard_False;
1057 myHasOwnFaceBoundaryDraw = Standard_False;
1058 myHasOwnDimLengthModelUnits = Standard_False;
1059 myHasOwnDimLengthDisplayUnits = Standard_False;
1060 myHasOwnDimAngleModelUnits = Standard_False;
1061 myHasOwnDimAngleDisplayUnits = Standard_False;
1062 myHasOwnHighlightStyle = Standard_False;
1063 myHasOwnSelectionStyle = Standard_False;
1065 myVertexDrawMode = Prs3d_VDM_Inherited;
1066 myTypeOfHLR = Prs3d_TOH_NotSet;
1069 //! Copy line aspect defaults from the Link.
1070 inline void copyLineAspect (const Handle(Prs3d_Drawer)& theLink,
1071 Handle(Prs3d_LineAspect)& theAspect,
1072 const Handle(Prs3d_LineAspect)& theBaseAspect)
1074 Handle(Prs3d_LineAspect) aBaseAspect = theBaseAspect;
1075 if (!theLink.IsNull())
1077 theAspect = new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0);
1078 *theAspect->Aspect() = *aBaseAspect->Aspect();
1082 //! Assign the shader program.
1083 template <typename T>
1084 inline void setAspectProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
1087 if (!thePrsAspect.IsNull())
1089 thePrsAspect->Aspect()->SetShaderProgram (theProgram);
1093 // =======================================================================
1094 // function : SetShaderProgram
1096 // =======================================================================
1097 void Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
1098 const Graphic3d_GroupAspect theAspect,
1099 const bool theToOverrideDefaults)
1103 case Graphic3d_ASPECT_LINE:
1105 if (theToOverrideDefaults)
1107 if (myUIsoAspect.IsNull())
1109 Handle(Prs3d_IsoAspect) anAspect = UIsoAspect();
1110 if (!myLink.IsNull())
1112 myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
1113 *myUIsoAspect->Aspect() = *anAspect->Aspect();
1114 myUIsoAspect->SetNumber (anAspect->Number());
1117 if (myVIsoAspect.IsNull())
1119 Handle(Prs3d_IsoAspect) anAspect = VIsoAspect();
1120 if (!myLink.IsNull())
1122 myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
1123 *myVIsoAspect->Aspect() = *anAspect->Aspect();
1124 myUIsoAspect->SetNumber (anAspect->Number());
1127 if (myWireAspect.IsNull())
1129 copyLineAspect (myLink, myWireAspect, WireAspect());
1131 if (myLineAspect.IsNull())
1133 copyLineAspect (myLink, myLineAspect, LineAspect());
1135 if (mySeenLineAspect.IsNull())
1137 copyLineAspect (myLink, mySeenLineAspect, SeenLineAspect());
1139 if (myHiddenLineAspect.IsNull())
1141 copyLineAspect (myLink, myHiddenLineAspect, HiddenLineAspect());
1143 if (myVectorAspect.IsNull())
1145 copyLineAspect (myLink, myVectorAspect, VectorAspect());
1147 if (mySectionAspect.IsNull())
1149 copyLineAspect (myLink, mySectionAspect, SectionAspect());
1151 if (myFreeBoundaryAspect.IsNull())
1153 copyLineAspect (myLink, myFreeBoundaryAspect, FreeBoundaryAspect());
1155 if (myUnFreeBoundaryAspect.IsNull())
1157 copyLineAspect (myLink, myUnFreeBoundaryAspect, UnFreeBoundaryAspect());
1159 if (myFaceBoundaryAspect.IsNull())
1161 copyLineAspect (myLink, myFaceBoundaryAspect, FaceBoundaryAspect());
1164 if (myPlaneAspect.IsNull())
1166 myPlaneAspect = new Prs3d_PlaneAspect();
1168 if (myArrowAspect.IsNull())
1170 myArrowAspect = new Prs3d_ArrowAspect();
1172 if (myDatumAspect.IsNull())
1174 myDatumAspect = new Prs3d_DatumAspect();
1178 setAspectProgram (theProgram, myUIsoAspect);
1179 setAspectProgram (theProgram, myVIsoAspect);
1180 setAspectProgram (theProgram, myWireAspect);
1181 setAspectProgram (theProgram, myLineAspect);
1182 setAspectProgram (theProgram, mySeenLineAspect);
1183 setAspectProgram (theProgram, myHiddenLineAspect);
1184 setAspectProgram (theProgram, myVectorAspect);
1185 setAspectProgram (theProgram, mySectionAspect);
1186 setAspectProgram (theProgram, myFreeBoundaryAspect);
1187 setAspectProgram (theProgram, myUnFreeBoundaryAspect);
1188 setAspectProgram (theProgram, myFaceBoundaryAspect);
1189 if (!myPlaneAspect.IsNull())
1191 setAspectProgram (theProgram, myPlaneAspect->EdgesAspect());
1192 setAspectProgram (theProgram, myPlaneAspect->IsoAspect());
1193 setAspectProgram (theProgram, myPlaneAspect->ArrowAspect());
1195 if (!myDatumAspect.IsNull())
1197 setAspectProgram (theProgram, myDatumAspect->FirstAxisAspect());
1198 setAspectProgram (theProgram, myDatumAspect->SecondAxisAspect());
1199 setAspectProgram (theProgram, myDatumAspect->ThirdAxisAspect());
1201 setAspectProgram (theProgram, myArrowAspect);
1204 case Graphic3d_ASPECT_TEXT:
1206 if (theToOverrideDefaults
1207 && myTextAspect.IsNull())
1209 myTextAspect = new Prs3d_TextAspect();
1210 if (!myLink.IsNull())
1212 *myTextAspect->Aspect() = *myLink->TextAspect()->Aspect();
1216 setAspectProgram (theProgram, myTextAspect);
1219 case Graphic3d_ASPECT_MARKER:
1221 if (theToOverrideDefaults
1222 && myPointAspect.IsNull())
1224 myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
1225 if (!myLink.IsNull())
1227 *myPointAspect->Aspect() = *myLink->PointAspect()->Aspect();
1231 setAspectProgram (theProgram, myPointAspect);
1234 case Graphic3d_ASPECT_FILL_AREA:
1236 if (myShadingAspect.IsNull()
1237 && theToOverrideDefaults)
1239 myShadingAspect = new Prs3d_ShadingAspect();
1240 if (!myLink.IsNull())
1242 *myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
1245 setAspectProgram (theProgram, myShadingAspect);
1251 // =======================================================================
1252 // function : SetHighlightStyle
1254 // =======================================================================
1255 void Prs3d_Drawer::SetHighlightStyle (const Handle(Graphic3d_HighlightStyle)& theStyle)
1257 myHighlightStyle = theStyle;
1258 myHasOwnHighlightStyle = !myHighlightStyle.IsNull();
1261 // =======================================================================
1262 // function : SetSelectionStyle
1264 // =======================================================================
1265 void Prs3d_Drawer::SetSelectionStyle (const Handle(Graphic3d_HighlightStyle)& theStyle)
1267 mySelectionStyle = theStyle;
1268 myHasOwnSelectionStyle = !mySelectionStyle.IsNull();