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