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