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