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