0028162: Draw Harness - eliminate usage of deprecated Local Context
[occt.git] / src / Prs3d / Prs3d_Drawer.cxx
CommitLineData
b311480e 1// Copyright (c) 1995-1999 Matra Datavision
973c2be1 2// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 3//
973c2be1 4// This file is part of Open CASCADE Technology software library.
b311480e 5//
d5f74e42 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
973c2be1 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.
b311480e 11//
973c2be1 12// Alternatively, this file may be used under the terms of Open CASCADE
13// commercial license or contractual agreement.
b311480e 14
6262338c 15#include <Prs3d_Drawer.hxx>
fb66bb28 16
17#include <Graphic3d_AspectFillArea3d.hxx>
18#include <Graphic3d_AspectMarker3d.hxx>
19#include <Graphic3d_AspectText3d.hxx>
6262338c 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
92efcf78 30IMPLEMENT_STANDARD_RTTIEXT(Prs3d_Drawer,MMgt_TShared)
31
60bf98ae 32// =======================================================================
33// function : Prs3d_Drawer
34// purpose :
35// =======================================================================
36Prs3d_Drawer::Prs3d_Drawer()
6262338c 37: myNbPoints (30),
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),
5ad8c033 56 myIsoOnTriangulation (Standard_False),
57 myHasOwnIsoOnTriangulation (Standard_False),
4c513386 58 myIsAutoTriangulated (Standard_True),
59 myHasOwnIsAutoTriangulated (Standard_False),
6262338c 60
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),
6262338c 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),
82
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),
92
93 myHasOwnDimensionAspect (Standard_False),
94 myHasOwnDimLengthModelUnits (Standard_False),
95 myHasOwnDimAngleModelUnits (Standard_False),
96 myHasOwnDimLengthDisplayUnits (Standard_False),
8e5fb5ea 97 myHasOwnDimAngleDisplayUnits (Standard_False),
98
99 myHasOwnHighlightStyle (Standard_False),
100 myHasOwnSelectionStyle (Standard_False)
7fd59977 101{
60bf98ae 102 myDimensionModelUnits.SetLengthUnits ("m");
103 myDimensionModelUnits.SetAngleUnits ("rad");
104 myDimensionDisplayUnits.SetLengthUnits ("m");
105 myDimensionDisplayUnits.SetAngleUnits ("deg");
106}
7fd59977 107
6262338c 108// =======================================================================
109// function : SetTypeOfDeflection
110// purpose :
111// =======================================================================
7fd59977 112
6262338c 113void Prs3d_Drawer::SetTypeOfDeflection (const Aspect_TypeOfDeflection theTypeOfDeflection)
7fd59977 114{
6262338c 115 myHasOwnTypeOfDeflection = Standard_True;
116 myTypeOfDeflection = theTypeOfDeflection;
7fd59977 117}
118
6262338c 119// =======================================================================
120// function : SetMaximalChordialDeviation
121// purpose :
122// =======================================================================
123
124void Prs3d_Drawer::SetMaximalChordialDeviation (const Quantity_Length theChordialDeviation)
7fd59977 125{
6262338c 126 myHasOwnChordialDeviation = Standard_True;
127 myChordialDeviation = theChordialDeviation;
7fd59977 128}
129
6262338c 130// =======================================================================
131// function : SetTypeOfHLR
132// purpose : set type of HLR algorithm
133// =======================================================================
7fd59977 134
6262338c 135void Prs3d_Drawer::SetTypeOfHLR (const Prs3d_TypeOfHLR theTypeOfHLR)
7fd59977 136{
6262338c 137 myTypeOfHLR = theTypeOfHLR;
7fd59977 138}
139
6262338c 140// =======================================================================
141// function : TypeOfHLR
142// purpose : gets type of HLR algorithm
143// =======================================================================
7fd59977 144
6262338c 145Prs3d_TypeOfHLR Prs3d_Drawer::TypeOfHLR()
7fd59977 146{
6262338c 147 if (!HasOwnTypeOfHLR())
148 {
149 if (!myLink.IsNull())
150 {
151 return myLink->TypeOfHLR();
152 }
153 // Prs3d_TOH_PolyAlgo is default value for this setting.
154 myTypeOfHLR = Prs3d_TOH_PolyAlgo;
155 }
156 return myTypeOfHLR;
7fd59977 157}
158
6262338c 159// =======================================================================
5ad8c033 160// function : SetIsoOnTriangulation
161// purpose :
162// =======================================================================
163void Prs3d_Drawer::SetIsoOnTriangulation (const Standard_Boolean theToEnable)
164{
165 myHasOwnIsoOnTriangulation = Standard_True;
166 myIsoOnTriangulation = theToEnable;
167}
168
169// =======================================================================
6262338c 170// function : SetMaximalParameterValue
171// purpose :
172// =======================================================================
7fd59977 173
6262338c 174void Prs3d_Drawer::SetMaximalParameterValue (const Standard_Real theValue)
175{
176 myHasOwnMaximalParameterValue = Standard_True;
177 myMaximalParameterValue = theValue;
7fd59977 178}
179
6262338c 180// =======================================================================
181// function : SetIsoOnPlane
182// purpose :
183// =======================================================================
7fd59977 184
6262338c 185void Prs3d_Drawer::SetIsoOnPlane (const Standard_Boolean theIsEnabled)
186{
187 myHasOwnIsoOnPlane = Standard_True;
188 myIsoOnPlane = theIsEnabled;
189}
7fd59977 190
6262338c 191// =======================================================================
192// function : SetDiscretisation
193// purpose :
194// =======================================================================
7fd59977 195
6262338c 196void Prs3d_Drawer::SetDiscretisation (const Standard_Integer theValue)
197{
198 myHasOwnNbPoints = Standard_True;
199 myNbPoints = theValue;
7fd59977 200}
201
202//=======================================================================
6262338c 203//function : SetDeviationCoefficient
7fd59977 204//purpose :
205//=======================================================================
206
6262338c 207void Prs3d_Drawer::SetDeviationCoefficient (const Standard_Real theCoefficient)
208{
209 myPreviousDeviationCoefficient = DeviationCoefficient();
210 myDeviationCoefficient = theCoefficient;
211 myHasOwnDeviationCoefficient = Standard_True;
7fd59977 212}
213
214//=======================================================================
215//function : SetHLRDeviationCoefficient
216//purpose :
217//=======================================================================
218
6262338c 219void Prs3d_Drawer::SetHLRDeviationCoefficient (const Standard_Real theCoefficient)
220{
221 myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient();
222 myHLRDeviationCoefficient = theCoefficient;
223 myHasOwnHLRDeviationCoefficient = Standard_True;
7fd59977 224}
225
226//=======================================================================
6262338c 227//function : SetDeviationAngle
7fd59977 228//purpose :
229//=======================================================================
230
6262338c 231void Prs3d_Drawer::SetDeviationAngle (const Standard_Real theAngle)
232{
233 myPreviousDeviationAngle = DeviationAngle();
234 myDeviationAngle = theAngle;
235 myHasOwnDeviationAngle = Standard_True;
7fd59977 236}
237
238//=======================================================================
239//function : SetHLRAngle
240//purpose :
241//=======================================================================
242
6262338c 243void Prs3d_Drawer::SetHLRAngle (const Standard_Real theAngle)
244{
245 myPreviousHLRDeviationAngle = HLRAngle();
246 myHLRAngle = theAngle;
247 myHasOwnHLRDeviationAngle = Standard_True;
7fd59977 248}
249
6262338c 250// =======================================================================
4c513386 251// function : SetAutoTriangulation
252// purpose :
253// =======================================================================
254
255void Prs3d_Drawer::SetAutoTriangulation (const Standard_Boolean theIsEnabled)
256{
257 myHasOwnIsAutoTriangulated = Standard_True;
258 myIsAutoTriangulated = theIsEnabled;
259}
260
261// =======================================================================
6262338c 262// function : FreeBoundaryAspect
263// purpose :
264// =======================================================================
7fd59977 265
6262338c 266const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FreeBoundaryAspect()
267{
268 if (!HasOwnFreeBoundaryAspect())
269 {
270 if (!myLink.IsNull())
271 {
272 return myLink->FreeBoundaryAspect();
273 }
274 if (myFreeBoundaryAspect.IsNull())
275 {
276 myFreeBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_GREEN, Aspect_TOL_SOLID, 1.0);
277 }
278 }
279 return myFreeBoundaryAspect;
7fd59977 280}
281
6262338c 282// =======================================================================
283// function : FreeBoundaryAspect
284// purpose :
285// =======================================================================
7fd59977 286
6262338c 287void Prs3d_Drawer::SetFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
7fd59977 288{
6262338c 289 myFreeBoundaryAspect = theAspect;
290 myHasOwnFreeBoundaryAspect = !myFreeBoundaryAspect.IsNull();
7fd59977 291}
292
6262338c 293// =======================================================================
294// function : SetFreeBoundaryDraw
295// purpose :
296// =======================================================================
7fd59977 297
6262338c 298void Prs3d_Drawer::SetFreeBoundaryDraw (const Standard_Boolean theIsEnabled)
7fd59977 299{
6262338c 300 myHasOwnFreeBoundaryDraw = Standard_True;
301 myFreeBoundaryDraw = theIsEnabled;
7fd59977 302}
303
6262338c 304// =======================================================================
305// function : UnFreeBoundaryAspect
306// purpose :
307// =======================================================================
7fd59977 308
6262338c 309const Handle(Prs3d_LineAspect)& Prs3d_Drawer::UnFreeBoundaryAspect()
310{
311 if (!HasOwnUnFreeBoundaryAspect())
312 {
313 if (!myLink.IsNull())
314 {
315 return myLink->UnFreeBoundaryAspect();
316 }
317 if (myUnFreeBoundaryAspect.IsNull())
318 {
319 myUnFreeBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
320 }
321 }
322 return myUnFreeBoundaryAspect;
7fd59977 323}
324
6262338c 325// =======================================================================
326// function : SetUnFreeBoundaryAspect
327// purpose :
328// =======================================================================
7fd59977 329
6262338c 330void Prs3d_Drawer::SetUnFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
331{
332 myUnFreeBoundaryAspect = theAspect;
333 myHasOwnUnFreeBoundaryAspect = !myUnFreeBoundaryAspect.IsNull();
7fd59977 334}
335
6262338c 336// =======================================================================
337// function : SetUnFreeBoundaryDraw
338// purpose :
339// =======================================================================
7fd59977 340
6262338c 341void Prs3d_Drawer::SetUnFreeBoundaryDraw (const Standard_Boolean theIsEnabled)
342{
343 myHasOwnUnFreeBoundaryDraw = Standard_True;
344 myUnFreeBoundaryDraw = theIsEnabled;
7fd59977 345}
346
6262338c 347// =======================================================================
348// function : FaceBoundaryAspect
349// purpose :
350// =======================================================================
7fd59977 351
6262338c 352const Handle(Prs3d_LineAspect)& Prs3d_Drawer::FaceBoundaryAspect()
353{
354 if (!HasOwnFaceBoundaryAspect())
355 {
356 if (!myLink.IsNull())
357 {
358 return myLink->FaceBoundaryAspect();
359 }
360 if (myFaceBoundaryAspect.IsNull())
361 {
362 myFaceBoundaryAspect = new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0);
363 }
364 }
365 return myFaceBoundaryAspect;
7fd59977 366}
367
6262338c 368// =======================================================================
369// function : SetFaceBoundaryAspect
370// purpose :
371// =======================================================================
7fd59977 372
6262338c 373void Prs3d_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
374{
375 myFaceBoundaryAspect = theAspect;
376 myHasOwnFaceBoundaryAspect = !myFaceBoundaryAspect.IsNull();
7fd59977 377}
378
6262338c 379// =======================================================================
380// function : SetFaceBoundaryDraw
381// purpose :
382// =======================================================================
7fd59977 383
6262338c 384void Prs3d_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
385{
386 myHasOwnFaceBoundaryDraw = Standard_True;
387 myFaceBoundaryDraw = theIsEnabled;
7fd59977 388}
389
6262338c 390// =======================================================================
391// function : DimensionAspect
392// purpose :
393// =======================================================================
7fd59977 394
6262338c 395const Handle(Prs3d_DimensionAspect)& Prs3d_Drawer::DimensionAspect()
396{
397 if (!HasOwnDimensionAspect())
398 {
399 if (!myLink.IsNull())
400 {
401 return myLink->DimensionAspect();
402 }
403 if (myDimensionAspect.IsNull())
404 {
405 myDimensionAspect = new Prs3d_DimensionAspect;
406 }
407 }
408 return myDimensionAspect;
7fd59977 409}
410
6262338c 411// =======================================================================
412// function : SetDimensionAspect
413// purpose :
414// =======================================================================
7fd59977 415
6262338c 416void Prs3d_Drawer::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theAspect)
417{
418 myDimensionAspect = theAspect;
419 myHasOwnDimensionAspect = !myDimensionAspect.IsNull();
7fd59977 420}
421
6262338c 422// =======================================================================
423// function : SetDimLengthModelUnits
424// purpose :
425// =======================================================================
7fd59977 426
6262338c 427void Prs3d_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
428{
429 myHasOwnDimLengthModelUnits = Standard_True;
430 myDimensionModelUnits.SetLengthUnits (theUnits);
7fd59977 431}
432
6262338c 433// =======================================================================
434// function : SetDimAngleModelUnits
435// purpose :
436// =======================================================================
7fd59977 437
6262338c 438void Prs3d_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
439{
440 myHasOwnDimAngleModelUnits = Standard_True;
441 myDimensionModelUnits.SetAngleUnits (theUnits);
7fd59977 442}
443
6262338c 444// =======================================================================
445// function : SetDimLengthDisplayUnits
446// purpose :
447// =======================================================================
448
449void Prs3d_Drawer::SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits)
450{
451 myHasOwnDimLengthDisplayUnits = Standard_True;
452 myDimensionDisplayUnits.SetLengthUnits (theUnits);
7fd59977 453}
454
6262338c 455// =======================================================================
456// function : SetDimAngleDisplayUnits
457// purpose :
458// =======================================================================
7fd59977 459
6262338c 460void Prs3d_Drawer::SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits)
461{
462 myHasOwnDimAngleDisplayUnits = Standard_True;
463 myDimensionDisplayUnits.SetAngleUnits (theUnits);
7fd59977 464}
465
6262338c 466// =======================================================================
467// function : UIsoAspect
468// purpose :
469// =======================================================================
470
471const Handle(Prs3d_IsoAspect)& Prs3d_Drawer::UIsoAspect()
472{
473 if (!HasOwnUIsoAspect())
474 {
475 if (!myLink.IsNull())
476 {
477 return myLink->UIsoAspect();
478 }
479 if (myUIsoAspect.IsNull())
480 {
1b9f5d95 481 myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
6262338c 482 }
483 }
484 return myUIsoAspect;
7fd59977 485}
486
6262338c 487// =======================================================================
488// function : SetUIsoAspect
489// purpose :
490// =======================================================================
7fd59977 491
6262338c 492void Prs3d_Drawer::SetUIsoAspect (const Handle(Prs3d_IsoAspect)& theAspect)
493{
494 myUIsoAspect = theAspect;
495 myHasOwnUIsoAspect = !myUIsoAspect.IsNull();
7fd59977 496}
497
6262338c 498// =======================================================================
499// function : VIsoAspect
500// purpose :
501// =======================================================================
7fd59977 502
6262338c 503const Handle(Prs3d_IsoAspect)& Prs3d_Drawer::VIsoAspect()
504{
505 if (!HasOwnVIsoAspect())
506 {
507 if (!myLink.IsNull())
508 {
509 return myLink->VIsoAspect();
510 }
511 if (myVIsoAspect.IsNull())
512 {
1b9f5d95 513 myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
6262338c 514 }
515 }
516 return myVIsoAspect;
7fd59977 517}
518
6262338c 519// =======================================================================
520// function : SetVIsoAspect
521// purpose :
522// =======================================================================
7fd59977 523
6262338c 524void Prs3d_Drawer::SetVIsoAspect (const Handle(Prs3d_IsoAspect)& theAspect)
525{
526 myVIsoAspect = theAspect;
527 myHasOwnVIsoAspect= !myVIsoAspect.IsNull();
7fd59977 528}
7fd59977 529
6262338c 530// =======================================================================
531// function : WireAspect
532// purpose :
533// =======================================================================
534
535const Handle(Prs3d_LineAspect)& Prs3d_Drawer::WireAspect()
536{
537 if (!HasOwnWireAspect())
538 {
539 if (!myLink.IsNull())
540 {
541 return myLink->WireAspect();
542 }
543 if (myWireAspect.IsNull())
544 {
545 myWireAspect = new Prs3d_LineAspect (Quantity_NOC_RED, Aspect_TOL_SOLID, 1.0);
546 }
547 }
548 return myWireAspect;
7fd59977 549}
550
6262338c 551// =======================================================================
552// function : SetWireAspect
553// purpose :
554// =======================================================================
7fd59977 555
6262338c 556void Prs3d_Drawer::SetWireAspect (const Handle(Prs3d_LineAspect)& theAspect)
557{
558 myWireAspect = theAspect;
559 myHasOwnWireAspect = !myWireAspect.IsNull();
7fd59977 560}
561
6262338c 562// =======================================================================
563// function : SetWireDraw
564// purpose :
565// =======================================================================
566
567void Prs3d_Drawer::SetWireDraw (const Standard_Boolean theIsEnabled)
568{
569 myHasOwnWireDraw = Standard_True;
570 myWireDraw = theIsEnabled;
7fd59977 571}
572
6262338c 573// =======================================================================
574// function : PointAspect
575// purpose :
576// =======================================================================
7fd59977 577
6262338c 578const Handle(Prs3d_PointAspect)& Prs3d_Drawer::PointAspect()
579{
580 if (!HasOwnPointAspect())
581 {
582 if (!myLink.IsNull())
583 {
584 return myLink->PointAspect();
585 }
586 if (myPointAspect.IsNull())
587 {
588 myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
589 }
590 }
7fd59977 591 return myPointAspect;
592}
593
6262338c 594// =======================================================================
595// function : SetPointAspect
596// purpose :
597// =======================================================================
7fd59977 598
6262338c 599void Prs3d_Drawer::SetPointAspect (const Handle(Prs3d_PointAspect)& theAspect)
53b15292 600{
6262338c 601 myPointAspect = theAspect;
602 myHasOwnPointAspect = !myPointAspect.IsNull();
53b15292 603}
604
6262338c 605// =======================================================================
606// function : LineAspect
607// purpose :
608// =======================================================================
609
610const Handle(Prs3d_LineAspect)& Prs3d_Drawer::LineAspect()
53b15292 611{
6262338c 612 if (!HasOwnLineAspect())
613 {
614 if (!myLink.IsNull())
615 {
616 return myLink->LineAspect();
617 }
618 if (myLineAspect.IsNull())
619 {
620 myLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
621 }
622 }
623 return myLineAspect;
53b15292 624}
625
6262338c 626// =======================================================================
627// function : SetLineAspect
628// purpose :
629// =======================================================================
7fd59977 630
6262338c 631void Prs3d_Drawer::SetLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
632{
633 myLineAspect = theAspect;
634 myHasOwnLineAspect = !myLineAspect.IsNull();
7fd59977 635}
636
6262338c 637// =======================================================================
638// function : TextAspect
639// purpose :
640// =======================================================================
7fd59977 641
6262338c 642const Handle(Prs3d_TextAspect)& Prs3d_Drawer::TextAspect()
643{
644 if (!HasOwnTextAspect())
645 {
646 if (!myLink.IsNull())
647 {
648 return myLink->TextAspect();
649 }
650 if (myTextAspect.IsNull())
651 {
652 myTextAspect = new Prs3d_TextAspect();
653 }
654 }
655 return myTextAspect;
7fd59977 656}
657
6262338c 658// =======================================================================
659// function : SetTextAspect
660// purpose :
661// =======================================================================
7fd59977 662
6262338c 663void Prs3d_Drawer::SetTextAspect (const Handle(Prs3d_TextAspect)& theAspect)
664{
665 myTextAspect = theAspect;
666 myHasOwnTextAspect = !myTextAspect.IsNull();
7fd59977 667}
668
6262338c 669// =======================================================================
670// function : ShadingAspect
671// purpose :
672// =======================================================================
673
674const Handle(Prs3d_ShadingAspect)& Prs3d_Drawer::ShadingAspect()
675{
676 if (!HasOwnShadingAspect())
677 {
678 if (!myLink.IsNull())
679 {
680 return myLink->ShadingAspect();
681 }
682 if (myShadingAspect.IsNull())
683 {
684 myShadingAspect = new Prs3d_ShadingAspect();
685 }
686 }
687 return myShadingAspect;
7fd59977 688}
689
6262338c 690// =======================================================================
691// function : SetShadingAspect
692// purpose :
693// =======================================================================
7fd59977 694
6262338c 695void Prs3d_Drawer::SetShadingAspect (const Handle(Prs3d_ShadingAspect)& theAspect)
696{
697 myShadingAspect = theAspect;
698 myHasOwnShadingAspect = !myShadingAspect.IsNull();
7fd59977 699}
700
6262338c 701// =======================================================================
6262338c 702// function : PlaneAspect
703// purpose :
704// =======================================================================
7fd59977 705
6262338c 706const Handle(Prs3d_PlaneAspect)& Prs3d_Drawer::PlaneAspect()
707{
708 if (!HasOwnPlaneAspect())
709 {
710 if (!myLink.IsNull())
711 {
712 return myLink->PlaneAspect();
713 }
714 if (myPlaneAspect.IsNull())
715 {
716 myPlaneAspect = new Prs3d_PlaneAspect();
717 }
718 }
7fd59977 719 return myPlaneAspect;
720}
721
6262338c 722// =======================================================================
723// function : SetPlaneAspect
724// purpose :
725// =======================================================================
726
727void Prs3d_Drawer::SetPlaneAspect (const Handle(Prs3d_PlaneAspect)& theAspect)
728{
729 myPlaneAspect = theAspect;
730 myHasOwnPlaneAspect = !myPlaneAspect.IsNull();
7fd59977 731}
732
60bf98ae 733// =======================================================================
6262338c 734// function : SeenLineAspect
60bf98ae 735// purpose :
736// =======================================================================
6262338c 737
738const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SeenLineAspect()
a6eb515f 739{
6262338c 740 if (!HasOwnSeenLineAspect())
60bf98ae 741 {
6262338c 742 if (!myLink.IsNull())
743 {
744 return myLink->SeenLineAspect();
745 }
746 if (mySeenLineAspect.IsNull())
747 {
748 mySeenLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_SOLID, 1.0);
749 }
60bf98ae 750 }
6262338c 751 return mySeenLineAspect;
7fd59977 752}
753
60bf98ae 754// =======================================================================
6262338c 755// function : SetSeenLineAspect
60bf98ae 756// purpose :
757// =======================================================================
6262338c 758
759void Prs3d_Drawer::SetSeenLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
60bf98ae 760{
6262338c 761 mySeenLineAspect = theAspect;
762 myHasOwnSeenLineAspect = !mySeenLineAspect.IsNull();
60bf98ae 763}
764
765// =======================================================================
6262338c 766// function : ArrowAspect
60bf98ae 767// purpose :
768// =======================================================================
6262338c 769
770const Handle(Prs3d_ArrowAspect)& Prs3d_Drawer::ArrowAspect()
60bf98ae 771{
6262338c 772 if (!HasOwnArrowAspect())
773 {
774 if (!myLink.IsNull())
775 {
776 return myLink->ArrowAspect();
777 }
778 if (myArrowAspect.IsNull())
779 {
780 myArrowAspect = new Prs3d_ArrowAspect();
781 }
782 }
783 return myArrowAspect;
60bf98ae 784}
785
786// =======================================================================
6262338c 787// function : SetArrowAspect
60bf98ae 788// purpose :
789// =======================================================================
6262338c 790
791void Prs3d_Drawer::SetArrowAspect (const Handle(Prs3d_ArrowAspect)& theAspect)
60bf98ae 792{
6262338c 793 myArrowAspect = theAspect;
794 myHasOwnArrowAspect = !myArrowAspect.IsNull();
60bf98ae 795}
796
797// =======================================================================
6262338c 798// function : SetLineArrowDraw
60bf98ae 799// purpose :
800// =======================================================================
6262338c 801
802void Prs3d_Drawer::SetLineArrowDraw (const Standard_Boolean theIsEnabled)
60bf98ae 803{
6262338c 804 myHasOwnLineArrowDraw = Standard_True;
805 myLineArrowDraw = theIsEnabled;
60bf98ae 806}
807
808// =======================================================================
6262338c 809// function : HiddenLineAspect
60bf98ae 810// purpose :
811// =======================================================================
6262338c 812
813const Handle(Prs3d_LineAspect)& Prs3d_Drawer::HiddenLineAspect()
60bf98ae 814{
6262338c 815 if (!HasOwnHiddenLineAspect())
816 {
817 if (!myLink.IsNull())
818 {
819 return myLink->HiddenLineAspect();
820 }
821 if (myHiddenLineAspect.IsNull())
822 {
1b9f5d95 823 myHiddenLineAspect = new Prs3d_LineAspect (Quantity_NOC_YELLOW, Aspect_TOL_DASH, 1.0);
6262338c 824 }
825 }
826 return myHiddenLineAspect;
60bf98ae 827}
828
829// =======================================================================
6262338c 830// function : SetHiddenLineAspect
60bf98ae 831// purpose :
832// =======================================================================
6262338c 833
834void Prs3d_Drawer::SetHiddenLineAspect (const Handle(Prs3d_LineAspect)& theAspect)
60bf98ae 835{
6262338c 836 myHiddenLineAspect = theAspect;
837 myHasOwnHiddenLineAspect = !myHiddenLineAspect.IsNull();
60bf98ae 838}
839
840// =======================================================================
6262338c 841// function : EnableDrawHiddenLineDraw
60bf98ae 842// purpose :
843// =======================================================================
6262338c 844
845void Prs3d_Drawer::EnableDrawHiddenLine()
60bf98ae 846{
6262338c 847 myHasOwnDrawHiddenLine = Standard_True;
848 myDrawHiddenLine = Standard_True;
60bf98ae 849}
850
851// =======================================================================
6262338c 852// function : DisableDrawHiddenLine
60bf98ae 853// purpose :
854// =======================================================================
6262338c 855
856void Prs3d_Drawer::DisableDrawHiddenLine()
a6eb515f 857{
6262338c 858 myHasOwnDrawHiddenLine = Standard_True;
859 myDrawHiddenLine = Standard_False;
7fd59977 860}
861
60bf98ae 862// =======================================================================
6262338c 863// function : VectorAspect
60bf98ae 864// purpose :
865// =======================================================================
6262338c 866
867const Handle(Prs3d_LineAspect)& Prs3d_Drawer::VectorAspect()
60bf98ae 868{
6262338c 869 if (!HasOwnVectorAspect())
870 {
871 if (!myLink.IsNull())
872 {
873 return myLink->VectorAspect();
874 }
875 if (myVectorAspect.IsNull())
876 {
877 myVectorAspect = new Prs3d_LineAspect (Quantity_NOC_SKYBLUE, Aspect_TOL_SOLID, 1.0);
878 }
879 }
880 return myVectorAspect;
60bf98ae 881}
7fd59977 882
60bf98ae 883// =======================================================================
6262338c 884// function : SetVectorAspect
60bf98ae 885// purpose :
886// =======================================================================
7fd59977 887
6262338c 888void Prs3d_Drawer::SetVectorAspect (const Handle(Prs3d_LineAspect)& theAspect)
889{
890 myVectorAspect = theAspect;
891 myHasOwnVectorAspect = !myVectorAspect.IsNull();
7fd59977 892}
893
60bf98ae 894// =======================================================================
6262338c 895// function : SetVertexDrawMode
60bf98ae 896// purpose :
897// =======================================================================
6262338c 898
899void Prs3d_Drawer::SetVertexDrawMode (const Prs3d_VertexDrawMode theMode)
60bf98ae 900{
6262338c 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;
7fd59977 904}
a2d5ab2e 905
906// =======================================================================
6262338c 907// function : VertexDrawMode
a2d5ab2e 908// purpose :
909// =======================================================================
6262338c 910
911Prs3d_VertexDrawMode Prs3d_Drawer::VertexDrawMode()
a2d5ab2e 912{
6262338c 913 if (!HasOwnVertexDrawMode())
914 {
915 if (!myLink.IsNull())
916 {
917 return myLink->VertexDrawMode();
918 }
919 // Prs3d_VDM_Isolated is default value for this setting.
920 myVertexDrawMode = Prs3d_VDM_Isolated;
921 }
922 return myVertexDrawMode;
a2d5ab2e 923}
924
925// =======================================================================
6262338c 926// function : DatumAspect
a2d5ab2e 927// purpose :
928// =======================================================================
6262338c 929
930const Handle(Prs3d_DatumAspect)& Prs3d_Drawer::DatumAspect()
a2d5ab2e 931{
6262338c 932 if (!HasOwnDatumAspect())
933 {
934 if (!myLink.IsNull())
935 {
936 return myLink->DatumAspect();
937 }
938 if (myDatumAspect.IsNull())
939 {
940 myDatumAspect = new Prs3d_DatumAspect();
941 }
942 }
943 return myDatumAspect;
a2d5ab2e 944}
945
946// =======================================================================
6262338c 947// function : SetDatumAspect
a2d5ab2e 948// purpose :
949// =======================================================================
6262338c 950
951void Prs3d_Drawer::SetDatumAspect (const Handle(Prs3d_DatumAspect)& theAspect)
a2d5ab2e 952{
6262338c 953 myDatumAspect = theAspect;
954 myHasOwnDatumAspect = !myDatumAspect.IsNull();
a2d5ab2e 955}
956
957// =======================================================================
6262338c 958// function : SectionAspect
a2d5ab2e 959// purpose :
960// =======================================================================
6262338c 961
962const Handle(Prs3d_LineAspect)& Prs3d_Drawer::SectionAspect()
a2d5ab2e 963{
6262338c 964 if (!HasOwnSectionAspect())
a2d5ab2e 965 {
6262338c 966 if (!myLink.IsNull())
967 {
968 return myLink->SectionAspect();
969 }
970 if (mySectionAspect.IsNull())
971 {
972 mySectionAspect = new Prs3d_LineAspect (Quantity_NOC_ORANGE, Aspect_TOL_SOLID, 1.0);
973 }
a2d5ab2e 974 }
6262338c 975 return mySectionAspect;
a2d5ab2e 976}
0a768f56 977
978// =======================================================================
6262338c 979// function : SetSectionAspect
980// purpose :
0a768f56 981// =======================================================================
6262338c 982
983void Prs3d_Drawer::SetSectionAspect (const Handle(Prs3d_LineAspect)& theAspect)
0a768f56 984{
6262338c 985 mySectionAspect = theAspect;
986 myHasOwnSectionAspect = !mySectionAspect.IsNull();
0a768f56 987}
988
989// =======================================================================
6262338c 990// function : SetSectionAspect
991// purpose :
0a768f56 992// =======================================================================
6262338c 993
994void Prs3d_Drawer::ClearLocalAttributes()
0a768f56 995{
6262338c 996 if (myLink.IsNull())
997 {
998 return;
999 }
1000
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();
8e5fb5ea 1019 myHighlightStyle.Nullify();
1020 mySelectionStyle.Nullify();
6262338c 1021
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;
1040
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;
5ad8c033 1050 myHasOwnIsoOnTriangulation = Standard_False;
4c513386 1051 myHasOwnIsAutoTriangulated = Standard_False;
6262338c 1052 myHasOwnWireDraw = Standard_False;
6262338c 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;
8e5fb5ea 1062 myHasOwnHighlightStyle = Standard_False;
1063 myHasOwnSelectionStyle = Standard_False;
6262338c 1064
1065 myVertexDrawMode = Prs3d_VDM_Inherited;
1066 myTypeOfHLR = Prs3d_TOH_NotSet;
0a768f56 1067}
fb66bb28 1068
1069//! Copy line aspect defaults from the Link.
1070inline void copyLineAspect (const Handle(Prs3d_Drawer)& theLink,
1071 Handle(Prs3d_LineAspect)& theAspect,
1072 const Handle(Prs3d_LineAspect)& theBaseAspect)
1073{
1074 Handle(Prs3d_LineAspect) aBaseAspect = theBaseAspect;
1075 if (!theLink.IsNull())
1076 {
1077 theAspect = new Prs3d_LineAspect (Quantity_NOC_WHITE, Aspect_TOL_SOLID, 1.0);
1078 *theAspect->Aspect() = *aBaseAspect->Aspect();
1079 }
1080}
1081
1082//! Assign the shader program.
1083template <typename T>
1084inline void setAspectProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
1085 T thePrsAspect)
1086{
1087 if (!thePrsAspect.IsNull())
1088 {
1089 thePrsAspect->Aspect()->SetShaderProgram (theProgram);
1090 }
1091}
1092
1093// =======================================================================
1094// function : SetShaderProgram
1095// purpose :
1096// =======================================================================
1097void Prs3d_Drawer::SetShaderProgram (const Handle(Graphic3d_ShaderProgram)& theProgram,
1098 const Graphic3d_GroupAspect theAspect,
1099 const bool theToOverrideDefaults)
1100{
1101 switch (theAspect)
1102 {
1103 case Graphic3d_ASPECT_LINE:
1104 {
1105 if (theToOverrideDefaults)
1106 {
1107 if (myUIsoAspect.IsNull())
1108 {
1109 Handle(Prs3d_IsoAspect) anAspect = UIsoAspect();
1110 if (!myLink.IsNull())
1111 {
1112 myUIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
1113 *myUIsoAspect->Aspect() = *anAspect->Aspect();
1114 myUIsoAspect->SetNumber (anAspect->Number());
1115 }
1116 }
1117 if (myVIsoAspect.IsNull())
1118 {
1119 Handle(Prs3d_IsoAspect) anAspect = VIsoAspect();
1120 if (!myLink.IsNull())
1121 {
1122 myVIsoAspect = new Prs3d_IsoAspect (Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 1.0, 1);
1123 *myVIsoAspect->Aspect() = *anAspect->Aspect();
1124 myUIsoAspect->SetNumber (anAspect->Number());
1125 }
1126 }
1127 if (myWireAspect.IsNull())
1128 {
1129 copyLineAspect (myLink, myWireAspect, WireAspect());
1130 }
1131 if (myLineAspect.IsNull())
1132 {
1133 copyLineAspect (myLink, myLineAspect, LineAspect());
1134 }
1135 if (mySeenLineAspect.IsNull())
1136 {
1137 copyLineAspect (myLink, mySeenLineAspect, SeenLineAspect());
1138 }
1139 if (myHiddenLineAspect.IsNull())
1140 {
1141 copyLineAspect (myLink, myHiddenLineAspect, HiddenLineAspect());
1142 }
1143 if (myVectorAspect.IsNull())
1144 {
1145 copyLineAspect (myLink, myVectorAspect, VectorAspect());
1146 }
1147 if (mySectionAspect.IsNull())
1148 {
1149 copyLineAspect (myLink, mySectionAspect, SectionAspect());
1150 }
1151 if (myFreeBoundaryAspect.IsNull())
1152 {
1153 copyLineAspect (myLink, myFreeBoundaryAspect, FreeBoundaryAspect());
1154 }
1155 if (myUnFreeBoundaryAspect.IsNull())
1156 {
1157 copyLineAspect (myLink, myUnFreeBoundaryAspect, UnFreeBoundaryAspect());
1158 }
1159 if (myFaceBoundaryAspect.IsNull())
1160 {
1161 copyLineAspect (myLink, myFaceBoundaryAspect, FaceBoundaryAspect());
1162 }
1163
1164 if (myPlaneAspect.IsNull())
1165 {
1166 myPlaneAspect = new Prs3d_PlaneAspect();
1167 }
1168 if (myArrowAspect.IsNull())
1169 {
1170 myArrowAspect = new Prs3d_ArrowAspect();
1171 }
1172 if (myDatumAspect.IsNull())
1173 {
1174 myDatumAspect = new Prs3d_DatumAspect();
1175 }
1176 }
1177
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())
1190 {
1191 setAspectProgram (theProgram, myPlaneAspect->EdgesAspect());
1192 setAspectProgram (theProgram, myPlaneAspect->IsoAspect());
1193 setAspectProgram (theProgram, myPlaneAspect->ArrowAspect());
1194 }
1195 if (!myDatumAspect.IsNull())
1196 {
1197 setAspectProgram (theProgram, myDatumAspect->FirstAxisAspect());
1198 setAspectProgram (theProgram, myDatumAspect->SecondAxisAspect());
1199 setAspectProgram (theProgram, myDatumAspect->ThirdAxisAspect());
1200 }
1201 setAspectProgram (theProgram, myArrowAspect);
1202 return;
1203 }
1204 case Graphic3d_ASPECT_TEXT:
1205 {
1206 if (theToOverrideDefaults
1207 && myTextAspect.IsNull())
1208 {
1209 myTextAspect = new Prs3d_TextAspect();
1210 if (!myLink.IsNull())
1211 {
1212 *myTextAspect->Aspect() = *myLink->TextAspect()->Aspect();
1213 }
1214 }
1215
1216 setAspectProgram (theProgram, myTextAspect);
1217 return;
1218 }
1219 case Graphic3d_ASPECT_MARKER:
1220 {
1221 if (theToOverrideDefaults
1222 && myPointAspect.IsNull())
1223 {
1224 myPointAspect = new Prs3d_PointAspect (Aspect_TOM_PLUS, Quantity_NOC_YELLOW, 1.0);
1225 if (!myLink.IsNull())
1226 {
1227 *myPointAspect->Aspect() = *myLink->PointAspect()->Aspect();
1228 }
1229 }
1230
1231 setAspectProgram (theProgram, myPointAspect);
1232 return;
1233 }
1234 case Graphic3d_ASPECT_FILL_AREA:
1235 {
1236 if (myShadingAspect.IsNull()
1237 && theToOverrideDefaults)
1238 {
1239 myShadingAspect = new Prs3d_ShadingAspect();
1240 if (!myLink.IsNull())
1241 {
1242 *myShadingAspect->Aspect() = *myLink->ShadingAspect()->Aspect();
1243 }
1244 }
1245 setAspectProgram (theProgram, myShadingAspect);
1246 return;
1247 }
1248 }
1249}
8e5fb5ea 1250
1251// =======================================================================
1252// function : SetHighlightStyle
1253// purpose :
1254// =======================================================================
1255void Prs3d_Drawer::SetHighlightStyle (const Handle(Graphic3d_HighlightStyle)& theStyle)
1256{
1257 myHighlightStyle = theStyle;
1258 myHasOwnHighlightStyle = !myHighlightStyle.IsNull();
1259}
1260
1261// =======================================================================
1262// function : SetSelectionStyle
1263// purpose :
1264// =======================================================================
1265void Prs3d_Drawer::SetSelectionStyle (const Handle(Graphic3d_HighlightStyle)& theStyle)
1266{
1267 mySelectionStyle = theStyle;
1268 myHasOwnSelectionStyle = !mySelectionStyle.IsNull();
1269}