0033661: Data Exchange, Step Import - Tessellated GDTs are not imported
[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
87432b82 17#include <AIS_Plane.hxx>
7fd59977 18
42cf5bc1 19#include <AIS_InteractiveContext.hxx>
42cf5bc1 20#include <DsgPrs_ShadedPlanePresentation.hxx>
21#include <DsgPrs_XYZPlanePresentation.hxx>
7fd59977 22#include <ElSLib.hxx>
42cf5bc1 23#include <Geom_Axis2Placement.hxx>
24#include <Geom_Plane.hxx>
42cf5bc1 25#include <GeomAdaptor_Surface.hxx>
26#include <gp_Pnt.hxx>
b8ddfc2f 27#include <Graphic3d_ArrayOfQuadrangles.hxx>
42cf5bc1 28#include <Graphic3d_AspectFillArea3d.hxx>
29#include <Graphic3d_AspectLine3d.hxx>
7fd59977 30#include <Graphic3d_Group.hxx>
42cf5bc1 31#include <Graphic3d_MaterialAspect.hxx>
32#include <Graphic3d_Structure.hxx>
b06da8f1 33#include <Graphic3d_TransformPersScaledAbove.hxx>
42cf5bc1 34#include <Poly_Triangulation.hxx>
35#include <Precision.hxx>
36#include <Prs3d_DatumAspect.hxx>
7fd59977 37#include <Prs3d_Drawer.hxx>
38#include <Prs3d_LineAspect.hxx>
39#include <Prs3d_PlaneAspect.hxx>
42cf5bc1 40#include <Prs3d_Presentation.hxx>
7fd59977 41#include <Prs3d_ShadingAspect.hxx>
42cf5bc1 42#include <Quantity_Color.hxx>
51f8f60c 43#include <Select3D_SensitiveTriangulation.hxx>
7fd59977 44#include <SelectMgr_EntityOwner.hxx>
42cf5bc1 45#include <Standard_Type.hxx>
46#include <StdPrs_Plane.hxx>
42cf5bc1 47#include <TColgp_Array1OfPnt.hxx>
7fd59977 48
92efcf78 49IMPLEMENT_STANDARD_RTTIEXT(AIS_Plane,AIS_InteractiveObject)
50
7fd59977 51//=======================================================================
52//function : AIS_Plane
53//purpose :
54//=======================================================================
55AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent,
56 const Standard_Boolean aCurrentMode):
57myComponent(aComponent),
58myCenter(gp_Pnt(0.,0.,0.)),
59myCurrentMode(aCurrentMode),
60myAutomaticPosition(Standard_True),
61myTypeOfPlane(AIS_TOPL_Unknown),
9e8804b6 62myIsXYZPlane(Standard_False),
63myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
7fd59977 64{
65 InitDrawerAttributes();
66}
67
68//=======================================================================
69//function : AIS_Plane
70//purpose : avec une position
71//=======================================================================
72AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent,
73 const gp_Pnt& aCenter,
74 const Standard_Boolean aCurrentMode):
75myComponent(aComponent),
76myCenter(aCenter),
77myCurrentMode(aCurrentMode),
78myAutomaticPosition(Standard_True),
79myTypeOfPlane(AIS_TOPL_Unknown),
9e8804b6 80myIsXYZPlane(Standard_False),
81myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
7fd59977 82{
83 InitDrawerAttributes();
84}
85
86//=======================================================================
87//function : AIS_Plane
88//purpose :
89//=======================================================================
90AIS_Plane::AIS_Plane(const Handle(Geom_Plane)& aComponent,
91 const gp_Pnt& aCenter,
92 const gp_Pnt& aPmin,
93 const gp_Pnt& aPmax,
94 const Standard_Boolean aCurrentMode):
95myComponent(aComponent),
96myCenter(aCenter),
97myPmin(aPmin),
98myPmax(aPmax),
99myCurrentMode(aCurrentMode),
100myAutomaticPosition(Standard_False),
101myTypeOfPlane(AIS_TOPL_Unknown),
9e8804b6 102myIsXYZPlane(Standard_False),
103myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
7fd59977 104{
105 InitDrawerAttributes();
7fd59977 106}
107
108//=======================================================================
109//function : AIS_Plane
110//purpose : XYPlane, XZPlane, YZPlane
111//=======================================================================
112AIS_Plane::AIS_Plane(const Handle(Geom_Axis2Placement)& aComponent,
113 const AIS_TypeOfPlane aPlaneType,
114 const Standard_Boolean aCurrentMode):
115myAx2(aComponent),
116myCurrentMode(aCurrentMode),
117myAutomaticPosition(Standard_True),
118myTypeOfPlane(aPlaneType),
9e8804b6 119myIsXYZPlane(Standard_True),
120myTypeOfSensitivity (Select3D_TOS_BOUNDARY)
7fd59977 121{
122 InitDrawerAttributes();
123 ComputeFields();
7fd59977 124}
125
126
127//=======================================================================
128//function : SetComponent
129//purpose :
130//=======================================================================
131
132void AIS_Plane::SetComponent(const Handle(Geom_Plane)& aComponent)
133{
134 myComponent = aComponent;
135 myTypeOfPlane = AIS_TOPL_Unknown;
136 myIsXYZPlane = Standard_False;
137 //myCenter = gp_Pnt(0.,0.,0.);
138 myAutomaticPosition = Standard_True;
139}
140
7fd59977 141//=======================================================================
142//function : Axis2Placement
143//purpose :
144//=======================================================================
145
146Handle(Geom_Axis2Placement) AIS_Plane::Axis2Placement()
147{
148 Handle(Geom_Axis2Placement) Bid;
149 return IsXYZPlane() ? myAx2:Bid;
150}
151//=======================================================================
152//function : SetAxis2Placement
153//purpose :
154//=======================================================================
155
156 void AIS_Plane::SetAxis2Placement(const Handle(Geom_Axis2Placement)& aComponent,
157 const AIS_TypeOfPlane aPlaneType)
158{
159 myTypeOfPlane = aPlaneType;
160 myIsXYZPlane = Standard_True;
161 myAx2= aComponent;
162 myAutomaticPosition = Standard_True;
163 ComputeFields();
164}
165
166//=======================================================================
167//function : PlaneAttributes
168//purpose :
169//=======================================================================
170Standard_Boolean AIS_Plane::PlaneAttributes(Handle(Geom_Plane)& aComponent,
171 gp_Pnt& aCenter,
172 gp_Pnt& aPmin,
173 gp_Pnt& aPmax)
174{
175 Standard_Boolean aStatus (Standard_False);
176 if (!myAutomaticPosition){
177 aComponent = myComponent;
178 aCenter = myCenter;
179 aPmin = myPmin;
180 aPmax = myPmax;
181 aStatus = Standard_True;
182 }
183 return aStatus;
184}
185
186//=======================================================================
187//function : SetPlaneAttributes
188//purpose :
189//=======================================================================
190void AIS_Plane::SetPlaneAttributes(const Handle(Geom_Plane)& aComponent,
191 const gp_Pnt& aCenter,
192 const gp_Pnt& aPmin,
193 const gp_Pnt& aPmax)
194{
195 myAutomaticPosition = Standard_False;
196 myComponent = aComponent;
197 myCenter = aCenter;
198 myPmin = aPmin;
199 myPmax = aPmax;
200 myTypeOfPlane = AIS_TOPL_Unknown;
201 myIsXYZPlane = Standard_False;
202}
203
204//=======================================================================
205//function : Compute
decbff0d 206//purpose :
7fd59977 207//=======================================================================
decbff0d 208void AIS_Plane::Compute (const Handle(PrsMgr_PresentationManager)& ,
209 const Handle(Prs3d_Presentation)& thePrs,
210 const Standard_Integer theMode)
7fd59977 211{
7fd59977 212 ComputeFields();
decbff0d 213 thePrs->SetInfiniteState (myInfiniteState);
b8ddfc2f 214 myDrawer->PlaneAspect()->EdgesAspect()->SetWidth(myCurrentMode == 0? 1 : 3);
215
decbff0d 216 switch (theMode)
b8ddfc2f 217 {
218 case 0:
219 {
220 if (!myIsXYZPlane)
221 {
222 ComputeFrame();
223 const Handle(Geom_Plane)& pl = myComponent;
c5f3a425 224 Handle(Geom_Plane) thegoodpl (Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter)));
b8ddfc2f 225 GeomAdaptor_Surface surf(thegoodpl);
decbff0d 226 StdPrs_Plane::Add (thePrs, surf, myDrawer);
b8ddfc2f 227 }
228 else
decbff0d 229 {
230 DsgPrs_XYZPlanePresentation::Add (thePrs, myDrawer, myCenter, myPmin, myPmax);
231 }
b8ddfc2f 232 break;
7fd59977 233 }
b8ddfc2f 234 case 1:
235 {
236 if (!myIsXYZPlane)
237 {
238 ComputeFrame();
decbff0d 239 Handle(Prs3d_PlaneAspect) anAspect = myDrawer->PlaneAspect();
240 Handle(Graphic3d_Group) aGroup = thePrs->CurrentGroup();
241 aGroup->SetPrimitivesAspect (myDrawer->ShadingAspect()->Aspect());
b8ddfc2f 242 gp_Pnt p1;
decbff0d 243 const Standard_Real Xmax = 0.5*Standard_Real(anAspect->PlaneXLength());
244 const Standard_Real Ymax = 0.5*Standard_Real(anAspect->PlaneYLength());
b8ddfc2f 245
246 Handle(Graphic3d_ArrayOfQuadrangles) aQuads = new Graphic3d_ArrayOfQuadrangles(4);
247
248 myComponent->D0(-Xmax,Ymax,p1);
249 aQuads->AddVertex(p1);
250 myComponent->D0(Xmax,Ymax,p1);
251 aQuads->AddVertex(p1);
252 myComponent->D0(Xmax,-Ymax,p1);
253 aQuads->AddVertex(p1);
254 myComponent->D0(-Xmax,-Ymax,p1);
255 aQuads->AddVertex(p1);
256
decbff0d 257 aGroup->AddPrimitiveArray (aQuads);
7fd59977 258 }
b8ddfc2f 259 else
decbff0d 260 {
261 DsgPrs_ShadedPlanePresentation::Add (thePrs, myDrawer, myCenter, myPmin, myPmax);
262 }
b8ddfc2f 263 break;
7fd59977 264 }
265 }
7fd59977 266}
267
7fd59977 268//=======================================================================
269//function : ComputeSelection
270//purpose :
271//=======================================================================
51f8f60c 272void AIS_Plane::ComputeSelection (const Handle(SelectMgr_Selection)& theSelection, const Standard_Integer /*theMode*/)
7fd59977 273{
51f8f60c 274 theSelection->Clear();
275 Handle(SelectMgr_EntityOwner) aSensitiveOwner = new SelectMgr_EntityOwner (this, 10);
276 Handle(Poly_Triangulation) aSensitivePoly;
7fd59977 277
51f8f60c 278 if (!myIsXYZPlane)
279 {
280 // plane representing rectangle
281 Standard_Real aLengthX = myDrawer->PlaneAspect()->PlaneXLength() / 2.0;
282 Standard_Real aLengthY = myDrawer->PlaneAspect()->PlaneYLength() / 2.0;
283 Handle(Geom_Plane) aPlane =
284 Handle(Geom_Plane)::DownCast (myComponent->Translated (myComponent->Location(), myCenter));
285
286 TColgp_Array1OfPnt aRectanglePoints (1, 4);
287 aPlane->D0 ( aLengthX, aLengthY, aRectanglePoints.ChangeValue (1));
288 aPlane->D0 ( aLengthX, -aLengthY, aRectanglePoints.ChangeValue (2));
289 aPlane->D0 (-aLengthX, -aLengthY, aRectanglePoints.ChangeValue (3));
290 aPlane->D0 (-aLengthX, aLengthY, aRectanglePoints.ChangeValue (4));
291
292 Poly_Array1OfTriangle aTriangles (1, 2);
293 aTriangles.ChangeValue (1) = Poly_Triangle (1, 2, 3);
294 aTriangles.ChangeValue (2) = Poly_Triangle (1, 3, 4);
295
296 aSensitivePoly = new Poly_Triangulation (aRectanglePoints, aTriangles);
7fd59977 297 }
51f8f60c 298 else
299 {
300 // plane representing triangle
301 TColgp_Array1OfPnt aTrianglePoints (1, 3);
302 aTrianglePoints.ChangeValue (1) = myCenter;
303 aTrianglePoints.ChangeValue (2) = myPmin;
304 aTrianglePoints.ChangeValue (3) = myPmax;
7fd59977 305
51f8f60c 306 Poly_Array1OfTriangle aTriangles (1, 1);
307 aTriangles.ChangeValue (1) = Poly_Triangle(1, 2, 3);
308
309 aSensitivePoly = new Poly_Triangulation (aTrianglePoints, aTriangles);
7fd59977 310 }
7fd59977 311
51f8f60c 312 Standard_Boolean isSensitiveInterior = myTypeOfSensitivity == Select3D_TOS_INTERIOR;
7fd59977 313
51f8f60c 314 Handle(Select3D_SensitiveTriangulation) aSensitive =
315 new Select3D_SensitiveTriangulation (aSensitiveOwner,
316 aSensitivePoly,
317 TopLoc_Location(),
318 isSensitiveInterior);
7fd59977 319
51f8f60c 320 theSelection->Add(aSensitive);
321}
7fd59977 322
323//=======================================================================
324//function : SetSize
325//purpose :
326//=======================================================================
327void AIS_Plane::SetSize(const Standard_Real aLength)
328{
329 SetSize(aLength,aLength);
330}
331
332void AIS_Plane::SetSize(const Standard_Real aXLength,
333 const Standard_Real aYLength)
334{
81bba717 335 //if the plane already has a proper color or size,
336 //there is already a specific PlaneAspect and DatumAspect
7fd59977 337
338 Handle(Prs3d_PlaneAspect) PA;
339 Handle(Prs3d_DatumAspect) DA;
340
341 PA = myDrawer->PlaneAspect();
342 DA = myDrawer->DatumAspect();
343
344 Standard_Boolean yenavaitPA(Standard_True),yenavaitDA(Standard_True);
6262338c 345 if(myDrawer->HasLink() && myDrawer->Link()->PlaneAspect() == PA){
7fd59977 346 yenavaitPA = Standard_False;
347 PA = new Prs3d_PlaneAspect();}
6262338c 348 if(myDrawer->HasLink() && myDrawer->Link()->DatumAspect() == DA){
7fd59977 349 yenavaitDA = Standard_False;
350 DA = new Prs3d_DatumAspect();
351 }
352
353 PA->SetPlaneLength(aXLength,aYLength);
354 DA->SetAxisLength(aXLength,aYLength,aXLength);
355
356 if(!yenavaitPA)
357 myDrawer->SetPlaneAspect(PA);
358 if(!yenavaitDA)
359 myDrawer->SetDatumAspect(DA);
360
361
362 myHasOwnSize = Standard_True;
226fce20 363 SetToUpdate();
364 UpdatePresentations();
7fd59977 365 UpdateSelection();
366}
367
368
369//=======================================================================
370//function : UnsetSize
81bba717 371//purpose : If there is a color, the size is restaured from the drawer of the context...
7fd59977 372//=======================================================================
373void AIS_Plane::UnsetSize()
374{
375
376 if(!myHasOwnSize) return;
6262338c 377 if(!hasOwnColor)
378 {
379 myDrawer->SetPlaneAspect (Handle(Prs3d_PlaneAspect)());
380 myDrawer->SetDatumAspect (Handle(Prs3d_DatumAspect)());
7fd59977 381 }
382 else{
6262338c 383 const Handle(Prs3d_PlaneAspect) PA = myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() :
384 new Prs3d_PlaneAspect();
385 const Handle(Prs3d_DatumAspect) DA = myDrawer->HasLink() ? myDrawer->Link()->DatumAspect() :
386 new Prs3d_DatumAspect();
7fd59977 387
388 myDrawer->PlaneAspect()->SetPlaneLength(PA->PlaneXLength(),PA->PlaneYLength());
24f9d04c 389 myDrawer->DatumAspect()->SetAxisLength(DA->AxisLength(Prs3d_DatumParts_XAxis),
390 DA->AxisLength(Prs3d_DatumParts_YAxis),
391 DA->AxisLength(Prs3d_DatumParts_ZAxis));
7fd59977 392 }
393
394 myHasOwnSize = Standard_False;
226fce20 395 SetToUpdate();
396 UpdatePresentations();
7fd59977 397 UpdateSelection();
398
399}
400
401//=======================================================================
402//function : Size
403//purpose :
404//=======================================================================
405
406Standard_Boolean AIS_Plane::Size(Standard_Real& X,Standard_Real& Y) const
407{
408 X = myDrawer->PlaneAspect()->PlaneXLength();
409 Y = myDrawer->PlaneAspect()->PlaneYLength();
410 return Abs(X-Y)<=Precision::Confusion();
411}
412
b06da8f1 413//=======================================================================
414//function : SetMinimumSize
415//purpose :
416//=======================================================================
417void AIS_Plane::SetMinimumSize (const Standard_Real theValue)
418{
419 if (theValue <= 0)
420 {
421 UnsetMinimumSize();
422 return;
423 }
424 Standard_Real aX, anY;
425 Size (aX, anY);
426 SetTransformPersistence (new Graphic3d_TransformPersScaledAbove (Min (aX, anY) / theValue, myCenter));
427}
428
429//=======================================================================
430//function : UnsetMinimumSize
431//purpose :
432//=======================================================================
433void AIS_Plane::UnsetMinimumSize()
434{
435 SetTransformPersistence (NULL);
436}
437
438//=======================================================================
439//function : HasMinimumSize
440//purpose :
441//=======================================================================
442Standard_Boolean AIS_Plane::HasMinimumSize() const
443{
444 return !Handle(Graphic3d_TransformPersScaledAbove)::DownCast (TransformPersistence()).IsNull();
445}
446
7fd59977 447//=======================================================================
448//function : SetColor
449//purpose :
450//=======================================================================
7fd59977 451void AIS_Plane::SetColor(const Quantity_Color &aCol)
7fd59977 452{
81bba717 453 // if the plane already has its proper size, there is an already created planeaspect
7fd59977 454// Standard_Boolean yenadeja = hasOwnColor || myHasOwnSize;
455 Handle(Prs3d_PlaneAspect) PA;
456 Handle(Prs3d_DatumAspect) DA;
457
458 PA = myDrawer->PlaneAspect();
459 DA = myDrawer->DatumAspect();
460
461 Standard_Boolean yenavaitPA(Standard_True),yenavaitDA(Standard_True);
6262338c 462 if(myDrawer->HasLink() && myDrawer->Link()->PlaneAspect() == PA){
7fd59977 463 yenavaitPA = Standard_False;
464 PA = new Prs3d_PlaneAspect();}
6262338c 465 if(myDrawer->HasLink() && myDrawer->Link()->DatumAspect() == DA){
7fd59977 466 yenavaitDA = Standard_False;
467 DA = new Prs3d_DatumAspect();
468 }
469
470 PA->EdgesAspect()->SetColor(aCol);
24f9d04c 471 DA->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(aCol);
472 DA->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(aCol);
473 DA->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(aCol);
7fd59977 474
475 if(!yenavaitPA)
476 myDrawer->SetPlaneAspect(PA);
477 if(!yenavaitDA)
478 myDrawer->SetDatumAspect(DA);
479
480 myDrawer->ShadingAspect()->SetColor(aCol);
481
482 hasOwnColor=Standard_True;
f838dac4 483 myDrawer->SetColor (aCol);
7fd59977 484}
485//=======================================================================
486//function : SetColor
487//purpose :
488//=======================================================================
489void AIS_Plane::UnsetColor()
490{
491 if(!hasOwnColor) return;
6262338c 492 if(!myHasOwnSize)
493 {
494 myDrawer->SetPlaneAspect (Handle(Prs3d_PlaneAspect)());
495 myDrawer->SetDatumAspect (Handle(Prs3d_DatumAspect)());
7fd59977 496 }
497 else{
6262338c 498 const Handle(Prs3d_PlaneAspect) PA = myDrawer->HasLink() ? myDrawer->Link()->PlaneAspect() :
499 new Prs3d_PlaneAspect();
87432b82 500 Quantity_Color Col = PA->EdgesAspect()->Aspect()->Color();
7fd59977 501 myDrawer->PlaneAspect()->EdgesAspect()->SetColor(Col);
502
24f9d04c 503 myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_XAxis)->SetColor(Col);
504 myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_YAxis)->SetColor(Col);
505 myDrawer->DatumAspect()->LineAspect(Prs3d_DatumParts_ZAxis)->SetColor(Col);
7fd59977 506 }
507
508
509 hasOwnColor=Standard_False;
510
511}
512
513//=======================================================================
514//function : ComputeFrame
515//purpose :
516//=======================================================================
517void AIS_Plane::ComputeFrame()
518{
519
520 const Handle(Geom_Plane)& pl = myComponent;
521 Standard_Real U,V;
522
523 if (myAutomaticPosition) {
524 ElSLib::Parameters(pl->Pln(),myCenter,U,V);
525 pl->D0 (U, V, myCenter);
526 }
527 else {
c5f3a425 528 Handle(Geom_Plane) thegoodpl (Handle(Geom_Plane)::DownCast(pl->Translated(pl->Location(),myCenter)));
7fd59977 529 ElSLib::Parameters(thegoodpl->Pln(),myPmin,U,V);
530
531 U = 2.4*Abs(U);
532 V = 2.4*Abs(V);
533 if (U < 10*Precision::Confusion()) U=0.1;
534 if (V < 10*Precision::Confusion()) V=0.1;
535 SetSize(U,V);
536 myDrawer->PlaneAspect()->SetPlaneLength(U,V);
537 }
538}
539
7fd59977 540//=======================================================================
541//function : ComputeFields
542//purpose :
543//=======================================================================
544void 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);
24f9d04c 560 Standard_Real DS1 = DA->AxisLength(Prs3d_DatumParts_XAxis);
561 Standard_Real DS2 = DA->AxisLength(Prs3d_DatumParts_YAxis);
562 Standard_Real DS3 = DA->AxisLength(Prs3d_DatumParts_ZAxis);
7fd59977 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
603void AIS_Plane::InitDrawerAttributes()
604{
7fd59977 605 Handle(Prs3d_ShadingAspect) shasp = new Prs3d_ShadingAspect();
a966542b 606 shasp->SetMaterial(Graphic3d_NameOfMaterial_Plastified);
7fd59977 607 shasp->SetColor(Quantity_NOC_GRAY40);
608 myDrawer->SetShadingAspect(shasp);
609 Handle(Graphic3d_AspectFillArea3d) asf = shasp->Aspect();
610 Graphic3d_MaterialAspect asp = asf->FrontMaterial();
4e1bc39a 611 asp.SetTransparency (0.8f);
7fd59977 612 asf->SetFrontMaterial(asp);
613 asf->SetBackMaterial(asp);
7fd59977 614}
615
616//=======================================================================
617//function : AcceptDisplayMode
618//purpose :
619//=======================================================================
620
621Standard_Boolean AIS_Plane::
622AcceptDisplayMode(const Standard_Integer aMode) const
623{return aMode == 0;}
624
625
626//=======================================================================
627//function : SetContext
628//purpose :
629//=======================================================================
630
631void AIS_Plane::SetContext(const Handle(AIS_InteractiveContext)& Ctx)
632{
633 AIS_InteractiveObject::SetContext(Ctx);
634 ComputeFields();
635
636}