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