b311480e |
1 | // Created on: 1997-01-29 |
2 | // Created by: Robert COUBLANC |
3 | // Copyright (c) 1997-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 | |
17 | #define UKI60826 //GG_161199 Use the requested selection color instead of default |
18 | |
19 | #define IMP280200 //GG Don't returns a NULL shape in SelectedShape() |
20 | // method when the current selected is a shape ! |
21 | |
22 | #define BUC60814 //GG_300101 Idem UKI60826 |
23 | |
7fd59977 |
24 | #define OCC138 //VTN Avoding infinit loop in AddOrRemoveCurrentObject method. |
25 | |
26 | #define OCC9657 |
27 | |
28 | #include <AIS_InteractiveContext.jxx> |
29 | #include <SelectMgr_EntityOwner.hxx> |
30 | #include <AIS_Selection.hxx> |
31 | #include <AIS_StatusOfDetection.hxx> |
32 | #include <AIS_StatusOfPick.hxx> |
33 | |
34 | #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx> |
35 | #include <AIS_LocalContext.hxx> |
36 | #include <AIS_GlobalStatus.hxx> |
37 | #include <AIS_Shape.hxx> |
38 | |
679ecdee |
39 | #include <Aspect_Grid.hxx> |
40 | |
7fd59977 |
41 | #include <V3d_Light.hxx> |
42 | #include <V3d_PositionalLight.hxx> |
43 | #include <V3d_SpotLight.hxx> |
44 | #include <V3d_DirectionalLight.hxx> |
45 | #include <V3d_AmbientLight.hxx> |
46 | |
47 | #include <TColStd_ListIteratorOfListOfInteger.hxx> |
48 | #include <SelectMgr_Selection.hxx> |
49 | #include <SelectBasics_SensitiveEntity.hxx> |
50 | |
7fd59977 |
51 | #include <Prs3d_Presentation.hxx> |
7fd59977 |
52 | |
53 | #ifdef OCC9657 |
54 | #include <AIS_MapOfInteractive.hxx> |
55 | #include <AIS_MapIteratorOfMapOfInteractive.hxx> |
56 | #endif |
57 | |
7fd59977 |
58 | //======================================================================= |
59 | //function : MoveTo |
679ecdee |
60 | //purpose : |
7fd59977 |
61 | //======================================================================= |
679ecdee |
62 | AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer theXPix, |
63 | const Standard_Integer theYPix, |
64 | const Handle(V3d_View)& theView, |
65 | const Standard_Boolean theToRedrawOnUpdate) |
7fd59977 |
66 | { |
679ecdee |
67 | if (HasOpenedContext()) |
68 | { |
7fd59977 |
69 | myWasLastMain = Standard_True; |
679ecdee |
70 | return myLocalContexts (myCurLocalIndex)->MoveTo (theXPix, theYPix, theView, theToRedrawOnUpdate); |
7fd59977 |
71 | } |
72 | |
7fd59977 |
73 | myAISCurDetected = 0; |
74 | myAISDetectedSeq.Clear(); |
7fd59977 |
75 | |
679ecdee |
76 | if (theView->Viewer() != myMainVwr) |
77 | { |
7fd59977 |
78 | return AIS_SOD_Error; |
679ecdee |
79 | } |
80 | |
81 | // preliminaires |
82 | myLastPicked = myLastinMain; |
83 | myWasLastMain = Standard_True; |
84 | AIS_StatusOfDetection aStatus = AIS_SOD_Nothing; |
85 | Standard_Boolean toUpdateViewer = Standard_False; |
86 | |
7fd59977 |
87 | // allonzy |
679ecdee |
88 | myMainSel->Pick (theXPix, theYPix, theView); |
89 | |
90 | // filling of myAISDetectedSeq sequence storing information about detected AIS objects |
91 | // (the objects must be AIS_Shapes) |
92 | const Standard_Integer aDetectedNb = myMainSel->NbPicked(); |
54a16ee4 |
93 | Standard_Integer aNewDetected = 0; |
679ecdee |
94 | for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter) |
7fd59977 |
95 | { |
679ecdee |
96 | Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter); |
97 | if (anOwner.IsNull() |
98 | || !myFilters->IsOk (anOwner)) |
99 | { |
100 | continue; |
101 | } |
102 | |
54a16ee4 |
103 | if (aNewDetected < 1) |
104 | { |
105 | aNewDetected = aDetIter; |
106 | } |
679ecdee |
107 | Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); |
57ad5cbd |
108 | if (!anObj.IsNull()) |
679ecdee |
109 | { |
110 | myAISDetectedSeq.Append (anObj); |
111 | } |
7fd59977 |
112 | } |
7fd59977 |
113 | |
54a16ee4 |
114 | if (aNewDetected >= 1) |
7fd59977 |
115 | { |
679ecdee |
116 | // does nothing if previously detected object is equal to the current one |
54a16ee4 |
117 | Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected); |
118 | if (aNewPickedOwner->Selectable() == myLastPicked) |
eafb234b |
119 | { |
8abada55 |
120 | return myLastPicked->State() == 1 |
121 | ? AIS_SOD_Selected |
122 | : AIS_SOD_OnlyOneDetected; |
679ecdee |
123 | } |
81bba717 |
124 | |
7fd59977 |
125 | // Previously detected object is unhilighted if it is not selected or hilighted |
126 | // with selection color if it is selected. Such highlighting with selection color |
127 | // is needed only if myToHilightSelected flag is true. In this case previously detected |
128 | // object has been already highlighted with myHilightColor during previous MoveTo() |
129 | // method call. As result it is necessary to rehighligt it with mySelectionColor. |
be6e564e |
130 | if (!myLastPicked.IsNull()) |
7fd59977 |
131 | { |
679ecdee |
132 | const Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0; |
be6e564e |
133 | if (myLastPicked->State() != 1) |
7fd59977 |
134 | { |
679ecdee |
135 | myMainPM->Unhighlight (myLastPicked, aHiMod); |
136 | toUpdateViewer = Standard_True; |
7fd59977 |
137 | } |
be6e564e |
138 | else if (myToHilightSelected) |
7fd59977 |
139 | { |
679ecdee |
140 | myMainPM->Color (myLastPicked, mySelectionColor, aHiMod); |
141 | toUpdateViewer = Standard_True; |
7fd59977 |
142 | } |
143 | } |
be6e564e |
144 | |
679ecdee |
145 | // initialize myLastPicked field with currently detected object |
54a16ee4 |
146 | myLastPicked = Handle(AIS_InteractiveObject)::DownCast (aNewPickedOwner->Selectable()); |
679ecdee |
147 | myLastinMain = myLastPicked; |
be6e564e |
148 | |
679ecdee |
149 | // highlight detected object if it is not selected or myToHilightSelected flag is true |
150 | if (!myLastPicked.IsNull()) |
7fd59977 |
151 | { |
679ecdee |
152 | if (myLastPicked->State() != 1 || myToHilightSelected) |
153 | { |
154 | const Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0; |
155 | myMainPM->Color (myLastPicked, myHilightColor, aHiMod); |
156 | toUpdateViewer = Standard_True; |
157 | } |
be6e564e |
158 | |
8abada55 |
159 | aStatus = myLastPicked->State() == 1 |
160 | ? AIS_SOD_Selected |
161 | : AIS_SOD_OnlyOneDetected; |
be6e564e |
162 | } |
7fd59977 |
163 | } |
164 | else |
165 | { |
679ecdee |
166 | // previously detected object is unhilighted if it is not selected or hilighted |
167 | // with selection color if it is selected |
168 | aStatus = AIS_SOD_Nothing; |
be6e564e |
169 | if (!myLastPicked.IsNull()) |
7fd59977 |
170 | { |
be6e564e |
171 | Standard_Integer aHiMod = myLastPicked->HasHilightMode() ? myLastPicked->HilightMode() : 0; |
172 | if (myLastPicked->State() != 1) |
7fd59977 |
173 | { |
679ecdee |
174 | myMainPM->Unhighlight (myLastPicked, aHiMod); |
175 | toUpdateViewer = Standard_True; |
7fd59977 |
176 | } |
be6e564e |
177 | else if (myToHilightSelected) |
7fd59977 |
178 | { |
679ecdee |
179 | myMainPM->Color (myLastPicked, mySelectionColor, aHiMod); |
180 | toUpdateViewer = Standard_True; |
7fd59977 |
181 | } |
182 | } |
be6e564e |
183 | |
679ecdee |
184 | myLastinMain.Nullify(); |
8abada55 |
185 | myLastPicked.Nullify(); |
7fd59977 |
186 | } |
679ecdee |
187 | |
188 | if (toUpdateViewer) |
189 | { |
190 | if (theToRedrawOnUpdate) |
191 | { |
192 | theView->Viewer()->Update(); |
193 | } |
194 | else |
195 | { |
196 | theView->Viewer()->Invalidate(); |
197 | } |
198 | } |
199 | |
679ecdee |
200 | mylastmoveview = theView; |
201 | return aStatus; |
7fd59977 |
202 | } |
203 | |
204 | //======================================================================= |
205 | //function : Select |
206 | //purpose : |
207 | //======================================================================= |
c398b00e |
208 | AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin, |
209 | const Standard_Integer theYPMin, |
210 | const Standard_Integer theXPMax, |
211 | const Standard_Integer theYPMax, |
212 | const Handle(V3d_View)& theView, |
213 | const Standard_Boolean toUpdateViewer) |
7fd59977 |
214 | { |
81bba717 |
215 | // all objects detected by the selector are taken, previous current objects are emptied, |
216 | // new objects are put... |
7fd59977 |
217 | |
c398b00e |
218 | if (HasOpenedContext()) |
219 | { |
220 | return myLocalContexts(myCurLocalIndex)->Select (theXPMin, theYPMin, |
221 | theXPMax, theYPMax, |
222 | theView, toUpdateViewer); |
223 | } |
7fd59977 |
224 | |
c398b00e |
225 | ClearCurrents (Standard_False); |
eb4320f2 |
226 | |
c398b00e |
227 | Handle(StdSelect_ViewerSelector3d) aSelector; |
7fd59977 |
228 | |
c398b00e |
229 | if (theView->Viewer() == myMainVwr) |
7fd59977 |
230 | { |
c398b00e |
231 | aSelector = myMainSel; |
232 | myWasLastMain = Standard_True; |
7fd59977 |
233 | } |
c398b00e |
234 | |
235 | aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); |
236 | AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); |
237 | |
238 | AIS_MapOfInteractive anObjectsToSelect; |
239 | for (aSelector->Init(); aSelector->More(); aSelector->Next()) |
7fd59977 |
240 | { |
c398b00e |
241 | Handle(AIS_InteractiveObject) anObj = |
242 | Handle(AIS_InteractiveObject)::DownCast (aSelector->Picked()->Selectable()); |
243 | if (!anObj.IsNull()) |
244 | { |
245 | anObjectsToSelect.Add (anObj); |
7fd59977 |
246 | } |
247 | } |
248 | |
c398b00e |
249 | AIS_MapIteratorOfMapOfInteractive anIt (anObjectsToSelect); |
250 | for ( ; anIt.More(); anIt.Next()) |
251 | { |
252 | AIS_Selection::Select (anIt.Key()); |
253 | anIt.Key()->State (1); |
254 | } |
255 | |
256 | HilightCurrents (toUpdateViewer); |
257 | |
258 | Standard_Integer aSelNum = NbCurrents(); |
259 | |
260 | return (aSelNum == 0) ? AIS_SOP_NothingSelected |
261 | : (aSelNum == 1) ? AIS_SOP_OneSelected |
262 | : AIS_SOP_SeveralSelected; |
7fd59977 |
263 | |
264 | } |
265 | |
266 | //======================================================================= |
267 | //function : Select |
268 | //purpose : Selection by polyline |
269 | //======================================================================= |
c398b00e |
270 | AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline, |
271 | const Handle(V3d_View)& theView, |
272 | const Standard_Boolean toUpdateViewer) |
7fd59977 |
273 | { |
81bba717 |
274 | // all objects detected by the selector are taken, previous current objects are emptied, |
275 | // new objects are put... |
7fd59977 |
276 | |
c398b00e |
277 | if (HasOpenedContext()) |
278 | { |
279 | return myLocalContexts(myCurLocalIndex)->Select (thePolyline, theView, toUpdateViewer); |
280 | } |
eb4320f2 |
281 | |
c398b00e |
282 | ClearCurrents (Standard_False); |
7fd59977 |
283 | |
c398b00e |
284 | Handle(StdSelect_ViewerSelector3d) aSelector; |
7fd59977 |
285 | |
c398b00e |
286 | if (theView->Viewer() == myMainVwr) |
7fd59977 |
287 | { |
c398b00e |
288 | aSelector = myMainSel; |
289 | myWasLastMain = Standard_True; |
7fd59977 |
290 | } |
c398b00e |
291 | |
292 | aSelector->Pick (thePolyline, theView); |
293 | AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); |
294 | |
295 | AIS_MapOfInteractive anObjectsToSelect; |
296 | for (aSelector->Init(); aSelector->More(); aSelector->Next()) |
7fd59977 |
297 | { |
c398b00e |
298 | Handle(AIS_InteractiveObject) anObj = |
299 | Handle( AIS_InteractiveObject )::DownCast (aSelector->Picked()->Selectable()); |
300 | if (!anObj.IsNull()) |
301 | { |
302 | anObjectsToSelect.Add (anObj); |
7fd59977 |
303 | } |
304 | } |
c398b00e |
305 | |
306 | AIS_MapIteratorOfMapOfInteractive anIt (anObjectsToSelect); |
307 | for ( ; anIt.More(); anIt.Next()) |
308 | { |
309 | AIS_Selection::Select (anIt.Key()); |
310 | anIt.Key()->State (1); |
311 | } |
312 | |
313 | HilightCurrents (toUpdateViewer); |
314 | |
315 | Standard_Integer aSelNum = NbCurrents(); |
316 | |
317 | return (aSelNum == 0) ? AIS_SOP_NothingSelected |
318 | : (aSelNum == 1) ? AIS_SOP_OneSelected |
319 | : AIS_SOP_SeveralSelected; |
7fd59977 |
320 | |
321 | } |
322 | |
323 | //======================================================================= |
324 | //function : Select |
325 | //purpose : |
326 | //======================================================================= |
c398b00e |
327 | AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer) |
7fd59977 |
328 | { |
c398b00e |
329 | if (HasOpenedContext()) |
330 | { |
7fd59977 |
331 | if(myWasLastMain) |
c398b00e |
332 | { |
333 | return myLocalContexts(myCurLocalIndex)->Select (toUpdateViewer); |
334 | } |
7fd59977 |
335 | else |
c398b00e |
336 | { |
337 | myLocalContexts(myCurLocalIndex)->SetSelected (myLastPicked, toUpdateViewer); |
338 | return AIS_SOP_OneSelected; |
339 | } |
340 | } |
341 | |
342 | if (myWasLastMain && !myLastinMain.IsNull()) |
343 | { |
344 | if(myLastinMain->State() != 1) |
345 | { |
346 | SetCurrentObject (myLastinMain,Standard_False); |
347 | if(toUpdateViewer) |
7fd59977 |
348 | { |
c398b00e |
349 | UpdateCurrentViewer(); |
7fd59977 |
350 | } |
c398b00e |
351 | } |
7fd59977 |
352 | } |
c398b00e |
353 | else |
354 | { |
355 | AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); |
356 | Handle(AIS_Selection) aSelection = AIS_Selection::CurrentSelection(); |
357 | Handle(AIS_InteractiveObject) anObj; |
358 | for (aSelection->Init(); aSelection->More(); aSelection->Next()) |
359 | { |
360 | anObj = Handle(AIS_InteractiveObject)::DownCast (aSelection->Value()); |
361 | anObj->State (0); |
362 | Unhilight (anObj,Standard_False); |
363 | if (myObjects.IsBound (anObj) && myObjects(anObj)->IsSubIntensityOn()) |
364 | { |
365 | HilightWithColor (anObj, mySubIntensity, Standard_False); |
7fd59977 |
366 | } |
367 | } |
c398b00e |
368 | |
7fd59977 |
369 | AIS_Selection::Select(); |
c398b00e |
370 | if (toUpdateViewer && myWasLastMain) |
371 | { |
eb4320f2 |
372 | UpdateCurrentViewer(); |
7fd59977 |
373 | } |
374 | } |
c398b00e |
375 | |
376 | Standard_Integer aSelNum = NbCurrents(); |
377 | |
378 | return (aSelNum == 0) ? AIS_SOP_NothingSelected |
379 | : (aSelNum == 1) ? AIS_SOP_OneSelected |
380 | : AIS_SOP_SeveralSelected; |
7fd59977 |
381 | } |
382 | |
383 | //======================================================================= |
384 | //function : ShiftSelect |
385 | //purpose : |
386 | //======================================================================= |
c398b00e |
387 | AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer) |
7fd59977 |
388 | { |
c398b00e |
389 | if (HasOpenedContext()) |
390 | { |
7fd59977 |
391 | if(myWasLastMain) |
c398b00e |
392 | { |
393 | return myLocalContexts (myCurLocalIndex)->ShiftSelect (toUpdateViewer); |
394 | } |
395 | else |
396 | { |
397 | myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (myLastPicked, toUpdateViewer); |
398 | |
399 | Standard_Integer aSelNum = NbSelected(); |
400 | return (aSelNum == 0) ? AIS_SOP_NothingSelected |
401 | : (aSelNum == 1) ? AIS_SOP_OneSelected |
402 | : AIS_SOP_SeveralSelected; |
7fd59977 |
403 | } |
404 | } |
eb4320f2 |
405 | |
c398b00e |
406 | if (myWasLastMain && !myLastinMain.IsNull()) |
407 | { |
408 | AddOrRemoveCurrentObject (myLastinMain, toUpdateViewer); |
409 | } |
7fd59977 |
410 | |
c398b00e |
411 | Standard_Integer aCurrentSelNum = NbCurrents(); |
412 | |
413 | return (aCurrentSelNum == 0) ? AIS_SOP_NothingSelected |
414 | : (aCurrentSelNum == 1) ? AIS_SOP_OneSelected |
415 | : AIS_SOP_SeveralSelected; |
416 | } |
7fd59977 |
417 | |
418 | //======================================================================= |
419 | //function : ShiftSelect |
420 | //purpose : |
421 | //======================================================================= |
c398b00e |
422 | AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin, |
423 | const Standard_Integer theYPMin, |
424 | const Standard_Integer theXPMax, |
425 | const Standard_Integer theYPMax, |
426 | const Handle(V3d_View)& theView, |
427 | const Standard_Boolean toUpdateViewer) |
7fd59977 |
428 | { |
c398b00e |
429 | if (HasOpenedContext()) |
430 | { |
431 | return myLocalContexts(myCurLocalIndex)->ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax, |
432 | theView, toUpdateViewer); |
433 | } |
434 | |
435 | UnhilightCurrents (Standard_False); |
436 | |
437 | Handle(StdSelect_ViewerSelector3d) aSelector; |
438 | if (theView->Viewer() == myMainVwr) |
439 | { |
440 | aSelector = myMainSel; |
441 | myWasLastMain = Standard_True; |
442 | } |
7fd59977 |
443 | else |
c398b00e |
444 | { |
7fd59977 |
445 | return AIS_SOP_NothingSelected; |
c398b00e |
446 | } |
447 | |
448 | aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); |
449 | AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); |
450 | for (aSelector->Init(); aSelector->More(); aSelector->Next()) |
451 | { |
452 | Handle(AIS_InteractiveObject) anObjToSelect = Handle(AIS_InteractiveObject)::DownCast (aSelector->Picked()->Selectable()); |
453 | if (!anObjToSelect.IsNull()) |
454 | { |
455 | AIS_SelectStatus aSelStatus = AIS_Selection::Select (anObjToSelect); |
456 | Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0; |
457 | anObjToSelect->State (aState); |
7fd59977 |
458 | } |
459 | } |
c398b00e |
460 | |
461 | HilightCurrents (toUpdateViewer); |
462 | |
463 | Standard_Integer aSelNum = NbCurrents(); |
464 | |
465 | return (aSelNum == 0) ? AIS_SOP_NothingSelected |
466 | : (aSelNum == 1) ? AIS_SOP_OneSelected |
467 | : AIS_SOP_SeveralSelected; |
468 | |
7fd59977 |
469 | } |
470 | |
471 | //======================================================================= |
472 | //function : ShiftSelect |
473 | //purpose : |
474 | //======================================================================= |
c398b00e |
475 | AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline, |
476 | const Handle(V3d_View)& theView, |
477 | const Standard_Boolean toUpdateViewer) |
7fd59977 |
478 | { |
c398b00e |
479 | if (HasOpenedContext()) |
480 | { |
481 | return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer); |
482 | } |
7fd59977 |
483 | |
c398b00e |
484 | UnhilightCurrents (Standard_False); |
485 | |
486 | Handle(StdSelect_ViewerSelector3d) aSelector; |
487 | |
488 | if (theView->Viewer() == myMainVwr) |
489 | { |
490 | aSelector= myMainSel; |
491 | myWasLastMain = Standard_True; |
492 | } |
493 | else |
494 | { |
495 | return AIS_SOP_NothingSelected; |
496 | } |
497 | |
498 | aSelector->Pick (thePolyline, theView); |
499 | |
500 | AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); |
501 | for (aSelector->Init(); aSelector->More(); aSelector->Next()) |
502 | { |
503 | Handle(AIS_InteractiveObject) anObjToSelect = Handle(AIS_InteractiveObject)::DownCast (aSelector->Picked()->Selectable()); |
504 | if (!anObjToSelect.IsNull()) |
505 | { |
506 | AIS_SelectStatus aSelStatus = AIS_Selection::Select (anObjToSelect); |
507 | Standard_Integer aState = (aSelStatus == AIS_SS_Added ) ? 1 : 0; |
508 | anObjToSelect->State (aState); |
7fd59977 |
509 | } |
c398b00e |
510 | } |
511 | |
512 | HilightCurrents (toUpdateViewer); |
513 | |
514 | Standard_Integer aSelNum = NbCurrents(); |
515 | |
516 | return (aSelNum == 0) ? AIS_SOP_NothingSelected |
517 | : (aSelNum == 1) ? AIS_SOP_OneSelected |
518 | : AIS_SOP_SeveralSelected; |
7fd59977 |
519 | } |
520 | |
521 | //======================================================================= |
522 | //function : SetCurrentObject |
523 | //purpose : |
524 | //======================================================================= |
7fd59977 |
525 | void AIS_InteractiveContext::SetCurrentObject(const Handle(AIS_InteractiveObject)& anIObj, |
526 | const Standard_Boolean updateviewer) |
527 | { |
81bba717 |
528 | // single case processing... |
7fd59977 |
529 | if(NbCurrents()==1 && anIObj->State()==1){ |
530 | Quantity_NameOfColor HiCol; |
531 | Standard_Boolean HasHiCol; |
532 | if(IsHilighted(anIObj,HasHiCol,HiCol)){ |
533 | if(HasHiCol && HiCol!= mySelectionColor) { |
534 | #ifdef UKI60826 |
535 | HilightWithColor(anIObj,mySelectionColor,updateviewer); |
536 | #else |
537 | Hilight(anIObj,updateviewer); |
538 | #endif |
539 | } |
540 | } |
541 | return; |
542 | } |
543 | |
544 | |
545 | // |
546 | if(!HasOpenedContext()) { |
547 | if(anIObj.IsNull()) return; |
548 | if(!myObjects.IsBound(anIObj)) |
549 | Display(anIObj,Standard_False); |
550 | |
551 | AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); |
552 | Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); |
553 | Handle(Standard_Transient) TR; |
554 | Handle(AIS_InteractiveObject) IO; |
555 | sel->Init(); |
556 | while (sel->More()) { |
557 | TR = sel->Value(); |
558 | IO = *((Handle(AIS_InteractiveObject)*)&TR); |
559 | Unhilight(IO,Standard_False); |
560 | IO->State(0); |
561 | sel->Next(); |
562 | } |
563 | |
81bba717 |
564 | // added to avoid untimely viewer update... |
7fd59977 |
565 | AIS_Selection::ClearAndSelect(anIObj); |
566 | anIObj->State(1); |
567 | Quantity_NameOfColor HiCol; |
568 | Standard_Boolean HasHiCol; |
569 | if(IsHilighted(anIObj,HasHiCol,HiCol)){ |
570 | if(HasHiCol && HiCol!= mySelectionColor) { |
571 | #ifdef UKI60826 |
572 | HilightWithColor(anIObj,mySelectionColor,Standard_False); |
573 | #else |
574 | Hilight(anIObj,Standard_False); |
575 | #endif |
576 | } |
577 | } |
578 | else{ |
579 | #ifdef UKI60826 |
580 | HilightWithColor(anIObj,mySelectionColor,Standard_False); |
581 | #else |
582 | Hilight(anIObj,Standard_False); |
583 | #endif |
584 | } |
585 | if (updateviewer) |
586 | UpdateCurrentViewer(); |
587 | } |
588 | else{ |
63c629aa |
589 | #ifdef AIS_DEB |
7fd59977 |
590 | cout<<"Nothing Done : Opened Local Context"<<endl; |
591 | #endif |
592 | } |
593 | } |
594 | |
595 | //======================================================================= |
596 | //function : AddOrRemoveCurrentObject |
597 | //purpose : |
598 | //======================================================================= |
599 | |
600 | void AIS_InteractiveContext:: |
601 | AddOrRemoveCurrentObject(const Handle(AIS_InteractiveObject)& anIObj, |
602 | const Standard_Boolean updateviewer) |
603 | { |
604 | if(anIObj.IsNull()) return; |
605 | //OCC5682 to remove an object from neutral point even if Local Context is opened (Remove method) |
606 | if(!HasOpenedContext() /*OCC5682*/|| myObjects.IsBound(anIObj)) { |
607 | |
608 | AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); |
609 | Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); |
610 | |
611 | AIS_SelectStatus SelStat = AIS_Selection::Select(anIObj); |
612 | |
613 | Standard_Integer mod = (SelStat==AIS_SS_Added) ? 1 : 0; |
614 | anIObj->State(mod); |
615 | if(mod==1) |
616 | #ifdef BUC60814 |
617 | HilightWithColor(anIObj,mySelectionColor,Standard_False); |
618 | #else |
619 | Hilight(anIObj,Standard_False); |
620 | #endif |
621 | else |
622 | Unhilight(anIObj,Standard_False); |
623 | |
624 | |
625 | if(updateviewer) |
626 | UpdateCurrentViewer(); |
627 | } |
628 | else{ |
63c629aa |
629 | #ifdef AIS_DEB |
7fd59977 |
630 | cout<<"Nothing Done : Opened Local Context"<<endl; |
631 | #endif |
632 | } |
633 | } |
634 | //======================================================================= |
635 | //function : UpdateCurrent |
636 | //purpose : |
637 | //======================================================================= |
638 | |
639 | void AIS_InteractiveContext::UpdateCurrent() |
640 | { |
641 | HilightCurrents(); |
642 | } |
643 | |
644 | //======================================================================= |
645 | //function : IsCurrent |
646 | //purpose : |
647 | //======================================================================= |
648 | |
649 | Standard_Boolean AIS_InteractiveContext::IsCurrent(const Handle(AIS_InteractiveObject)& anIObj) const |
650 | { |
651 | |
652 | if (anIObj.IsNull()) return Standard_False; |
653 | return (anIObj->State()==1); |
654 | |
655 | // Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); |
656 | // sel->Init(); |
657 | // while (sel->More()) { |
658 | // if (anIObj == sel->Value()) return Standard_True; |
659 | // sel->Next(); |
660 | // } |
661 | // return Standard_False; |
662 | |
663 | } |
664 | |
665 | //======================================================================= |
666 | //function : InitCurrent |
667 | //purpose : |
668 | //======================================================================= |
669 | |
670 | void AIS_InteractiveContext::InitCurrent() |
671 | { |
672 | AIS_Selection::Selection(myCurrentName.ToCString())->Init(); |
673 | } |
674 | |
675 | //======================================================================= |
676 | //function : MoreCurrent |
677 | //purpose : |
678 | //======================================================================= |
679 | |
680 | Standard_Boolean AIS_InteractiveContext::MoreCurrent() const |
681 | { |
682 | return AIS_Selection::Selection(myCurrentName.ToCString())->More(); |
683 | |
684 | } |
685 | |
686 | //======================================================================= |
687 | //function : NextCurrent |
688 | //purpose : |
689 | //======================================================================= |
690 | |
691 | void AIS_InteractiveContext::NextCurrent() |
692 | { |
693 | AIS_Selection::Selection(myCurrentName.ToCString())->Next(); |
694 | } |
695 | |
696 | //======================================================================= |
697 | //function : Current |
698 | //purpose : |
699 | //======================================================================= |
700 | |
701 | Handle(AIS_InteractiveObject) AIS_InteractiveContext::Current() const |
702 | { |
703 | Handle(Standard_Transient) TR = AIS_Selection::Selection(myCurrentName.ToCString())->Value(); |
704 | Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&TR); |
705 | return IO; |
706 | } |
707 | |
708 | //======================================================================= |
709 | //function : FirstCurrentObject |
710 | //purpose : |
711 | //======================================================================= |
712 | Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstCurrentObject() |
713 | { |
714 | Handle(AIS_InteractiveObject) IO ; |
715 | InitCurrent(); |
716 | if(MoreCurrent()){ |
717 | return Current(); |
718 | } |
719 | return IO; |
720 | } |
721 | |
722 | //======================================================================= |
723 | //function : NbCurrents |
724 | //purpose : |
725 | //======================================================================= |
726 | Standard_Integer AIS_InteractiveContext::NbCurrents() |
727 | { |
728 | Standard_Integer i(0); |
729 | for(InitCurrent();MoreCurrent();NextCurrent()) |
730 | {i++;} |
731 | return i; |
732 | } |
733 | |
734 | //======================================================================= |
735 | //function : HilightCurrents |
736 | //purpose : |
737 | //======================================================================= |
738 | void AIS_InteractiveContext::HilightCurrents(const Standard_Boolean updateviewer) |
739 | { |
740 | AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); |
741 | Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); |
742 | Handle(Standard_Transient) TR; |
743 | Handle(AIS_InteractiveObject) IO; |
744 | sel->Init(); |
745 | while (sel->More()) { |
746 | TR = sel->Value(); |
747 | IO = *((Handle(AIS_InteractiveObject)*)&TR); |
748 | #ifdef BUC60814 |
749 | HilightWithColor(IO,mySelectionColor,Standard_False); |
750 | #else |
751 | Hilight(IO,Standard_False); |
752 | #endif |
753 | sel->Next(); |
754 | } |
755 | if(updateviewer) |
756 | UpdateCurrentViewer(); |
757 | } |
758 | |
759 | //======================================================================= |
760 | //function : UnhilightCurrents |
761 | //purpose : |
762 | //======================================================================= |
763 | |
764 | void AIS_InteractiveContext::UnhilightCurrents(const Standard_Boolean updateviewer) |
765 | { |
766 | AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); |
767 | Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); |
768 | Handle(Standard_Transient) TR; |
769 | Handle(AIS_InteractiveObject) IO; |
770 | sel->Init(); |
771 | while (sel->More()) { |
772 | TR = sel->Value(); |
773 | IO = *((Handle(AIS_InteractiveObject)*)&TR); |
774 | Unhilight(IO,Standard_False); |
775 | sel->Next(); |
776 | } |
777 | if(updateviewer) |
778 | UpdateCurrentViewer(); |
779 | } |
780 | |
781 | //======================================================================= |
782 | //function : ClearCurrents |
783 | //purpose : |
784 | //======================================================================= |
785 | |
786 | void AIS_InteractiveContext::ClearCurrents(const Standard_Boolean updateviewer) |
787 | { |
788 | if(NbCurrents()==0) return; |
789 | AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); |
790 | Handle(AIS_Selection) S = AIS_Selection::CurrentSelection(); |
791 | Handle(Standard_Transient) Tr; |
792 | Handle(AIS_InteractiveObject) IO; |
793 | for(S->Init();S->More();S->Next()){ |
794 | Tr = S->Value(); |
795 | IO = (*((Handle(AIS_InteractiveObject)*)&Tr)); |
796 | IO->State(0); |
797 | Unhilight(IO,Standard_False); |
798 | } |
799 | AIS_Selection::Select(); |
800 | if(updateviewer) |
801 | UpdateCurrentViewer(); |
802 | } |
803 | |
804 | |
805 | //======================================================================= |
806 | //function : HilightSelected |
807 | //purpose : |
808 | //======================================================================= |
809 | |
810 | void AIS_InteractiveContext::HilightSelected(const Standard_Boolean updateviewer) |
811 | { |
812 | if(!HasOpenedContext()){ |
813 | AIS_Selection::SetCurrentSelection(mySelectionName.ToCString()); |
814 | Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); |
815 | Handle(Standard_Transient) TR; |
816 | Handle(AIS_InteractiveObject) IO; |
817 | sel->Init(); |
818 | while (sel->More()) { |
819 | TR = sel->Value(); |
820 | IO = *((Handle(AIS_InteractiveObject)*)&TR); |
821 | #ifdef BUC60814 |
822 | HilightWithColor(IO,mySelectionColor,Standard_False); |
823 | #else |
824 | Hilight(IO,Standard_False); |
825 | #endif |
826 | sel->Next(); |
827 | } |
828 | } |
829 | else |
830 | { |
831 | myLocalContexts(myCurLocalIndex)->HilightPicked(updateviewer); |
832 | } |
833 | if(updateviewer) |
834 | UpdateCurrentViewer(); |
835 | } |
836 | |
837 | //======================================================================= |
838 | //function : UnhilightSelected |
839 | //purpose : |
840 | //======================================================================= |
841 | |
842 | void AIS_InteractiveContext::UnhilightSelected(const Standard_Boolean updateviewer) |
843 | { |
844 | if(!HasOpenedContext()){ |
845 | AIS_Selection::SetCurrentSelection(mySelectionName.ToCString()); |
846 | Handle(AIS_Selection) sel = AIS_Selection::Selection(myCurrentName.ToCString()); |
847 | Handle(Standard_Transient) TR; |
848 | Handle(AIS_InteractiveObject) IO; |
849 | sel->Init(); |
850 | while (sel->More()) { |
851 | TR = sel->Value(); |
852 | IO = *((Handle(AIS_InteractiveObject)*)&TR); |
853 | Unhilight(IO,Standard_False); |
854 | sel->Next(); |
855 | } |
856 | if(updateviewer) |
857 | UpdateCurrentViewer(); |
858 | } |
859 | else |
860 | { |
861 | myLocalContexts(myCurLocalIndex)->UnhilightPicked(updateviewer); |
862 | } |
863 | } |
864 | |
865 | |
866 | //======================================================================= |
867 | //function : ClearSelected |
868 | //purpose : |
869 | //======================================================================= |
870 | |
871 | void AIS_InteractiveContext::ClearSelected(const Standard_Boolean updateviewer) |
872 | { |
873 | if(!HasOpenedContext()) |
874 | ClearCurrents(updateviewer); |
875 | else |
876 | myLocalContexts(myCurLocalIndex)->ClearSelected(updateviewer); |
877 | |
878 | } |
879 | |
880 | |
881 | //======================================================================= |
882 | //function : SetSelectedCurrent |
883 | //purpose : |
884 | //======================================================================= |
885 | |
886 | void AIS_InteractiveContext::SetSelectedCurrent() |
887 | { |
888 | |
889 | |
63c629aa |
890 | #ifdef AIS_DEB |
7fd59977 |
891 | cout<<"Not Yet Implemented"<<endl; |
892 | #endif |
893 | } |
894 | |
895 | //======================================================================= |
896 | //function : UpdateSelection |
897 | //purpose : |
898 | //======================================================================= |
899 | |
900 | void AIS_InteractiveContext::UpdateSelected(const Standard_Boolean updateviewer) |
901 | { |
902 | if(!HasOpenedContext()) { |
903 | HilightSelected(); |
904 | #ifndef BUG |
905 | return; |
906 | #endif |
907 | } |
908 | myLocalContexts(myCurLocalIndex)->UpdateSelected(updateviewer); |
909 | } |
910 | |
911 | //======================================================================= |
912 | //function : SetCurrentObject |
913 | //purpose : |
914 | //======================================================================= |
915 | void AIS_InteractiveContext::SetSelected(const Handle(AIS_InteractiveObject)& anIObj,const Standard_Boolean updateviewer) |
916 | { |
917 | if(!HasOpenedContext()) |
918 | SetCurrentObject(anIObj,updateviewer); |
919 | else |
920 | myLocalContexts(myCurLocalIndex)->SetSelected(anIObj,updateviewer); |
921 | } |
922 | |
923 | //======================================================================= |
924 | //function : AddOrRemoveSelected |
925 | //purpose : |
926 | //======================================================================= |
927 | |
928 | void AIS_InteractiveContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)& anIObj, |
929 | const Standard_Boolean updateviewer) |
930 | { |
931 | if(!anIObj->HasInteractiveContext()) anIObj->SetContext(this); |
932 | if(!HasOpenedContext()) |
933 | AddOrRemoveCurrentObject(anIObj,updateviewer); |
934 | else |
935 | myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(anIObj,updateviewer); |
936 | |
937 | } |
938 | //======================================================================= |
939 | //function : AddOrRemoveSelected |
940 | //purpose : |
941 | //======================================================================= |
942 | |
943 | void AIS_InteractiveContext::AddOrRemoveSelected(const TopoDS_Shape& aShap, |
944 | const Standard_Boolean updateviewer) |
945 | { |
946 | if(!HasOpenedContext()) { |
63c629aa |
947 | #ifdef AIS_DEB |
7fd59977 |
948 | cout<<" Attempt to remove a selected shape with no opened local context"<<endl; |
949 | #endif |
950 | return; |
951 | } |
952 | |
953 | myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(aShap,updateviewer); |
954 | if(updateviewer) UpdateCurrentViewer(); |
955 | |
956 | } |
957 | //======================================================================= |
958 | //function : AddOrRemoveSelected |
959 | //purpose : |
960 | //======================================================================= |
961 | |
962 | void AIS_InteractiveContext::AddOrRemoveSelected(const Handle(SelectMgr_EntityOwner)& Own, |
963 | const Standard_Boolean updateviewer) |
964 | { |
965 | if(!HasOpenedContext()) { |
63c629aa |
966 | #ifdef AIS_DEB |
7fd59977 |
967 | cout<<" Attempt to remove a selected ownr with no opened local context"<<endl; |
968 | #endif |
969 | return; |
970 | } |
971 | |
972 | myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(Own,Standard_False); |
973 | if(updateviewer) UpdateCurrentViewer(); |
974 | |
975 | } |
976 | |
977 | |
978 | |
979 | //======================================================================= |
980 | //function : IsSelected |
981 | //purpose : |
982 | //======================================================================= |
983 | |
984 | Standard_Boolean AIS_InteractiveContext:: |
985 | IsSelected(const Handle(AIS_InteractiveObject)& anIObj) const |
986 | { |
987 | if (anIObj.IsNull()) return Standard_False; |
988 | |
989 | if(!HasOpenedContext()) |
990 | return (anIObj->State()==1); |
991 | else |
992 | return myLocalContexts(myCurLocalIndex)->IsSelected(anIObj); |
993 | } |
994 | |
995 | |
996 | //======================================================================= |
997 | //function : InitSelected |
998 | //purpose : |
999 | //======================================================================= |
1000 | |
1001 | void AIS_InteractiveContext::InitSelected() |
1002 | { |
1003 | if(!HasOpenedContext()) |
1004 | AIS_Selection::Selection(myCurrentName.ToCString())->Init(); |
1005 | else |
1006 | myLocalContexts(myCurLocalIndex)->InitSelected(); |
1007 | } |
1008 | |
1009 | //======================================================================= |
1010 | //function : MoreSelected |
1011 | //purpose : |
1012 | //======================================================================= |
1013 | |
1014 | Standard_Boolean AIS_InteractiveContext::MoreSelected() const |
1015 | { |
1016 | if(!HasOpenedContext()) |
1017 | return AIS_Selection::Selection(myCurrentName.ToCString())->More(); |
1018 | return myLocalContexts(myCurLocalIndex)->MoreSelected(); |
1019 | } |
1020 | |
1021 | //======================================================================= |
1022 | //function : NextSelected |
1023 | //purpose : |
1024 | //======================================================================= |
1025 | |
1026 | void AIS_InteractiveContext::NextSelected() |
1027 | { |
1028 | if(!HasOpenedContext()) |
1029 | AIS_Selection::Selection(myCurrentName.ToCString())->Next(); |
1030 | else |
1031 | myLocalContexts(myCurLocalIndex)->NextSelected(); |
1032 | } |
1033 | |
1034 | //======================================================================= |
1035 | //function : HasSelectedShape |
1036 | //purpose : |
1037 | //======================================================================= |
1038 | |
1039 | Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const |
1040 | { |
1041 | if(!HasOpenedContext()) { |
1042 | #ifdef IMP280200 |
1043 | Handle(AIS_Shape) shape = |
1044 | Handle(AIS_Shape)::DownCast(SelectedInteractive()); |
1045 | if( !shape.IsNull() ) return Standard_True; |
1046 | #endif |
1047 | return Standard_False; |
1048 | } |
1049 | return myLocalContexts(myCurLocalIndex)->HasShape(); |
1050 | |
1051 | |
1052 | } |
1053 | |
1054 | //======================================================================= |
1055 | //function : SelectedShape |
1056 | //purpose : |
1057 | //======================================================================= |
1058 | |
1059 | TopoDS_Shape AIS_InteractiveContext::SelectedShape() const |
1060 | { |
0717ddc1 |
1061 | if (!HasOpenedContext()) |
1062 | { |
d8110103 |
1063 | TopoDS_Shape aResShape; |
1064 | Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (SelectedInteractive()); |
1065 | if (!aShape.IsNull()) |
1066 | { |
1067 | aResShape = aShape->Shape().Located (TopLoc_Location (SelectedInteractive()->Transformation()) * aShape->Shape().Location()); |
1068 | } |
1069 | |
1070 | return aResShape; |
0717ddc1 |
1071 | } |
1072 | else |
1073 | { |
1074 | return myLocalContexts (myCurLocalIndex)->SelectedShape(); |
1075 | } |
7fd59977 |
1076 | } |
1077 | |
1078 | //======================================================================= |
1079 | //function : Interactive |
1080 | //purpose : |
1081 | //======================================================================= |
1082 | |
1083 | Handle(AIS_InteractiveObject) AIS_InteractiveContext::Interactive() const |
1084 | { |
1085 | return SelectedInteractive(); |
1086 | } |
1087 | |
1088 | Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const |
1089 | { |
1090 | if(!HasOpenedContext()){ |
1091 | Handle(Standard_Transient) TR =AIS_Selection::Selection(myCurrentName.ToCString())->Value(); |
1092 | Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&TR); |
1093 | return IO;} |
1094 | |
1095 | return myLocalContexts(myCurLocalIndex)->SelectedInteractive(); |
1096 | |
1097 | } |
1098 | //======================================================================= |
1099 | //function : Interactive |
1100 | //purpose : |
1101 | //======================================================================= |
1102 | |
1103 | Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const |
1104 | { |
1105 | if(!HasOpenedContext()){ |
1106 | Handle(SelectMgr_EntityOwner) Ownr; |
1107 | return Ownr; |
1108 | } |
1109 | return myLocalContexts(myCurLocalIndex)->SelectedOwner(); |
1110 | |
1111 | } |
1112 | |
1113 | //======================================================================= |
1114 | //function : EntityOwners |
1115 | //purpose : |
1116 | //======================================================================= |
1117 | void AIS_InteractiveContext::EntityOwners(SelectMgr_IndexedMapOfOwner& theOwners, |
1118 | const Handle(AIS_InteractiveObject)& theIObj, |
1119 | const Standard_Integer theMode) const |
1120 | { |
1121 | if ( theIObj.IsNull() ) |
1122 | return; |
1123 | |
1124 | TColStd_ListOfInteger aModes; |
1125 | if ( theMode == -1 ) |
1126 | ActivatedModes( theIObj, aModes ); |
1127 | else |
1128 | aModes.Append( theMode ); |
1129 | |
1130 | TColStd_ListIteratorOfListOfInteger anItr( aModes ); |
1131 | for (; anItr.More(); anItr.Next() ) |
1132 | { |
1133 | int aMode = anItr.Value(); |
1134 | if ( !theIObj->HasSelection( aMode ) ) |
1135 | continue; |
1136 | |
1137 | Handle(SelectMgr_Selection) aSel = theIObj->Selection( aMode ); |
1138 | |
1139 | for ( aSel->Init(); aSel->More(); aSel->Next() ) |
1140 | { |
1141 | Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive(); |
1142 | if ( aEntity.IsNull() ) |
1143 | continue; |
1144 | |
1145 | Handle(SelectMgr_EntityOwner) aOwner = |
1146 | Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId()); |
1147 | if ( !aOwner.IsNull() ) |
1148 | theOwners.Add( aOwner ); |
1149 | } |
1150 | } |
1151 | } |
1152 | |
1153 | Standard_Integer AIS_InteractiveContext::NbSelected() |
1154 | { |
1155 | Standard_Integer i(0); |
1156 | for(InitSelected();MoreSelected();NextSelected()) |
1157 | {i++;} |
1158 | return i; |
1159 | } |
1160 | |
1161 | //======================================================================= |
1162 | //function : HasApplicative |
1163 | //purpose : |
1164 | //======================================================================= |
1165 | |
1166 | Standard_Boolean AIS_InteractiveContext::HasApplicative() const |
1167 | { |
1168 | return Interactive()->HasOwner(); |
1169 | } |
1170 | |
1171 | //======================================================================= |
1172 | //function : Applicative |
1173 | //purpose : |
1174 | //======================================================================= |
1175 | |
1176 | Handle(Standard_Transient) AIS_InteractiveContext::Applicative() const |
1177 | { |
1178 | return Interactive()->GetOwner(); |
1179 | } |
1180 | |
1181 | |
1182 | |
1183 | //================================================== |
1184 | // Function: |
1185 | // Purpose : |
1186 | //================================================== |
1187 | Standard_Boolean AIS_InteractiveContext::HasDetected() const |
1188 | { |
1189 | if(HasOpenedContext()) |
1190 | return myLocalContexts(myCurLocalIndex)->HasDetected(); |
1191 | else |
1192 | return !myLastPicked.IsNull(); |
1193 | } |
1194 | |
1195 | //======================================================================= |
1196 | //function : HasDetectedShape |
1197 | //purpose : |
1198 | //======================================================================= |
1199 | |
1200 | Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const |
1201 | { |
1202 | if(HasOpenedContext()) |
1203 | return myLocalContexts(myCurLocalIndex)->HasDetectedShape(); |
1204 | return Standard_False; |
1205 | } |
1206 | |
1207 | //======================================================================= |
1208 | //function : DetectedShape |
1209 | //purpose : |
1210 | //======================================================================= |
1211 | |
1212 | const TopoDS_Shape& |
1213 | AIS_InteractiveContext::DetectedShape() const |
1214 | { |
1215 | return myLocalContexts(myCurLocalIndex)->DetectedShape(); |
1216 | } |
1217 | |
1218 | //======================================================================= |
1219 | //function : DetectedInteractive |
1220 | //purpose : |
1221 | //======================================================================= |
1222 | |
1223 | Handle(AIS_InteractiveObject) |
1224 | AIS_InteractiveContext::DetectedInteractive() const |
1225 | { |
1226 | if(HasOpenedContext()) |
1227 | return myLocalContexts(myCurLocalIndex)->DetectedInteractive(); |
1228 | return myLastPicked; |
1229 | } |
1230 | |
1231 | |
1232 | Standard_Boolean AIS_InteractiveContext::HasNextDetected() const |
1233 | { |
1234 | if(!HasOpenedContext()) |
1235 | return Standard_False; // temporaire |
1236 | else |
1237 | return myLocalContexts(myCurLocalIndex)->HasNextDetected(); |
1238 | |
1239 | } |
1240 | |
1241 | |
1242 | //======================================================================= |
1243 | //function : DetectedOwner |
1244 | //purpose : |
1245 | //======================================================================= |
1246 | Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const |
1247 | { |
1248 | if(HasOpenedContext()) |
1249 | return myLocalContexts(myCurLocalIndex)->DetectedOwner(); |
1250 | Handle(SelectMgr_EntityOwner) Ownr; |
1251 | return Ownr; |
1252 | } |
1253 | |
1254 | |
1255 | //======================================================================= |
1256 | //function : HilightNextDetected |
679ecdee |
1257 | //purpose : |
7fd59977 |
1258 | //======================================================================= |
679ecdee |
1259 | Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView, |
1260 | const Standard_Boolean theToRedrawImmediate) |
7fd59977 |
1261 | { |
679ecdee |
1262 | return HasOpenedContext() |
1263 | ? myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate) |
1264 | : 0; |
7fd59977 |
1265 | |
1266 | } |
1267 | |
1268 | //======================================================================= |
1269 | //function : HilightNextDetected |
679ecdee |
1270 | //purpose : |
7fd59977 |
1271 | //======================================================================= |
679ecdee |
1272 | Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView, |
1273 | const Standard_Boolean theToRedrawImmediate) |
7fd59977 |
1274 | { |
679ecdee |
1275 | return HasOpenedContext() |
1276 | ? myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate) |
1277 | : 0; |
7fd59977 |
1278 | |
1279 | } |
1280 | |
7fd59977 |
1281 | //======================================================================= |
1282 | //function : InitDetected |
1283 | //purpose : |
1284 | //======================================================================= |
1285 | void AIS_InteractiveContext::InitDetected() |
1286 | { |
57ad5cbd |
1287 | if (HasOpenedContext()) |
7fd59977 |
1288 | { |
1289 | myLocalContexts(myCurLocalIndex)->InitDetected(); |
1290 | return; |
1291 | } |
1292 | |
1293 | if(myAISDetectedSeq.Length() != 0) |
57ad5cbd |
1294 | { |
7fd59977 |
1295 | myAISCurDetected = 1; |
57ad5cbd |
1296 | } |
7fd59977 |
1297 | } |
1298 | |
1299 | //======================================================================= |
1300 | //function : MoreDetected |
1301 | //purpose : |
1302 | //======================================================================= |
1303 | Standard_Boolean AIS_InteractiveContext::MoreDetected() const |
1304 | { |
57ad5cbd |
1305 | if (HasOpenedContext()) |
1306 | { |
7fd59977 |
1307 | return myLocalContexts(myCurLocalIndex)->MoreDetected(); |
57ad5cbd |
1308 | } |
7fd59977 |
1309 | |
57ad5cbd |
1310 | return (myAISCurDetected > 0 && myAISCurDetected <= myAISDetectedSeq.Length()) ? |
7fd59977 |
1311 | Standard_True : Standard_False; |
1312 | } |
1313 | |
1314 | //======================================================================= |
1315 | //function : NextDetected |
1316 | //purpose : |
1317 | //======================================================================= |
1318 | void AIS_InteractiveContext::NextDetected() |
1319 | { |
1320 | if(HasOpenedContext()) |
1321 | { |
1322 | myLocalContexts(myCurLocalIndex)->NextDetected(); |
1323 | return; |
1324 | } |
1325 | |
1326 | myAISCurDetected++; |
1327 | } |
1328 | |
1329 | //======================================================================= |
1330 | //function : DetectedCurrentShape |
1331 | //purpose : |
1332 | //======================================================================= |
7fd59977 |
1333 | const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const |
1334 | { |
57ad5cbd |
1335 | if (HasOpenedContext()) |
1336 | { |
7fd59977 |
1337 | return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape(); |
57ad5cbd |
1338 | } |
7fd59977 |
1339 | |
57ad5cbd |
1340 | static TopoDS_Shape aDummyShape; |
1341 | |
1342 | Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject()); |
1343 | |
1344 | if (aCurrentShape.IsNull()) |
1345 | { |
1346 | return aDummyShape; |
1347 | } |
1348 | |
1349 | return aCurrentShape->Shape(); |
7fd59977 |
1350 | } |
1351 | |
1352 | //======================================================================= |
1353 | //function : DetectedCurrentObject |
1354 | //purpose : |
1355 | //======================================================================= |
57ad5cbd |
1356 | Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const |
1357 | { |
1358 | if (HasOpenedContext()) |
1359 | { |
7fd59977 |
1360 | return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject(); |
57ad5cbd |
1361 | } |
7fd59977 |
1362 | |
57ad5cbd |
1363 | return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL; |
7fd59977 |
1364 | } |