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