0024133: Development of improvement of dimensions implementation; new length, radius...
[occt.git] / src / AIS / AIS_Trihedron.cxx
1 // Created on: 1995-10-09
2 // Created by: Arnaud BOUZY/Odile Olivier
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22 //GER61351              //GG_171199     Enable to set an object RGB color instead a restricted object NameOfColor.
23
24 #define IMP120100       // GG Add SetTextColor() and SetArrowColor() methods
25
26 #include <AIS_Trihedron.ixx>
27 #include <DsgPrs_DatumPrs.hxx>
28 #include <SelectBasics_EntityOwner.hxx>
29 #include <SelectMgr_EntityOwner.hxx>
30 #include <Select3D_SensitiveSegment.hxx>
31 #include <Select3D_SensitiveFace.hxx>
32 #include <Select3D_SensitivePoint.hxx>
33 #include <Geom_Axis2Placement.hxx>
34 #include <Geom_Line.hxx>
35 #include <Geom_Point.hxx>
36 #include <Geom_Plane.hxx>
37 #include <Geom_CartesianPoint.hxx>
38 #include <gp_Dir.hxx>
39 #include <gp_Ax1.hxx>
40 #include <gp_Ax2.hxx>
41 #include <gp_Pnt.hxx>
42 #include <gp_Vec.hxx>
43 #include <Prs3d_Drawer.hxx>
44 #include <Prs3d_LineAspect.hxx>
45 #include <Prs3d_TextAspect.hxx>
46 #include <Prs3d_ArrowAspect.hxx>
47 #include <Prs3d_DatumAspect.hxx>
48 #include <Graphic3d_AspectLine3d.hxx>
49 #include <Graphic3d_Structure.hxx>
50 #include <Graphic3d_MaterialAspect.hxx>
51 #include <Graphic3d_AspectFillArea3d.hxx>
52 #include <Aspect_TypeOfLine.hxx>
53 #include <AIS_Drawer.hxx>
54 #include <AIS_Plane.hxx>
55 #include <AIS_Axis.hxx>
56 #include <AIS_Point.hxx>
57 #include <UnitsAPI.hxx>
58
59 #include <Select3D_SensitiveBox.hxx>
60 #include <Select3D_SensitiveTriangle.hxx>
61 #include <TColgp_Array1OfPnt.hxx>
62
63
64
65 //=======================================================================
66 //function : AIS_Trihedron
67 //purpose  : 
68 //=======================================================================
69 AIS_Trihedron::AIS_Trihedron(const Handle(Geom_Axis2Placement)& aComponent):
70 myComponent(aComponent),
71 myHasOwnSize(Standard_False)
72 #ifdef IMP120100
73 ,myHasOwnTextColor(Standard_False)
74 ,myHasOwnArrowColor(Standard_False)
75 #endif
76
77 {  LoadSubObjects();}
78
79
80
81 //=======================================================================
82 //function : SetComponent
83 //purpose  : 
84 //=======================================================================
85
86 void AIS_Trihedron::SetComponent(const Handle(Geom_Axis2Placement)& aComponent)
87 {
88   myComponent = aComponent;
89
90   // Remove from current context and nullify objects to update
91   Handle(AIS_InteractiveContext) anAISContext = GetContext();
92   Standard_Boolean hasContext = (anAISContext.IsNull() == Standard_False);
93   Standard_Integer anIdx;
94   for (anIdx = 0; anIdx < 7; anIdx++)
95   {
96     // Deselect object
97     if (hasContext)
98     {
99       if (anAISContext->IsSelected (myShapes[anIdx]))
100         anAISContext->AddOrRemoveSelected (myShapes[anIdx], Standard_False);
101
102       anAISContext->Remove (myShapes[anIdx], Standard_False);
103     }
104     myShapes[anIdx].Nullify();
105   }
106
107   LoadSubObjects();
108 }
109
110 //=======================================================================
111 //function : SetLocation
112 //purpose  : 
113 //=======================================================================
114
115 void AIS_Trihedron::SetLocation(const TopLoc_Location& aLoc)
116 {
117   // Update location to the subshapes
118   Standard_Integer anIdx;
119   for (anIdx = 0; anIdx < 7; anIdx++)
120     myShapes[anIdx]->SetLocation (aLoc);
121
122   AIS_InteractiveObject::SetLocation (aLoc);
123 }
124
125 //=======================================================================
126 //function : SetSize
127 //purpose  : 
128 //=======================================================================
129 void AIS_Trihedron::SetSize(const Standard_Real aValue)
130 {
131   myHasOwnSize = Standard_True;
132   if(!myDrawer->HasDatumAspect()){
133     Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
134     myDrawer->SetDatumAspect(DA);
135   }
136   
137   myDrawer->DatumAspect()->SetAxisLength(aValue,aValue,aValue);
138   
139   for(Standard_Integer i=4;i<=6;i++) 
140     (*((Handle(AIS_Plane)*)&myShapes[i]))->SetSize(aValue);
141
142   Update();
143   UpdateSelection();
144 }
145
146
147
148 //=======================================================================
149 //function : UnsetSize
150 //purpose  : if the object has 1 color, the default size of the 
151 //           drawer is reproduced, otherwise DatumAspect becomes null
152 //=======================================================================
153
154 void AIS_Trihedron::UnsetSize()
155 {
156   if(!myHasOwnSize) return;
157   
158   myHasOwnSize = Standard_False;
159   if(hasOwnColor){
160     const Handle(Prs3d_DatumAspect)& DA = myDrawer->Link()->DatumAspect();
161     myDrawer->DatumAspect()->SetAxisLength(DA->FirstAxisLength(),
162                                            DA->SecondAxisLength(),
163                                            DA->ThirdAxisLength());
164   }
165   else
166     myDrawer->DatumAspect().Nullify();
167   Update();
168   UpdateSelection();
169
170 }
171
172 //=======================================================================
173 //function : Size
174 //purpose  : 
175 //=======================================================================
176
177 Standard_Real AIS_Trihedron::Size() const 
178 {
179   if(myDrawer->HasDatumAspect()){
180     myDrawer->Link()->DatumAspect(); // ? to ensure that myDrawer->myLink is not null for next call ?
181     return myDrawer->DatumAspect()->FirstAxisLength();
182   }
183   else
184     //return the Defaut value
185     return 100. ;
186     
187
188 }
189
190 //=======================================================================
191 //function : XAxis
192 //purpose  : 
193 //=======================================================================
194 Handle(AIS_Axis) AIS_Trihedron::XAxis() const 
195 {
196   Handle(AIS_Axis) anAxis = Handle(AIS_Axis)::DownCast(myShapes[1]);
197   if (anAxis.IsNull()) anAxis = new AIS_Axis (myComponent,AIS_TOAX_XAxis);
198   return anAxis;
199 }
200
201 //=======================================================================
202 //function : YAxis
203 //purpose  : 
204 //=======================================================================
205 Handle(AIS_Axis) AIS_Trihedron::YAxis() const 
206 {
207   Handle(AIS_Axis) anAxis = Handle(AIS_Axis)::DownCast(myShapes[2]);
208   if (anAxis.IsNull()) anAxis = new AIS_Axis (myComponent,AIS_TOAX_YAxis);
209   return anAxis;
210 }
211
212 //=======================================================================
213 //function : Axis
214 //purpose  : 
215 //=======================================================================
216 Handle(AIS_Axis) AIS_Trihedron::Axis() const 
217 {
218   Handle(AIS_Axis) anAxis = Handle(AIS_Axis)::DownCast(myShapes[3]);
219   if (anAxis.IsNull()) anAxis = new AIS_Axis (myComponent,AIS_TOAX_ZAxis);
220   return anAxis;
221 }
222
223 //=======================================================================
224 //function : Position
225 //purpose  : 
226 //=======================================================================
227 Handle(AIS_Point) AIS_Trihedron::Position() const 
228 {
229   Handle(AIS_Point) aPt = Handle(AIS_Point)::DownCast(myShapes[0]);
230   if (aPt.IsNull()) {
231     gp_Pnt aPnt = myComponent->Ax2().Location();
232     Handle(Geom_Point) aPoint = new Geom_CartesianPoint(aPnt);
233     aPt = new AIS_Point (aPoint);
234   }
235   return aPt;
236 }
237
238 //=======================================================================
239 //function : XYPlane
240 //purpose  : 
241 //=======================================================================
242 Handle(AIS_Plane) AIS_Trihedron::XYPlane() const 
243 {
244   Handle(AIS_Plane) aPl = Handle(AIS_Plane)::DownCast(myShapes[4]);
245   if (aPl.IsNull()) aPl = new AIS_Plane (myComponent,AIS_TOPL_XYPlane);
246   return aPl;
247 }
248
249 //=======================================================================
250 //function : XZPlane
251 //purpose  : 
252 //=======================================================================
253 Handle(AIS_Plane) AIS_Trihedron::XZPlane() const 
254 {
255   Handle(AIS_Plane) aPl = Handle(AIS_Plane)::DownCast(myShapes[5]);
256   if (aPl.IsNull()) aPl = new AIS_Plane (myComponent,AIS_TOPL_XZPlane);
257   return aPl;
258 }
259
260 //=======================================================================
261 //function : YZPlane
262 //purpose  : 
263 //=======================================================================
264 Handle(AIS_Plane) AIS_Trihedron::YZPlane() const 
265 {
266   Handle(AIS_Plane) aPl = Handle(AIS_Plane)::DownCast(myShapes[6]);
267   if (aPl.IsNull()) aPl = new AIS_Plane (myComponent,AIS_TOPL_YZPlane);
268   return aPl;
269 }
270
271 //=======================================================================
272 //function : Compute
273 //purpose  : 
274 //=======================================================================
275 void AIS_Trihedron::Compute(
276  const Handle(PrsMgr_PresentationManager3d)& /*aPresentationManager*/,
277  const Handle(Prs3d_Presentation)& aPresentation, 
278  const Standard_Integer aMode)
279 {
280   aPresentation->Clear();
281
282   aPresentation->SetInfiniteState (Standard_True);
283   switch(aMode){
284   case 0: 
285     DsgPrs_DatumPrs::Add(aPresentation,myComponent->Ax2(),myDrawer);
286     break;
287   case 1:
288     break;
289   case 2:
290     break;
291   }
292 }
293
294 //=======================================================================
295 //function : Compute
296 //purpose  : 
297 //=======================================================================
298
299 void AIS_Trihedron::Compute(const Handle_Prs3d_Projector& aProjector,
300                             const Handle_Geom_Transformation& aTransformation,
301                             const Handle_Prs3d_Presentation& aPresentation)
302 {
303 // Standard_NotImplemented::Raise("AIS_Trihedron::Compute(const Handle_Prs3d_Projector&, const Handle_Geom_Transformation&, const Handle_Prs3d_Presentation&)");
304  PrsMgr_PresentableObject::Compute( aProjector , aTransformation , aPresentation) ;
305 }
306
307 //=======================================================================
308 //function : ComputeSelection
309 //purpose  : 
310 //=======================================================================
311
312 void AIS_Trihedron::ComputeSelection(const Handle(SelectMgr_Selection)& aSelection,
313                                      const Standard_Integer aMode)
314 {
315   // retrieve the tops of the trihedron.
316   Standard_Integer Prior, anIdx;
317   Handle(SelectMgr_EntityOwner) eown;
318   TColgp_Array1OfPnt PP(1,4),PO(1,4);
319   ExtremityPoints(PP);
320
321   // remove shapes from active selections
322   Handle(AIS_InteractiveContext) anAISContext = GetContext();
323   if (!anAISContext.IsNull())
324     for (anIdx = 0; anIdx < 7; anIdx++)
325     {
326       // Deselect object
327       if (anAISContext->IsSelected (myShapes[anIdx]))
328         anAISContext->AddOrRemoveSelected (myShapes[anIdx], Standard_False);
329
330       anAISContext->Remove (myShapes[anIdx], Standard_False);
331     }
332   
333   switch (aMode) {
334   case 0:
335     {   // complete triedron only 1 owner : this... priority 5 (same as faces)
336       Prior = 5;
337       eown = new SelectMgr_EntityOwner(this,Prior);
338       for (Standard_Integer i=1; i<=3;i++)
339         aSelection->Add(new Select3D_SensitiveSegment(eown,PP(1),PP(i+1)));
340       break;
341     }
342   case 1:
343     {  //origin : 
344       Prior = 8;
345       eown= new SelectMgr_EntityOwner(myShapes[0],Prior);
346       
347       aSelection->Add(new Select3D_SensitivePoint (eown,myComponent->Location()));
348       // If the trihedron's shapes display and selection modes are the same
349       // the shapes are still displayed after selection, so we need to
350       // use different presentation and hide it by nullifying
351       if (!anAISContext.IsNull())
352       {
353         anAISContext->Display (myShapes[0], 1, 0, Standard_False);
354         anAISContext->ClearPrs (myShapes[0], 1, Standard_False);
355       }
356       
357       break;
358     }
359   case 2:
360     {  //axes ... priority 7
361       Prior = 7;
362       for (Standard_Integer i=1; i<=3;i++){
363         eown= new SelectMgr_EntityOwner(myShapes[i],Prior);
364         aSelection->Add(new Select3D_SensitiveSegment(eown,PP(1),PP(i+1)));
365
366       }
367
368       // If the trihedron's shapes display and selection modes are the same
369       // the shapes are still displayed after selection, so we need to
370       // use different presentation and hide it by nullifying
371       AIS_TypeOfAxis anAxisType;
372       if (!anAISContext.IsNull())
373         for (anIdx = 1; anIdx <= 3; anIdx++)
374         {
375           // update AIS_Axis for selection
376           Handle(AIS_Axis) anAxis = Handle(AIS_Axis)::DownCast(myShapes[anIdx]);
377           Handle(AIS_Drawer) aDrawer = anAxis->Attributes();
378           Handle(Prs3d_DatumAspect) aDatum = myDrawer->DatumAspect();
379           aDrawer->DatumAspect()->SetAxisLength (aDatum->FirstAxisLength(),
380                                                  aDatum->SecondAxisLength(),
381                                                  aDatum->ThirdAxisLength());
382           anAxisType = anAxis->TypeOfAxis();
383           anAxis->SetAxis2Placement (myComponent, anAxisType);
384
385           // display
386           anAISContext->Display (myShapes[anIdx], 1, 0, Standard_False);
387           anAISContext->ClearPrs (myShapes[anIdx], 1, Standard_False);
388         }
389       
390       break;
391     }
392     
393   case 3:
394     {  // main planes priority 6
395 //      PO(1) = PP(1);
396 //      PO(4) = PP(1);
397       Prior =5;
398       
399       
400       eown= new SelectMgr_EntityOwner(myShapes[4],Prior);
401 //      PO(2) = PP(2);PO(3) = PP(3);
402       aSelection->Add(new Select3D_SensitiveTriangle(eown,PP(1),PP(2),PP(3)));
403
404       eown= new SelectMgr_EntityOwner(myShapes[5],Prior);
405 //      PO(2) = PP(3);PO(3) = PP(4);
406       aSelection->Add(new Select3D_SensitiveTriangle(eown,PP(1),PP(2),PP(4)));
407
408       eown= new SelectMgr_EntityOwner(myShapes[6],Prior);
409 //      PO(2) = PP(4);PO(3) = PP(2);
410       aSelection->Add(new Select3D_SensitiveTriangle(eown,PP(1),PP(3),PP(4)));
411       
412       // If the trihedron's shapes display and selection modes are the same
413       // the shapes are still displayed after selection, so we need to
414       // use different presentation and hide it by nullifying
415       if (!anAISContext.IsNull())
416         for (anIdx = 4; anIdx < 7; anIdx++)
417         {
418           anAISContext->Display (myShapes[anIdx], 1, 0, Standard_False);
419           anAISContext->ClearPrs (myShapes[anIdx], 1, Standard_False);
420         }
421     }
422   }
423   
424 }
425
426 //=======================================================================
427 //function : SetColor
428 //purpose  : 
429 //=======================================================================
430
431 void AIS_Trihedron::SetColor(const Quantity_NameOfColor aCol)
432 {
433   SetColor(Quantity_Color(aCol));
434 }
435
436 void AIS_Trihedron::SetColor(const Quantity_Color &aCol)
437 {
438   hasOwnColor=Standard_True;
439   myOwnColor = aCol;
440   
441   if(!myDrawer->HasDatumAspect()){
442     Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
443     
444     DA->SetAxisLength(myDrawer->DatumAspect()->FirstAxisLength(),
445                       myDrawer->DatumAspect()->SecondAxisLength(),
446                       myDrawer->DatumAspect()->ThirdAxisLength());
447     myDrawer->SetDatumAspect(DA);
448   }
449   myDrawer->DatumAspect()->FirstAxisAspect()->SetColor(aCol);
450   myDrawer->DatumAspect()->SecondAxisAspect()->SetColor(aCol);
451   myDrawer->DatumAspect()->ThirdAxisAspect()->SetColor(aCol);
452
453 }
454
455 //=======================================================================
456 //function : SetTextColor
457 //purpose  : 
458 //=======================================================================
459
460 #ifdef IMP120100
461 void AIS_Trihedron::SetTextColor(const Quantity_NameOfColor aCol)
462 {
463   myHasOwnTextColor = Standard_True;
464   myOwnTextColor = aCol;
465   
466   if(!myDrawer->HasDatumAspect()){
467     Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
468     
469     DA->SetAxisLength(myDrawer->DatumAspect()->FirstAxisLength(),
470                       myDrawer->DatumAspect()->SecondAxisLength(),
471                       myDrawer->DatumAspect()->ThirdAxisLength());
472     myDrawer->SetDatumAspect(DA);
473   }
474   Handle(Prs3d_TextAspect) aspect = myDrawer->TextAspect();
475   aspect->SetColor(aCol);
476   myDrawer->SetTextAspect(aspect);
477 }
478
479 void AIS_Trihedron::SetArrowColor(const Quantity_NameOfColor aCol)
480 {
481   myHasOwnArrowColor = Standard_True;
482   myOwnArrowColor = aCol;
483   
484   if(!myDrawer->HasDatumAspect()){
485     Handle (Prs3d_DatumAspect) DA = new Prs3d_DatumAspect();
486     
487     DA->SetAxisLength(myDrawer->DatumAspect()->FirstAxisLength(),
488                       myDrawer->DatumAspect()->SecondAxisLength(),
489                       myDrawer->DatumAspect()->ThirdAxisLength());
490     myDrawer->SetDatumAspect(DA);
491   }
492   Handle(Prs3d_ArrowAspect) aspect = myDrawer->ArrowAspect();
493   aspect->SetColor(aCol);
494   myDrawer->SetArrowAspect(aspect);
495 }
496
497 //=======================================================================
498 Standard_Boolean AIS_Trihedron::HasTextColor() const {
499
500   return myHasOwnTextColor;
501 }
502
503 //=======================================================================
504 Quantity_NameOfColor AIS_Trihedron::TextColor() const {
505
506   return myOwnTextColor;
507 }
508
509 //=======================================================================
510 Standard_Boolean AIS_Trihedron::HasArrowColor() const {
511
512   return myHasOwnArrowColor;
513 }
514
515 //=======================================================================
516 Quantity_NameOfColor AIS_Trihedron::ArrowColor() const {
517
518   return myOwnArrowColor;
519 }
520 #endif
521
522
523 //=======================================================================
524 //function : Compute
525 //purpose  : to avoid warning
526 //=======================================================================
527 void AIS_Trihedron::Compute(const Handle(Prs3d_Projector)&, 
528                                const Handle(Prs3d_Presentation)&)
529 {
530 }
531 //=======================================================================
532 //function : Type
533 //purpose  : 
534 //=======================================================================
535
536 AIS_KindOfInteractive AIS_Trihedron::Type() const 
537 {return AIS_KOI_Datum;}
538
539
540 //=======================================================================
541 //function : Signature
542 //purpose  : 
543 //=======================================================================
544
545  Standard_Integer AIS_Trihedron::Signature() const 
546 {return 3;}
547
548 //=======================================================================
549 //function : ExtremityPoints
550 //purpose  : to avoid warning
551 //=======================================================================
552 void  AIS_Trihedron::ExtremityPoints(TColgp_Array1OfPnt& PP) const 
553 {
554   gp_Ax2 theax(myComponent->Ax2());
555   PP(1) = theax.Location();
556
557   Standard_Real len = myDrawer->DatumAspect()->FirstAxisLength();
558   gp_Vec vec = theax.XDirection();
559   vec *= len;
560   PP(2) = PP(1).Translated(vec);
561   
562   len = myDrawer->DatumAspect()->SecondAxisLength();
563   vec = theax.YDirection();
564   vec *= len;
565   PP(3) = PP(1).Translated(vec);
566
567   len = myDrawer->DatumAspect()->ThirdAxisLength();
568   vec = theax.Direction();
569   vec *= len;
570   PP(4) = PP(1).Translated(vec);
571 }
572
573 //=======================================================================
574 //function : AcceptDisplayMode
575 //purpose  : 
576 //=======================================================================
577
578  Standard_Boolean  AIS_Trihedron::
579 AcceptDisplayMode(const Standard_Integer aMode) const
580 {return aMode == 0;}
581
582
583
584 //=======================================================================
585 //function : UnsetColor
586 //purpose  : 
587 //=======================================================================
588
589 void AIS_Trihedron::UnsetColor()
590 {
591   hasOwnColor=Standard_False;
592   myOwnColor = Quantity_NOC_LIGHTSTEELBLUE4;
593   myDrawer->DatumAspect()->FirstAxisAspect()->SetColor(myOwnColor);
594   myDrawer->DatumAspect()->SecondAxisAspect()->SetColor(myOwnColor);
595   myDrawer->DatumAspect()->ThirdAxisAspect()->SetColor(myOwnColor);
596 #ifdef IMP120100
597   if( HasTextColor() ) {
598     SetTextColor(myOwnColor.Name());
599     myHasOwnTextColor = Standard_False;
600   }
601   if( HasArrowColor() ) {
602     SetArrowColor(myOwnColor.Name());
603     myHasOwnArrowColor = Standard_False;
604   }
605 #endif
606   
607 }
608
609 //=======================================================================
610 //function : UnsetWitdth
611 //purpose  : 
612 //=======================================================================
613
614 void AIS_Trihedron::UnsetWidth()
615 {
616   myOwnWidth =0.0;
617   myDrawer->DatumAspect()->FirstAxisAspect()->SetWidth(1.);
618   myDrawer->DatumAspect()->SecondAxisAspect()->SetWidth(1.);
619   myDrawer->DatumAspect()->ThirdAxisAspect()->SetWidth(1.);
620
621 }
622 void AIS_Trihedron::LoadSubObjects()
623 {
624   myShapes[0] = Position();
625   myShapes[1] = XAxis();
626   myShapes[2] = YAxis();
627   myShapes[3] = Axis();
628   myShapes[4] = XYPlane();
629   myShapes[5] = XZPlane();
630   myShapes[6] = YZPlane();
631 }
632
633 //=======================================================================
634 //function : SetContext
635 //purpose  : 
636 //=======================================================================
637
638 void AIS_Trihedron::SetContext(const Handle(AIS_InteractiveContext)& Ctx)
639 {
640 //  Standard_Boolean same_DA = myDrawer->Link() == Ctx->DefaultDrawer();
641    
642    if( Ctx.IsNull())
643    {
644       Standard_Integer anIdx;
645       for (anIdx = 0; anIdx < 7; anIdx++)
646       {
647         myShapes[anIdx]->SetContext(Ctx);
648       }
649      AIS_InteractiveObject::SetContext (Ctx);
650      return;
651    }
652   // Remove subobjects from current context
653   Handle(AIS_InteractiveContext) anAISContext = GetContext();
654   
655   Standard_Boolean hasContext = (anAISContext.IsNull() == Standard_False);
656   Standard_Integer anIdx;
657   for (anIdx = 0; anIdx < 7; anIdx++)
658     {
659       // Deselect object
660       if (hasContext)
661         {
662           if (anAISContext->IsSelected (myShapes[anIdx]))
663             anAISContext->AddOrRemoveSelected (myShapes[anIdx]);
664           
665           anAISContext->Remove (myShapes[anIdx], Standard_False);
666         }
667       myShapes[anIdx].Nullify();
668     }
669  
670   AIS_InteractiveObject::SetContext (Ctx);
671   LoadSubObjects();
672   for(Standard_Integer i= 0;i<=6;i++)
673     myShapes[i]->SetContext (Ctx);
674 }