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