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