0024326: Get rid of confusing extension line
[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 myHasOwnFaceBoundaryDraw (Standard_False)
31 {
32   SetMaximalParameterValue(500000.);
33   myLink->SetMaximalParameterValue(500000.);
34   SetTypeOfHLR (Prs3d_TOH_NotSet);
35
36
37
38 Aspect_TypeOfDeflection AIS_Drawer::TypeOfDeflection () const 
39 {
40   return myLink->TypeOfDeflection();
41 }
42
43 Standard_Boolean AIS_Drawer::IsoOnPlane() const 
44 {
45     return myLink->IsoOnPlane();
46 }
47
48 Standard_Integer AIS_Drawer::Discretisation() const 
49 {
50   return myLink->Discretisation();
51 }
52
53 Quantity_Length AIS_Drawer::MaximalChordialDeviation() const 
54 {
55   return myLink->MaximalChordialDeviation();
56 }
57
58
59 //=======================================================================
60 //function : SetDeviationCoefficient
61 //purpose  : 
62 //=======================================================================
63
64 void 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
77 void 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
89 void 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
101 void AIS_Drawer::SetHLRAngle ( const Standard_Real anAngle ) 
102 {
103   myPreviousHLRDeviationAngle = HLRAngle() ;
104   myOwnHLRDeviationAngle     = anAngle ;
105   myhasOwnHLRDeviationAngle    = Standard_True;   
106 }
107
108 /////// Get
109 //=======================================================================
110 //function : DeviationCoefficient
111 //purpose  : 
112 //=======================================================================
113
114 Standard_Real AIS_Drawer::DeviationCoefficient ()  const 
115 {
116   return myhasOwnDeviationCoefficient? myOwnDeviationCoefficient :myLink->DeviationCoefficient();
117 }
118
119 //=======================================================================
120 //function : HLRDeviationCoefficient
121 //purpose  : 
122 //=======================================================================
123
124 Standard_Real AIS_Drawer::HLRDeviationCoefficient ()  const 
125 {
126   return myhasOwnHLRDeviationCoefficient?myOwnHLRDeviationCoefficient : myLink->HLRDeviationCoefficient() ;
127 }
128
129 //=======================================================================
130 //function : DeviationAngle
131 //purpose  : 
132 //=======================================================================
133
134 Standard_Real AIS_Drawer::DeviationAngle ()  const 
135 {
136   return myhasOwnDeviationAngle ? myOwnDeviationAngle :  myLink->DeviationAngle();
137 }
138
139 //=======================================================================
140 //function : HLRAngle
141 //purpose  : 
142 //=======================================================================
143
144 Standard_Real AIS_Drawer::HLRAngle ()  const 
145 {
146   
147   return myhasOwnHLRDeviationAngle ?  myOwnHLRDeviationAngle : myLink->HLRAngle();
148 }
149
150 Standard_Real AIS_Drawer::MaximalParameterValue () const 
151 { return myLink->MaximalParameterValue();}
152
153 Handle (Prs3d_IsoAspect) AIS_Drawer::UIsoAspect ()  
154 { return myUIsoAspect.IsNull() ? myLink->UIsoAspect (): myUIsoAspect;}
155
156 Handle (Prs3d_IsoAspect) AIS_Drawer::VIsoAspect () 
157 { return myVIsoAspect.IsNull() ? myLink->VIsoAspect (): myVIsoAspect;}
158
159 Handle (Prs3d_LineAspect) AIS_Drawer::FreeBoundaryAspect () 
160 {return myFreeBoundaryAspect.IsNull() ? myLink->FreeBoundaryAspect (): myFreeBoundaryAspect;}
161
162 Standard_Boolean AIS_Drawer::FreeBoundaryDraw () const 
163 {return myLink->FreeBoundaryDraw();}
164
165 Handle (Prs3d_LineAspect) AIS_Drawer::UnFreeBoundaryAspect ()  
166 {return myUnFreeBoundaryAspect.IsNull() ? myLink->UnFreeBoundaryAspect (): myUnFreeBoundaryAspect;}
167
168 Standard_Boolean AIS_Drawer::UnFreeBoundaryDraw ()  const  
169 {return myLink->UnFreeBoundaryDraw ();}
170
171 Handle (Prs3d_LineAspect) AIS_Drawer::WireAspect ()
172 {  return myWireAspect.IsNull()? myLink->WireAspect (): myWireAspect;}
173
174 Standard_Boolean AIS_Drawer::WireDraw ()  const 
175 { return myLink->WireDraw();}
176
177 Handle (Prs3d_LineAspect) AIS_Drawer::LineAspect ()  
178 { return myLineAspect.IsNull() ? myLink->LineAspect (): myLineAspect;}
179
180 Handle (Prs3d_TextAspect) AIS_Drawer::TextAspect ()  
181 { return myTextAspect.IsNull() ? myLink->TextAspect () : myTextAspect ;}
182
183 Handle (Prs3d_ShadingAspect) AIS_Drawer::ShadingAspect ()
184 {
185 return myShadingAspect.IsNull() ? myLink->ShadingAspect ()  : myShadingAspect ;
186 }
187
188 Standard_Boolean AIS_Drawer::ShadingAspectGlobal()  const 
189 { return myLink->ShadingAspectGlobal();}
190  
191
192 Standard_Boolean AIS_Drawer::LineArrowDraw ()  const 
193 { return myLink->LineArrowDraw();}
194
195 Handle (Prs3d_ArrowAspect) AIS_Drawer::ArrowAspect() 
196 {return myArrowAspect.IsNull()?  myLink->ArrowAspect () :  myArrowAspect;}
197
198 Handle (Prs3d_PointAspect) AIS_Drawer::PointAspect() 
199 {return myPointAspect.IsNull()?  myLink->PointAspect () :  myPointAspect;}
200
201 Standard_Boolean AIS_Drawer::DrawHiddenLine ()  const 
202 {return myLink->DrawHiddenLine();}
203
204 Handle (Prs3d_LineAspect) AIS_Drawer::HiddenLineAspect ()  
205 {return  myHiddenLineAspect.IsNull()?  myLink->HiddenLineAspect () : myHiddenLineAspect;}
206
207 Handle (Prs3d_LineAspect) AIS_Drawer::SeenLineAspect ()  
208 { return mySeenLineAspect.IsNull() ? myLink->SeenLineAspect (): mySeenLineAspect ;}
209
210 Handle (Prs3d_LineAspect) AIS_Drawer::VectorAspect ()  
211 {return myVectorAspect.IsNull()?  myLink->VectorAspect () : myVectorAspect;}
212
213 Handle (Prs3d_DatumAspect) AIS_Drawer::DatumAspect () 
214 {return myDatumAspect.IsNull()?  myLink->DatumAspect () : myDatumAspect; }
215
216 Handle (Prs3d_PlaneAspect) AIS_Drawer::PlaneAspect () 
217 {return myPlaneAspect.IsNull() ? myLink->PlaneAspect (): myPlaneAspect;}
218
219 Handle (Prs3d_DimensionAspect) AIS_Drawer::DimensionAspect ()  
220 {return myDimensionAspect.IsNull()? myLink->DimensionAspect () : myDimensionAspect ;}
221
222 Handle (Prs3d_LineAspect) AIS_Drawer::SectionAspect ()
223 {return mySectionAspect.IsNull()? myLink->SectionAspect (): mySectionAspect;}
224
225 const Handle (Prs3d_Drawer)& AIS_Drawer::Link()  
226
227   if(myLink.IsNull()) myLink =  new Prs3d_Drawer();
228   return myLink;
229  }
230
231 void 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();     
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();
257   
258   myHasOwnFaceBoundaryDraw = Standard_False;
259
260   hasLocalAttributes = Standard_False;
261
262 }
263
264 // =======================================================================
265 // function : SetFaceBoundaryDraw
266 // purpose  :
267 // =======================================================================
268 void AIS_Drawer::SetFaceBoundaryDraw (const Standard_Boolean theIsEnabled)
269 {
270   myHasOwnFaceBoundaryDraw = Standard_True;
271   myFaceBoundaryDraw       = theIsEnabled;
272 }
273
274 // =======================================================================
275 // function : IsFaceBoundaryDraw
276 // purpose  :
277 // =======================================================================
278 Standard_Boolean AIS_Drawer::IsFaceBoundaryDraw() const
279 {
280   if (!IsOwnFaceBoundaryDraw ())
281   {
282     return myLink->IsFaceBoundaryDraw ();
283   }
284
285   return myFaceBoundaryDraw;
286 }
287
288 // =======================================================================
289 // function : SetFaceBoundaryAspect
290 // purpose  :
291 // =======================================================================
292 void AIS_Drawer::SetFaceBoundaryAspect (const Handle(Prs3d_LineAspect)& theAspect)
293 {
294   myFaceBoundaryAspect = theAspect;
295 }
296
297 // =======================================================================
298 // function : FaceBoundaryAspect
299 // purpose  :
300 // =======================================================================
301 Handle_Prs3d_LineAspect AIS_Drawer::FaceBoundaryAspect()
302 {
303   if (!IsOwnFaceBoundaryAspect ())
304   {
305     return myLink->FaceBoundaryAspect ();
306   }
307
308   return myFaceBoundaryAspect;
309 }