0026163: Visualization - AIS_Shape::SetWidth() should not overwrite the free boundary...
[occt.git] / src / AIS / AIS_Shape.cxx
CommitLineData
b311480e 1// Created on: 1996-12-20
2// Created by: Robert COUBLANC
3// Copyright (c) 1996-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17#include <AIS_Shape.ixx>
18
19
20#include <Standard_ErrorHandler.hxx>
21#include <OSD_Timer.hxx>
22#include <TColStd_ListIteratorOfListOfInteger.hxx>
23
24#include <Quantity_Color.hxx>
25
26#include <gp_Pnt.hxx>
27#include <Bnd_Box.hxx>
28#include <BRep_Builder.hxx>
29#include <BRepTools_ShapeSet.hxx>
30#include <BRepTools.hxx>
31#include <BRepBndLib.hxx>
32#include <TopExp.hxx>
33#include <TopExp_Explorer.hxx>
34
35#include <Aspect_TypeOfLine.hxx>
36#include <Graphic3d_Structure.hxx>
37#include <Graphic3d_Group.hxx>
38#include <Graphic3d_AspectLine3d.hxx>
39#include <Graphic3d_AspectText3d.hxx>
40#include <Graphic3d_AspectMarker3d.hxx>
41#include <Graphic3d_AspectFillArea3d.hxx>
b8ddfc2f 42#include <Graphic3d_ArrayOfPolylines.hxx>
7fd59977 43#include <Graphic3d_MaterialAspect.hxx>
48cc825e 44#include <Graphic3d_SequenceOfGroup.hxx>
7fd59977 45
9dba391d 46#include <Prs3d.hxx>
7fd59977 47#include <Prs3d_Presentation.hxx>
48#include <Prs3d_Root.hxx>
49#include <Prs3d_ShadingAspect.hxx>
50#include <Prs3d_Drawer.hxx>
51#include <Prs3d_IsoAspect.hxx>
52
7fd59977 53#include <StdPrs_WFShape.hxx>
54#include <StdPrs_WFDeflectionShape.hxx>
55#include <StdPrs_ShadedShape.hxx>
56#include <StdPrs_HLRShape.hxx>
57#include <StdPrs_HLRPolyShape.hxx>
58
59#include <PrsMgr_ModedPresentation.hxx>
60
61#include <Select3D_SensitiveEntity.hxx>
62#include <StdSelect.hxx>
63#include <StdSelect_BRepSelectionTool.hxx>
64#include <StdSelect_BRepOwner.hxx>
65#include <StdSelect_DisplayMode.hxx>
66
67#include <AIS_GraphicTool.hxx>
68#include <AIS_InteractiveContext.hxx>
7fd59977 69#include <HLRBRep.hxx>
70#include <Precision.hxx>
71
72#include <Standard_Failure.hxx>
73#include <Standard_ErrorHandler.hxx>
74#include <Select3D_SensitiveBox.hxx>
7fd59977 75#include <TopoDS_Iterator.hxx>
7fd59977 76
77static Standard_Boolean myFirstCompute;
78
7fd59977 79static Standard_Boolean IsInList(const TColStd_ListOfInteger& LL, const Standard_Integer aMode)
80{
81 TColStd_ListIteratorOfListOfInteger It(LL);
82 for(;It.More();It.Next()){
83 if(It.Value()==aMode)
84 return Standard_True;}
85 return Standard_False;
86}
87
88//==================================================
89// Function:
90// Purpose :
91//==================================================
92
93AIS_Shape::
94AIS_Shape(const TopoDS_Shape& shap):
95AIS_InteractiveObject(PrsMgr_TOP_ProjectorDependant),
7fd59977 96myInitAng(0.)
97{
6262338c 98 Set (shap);
7fd59977 99 myFirstCompute = Standard_True;
100 SetHilightMode(0);
101 myDrawer->SetShadingAspectGlobal(Standard_False);
102}
103
104//=======================================================================
105//function : Type
106//purpose :
107//=======================================================================
108AIS_KindOfInteractive AIS_Shape::Type() const
109{return AIS_KOI_Shape;}
110
111
112//=======================================================================
113//function : Signature
114//purpose :
115//=======================================================================
116Standard_Integer AIS_Shape::Signature() const
117{return 0;}
118
119//=======================================================================
120//function : AcceptShapeDecomposition
121//purpose :
122//=======================================================================
123Standard_Boolean AIS_Shape::AcceptShapeDecomposition() const
124{return Standard_True;}
125
126//=======================================================================
127//function : Compute
128//purpose :
129//=======================================================================
130void AIS_Shape::Compute(const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
3c34883c
O
131 const Handle(Prs3d_Presentation)& aPrs,
132 const Standard_Integer aMode)
7fd59977 133{
134 aPrs->Clear();
135 if(myshape.IsNull()) return;
136
137 // wire,edge,vertex -> pas de HLR + priorite display superieure
138 Standard_Integer TheType = (Standard_Integer) myshape.ShapeType();
139 if(TheType>4 && TheType<8) {
140 aPrs->SetVisual(Graphic3d_TOS_ALL);
141 aPrs->SetDisplayPriority(TheType+2);
142 }
143 // Shape vide -> Assemblage vide.
144 if (myshape.ShapeType() == TopAbs_COMPOUND) {
7fd59977 145 TopoDS_Iterator anExplor (myshape);
a10fa819 146
7fd59977 147 if (!anExplor.More()) {
148 return;
149 }
150 }
a10fa819 151
81bba717 152 if (IsInfinite()) aPrs->SetInfiniteState(Standard_True); //not taken in account duting FITALL
7fd59977 153 switch (aMode) {
154 case 0:{
155 try { OCC_CATCH_SIGNALS StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer); }
156 catch (Standard_Failure) {
0797d9d3 157#ifdef OCCT_DEBUG
7fd59977 158 cout << "AIS_Shape::Compute() failed"<< endl;
7fd59977 159 cout << "a Shape should be incorrect : No Compute can be maked on it "<< endl;
63c629aa 160#endif
81bba717 161// presentation of the bounding box is calculated
7fd59977 162// Compute(aPresentationManager,aPrs,2);
163 }
164 break;
165 }
166 case 1:
167 {
4c513386 168 if (myDrawer->IsAutoTriangulation())
ad3217cd 169 {
4c513386 170 Standard_Real anAnglePrev, anAngleNew, aCoeffPrev, aCoeffNew;
171 Standard_Boolean isOwnDeviationAngle = OwnDeviationAngle (anAngleNew, anAnglePrev);
172 Standard_Boolean isOwnDeviationCoefficient = OwnDeviationCoefficient(aCoeffNew, aCoeffPrev);
173 if ((isOwnDeviationAngle && Abs (anAngleNew - anAnglePrev) > Precision::Angular())
174 || (isOwnDeviationCoefficient && Abs (aCoeffNew - aCoeffPrev) > Precision::Confusion()))
175 {
176 BRepTools::Clean (myshape);
177 }
bbf847ad 178 }
ad3217cd 179
81bba717 180 //shading only on face...
7fd59977 181 if ((Standard_Integer) myshape.ShapeType()>4)
3c34883c 182 StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
7fd59977 183 else {
3c34883c
O
184 myDrawer->SetShadingAspectGlobal(Standard_False);
185 if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
186 else {
187 {
188 try {
189 OCC_CATCH_SIGNALS
190 StdPrs_ShadedShape::Add(aPrs,myshape,myDrawer);
191 }
192 catch (Standard_Failure) {
0797d9d3 193#ifdef OCCT_DEBUG
3c34883c 194 cout << "AIS_Shape::Compute() in ShadingMode failed"<< endl;
7fd59977 195#endif
3c34883c
O
196 StdPrs_WFShape::Add(aPrs,myshape,myDrawer);
197 }
198 }
199 }
7fd59977 200 }
7fd59977 201 Standard_Real value = Transparency() ;
202 if( value > 0. ) {
3c34883c 203 SetTransparency( value );
7fd59977 204 }
7fd59977 205 break;
206 }
207 case 2:
208 {
81bba717 209 // bounding box
7fd59977 210 if (IsInfinite()) StdPrs_WFDeflectionShape::Add(aPrs,myshape,myDrawer);
d33222c1 211 else StdPrs_WFDeflectionRestrictedFace::AddBox (aPrs, BoundingBox(), myDrawer);
7fd59977 212 }
7fd59977 213 } // end switch
214 aPrs->ReCompute(); // for hidden line recomputation if necessary...
7fd59977 215}
216
7fd59977 217//=======================================================================
218//function : Compute
219//purpose : Hidden Line Removal
220//=======================================================================
221void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
3c34883c 222 const Handle(Prs3d_Presentation)& aPresentation)
7fd59977 223{
224 Compute(aProjector,aPresentation,myshape);
225}
226
227//=======================================================================
228//function : Compute
229//purpose :
230//=======================================================================
231
232void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
3c34883c
O
233 const Handle(Geom_Transformation)& TheTrsf,
234 const Handle(Prs3d_Presentation)& aPresentation)
7fd59977 235{
236 const TopLoc_Location& loc = myshape.Location();
237 TopoDS_Shape shbis = myshape.Located(TopLoc_Location(TheTrsf->Trsf())*loc);
238 Compute(aProjector,aPresentation,shbis);
239}
240
241//=======================================================================
242//function : Compute
243//purpose :
244//=======================================================================
245
246void AIS_Shape::Compute(const Handle(Prs3d_Projector)& aProjector,
3c34883c
O
247 const Handle(Prs3d_Presentation)& aPresentation,
248 const TopoDS_Shape& SH)
7fd59977 249{
250 if (SH.ShapeType() == TopAbs_COMPOUND) {
7fd59977 251 TopoDS_Iterator anExplor (SH);
a10fa819 252
7fd59977 253 if (!anExplor.More()) // Shape vide -> Assemblage vide.
254 return;
255 }
a10fa819 256
7fd59977 257 Handle (Prs3d_Drawer) defdrawer = GetContext()->DefaultDrawer();
6262338c 258 if (defdrawer->DrawHiddenLine())
7fd59977 259 {myDrawer->EnableDrawHiddenLine();}
260 else {myDrawer->DisableDrawHiddenLine();}
a10fa819 261
7fd59977 262 Aspect_TypeOfDeflection prevdef = defdrawer->TypeOfDeflection();
263 defdrawer->SetTypeOfDeflection(Aspect_TOD_RELATIVE);
264
4c513386 265 if (myDrawer->IsAutoTriangulation())
266 {
267 // coefficients for calculation
268 Standard_Real aPrevAngle, aNewAngle, aPrevCoeff, aNewCoeff;
269 Standard_Boolean isOwnHLRDeviationAngle = OwnHLRDeviationAngle (aNewAngle, aPrevAngle);
270 Standard_Boolean isOwnHLRDeviationCoefficient = OwnHLRDeviationCoefficient (aNewCoeff, aPrevCoeff);
271 if (((Abs (aNewAngle - aPrevAngle) > Precision::Angular()) && isOwnHLRDeviationAngle) ||
272 ((Abs (aNewCoeff - aPrevCoeff) > Precision::Confusion()) && isOwnHLRDeviationCoefficient))
273 {
7fd59977 274 BRepTools::Clean(SH);
275 }
4c513386 276 }
7fd59977 277
278 {
279 try {
280 OCC_CATCH_SIGNALS
0a768f56 281 switch (TypeOfHLR()) {
282 case Prs3d_TOH_Algo:
283 StdPrs_HLRShape::Add (aPresentation, SH, myDrawer, aProjector);
284 break;
285 case Prs3d_TOH_PolyAlgo:
286 default:
287 StdPrs_HLRPolyShape::Add (aPresentation, SH, myDrawer, aProjector);
288 break;
289 }
7fd59977 290 }
291 catch (Standard_Failure) {
0797d9d3 292#ifdef OCCT_DEBUG
7fd59977 293 cout <<"AIS_Shape::Compute(Proj) HLR Algorithm failed" << endl;
294#endif
295 StdPrs_WFShape::Add(aPresentation,SH,myDrawer);
296 }
297 }
298
7fd59977 299 defdrawer->SetTypeOfDeflection (prevdef);
300}
301
302//=======================================================================
303//function : SelectionType
304//purpose : gives the type according to the Index of Selection Mode
305//=======================================================================
306
307TopAbs_ShapeEnum AIS_Shape::SelectionType(const Standard_Integer aMode)
308{
309 switch(aMode){
310 case 1:
311 return TopAbs_VERTEX;
312 case 2:
313 return TopAbs_EDGE;
314 case 3:
315 return TopAbs_WIRE;
316 case 4:
317 return TopAbs_FACE;
318 case 5:
319 return TopAbs_SHELL;
320 case 6:
321 return TopAbs_SOLID;
322 case 7:
323 return TopAbs_COMPSOLID;
324 case 8:
325 return TopAbs_COMPOUND;
326 case 0:
327 default:
328 return TopAbs_SHAPE;
329 }
330
331}
332//=======================================================================
333//function : SelectionType
334//purpose : gives the SelectionMode according to the Type od Decomposition...
335//=======================================================================
336Standard_Integer AIS_Shape::SelectionMode(const TopAbs_ShapeEnum aType)
337{
338 switch(aType){
339 case TopAbs_VERTEX:
340 return 1;
341 case TopAbs_EDGE:
342 return 2;
343 case TopAbs_WIRE:
344 return 3;
345 case TopAbs_FACE:
346 return 4;
347 case TopAbs_SHELL:
348 return 5;
349 case TopAbs_SOLID:
350 return 6;
351 case TopAbs_COMPSOLID:
352 return 7;
353 case TopAbs_COMPOUND:
354 return 8;
355 case TopAbs_SHAPE:
356 default:
357 return 0;
358 }
359}
360
361
362//=======================================================================
363//function : ComputeSelection
364//purpose :
365//=======================================================================
366
367void AIS_Shape::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
3c34883c 368 const Standard_Integer aMode)
7fd59977 369{
370 if(myshape.IsNull()) return;
371 if (myshape.ShapeType() == TopAbs_COMPOUND) {
7fd59977 372 TopoDS_Iterator anExplor (myshape);
a10fa819 373
81bba717 374 if (!anExplor.More()) // empty Shape -> empty Assembly.
7fd59977 375 return;
376 }
377
378 static TopAbs_ShapeEnum TypOfSel;
379 TypOfSel = AIS_Shape::SelectionType(aMode);
380 TopoDS_Shape shape = myshape;
7fd59977 381
81bba717 382// POP protection against crash in low layers
7fd59977 383
9dba391d 384 Standard_Real aDeflection = Prs3d::GetDeflection(shape, myDrawer);
7fd59977 385 try {
386 OCC_CATCH_SIGNALS
387 StdSelect_BRepSelectionTool::Load(aSelection,
388 this,
389 shape,
390 TypOfSel,
391 aDeflection,
3c34883c 392 myDrawer->HLRAngle(),
4c513386 393 myDrawer->IsAutoTriangulation());
7fd59977 394 } catch ( Standard_Failure ) {
395// cout << "a Shape should be incorrect : A Selection on the Bnd is activated "<<endl;
396 if ( aMode == 0 ) {
53a70197 397 aSelection->Clear();
7fd59977 398 Bnd_Box B = BoundingBox();
399 Handle(StdSelect_BRepOwner) aOwner = new StdSelect_BRepOwner(shape,this);
400 Handle(Select3D_SensitiveBox) aSensitiveBox = new Select3D_SensitiveBox(aOwner,B);
401 aSelection->Add(aSensitiveBox);
402 }
403 }
404
405 // insert the drawer in the BrepOwners for hilight...
406 StdSelect::SetDrawerForBRepOwner(aSelection,myDrawer);
407}
408
7fd59977 409Quantity_NameOfColor AIS_Shape::Color() const {
410Quantity_Color aColor;
411 Color(aColor);
412 return aColor.Name();
413}
414
415void AIS_Shape::Color( Quantity_Color& aColor ) const {
416 aColor = myDrawer->ShadingAspect()->Color(myCurrentFacingModel);
417}
418
419Graphic3d_NameOfMaterial AIS_Shape::Material() const {
420 return (myDrawer->ShadingAspect()->Material(myCurrentFacingModel)).Name();
421}
422
423Standard_Real AIS_Shape::Transparency() const {
424 return myDrawer->ShadingAspect()->Transparency(myCurrentFacingModel);
425}
7fd59977 426
427//=======================================================================
428//function : SetColor
429//purpose :
430//=======================================================================
431
432void AIS_Shape::SetColor(const Quantity_NameOfColor aCol)
7fd59977 433{
434 SetColor(Quantity_Color(aCol));
435}
436
5cbef0fe 437//=======================================================================
ad3217cd 438//function : setColor
439//purpose :
5cbef0fe
S
440//=======================================================================
441
6262338c 442void AIS_Shape::setColor (const Handle(Prs3d_Drawer)& theDrawer,
443 const Quantity_Color& theColor) const
7fd59977 444{
6262338c 445 if (!theDrawer->HasOwnShadingAspect())
ad3217cd 446 {
447 theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
6262338c 448 if (theDrawer->HasLink())
449 {
450 *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
451 }
7fd59977 452 }
6262338c 453 if (!theDrawer->HasOwnLineAspect())
ad3217cd 454 {
455 theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
6262338c 456 if (theDrawer->HasLink())
457 {
458 *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
459 }
ad3217cd 460 }
6262338c 461 if (!theDrawer->HasOwnWireAspect())
ad3217cd 462 {
463 theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
6262338c 464 if (theDrawer->HasLink())
465 {
466 *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
467 }
ad3217cd 468 }
6262338c 469 if (!theDrawer->HasOwnPointAspect())
ad3217cd 470 {
471 theDrawer->SetPointAspect (new Prs3d_PointAspect (Aspect_TOM_POINT, Quantity_NOC_BLACK, 1.0));
6262338c 472 if (theDrawer->HasLink())
473 {
474 *theDrawer->PointAspect()->Aspect() = *theDrawer->Link()->PointAspect()->Aspect();
475 }
ad3217cd 476 }
8a5dfb38 477 if (!theDrawer->HasOwnFreeBoundaryAspect())
478 {
479 theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
480 if (theDrawer->HasLink())
481 {
482 *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
483 }
484 }
485 if (!theDrawer->HasOwnUnFreeBoundaryAspect())
486 {
487 theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
488 if (theDrawer->HasLink())
489 {
490 *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
491 }
492 }
493 if (!theDrawer->HasOwnSeenLineAspect())
494 {
495 theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
496 if (theDrawer->HasLink())
497 {
498 *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
499 }
500 }
ad3217cd 501
502 // override color
503 theDrawer->ShadingAspect()->SetColor (theColor, myCurrentFacingModel);
504 theDrawer->SetShadingAspectGlobal (Standard_False);
505 theDrawer->LineAspect()->SetColor (theColor);
506 theDrawer->WireAspect()->SetColor (theColor);
507 theDrawer->PointAspect()->SetColor (theColor);
8a5dfb38 508 theDrawer->FreeBoundaryAspect()->SetColor (theColor);
509 theDrawer->UnFreeBoundaryAspect()->SetColor (theColor);
510 theDrawer->SeenLineAspect()->SetColor (theColor);
ad3217cd 511}
a10fa819 512
ad3217cd 513//=======================================================================
514//function : SetColor
515//purpose :
516//=======================================================================
7fd59977 517
ad3217cd 518void AIS_Shape::SetColor (const Quantity_Color& theColor)
519{
520 setColor (myDrawer, theColor);
521 myOwnColor = theColor;
522 hasOwnColor = Standard_True;
7fd59977 523
48cc825e 524 // modify shading presentation without re-computation
525 const PrsMgr_Presentations& aPrsList = Presentations();
526 Handle(Graphic3d_AspectFillArea3d) anAreaAspect = myDrawer->ShadingAspect()->Aspect();
527 Handle(Graphic3d_AspectLine3d) aLineAspect = myDrawer->LineAspect()->Aspect();
528 Handle(Graphic3d_AspectMarker3d) aPointAspect = myDrawer->PointAspect()->Aspect();
529 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
ad3217cd 530 {
48cc825e 531 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
532 if (aPrsModed.Mode() != AIS_Shaded)
ad3217cd 533 {
48cc825e 534 continue;
535 }
536
537 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
538
539 // Set aspects for presentation
540 aPrs->SetPrimitivesAspect (anAreaAspect);
541 aPrs->SetPrimitivesAspect (aLineAspect);
542 aPrs->SetPrimitivesAspect (aPointAspect);
543
544 // Go through all groups to change color for all primitives
545 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
546 {
547 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
548
a10fa819
A
549 // Check if aspect of given type is set for the group,
550 // because setting aspect for group with no already set aspect
551 // can lead to loss of presentation data
48cc825e 552 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
ad3217cd 553 {
48cc825e 554 aGroup->SetGroupPrimitivesAspect (anAreaAspect);
ad3217cd 555 }
48cc825e 556 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
ad3217cd 557 {
48cc825e 558 aGroup->SetGroupPrimitivesAspect (aLineAspect);
ad3217cd 559 }
48cc825e 560 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_MARKER))
ad3217cd 561 {
48cc825e 562 aGroup->SetGroupPrimitivesAspect (aPointAspect);
ad3217cd 563 }
a10fa819 564 }
7fd59977 565 }
566
ad3217cd 567 LoadRecomputable (AIS_WireFrame);
568 LoadRecomputable (2);
7fd59977 569}
5cbef0fe 570
7fd59977 571//=======================================================================
572//function : UnsetColor
ad3217cd 573//purpose :
7fd59977 574//=======================================================================
575
576void AIS_Shape::UnsetColor()
577{
ad3217cd 578 if (!HasColor())
5cbef0fe
S
579 {
580 myToRecomputeModes.Clear();
581 return;
582 }
7fd59977 583 hasOwnColor = Standard_False;
584
ad3217cd 585 if (!HasWidth())
586 {
587 Handle(Prs3d_LineAspect) anEmptyAsp;
588 myDrawer->SetLineAspect (anEmptyAsp);
589 myDrawer->SetWireAspect (anEmptyAsp);
590 myDrawer->SetFreeBoundaryAspect (anEmptyAsp);
591 myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
592 myDrawer->SetSeenLineAspect (anEmptyAsp);
593 }
594 else
595 {
6262338c 596 Quantity_Color aColor = Quantity_NOC_YELLOW;
597 if (myDrawer->HasLink())
598 {
599 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Line, aColor);
600 }
ad3217cd 601 myDrawer->LineAspect()->SetColor (aColor);
6262338c 602 aColor = Quantity_NOC_RED;
603 if (myDrawer->HasLink())
604 {
605 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Wire, aColor);
606 }
ad3217cd 607 myDrawer->WireAspect()->SetColor (aColor);
6262338c 608 aColor = Quantity_NOC_GREEN;
609 if (myDrawer->HasLink())
610 {
611 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Free, aColor);
612 }
ad3217cd 613 myDrawer->FreeBoundaryAspect()->SetColor (aColor);
6262338c 614 aColor = Quantity_NOC_YELLOW;
615 if (myDrawer->HasLink())
616 {
617 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_UnFree, aColor);
618 }
ad3217cd 619 myDrawer->UnFreeBoundaryAspect()->SetColor (aColor);
6262338c 620 if (myDrawer->HasLink())
621 {
622 AIS_GraphicTool::GetLineColor (myDrawer->Link(), AIS_TOA_Seen, aColor);
623 }
ad3217cd 624 myDrawer->SeenLineAspect()->SetColor (aColor);
625 }
626
627 if (HasMaterial()
628 || IsTransparent())
629 {
6262338c 630 Graphic3d_MaterialAspect aDefaultMat (Graphic3d_NOM_BRASS);
631 Graphic3d_MaterialAspect mat = aDefaultMat;
632 if (HasMaterial() || myDrawer->HasLink())
633 {
634 mat = AIS_GraphicTool::GetMaterial(HasMaterial()? myDrawer : myDrawer->Link());
635 }
ad3217cd 636 if (HasMaterial())
637 {
6262338c 638 Quantity_Color aColor = aDefaultMat.AmbientColor();
639 if (myDrawer->HasLink())
640 {
4e2914a6 641 aColor = myDrawer->Link()->ShadingAspect()->Color (myCurrentFacingModel);
6262338c 642 }
ad3217cd 643 mat.SetColor (aColor);
5cbef0fe 644 }
ad3217cd 645 if (IsTransparent())
646 {
647 Standard_Real aTransp = myDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
648 mat.SetTransparency (aTransp);
5cbef0fe 649 }
ad3217cd 650 myDrawer->ShadingAspect()->SetMaterial (mat ,myCurrentFacingModel);
5cbef0fe 651 }
ad3217cd 652 else
653 {
654 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
5cbef0fe 655 }
ad3217cd 656 myDrawer->SetPointAspect (Handle(Prs3d_PointAspect)());
5cbef0fe 657
48cc825e 658 // modify shading presentation without re-computation
659 const PrsMgr_Presentations& aPrsList = Presentations();
660 Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->Link()->ShadingAspect()->Aspect();
661 Handle(Graphic3d_AspectLine3d) aLineAsp = myDrawer->Link()->LineAspect()->Aspect();
662 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
ad3217cd 663 {
48cc825e 664 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
665 if (aPrsModed.Mode() != AIS_Shaded)
ad3217cd 666 {
48cc825e 667 continue;
668 }
669
670 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
671
672 aPrs->SetPrimitivesAspect (anAreaAsp);
673 aPrs->SetPrimitivesAspect (aLineAsp);
674
675 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
676 {
677 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
678
679 // Check if aspect of given type is set for the group,
a10fa819
A
680 // because setting aspect for group with no already set aspect
681 // can lead to loss of presentation data
ad3217cd 682 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
683 {
684 aGroup->SetGroupPrimitivesAspect (anAreaAsp);
685 }
686 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_LINE))
687 {
688 aGroup->SetGroupPrimitivesAspect (aLineAsp);
689 }
7fd59977 690 }
5cbef0fe 691 }
48cc825e 692
ad3217cd 693 LoadRecomputable (AIS_WireFrame);
694 LoadRecomputable (2);
695}
696
697//=======================================================================
698//function : setWidth
699//purpose :
700//=======================================================================
701
6262338c 702void AIS_Shape::setWidth (const Handle(Prs3d_Drawer)& theDrawer,
703 const Standard_Real theLineWidth) const
ad3217cd 704{
6262338c 705 if (!theDrawer->HasOwnLineAspect())
ad3217cd 706 {
707 theDrawer->SetLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
6262338c 708 if (theDrawer->HasLink())
709 {
710 *theDrawer->LineAspect()->Aspect() = *theDrawer->Link()->LineAspect()->Aspect();
711 }
ad3217cd 712 }
6262338c 713 if (!theDrawer->HasOwnWireAspect())
ad3217cd 714 {
715 theDrawer->SetWireAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
6262338c 716 if (theDrawer->HasLink())
717 {
718 *theDrawer->WireAspect()->Aspect() = *theDrawer->Link()->WireAspect()->Aspect();
719 }
ad3217cd 720 }
8a5dfb38 721 if (!theDrawer->HasOwnFreeBoundaryAspect())
722 {
723 theDrawer->SetFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
724 if (theDrawer->HasLink())
725 {
726 *theDrawer->FreeBoundaryAspect()->Aspect() = *theDrawer->Link()->FreeBoundaryAspect()->Aspect();
727 }
728 }
729 if (!theDrawer->HasOwnUnFreeBoundaryAspect())
730 {
731 theDrawer->SetUnFreeBoundaryAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
732 if (theDrawer->HasLink())
733 {
734 *theDrawer->UnFreeBoundaryAspect()->Aspect() = *theDrawer->Link()->UnFreeBoundaryAspect()->Aspect();
735 }
736 }
737 if (!theDrawer->HasOwnSeenLineAspect())
738 {
739 theDrawer->SetSeenLineAspect (new Prs3d_LineAspect (Quantity_NOC_BLACK, Aspect_TOL_SOLID, 1.0));
740 if (theDrawer->HasLink())
741 {
742 *theDrawer->SeenLineAspect()->Aspect() = *theDrawer->Link()->SeenLineAspect()->Aspect();
743 }
744 }
ad3217cd 745
746 // override width
747 theDrawer->LineAspect()->SetWidth (theLineWidth);
748 theDrawer->WireAspect()->SetWidth (theLineWidth);
8a5dfb38 749 theDrawer->FreeBoundaryAspect()->SetWidth (theLineWidth);
750 theDrawer->UnFreeBoundaryAspect()->SetWidth (theLineWidth);
751 theDrawer->SeenLineAspect()->SetWidth (theLineWidth);
7fd59977 752}
753
7fd59977 754//=======================================================================
755//function : SetWidth
756//purpose :
757//=======================================================================
758
ad3217cd 759void AIS_Shape::SetWidth (const Standard_Real theLineWidth)
7fd59977 760{
ad3217cd 761 setWidth (myDrawer, theLineWidth);
762 myOwnWidth = theLineWidth;
763 LoadRecomputable (AIS_WireFrame); // means that it is necessary to recompute only the wireframe....
764 LoadRecomputable (2); // and the bounding box...
7fd59977 765}
766
767//=======================================================================
768//function : UnsetWidth
ad3217cd 769//purpose :
7fd59977 770//=======================================================================
771
772void AIS_Shape::UnsetWidth()
773{
ad3217cd 774 if (myOwnWidth == 0.0)
5cbef0fe
S
775 {
776 myToRecomputeModes.Clear();
777 return;
778 }
5cbef0fe 779
ad3217cd 780 myOwnWidth = 0.0;
781
782 Handle(Prs3d_LineAspect) anEmptyAsp;
5cbef0fe 783
ad3217cd 784 if (!HasColor())
785 {
786 myDrawer->SetLineAspect (anEmptyAsp);
787 myDrawer->SetWireAspect (anEmptyAsp);
788 myDrawer->SetFreeBoundaryAspect (anEmptyAsp);
789 myDrawer->SetUnFreeBoundaryAspect(anEmptyAsp);
790 myDrawer->SetSeenLineAspect (anEmptyAsp);
7fd59977 791 }
ad3217cd 792 else
793 {
6262338c 794 myDrawer->LineAspect() ->SetWidth (myDrawer->HasLink() ?
795 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Line) : 1.);
796 myDrawer->WireAspect() ->SetWidth (myDrawer->HasLink() ?
797 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Wire) : 1.);
798 myDrawer->FreeBoundaryAspect() ->SetWidth (myDrawer->HasLink() ?
799 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Free) : 1.);
800 myDrawer->UnFreeBoundaryAspect()->SetWidth (myDrawer->HasLink() ?
801 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_UnFree) : 1.);
802 myDrawer->SeenLineAspect() ->SetWidth (myDrawer->HasLink() ?
803 AIS_GraphicTool::GetLineWidth (myDrawer->Link(), AIS_TOA_Seen) : 1.);
7fd59977 804 }
ad3217cd 805 LoadRecomputable (AIS_WireFrame);
7fd59977 806}
807
e0608a8d 808//=======================================================================
809//function : setMaterial
810//purpose :
811//=======================================================================
812
6262338c 813void AIS_Shape::setMaterial (const Handle(Prs3d_Drawer)& theDrawer,
e0608a8d 814 const Graphic3d_MaterialAspect& theMaterial,
815 const Standard_Boolean theToKeepColor,
816 const Standard_Boolean theToKeepTransp) const
817{
818 const Quantity_Color aColor = theDrawer->ShadingAspect()->Material (myCurrentFacingModel).Color();
819 const Standard_Real aTransp = theDrawer->ShadingAspect()->Transparency (myCurrentFacingModel);
6262338c 820 if (!theDrawer->HasOwnShadingAspect())
e0608a8d 821 {
822 theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
6262338c 823 if (theDrawer->HasLink())
824 {
825 *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
826 }
e0608a8d 827 }
828 theDrawer->ShadingAspect()->SetMaterial (theMaterial, myCurrentFacingModel);
829
830 if (theToKeepColor)
831 {
832 theDrawer->ShadingAspect()->SetColor (aColor, myCurrentFacingModel);
833 }
834 if (theToKeepTransp)
835 {
836 theDrawer->ShadingAspect()->SetTransparency (aTransp, myCurrentFacingModel);
837 }
838}
839
7fd59977 840//=======================================================================
841//function : SetMaterial
842//purpose :
843//=======================================================================
5cbef0fe 844
7fd59977 845void AIS_Shape::SetMaterial(const Graphic3d_NameOfMaterial aMat)
846{
a10fa819 847 SetMaterial(Graphic3d_MaterialAspect(aMat));
7fd59977 848}
5cbef0fe 849
7fd59977 850//=======================================================================
851//function : SetMaterial
ad3217cd 852//purpose :
7fd59977 853//=======================================================================
5cbef0fe 854
ad3217cd 855void AIS_Shape::SetMaterial (const Graphic3d_MaterialAspect& theMat)
7fd59977 856{
e0608a8d 857 setMaterial (myDrawer, theMat, HasColor(), IsTransparent());
7fd59977 858 hasOwnMaterial = Standard_True;
5cbef0fe 859
48cc825e 860 // modify shading presentation without re-computation
861 const PrsMgr_Presentations& aPrsList = Presentations();
862 Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
863 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
ad3217cd 864 {
48cc825e 865 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
866 if (aPrsModed.Mode() != AIS_Shaded)
af324faa 867 {
48cc825e 868 continue;
869 }
870
871 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
872 aPrs->SetPrimitivesAspect (anAreaAsp);
873 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
874 {
875 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
876
a10fa819
A
877 // Check if aspect of given type is set for the group,
878 // because setting aspect for group with no already set aspect
879 // can lead to loss of presentation data
ad3217cd 880 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
881 {
882 aGroup->SetGroupPrimitivesAspect (anAreaAsp);
883 }
5cbef0fe 884 }
7fd59977 885 }
48cc825e 886
887 myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
888 myToRecomputeModes.Clear();
7fd59977 889}
ad3217cd 890
7fd59977 891//=======================================================================
892//function : UnsetMaterial
ad3217cd 893//purpose :
7fd59977 894//=======================================================================
5cbef0fe 895
7fd59977 896void AIS_Shape::UnsetMaterial()
897{
ad3217cd 898 if (!HasMaterial())
899 {
900 return;
901 }
5cbef0fe 902
ad3217cd 903 if (HasColor()
904 || IsTransparent())
905 {
6262338c 906 if(myDrawer->HasLink())
907 {
908 myDrawer->ShadingAspect()->SetMaterial (myDrawer->Link()->ShadingAspect()->Material (myCurrentFacingModel),
909 myCurrentFacingModel);
910 }
ad3217cd 911 if (HasColor())
912 {
913 myDrawer->ShadingAspect()->SetColor (myOwnColor, myCurrentFacingModel);
914 myDrawer->ShadingAspect()->SetTransparency (myTransparency, myCurrentFacingModel);
7fd59977 915 }
ad3217cd 916 }
917 else
918 {
919 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
7fd59977 920 }
921 hasOwnMaterial = Standard_False;
ad3217cd 922
48cc825e 923 // modify shading presentation without re-computation
924 const PrsMgr_Presentations& aPrsList = Presentations();
925 Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
926 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
ad3217cd 927 {
48cc825e 928 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
929 if (aPrsModed.Mode() != AIS_Shaded)
ad3217cd 930 {
48cc825e 931 continue;
932 }
933
934 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
935 aPrs->SetPrimitivesAspect (anAreaAsp);
936 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
937 {
938 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
ad3217cd 939 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
940 {
941 aGroup->SetGroupPrimitivesAspect (anAreaAsp);
942 }
7fd59977 943 }
944 }
48cc825e 945
ad3217cd 946 myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
7fd59977 947 myToRecomputeModes.Clear();
7fd59977 948}
5cbef0fe 949
7fd59977 950//=======================================================================
ad3217cd 951//function : setTransparency
952//purpose :
7fd59977 953//=======================================================================
954
6262338c 955void AIS_Shape::setTransparency (const Handle(Prs3d_Drawer)& theDrawer,
956 const Standard_Real theValue) const
7fd59977 957{
6262338c 958 if (!theDrawer->HasOwnShadingAspect())
ad3217cd 959 {
960 theDrawer->SetShadingAspect (new Prs3d_ShadingAspect());
6262338c 961 if (theDrawer->HasLink())
962 {
963 *theDrawer->ShadingAspect()->Aspect() = *theDrawer->Link()->ShadingAspect()->Aspect();
964 }
7fd59977 965 }
5cbef0fe 966
ad3217cd 967 // override transparency
968 theDrawer->ShadingAspect()->SetTransparency (theValue, myCurrentFacingModel);
969}
970
971//=======================================================================
972//function : SetTransparency
973//purpose :
974//=======================================================================
975
976void AIS_Shape::SetTransparency (const Standard_Real theValue)
977{
978 setTransparency (myDrawer, theValue);
979 myTransparency = theValue;
980
48cc825e 981 // modify shading presentation without re-computation
982 const PrsMgr_Presentations& aPrsList = Presentations();
983 Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
984 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
ad3217cd 985 {
48cc825e 986 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
987 if (aPrsModed.Mode() != AIS_Shaded)
ad3217cd 988 {
48cc825e 989 continue;
990 }
991
992 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
993 aPrs->SetPrimitivesAspect (anAreaAsp);
994 aPrs->SetDisplayPriority (10); // force highest priority for translucent objects
995 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
996 {
997 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
ad3217cd 998 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
999 {
1000 aGroup->SetGroupPrimitivesAspect (anAreaAsp);
1001 }
7fd59977 1002 }
1003 }
48cc825e 1004
ad3217cd 1005 myRecomputeEveryPrs = Standard_False; // no mode to recalculate - only viewer update
5cbef0fe 1006 myToRecomputeModes.Clear();
7fd59977 1007}
1008
1009//=======================================================================
1010//function : UnsetTransparency
ad3217cd 1011//purpose :
7fd59977 1012//=======================================================================
5cbef0fe 1013
7fd59977 1014void AIS_Shape::UnsetTransparency()
1015{
7fd59977 1016 myTransparency = 0.0;
6262338c 1017 if (!myDrawer->HasOwnShadingAspect())
ad3217cd 1018 {
1019 return;
1020 }
1021 else if (HasColor() || HasMaterial())
1022 {
1023 myDrawer->ShadingAspect()->SetTransparency (0.0, myCurrentFacingModel);
1024 }
1025 else
1026 {
1027 myDrawer->SetShadingAspect (Handle(Prs3d_ShadingAspect)());
1028 }
5cbef0fe 1029
48cc825e 1030 // modify shading presentation without re-computation
1031 const PrsMgr_Presentations& aPrsList = Presentations();
1032 Handle(Graphic3d_AspectFillArea3d) anAreaAsp = myDrawer->ShadingAspect()->Aspect();
1033 for (Standard_Integer aPrsIt = 1; aPrsIt <= aPrsList.Length(); ++aPrsIt)
ad3217cd 1034 {
48cc825e 1035 const PrsMgr_ModedPresentation& aPrsModed = aPrsList.Value (aPrsIt);
1036 if (aPrsModed.Mode() != AIS_Shaded)
ad3217cd 1037 {
48cc825e 1038 continue;
1039 }
1040
1041 const Handle(Prs3d_Presentation)& aPrs = aPrsModed.Presentation()->Presentation();
1042 aPrs->SetPrimitivesAspect (anAreaAsp);
1043 for (Graphic3d_SequenceOfGroup::Iterator aGroupIt (aPrs->Groups()); aGroupIt.More(); aGroupIt.Next())
1044 {
1045 const Handle(Graphic3d_Group)& aGroup = aGroupIt.Value();
ad3217cd 1046 if (aGroup->IsGroupPrimitivesAspectSet (Graphic3d_ASPECT_FILL_AREA))
1047 {
1048 aGroup->SetGroupPrimitivesAspect (anAreaAsp);
1049 }
7fd59977 1050 }
48cc825e 1051 aPrs->ResetDisplayPriority();
7fd59977 1052 }
48cc825e 1053
ad3217cd 1054 myRecomputeEveryPrs = Standard_False; // no mode to recalculate :only viewer update
5cbef0fe 1055 myToRecomputeModes.Clear();
7fd59977 1056}
1057
5cbef0fe
S
1058//=======================================================================
1059//function : LoadRecomputable
1060//purpose :
1061//=======================================================================
7fd59977 1062
1063void AIS_Shape::LoadRecomputable(const Standard_Integer TheMode)
1064{
5cbef0fe 1065 myRecomputeEveryPrs = Standard_False;
7fd59977 1066 if(!IsInList(myToRecomputeModes,TheMode))
1067 myToRecomputeModes.Append(TheMode);
1068}
1069
7fd59977 1070//=======================================================================
1071//function : BoundingBox
1072//purpose :
1073//=======================================================================
1074
1075const Bnd_Box& AIS_Shape::BoundingBox()
1076{
1077 if (myshape.ShapeType() == TopAbs_COMPOUND) {
7fd59977 1078 TopoDS_Iterator anExplor (myshape);
a10fa819 1079
81bba717 1080 if (!anExplor.More()) { // empty Shape -> empty Assembly.
a10fa819 1081 myBB.SetVoid();
7fd59977 1082 return myBB;
1083 }
1084 }
1085
1086 if(myCompBB) {
1087 BRepBndLib::AddClose(myshape, myBB);
a10fa819 1088 myCompBB = Standard_False;
7fd59977 1089 }
1090 return myBB;
1091}
1092
1093//*****
1094//***** Reset
1095//=======================================================================
1096//function : SetOwnDeviationCoefficient
1097//purpose : resets myhasOwnDeviationCoefficient to Standard_False and
1098// returns Standard_True if it change
1099//=======================================================================
1100
1101Standard_Boolean AIS_Shape::SetOwnDeviationCoefficient ()
1102{
6262338c 1103 Standard_Boolean itSet = myDrawer->HasOwnDeviationCoefficient();
7fd59977 1104 if(itSet) myDrawer->SetDeviationCoefficient();
1105 return itSet;
7fd59977 1106}
1107
7fd59977 1108//=======================================================================
1109//function : SetHLROwnDeviationCoefficient
1110//purpose : resets myhasOwnHLRDeviationCoefficient to Standard_False and
1111// returns Standard_True if it change
1112//=======================================================================
1113
1114Standard_Boolean AIS_Shape::SetOwnHLRDeviationCoefficient ()
1115{
6262338c 1116 Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationCoefficient();
7fd59977 1117 if(itSet) myDrawer->SetHLRDeviationCoefficient();
1118 return itSet;
1119
1120}
1121
1122//=======================================================================
1123//function : SetOwnDeviationAngle
1124//purpose : resets myhasOwnDeviationAngle to Standard_False and
1125// returns Standard_True if it change
1126//=======================================================================
1127
1128Standard_Boolean AIS_Shape::SetOwnDeviationAngle ()
1129{
6262338c 1130 Standard_Boolean itSet = myDrawer->HasOwnDeviationAngle();
7fd59977 1131 if(itSet) myDrawer->SetDeviationAngle();
1132 return itSet;
1133
1134}
1135
1136//=======================================================================
1137//function : SetOwnHLRDeviationAngle
1138//purpose : resets myhasOwnHLRDeviationAngle to Standard_False and
1139// returns Standard_True if it change
1140//=======================================================================
1141
1142Standard_Boolean AIS_Shape::SetOwnHLRDeviationAngle ()
1143{
6262338c 1144 Standard_Boolean itSet = myDrawer->HasOwnHLRDeviationAngle();
7fd59977 1145 if(itSet) myDrawer->SetHLRAngle();
1146 return itSet;
1147
1148}
1149//***** SetOwn
1150//=======================================================================
1151//function : SetOwnDeviationCoefficient
1152//purpose :
1153//=======================================================================
1154
1155void AIS_Shape::SetOwnDeviationCoefficient ( const Standard_Real aCoefficient )
1156{
1157 myDrawer->SetDeviationCoefficient( aCoefficient );
1158 SetToUpdate(0) ; // WireFrame
1159 SetToUpdate(1) ; // Shadding
1160}
1161
1162//=======================================================================
1163//function : SetOwnHLRDeviationCoefficient
1164//purpose :
1165//=======================================================================
1166
1167void AIS_Shape::SetOwnHLRDeviationCoefficient ( const Standard_Real aCoefficient )
1168{
1169 myDrawer->SetHLRDeviationCoefficient( aCoefficient );
1170
1171}
1172
1173//=======================================================================
1174//function : SetOwnDeviationAngle
1175//purpose :
1176//=======================================================================
1177
1178void AIS_Shape::SetOwnDeviationAngle ( const Standard_Real anAngle )
1179{
1180
1181 myDrawer->SetDeviationAngle(anAngle );
1182 SetToUpdate(0) ; // WireFrame
1183}
1184//=======================================================================
1185//function : SetOwnDeviationAngle
1186//purpose :
1187//=======================================================================
1188
1189void AIS_Shape::SetAngleAndDeviation ( const Standard_Real anAngle )
1190{
1191 Standard_Real OutAngl,OutDefl;
1192 HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
1193 SetOwnDeviationAngle(anAngle) ;
7fd59977 1194 SetOwnDeviationCoefficient(OutDefl) ;
1195 myInitAng = anAngle;
1196 SetToUpdate(0);
1197 SetToUpdate(1);
1198}
1199
1200//=======================================================================
1201//function : UserAngle
1202//purpose :
1203//=======================================================================
1204
1205Standard_Real AIS_Shape::UserAngle() const
1206{
1207 return myInitAng ==0. ? GetContext()->DeviationAngle(): myInitAng;
1208}
1209
1210
1211//=======================================================================
1212//function : SetHLRAngleAndDeviation
1213//purpose :
1214//=======================================================================
1215
1216void AIS_Shape::SetHLRAngleAndDeviation ( const Standard_Real anAngle )
1217{
1218 Standard_Real OutAngl,OutDefl;
1219 HLRBRep::PolyHLRAngleAndDeflection(anAngle,OutAngl,OutDefl);
1220 SetOwnHLRDeviationAngle( OutAngl );
1221 SetOwnHLRDeviationCoefficient(OutDefl);
1222
1223}
1224//=======================================================================
1225//function : SetOwnHLRDeviationAngle
1226//purpose :
1227//=======================================================================
1228
1229void AIS_Shape::SetOwnHLRDeviationAngle ( const Standard_Real anAngle )
1230{
1231 myDrawer->SetHLRAngle( anAngle );
1232}
1233
1234//***** GetOwn
1235//=======================================================================
1236//function : OwnDeviationCoefficient
1237//purpose :
1238//=======================================================================
1239
1240Standard_Boolean AIS_Shape::OwnDeviationCoefficient ( Standard_Real & aCoefficient,
3c34883c 1241 Standard_Real & aPreviousCoefficient ) const
7fd59977 1242{
1243 aCoefficient = myDrawer->DeviationCoefficient();
1244 aPreviousCoefficient = myDrawer->PreviousDeviationCoefficient ();
6262338c 1245 return myDrawer->HasOwnDeviationCoefficient() ;
7fd59977 1246}
1247
1248//=======================================================================
1249//function : OwnHLRDeviationCoefficient
1250//purpose :
1251//=======================================================================
1252
1253Standard_Boolean AIS_Shape::OwnHLRDeviationCoefficient ( Standard_Real & aCoefficient,
3c34883c 1254 Standard_Real & aPreviousCoefficient ) const
7fd59977 1255{
1256 aCoefficient = myDrawer->HLRDeviationCoefficient();
1257 aPreviousCoefficient = myDrawer->PreviousHLRDeviationCoefficient ();
6262338c 1258 return myDrawer->HasOwnHLRDeviationCoefficient();
7fd59977 1259
1260}
1261
1262//=======================================================================
1263//function : OwnDeviationAngle
1264//purpose :
1265//=======================================================================
1266
1267Standard_Boolean AIS_Shape::OwnDeviationAngle ( Standard_Real & anAngle,
3c34883c 1268 Standard_Real & aPreviousAngle ) const
7fd59977 1269{
1270 anAngle = myDrawer->DeviationAngle();
1271 aPreviousAngle = myDrawer->PreviousDeviationAngle ();
6262338c 1272 return myDrawer->HasOwnDeviationAngle();
7fd59977 1273}
1274
1275//=======================================================================
1276//function : OwnHLRDeviationAngle
1277//purpose :
1278//=======================================================================
1279
1280Standard_Boolean AIS_Shape::OwnHLRDeviationAngle ( Standard_Real & anAngle,
3c34883c 1281 Standard_Real & aPreviousAngle ) const
7fd59977 1282{
1283 anAngle = myDrawer->HLRAngle();
1284 aPreviousAngle = myDrawer->PreviousHLRDeviationAngle ();
6262338c 1285 return myDrawer->HasOwnHLRDeviationAngle();
7fd59977 1286}