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