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