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)
31 SetMaximalParameterValue(500000.);
32 myLink->SetMaximalParameterValue(500000.);
36 Aspect_TypeOfDeflection AIS_Drawer::TypeOfDeflection () const
38 return myLink->TypeOfDeflection();
41 Standard_Boolean AIS_Drawer::IsoOnPlane() const
43 return myLink->IsoOnPlane();
46 Standard_Integer AIS_Drawer::Discretisation() const
48 return myLink->Discretisation();
51 Quantity_Length AIS_Drawer::MaximalChordialDeviation() const
53 return myLink->MaximalChordialDeviation();
57 //=======================================================================
58 //function : SetDeviationCoefficient
60 //=======================================================================
62 void AIS_Drawer::SetDeviationCoefficient ( const Standard_Real aCoefficient )
64 myPreviousDeviationCoefficient = DeviationCoefficient() ;
65 myOwnDeviationCoefficient = aCoefficient ;
66 myhasOwnDeviationCoefficient = Standard_True;
70 //=======================================================================
71 //function : SetHLRDeviationCoefficient
73 //=======================================================================
75 void AIS_Drawer::SetHLRDeviationCoefficient ( const Standard_Real aCoefficient )
77 myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient() ;
78 myOwnHLRDeviationCoefficient = aCoefficient ;
79 myhasOwnHLRDeviationCoefficient = Standard_True;
82 //=======================================================================
83 //function : SetDeviationAngle
85 //=======================================================================
87 void AIS_Drawer::SetDeviationAngle ( const Standard_Real anAngle )
89 myPreviousDeviationAngle = DeviationAngle() ;
90 myOwnDeviationAngle = anAngle ;
91 myhasOwnDeviationAngle = Standard_True;
94 //=======================================================================
95 //function : SetHLRAngle
97 //=======================================================================
99 void AIS_Drawer::SetHLRAngle ( const Standard_Real anAngle )
101 myPreviousHLRDeviationAngle = HLRAngle() ;
102 myOwnHLRDeviationAngle = anAngle ;
103 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 Handle (Prs3d_LengthAspect) AIS_Drawer::LengthAspect ()
219 {return myLengthAspect.IsNull()? myLink->LengthAspect () : myLengthAspect ;}
222 Handle (Prs3d_AngleAspect) AIS_Drawer::AngleAspect ()
223 {return myAngleAspect.IsNull()? myLink->AngleAspect () :myAngleAspect ;}
226 Handle (Prs3d_RadiusAspect) AIS_Drawer::RadiusAspect () const
227 {return myRadiusAspect.IsNull()? myLink->RadiusAspect():myRadiusAspect; }
230 Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect ()
231 {return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;}
233 const Handle (Prs3d_Drawer)& AIS_Drawer::Link()
235 if(myLink.IsNull()) myLink = new Prs3d_Drawer();
239 void AIS_Drawer::ClearLocalAttributes()
241 if(myLink.IsNull()) return;
242 // attention pas beau....
245 if(!myUIsoAspect.IsNull()) myUIsoAspect.Nullify();
246 if(!myVIsoAspect.IsNull()) myVIsoAspect.Nullify();
247 if(!myFreeBoundaryAspect.IsNull()) myFreeBoundaryAspect.Nullify();
248 if(!myUnFreeBoundaryAspect.IsNull()) myUnFreeBoundaryAspect.Nullify();
249 if(!myWireAspect.IsNull()) myWireAspect.Nullify();
250 if(!myLineAspect.IsNull()) myLineAspect.Nullify();
251 if(!myTextAspect.IsNull()) myTextAspect.Nullify();
252 if(!myShadingAspect.IsNull()) myShadingAspect.Nullify();
253 if(!myPointAspect.IsNull()) myPointAspect.Nullify();
254 if(!myPlaneAspect.IsNull()) myPlaneAspect.Nullify();
255 if(!myArrowAspect.IsNull()) myArrowAspect.Nullify();
256 if(!myHiddenLineAspect.IsNull()) myHiddenLineAspect.Nullify();
257 if(!mySeenLineAspect.IsNull()) mySeenLineAspect.Nullify();
258 if(!myVectorAspect.IsNull()) myVectorAspect .Nullify();
259 if(!myDatumAspect.IsNull()) myDatumAspect.Nullify();
260 if(!myLengthAspect.IsNull()) myLengthAspect.Nullify();
261 if(!myAngleAspect.IsNull()) myAngleAspect.Nullify();
262 if(!myRadiusAspect.IsNull()) myRadiusAspect.Nullify();
263 if(!mySectionAspect.IsNull()) mySectionAspect.Nullify();
264 if( myhasOwnHLRDeviationCoefficient ) myhasOwnHLRDeviationCoefficient = Standard_False;
265 if(myhasOwnHLRDeviationAngle ) myhasOwnHLRDeviationAngle = Standard_False;
267 hasLocalAttributes = Standard_False;