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