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