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