7fd59977 |
1 | // File: AIS_Plane.cxx |
2 | // Created: Wed Aug 2 16:20:31 1995 |
3 | // Author: Arnaud BOUZY/Odile Olivier |
4 | // <adn> |
5 | |
6 | #define GER61351 //GG_171199 Enable to set an object RGB color |
7 | // instead a restricted object NameOfColor. |
8 | |
9 | #include <AIS_Plane.ixx> |
10 | |
11 | #include <TColgp_Array1OfPnt.hxx> |
12 | #include <TColgp_HArray1OfPnt.hxx> |
13 | |
14 | #include <Precision.hxx> |
15 | #include <gp_Pnt.hxx> |
16 | #include <ElSLib.hxx> |
17 | |
18 | #include <Graphic3d_Array1OfVertex.hxx> |
19 | #include <Graphic3d_Group.hxx> |
20 | #include <Prs3d_Drawer.hxx> |
21 | #include <Prs3d_LineAspect.hxx> |
22 | #include <Prs3d_PlaneAspect.hxx> |
23 | #include <Prs3d_DatumAspect.hxx> |
24 | #include <Prs3d_ShadingAspect.hxx> |
25 | #include <StdPrs_Plane.hxx> |
26 | #include <StdPrs_ShadedSurface.hxx> |
27 | |
28 | #include <Geom_Plane.hxx> |
29 | #include <GeomAdaptor_Surface.hxx> |
30 | |
31 | #include <Aspect_TypeOfLine.hxx> |
32 | #include <Graphic3d_AspectLine3d.hxx> |
33 | #include <Graphic3d_Structure.hxx> |
34 | #include <Graphic3d_MaterialAspect.hxx> |
35 | #include <Graphic3d_AspectFillArea3d.hxx> |
36 | |
37 | #include <DsgPrs_XYZPlanePresentation.hxx> |
38 | #include <DsgPrs_ShadedPlanePresentation.hxx> |
39 | #include <UnitsAPI.hxx> |
40 | |
41 | #include <SelectBasics_EntityOwner.hxx> |
42 | #include <SelectMgr_EntityOwner.hxx> |
43 | #include <Select3D_SensitiveFace.hxx> |
44 | #include <StdPrs_ShadedShape.hxx> |
45 | |
46 | #include <AIS_Drawer.hxx> |
47 | |
48 | #include <TCollection_AsciiString.hxx> |
49 | |
50 | //======================================================================= |
51 | //function : AIS_Plane |
52 | //purpose : |
53 | //======================================================================= |
54 | AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent, |
55 | const Standard_Boolean aCurrentMode): |
56 | myComponent(aComponent), |
57 | myCenter(gp_Pnt(0.,0.,0.)), |
58 | myCurrentMode(aCurrentMode), |
59 | myAutomaticPosition(Standard_True), |
60 | myTypeOfPlane(AIS_TOPL_Unknown), |
61 | myIsXYZPlane(Standard_False) |
62 | { |
63 | InitDrawerAttributes(); |
64 | } |
65 | |
66 | //======================================================================= |
67 | //function : AIS_Plane |
68 | //purpose : avec une position |
69 | //======================================================================= |
70 | AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent, |
71 | const gp_Pnt& aCenter, |
72 | const Standard_Boolean aCurrentMode): |
73 | myComponent(aComponent), |
74 | myCenter(aCenter), |
75 | myCurrentMode(aCurrentMode), |
76 | myAutomaticPosition(Standard_True), |
77 | myTypeOfPlane(AIS_TOPL_Unknown), |
78 | myIsXYZPlane(Standard_False) |
79 | { |
80 | InitDrawerAttributes(); |
81 | } |
82 | |
83 | //======================================================================= |
84 | //function : AIS_Plane |
85 | //purpose : |
86 | //======================================================================= |
87 | AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent, |
88 | const gp_Pnt& aCenter, |
89 | const gp_Pnt& aPmin, |
90 | const gp_Pnt& aPmax, |
91 | const Standard_Boolean aCurrentMode): |
92 | myComponent(aComponent), |
93 | myCenter(aCenter), |
94 | myPmin(aPmin), |
95 | myPmax(aPmax), |
96 | myCurrentMode(aCurrentMode), |
97 | myAutomaticPosition(Standard_False), |
98 | myTypeOfPlane(AIS_TOPL_Unknown), |
99 | myIsXYZPlane(Standard_False) |
100 | { |
101 | InitDrawerAttributes(); |
102 | SetHilightMode(0); |
103 | } |
104 | |
105 | //======================================================================= |
106 | //function : AIS_Plane |
107 | //purpose : XYPlane, XZPlane, YZPlane |
108 | //======================================================================= |
109 | AIS_Plane::AIS_Plane(const Handle(Geom_Axis2Placement)& aComponent, |
110 | const AIS_TypeOfPlane aPlaneType, |
111 | const Standard_Boolean aCurrentMode): |
112 | myAx2(aComponent), |
113 | myCurrentMode(aCurrentMode), |
114 | myAutomaticPosition(Standard_True), |
115 | myTypeOfPlane(aPlaneType), |
116 | myIsXYZPlane(Standard_True) |
117 | { |
118 | InitDrawerAttributes(); |
119 | ComputeFields(); |
120 | SetHilightMode(0); |
121 | |
122 | } |
123 | |
124 | |
125 | //======================================================================= |
126 | //function : SetComponent |
127 | //purpose : |
128 | //======================================================================= |
129 | |
130 | void AIS_Plane::SetComponent(const Handle(Geom_Plane)& aComponent) |
131 | { |
132 | myComponent = aComponent; |
133 | myTypeOfPlane = AIS_TOPL_Unknown; |
134 | myIsXYZPlane = Standard_False; |
135 | //myCenter = gp_Pnt(0.,0.,0.); |
136 | myAutomaticPosition = Standard_True; |
137 | } |
138 | |
139 | //======================================================================= |
140 | //function : Type |
141 | //purpose : |
142 | //======================================================================= |
143 | |
144 | AIS_KindOfInteractive AIS_Plane::Type() const |
145 | {return AIS_KOI_Datum;} |
146 | |
147 | |
148 | //======================================================================= |
149 | //function : Signature |
150 | //purpose : |
151 | //======================================================================= |
152 | |
153 | Standard_Integer AIS_Plane::Signature() const |
154 | {return 7;} |
155 | |
156 | |
157 | //======================================================================= |
158 | //function : Axis2Placement |
159 | //purpose : |
160 | //======================================================================= |
161 | |
162 | Handle(Geom_Axis2Placement) AIS_Plane::Axis2Placement() |
163 | { |
164 | Handle(Geom_Axis2Placement) Bid; |
165 | return IsXYZPlane() ? myAx2:Bid; |
166 | } |
167 | //======================================================================= |
168 | //function : SetAxis2Placement |
169 | //purpose : |
170 | //======================================================================= |
171 | |
172 | void AIS_Plane::SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent, |
173 | const AIS_TypeOfPlane aPlaneType) |
174 | { |
175 | myTypeOfPlane = aPlaneType; |
176 | myIsXYZPlane = Standard_True; |
177 | myAx2= aComponent; |
178 | myAutomaticPosition = Standard_True; |
179 | ComputeFields(); |
180 | } |
181 | |
182 | //======================================================================= |
183 | //function : PlaneAttributes |
184 | //purpose : |
185 | //======================================================================= |
186 | Standard_Boolean AIS_Plane::PlaneAttributes(Handle(Geom_Plane)& aComponent, |
187 | gp_Pnt& aCenter, |
188 | gp_Pnt& aPmin, |
189 | gp_Pnt& aPmax) |
190 | { |
191 | Standard_Boolean aStatus (Standard_False); |
192 | if (!myAutomaticPosition){ |
193 | aComponent = myComponent; |
194 | aCenter = myCenter; |
195 | aPmin = myPmin; |
196 | aPmax = myPmax; |
197 | aStatus = Standard_True; |
198 | } |
199 | return aStatus; |
200 | } |
201 | |
202 | //======================================================================= |
203 | //function : SetPlaneAttributes |
204 | //purpose : |
205 | //======================================================================= |
206 | void AIS_Plane::SetPlaneAttributes(const Handle(Geom_Plane)& aComponent, |
207 | const gp_Pnt& aCenter, |
208 | const gp_Pnt& aPmin, |
209 | const gp_Pnt& aPmax) |
210 | { |
211 | myAutomaticPosition = Standard_False; |
212 | myComponent = aComponent; |
213 | myCenter = aCenter; |
214 | myPmin = aPmin; |
215 | myPmax = aPmax; |
216 | myTypeOfPlane = AIS_TOPL_Unknown; |
217 | myIsXYZPlane = Standard_False; |
218 | } |
219 | |
220 | //======================================================================= |
221 | //function : Compute |
222 | //purpose : |
223 | //======================================================================= |
224 | void AIS_Plane::Compute(const Handle(PrsMgr_PresentationManager3d)& , |
225 | const Handle(Prs3d_Presentation)& aPresentation, |
226 | const Standard_Integer aMode) |
227 | { |
228 | aPresentation->Clear(); |
229 | |
230 | ComputeFields(); |
231 | aPresentation->SetInfiniteState(myInfiniteState); |
232 | if (myCurrentMode) |
233 | myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(3); |
234 | else |
235 | myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(1); |
236 | if(aMode == 0){ |
237 | if (!myIsXYZPlane){ |
238 | ComputeFrame(); |
239 | const Handle(Geom_Plane)& pl = myComponent; |
240 | const Handle(Geom_Plane)& thegoodpl = Handle(Geom_Plane)::DownCast |
241 | (pl->Translated(pl->Location(),myCenter)); |
242 | GeomAdaptor_Surface surf(thegoodpl); |
243 | StdPrs_Plane::Add(aPresentation,surf,myDrawer); |
244 | } |
245 | else { |
246 | DsgPrs_XYZPlanePresentation::Add(aPresentation,myDrawer,myCenter,myPmin,myPmax); |
247 | } |
248 | } |
249 | else if (aMode == 1){ |
250 | if (!myIsXYZPlane){ |
251 | ComputeFrame(); |
7fd59977 |
252 | Handle(Prs3d_PlaneAspect) theaspect = myDrawer->PlaneAspect(); |
253 | Handle(Graphic3d_Group) TheGroup = Prs3d_Root::CurrentGroup(aPresentation); |
254 | gp_Pnt p1; |
255 | Standard_Real Xmax,Ymax; |
256 | Xmax = Standard_Real(theaspect->PlaneXLength())/2.; |
257 | Ymax = Standard_Real(theaspect->PlaneYLength())/2.; |
258 | static Graphic3d_Array1OfVertex vertices(1,5); |
259 | TheGroup->SetPrimitivesAspect(myDrawer->ShadingAspect()->Aspect()); |
260 | myComponent->D0(-Xmax,Ymax,p1); |
261 | vertices(1).SetCoord(p1.X(),p1.Y(),p1.Z()); |
262 | vertices(5).SetCoord(p1.X(),p1.Y(),p1.Z()); |
263 | myComponent->D0(Xmax,Ymax,p1); |
264 | vertices(2).SetCoord(p1.X(),p1.Y(),p1.Z()); |
265 | myComponent->D0(Xmax,-Ymax,p1); |
266 | vertices(3).SetCoord(p1.X(),p1.Y(),p1.Z()); |
267 | myComponent->D0(-Xmax,-Ymax,p1); |
268 | vertices(4).SetCoord(p1.X(),p1.Y(),p1.Z()); |
269 | TheGroup->Polygon(vertices); |
270 | |
271 | } |
272 | else{ |
273 | DsgPrs_ShadedPlanePresentation::Add(aPresentation,myDrawer,myCenter,myPmin,myPmax); |
274 | |
275 | } |
276 | } |
277 | |
278 | } |
279 | |
280 | void AIS_Plane::Compute(const Handle_Prs3d_Projector& aProjector, const Handle_Geom_Transformation& aTransformation, const Handle_Prs3d_Presentation& aPresentation) |
281 | { |
282 | // Standard_NotImplemented::Raise("AIS_Plane::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)"); |
283 | PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ; |
284 | } |
285 | |
286 | //======================================================================= |
287 | //function : ComputeSelection |
288 | //purpose : |
289 | //======================================================================= |
290 | void AIS_Plane::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection, |
291 | const Standard_Integer) |
292 | { |
293 | aSelection->Clear(); |
294 | Handle(SelectMgr_EntityOwner) eown = new SelectMgr_EntityOwner(this,10); |
295 | Handle(Select3D_SensitiveFace) sfac; |
296 | |
297 | if (!myIsXYZPlane){ |
298 | |
299 | Handle(TColgp_HArray1OfPnt) harr = new TColgp_HArray1OfPnt(1,5); |
300 | TColgp_Array1OfPnt& arr = harr->ChangeArray1(); |
301 | Standard_Real lx = myDrawer->PlaneAspect()->PlaneXLength()/2.; |
302 | Standard_Real ly = myDrawer->PlaneAspect()->PlaneYLength()/2.; |
303 | const Handle(Geom_Plane)& pl = myComponent; |
304 | const Handle(Geom_Plane)& thegoodpl = Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter)); |
305 | |
306 | thegoodpl->D0(lx,ly,arr(1)); |
307 | thegoodpl->D0(lx,-ly,arr(2)); |
308 | thegoodpl->D0(-lx,-ly,arr(3)); |
309 | thegoodpl->D0(-lx,ly,arr(4)); |
310 | arr(5) = arr(1); |
311 | sfac = new Select3D_SensitiveFace(eown,harr,Select3D_TOS_BOUNDARY); |
312 | |
313 | } |
314 | else { |
315 | Handle(TColgp_HArray1OfPnt) harr1 = new TColgp_HArray1OfPnt(1,4); |
316 | TColgp_Array1OfPnt& arr1 = harr1->ChangeArray1(); |
317 | |
318 | arr1(1) = myCenter; |
319 | arr1(2) = myPmin; |
320 | arr1(3) = myPmax; |
321 | arr1(4) = myCenter; |
322 | sfac = new Select3D_SensitiveFace(eown,harr1,Select3D_TOS_BOUNDARY); |
323 | |
324 | } |
325 | aSelection->Add(sfac); |
326 | } |
327 | |
328 | |
329 | |
330 | |
331 | //======================================================================= |
332 | //function : SetSize |
333 | //purpose : |
334 | //======================================================================= |
335 | void AIS_Plane::SetSize(const Standard_Real aLength) |
336 | { |
337 | SetSize(aLength,aLength); |
338 | } |
339 | |
340 | void AIS_Plane::SetSize(const Standard_Real aXLength, |
341 | const Standard_Real aYLength) |
342 | { |
81bba717 |
343 | //if the plane already has a proper color or size, |
344 | //there is already a specific PlaneAspect and DatumAspect |
7fd59977 |
345 | |
346 | Handle(Prs3d_PlaneAspect) PA; |
347 | Handle(Prs3d_DatumAspect) DA; |
348 | |
349 | PA = myDrawer->PlaneAspect(); |
350 | DA = myDrawer->DatumAspect(); |
351 | |
352 | Standard_Boolean yenavaitPA(Standard_True),yenavaitDA(Standard_True); |
353 | if(myDrawer->Link()->PlaneAspect() == PA){ |
354 | yenavaitPA = Standard_False; |
355 | PA = new Prs3d_PlaneAspect();} |
356 | if(myDrawer->Link()->DatumAspect() == DA){ |
357 | yenavaitDA = Standard_False; |
358 | DA = new Prs3d_DatumAspect(); |
359 | } |
360 | |
361 | PA->SetPlaneLength(aXLength,aYLength); |
362 | DA->SetAxisLength(aXLength,aYLength,aXLength); |
363 | |
364 | if(!yenavaitPA) |
365 | myDrawer->SetPlaneAspect(PA); |
366 | if(!yenavaitDA) |
367 | myDrawer->SetDatumAspect(DA); |
368 | |
369 | |
370 | myHasOwnSize = Standard_True; |
371 | Update(); |
372 | UpdateSelection(); |
373 | } |
374 | |
375 | |
376 | //======================================================================= |
377 | //function : UnsetSize |
81bba717 |
378 | //purpose : If there is a color, the size is restaured from the drawer of the context... |
7fd59977 |
379 | //======================================================================= |
380 | void AIS_Plane::UnsetSize() |
381 | { |
382 | |
383 | if(!myHasOwnSize) return; |
384 | if(!hasOwnColor){ |
385 | myDrawer->PlaneAspect().Nullify(); |
386 | myDrawer->DatumAspect().Nullify(); |
387 | } |
388 | else{ |
389 | const Handle(Prs3d_PlaneAspect)& PA = myDrawer->Link()->PlaneAspect(); |
390 | const Handle(Prs3d_DatumAspect)& DA = myDrawer->Link()->DatumAspect(); |
391 | |
392 | myDrawer->PlaneAspect()->SetPlaneLength(PA->PlaneXLength(),PA->PlaneYLength()); |
393 | myDrawer->DatumAspect()->SetAxisLength(DA->FirstAxisLength(), |
394 | DA->SecondAxisLength(), |
395 | DA->ThirdAxisLength()); |
396 | } |
397 | |
398 | myHasOwnSize = Standard_False; |
399 | Update(); |
400 | UpdateSelection(); |
401 | |
402 | } |
403 | |
404 | //======================================================================= |
405 | //function : Size |
406 | //purpose : |
407 | //======================================================================= |
408 | |
409 | Standard_Boolean AIS_Plane::Size(Standard_Real& X,Standard_Real& Y) const |
410 | { |
411 | X = myDrawer->PlaneAspect()->PlaneXLength(); |
412 | Y = myDrawer->PlaneAspect()->PlaneYLength(); |
413 | return Abs(X-Y)<=Precision::Confusion(); |
414 | } |
415 | |
416 | |
417 | //======================================================================= |
418 | //function : SetColor |
419 | //purpose : |
420 | //======================================================================= |
421 | |
422 | |
423 | void AIS_Plane::SetColor(const Quantity_NameOfColor aCol) |
424 | #ifdef GER61351 |
425 | { |
426 | SetColor(Quantity_Color(aCol)); |
427 | } |
428 | |
429 | void AIS_Plane::SetColor(const Quantity_Color &aCol) |
430 | #endif |
431 | { |
81bba717 |
432 | // if the plane already has its proper size, there is an already created planeaspect |
7fd59977 |
433 | // Standard_Boolean yenadeja = hasOwnColor || myHasOwnSize; |
434 | Handle(Prs3d_PlaneAspect) PA; |
435 | Handle(Prs3d_DatumAspect) DA; |
436 | |
437 | PA = myDrawer->PlaneAspect(); |
438 | DA = myDrawer->DatumAspect(); |
439 | |
440 | Standard_Boolean yenavaitPA(Standard_True),yenavaitDA(Standard_True); |
441 | if(myDrawer->Link()->PlaneAspect() == PA){ |
442 | yenavaitPA = Standard_False; |
443 | PA = new Prs3d_PlaneAspect();} |
444 | if(myDrawer->Link()->DatumAspect() == DA){ |
445 | yenavaitDA = Standard_False; |
446 | DA = new Prs3d_DatumAspect(); |
447 | } |
448 | |
449 | PA->EdgesAspect()->SetColor(aCol); |
450 | DA->FirstAxisAspect()->SetColor(aCol); |
451 | DA->SecondAxisAspect()->SetColor(aCol); |
452 | DA->ThirdAxisAspect()->SetColor(aCol); |
453 | |
454 | if(!yenavaitPA) |
455 | myDrawer->SetPlaneAspect(PA); |
456 | if(!yenavaitDA) |
457 | myDrawer->SetDatumAspect(DA); |
458 | |
459 | myDrawer->ShadingAspect()->SetColor(aCol); |
460 | |
461 | hasOwnColor=Standard_True; |
462 | myOwnColor = aCol; |
463 | } |
464 | //======================================================================= |
465 | //function : SetColor |
466 | //purpose : |
467 | //======================================================================= |
468 | void AIS_Plane::UnsetColor() |
469 | { |
470 | if(!hasOwnColor) return; |
471 | if(!myHasOwnSize){ |
472 | myDrawer->PlaneAspect().Nullify(); |
473 | myDrawer->DatumAspect().Nullify(); |
474 | } |
475 | else{ |
476 | const Handle(Prs3d_PlaneAspect)& PA = myDrawer->Link()->PlaneAspect(); |
477 | // const Handle(Prs3d_DatumAspect)& DA = myDrawer->Link()->DatumAspect(); |
478 | Quantity_Color C;Aspect_TypeOfLine T;Standard_Real W; |
479 | PA->EdgesAspect()->Aspect()->Values(C,T,W); |
480 | Quantity_NameOfColor Col = C.Name(); |
481 | myDrawer->PlaneAspect()->EdgesAspect()->SetColor(Col); |
482 | |
483 | myDrawer->DatumAspect()->FirstAxisAspect()->SetColor(Col); |
484 | myDrawer->DatumAspect()->SecondAxisAspect()->SetColor(Col); |
485 | myDrawer->DatumAspect()->ThirdAxisAspect()->SetColor(Col); |
486 | } |
487 | |
488 | |
489 | hasOwnColor=Standard_False; |
490 | |
491 | } |
492 | |
493 | //======================================================================= |
494 | //function : ComputeFrame |
495 | //purpose : |
496 | //======================================================================= |
497 | void AIS_Plane::ComputeFrame() |
498 | { |
499 | |
500 | const Handle(Geom_Plane)& pl = myComponent; |
501 | Standard_Real U,V; |
502 | |
503 | if (myAutomaticPosition) { |
504 | ElSLib::Parameters(pl->Pln(),myCenter,U,V); |
505 | pl->D0 (U, V, myCenter); |
506 | } |
507 | else { |
508 | const Handle(Geom_Plane)& thegoodpl = |
509 | Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter)); |
510 | ElSLib::Parameters(thegoodpl->Pln(),myPmin,U,V); |
511 | |
512 | U = 2.4*Abs(U); |
513 | V = 2.4*Abs(V); |
514 | if (U < 10*Precision::Confusion()) U=0.1; |
515 | if (V < 10*Precision::Confusion()) V=0.1; |
516 | SetSize(U,V); |
517 | myDrawer->PlaneAspect()->SetPlaneLength(U,V); |
518 | } |
519 | } |
520 | |
521 | //======================================================================= |
522 | //function : Compute |
523 | //purpose : to avoid warning |
524 | //======================================================================= |
525 | void AIS_Plane::Compute(const Handle(PrsMgr_PresentationManager2d)&, |
526 | const Handle(Graphic2d_GraphicObject)&, |
527 | const Standard_Integer) |
528 | { |
529 | } |
530 | |
531 | //======================================================================= |
532 | //function : Compute |
533 | //purpose : to avoid warning |
534 | //======================================================================= |
535 | void AIS_Plane::Compute(const Handle(Prs3d_Projector)&, |
536 | const Handle(Prs3d_Presentation)&) |
537 | { |
538 | } |
539 | |
540 | //======================================================================= |
541 | //function : ComputeFields |
542 | //purpose : |
543 | //======================================================================= |
544 | void AIS_Plane::ComputeFields() |
545 | { |
546 | if (myIsXYZPlane){ |
547 | Handle (Prs3d_DatumAspect) DA = myDrawer->DatumAspect(); |
548 | |
549 | gp_Pnt Orig = myAx2->Ax2().Location(); |
550 | gp_Dir oX = myAx2->Ax2().XDirection(); |
551 | gp_Dir oY = myAx2->Ax2().YDirection(); |
552 | gp_Dir oZ = myAx2->Ax2().Direction(); |
553 | myCenter = Orig; |
554 | Standard_Real xo,yo,zo,x1,y1,z1,x2,y2,z2,x3,y3,z3,x4=0,y4=0,z4=0; |
555 | Standard_Real x5=0,y5=0,z5=0; |
556 | Orig.Coord(xo,yo,zo); |
557 | oX.Coord(x1,y1,z1); |
558 | oY.Coord(x2,y2,z2); |
559 | oZ.Coord(x3,y3,z3); |
560 | Standard_Real DS1 = DA->FirstAxisLength(); |
561 | Standard_Real DS2 = DA->SecondAxisLength(); |
562 | Standard_Real DS3 = DA->ThirdAxisLength(); |
563 | // gp_Pnt aPt2,aPt3; |
564 | |
565 | switch (myTypeOfPlane) { |
566 | case AIS_TOPL_XYPlane: |
567 | { |
568 | gp_Pln XYP(0,0,1,0); |
569 | myComponent = new Geom_Plane(XYP); |
570 | x4=xo+x1*DS1; y4=yo+y1*DS1; z4=zo+z1*DS1; |
571 | x5=xo+x2*DS2; y5=yo+y2*DS2; z5=zo+z2*DS2; |
572 | break; |
573 | } |
574 | case AIS_TOPL_XZPlane: |
575 | { |
576 | gp_Pln XZP(0,1,0,0); |
577 | myComponent = new Geom_Plane(XZP); |
578 | x4=xo+x1*DS1; y4=yo+y1*DS1; z4=zo+z1*DS1; |
579 | x5=xo+x3*DS3; y5=yo+y3*DS3; z5=zo+z3*DS3; |
580 | break; |
581 | } |
582 | case AIS_TOPL_YZPlane: |
583 | { |
584 | gp_Pln XZP(1,0,0,0); |
585 | myComponent = new Geom_Plane(XZP); |
586 | x4=xo+x2*DS2; y4=yo+y2*DS2; z4=zo+z2*DS2; |
587 | x5=xo+x3*DS3; y5=yo+y3*DS3; z5=zo+z3*DS3; |
588 | break; |
589 | } |
590 | default: |
591 | break; |
592 | } |
593 | myPmin.SetCoord(x4,y4,z4); |
594 | myPmax.SetCoord(x5,y5,z5); |
595 | } |
596 | |
597 | } |
598 | //======================================================================= |
599 | //function : InitDrawerAttributes |
600 | //purpose : |
601 | //======================================================================= |
602 | |
603 | void AIS_Plane::InitDrawerAttributes() |
604 | { |
605 | |
606 | Handle(Prs3d_ShadingAspect) shasp = new Prs3d_ShadingAspect(); |
607 | shasp->SetMaterial(Graphic3d_NOM_PLASTIC); |
608 | shasp->SetColor(Quantity_NOC_GRAY40); |
609 | myDrawer->SetShadingAspect(shasp); |
610 | Handle(Graphic3d_AspectFillArea3d) asf = shasp->Aspect(); |
611 | Graphic3d_MaterialAspect asp = asf->FrontMaterial(); |
612 | asp.SetTransparency(0.8); |
613 | asf->SetFrontMaterial(asp); |
614 | asf->SetBackMaterial(asp); |
615 | |
616 | |
617 | } |
618 | |
619 | //======================================================================= |
620 | //function : AcceptDisplayMode |
621 | //purpose : |
622 | //======================================================================= |
623 | |
624 | Standard_Boolean AIS_Plane:: |
625 | AcceptDisplayMode(const Standard_Integer aMode) const |
626 | {return aMode == 0;} |
627 | |
628 | |
629 | //======================================================================= |
630 | //function : SetContext |
631 | //purpose : |
632 | //======================================================================= |
633 | |
634 | void AIS_Plane::SetContext(const Handle(AIS_InteractiveContext)& Ctx) |
635 | { |
636 | AIS_InteractiveObject::SetContext(Ctx); |
637 | ComputeFields(); |
638 | |
639 | } |