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