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