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)
32 SetMaximalParameterValue (500000.0);
33 myLink->SetMaximalParameterValue (500000.0);
34 SetTypeOfHLR (Prs3d_TOH_NotSet);
35 SetVertexDrawMode (Prs3d_VDM_Inherited);
38 Aspect_TypeOfDeflection AIS_Drawer::TypeOfDeflection () const
40 return myLink->TypeOfDeflection();
43 Standard_Boolean AIS_Drawer::IsoOnPlane() const
45 return myLink->IsoOnPlane();
48 Standard_Integer AIS_Drawer::Discretisation() const
50 return myLink->Discretisation();
53 Quantity_Length AIS_Drawer::MaximalChordialDeviation() const
55 return myLink->MaximalChordialDeviation();
59 //=======================================================================
60 //function : SetDeviationCoefficient
62 //=======================================================================
64 void AIS_Drawer::SetDeviationCoefficient ( const Standard_Real aCoefficient )
66 myPreviousDeviationCoefficient = DeviationCoefficient() ;
67 myOwnDeviationCoefficient = aCoefficient ;
68 myhasOwnDeviationCoefficient = Standard_True;
72 //=======================================================================
73 //function : SetHLRDeviationCoefficient
75 //=======================================================================
77 void AIS_Drawer::SetHLRDeviationCoefficient ( const Standard_Real aCoefficient )
79 myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient() ;
80 myOwnHLRDeviationCoefficient = aCoefficient ;
81 myhasOwnHLRDeviationCoefficient = Standard_True;
84 //=======================================================================
85 //function : SetDeviationAngle
87 //=======================================================================
89 void AIS_Drawer::SetDeviationAngle ( const Standard_Real anAngle )
91 myPreviousDeviationAngle = DeviationAngle() ;
92 myOwnDeviationAngle = anAngle ;
93 myhasOwnDeviationAngle = Standard_True;
96 //=======================================================================
97 //function : SetHLRAngle
99 //=======================================================================
101 void AIS_Drawer::SetHLRAngle ( const Standard_Real anAngle )
103 myPreviousHLRDeviationAngle = HLRAngle() ;
104 myOwnHLRDeviationAngle = anAngle ;
105 myhasOwnHLRDeviationAngle = Standard_True;
109 //=======================================================================
110 //function : DeviationCoefficient
112 //=======================================================================
114 Standard_Real AIS_Drawer::DeviationCoefficient () const
116 return myhasOwnDeviationCoefficient? myOwnDeviationCoefficient :myLink->DeviationCoefficient();
119 //=======================================================================
120 //function : HLRDeviationCoefficient
122 //=======================================================================
124 Standard_Real AIS_Drawer::HLRDeviationCoefficient () const
126 return myhasOwnHLRDeviationCoefficient?myOwnHLRDeviationCoefficient : myLink->HLRDeviationCoefficient() ;
129 //=======================================================================
130 //function : DeviationAngle
132 //=======================================================================
134 Standard_Real AIS_Drawer::DeviationAngle () const
136 return myhasOwnDeviationAngle ? myOwnDeviationAngle : myLink->DeviationAngle();
139 //=======================================================================
140 //function : HLRAngle
142 //=======================================================================
144 Standard_Real AIS_Drawer::HLRAngle () const
147 return myhasOwnHLRDeviationAngle ? myOwnHLRDeviationAngle : myLink->HLRAngle();
150 Standard_Real AIS_Drawer::MaximalParameterValue () const
151 { return myLink->MaximalParameterValue();}
153 Handle (Prs3d_IsoAspect) AIS_Drawer::UIsoAspect ()
154 { return myUIsoAspect.IsNull() ? myLink->UIsoAspect (): myUIsoAspect;}
156 Handle (Prs3d_IsoAspect) AIS_Drawer::VIsoAspect ()
157 { return myVIsoAspect.IsNull() ? myLink->VIsoAspect (): myVIsoAspect;}
159 Handle (Prs3d_LineAspect) AIS_Drawer::FreeBoundaryAspect ()
160 {return myFreeBoundaryAspect.IsNull() ? myLink->FreeBoundaryAspect (): myFreeBoundaryAspect;}
162 Standard_Boolean AIS_Drawer::FreeBoundaryDraw () const
163 {return myLink->FreeBoundaryDraw();}
165 Handle (Prs3d_LineAspect) AIS_Drawer::UnFreeBoundaryAspect ()
166 {return myUnFreeBoundaryAspect.IsNull() ? myLink->UnFreeBoundaryAspect (): myUnFreeBoundaryAspect;}
168 Standard_Boolean AIS_Drawer::UnFreeBoundaryDraw () const
169 {return myLink->UnFreeBoundaryDraw ();}
171 Handle (Prs3d_LineAspect) AIS_Drawer::WireAspect ()
172 { return myWireAspect.IsNull()? myLink->WireAspect (): myWireAspect;}
174 Standard_Boolean AIS_Drawer::WireDraw () const
175 { return myLink->WireDraw();}
177 Handle (Prs3d_LineAspect) AIS_Drawer::LineAspect ()
178 { return myLineAspect.IsNull() ? myLink->LineAspect (): myLineAspect;}
180 Handle (Prs3d_TextAspect) AIS_Drawer::TextAspect ()
181 { return myTextAspect.IsNull() ? myLink->TextAspect () : myTextAspect ;}
183 Handle (Prs3d_ShadingAspect) AIS_Drawer::ShadingAspect ()
185 return myShadingAspect.IsNull() ? myLink->ShadingAspect () : myShadingAspect ;
188 Standard_Boolean AIS_Drawer::ShadingAspectGlobal() const
189 { return myLink->ShadingAspectGlobal();}
192 Standard_Boolean AIS_Drawer::LineArrowDraw () const
193 { return myLink->LineArrowDraw();}
195 Handle (Prs3d_ArrowAspect) AIS_Drawer::ArrowAspect()
196 {return myArrowAspect.IsNull()? myLink->ArrowAspect () : myArrowAspect;}
198 Handle (Prs3d_PointAspect) AIS_Drawer::PointAspect()
199 {return myPointAspect.IsNull()? myLink->PointAspect () : myPointAspect;}
201 void AIS_Drawer::SetVertexDrawMode (const Prs3d_VertexDrawMode theMode)
203 // Assuming that myLink always exists --> Prs3d_VDM_Inherited value is acceptable.
204 // So we simply store the new mode, as opposed to Prs3d_Drawer::SetVertexDrawMode()
205 myVertexDrawMode = theMode;
208 Prs3d_VertexDrawMode AIS_Drawer::VertexDrawMode () const
210 return IsOwnVertexDrawMode() ? myVertexDrawMode : myLink->VertexDrawMode();
213 Standard_Boolean AIS_Drawer::DrawHiddenLine () const
214 {return myLink->DrawHiddenLine();}
216 Handle (Prs3d_LineAspect) AIS_Drawer::HiddenLineAspect ()
217 {return myHiddenLineAspect.IsNull()? myLink->HiddenLineAspect () : myHiddenLineAspect;}
219 Handle (Prs3d_LineAspect) AIS_Drawer::SeenLineAspect ()
220 { return mySeenLineAspect.IsNull() ? myLink->SeenLineAspect (): mySeenLineAspect ;}
222 Handle (Prs3d_LineAspect) AIS_Drawer::VectorAspect ()
223 {return myVectorAspect.IsNull()? myLink->VectorAspect () : myVectorAspect;}
225 Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect ()
226 {return myDatumAspect.IsNull()? myLink->DatumAspect () : myDatumAspect; }
228 Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect ()
229 {return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;}
231 // =======================================================================
232 // function : DimensionAspect
234 // =======================================================================
235 Handle (Prs3d_DimensionAspect) AIS_Drawer::DimensionAspect()
237 return myDimensionAspect.IsNull()? myLink->DimensionAspect () : myDimensionAspect;
240 // =======================================================================
241 // function : DimAngleModelUnits
243 // =======================================================================
244 const TCollection_AsciiString& AIS_Drawer::DimAngleModelUnits() const
246 return myHasOwnDimAngleModelUnits
247 ? Prs3d_Drawer::DimAngleModelUnits()
248 : myLink->DimAngleModelUnits();
251 // =======================================================================
252 // function : DimensionModelUnits
254 // =======================================================================
255 const TCollection_AsciiString& AIS_Drawer::DimLengthModelUnits() const
257 return myHasOwnDimLengthModelUnits
258 ? Prs3d_Drawer::DimLengthModelUnits()
259 : myLink->DimLengthModelUnits();
261 // =======================================================================
262 // function : SetDimLengthModelUnits
264 // =======================================================================
265 void AIS_Drawer::SetDimLengthModelUnits (const TCollection_AsciiString& theUnits)
267 myHasOwnDimLengthModelUnits = Standard_True;
268 Prs3d_Drawer::SetDimLengthDisplayUnits (theUnits);
271 // =======================================================================
272 // function : SetDimAngleModelUnits
274 // =======================================================================
275 void AIS_Drawer::SetDimAngleModelUnits (const TCollection_AsciiString& theUnits)
277 myHasOwnDimAngleModelUnits = Standard_True;
278 Prs3d_Drawer::SetDimAngleDisplayUnits (theUnits);
281 // =======================================================================
282 // function : DimAngleDisplayUnits
284 // =======================================================================
285 const TCollection_AsciiString& AIS_Drawer::DimAngleDisplayUnits() const
287 return myHasOwnDimAngleDisplayUnits
288 ? Prs3d_Drawer::DimAngleDisplayUnits()
289 : myLink->DimAngleDisplayUnits();
292 // =======================================================================
293 // function : DimLengthDisplayUnits
295 // =======================================================================
296 const TCollection_AsciiString& AIS_Drawer::DimLengthDisplayUnits() const
298 return myHasOwnDimLengthDisplayUnits
299 ? Prs3d_Drawer::DimLengthDisplayUnits()
300 : myLink->DimLengthDisplayUnits();
303 // =======================================================================
304 // function : SetDimLengthDisplayUnits
306 // =======================================================================
307 void AIS_Drawer::SetDimLengthDisplayUnits (const TCollection_AsciiString& theUnits)
309 myHasOwnDimLengthDisplayUnits = Standard_True;
310 Prs3d_Drawer::SetDimLengthDisplayUnits (theUnits);
313 // =======================================================================
314 // function : SetDimAngleDisplayUnits
316 // =======================================================================
317 void AIS_Drawer::SetDimAngleDisplayUnits (const TCollection_AsciiString& theUnits)
319 myHasOwnDimAngleDisplayUnits = Standard_True;
320 Prs3d_Drawer::SetDimAngleDisplayUnits (theUnits);
323 Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect ()
324 {return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;}
326 const Handle (Prs3d_Drawer)& AIS_Drawer::Link()
328 if(myLink.IsNull()) myLink = new Prs3d_Drawer();
332 void AIS_Drawer::ClearLocalAttributes()
334 if(myLink.IsNull()) return;
335 // attention pas beau....
338 if(!myUIsoAspect.IsNull()) myUIsoAspect.Nullify();
339 if(!myVIsoAspect.IsNull()) myVIsoAspect.Nullify();
340 if(!myFreeBoundaryAspect.IsNull()) myFreeBoundaryAspect.Nullify();
341 if(!myUnFreeBoundaryAspect.IsNull()) myUnFreeBoundaryAspect.Nullify();
342 if(!myWireAspect.IsNull()) myWireAspect.Nullify();
343 if(!myLineAspect.IsNull()) myLineAspect.Nullify();
344 if(!myTextAspect.IsNull()) myTextAspect.Nullify();
345 if(!myShadingAspect.IsNull()) myShadingAspect.Nullify();
346 if(!myPointAspect.IsNull()) myPointAspect.Nullify();
347 if(!myPlaneAspect.IsNull()) myPlaneAspect.Nullify();
348 if(!myArrowAspect.IsNull()) myArrowAspect.Nullify();
349 if(!myHiddenLineAspect.IsNull()) myHiddenLineAspect.Nullify();
350 if(!mySeenLineAspect.IsNull()) mySeenLineAspect.Nullify();
351 if(!myVectorAspect.IsNull()) myVectorAspect .Nullify();
352 if(!myDatumAspect.IsNull()) myDatumAspect.Nullify();
353 if(!myDimensionAspect.IsNull()) myDimensionAspect.Nullify();
354 if(!mySectionAspect.IsNull()) mySectionAspect.Nullify();
355 if( myhasOwnHLRDeviationCoefficient ) myhasOwnHLRDeviationCoefficient = Standard_False;
356 if(myhasOwnHLRDeviationAngle ) myhasOwnHLRDeviationAngle = Standard_False;
357 if (!myFaceBoundaryAspect.IsNull()) myFaceBoundaryAspect.Nullify();
359 myHasOwnFaceBoundaryDraw = Standard_False;
360 myHasOwnDimLengthModelUnits = Standard_False;
361 myHasOwnDimLengthDisplayUnits = Standard_False;
362 myHasOwnDimAngleModelUnits = Standard_False;
363 myHasOwnDimAngleDisplayUnits = Standard_False;
365 hasLocalAttributes = Standard_False;
369 // =======================================================================
370 // function : SetFaceBoundaryDraw
372 // =======================================================================
373 void AIS_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
375 myHasOwnFaceBoundaryDraw = Standard_True;
376 myFaceBoundaryDraw = theIsEnabled;
379 // =======================================================================
380 // function : IsFaceBoundaryDraw
382 // =======================================================================
383 Standard_Boolean AIS_Drawer::IsFaceBoundaryDraw() const
385 if (!IsOwnFaceBoundaryDraw ())
387 return myLink->IsFaceBoundaryDraw ();
390 return myFaceBoundaryDraw;
393 // =======================================================================
394 // function : SetFaceBoundaryAspect
396 // =======================================================================
397 void AIS_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
399 myFaceBoundaryAspect = theAspect;
402 // =======================================================================
403 // function : FaceBoundaryAspect
405 // =======================================================================
406 Handle(Prs3d_LineAspect) AIS_Drawer::FaceBoundaryAspect()
408 if (!IsOwnFaceBoundaryAspect ())
410 return myLink->FaceBoundaryAspect ();
413 return myFaceBoundaryAspect;