7fd59977 |
1 | // File: AIS_Shape.cxx |
2 | // Created: Fri Dec 20 17:18:37 1996 |
3 | // Author: Robert COUBLANC |
4 | // <rob@robox.paris1.matra-dtv.fr> |
5 | // Modified: Christiane ARMAND: 5/05/97: dans le compute on prend en |
6 | // compte le cas des objets infinis |
7 | // ROB : introduction des primitives connectees |
8 | // Pour le calcul des faces sensibles... |
9 | // oct-03-97 ROB : en fonction du type de shapes, on change les coeffs de polygonisation... |
10 | // (correction du Pb des cercles pas assez discretises...) |
11 | |
12 | #define BUC60577 //GG_191099 Draw correct bounding box and Menage ... |
13 | |
14 | #define BUC60547 //GG_091299 Enable to show a Shape of type COMPOUND |
15 | |
16 | #define GER61351 //GG_171199 Enable to set an object RGB color |
17 | // instead a restricted object NameOfColor. |
18 | // Redefines the Color(),Material(),Transparency() methods . |
19 | // enable to get separately the shape attributes. |
20 | |
21 | #define IMP040200 //GG Enable to compute selection after transformation |
22 | |
23 | #define BUC60918 //GG 31/05/01 To avoid transparency bug between |
24 | // transparent and non transparent objects, |
25 | // increase display priority for transparent objects |
26 | |
27 | #include <AIS_Shape.ixx> |
28 | |
29 | |
30 | #include <Standard_ErrorHandler.hxx> |
31 | #include <OSD_Timer.hxx> |
32 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
33 | |
34 | #include <Quantity_Color.hxx> |
35 | |
36 | #include <gp_Pnt.hxx> |
37 | #include <Bnd_Box.hxx> |
38 | #include <BRep_Builder.hxx> |
39 | #include <BRepTools_ShapeSet.hxx> |
40 | #include <BRepTools.hxx> |
41 | #include <BRepBndLib.hxx> |
42 | #include <TopExp.hxx> |
43 | #include <TopExp_Explorer.hxx> |
44 | |
45 | #include <Aspect_TypeOfLine.hxx> |
46 | #include <Graphic3d_Structure.hxx> |
47 | #include <Graphic3d_Group.hxx> |
48 | #include <Graphic3d_AspectLine3d.hxx> |
49 | #include <Graphic3d_AspectText3d.hxx> |
50 | #include <Graphic3d_AspectMarker3d.hxx> |
51 | #include <Graphic3d_AspectFillArea3d.hxx> |
52 | #include <Graphic3d_Array1OfVertex.hxx> |
53 | #include <Graphic3d_ArrayOfPrimitives.hxx> |
54 | #include <Graphic3d_MaterialAspect.hxx> |
55 | |
56 | #include <Prs3d_Presentation.hxx> |
57 | #include <Prs3d_Root.hxx> |
58 | #include <Prs3d_ShadingAspect.hxx> |
59 | #include <Prs3d_Drawer.hxx> |
60 | #include <Prs3d_IsoAspect.hxx> |
61 | |
62 | //#include <StdPrs_WFSectionShape.hxx> |
63 | #include <StdPrs_WFShape.hxx> |
64 | #include <StdPrs_WFDeflectionShape.hxx> |
65 | #include <StdPrs_ShadedShape.hxx> |
66 | #include <StdPrs_HLRShape.hxx> |
67 | #include <StdPrs_HLRPolyShape.hxx> |
68 | |
69 | #include <PrsMgr_ModedPresentation.hxx> |
70 | |
71 | #include <Select3D_SensitiveEntity.hxx> |
72 | #include <StdSelect.hxx> |
73 | #include <StdSelect_BRepSelectionTool.hxx> |
74 | #include <StdSelect_BRepOwner.hxx> |
75 | #include <StdSelect_DisplayMode.hxx> |
76 | |
77 | #include <AIS_GraphicTool.hxx> |
78 | #include <AIS_InteractiveContext.hxx> |
79 | #include <AIS_Drawer.hxx> |
80 | #include <HLRBRep.hxx> |
81 | #include <Precision.hxx> |
82 | |
83 | #include <Standard_Failure.hxx> |
84 | #include <Standard_ErrorHandler.hxx> |
85 | #include <Select3D_SensitiveBox.hxx> |
86 | #ifdef BUC60547 |
87 | #include <TopoDS_Iterator.hxx> |
88 | #endif |
89 | |
90 | static Standard_Boolean myFirstCompute; |
91 | |
92 | Standard_Real AIS_Shape::GetDeflection(const TopoDS_Shape& aShape, |
93 | const Handle(Prs3d_Drawer)& aDrawer) |
94 | { |
95 | // WARNING: this same piece of code appears several times in Prs3d classes |
96 | Standard_Real aDeflection; |
97 | if (aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) { |
98 | Bnd_Box B; |
99 | BRepBndLib::Add(aShape, B); |
100 | if ( ! B.IsVoid() ) |
101 | { |
102 | Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; |
103 | B.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); |
104 | aDeflection = Max( aXmax-aXmin, Max(aYmax-aYmin, aZmax-aZmin)) * |
105 | aDrawer->DeviationCoefficient() * 4; |
106 | } |
107 | else |
108 | aDeflection = aDrawer->MaximalChordialDeviation(); |
109 | } |
110 | else |
111 | aDeflection = aDrawer->MaximalChordialDeviation(); |
112 | return aDeflection; |
113 | } |
114 | |
115 | void AIS_Shape::DisplayBox(const Handle(Prs3d_Presentation)& aPrs, |
116 | const Bnd_Box& B, |
117 | const Handle(Prs3d_Drawer)& aDrawer) |
118 | { |
119 | Standard_Real X[2],Y[2],Z[2]; |
120 | Standard_Integer Indx [16] ; |
121 | if ( B.IsVoid() ) |
122 | return; // nothing to show |
123 | |
124 | #ifdef BUC60577 |
125 | Indx [0]=1;Indx [1]=2;Indx [2]=4;Indx [3]=3; |
126 | Indx [4]=5;Indx [5]=6;Indx [6]=8;Indx [7]=7; |
127 | Indx [8]=1;Indx [9]=3;Indx [10]=7;Indx [11]=5; |
128 | Indx [12]=2;Indx [13]=4;Indx [14]=8;Indx [15]=6; |
129 | B.Get(X[0], Y[0], Z[0], X[1], Y[1], Z[1]); |
130 | #else |
131 | Indx [0]=1;Indx [1]=2;Indx [2]=3;Indx [3]=4;Indx [4]=5;Indx [5]=6;Indx [6]=7; |
132 | Indx [7]=8;Indx [8]=1;Indx [9]=2;Indx [10]=6;Indx [10]=5;Indx [10]=3; |
133 | Indx [10]=4;Indx [10]=8;Indx [10]=7; |
134 | B.Get(X[1], Y[1], Z[1], X[2], Y[2], Z[2]); |
135 | #endif |
136 | |
137 | Graphic3d_Array1OfVertex V(1,8); |
138 | Standard_Integer Rank(0); |
139 | for(Standard_Integer k=0;k<=1;k++) |
140 | for(Standard_Integer j=0;j<=1;j++) |
141 | for(Standard_Integer i=0;i<=1;i++) |
142 | V(++Rank) = Graphic3d_Vertex(X[i],Y[j],Z[k]); |
143 | |
144 | |
145 | Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(aPrs); |
146 | Quantity_Color Q; |
147 | Aspect_TypeOfLine A; |
148 | Standard_Real W; |
149 | aDrawer->LineAspect()->Aspect()->Values(Q,A,W); |
150 | |
151 | |
152 | G->SetGroupPrimitivesAspect(new Graphic3d_AspectLine3d(Q,Aspect_TOL_DOTDASH,W)); |
153 | |
154 | G->BeginPrimitives();Standard_Integer I,J; |
155 | Graphic3d_Array1OfVertex VVV (1,5); |
156 | for(I=1;I<=4;I++){ |
157 | for(J=1;J<=4;J++){ |
158 | VVV.SetValue(J,V(Indx[J+4*I-5])); |
159 | } |
160 | VVV.SetValue(5,VVV(1)); |
161 | G->Polyline(VVV); |
162 | } |
163 | G->EndPrimitives(); |
164 | } |
165 | |
166 | static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode) |
167 | { |
168 | TColStd_ListIteratorOfListOfInteger It(LL); |
169 | for(;It.More();It.Next()){ |
170 | if(It.Value()==aMode) |
171 | return Standard_True;} |
172 | return Standard_False; |
173 | } |
174 | |
175 | //================================================== |
176 | // Function: |
177 | // Purpose : |
178 | //================================================== |
179 | |
180 | AIS_Shape:: |
181 | AIS_Shape(const TopoDS_Shape& shap): |
182 | AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant), |
183 | myshape(shap), |
184 | myCompBB(Standard_True), |
185 | myInitAng(0.) |
186 | { |
187 | myFirstCompute = Standard_True; |
188 | SetHilightMode(0); |
189 | myDrawer->SetShadingAspectGlobal(Standard_False); |
190 | } |
191 | |
192 | //======================================================================= |
193 | //function : Type |
194 | //purpose : |
195 | //======================================================================= |
196 | AIS_KindOfInteractive AIS_Shape::Type() const |
197 | {return AIS_KOI_Shape;} |
198 | |
199 | |
200 | //======================================================================= |
201 | //function : Signature |
202 | //purpose : |
203 | //======================================================================= |
204 | Standard_Integer AIS_Shape::Signature() const |
205 | {return 0;} |
206 | |
207 | //======================================================================= |
208 | //function : AcceptShapeDecomposition |
209 | //purpose : |
210 | //======================================================================= |
211 | Standard_Boolean AIS_Shape::AcceptShapeDecomposition() const |
212 | {return Standard_True;} |
213 | |
214 | //======================================================================= |
215 | //function : Compute |
216 | //purpose : |
217 | //======================================================================= |
218 | void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/, |
219 | const Handle(Prs3d_Presentation)& aPrs, |
220 | const Standard_Integer aMode) |
221 | { |
222 | aPrs->Clear(); |
223 | if(myshape.IsNull()) return; |
224 | |
225 | // wire,edge,vertex -> pas de HLR + priorite display superieure |
226 | Standard_Integer TheType = (Standard_Integer) myshape.ShapeType(); |
227 | if(TheType>4 && TheType<8) { |
228 | aPrs->SetVisual(Graphic3d_TOS_ALL); |
229 | aPrs->SetDisplayPriority(TheType+2); |
230 | } |
231 | // Shape vide -> Assemblage vide. |
232 | if (myshape.ShapeType() == TopAbs_COMPOUND) { |
233 | #ifdef BUC60547 |
234 | TopoDS_Iterator anExplor (myshape); |
235 | #else |
236 | TopExp_Explorer anExplor (myshape, TopAbs_VERTEX); |
237 | #endif |
238 | if (!anExplor.More()) { |
239 | return; |
240 | } |
241 | } |
242 | |
243 | |
244 | if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //pas de prise en compte lors du FITALL |
245 | switch (aMode) { |
246 | case 0:{ |
247 | try { OCC_CATCH_SIGNALS StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); } |
248 | catch (Standard_Failure) { |
249 | #ifdef DEB |
250 | cout << "AIS_Shape::Compute() failed"<< endl; |
251 | #endif |
252 | cout << "a Shape should be incorrect : No Compute can be maked on it "<< endl; |
253 | // on calcule une presentation de la boite englobante |
254 | // Compute(aPresentationManager,aPrs,2); |
255 | } |
256 | break; |
257 | } |
258 | case 1: |
259 | { |
260 | Standard_Real prevangle ; |
261 | Standard_Real newangle ; |
262 | Standard_Real prevcoeff ; |
263 | Standard_Real newcoeff ; |
264 | |
265 | |
266 | if (OwnDeviationAngle(newangle,prevangle) || |
267 | OwnDeviationCoefficient(newcoeff,prevcoeff)) |
268 | if (Abs (newangle - prevangle) > Precision::Angular() || |
269 | Abs (newcoeff - prevcoeff) > Precision::Confusion() ) { |
270 | #ifdef DEB |
271 | cout << "AIS_Shape : compute"<<endl; |
272 | cout << "newangl : " << newangle << " # de " << "prevangl : " << prevangle << " OU "<<endl; |
273 | cout << "newcoeff : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl; |
274 | #endif |
275 | BRepTools::Clean(myshape); |
276 | } |
277 | |
278 | //shading seulement a partir de face... |
279 | if ((Standard_Integer) myshape.ShapeType()>4) |
280 | StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); |
281 | else { |
282 | myDrawer->SetShadingAspectGlobal(Standard_False); |
283 | if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); |
284 | else { |
285 | { |
286 | try { |
287 | OCC_CATCH_SIGNALS |
288 | StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer); |
289 | } |
290 | catch (Standard_Failure) { |
291 | #ifdef DEB |
292 | cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl; |
293 | #endif |
294 | StdPrs_WFShape::Add(aPrs,myshape,myDrawer); |
295 | } |
296 | } |
297 | } |
298 | } |
299 | #ifdef BUC60918 |
300 | Standard_Real value = Transparency() ; |
301 | if( value > 0. ) { |
302 | SetTransparency( value ); |
303 | } |
304 | #endif |
305 | break; |
306 | } |
307 | case 2: |
308 | { |
309 | // boite englobante |
310 | if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); |
311 | else DisplayBox(aPrs,BoundingBox(),myDrawer); |
312 | } |
313 | |
314 | |
315 | } // end switch |
316 | aPrs->ReCompute(); // for hidden line recomputation if necessary... |
317 | |
318 | } |
319 | |
320 | //======================================================================= |
321 | //function : Compute |
322 | //purpose : |
323 | //======================================================================= |
324 | |
325 | void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager2d)& /*aPresentationManager*/, |
326 | const Handle(Graphic2d_GraphicObject)& /*aGRO*/, |
327 | const Standard_Integer /*aMode*/) |
328 | { |
329 | } |
330 | |
331 | //======================================================================= |
332 | //function : Compute |
333 | //purpose : Hidden Line Removal |
334 | //======================================================================= |
335 | void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector, |
336 | const Handle(Prs3d_Presentation)& aPresentation) |
337 | { |
338 | Compute(aProjector,aPresentation,myshape); |
339 | } |
340 | |
341 | //======================================================================= |
342 | //function : Compute |
343 | //purpose : |
344 | //======================================================================= |
345 | |
346 | void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector, |
347 | const Handle(Geom_Transformation)& TheTrsf, |
348 | const Handle(Prs3d_Presentation)& aPresentation) |
349 | { |
350 | const TopLoc_Location& loc = myshape.Location(); |
351 | TopoDS_Shape shbis = myshape.Located(TopLoc_Location(TheTrsf->Trsf())*loc); |
352 | Compute(aProjector,aPresentation,shbis); |
353 | } |
354 | |
355 | //======================================================================= |
356 | //function : Compute |
357 | //purpose : |
358 | //======================================================================= |
359 | |
360 | void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector, |
361 | const Handle(Prs3d_Presentation)& aPresentation, |
362 | const TopoDS_Shape& SH) |
363 | { |
364 | if (SH.ShapeType() == TopAbs_COMPOUND) { |
365 | #ifdef BUC60547 |
366 | TopoDS_Iterator anExplor (SH); |
367 | #else |
368 | TopExp_Explorer anExplor (SH, TopAbs_VERTEX); |
369 | #endif |
370 | if (!anExplor.More()) // Shape vide -> Assemblage vide. |
371 | return; |
372 | } |
373 | |
374 | Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer(); |
375 | if (defdrawer->DrawHiddenLine()) |
376 | {myDrawer->EnableDrawHiddenLine();} |
377 | else {myDrawer->DisableDrawHiddenLine();} |
378 | |
379 | Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection(); |
380 | defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE); |
381 | |
382 | // coefficients pour le calcul |
383 | |
384 | Standard_Real prevangle, newangle ,prevcoeff,newcoeff ; |
385 | if (OwnHLRDeviationAngle(newangle,prevangle) || OwnHLRDeviationCoefficient(newcoeff, prevcoeff)) |
386 | |
387 | if (Abs (newangle - prevangle) > Precision::Angular() || |
388 | Abs (newcoeff - prevcoeff) > Precision::Confusion() ) { |
389 | #ifdef DEB |
390 | cout << "AIS_Shape : compute"<<endl; |
391 | cout << "newangle : " << newangle << " # de " << "prevangl : " << prevangle << " OU "<<endl; |
392 | cout << "newcoeff : " << newcoeff << " # de " << "prevcoeff : " << prevcoeff << endl; |
393 | #endif |
394 | BRepTools::Clean(SH); |
395 | } |
396 | |
397 | { |
398 | try { |
399 | OCC_CATCH_SIGNALS |
400 | StdPrs_HLRPolyShape::Add(aPresentation,SH,myDrawer,aProjector); |
401 | } |
402 | catch (Standard_Failure) { |
403 | #ifdef DEB |
404 | cout <<"AIS_Shape::Compute(Proj) HLR Algorithm failed" << endl; |
405 | #endif |
406 | StdPrs_WFShape::Add(aPresentation,SH,myDrawer); |
407 | } |
408 | } |
409 | |
410 | |
411 | defdrawer->SetTypeOfDeflection (prevdef); |
412 | } |
413 | |
414 | //======================================================================= |
415 | //function : SelectionType |
416 | //purpose : gives the type according to the Index of Selection Mode |
417 | //======================================================================= |
418 | |
419 | TopAbs_ShapeEnum AIS_Shape::SelectionType(const Standard_Integer aMode) |
420 | { |
421 | switch(aMode){ |
422 | case 1: |
423 | return TopAbs_VERTEX; |
424 | case 2: |
425 | return TopAbs_EDGE; |
426 | case 3: |
427 | return TopAbs_WIRE; |
428 | case 4: |
429 | return TopAbs_FACE; |
430 | case 5: |
431 | return TopAbs_SHELL; |
432 | case 6: |
433 | return TopAbs_SOLID; |
434 | case 7: |
435 | return TopAbs_COMPSOLID; |
436 | case 8: |
437 | return TopAbs_COMPOUND; |
438 | case 0: |
439 | default: |
440 | return TopAbs_SHAPE; |
441 | } |
442 | |
443 | } |
444 | //======================================================================= |
445 | //function : SelectionType |
446 | //purpose : gives the SelectionMode according to the Type od Decomposition... |
447 | //======================================================================= |
448 | Standard_Integer AIS_Shape::SelectionMode(const TopAbs_ShapeEnum aType) |
449 | { |
450 | switch(aType){ |
451 | case TopAbs_VERTEX: |
452 | return 1; |
453 | case TopAbs_EDGE: |
454 | return 2; |
455 | case TopAbs_WIRE: |
456 | return 3; |
457 | case TopAbs_FACE: |
458 | return 4; |
459 | case TopAbs_SHELL: |
460 | return 5; |
461 | case TopAbs_SOLID: |
462 | return 6; |
463 | case TopAbs_COMPSOLID: |
464 | return 7; |
465 | case TopAbs_COMPOUND: |
466 | return 8; |
467 | case TopAbs_SHAPE: |
468 | default: |
469 | return 0; |
470 | } |
471 | } |
472 | |
473 | |
474 | //======================================================================= |
475 | //function : ComputeSelection |
476 | //purpose : |
477 | //======================================================================= |
478 | |
479 | void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, |
480 | const Standard_Integer aMode) |
481 | { |
482 | if(myshape.IsNull()) return; |
483 | if (myshape.ShapeType() == TopAbs_COMPOUND) { |
484 | #ifdef BUC60547 |
485 | TopoDS_Iterator anExplor (myshape); |
486 | #else |
487 | TopExp_Explorer anExplor (myshape, TopAbs_VERTEX); |
488 | #endif |
489 | if (!anExplor.More()) // Shape vide -> Assemblage vide. |
490 | return; |
491 | } |
492 | |
493 | static TopAbs_ShapeEnum TypOfSel; |
494 | TypOfSel = AIS_Shape::SelectionType(aMode); |
495 | TopoDS_Shape shape = myshape; |
496 | #ifdef IMP040200 |
497 | if( HasTransformation() ) { |
498 | Handle(Geom_Transformation) trsf = Transformation(); |
499 | shape = shape.Located(TopLoc_Location(trsf->Trsf())*shape.Location()); |
500 | } |
501 | #endif |
502 | |
503 | // POP on protege contre un plantage dans les couches basses |
504 | |
505 | Standard_Real aDeflection = myDrawer->MaximalChordialDeviation(); |
506 | if (myDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE) |
507 | { |
508 | // On calcule la fleche en fonction des min max globaux de la piece: |
509 | Bnd_Box aBndBox; //= BoundingBox(); ? |
510 | BRepBndLib::Add (shape, aBndBox); |
511 | if (!aBndBox.IsVoid()) |
512 | { |
513 | Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; |
514 | aBndBox.Get (aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); |
515 | aDeflection = Max (aXmax - aXmin, Max (aYmax - aYmin, aZmax - aZmin)) * myDrawer->DeviationCoefficient(); |
516 | } |
517 | } |
518 | |
519 | Standard_Boolean autoTriangulation = Standard_True; |
520 | try { |
521 | OCC_CATCH_SIGNALS |
522 | StdSelect_BRepSelectionTool::Load(aSelection, |
523 | this, |
524 | shape, |
525 | TypOfSel, |
526 | aDeflection, |
527 | myDrawer->DeviationAngle(), |
528 | autoTriangulation); |
529 | } catch ( Standard_Failure ) { |
530 | // cout << "a Shape should be incorrect : A Selection on the Bnd is activated "<<endl; |
531 | if ( aMode == 0 ) { |
532 | Bnd_Box B = BoundingBox(); |
533 | Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(shape,this); |
534 | Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox(aOwner,B); |
535 | aSelection->Add(aSensitiveBox); |
536 | } |
537 | } |
538 | |
539 | // insert the drawer in the BrepOwners for hilight... |
540 | StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer); |
541 | } |
542 | |
543 | #ifdef GER61351 |
544 | Quantity_NameOfColor AIS_Shape::Color() const { |
545 | Quantity_Color aColor; |
546 | Color(aColor); |
547 | return aColor.Name(); |
548 | } |
549 | |
550 | void AIS_Shape::Color( Quantity_Color& aColor ) const { |
551 | aColor = myDrawer->ShadingAspect()->Color(myCurrentFacingModel); |
552 | } |
553 | |
554 | Graphic3d_NameOfMaterial AIS_Shape::Material() const { |
555 | return (myDrawer->ShadingAspect()->Material(myCurrentFacingModel)).Name(); |
556 | } |
557 | |
558 | Standard_Real AIS_Shape::Transparency() const { |
559 | return myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel); |
560 | } |
561 | #endif |
562 | |
563 | //======================================================================= |
564 | //function : SetColor |
565 | //purpose : |
566 | //======================================================================= |
567 | |
568 | void AIS_Shape::SetColor(const Quantity_NameOfColor aCol) |
569 | #ifdef GER61351 |
570 | { |
571 | SetColor(Quantity_Color(aCol)); |
572 | } |
573 | |
574 | void AIS_Shape::SetColor(const Quantity_Color &aCol) |
575 | #endif |
576 | { |
577 | hasOwnColor = Standard_True; |
578 | #ifdef GER61351 |
579 | if( !HasColor() && !IsTransparent() && !HasMaterial() ) { |
580 | myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); |
581 | } |
582 | #else |
583 | myOwnColor = aCol; |
584 | if(!myDrawer->HasShadingAspect()){ |
585 | Handle(Prs3d_ShadingAspect) asp = new Prs3d_ShadingAspect(); |
586 | // recuperons le materiau reference... |
587 | if(myDrawer->HasLink()){ |
588 | const Handle(Prs3d_Drawer)& refdr = myDrawer->Link(); |
589 | Graphic3d_MaterialAspect theRefMat = |
590 | refdr->ShadingAspect()->Aspect()->FrontMaterial(); |
591 | theRefMat.SetTransparency(myTransparency); |
592 | asp->SetMaterial(theRefMat); |
593 | } |
594 | |
595 | myDrawer->SetShadingAspect(asp); |
596 | } |
597 | #endif |
598 | |
599 | #ifdef GER61351 |
600 | myDrawer->ShadingAspect()->SetColor(aCol,myCurrentFacingModel); |
601 | #else |
602 | myDrawer->ShadingAspect()->SetColor(aCol); |
603 | #endif |
604 | myDrawer->SetShadingAspectGlobal(Standard_False); |
605 | |
606 | Standard_Real WW = HasWidth()? Width():AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line); |
607 | |
608 | myDrawer->SetLineAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW)); |
609 | myDrawer->SetWireAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW)); |
610 | myDrawer->SetFreeBoundaryAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW)); |
611 | myDrawer->SetUnFreeBoundaryAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW)); |
612 | myDrawer->SetSeenLineAspect(new Prs3d_LineAspect(aCol,Aspect_TOL_SOLID,WW)); |
613 | |
614 | // modif du shading rapide... |
615 | if(!GetContext().IsNull()){ |
616 | if( GetContext()->MainPrsMgr()->HasPresentation(this,1)){ |
617 | Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); |
618 | Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); |
619 | Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect(); |
620 | #ifdef BUC60577 |
621 | P->SetPrimitivesAspect(a4bis); |
622 | G->SetGroupPrimitivesAspect(a4bis); |
623 | #else |
624 | a4bis->SetInteriorColor(Quantity_Color(aCol)); // Already done above in SetColor(...) |
625 | |
626 | //***test rob : pour avoir la vraie couleur demandee en shading *** |
627 | // mais du coup, le shading est "plat" ...**** |
628 | // Graphic3d_MaterialAspect FMAT = a4bis->FrontMaterial(); |
629 | // FMAT.SetColor(Quantity_Color(aCol)); |
630 | // a4bis->SetFrontMaterial(FMAT); |
631 | //****** |
632 | |
633 | P->SetPrimitivesAspect(myDrawer->ShadingAspect()->Aspect()); |
634 | G->SetGroupPrimitivesAspect(myDrawer->ShadingAspect()->Aspect()); |
635 | #endif |
636 | } |
637 | } |
638 | |
639 | LoadRecomputable(0); |
640 | LoadRecomputable(2); |
641 | } |
642 | //======================================================================= |
643 | //function : UnsetColor |
644 | //purpose : |
645 | //======================================================================= |
646 | |
647 | void AIS_Shape::UnsetColor() |
648 | { |
649 | // Evitons les stupidites... |
650 | if(!HasColor() ){ myToRecomputeModes.Clear(); |
651 | return;} |
652 | |
653 | hasOwnColor = Standard_False; |
654 | |
655 | Handle(Prs3d_LineAspect) NullAsp; |
656 | Handle(Prs3d_ShadingAspect) NullShA; |
657 | |
658 | if(!HasWidth()){ |
659 | myDrawer->SetLineAspect(NullAsp); |
660 | myDrawer->SetWireAspect(NullAsp); |
661 | myDrawer->SetFreeBoundaryAspect(NullAsp); |
662 | myDrawer->SetUnFreeBoundaryAspect(NullAsp); |
663 | myDrawer->SetSeenLineAspect(NullAsp); |
664 | } |
665 | else{ |
666 | #ifdef GER61351 |
667 | Quantity_Color CC; |
668 | AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); |
669 | myDrawer->LineAspect()->SetColor(CC); |
670 | AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Wire,CC); |
671 | myDrawer->WireAspect()->SetColor(CC); |
672 | AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Free,CC); |
673 | myDrawer->FreeBoundaryAspect()->SetColor(CC); |
674 | AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_UnFree,CC); |
675 | myDrawer->UnFreeBoundaryAspect()->SetColor(CC); |
676 | AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen,CC); |
677 | myDrawer->SeenLineAspect()->SetColor(CC); |
678 | #else |
679 | myDrawer->LineAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line)); |
680 | myDrawer->WireAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Wire)); |
681 | myDrawer->FreeBoundaryAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Free)); |
682 | myDrawer->UnFreeBoundaryAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_UnFree)); |
683 | myDrawer->SeenLineAspect()->SetColor(AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen)); |
684 | #endif |
685 | } |
686 | |
687 | if(myDrawer->HasShadingAspect()){ |
688 | myDrawer->SetShadingAspect(NullShA); |
689 | } |
690 | |
691 | if(!GetContext().IsNull()){ |
692 | if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){ |
693 | Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); |
694 | Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); |
695 | |
696 | Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->Link()->ShadingAspect()->Aspect(); |
697 | #ifdef GER61351 |
698 | Quantity_Color CC; |
699 | AIS_GraphicTool::GetInteriorColor(myDrawer->Link(),CC); |
700 | a4bis->SetInteriorColor(CC); |
701 | #else |
702 | Quantity_NameOfColor KOL = AIS_GraphicTool::GetInteriorColor(myDrawer->Link()); |
703 | a4bis->SetInteriorColor(Quantity_Color(KOL)); |
704 | #endif |
705 | P->SetPrimitivesAspect(a4bis); |
706 | G->SetGroupPrimitivesAspect(a4bis); |
707 | } |
708 | } |
709 | LoadRecomputable(0); |
710 | LoadRecomputable(2); |
711 | |
712 | } |
713 | |
714 | |
715 | //======================================================================= |
716 | //function : SetWidth |
717 | //purpose : |
718 | //======================================================================= |
719 | |
720 | void AIS_Shape::SetWidth(const Standard_Real W) |
721 | { |
722 | if(HasColor() || HasWidth()){ |
723 | myDrawer->LineAspect()->SetWidth(W); |
724 | myDrawer->WireAspect()->SetWidth(W); |
725 | myDrawer->FreeBoundaryAspect()->SetWidth(W); |
726 | myDrawer->UnFreeBoundaryAspect()->SetWidth(W); |
727 | myDrawer->SeenLineAspect()->SetWidth(W); |
728 | } |
729 | else{ |
730 | #ifdef GER61351 |
731 | Quantity_Color CC; |
732 | AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line,CC); |
733 | myDrawer->SetLineAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W)); |
734 | AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Wire,CC); |
735 | myDrawer->SetWireAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W)); |
736 | AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Free,CC); |
737 | myDrawer->SetFreeBoundaryAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W)); |
738 | AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_UnFree,CC); |
739 | myDrawer->SetUnFreeBoundaryAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W)); |
740 | AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen,CC); |
741 | myDrawer->SetSeenLineAspect(new Prs3d_LineAspect(CC,Aspect_TOL_SOLID,W)); |
742 | #else |
743 | Quantity_NameOfColor KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Line); |
744 | myDrawer->SetLineAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W)); |
745 | |
746 | KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Wire); |
747 | myDrawer->SetWireAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W)); |
748 | |
749 | KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Free); |
750 | myDrawer->SetFreeBoundaryAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W)); |
751 | |
752 | KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_UnFree); |
753 | myDrawer->SetUnFreeBoundaryAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W)); |
754 | |
755 | KOL = AIS_GraphicTool::GetLineColor(myDrawer->Link(),AIS_TOA_Seen); |
756 | myDrawer->SetSeenLineAspect(new Prs3d_LineAspect(KOL,Aspect_TOL_SOLID,W)); |
757 | #endif |
758 | } |
759 | myOwnWidth = W; |
760 | LoadRecomputable(0); // signifier qu'il faut recalculer uniquement le wireframe.... |
761 | LoadRecomputable(2); // et la boite englobante... |
762 | |
763 | } |
764 | |
765 | //======================================================================= |
766 | //function : UnsetWidth |
767 | //purpose : |
768 | //======================================================================= |
769 | |
770 | void AIS_Shape::UnsetWidth() |
771 | { |
772 | if(myOwnWidth== 0.0){ myToRecomputeModes.Clear(); |
773 | return;} |
774 | myOwnWidth=0.0; |
775 | Handle(Prs3d_LineAspect) NullAsp; |
776 | |
777 | if(!HasColor()){ |
778 | myDrawer->SetLineAspect(NullAsp); |
779 | myDrawer->SetWireAspect(NullAsp); |
780 | myDrawer->SetFreeBoundaryAspect(NullAsp); |
781 | myDrawer->SetUnFreeBoundaryAspect(NullAsp); |
782 | myDrawer->SetSeenLineAspect(NullAsp); |
783 | } |
784 | else{ |
785 | myDrawer->LineAspect()->SetWidth(AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Line)); |
786 | myDrawer->WireAspect()->SetWidth(AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Wire)); |
787 | myDrawer->FreeBoundaryAspect()->SetWidth(AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Free)); |
788 | myDrawer->UnFreeBoundaryAspect()->SetWidth(AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_UnFree)); |
789 | myDrawer->SeenLineAspect()->SetWidth(AIS_GraphicTool::GetLineWidth(myDrawer->Link(),AIS_TOA_Seen)); |
790 | } |
791 | LoadRecomputable(0); |
792 | } |
793 | |
794 | |
795 | //======================================================================= |
796 | //function : SetMaterial |
797 | //purpose : |
798 | //======================================================================= |
799 | void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat) |
800 | { |
801 | #ifdef GER61351 |
802 | if( !HasColor() && !IsTransparent() && !HasMaterial() ) { |
803 | myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); |
804 | } |
805 | myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel); |
806 | hasOwnMaterial = Standard_True; |
807 | #else |
808 | AIS_InteractiveObject::SetMaterial(aMat); |
809 | #endif |
810 | if(!GetContext().IsNull()){ |
811 | if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){ |
812 | Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); |
813 | Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); |
814 | |
815 | Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect(); |
816 | P->SetPrimitivesAspect(a4bis); |
817 | G->SetGroupPrimitivesAspect(a4bis); |
818 | } |
819 | } |
820 | myRecomputeEveryPrs =Standard_False; // aucun mode a recalculer :uniquement update viewer |
821 | myToRecomputeModes.Clear(); |
822 | } |
823 | //======================================================================= |
824 | //function : SetMaterial |
825 | //purpose : |
826 | //======================================================================= |
827 | void AIS_Shape::SetMaterial(const Graphic3d_MaterialAspect& aMat) |
828 | { |
829 | #ifdef GER61351 |
830 | if( !HasColor() && !IsTransparent() && !HasMaterial() ) { |
831 | myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); |
832 | } |
833 | myDrawer->ShadingAspect()->SetMaterial(aMat,myCurrentFacingModel); |
834 | hasOwnMaterial = Standard_True; |
835 | #else |
836 | AIS_InteractiveObject::SetMaterial(aMat); |
837 | #endif |
838 | if(!GetContext().IsNull()){ |
839 | if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){ |
840 | Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); |
841 | Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); |
842 | |
843 | Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect(); |
844 | P->SetPrimitivesAspect(a4bis); |
845 | G->SetGroupPrimitivesAspect(a4bis); |
846 | } |
847 | } |
848 | myRecomputeEveryPrs =Standard_False; // aucun mode a recalculer :uniquement update viewer |
849 | myToRecomputeModes.Clear(); |
850 | } |
851 | |
852 | //======================================================================= |
853 | //function : UnsetMaterial |
854 | //purpose : |
855 | //======================================================================= |
856 | void AIS_Shape::UnsetMaterial() |
857 | { |
858 | #ifdef GER61351 |
859 | if( !HasMaterial() ) return; |
860 | if( HasColor() || IsTransparent()) { |
861 | Graphic3d_MaterialAspect mat = AIS_GraphicTool::GetMaterial(myDrawer->Link()); |
862 | if( HasColor() ) { |
863 | Quantity_Color color = myDrawer->ShadingAspect()->Color(myCurrentFacingModel); |
864 | mat.SetColor(color); |
865 | } |
866 | if( IsTransparent() ) { |
867 | Standard_Real trans = myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel); |
868 | mat.SetTransparency(trans); |
869 | } |
870 | myDrawer->ShadingAspect()->SetMaterial(mat,myCurrentFacingModel); |
871 | } else { |
872 | Handle(Prs3d_ShadingAspect) SA; |
873 | myDrawer->SetShadingAspect(SA); |
874 | } |
875 | hasOwnMaterial = Standard_False; |
876 | #else |
877 | AIS_InteractiveObject::UnsetMaterial(); |
878 | #endif |
879 | if(!GetContext().IsNull()){ |
880 | |
881 | if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){ |
882 | Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); |
883 | Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); |
884 | |
885 | Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect(); |
886 | P->SetPrimitivesAspect(a4bis); |
887 | G->SetGroupPrimitivesAspect(a4bis); |
888 | } |
889 | } |
890 | myRecomputeEveryPrs =Standard_False; // aucun mode a recalculer :uniquement update viewer |
891 | myToRecomputeModes.Clear(); |
892 | |
893 | } |
894 | //======================================================================= |
895 | //function : SetTransparency |
896 | //purpose : |
897 | //======================================================================= |
898 | |
899 | void AIS_Shape::SetTransparency(const Standard_Real AValue) |
900 | { |
901 | #ifdef GER61351 |
902 | if(!HasColor() && !HasMaterial() ) { |
903 | myDrawer->SetShadingAspect(new Prs3d_ShadingAspect()); |
904 | } |
905 | myDrawer->ShadingAspect()->SetTransparency(AValue,myCurrentFacingModel); |
906 | myTransparency = AValue; |
907 | #else |
908 | AIS_InteractiveObject::SetTransparency(AValue); |
909 | #endif |
910 | if(!GetContext().IsNull()){ |
911 | if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){ |
912 | Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); |
913 | Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); |
914 | |
915 | Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect(); |
916 | P->SetPrimitivesAspect(a4bis); |
917 | #ifdef BUC60918 //force highest priority for transparent objects |
918 | P->SetDisplayPriority(10); |
919 | #endif |
920 | G->SetGroupPrimitivesAspect(a4bis); |
921 | } |
922 | } |
923 | myRecomputeEveryPrs =Standard_False; // aucun mode a recalculer :uniquement update viewer |
924 | myToRecomputeModes.Clear(); |
925 | |
926 | } |
927 | |
928 | //======================================================================= |
929 | //function : UnsetTransparency |
930 | //purpose : |
931 | //======================================================================= |
932 | void AIS_Shape::UnsetTransparency() |
933 | { |
934 | #ifdef GER61351 |
935 | if(HasColor() || HasMaterial() ) { |
936 | myDrawer->ShadingAspect()->SetTransparency(0.0,myCurrentFacingModel); |
937 | } else { |
938 | Handle(Prs3d_ShadingAspect) SA; |
939 | myDrawer->SetShadingAspect(SA); |
940 | } |
941 | myTransparency = 0.0; |
942 | #else |
943 | AIS_InteractiveObject::UnsetTransparency(); |
944 | #endif |
945 | if(!GetContext().IsNull()){ |
946 | |
947 | if(GetContext()->MainPrsMgr()->HasPresentation(this,1)){ |
948 | Handle(Prs3d_Presentation) P = GetContext()->MainPrsMgr()->CastPresentation(this,1)->Presentation(); |
949 | Handle(Graphic3d_Group) G = Prs3d_Root::CurrentGroup(P); |
950 | |
951 | Handle(Graphic3d_AspectFillArea3d) a4bis = myDrawer->ShadingAspect()->Aspect(); |
952 | P->SetPrimitivesAspect(a4bis); |
953 | G->SetGroupPrimitivesAspect(a4bis); |
954 | #ifdef BUC60918 |
955 | P->ResetDisplayPriority(); |
956 | #endif |
957 | } |
958 | } |
959 | myRecomputeEveryPrs =Standard_False; // aucun mode a recalculer :uniquement update viewer |
960 | myToRecomputeModes.Clear(); |
961 | } |
962 | |
963 | |
964 | void AIS_Shape::LoadRecomputable(const Standard_Integer TheMode) |
965 | { |
966 | myRecomputeEveryPrs =Standard_False; |
967 | if(!IsInList(myToRecomputeModes,TheMode)) |
968 | myToRecomputeModes.Append(TheMode); |
969 | } |
970 | |
971 | |
972 | |
973 | //======================================================================= |
974 | //function : BoundingBox |
975 | //purpose : |
976 | //======================================================================= |
977 | |
978 | const Bnd_Box& AIS_Shape::BoundingBox() |
979 | { |
980 | if (myshape.ShapeType() == TopAbs_COMPOUND) { |
981 | #ifdef BUC60547 |
982 | TopoDS_Iterator anExplor (myshape); |
983 | #else |
984 | TopExp_Explorer anExplor (myshape, TopAbs_VERTEX); |
985 | #endif |
986 | if (!anExplor.More()) { // Shape vide -> Assemblage vide. |
987 | myBB.SetVoid(); |
988 | return myBB; |
989 | } |
990 | } |
991 | |
992 | if(myCompBB) { |
993 | BRepBndLib::AddClose(myshape, myBB); |
994 | myCompBB = Standard_False; |
995 | } |
996 | return myBB; |
997 | } |
998 | |
999 | //***** |
1000 | //***** Reset |
1001 | //======================================================================= |
1002 | //function : SetOwnDeviationCoefficient |
1003 | //purpose : resets myhasOwnDeviationCoefficient to Standard_False and |
1004 | // returns Standard_True if it change |
1005 | //======================================================================= |
1006 | |
1007 | Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient () |
1008 | { |
1009 | Standard_Boolean itSet = myDrawer->IsOwnDeviationCoefficient(); |
1010 | if(itSet) myDrawer->SetDeviationCoefficient(); |
1011 | return itSet; |
1012 | |
1013 | } |
1014 | |
1015 | |
1016 | //======================================================================= |
1017 | //function : SetHLROwnDeviationCoefficient |
1018 | //purpose : resets myhasOwnHLRDeviationCoefficient to Standard_False and |
1019 | // returns Standard_True if it change |
1020 | //======================================================================= |
1021 | |
1022 | Standard_Boolean AIS_Shape::SetOwnHLRDeviationCoefficient () |
1023 | { |
1024 | Standard_Boolean itSet = myDrawer->IsOwnHLRDeviationCoefficient(); |
1025 | if(itSet) myDrawer->SetHLRDeviationCoefficient(); |
1026 | return itSet; |
1027 | |
1028 | } |
1029 | |
1030 | //======================================================================= |
1031 | //function : SetOwnDeviationAngle |
1032 | //purpose : resets myhasOwnDeviationAngle to Standard_False and |
1033 | // returns Standard_True if it change |
1034 | //======================================================================= |
1035 | |
1036 | Standard_Boolean AIS_Shape::SetOwnDeviationAngle () |
1037 | { |
1038 | Standard_Boolean itSet = myDrawer->IsOwnDeviationAngle(); |
1039 | if(itSet) myDrawer->SetDeviationAngle(); |
1040 | return itSet; |
1041 | |
1042 | } |
1043 | |
1044 | //======================================================================= |
1045 | //function : SetOwnHLRDeviationAngle |
1046 | //purpose : resets myhasOwnHLRDeviationAngle to Standard_False and |
1047 | // returns Standard_True if it change |
1048 | //======================================================================= |
1049 | |
1050 | Standard_Boolean AIS_Shape::SetOwnHLRDeviationAngle () |
1051 | { |
1052 | Standard_Boolean itSet = myDrawer->IsOwnHLRDeviationAngle(); |
1053 | if(itSet) myDrawer->SetHLRAngle(); |
1054 | return itSet; |
1055 | |
1056 | } |
1057 | //***** SetOwn |
1058 | //======================================================================= |
1059 | //function : SetOwnDeviationCoefficient |
1060 | //purpose : |
1061 | //======================================================================= |
1062 | |
1063 | void AIS_Shape::SetOwnDeviationCoefficient ( const Standard_Real aCoefficient ) |
1064 | { |
1065 | myDrawer->SetDeviationCoefficient( aCoefficient ); |
1066 | SetToUpdate(0) ; // WireFrame |
1067 | SetToUpdate(1) ; // Shadding |
1068 | } |
1069 | |
1070 | //======================================================================= |
1071 | //function : SetOwnHLRDeviationCoefficient |
1072 | //purpose : |
1073 | //======================================================================= |
1074 | |
1075 | void AIS_Shape::SetOwnHLRDeviationCoefficient ( const Standard_Real aCoefficient ) |
1076 | { |
1077 | myDrawer->SetHLRDeviationCoefficient( aCoefficient ); |
1078 | |
1079 | } |
1080 | |
1081 | //======================================================================= |
1082 | //function : SetOwnDeviationAngle |
1083 | //purpose : |
1084 | //======================================================================= |
1085 | |
1086 | void AIS_Shape::SetOwnDeviationAngle ( const Standard_Real anAngle ) |
1087 | { |
1088 | |
1089 | myDrawer->SetDeviationAngle(anAngle ); |
1090 | SetToUpdate(0) ; // WireFrame |
1091 | } |
1092 | //======================================================================= |
1093 | //function : SetOwnDeviationAngle |
1094 | //purpose : |
1095 | //======================================================================= |
1096 | |
1097 | void AIS_Shape::SetAngleAndDeviation ( const Standard_Real anAngle ) |
1098 | { |
1099 | Standard_Real OutAngl,OutDefl; |
1100 | HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl); |
1101 | SetOwnDeviationAngle(anAngle) ; |
1102 | // SetOwnDeviationAngle(OutAngl) ; |
1103 | SetOwnDeviationCoefficient(OutDefl) ; |
1104 | myInitAng = anAngle; |
1105 | SetToUpdate(0); |
1106 | SetToUpdate(1); |
1107 | } |
1108 | |
1109 | //======================================================================= |
1110 | //function : UserAngle |
1111 | //purpose : |
1112 | //======================================================================= |
1113 | |
1114 | Standard_Real AIS_Shape::UserAngle() const |
1115 | { |
1116 | return myInitAng ==0. ? GetContext()->DeviationAngle(): myInitAng; |
1117 | } |
1118 | |
1119 | |
1120 | //======================================================================= |
1121 | //function : SetHLRAngleAndDeviation |
1122 | //purpose : |
1123 | //======================================================================= |
1124 | |
1125 | void AIS_Shape::SetHLRAngleAndDeviation ( const Standard_Real anAngle ) |
1126 | { |
1127 | Standard_Real OutAngl,OutDefl; |
1128 | HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl); |
1129 | SetOwnHLRDeviationAngle( OutAngl ); |
1130 | SetOwnHLRDeviationCoefficient(OutDefl); |
1131 | |
1132 | } |
1133 | //======================================================================= |
1134 | //function : SetOwnHLRDeviationAngle |
1135 | //purpose : |
1136 | //======================================================================= |
1137 | |
1138 | void AIS_Shape::SetOwnHLRDeviationAngle ( const Standard_Real anAngle ) |
1139 | { |
1140 | myDrawer->SetHLRAngle( anAngle ); |
1141 | } |
1142 | |
1143 | //***** GetOwn |
1144 | //======================================================================= |
1145 | //function : OwnDeviationCoefficient |
1146 | //purpose : |
1147 | //======================================================================= |
1148 | |
1149 | Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real & aCoefficient, |
1150 | Standard_Real & aPreviousCoefficient ) const |
1151 | { |
1152 | aCoefficient = myDrawer->DeviationCoefficient(); |
1153 | aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient (); |
1154 | return myDrawer->IsOwnDeviationCoefficient() ; |
1155 | } |
1156 | |
1157 | //======================================================================= |
1158 | //function : OwnHLRDeviationCoefficient |
1159 | //purpose : |
1160 | //======================================================================= |
1161 | |
1162 | Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoefficient, |
1163 | Standard_Real & aPreviousCoefficient ) const |
1164 | { |
1165 | aCoefficient = myDrawer->HLRDeviationCoefficient(); |
1166 | aPreviousCoefficient = myDrawer->PreviousHLRDeviationCoefficient (); |
1167 | return myDrawer->IsOwnHLRDeviationCoefficient(); |
1168 | |
1169 | } |
1170 | |
1171 | //======================================================================= |
1172 | //function : OwnDeviationAngle |
1173 | //purpose : |
1174 | //======================================================================= |
1175 | |
1176 | Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real & anAngle, |
1177 | Standard_Real & aPreviousAngle ) const |
1178 | { |
1179 | anAngle = myDrawer->DeviationAngle(); |
1180 | aPreviousAngle = myDrawer->PreviousDeviationAngle (); |
1181 | return myDrawer->IsOwnDeviationAngle(); |
1182 | } |
1183 | |
1184 | //======================================================================= |
1185 | //function : OwnHLRDeviationAngle |
1186 | //purpose : |
1187 | //======================================================================= |
1188 | |
1189 | Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real & anAngle, |
1190 | Standard_Real & aPreviousAngle ) const |
1191 | { |
1192 | anAngle = myDrawer->HLRAngle(); |
1193 | aPreviousAngle = myDrawer->PreviousHLRDeviationAngle (); |
1194 | return myDrawer->IsOwnHLRDeviationAngle(); |
1195 | |
1196 | } |