1 // Copyright (c) 1998-1999 Matra Datavision
2 // Copyright (c) 1999-2012 OPEN CASCADE SAS
4 // The content of this file is subject to the Open CASCADE Technology Public
5 // License Version 6.5 (the "License"). You may not use the content of this file
6 // except in compliance with the License. Please obtain a copy of the License
7 // at http://www.opencascade.org and read it completely before using this file.
9 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
10 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 // The Original Code and all software distributed under the License is
13 // distributed on an "AS IS" basis, without warranty of any kind, and the
14 // Initial Developer hereby disclaims all such warranties, including without
15 // limitation, any warranties of merchantability, fitness for a particular
16 // purpose or non-infringement. Please see the License for the specific terms
17 // and conditions governing the rights and limitations under the License.
19 #include <AIS_Drawer.ixx>
20 #include <Standard_ProgramError.hxx>
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.);
33 myLink->SetMaximalParameterValue(500000.);
34 SetTypeOfHLR (Prs3d_TOH_NotSet);
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 Standard_Boolean AIS_Drawer::DrawHiddenLine () const
202 {return myLink->DrawHiddenLine();}
204 Handle (Prs3d_LineAspect) AIS_Drawer::HiddenLineAspect ()
205 {return myHiddenLineAspect.IsNull()? myLink->HiddenLineAspect () : myHiddenLineAspect;}
207 Handle (Prs3d_LineAspect) AIS_Drawer::SeenLineAspect ()
208 { return mySeenLineAspect.IsNull() ? myLink->SeenLineAspect (): mySeenLineAspect ;}
210 Handle (Prs3d_LineAspect) AIS_Drawer::VectorAspect ()
211 {return myVectorAspect.IsNull()? myLink->VectorAspect () : myVectorAspect;}
213 Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect ()
214 {return myDatumAspect.IsNull()? myLink->DatumAspect () : myDatumAspect; }
216 Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect ()
217 {return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;}
219 Handle (Prs3d_DimensionAspect) AIS_Drawer::DimensionAspect ()
220 {return myDimensionAspect.IsNull()? myLink->DimensionAspect () : myDimensionAspect ;}
222 Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect ()
223 {return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;}
225 const Handle (Prs3d_Drawer)& AIS_Drawer::Link()
227 if(myLink.IsNull()) myLink = new Prs3d_Drawer();
231 void AIS_Drawer::ClearLocalAttributes()
233 if(myLink.IsNull()) return;
234 // attention pas beau....
237 if(!myUIsoAspect.IsNull()) myUIsoAspect.Nullify();
238 if(!myVIsoAspect.IsNull()) myVIsoAspect.Nullify();
239 if(!myFreeBoundaryAspect.IsNull()) myFreeBoundaryAspect.Nullify();
240 if(!myUnFreeBoundaryAspect.IsNull()) myUnFreeBoundaryAspect.Nullify();
241 if(!myWireAspect.IsNull()) myWireAspect.Nullify();
242 if(!myLineAspect.IsNull()) myLineAspect.Nullify();
243 if(!myTextAspect.IsNull()) myTextAspect.Nullify();
244 if(!myShadingAspect.IsNull()) myShadingAspect.Nullify();
245 if(!myPointAspect.IsNull()) myPointAspect.Nullify();
246 if(!myPlaneAspect.IsNull()) myPlaneAspect.Nullify();
247 if(!myArrowAspect.IsNull()) myArrowAspect.Nullify();
248 if(!myHiddenLineAspect.IsNull()) myHiddenLineAspect.Nullify();
249 if(!mySeenLineAspect.IsNull()) mySeenLineAspect.Nullify();
250 if(!myVectorAspect.IsNull()) myVectorAspect .Nullify();
251 if(!myDatumAspect.IsNull()) myDatumAspect.Nullify();
252 if(!myDimensionAspect.IsNull()) myDimensionAspect.Nullify();
253 if(!mySectionAspect.IsNull()) mySectionAspect.Nullify();
254 if( myhasOwnHLRDeviationCoefficient ) myhasOwnHLRDeviationCoefficient = Standard_False;
255 if(myhasOwnHLRDeviationAngle ) myhasOwnHLRDeviationAngle = Standard_False;
256 if (!myFaceBoundaryAspect.IsNull()) myFaceBoundaryAspect.Nullify();
258 myHasOwnFaceBoundaryDraw = Standard_False;
260 hasLocalAttributes = Standard_False;
264 // =======================================================================
265 // function : SetFaceBoundaryDraw
267 // =======================================================================
268 void AIS_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
270 myHasOwnFaceBoundaryDraw = Standard_True;
271 myFaceBoundaryDraw = theIsEnabled;
274 // =======================================================================
275 // function : IsFaceBoundaryDraw
277 // =======================================================================
278 Standard_Boolean AIS_Drawer::IsFaceBoundaryDraw() const
280 if (!IsOwnFaceBoundaryDraw ())
282 return myLink->IsFaceBoundaryDraw ();
285 return myFaceBoundaryDraw;
288 // =======================================================================
289 // function : SetFaceBoundaryAspect
291 // =======================================================================
292 void AIS_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
294 myFaceBoundaryAspect = theAspect;
297 // =======================================================================
298 // function : FaceBoundaryAspect
300 // =======================================================================
301 Handle_Prs3d_LineAspect AIS_Drawer::FaceBoundaryAspect()
303 if (!IsOwnFaceBoundaryAspect ())
305 return myLink->FaceBoundaryAspect ();
308 return myFaceBoundaryAspect;