1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 #include <AIS_Drawer.ixx>
16 #include <Standard_ProgramError.hxx>
18 // =======================================================================
19 // function : AIS_Drawer
21 // =======================================================================
22 AIS_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)
32 SetMaximalParameterValue (500000.0);
33 myLink->SetMaximalParameterValue (500000.0);
34 SetTypeOfHLR (Prs3d_TOH_NotSet);
37 Aspect_TypeOfDeflection AIS_Drawer::TypeOfDeflection () const
39 return myLink->TypeOfDeflection();
42 Standard_Boolean AIS_Drawer::IsoOnPlane() const
44 return myLink->IsoOnPlane();
47 Standard_Integer AIS_Drawer::Discretisation() const
49 return myLink->Discretisation();
52 Quantity_Length AIS_Drawer::MaximalChordialDeviation() const
54 return myLink->MaximalChordialDeviation();
58 //=======================================================================
59 //function : SetDeviationCoefficient
61 //=======================================================================
63 void AIS_Drawer::SetDeviationCoefficient ( const Standard_Real aCoefficient )
65 myPreviousDeviationCoefficient = DeviationCoefficient() ;
66 myOwnDeviationCoefficient = aCoefficient ;
67 myhasOwnDeviationCoefficient = Standard_True;
71 //=======================================================================
72 //function : SetHLRDeviationCoefficient
74 //=======================================================================
76 void AIS_Drawer::SetHLRDeviationCoefficient ( const Standard_Real aCoefficient )
78 myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient() ;
79 myOwnHLRDeviationCoefficient = aCoefficient ;
80 myhasOwnHLRDeviationCoefficient = Standard_True;
83 //=======================================================================
84 //function : SetDeviationAngle
86 //=======================================================================
88 void AIS_Drawer::SetDeviationAngle ( const Standard_Real anAngle )
90 myPreviousDeviationAngle = DeviationAngle() ;
91 myOwnDeviationAngle = anAngle ;
92 myhasOwnDeviationAngle = Standard_True;
95 //=======================================================================
96 //function : SetHLRAngle
98 //=======================================================================
100 void AIS_Drawer::SetHLRAngle ( const Standard_Real anAngle )
102 myPreviousHLRDeviationAngle = HLRAngle() ;
103 myOwnHLRDeviationAngle = anAngle ;
104 myhasOwnHLRDeviationAngle = Standard_True;
108 //=======================================================================
109 //function : DeviationCoefficient
111 //=======================================================================
113 Standard_Real AIS_Drawer::DeviationCoefficient () const
115 return myhasOwnDeviationCoefficient? myOwnDeviationCoefficient :myLink->DeviationCoefficient();
118 //=======================================================================
119 //function : HLRDeviationCoefficient
121 //=======================================================================
123 Standard_Real AIS_Drawer::HLRDeviationCoefficient () const
125 return myhasOwnHLRDeviationCoefficient?myOwnHLRDeviationCoefficient : myLink->HLRDeviationCoefficient() ;
128 //=======================================================================
129 //function : DeviationAngle
131 //=======================================================================
133 Standard_Real AIS_Drawer::DeviationAngle () const
135 return myhasOwnDeviationAngle ? myOwnDeviationAngle : myLink->DeviationAngle();
138 //=======================================================================
139 //function : HLRAngle
141 //=======================================================================
143 Standard_Real AIS_Drawer::HLRAngle () const
146 return myhasOwnHLRDeviationAngle ? myOwnHLRDeviationAngle : myLink->HLRAngle();
149 Standard_Real AIS_Drawer::MaximalParameterValue () const
150 { return myLink->MaximalParameterValue();}
152 Handle (Prs3d_IsoAspect) AIS_Drawer::UIsoAspect ()
153 { return myUIsoAspect.IsNull() ? myLink->UIsoAspect (): myUIsoAspect;}
155 Handle (Prs3d_IsoAspect) AIS_Drawer::VIsoAspect ()
156 { return myVIsoAspect.IsNull() ? myLink->VIsoAspect (): myVIsoAspect;}
158 Handle (Prs3d_LineAspect) AIS_Drawer::FreeBoundaryAspect ()
159 {return myFreeBoundaryAspect.IsNull() ? myLink->FreeBoundaryAspect (): myFreeBoundaryAspect;}
161 Standard_Boolean AIS_Drawer::FreeBoundaryDraw () const
162 {return myLink->FreeBoundaryDraw();}
164 Handle (Prs3d_LineAspect) AIS_Drawer::UnFreeBoundaryAspect ()
165 {return myUnFreeBoundaryAspect.IsNull() ? myLink->UnFreeBoundaryAspect (): myUnFreeBoundaryAspect;}
167 Standard_Boolean AIS_Drawer::UnFreeBoundaryDraw () const
168 {return myLink->UnFreeBoundaryDraw ();}
170 Handle (Prs3d_LineAspect) AIS_Drawer::WireAspect ()
171 { return myWireAspect.IsNull()? myLink->WireAspect (): myWireAspect;}
173 Standard_Boolean AIS_Drawer::WireDraw () const
174 { return myLink->WireDraw();}
176 Handle (Prs3d_LineAspect) AIS_Drawer::LineAspect ()
177 { return myLineAspect.IsNull() ? myLink->LineAspect (): myLineAspect;}
179 Handle (Prs3d_TextAspect) AIS_Drawer::TextAspect ()
180 { return myTextAspect.IsNull() ? myLink->TextAspect () : myTextAspect ;}
182 Handle (Prs3d_ShadingAspect) AIS_Drawer::ShadingAspect ()
184 return myShadingAspect.IsNull() ? myLink->ShadingAspect () : myShadingAspect ;
187 Standard_Boolean AIS_Drawer::ShadingAspectGlobal() const
188 { return myLink->ShadingAspectGlobal();}
191 Standard_Boolean AIS_Drawer::LineArrowDraw () const
192 { return myLink->LineArrowDraw();}
194 Handle (Prs3d_ArrowAspect) AIS_Drawer::ArrowAspect()
195 {return myArrowAspect.IsNull()? myLink->ArrowAspect () : myArrowAspect;}
197 Handle (Prs3d_PointAspect) AIS_Drawer::PointAspect()
198 {return myPointAspect.IsNull()? myLink->PointAspect () : myPointAspect;}
200 Standard_Boolean AIS_Drawer::DrawHiddenLine () const
201 {return myLink->DrawHiddenLine();}
203 Handle (Prs3d_LineAspect) AIS_Drawer::HiddenLineAspect ()
204 {return myHiddenLineAspect.IsNull()? myLink->HiddenLineAspect () : myHiddenLineAspect;}
206 Handle (Prs3d_LineAspect) AIS_Drawer::SeenLineAspect ()
207 { return mySeenLineAspect.IsNull() ? myLink->SeenLineAspect (): mySeenLineAspect ;}
209 Handle (Prs3d_LineAspect) AIS_Drawer::VectorAspect ()
210 {return myVectorAspect.IsNull()? myLink->VectorAspect () : myVectorAspect;}
212 Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect ()
213 {return myDatumAspect.IsNull()? myLink->DatumAspect () : myDatumAspect; }
215 Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect ()
216 {return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;}
218 // =======================================================================
219 // function : DimensionAspect
221 // =======================================================================
222 Handle (Prs3d_DimensionAspect) AIS_Drawer::DimensionAspect()
224 return myDimensionAspect.IsNull()? myLink->DimensionAspect () : myDimensionAspect;
227 // =======================================================================
228 // function : DimAngleModelUnits
230 // =======================================================================
231 const TCollection_AsciiString& AIS_Drawer::DimAngleModelUnits() const
233 return myHasOwnDimAngleModelUnits
234 ? Prs3d_Drawer::DimAngleModelUnits()
235 : myLink->DimAngleModelUnits();
238 // =======================================================================
239 // function : DimensionModelUnits
241 // =======================================================================
242 const TCollection_AsciiString& AIS_Drawer::DimLengthModelUnits() const
244 return myHasOwnDimLengthModelUnits
245 ? Prs3d_Drawer::DimLengthModelUnits()
246 : myLink->DimLengthModelUnits();
248 // =======================================================================
249 // function : SetDimLengthModelUnits
251 // =======================================================================
252 void AIS_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
254 myHasOwnDimLengthModelUnits = Standard_True;
255 Prs3d_Drawer::SetDimLengthDisplayUnits (theUnits);
258 // =======================================================================
259 // function : SetDimAngleModelUnits
261 // =======================================================================
262 void AIS_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
264 myHasOwnDimAngleModelUnits = Standard_True;
265 Prs3d_Drawer::SetDimAngleDisplayUnits (theUnits);
268 // =======================================================================
269 // function : DimAngleDisplayUnits
271 // =======================================================================
272 const TCollection_AsciiString& AIS_Drawer::DimAngleDisplayUnits() const
274 return myHasOwnDimAngleDisplayUnits
275 ? Prs3d_Drawer::DimAngleDisplayUnits()
276 : myLink->DimAngleDisplayUnits();
279 // =======================================================================
280 // function : DimLengthDisplayUnits
282 // =======================================================================
283 const TCollection_AsciiString& AIS_Drawer::DimLengthDisplayUnits() const
285 return myHasOwnDimLengthDisplayUnits
286 ? Prs3d_Drawer::DimLengthDisplayUnits()
287 : myLink->DimLengthDisplayUnits();
290 // =======================================================================
291 // function : SetDimLengthDisplayUnits
293 // =======================================================================
294 void AIS_Drawer::SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits)
296 myHasOwnDimLengthDisplayUnits = Standard_True;
297 Prs3d_Drawer::SetDimLengthDisplayUnits (theUnits);
300 // =======================================================================
301 // function : SetDimAngleDisplayUnits
303 // =======================================================================
304 void AIS_Drawer::SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits)
306 myHasOwnDimAngleDisplayUnits = Standard_True;
307 Prs3d_Drawer::SetDimAngleDisplayUnits (theUnits);
310 Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect ()
311 {return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;}
313 const Handle (Prs3d_Drawer)& AIS_Drawer::Link()
315 if(myLink.IsNull()) myLink = new Prs3d_Drawer();
319 void AIS_Drawer::ClearLocalAttributes()
321 if(myLink.IsNull()) return;
322 // attention pas beau....
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();
340 if(!myDimensionAspect.IsNull()) myDimensionAspect.Nullify();
341 if(!mySectionAspect.IsNull()) mySectionAspect.Nullify();
342 if( myhasOwnHLRDeviationCoefficient ) myhasOwnHLRDeviationCoefficient = Standard_False;
343 if(myhasOwnHLRDeviationAngle ) myhasOwnHLRDeviationAngle = Standard_False;
344 if (!myFaceBoundaryAspect.IsNull()) myFaceBoundaryAspect.Nullify();
346 myHasOwnFaceBoundaryDraw = Standard_False;
347 myHasOwnDimLengthModelUnits = Standard_False;
348 myHasOwnDimLengthDisplayUnits = Standard_False;
349 myHasOwnDimAngleModelUnits = Standard_False;
350 myHasOwnDimAngleDisplayUnits = Standard_False;
352 hasLocalAttributes = Standard_False;
356 // =======================================================================
357 // function : SetFaceBoundaryDraw
359 // =======================================================================
360 void AIS_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
362 myHasOwnFaceBoundaryDraw = Standard_True;
363 myFaceBoundaryDraw = theIsEnabled;
366 // =======================================================================
367 // function : IsFaceBoundaryDraw
369 // =======================================================================
370 Standard_Boolean AIS_Drawer::IsFaceBoundaryDraw() const
372 if (!IsOwnFaceBoundaryDraw ())
374 return myLink->IsFaceBoundaryDraw ();
377 return myFaceBoundaryDraw;
380 // =======================================================================
381 // function : SetFaceBoundaryAspect
383 // =======================================================================
384 void AIS_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
386 myFaceBoundaryAspect = theAspect;
389 // =======================================================================
390 // function : FaceBoundaryAspect
392 // =======================================================================
393 Handle_Prs3d_LineAspect AIS_Drawer::FaceBoundaryAspect()
395 if (!IsOwnFaceBoundaryAspect ())
397 return myLink->FaceBoundaryAspect ();
400 return myFaceBoundaryAspect;