0024448: Possible copy-paste bug in IGESGeom_SplineCurve.cxx
[occt.git] / src / AIS / AIS_Drawer.cxx
CommitLineData
b311480e 1// Copyright (c) 1998-1999 Matra Datavision
2// Copyright (c) 1999-2012 OPEN CASCADE SAS
3//
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.
8//
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.
11//
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.
18
7fd59977 19#include <AIS_Drawer.ixx>
20#include <Standard_ProgramError.hxx>
21
22AIS_Drawer::AIS_Drawer():
23myLink(new Prs3d_Drawer()),
24hasLocalAttributes(Standard_False),
25myhasOwnDeviationCoefficient(Standard_False),
26myPreviousDeviationCoefficient(0.1),
27myhasOwnHLRDeviationCoefficient (Standard_False),
28myhasOwnDeviationAngle (Standard_False),
a2d5ab2e 29myhasOwnHLRDeviationAngle (Standard_False),
30myHasOwnFaceBoundaryDraw (Standard_False)
7fd59977 31{
32 SetMaximalParameterValue(500000.);
33 myLink->SetMaximalParameterValue(500000.);
0a768f56 34 SetTypeOfHLR (Prs3d_TOH_NotSet);
7fd59977 35}
36
37
38Aspect_TypeOfDeflection AIS_Drawer::TypeOfDeflection () const
39{
40 return myLink->TypeOfDeflection();
41}
42
43Standard_Boolean AIS_Drawer::IsoOnPlane() const
44{
45 return myLink->IsoOnPlane();
46}
47
48Standard_Integer AIS_Drawer::Discretisation() const
49{
50 return myLink->Discretisation();
51}
52
53Quantity_Length AIS_Drawer::MaximalChordialDeviation() const
54{
55 return myLink->MaximalChordialDeviation();
56}
57
58
59//=======================================================================
60//function : SetDeviationCoefficient
61//purpose :
62//=======================================================================
63
64void AIS_Drawer::SetDeviationCoefficient ( const Standard_Real aCoefficient )
65{
66 myPreviousDeviationCoefficient = DeviationCoefficient() ;
67 myOwnDeviationCoefficient = aCoefficient ;
68 myhasOwnDeviationCoefficient = Standard_True;
69}
70
71
72//=======================================================================
73//function : SetHLRDeviationCoefficient
74//purpose :
75//=======================================================================
76
77void AIS_Drawer::SetHLRDeviationCoefficient ( const Standard_Real aCoefficient )
78{
79 myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient() ;
80 myOwnHLRDeviationCoefficient = aCoefficient ;
81 myhasOwnHLRDeviationCoefficient = Standard_True;
82}
83
84//=======================================================================
85//function : SetDeviationAngle
86//purpose :
87//=======================================================================
88
89void AIS_Drawer::SetDeviationAngle ( const Standard_Real anAngle )
90{
91 myPreviousDeviationAngle = DeviationAngle() ;
92 myOwnDeviationAngle = anAngle ;
93 myhasOwnDeviationAngle = Standard_True;
94}
95
96//=======================================================================
97//function : SetHLRAngle
98//purpose :
99//=======================================================================
100
101void AIS_Drawer::SetHLRAngle ( const Standard_Real anAngle )
102{
103 myPreviousHLRDeviationAngle = HLRAngle() ;
104 myOwnHLRDeviationAngle = anAngle ;
105 myhasOwnHLRDeviationAngle = Standard_True;
106}
107
7fd59977 108/////// Get
109//=======================================================================
110//function : DeviationCoefficient
111//purpose :
112//=======================================================================
113
114Standard_Real AIS_Drawer::DeviationCoefficient () const
115{
116 return myhasOwnDeviationCoefficient? myOwnDeviationCoefficient :myLink->DeviationCoefficient();
117}
118
119//=======================================================================
120//function : HLRDeviationCoefficient
121//purpose :
122//=======================================================================
123
124Standard_Real AIS_Drawer::HLRDeviationCoefficient () const
125{
126 return myhasOwnHLRDeviationCoefficient?myOwnHLRDeviationCoefficient : myLink->HLRDeviationCoefficient() ;
127}
128
129//=======================================================================
130//function : DeviationAngle
131//purpose :
132//=======================================================================
133
134Standard_Real AIS_Drawer::DeviationAngle () const
135{
136 return myhasOwnDeviationAngle ? myOwnDeviationAngle : myLink->DeviationAngle();
137}
138
139//=======================================================================
140//function : HLRAngle
141//purpose :
142//=======================================================================
143
144Standard_Real AIS_Drawer::HLRAngle () const
145{
146
147 return myhasOwnHLRDeviationAngle ? myOwnHLRDeviationAngle : myLink->HLRAngle();
148}
149
150Standard_Real AIS_Drawer::MaximalParameterValue () const
151{ return myLink->MaximalParameterValue();}
152
153Handle (Prs3d_IsoAspect) AIS_Drawer::UIsoAspect ()
154{ return myUIsoAspect.IsNull() ? myLink->UIsoAspect (): myUIsoAspect;}
155
156Handle (Prs3d_IsoAspect) AIS_Drawer::VIsoAspect ()
157{ return myVIsoAspect.IsNull() ? myLink->VIsoAspect (): myVIsoAspect;}
158
159Handle (Prs3d_LineAspect) AIS_Drawer::FreeBoundaryAspect ()
160{return myFreeBoundaryAspect.IsNull() ? myLink->FreeBoundaryAspect (): myFreeBoundaryAspect;}
161
162Standard_Boolean AIS_Drawer::FreeBoundaryDraw () const
163{return myLink->FreeBoundaryDraw();}
164
165Handle (Prs3d_LineAspect) AIS_Drawer::UnFreeBoundaryAspect ()
166{return myUnFreeBoundaryAspect.IsNull() ? myLink->UnFreeBoundaryAspect (): myUnFreeBoundaryAspect;}
167
168Standard_Boolean AIS_Drawer::UnFreeBoundaryDraw () const
169{return myLink->UnFreeBoundaryDraw ();}
170
171Handle (Prs3d_LineAspect) AIS_Drawer::WireAspect ()
172{ return myWireAspect.IsNull()? myLink->WireAspect (): myWireAspect;}
173
174Standard_Boolean AIS_Drawer::WireDraw () const
175{ return myLink->WireDraw();}
176
177Handle (Prs3d_LineAspect) AIS_Drawer::LineAspect ()
178{ return myLineAspect.IsNull() ? myLink->LineAspect (): myLineAspect;}
179
180Handle (Prs3d_TextAspect) AIS_Drawer::TextAspect ()
181{ return myTextAspect.IsNull() ? myLink->TextAspect () : myTextAspect ;}
182
183Handle (Prs3d_ShadingAspect) AIS_Drawer::ShadingAspect ()
184{
185return myShadingAspect.IsNull() ? myLink->ShadingAspect () : myShadingAspect ;
186}
187
188Standard_Boolean AIS_Drawer::ShadingAspectGlobal() const
189{ return myLink->ShadingAspectGlobal();}
190
191
192Standard_Boolean AIS_Drawer::LineArrowDraw () const
193{ return myLink->LineArrowDraw();}
194
195Handle (Prs3d_ArrowAspect) AIS_Drawer::ArrowAspect()
196{return myArrowAspect.IsNull()? myLink->ArrowAspect () : myArrowAspect;}
197
198Handle (Prs3d_PointAspect) AIS_Drawer::PointAspect()
199{return myPointAspect.IsNull()? myLink->PointAspect () : myPointAspect;}
200
201Standard_Boolean AIS_Drawer::DrawHiddenLine () const
202{return myLink->DrawHiddenLine();}
203
204Handle (Prs3d_LineAspect) AIS_Drawer::HiddenLineAspect ()
205{return myHiddenLineAspect.IsNull()? myLink->HiddenLineAspect () : myHiddenLineAspect;}
206
207Handle (Prs3d_LineAspect) AIS_Drawer::SeenLineAspect ()
208{ return mySeenLineAspect.IsNull() ? myLink->SeenLineAspect (): mySeenLineAspect ;}
209
210Handle (Prs3d_LineAspect) AIS_Drawer::VectorAspect ()
211{return myVectorAspect.IsNull()? myLink->VectorAspect () : myVectorAspect;}
212
213Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect ()
214{return myDatumAspect.IsNull()? myLink->DatumAspect () : myDatumAspect; }
215
216Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect ()
217{return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;}
218
a6eb515f 219Handle (Prs3d_DimensionAspect) AIS_Drawer::DimensionAspect ()
220{return myDimensionAspect.IsNull()? myLink->DimensionAspect () : myDimensionAspect ;}
7fd59977 221
222Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect ()
223{return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;}
224
225const Handle (Prs3d_Drawer)& AIS_Drawer::Link()
226{
227 if(myLink.IsNull()) myLink = new Prs3d_Drawer();
228 return myLink;
229 }
230
231void AIS_Drawer::ClearLocalAttributes()
232{
233 if(myLink.IsNull()) return;
234// attention pas beau....
235// The Handles
236
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();
a6eb515f 252 if(!myDimensionAspect.IsNull()) myDimensionAspect.Nullify();
7fd59977 253 if(!mySectionAspect.IsNull()) mySectionAspect.Nullify();
254 if( myhasOwnHLRDeviationCoefficient ) myhasOwnHLRDeviationCoefficient = Standard_False;
a2d5ab2e 255 if(myhasOwnHLRDeviationAngle ) myhasOwnHLRDeviationAngle = Standard_False;
256 if (!myFaceBoundaryAspect.IsNull()) myFaceBoundaryAspect.Nullify();
7fd59977 257
a2d5ab2e 258 myHasOwnFaceBoundaryDraw = Standard_False;
259
7fd59977 260 hasLocalAttributes = Standard_False;
261
262}
263
a2d5ab2e 264// =======================================================================
265// function : SetFaceBoundaryDraw
266// purpose :
267// =======================================================================
268void AIS_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
269{
270 myHasOwnFaceBoundaryDraw = Standard_True;
271 myFaceBoundaryDraw = theIsEnabled;
272}
273
274// =======================================================================
275// function : IsFaceBoundaryDraw
276// purpose :
277// =======================================================================
278Standard_Boolean AIS_Drawer::IsFaceBoundaryDraw() const
279{
280 if (!IsOwnFaceBoundaryDraw ())
281 {
282 return myLink->IsFaceBoundaryDraw ();
283 }
284
285 return myFaceBoundaryDraw;
286}
7fd59977 287
a2d5ab2e 288// =======================================================================
289// function : SetFaceBoundaryAspect
290// purpose :
291// =======================================================================
292void AIS_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
293{
294 myFaceBoundaryAspect = theAspect;
295}
296
297// =======================================================================
298// function : FaceBoundaryAspect
299// purpose :
300// =======================================================================
301Handle_Prs3d_LineAspect AIS_Drawer::FaceBoundaryAspect()
302{
303 if (!IsOwnFaceBoundaryAspect ())
304 {
305 return myLink->FaceBoundaryAspect ();
306 }
307
308 return myFaceBoundaryAspect;
309}