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