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