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