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