0025853: Edges disappear or reappear when displaying new edges
[occt.git] / src / AIS / AIS_Drawer.cxx
CommitLineData
b311480e 1// Copyright (c) 1998-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 <AIS_Drawer.ixx>
16#include <Standard_ProgramError.hxx>
17
60bf98ae 18// =======================================================================
19// function : AIS_Drawer
20// purpose :
21// =======================================================================
22AIS_Drawer::AIS_Drawer()
23: myLink (new Prs3d_Drawer()),
24 hasLocalAttributes (Standard_False),
25 myhasOwnDeviationCoefficient (Standard_False),
26 myPreviousDeviationCoefficient (0.1),
27 myhasOwnHLRDeviationCoefficient (Standard_False),
28 myhasOwnDeviationAngle (Standard_False),
29 myhasOwnHLRDeviationAngle (Standard_False),
1c9d1517 30 myHasOwnFaceBoundaryDraw (Standard_False),
31 myHasOwnDimLengthModelUnits (Standard_False),
32 myHasOwnDimLengthDisplayUnits (Standard_False),
33 myHasOwnDimAngleModelUnits (Standard_False),
34 myHasOwnDimAngleDisplayUnits (Standard_False)
7fd59977 35{
60bf98ae 36 SetMaximalParameterValue (500000.0);
37 myLink->SetMaximalParameterValue (500000.0);
0a768f56 38 SetTypeOfHLR (Prs3d_TOH_NotSet);
53b15292 39 SetVertexDrawMode (Prs3d_VDM_Inherited);
60bf98ae 40}
7fd59977 41
42Aspect_TypeOfDeflection AIS_Drawer::TypeOfDeflection () const
43{
44 return myLink->TypeOfDeflection();
45}
46
47Standard_Boolean AIS_Drawer::IsoOnPlane() const
48{
49 return myLink->IsoOnPlane();
50}
51
52Standard_Integer AIS_Drawer::Discretisation() const
53{
54 return myLink->Discretisation();
55}
56
57Quantity_Length AIS_Drawer::MaximalChordialDeviation() const
58{
59 return myLink->MaximalChordialDeviation();
60}
61
62
63//=======================================================================
64//function : SetDeviationCoefficient
65//purpose :
66//=======================================================================
67
68void AIS_Drawer::SetDeviationCoefficient ( const Standard_Real aCoefficient )
69{
70 myPreviousDeviationCoefficient = DeviationCoefficient() ;
71 myOwnDeviationCoefficient = aCoefficient ;
72 myhasOwnDeviationCoefficient = Standard_True;
73}
74
75
76//=======================================================================
77//function : SetHLRDeviationCoefficient
78//purpose :
79//=======================================================================
80
81void AIS_Drawer::SetHLRDeviationCoefficient ( const Standard_Real aCoefficient )
82{
83 myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient() ;
84 myOwnHLRDeviationCoefficient = aCoefficient ;
85 myhasOwnHLRDeviationCoefficient = Standard_True;
86}
87
88//=======================================================================
89//function : SetDeviationAngle
90//purpose :
91//=======================================================================
92
93void AIS_Drawer::SetDeviationAngle ( const Standard_Real anAngle )
94{
95 myPreviousDeviationAngle = DeviationAngle() ;
96 myOwnDeviationAngle = anAngle ;
97 myhasOwnDeviationAngle = Standard_True;
98}
99
100//=======================================================================
101//function : SetHLRAngle
102//purpose :
103//=======================================================================
104
105void AIS_Drawer::SetHLRAngle ( const Standard_Real anAngle )
106{
107 myPreviousHLRDeviationAngle = HLRAngle() ;
108 myOwnHLRDeviationAngle = anAngle ;
109 myhasOwnHLRDeviationAngle = Standard_True;
110}
111
7fd59977 112/////// Get
113//=======================================================================
114//function : DeviationCoefficient
115//purpose :
116//=======================================================================
117
118Standard_Real AIS_Drawer::DeviationCoefficient () const
119{
120 return myhasOwnDeviationCoefficient? myOwnDeviationCoefficient :myLink->DeviationCoefficient();
121}
122
123//=======================================================================
124//function : HLRDeviationCoefficient
125//purpose :
126//=======================================================================
127
128Standard_Real AIS_Drawer::HLRDeviationCoefficient () const
129{
130 return myhasOwnHLRDeviationCoefficient?myOwnHLRDeviationCoefficient : myLink->HLRDeviationCoefficient() ;
131}
132
133//=======================================================================
134//function : DeviationAngle
135//purpose :
136//=======================================================================
137
138Standard_Real AIS_Drawer::DeviationAngle () const
139{
140 return myhasOwnDeviationAngle ? myOwnDeviationAngle : myLink->DeviationAngle();
141}
142
143//=======================================================================
144//function : HLRAngle
145//purpose :
146//=======================================================================
147
148Standard_Real AIS_Drawer::HLRAngle () const
149{
150
151 return myhasOwnHLRDeviationAngle ? myOwnHLRDeviationAngle : myLink->HLRAngle();
152}
153
154Standard_Real AIS_Drawer::MaximalParameterValue () const
155{ return myLink->MaximalParameterValue();}
156
157Handle (Prs3d_IsoAspect) AIS_Drawer::UIsoAspect ()
158{ return myUIsoAspect.IsNull() ? myLink->UIsoAspect (): myUIsoAspect;}
159
160Handle (Prs3d_IsoAspect) AIS_Drawer::VIsoAspect ()
161{ return myVIsoAspect.IsNull() ? myLink->VIsoAspect (): myVIsoAspect;}
162
163Handle (Prs3d_LineAspect) AIS_Drawer::FreeBoundaryAspect ()
164{return myFreeBoundaryAspect.IsNull() ? myLink->FreeBoundaryAspect (): myFreeBoundaryAspect;}
165
166Standard_Boolean AIS_Drawer::FreeBoundaryDraw () const
167{return myLink->FreeBoundaryDraw();}
168
169Handle (Prs3d_LineAspect) AIS_Drawer::UnFreeBoundaryAspect ()
170{return myUnFreeBoundaryAspect.IsNull() ? myLink->UnFreeBoundaryAspect (): myUnFreeBoundaryAspect;}
171
172Standard_Boolean AIS_Drawer::UnFreeBoundaryDraw () const
173{return myLink->UnFreeBoundaryDraw ();}
174
175Handle (Prs3d_LineAspect) AIS_Drawer::WireAspect ()
176{ return myWireAspect.IsNull()? myLink->WireAspect (): myWireAspect;}
177
178Standard_Boolean AIS_Drawer::WireDraw () const
179{ return myLink->WireDraw();}
180
181Handle (Prs3d_LineAspect) AIS_Drawer::LineAspect ()
182{ return myLineAspect.IsNull() ? myLink->LineAspect (): myLineAspect;}
183
184Handle (Prs3d_TextAspect) AIS_Drawer::TextAspect ()
185{ return myTextAspect.IsNull() ? myLink->TextAspect () : myTextAspect ;}
186
187Handle (Prs3d_ShadingAspect) AIS_Drawer::ShadingAspect ()
188{
189return myShadingAspect.IsNull() ? myLink->ShadingAspect () : myShadingAspect ;
190}
191
192Standard_Boolean AIS_Drawer::ShadingAspectGlobal() const
193{ return myLink->ShadingAspectGlobal();}
194
195
196Standard_Boolean AIS_Drawer::LineArrowDraw () const
197{ return myLink->LineArrowDraw();}
198
199Handle (Prs3d_ArrowAspect) AIS_Drawer::ArrowAspect()
200{return myArrowAspect.IsNull()? myLink->ArrowAspect () : myArrowAspect;}
201
202Handle (Prs3d_PointAspect) AIS_Drawer::PointAspect()
203{return myPointAspect.IsNull()? myLink->PointAspect () : myPointAspect;}
204
53b15292 205void AIS_Drawer::SetVertexDrawMode (const Prs3d_VertexDrawMode theMode)
206{
207 // Assuming that myLink always exists --> Prs3d_VDM_Inherited value is acceptable.
208 // So we simply store the new mode, as opposed to Prs3d_Drawer::SetVertexDrawMode()
209 myVertexDrawMode = theMode;
210}
211
212Prs3d_VertexDrawMode AIS_Drawer::VertexDrawMode () const
213{
214 return IsOwnVertexDrawMode() ? myVertexDrawMode : myLink->VertexDrawMode();
215}
216
7fd59977 217Standard_Boolean AIS_Drawer::DrawHiddenLine () const
218{return myLink->DrawHiddenLine();}
219
220Handle (Prs3d_LineAspect) AIS_Drawer::HiddenLineAspect ()
221{return myHiddenLineAspect.IsNull()? myLink->HiddenLineAspect () : myHiddenLineAspect;}
222
223Handle (Prs3d_LineAspect) AIS_Drawer::SeenLineAspect ()
224{ return mySeenLineAspect.IsNull() ? myLink->SeenLineAspect (): mySeenLineAspect ;}
225
226Handle (Prs3d_LineAspect) AIS_Drawer::VectorAspect ()
227{return myVectorAspect.IsNull()? myLink->VectorAspect () : myVectorAspect;}
228
229Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect ()
230{return myDatumAspect.IsNull()? myLink->DatumAspect () : myDatumAspect; }
231
232Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect ()
233{return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;}
234
60bf98ae 235// =======================================================================
236// function : DimensionAspect
237// purpose :
238// =======================================================================
239Handle (Prs3d_DimensionAspect) AIS_Drawer::DimensionAspect()
240{
241 return myDimensionAspect.IsNull()? myLink->DimensionAspect () : myDimensionAspect;
242}
243
244// =======================================================================
245// function : DimAngleModelUnits
246// purpose :
247// =======================================================================
248const TCollection_AsciiString& AIS_Drawer::DimAngleModelUnits() const
249{
250 return myHasOwnDimAngleModelUnits
251 ? Prs3d_Drawer::DimAngleModelUnits()
252 : myLink->DimAngleModelUnits();
253}
254
255// =======================================================================
256// function : DimensionModelUnits
257// purpose :
258// =======================================================================
259const TCollection_AsciiString& AIS_Drawer::DimLengthModelUnits() const
260{
261 return myHasOwnDimLengthModelUnits
262 ? Prs3d_Drawer::DimLengthModelUnits()
263 : myLink->DimLengthModelUnits();
264}
265// =======================================================================
266// function : SetDimLengthModelUnits
267// purpose :
268// =======================================================================
269void AIS_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
270{
271 myHasOwnDimLengthModelUnits = Standard_True;
1c9d1517 272 Prs3d_Drawer::SetDimLengthModelUnits (theUnits);
60bf98ae 273}
274
275// =======================================================================
276// function : SetDimAngleModelUnits
277// purpose :
278// =======================================================================
279void AIS_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
280{
281 myHasOwnDimAngleModelUnits = Standard_True;
1c9d1517 282 Prs3d_Drawer::SetDimAngleModelUnits (theUnits);
60bf98ae 283}
284
285// =======================================================================
286// function : DimAngleDisplayUnits
287// purpose :
288// =======================================================================
289const TCollection_AsciiString& AIS_Drawer::DimAngleDisplayUnits() const
290{
291 return myHasOwnDimAngleDisplayUnits
292 ? Prs3d_Drawer::DimAngleDisplayUnits()
293 : myLink->DimAngleDisplayUnits();
294}
295
296// =======================================================================
297// function : DimLengthDisplayUnits
298// purpose :
299// =======================================================================
300const TCollection_AsciiString& AIS_Drawer::DimLengthDisplayUnits() const
301{
302 return myHasOwnDimLengthDisplayUnits
303 ? Prs3d_Drawer::DimLengthDisplayUnits()
304 : myLink->DimLengthDisplayUnits();
305}
306
307// =======================================================================
308// function : SetDimLengthDisplayUnits
309// purpose :
310// =======================================================================
311void AIS_Drawer::SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits)
312{
313 myHasOwnDimLengthDisplayUnits = Standard_True;
314 Prs3d_Drawer::SetDimLengthDisplayUnits (theUnits);
315}
316
317// =======================================================================
318// function : SetDimAngleDisplayUnits
319// purpose :
320// =======================================================================
321void AIS_Drawer::SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits)
322{
323 myHasOwnDimAngleDisplayUnits = Standard_True;
324 Prs3d_Drawer::SetDimAngleDisplayUnits (theUnits);
325}
7fd59977 326
327Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect ()
328{return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;}
329
330const Handle (Prs3d_Drawer)& AIS_Drawer::Link()
331{
332 if(myLink.IsNull()) myLink = new Prs3d_Drawer();
333 return myLink;
334 }
335
336void AIS_Drawer::ClearLocalAttributes()
337{
338 if(myLink.IsNull()) return;
339// attention pas beau....
340// The Handles
341
342 if(!myUIsoAspect.IsNull()) myUIsoAspect.Nullify();
343 if(!myVIsoAspect.IsNull()) myVIsoAspect.Nullify();
344 if(!myFreeBoundaryAspect.IsNull()) myFreeBoundaryAspect.Nullify();
345 if(!myUnFreeBoundaryAspect.IsNull()) myUnFreeBoundaryAspect.Nullify();
346 if(!myWireAspect.IsNull()) myWireAspect.Nullify();
347 if(!myLineAspect.IsNull()) myLineAspect.Nullify();
348 if(!myTextAspect.IsNull()) myTextAspect.Nullify();
349 if(!myShadingAspect.IsNull()) myShadingAspect.Nullify();
350 if(!myPointAspect.IsNull()) myPointAspect.Nullify();
351 if(!myPlaneAspect.IsNull()) myPlaneAspect.Nullify();
352 if(!myArrowAspect.IsNull()) myArrowAspect.Nullify();
353 if(!myHiddenLineAspect.IsNull()) myHiddenLineAspect.Nullify();
354 if(!mySeenLineAspect.IsNull()) mySeenLineAspect.Nullify();
355 if(!myVectorAspect.IsNull()) myVectorAspect .Nullify();
356 if(!myDatumAspect.IsNull()) myDatumAspect.Nullify();
a6eb515f 357 if(!myDimensionAspect.IsNull()) myDimensionAspect.Nullify();
7fd59977 358 if(!mySectionAspect.IsNull()) mySectionAspect.Nullify();
359 if( myhasOwnHLRDeviationCoefficient ) myhasOwnHLRDeviationCoefficient = Standard_False;
a2d5ab2e 360 if(myhasOwnHLRDeviationAngle ) myhasOwnHLRDeviationAngle = Standard_False;
361 if (!myFaceBoundaryAspect.IsNull()) myFaceBoundaryAspect.Nullify();
7fd59977 362
a2d5ab2e 363 myHasOwnFaceBoundaryDraw = Standard_False;
60bf98ae 364 myHasOwnDimLengthModelUnits = Standard_False;
365 myHasOwnDimLengthDisplayUnits = Standard_False;
366 myHasOwnDimAngleModelUnits = Standard_False;
367 myHasOwnDimAngleDisplayUnits = Standard_False;
a2d5ab2e 368
7fd59977 369 hasLocalAttributes = Standard_False;
370
371}
372
a2d5ab2e 373// =======================================================================
374// function : SetFaceBoundaryDraw
375// purpose :
376// =======================================================================
377void AIS_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
378{
379 myHasOwnFaceBoundaryDraw = Standard_True;
380 myFaceBoundaryDraw = theIsEnabled;
381}
382
383// =======================================================================
384// function : IsFaceBoundaryDraw
385// purpose :
386// =======================================================================
387Standard_Boolean AIS_Drawer::IsFaceBoundaryDraw() const
388{
389 if (!IsOwnFaceBoundaryDraw ())
390 {
391 return myLink->IsFaceBoundaryDraw ();
392 }
393
394 return myFaceBoundaryDraw;
395}
7fd59977 396
a2d5ab2e 397// =======================================================================
398// function : SetFaceBoundaryAspect
399// purpose :
400// =======================================================================
401void AIS_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
402{
403 myFaceBoundaryAspect = theAspect;
404}
405
406// =======================================================================
407// function : FaceBoundaryAspect
408// purpose :
409// =======================================================================
857ffd5e 410Handle(Prs3d_LineAspect) AIS_Drawer::FaceBoundaryAspect()
a2d5ab2e 411{
412 if (!IsOwnFaceBoundaryAspect ())
413 {
414 return myLink->FaceBoundaryAspect ();
415 }
416
417 return myFaceBoundaryAspect;
418}