0023365: Name collision of global IsEqual() leads to overriding user's definition
[occt.git] / src / AIS / AIS_Drawer.cxx
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
19 #include <AIS_Drawer.ixx>
20 #include <Standard_ProgramError.hxx>
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 {
31   SetMaximalParameterValue(500000.);
32   myLink->SetMaximalParameterValue(500000.);
33
34
35
36 Aspect_TypeOfDeflection AIS_Drawer::TypeOfDeflection () const 
37 {
38   return myLink->TypeOfDeflection();
39 }
40
41 Standard_Boolean AIS_Drawer::IsoOnPlane() const 
42 {
43     return myLink->IsoOnPlane();
44 }
45
46 Standard_Integer AIS_Drawer::Discretisation() const 
47 {
48   return myLink->Discretisation();
49 }
50
51 Quantity_Length AIS_Drawer::MaximalChordialDeviation() const 
52 {
53   return myLink->MaximalChordialDeviation();
54 }
55
56
57 //=======================================================================
58 //function : SetDeviationCoefficient
59 //purpose  : 
60 //=======================================================================
61
62 void AIS_Drawer::SetDeviationCoefficient ( const Standard_Real  aCoefficient )
63 {
64   myPreviousDeviationCoefficient = DeviationCoefficient() ;
65   myOwnDeviationCoefficient     = aCoefficient ;
66   myhasOwnDeviationCoefficient    = Standard_True; 
67 }
68
69
70 //=======================================================================
71 //function : SetHLRDeviationCoefficient
72 //purpose  : 
73 //=======================================================================
74
75 void AIS_Drawer::SetHLRDeviationCoefficient ( const Standard_Real  aCoefficient ) 
76 {
77   myPreviousHLRDeviationCoefficient = HLRDeviationCoefficient() ;
78   myOwnHLRDeviationCoefficient     = aCoefficient ;
79   myhasOwnHLRDeviationCoefficient    = Standard_True; 
80 }
81
82 //=======================================================================
83 //function : SetDeviationAngle
84 //purpose  : 
85 //=======================================================================
86
87 void AIS_Drawer::SetDeviationAngle ( const Standard_Real anAngle ) 
88 {
89   myPreviousDeviationAngle = DeviationAngle() ;
90   myOwnDeviationAngle     = anAngle ;
91   myhasOwnDeviationAngle    = Standard_True;   
92 }
93
94 //=======================================================================
95 //function : SetHLRAngle
96 //purpose  : 
97 //=======================================================================
98
99 void AIS_Drawer::SetHLRAngle ( const Standard_Real anAngle ) 
100 {
101   myPreviousHLRDeviationAngle = HLRAngle() ;
102   myOwnHLRDeviationAngle     = anAngle ;
103   myhasOwnHLRDeviationAngle    = Standard_True;   
104 }
105
106
107 /////// Get
108 //=======================================================================
109 //function : DeviationCoefficient
110 //purpose  : 
111 //=======================================================================
112
113 Standard_Real AIS_Drawer::DeviationCoefficient ()  const 
114 {
115   return myhasOwnDeviationCoefficient? myOwnDeviationCoefficient :myLink->DeviationCoefficient();
116 }
117
118 //=======================================================================
119 //function : HLRDeviationCoefficient
120 //purpose  : 
121 //=======================================================================
122
123 Standard_Real AIS_Drawer::HLRDeviationCoefficient ()  const 
124 {
125   return myhasOwnHLRDeviationCoefficient?myOwnHLRDeviationCoefficient : myLink->HLRDeviationCoefficient() ;
126 }
127
128 //=======================================================================
129 //function : DeviationAngle
130 //purpose  : 
131 //=======================================================================
132
133 Standard_Real AIS_Drawer::DeviationAngle ()  const 
134 {
135   return myhasOwnDeviationAngle ? myOwnDeviationAngle :  myLink->DeviationAngle();
136 }
137
138 //=======================================================================
139 //function : HLRAngle
140 //purpose  : 
141 //=======================================================================
142
143 Standard_Real AIS_Drawer::HLRAngle ()  const 
144 {
145   
146   return myhasOwnHLRDeviationAngle ?  myOwnHLRDeviationAngle : myLink->HLRAngle();
147 }
148
149 Standard_Real AIS_Drawer::MaximalParameterValue () const 
150 { return myLink->MaximalParameterValue();}
151
152 Handle (Prs3d_IsoAspect) AIS_Drawer::UIsoAspect ()  
153 { return myUIsoAspect.IsNull() ? myLink->UIsoAspect (): myUIsoAspect;}
154
155 Handle (Prs3d_IsoAspect) AIS_Drawer::VIsoAspect () 
156 { return myVIsoAspect.IsNull() ? myLink->VIsoAspect (): myVIsoAspect;}
157
158 Handle (Prs3d_LineAspect) AIS_Drawer::FreeBoundaryAspect () 
159 {return myFreeBoundaryAspect.IsNull() ? myLink->FreeBoundaryAspect (): myFreeBoundaryAspect;}
160
161 Standard_Boolean AIS_Drawer::FreeBoundaryDraw () const 
162 {return myLink->FreeBoundaryDraw();}
163
164 Handle (Prs3d_LineAspect) AIS_Drawer::UnFreeBoundaryAspect ()  
165 {return myUnFreeBoundaryAspect.IsNull() ? myLink->UnFreeBoundaryAspect (): myUnFreeBoundaryAspect;}
166
167 Standard_Boolean AIS_Drawer::UnFreeBoundaryDraw ()  const  
168 {return myLink->UnFreeBoundaryDraw ();}
169
170 Handle (Prs3d_LineAspect) AIS_Drawer::WireAspect ()
171 {  return myWireAspect.IsNull()? myLink->WireAspect (): myWireAspect;}
172
173 Standard_Boolean AIS_Drawer::WireDraw ()  const 
174 { return myLink->WireDraw();}
175
176 Handle (Prs3d_LineAspect) AIS_Drawer::LineAspect ()  
177 { return myLineAspect.IsNull() ? myLink->LineAspect (): myLineAspect;}
178
179 Handle (Prs3d_TextAspect) AIS_Drawer::TextAspect ()  
180 { return myTextAspect.IsNull() ? myLink->TextAspect () : myTextAspect ;}
181
182 Handle (Prs3d_ShadingAspect) AIS_Drawer::ShadingAspect ()
183 {
184 return myShadingAspect.IsNull() ? myLink->ShadingAspect ()  : myShadingAspect ;
185 }
186
187 Standard_Boolean AIS_Drawer::ShadingAspectGlobal()  const 
188 { return myLink->ShadingAspectGlobal();}
189  
190
191 Standard_Boolean AIS_Drawer::LineArrowDraw ()  const 
192 { return myLink->LineArrowDraw();}
193
194 Handle (Prs3d_ArrowAspect) AIS_Drawer::ArrowAspect() 
195 {return myArrowAspect.IsNull()?  myLink->ArrowAspect () :  myArrowAspect;}
196
197 Handle (Prs3d_PointAspect) AIS_Drawer::PointAspect() 
198 {return myPointAspect.IsNull()?  myLink->PointAspect () :  myPointAspect;}
199
200 Standard_Boolean AIS_Drawer::DrawHiddenLine ()  const 
201 {return myLink->DrawHiddenLine();}
202
203 Handle (Prs3d_LineAspect) AIS_Drawer::HiddenLineAspect ()  
204 {return  myHiddenLineAspect.IsNull()?  myLink->HiddenLineAspect () : myHiddenLineAspect;}
205
206 Handle (Prs3d_LineAspect) AIS_Drawer::SeenLineAspect ()  
207 { return mySeenLineAspect.IsNull() ? myLink->SeenLineAspect (): mySeenLineAspect ;}
208
209 Handle (Prs3d_LineAspect) AIS_Drawer::VectorAspect ()  
210 {return myVectorAspect.IsNull()?  myLink->VectorAspect () : myVectorAspect;}
211
212 Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect () 
213 {return myDatumAspect.IsNull()?  myLink->DatumAspect () : myDatumAspect; }
214
215 Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect () 
216 {return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;}
217
218 Handle (Prs3d_LengthAspect) AIS_Drawer::LengthAspect ()  
219 {return myLengthAspect.IsNull()? myLink->LengthAspect () : myLengthAspect ;}
220
221
222 Handle (Prs3d_AngleAspect) AIS_Drawer::AngleAspect () 
223 {return myAngleAspect.IsNull()? myLink->AngleAspect () :myAngleAspect ;}
224
225
226 Handle (Prs3d_RadiusAspect) AIS_Drawer::RadiusAspect ()  const 
227 {return myRadiusAspect.IsNull()? myLink->RadiusAspect():myRadiusAspect; }
228
229
230 Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect ()
231 {return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;}
232
233 const Handle (Prs3d_Drawer)& AIS_Drawer::Link()  
234
235   if(myLink.IsNull()) myLink =  new Prs3d_Drawer();
236   return myLink;
237  }
238
239 void AIS_Drawer::ClearLocalAttributes()
240 {
241   if(myLink.IsNull()) return;
242 // attention pas beau....
243 // The Handles
244
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;   
266   
267   hasLocalAttributes = Standard_False;
268
269 }
270
271