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