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