0025853: Edges disappear or reappear when displaying new edges
[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
7fd59977 15#include <Prs3d_Drawer.ixx>
16
60bf98ae 17// =======================================================================
18// function : Prs3d_Drawer
19// purpose :
20// =======================================================================
21Prs3d_Drawer::Prs3d_Drawer()
22: myNbPoints (30),
23 myIsoOnPlane (Standard_False),
24 myFreeBoundaryDraw (Standard_True),
25 myUnFreeBoundaryDraw (Standard_True),
26 myWireDraw (Standard_True),
27 myShadingAspect (new Prs3d_ShadingAspect()),
28 myShadingAspectGlobal (Standard_True),
29 myChordialDeviation (0.0001),
30 myTypeOfDeflection (Aspect_TOD_RELATIVE),
31 myMaximalParameterValue (500000.),
32 myDeviationCoefficient (0.001),
33 myHLRDeviationCoefficient (0.02),
34 myDeviationAngle (12.0 * M_PI / 180.0),
35 myHLRAngle (20.0 * M_PI / 180.0),
53b15292 36 myVertexDrawMode (Prs3d_VDM_Isolated),
60bf98ae 37 myLineDrawArrow (Standard_False),
38 myDrawHiddenLine (Standard_False),
39 myFaceBoundaryDraw (Standard_False),
40 myTypeOfHLR (Prs3d_TOH_PolyAlgo)
7fd59977 41{
60bf98ae 42 myDimensionModelUnits.SetLengthUnits ("m");
43 myDimensionModelUnits.SetAngleUnits ("rad");
44 myDimensionDisplayUnits.SetLengthUnits ("m");
45 myDimensionDisplayUnits.SetAngleUnits ("deg");
46}
7fd59977 47
48void Prs3d_Drawer::SetTypeOfDeflection(const Aspect_TypeOfDeflection aTypeOfDeflection){
49
50 myTypeOfDeflection = aTypeOfDeflection;}
51
52Aspect_TypeOfDeflection Prs3d_Drawer::TypeOfDeflection() const {
53
54 return myTypeOfDeflection;
55
56}
57
58
59void Prs3d_Drawer::SetIsoOnPlane(const Standard_Boolean OnOff)
60{
61 myIsoOnPlane = OnOff;
62}
63
64
65Standard_Boolean Prs3d_Drawer::IsoOnPlane()const
66{
67 return myIsoOnPlane;
68}
69
70
71Standard_Integer Prs3d_Drawer::Discretisation() const
72{
73 return myNbPoints;
74}
75
76
77void Prs3d_Drawer::SetDiscretisation(const Standard_Integer d)
78{
79 myNbPoints = d;
80}
81
82
83void Prs3d_Drawer::SetMaximalChordialDeviation(
84 const Quantity_Length aChordialDeviation) {
85 myChordialDeviation = aChordialDeviation;
86}
87
88Quantity_Length Prs3d_Drawer::MaximalChordialDeviation() const {
89 return myChordialDeviation;
90}
91
92//
93//=======================================================================
94//function : SetDeviationCoefficient
95//purpose :
96//=======================================================================
97
98void Prs3d_Drawer::SetDeviationCoefficient (const Standard_Real aCoefficient) {
99
100 myDeviationCoefficient = aCoefficient;
101}
102
103//=======================================================================
104//function : DeviationCoefficient
105//purpose :
106//=======================================================================
107
108Standard_Real Prs3d_Drawer::DeviationCoefficient () const {
109
110 return myDeviationCoefficient;
111}
112
113//=======================================================================
114//function : SetHLRDeviationCoefficient
115//purpose :
116//=======================================================================
117
118void Prs3d_Drawer::SetHLRDeviationCoefficient (const Standard_Real aCoefficient) {
119
120 myHLRDeviationCoefficient = aCoefficient;
121}
122
123//=======================================================================
124//function : HLRDeviationCoefficient
125//purpose :
126//=======================================================================
127
128Standard_Real Prs3d_Drawer::HLRDeviationCoefficient () const {
129
130 return myHLRDeviationCoefficient;
131}
132
133//=======================================================================
134//function : SetHLRAngle
135//purpose :
136//=======================================================================
137
138void Prs3d_Drawer::SetHLRAngle (const Standard_Real anAngle) {
139
140 myHLRAngle = anAngle;
141}
142
143//=======================================================================
144//function : HLRAngle
145//purpose :
146//=======================================================================
147
148Standard_Real Prs3d_Drawer::HLRAngle () const {
149
150 return myHLRAngle;
151}
152
153//=======================================================================
154//function : SetDeviationAngle
155//purpose :
156//=======================================================================
157
158void Prs3d_Drawer::SetDeviationAngle (const Standard_Real anAngle)
159{
160 myDeviationAngle = anAngle;
161}
162
163//=======================================================================
164//function : DeviationAngle
165//purpose :
166//=======================================================================
167
168Standard_Real Prs3d_Drawer::DeviationAngle () const
169{
170 return myDeviationAngle;
171}
172
173
174void Prs3d_Drawer::SetMaximalParameterValue (const Standard_Real Value) {
175 myMaximalParameterValue = Value;
176}
177
178Standard_Real Prs3d_Drawer::MaximalParameterValue () const {
179 return myMaximalParameterValue;
180}
181
182Handle (Prs3d_IsoAspect) Prs3d_Drawer::UIsoAspect (){
183
184 if (myUIsoAspect.IsNull())
185 myUIsoAspect = new Prs3d_IsoAspect
186 (Quantity_NOC_GRAY75,Aspect_TOL_SOLID,0.5,1);
187
188 return myUIsoAspect;
189}
190
191void Prs3d_Drawer::SetUIsoAspect ( const Handle(Prs3d_IsoAspect)& anAspect) {
192 myUIsoAspect = anAspect;
193}
194
195Handle (Prs3d_IsoAspect) Prs3d_Drawer::VIsoAspect () {
196 if (myVIsoAspect.IsNull())
197 myVIsoAspect = new Prs3d_IsoAspect
198 (Quantity_NOC_GRAY75,Aspect_TOL_SOLID,0.5,1);
199
200 return myVIsoAspect;
201}
202
203void Prs3d_Drawer::SetVIsoAspect ( const Handle(Prs3d_IsoAspect)& anAspect) {
204 myVIsoAspect = anAspect;
205}
206
207Handle (Prs3d_LineAspect) Prs3d_Drawer::FreeBoundaryAspect () {
208 if (myFreeBoundaryAspect.IsNull())
209 myFreeBoundaryAspect = new Prs3d_LineAspect
210 (Quantity_NOC_GREEN,Aspect_TOL_SOLID,1.);
211
212 return myFreeBoundaryAspect;
213}
214
215void Prs3d_Drawer::SetFreeBoundaryAspect (const Handle(Prs3d_LineAspect)& anAspect) {
216 myFreeBoundaryAspect = anAspect;
217}
218
219void Prs3d_Drawer::SetFreeBoundaryDraw ( const Standard_Boolean OnOff ) {
220 myFreeBoundaryDraw = OnOff;
221}
222
223Standard_Boolean Prs3d_Drawer::FreeBoundaryDraw () const {
224return myFreeBoundaryDraw;
225}
226
227Handle (Prs3d_LineAspect) Prs3d_Drawer::UnFreeBoundaryAspect (){
228 if (myUnFreeBoundaryAspect.IsNull())
229 myUnFreeBoundaryAspect = new Prs3d_LineAspect
230 (Quantity_NOC_YELLOW,Aspect_TOL_SOLID,1.);
231 return myUnFreeBoundaryAspect;
232}
233
234void Prs3d_Drawer::SetUnFreeBoundaryAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
235 myUnFreeBoundaryAspect = anAspect;
236}
237
238void Prs3d_Drawer::SetUnFreeBoundaryDraw ( const Standard_Boolean OnOff ) {
239 myUnFreeBoundaryDraw = OnOff;
240}
241
242Standard_Boolean Prs3d_Drawer::UnFreeBoundaryDraw () const {
243 return myUnFreeBoundaryDraw;
244}
245
246Handle (Prs3d_LineAspect) Prs3d_Drawer::WireAspect () {
247 if (myWireAspect.IsNull())
248 myWireAspect = new Prs3d_LineAspect(Quantity_NOC_RED,Aspect_TOL_SOLID,1.);
249
250 return myWireAspect;
251}
252
253void Prs3d_Drawer::SetWireAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
254 myWireAspect = anAspect;
255}
256void Prs3d_Drawer::SetWireDraw ( const Standard_Boolean OnOff ) {
257 myWireDraw = OnOff;
258}
259
260Standard_Boolean Prs3d_Drawer::WireDraw () const {
261return myWireDraw;
262}
263
264
265Handle (Prs3d_LineAspect) Prs3d_Drawer::LineAspect () {
266 if (myLineAspect.IsNull())
267 myLineAspect = new Prs3d_LineAspect
268 (Quantity_NOC_YELLOW,Aspect_TOL_SOLID,1.);
269 return myLineAspect;
270}
271
272void Prs3d_Drawer::SetLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
273 myLineAspect = anAspect;
274}
275
276Handle (Prs3d_TextAspect) Prs3d_Drawer::TextAspect () {
277 if (myTextAspect.IsNull())
278 myTextAspect = new Prs3d_TextAspect();
279
280 return myTextAspect;
281}
282
283void Prs3d_Drawer::SetTextAspect ( const Handle(Prs3d_TextAspect)& anAspect) {
284 myTextAspect = anAspect;
285}
286
287Handle (Prs3d_ShadingAspect) Prs3d_Drawer::ShadingAspect () {
288 if (myShadingAspect.IsNull())
289 myShadingAspect = new Prs3d_ShadingAspect();
290
291 return myShadingAspect;
292}
293
294void Prs3d_Drawer::SetShadingAspect ( const Handle(Prs3d_ShadingAspect)& anAspect) {
295 myShadingAspect = anAspect;
296}
297
298void Prs3d_Drawer::SetShadingAspectGlobal(const Standard_Boolean aValue) {
299 myShadingAspectGlobal = aValue;
300}
301
302Standard_Boolean Prs3d_Drawer::ShadingAspectGlobal() const {
303
304 return myShadingAspectGlobal;
305
306}
307
308void Prs3d_Drawer::SetLineArrowDraw ( const Standard_Boolean OnOff ) {
309 myLineDrawArrow = OnOff;
310}
311
312Standard_Boolean Prs3d_Drawer::LineArrowDraw () const {
313return myLineDrawArrow;
314}
315
316Handle (Prs3d_ArrowAspect) Prs3d_Drawer::ArrowAspect() {
317 if (myArrowAspect.IsNull())
318 myArrowAspect = new Prs3d_ArrowAspect;
319
320 return myArrowAspect;
321}
322
323void Prs3d_Drawer::SetArrowAspect ( const Handle(Prs3d_ArrowAspect)& anAspect) {
324 myArrowAspect = anAspect;
325}
326
327Handle (Prs3d_PointAspect) Prs3d_Drawer::PointAspect() {
328 if (myPointAspect.IsNull())
329 myPointAspect = new Prs3d_PointAspect
330 (Aspect_TOM_PLUS,Quantity_NOC_YELLOW,1.);
331
332 return myPointAspect;
333}
334
335void Prs3d_Drawer::SetPointAspect ( const Handle(Prs3d_PointAspect)& anAspect) {
336 myPointAspect = anAspect;
337}
338
53b15292 339void Prs3d_Drawer::SetVertexDrawMode (const Prs3d_VertexDrawMode theMode)
340{
341 // Prs3d_VDM_Inherited value is allowed at AIS_Drawer level.
342 // Replacing it by Prs3d_VDM_Isolated to avoid unpredictable behavior.
343 myVertexDrawMode = (theMode == Prs3d_VDM_Inherited ? Prs3d_VDM_Isolated : theMode);
344}
345
346Prs3d_VertexDrawMode Prs3d_Drawer::VertexDrawMode () const
347{
348 return myVertexDrawMode;
349}
350
7fd59977 351Standard_Boolean Prs3d_Drawer::DrawHiddenLine () const {return myDrawHiddenLine;}
352
353void Prs3d_Drawer::EnableDrawHiddenLine () {myDrawHiddenLine=Standard_True;}
354
355void Prs3d_Drawer::DisableDrawHiddenLine () {myDrawHiddenLine=Standard_False;}
356
357Handle (Prs3d_LineAspect) Prs3d_Drawer::HiddenLineAspect () {
358 if (myHiddenLineAspect.IsNull())
359 myHiddenLineAspect = new Prs3d_LineAspect
360 (Quantity_NOC_YELLOW,Aspect_TOL_DASH,0.5);
361
362 return myHiddenLineAspect;
363}
364
365void Prs3d_Drawer::SetHiddenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
366 myHiddenLineAspect = anAspect;
367}
368
369Handle (Prs3d_LineAspect) Prs3d_Drawer::SeenLineAspect () {
370 if (mySeenLineAspect.IsNull())
371 mySeenLineAspect = new Prs3d_LineAspect
372 (Quantity_NOC_YELLOW,Aspect_TOL_SOLID,1.);
373
374 return mySeenLineAspect;
375}
376
377void Prs3d_Drawer::SetSeenLineAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
378 mySeenLineAspect = anAspect;
379}
380
381Handle (Prs3d_LineAspect) Prs3d_Drawer::VectorAspect () {
382 if (myVectorAspect.IsNull())
383 myVectorAspect = new Prs3d_LineAspect
384 (Quantity_NOC_SKYBLUE,Aspect_TOL_SOLID,1.);
385
386 return myVectorAspect;
387}
388
389void Prs3d_Drawer::SetVectorAspect ( const Handle(Prs3d_LineAspect)& anAspect) {
390 myVectorAspect = anAspect;
391}
392
393Handle (Prs3d_DatumAspect) Prs3d_Drawer::DatumAspect () {
394 if (myDatumAspect.IsNull())
395 myDatumAspect = new Prs3d_DatumAspect;
396
397 return myDatumAspect;
398}
399
400void Prs3d_Drawer::SetDatumAspect ( const Handle(Prs3d_DatumAspect)& anAspect) {
401 myDatumAspect = anAspect;
402}
403
404Handle (Prs3d_PlaneAspect) Prs3d_Drawer::PlaneAspect () {
405 if (myPlaneAspect.IsNull())
406 myPlaneAspect = new Prs3d_PlaneAspect;
407
408 return myPlaneAspect;
409}
410
411void Prs3d_Drawer::SetPlaneAspect ( const Handle(Prs3d_PlaneAspect)& anAspect) {
412 myPlaneAspect = anAspect;
413}
414
60bf98ae 415// =======================================================================
416// function : DimensionAspect
417// purpose :
418// =======================================================================
419Handle(Prs3d_DimensionAspect) Prs3d_Drawer::DimensionAspect()
a6eb515f 420{
421 if (myDimensionAspect.IsNull())
60bf98ae 422 {
a6eb515f 423 myDimensionAspect = new Prs3d_DimensionAspect;
60bf98ae 424 }
7fd59977 425
a6eb515f 426 return myDimensionAspect;
7fd59977 427}
428
60bf98ae 429// =======================================================================
430// function : SetDimensionAspect
431// purpose :
432// =======================================================================
433void Prs3d_Drawer::SetDimensionAspect (const Handle(Prs3d_DimensionAspect)& theAspect)
434{
435 myDimensionAspect = theAspect;
436}
437
438// =======================================================================
439// function : SetDimLengthModelUnits
440// purpose :
441// =======================================================================
442void Prs3d_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
443{
444 myDimensionModelUnits.SetLengthUnits (theUnits);
445}
446
447// =======================================================================
448// function : SetDimAngleModelUnits
449// purpose :
450// =======================================================================
451void Prs3d_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
452{
453 myDimensionModelUnits.SetAngleUnits (theUnits);
454}
455
456// =======================================================================
457// function : DimLengthModelUnits
458// purpose :
459// =======================================================================
460const TCollection_AsciiString& Prs3d_Drawer::DimLengthModelUnits() const
461{
462 return myDimensionModelUnits.GetLengthUnits();
463}
464
465// =======================================================================
466// function : DimAngleModelUnits
467// purpose :
468// =======================================================================
469const TCollection_AsciiString& Prs3d_Drawer::DimAngleModelUnits() const
470{
471 return myDimensionModelUnits.GetAngleUnits();
472}
473
474// =======================================================================
475// function : SetDimLengthDisplayUnits
476// purpose :
477// =======================================================================
478void Prs3d_Drawer::SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits)
479{
480 myDimensionDisplayUnits.SetLengthUnits (theUnits);
481}
482
483// =======================================================================
484// function : SetDimAngleDisplayUnits
485// purpose :
486// =======================================================================
487void Prs3d_Drawer::SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits)
488{
489 myDimensionDisplayUnits.SetAngleUnits (theUnits);
490}
491
492// =======================================================================
493// function : DimLengthDisplayUnits
494// purpose :
495// =======================================================================
496const TCollection_AsciiString& Prs3d_Drawer::DimLengthDisplayUnits() const
a6eb515f 497{
60bf98ae 498 return myDimensionDisplayUnits.GetLengthUnits();
7fd59977 499}
500
60bf98ae 501// =======================================================================
502// function : DimAngleDisplayUnits
503// purpose :
504// =======================================================================
505const TCollection_AsciiString& Prs3d_Drawer::DimAngleDisplayUnits() const
506{
507 return myDimensionDisplayUnits.GetAngleUnits();
508}
7fd59977 509
60bf98ae 510// =======================================================================
511// function : SectionAspect
512// purpose :
513// =======================================================================
514Handle (Prs3d_LineAspect) Prs3d_Drawer::SectionAspect()
515{
7fd59977 516 if (mySectionAspect.IsNull())
60bf98ae 517 {
518 mySectionAspect = new Prs3d_LineAspect (Quantity_NOC_ORANGE, Aspect_TOL_SOLID, 1.0);
519 }
7fd59977 520
521 return mySectionAspect;
522}
523
60bf98ae 524// =======================================================================
525// function : SetSectionAspect
526// purpose :
527// =======================================================================
528void Prs3d_Drawer::SetSectionAspect (const Handle(Prs3d_LineAspect)& theAspect)
529{
530 mySectionAspect = theAspect;
7fd59977 531}
a2d5ab2e 532
533// =======================================================================
534// function : SetFaceBoundaryDraw
535// purpose :
536// =======================================================================
537void Prs3d_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
538{
539 myFaceBoundaryDraw = theIsEnabled;
540}
541
542// =======================================================================
543// function : IsFaceBoundaryDraw
544// purpose :
545// =======================================================================
546Standard_Boolean Prs3d_Drawer::IsFaceBoundaryDraw () const
547{
548 return myFaceBoundaryDraw;
549}
550
551// =======================================================================
552// function : SetFaceBoundaryAspect
553// purpose :
554// =======================================================================
555void Prs3d_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
556{
557 myFaceBoundaryAspect = theAspect;
558}
559
560// =======================================================================
561// function : FaceBoundaryAspect
562// purpose :
563// =======================================================================
857ffd5e 564Handle(Prs3d_LineAspect) Prs3d_Drawer::FaceBoundaryAspect ()
a2d5ab2e 565{
566 if (myFaceBoundaryAspect.IsNull ())
567 {
568 myFaceBoundaryAspect =
569 new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0);
570 }
571
572 return myFaceBoundaryAspect;
573}
0a768f56 574
575// =======================================================================
576// function : SetTypeOfHLR
577// purpose : set type of HLR algorithm
578// =======================================================================
0a768f56 579void Prs3d_Drawer::SetTypeOfHLR ( const Prs3d_TypeOfHLR theTypeOfHLR)
580{
581 myTypeOfHLR = theTypeOfHLR;
582}
583
584// =======================================================================
585// function : TypeOfHLR
586// purpose : gets type of HLR algorithm
587// =======================================================================
0a768f56 588Prs3d_TypeOfHLR Prs3d_Drawer::TypeOfHLR ( ) const
589{
590 return myTypeOfHLR;
591}