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 under
7 // the terms of the GNU Lesser General Public License 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),
31 myHasOwnDimLengthModelUnits (Standard_False),
32 myHasOwnDimLengthDisplayUnits (Standard_False),
33 myHasOwnDimAngleModelUnits (Standard_False),
34 myHasOwnDimAngleDisplayUnits (Standard_False)
36 SetMaximalParameterValue (500000.0);
37 myLink->SetMaximalParameterValue (500000.0);
38 SetTypeOfHLR (Prs3d_TOH_NotSet);
39 SetVertexDrawMode (Prs3d_VDM_Inherited);
42 Aspect_TypeOfDeflection AIS_Drawer::TypeOfDeflection () const
44 return myLink->TypeOfDeflection();
47 Standard_Boolean AIS_Drawer::IsoOnPlane() const
49 return myLink->IsoOnPlane();
52 Standard_Integer AIS_Drawer::Discretisation() const
54 return myLink->Discretisation();
57 Quantity_Length AIS_Drawer::MaximalChordialDeviation() const
59 return myLink->MaximalChordialDeviation();
63 //=======================================================================
64 //function : SetDeviationCoefficient
66 //=======================================================================
68 void AIS_Drawer::SetDeviationCoefficient ( const Standard_Real aCoefficient )
70 myPreviousDeviationCoefficient = DeviationCoefficient() ;
71 myOwnDeviationCoefficient = aCoefficient ;
72 myhasOwnDeviationCoefficient = Standard_True;
76 //=======================================================================
77 //function : SetHLRDeviationCoefficient
79 //=======================================================================
81 void AIS_Drawer::SetHLRDeviationCoefficient ( const Standard_Real aCoefficient )
83 myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient() ;
84 myOwnHLRDeviationCoefficient = aCoefficient ;
85 myhasOwnHLRDeviationCoefficient = Standard_True;
88 //=======================================================================
89 //function : SetDeviationAngle
91 //=======================================================================
93 void AIS_Drawer::SetDeviationAngle ( const Standard_Real anAngle )
95 myPreviousDeviationAngle = DeviationAngle() ;
96 myOwnDeviationAngle = anAngle ;
97 myhasOwnDeviationAngle = Standard_True;
100 //=======================================================================
101 //function : SetHLRAngle
103 //=======================================================================
105 void AIS_Drawer::SetHLRAngle ( const Standard_Real anAngle )
107 myPreviousHLRDeviationAngle = HLRAngle() ;
108 myOwnHLRDeviationAngle = anAngle ;
109 myhasOwnHLRDeviationAngle = Standard_True;
113 //=======================================================================
114 //function : DeviationCoefficient
116 //=======================================================================
118 Standard_Real AIS_Drawer::DeviationCoefficient () const
120 return myhasOwnDeviationCoefficient? myOwnDeviationCoefficient :myLink->DeviationCoefficient();
123 //=======================================================================
124 //function : HLRDeviationCoefficient
126 //=======================================================================
128 Standard_Real AIS_Drawer::HLRDeviationCoefficient () const
130 return myhasOwnHLRDeviationCoefficient?myOwnHLRDeviationCoefficient : myLink->HLRDeviationCoefficient() ;
133 //=======================================================================
134 //function : DeviationAngle
136 //=======================================================================
138 Standard_Real AIS_Drawer::DeviationAngle () const
140 return myhasOwnDeviationAngle ? myOwnDeviationAngle : myLink->DeviationAngle();
143 //=======================================================================
144 //function : HLRAngle
146 //=======================================================================
148 Standard_Real AIS_Drawer::HLRAngle () const
151 return myhasOwnHLRDeviationAngle ? myOwnHLRDeviationAngle : myLink->HLRAngle();
154 Standard_Real AIS_Drawer::MaximalParameterValue () const
155 { return myLink->MaximalParameterValue();}
157 Handle (Prs3d_IsoAspect) AIS_Drawer::UIsoAspect ()
158 { return myUIsoAspect.IsNull() ? myLink->UIsoAspect (): myUIsoAspect;}
160 Handle (Prs3d_IsoAspect) AIS_Drawer::VIsoAspect ()
161 { return myVIsoAspect.IsNull() ? myLink->VIsoAspect (): myVIsoAspect;}
163 Handle (Prs3d_LineAspect) AIS_Drawer::FreeBoundaryAspect ()
164 {return myFreeBoundaryAspect.IsNull() ? myLink->FreeBoundaryAspect (): myFreeBoundaryAspect;}
166 Standard_Boolean AIS_Drawer::FreeBoundaryDraw () const
167 {return myLink->FreeBoundaryDraw();}
169 Handle (Prs3d_LineAspect) AIS_Drawer::UnFreeBoundaryAspect ()
170 {return myUnFreeBoundaryAspect.IsNull() ? myLink->UnFreeBoundaryAspect (): myUnFreeBoundaryAspect;}
172 Standard_Boolean AIS_Drawer::UnFreeBoundaryDraw () const
173 {return myLink->UnFreeBoundaryDraw ();}
175 Handle (Prs3d_LineAspect) AIS_Drawer::WireAspect ()
176 { return myWireAspect.IsNull()? myLink->WireAspect (): myWireAspect;}
178 Standard_Boolean AIS_Drawer::WireDraw () const
179 { return myLink->WireDraw();}
181 Handle (Prs3d_LineAspect) AIS_Drawer::LineAspect ()
182 { return myLineAspect.IsNull() ? myLink->LineAspect (): myLineAspect;}
184 Handle (Prs3d_TextAspect) AIS_Drawer::TextAspect ()
185 { return myTextAspect.IsNull() ? myLink->TextAspect () : myTextAspect ;}
187 Handle (Prs3d_ShadingAspect) AIS_Drawer::ShadingAspect ()
189 return myShadingAspect.IsNull() ? myLink->ShadingAspect () : myShadingAspect ;
192 Standard_Boolean AIS_Drawer::ShadingAspectGlobal() const
193 { return myLink->ShadingAspectGlobal();}
196 Standard_Boolean AIS_Drawer::LineArrowDraw () const
197 { return myLink->LineArrowDraw();}
199 Handle (Prs3d_ArrowAspect) AIS_Drawer::ArrowAspect()
200 {return myArrowAspect.IsNull()? myLink->ArrowAspect () : myArrowAspect;}
202 Handle (Prs3d_PointAspect) AIS_Drawer::PointAspect()
203 {return myPointAspect.IsNull()? myLink->PointAspect () : myPointAspect;}
205 void AIS_Drawer::SetVertexDrawMode (const Prs3d_VertexDrawMode theMode)
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;
212 Prs3d_VertexDrawMode AIS_Drawer::VertexDrawMode () const
214 return IsOwnVertexDrawMode() ? myVertexDrawMode : myLink->VertexDrawMode();
217 Standard_Boolean AIS_Drawer::DrawHiddenLine () const
218 {return myLink->DrawHiddenLine();}
220 Handle (Prs3d_LineAspect) AIS_Drawer::HiddenLineAspect ()
221 {return myHiddenLineAspect.IsNull()? myLink->HiddenLineAspect () : myHiddenLineAspect;}
223 Handle (Prs3d_LineAspect) AIS_Drawer::SeenLineAspect ()
224 { return mySeenLineAspect.IsNull() ? myLink->SeenLineAspect (): mySeenLineAspect ;}
226 Handle (Prs3d_LineAspect) AIS_Drawer::VectorAspect ()
227 {return myVectorAspect.IsNull()? myLink->VectorAspect () : myVectorAspect;}
229 Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect ()
230 {return myDatumAspect.IsNull()? myLink->DatumAspect () : myDatumAspect; }
232 Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect ()
233 {return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;}
235 // =======================================================================
236 // function : DimensionAspect
238 // =======================================================================
239 Handle (Prs3d_DimensionAspect) AIS_Drawer::DimensionAspect()
241 return myDimensionAspect.IsNull()? myLink->DimensionAspect () : myDimensionAspect;
244 // =======================================================================
245 // function : DimAngleModelUnits
247 // =======================================================================
248 const TCollection_AsciiString& AIS_Drawer::DimAngleModelUnits() const
250 return myHasOwnDimAngleModelUnits
251 ? Prs3d_Drawer::DimAngleModelUnits()
252 : myLink->DimAngleModelUnits();
255 // =======================================================================
256 // function : DimensionModelUnits
258 // =======================================================================
259 const TCollection_AsciiString& AIS_Drawer::DimLengthModelUnits() const
261 return myHasOwnDimLengthModelUnits
262 ? Prs3d_Drawer::DimLengthModelUnits()
263 : myLink->DimLengthModelUnits();
265 // =======================================================================
266 // function : SetDimLengthModelUnits
268 // =======================================================================
269 void AIS_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
271 myHasOwnDimLengthModelUnits = Standard_True;
272 Prs3d_Drawer::SetDimLengthModelUnits (theUnits);
275 // =======================================================================
276 // function : SetDimAngleModelUnits
278 // =======================================================================
279 void AIS_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
281 myHasOwnDimAngleModelUnits = Standard_True;
282 Prs3d_Drawer::SetDimAngleModelUnits (theUnits);
285 // =======================================================================
286 // function : DimAngleDisplayUnits
288 // =======================================================================
289 const TCollection_AsciiString& AIS_Drawer::DimAngleDisplayUnits() const
291 return myHasOwnDimAngleDisplayUnits
292 ? Prs3d_Drawer::DimAngleDisplayUnits()
293 : myLink->DimAngleDisplayUnits();
296 // =======================================================================
297 // function : DimLengthDisplayUnits
299 // =======================================================================
300 const TCollection_AsciiString& AIS_Drawer::DimLengthDisplayUnits() const
302 return myHasOwnDimLengthDisplayUnits
303 ? Prs3d_Drawer::DimLengthDisplayUnits()
304 : myLink->DimLengthDisplayUnits();
307 // =======================================================================
308 // function : SetDimLengthDisplayUnits
310 // =======================================================================
311 void AIS_Drawer::SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits)
313 myHasOwnDimLengthDisplayUnits = Standard_True;
314 Prs3d_Drawer::SetDimLengthDisplayUnits (theUnits);
317 // =======================================================================
318 // function : SetDimAngleDisplayUnits
320 // =======================================================================
321 void AIS_Drawer::SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits)
323 myHasOwnDimAngleDisplayUnits = Standard_True;
324 Prs3d_Drawer::SetDimAngleDisplayUnits (theUnits);
327 Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect ()
328 {return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;}
330 const Handle (Prs3d_Drawer)& AIS_Drawer::Link()
332 if(myLink.IsNull()) myLink = new Prs3d_Drawer();
336 void AIS_Drawer::ClearLocalAttributes()
338 if(myLink.IsNull()) return;
339 // attention pas beau....
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();
357 if(!myDimensionAspect.IsNull()) myDimensionAspect.Nullify();
358 if(!mySectionAspect.IsNull()) mySectionAspect.Nullify();
359 if( myhasOwnHLRDeviationCoefficient ) myhasOwnHLRDeviationCoefficient = Standard_False;
360 if(myhasOwnHLRDeviationAngle ) myhasOwnHLRDeviationAngle = Standard_False;
361 if (!myFaceBoundaryAspect.IsNull()) myFaceBoundaryAspect.Nullify();
363 myHasOwnFaceBoundaryDraw = Standard_False;
364 myHasOwnDimLengthModelUnits = Standard_False;
365 myHasOwnDimLengthDisplayUnits = Standard_False;
366 myHasOwnDimAngleModelUnits = Standard_False;
367 myHasOwnDimAngleDisplayUnits = Standard_False;
369 hasLocalAttributes = Standard_False;
373 // =======================================================================
374 // function : SetFaceBoundaryDraw
376 // =======================================================================
377 void AIS_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
379 myHasOwnFaceBoundaryDraw = Standard_True;
380 myFaceBoundaryDraw = theIsEnabled;
383 // =======================================================================
384 // function : IsFaceBoundaryDraw
386 // =======================================================================
387 Standard_Boolean AIS_Drawer::IsFaceBoundaryDraw() const
389 if (!IsOwnFaceBoundaryDraw ())
391 return myLink->IsFaceBoundaryDraw ();
394 return myFaceBoundaryDraw;
397 // =======================================================================
398 // function : SetFaceBoundaryAspect
400 // =======================================================================
401 void AIS_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
403 myFaceBoundaryAspect = theAspect;
406 // =======================================================================
407 // function : FaceBoundaryAspect
409 // =======================================================================
410 Handle(Prs3d_LineAspect) AIS_Drawer::FaceBoundaryAspect()
412 if (!IsOwnFaceBoundaryAspect ())
414 return myLink->FaceBoundaryAspect ();
417 return myFaceBoundaryAspect;