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