1 // Created on: 1997-01-29
2 // Created by: Robert COUBLANC
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <AIS_DataMapIteratorOfDataMapOfIOStatus.hxx>
19 #include <AIS_GlobalStatus.hxx>
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>
26 #include <AIS_Shape.hxx>
27 #include <AIS_StatusOfDetection.hxx>
28 #include <AIS_StatusOfPick.hxx>
29 #include <Aspect_Grid.hxx>
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>
41 #include <StdSelect_BRepOwner.hxx>
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>
47 #include <V3d_AmbientLight.hxx>
48 #include <V3d_DirectionalLight.hxx>
49 #include <V3d_Light.hxx>
50 #include <V3d_PositionalLight.hxx>
51 #include <V3d_SpotLight.hxx>
52 #include <V3d_View.hxx>
53 #include <V3d_Viewer.hxx>
55 typedef NCollection_DataMap<Handle(AIS_InteractiveObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > AIS_MapOfObjSelectedOwners;
59 TopoDS_Shape AIS_InteractiveContext_myDummyShape;
62 //=======================================================================
63 //function : highlightWithColor
65 //=======================================================================
66 void AIS_InteractiveContext::highlightWithColor (const Handle(SelectMgr_EntityOwner)& theOwner,
67 const Handle(V3d_Viewer)& theViewer)
69 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
75 const Handle(Prs3d_Drawer)& aStyle = getHiStyle (anObj, theOwner);
76 const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1);
78 myMainPM->BeginImmediateDraw();
79 theOwner->HilightWithColor (myMainPM, aStyle, aHiMode);
80 myMainPM->EndImmediateDraw (theViewer.IsNull() ? myMainVwr : theViewer);
83 //=======================================================================
84 //function : highlightSelected
86 //=======================================================================
87 void AIS_InteractiveContext::highlightSelected (const Handle(SelectMgr_EntityOwner)& theOwner)
89 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
95 if (!theOwner->IsAutoHilight())
97 SelectMgr_SequenceOfOwner aSeq;
98 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
100 if (aSelIter.Value()->IsSameSelectable (anObj))
102 aSeq.Append (aSelIter.Value());
105 anObj->HilightSelected (myMainPM, aSeq);
109 const Handle(Prs3d_Drawer)& aStyle = getSelStyle (anObj, theOwner);
110 const Standard_Integer aHiMode = getHilightMode (anObj, aStyle, -1);
111 theOwner->HilightWithColor (myMainPM, aStyle, aHiMode);
115 //=======================================================================
116 //function : highlightGlobal
118 //=======================================================================
119 void AIS_InteractiveContext::highlightGlobal (const Handle(AIS_InteractiveObject)& theObj,
120 const Handle(Prs3d_Drawer)& theStyle,
121 const Standard_Integer theDispMode) const
128 const Standard_Integer aHiMode = getHilightMode (theObj, theStyle, theDispMode);
129 const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
131 if (aGlobOwner.IsNull())
133 myMainPM->Color (theObj, theStyle, aHiMode);
137 if (!aGlobOwner->IsAutoHilight())
139 SelectMgr_SequenceOfOwner aSeq;
140 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
142 if (aSelIter.Value()->IsSameSelectable (theObj))
144 aSeq.Append (aSelIter.Value());
147 theObj->HilightSelected (myMainPM, aSeq);
151 aGlobOwner->HilightWithColor (myMainPM, theStyle, aHiMode);
155 //=======================================================================
156 //function : unhighlightSelected
158 //=======================================================================
159 void AIS_InteractiveContext::unhighlightSelected (const Standard_Boolean theIsToHilightSubIntensity)
161 NCollection_IndexedMap<Handle(AIS_InteractiveObject)> anObjToClear;
162 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
164 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
165 const Handle(AIS_InteractiveObject) anInteractive = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
166 Handle(AIS_GlobalStatus) aStatus;
167 if (!myObjects.Find (anInteractive, aStatus))
172 if (anOwner->IsAutoHilight())
174 anOwner->Unhilight (myMainPM);
175 if (theIsToHilightSubIntensity)
177 if (aStatus->IsSubIntensityOn())
179 const Standard_Integer aHiMode = getHilightMode (anInteractive, aStatus->HilightStyle(), aStatus->DisplayMode());
180 highlightWithSubintensity (anOwner, aHiMode);
186 anObjToClear.Add (anInteractive);
188 anOwner->SetSelected (Standard_False);
189 if (anOwner == anInteractive->GlobalSelOwner())
191 myObjects.ChangeFind (anInteractive)->SetHilightStatus (Standard_False);
194 for (NCollection_IndexedMap<Handle(AIS_InteractiveObject)>::Iterator anIter (anObjToClear); anIter.More(); anIter.Next())
196 const Handle(AIS_InteractiveObject)& anObj = anIter.Value();
197 myMainPM->Unhighlight (anObj);
198 anObj->ClearSelected();
202 //=======================================================================
203 //function : unhighlightGlobal
205 //=======================================================================
206 void AIS_InteractiveContext::unhighlightGlobal (const Handle(AIS_InteractiveObject)& theObj) const
213 const Handle(SelectMgr_EntityOwner)& aGlobOwner = theObj->GlobalSelOwner();
214 if (aGlobOwner.IsNull())
216 myMainPM->Unhighlight (theObj);
220 if (aGlobOwner->IsAutoHilight())
222 aGlobOwner->Unhilight (myMainPM);
226 myMainPM->Unhighlight (theObj);
227 theObj->ClearSelected();
231 //=======================================================================
232 //function : turnOnSubintensity
234 //=======================================================================
235 void AIS_InteractiveContext::turnOnSubintensity (const Handle(AIS_InteractiveObject)& theObject,
236 const Standard_Integer theDispMode,
237 const Standard_Boolean theIsDisplayedOnly) const
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());
243 if (theObject.IsNull())
245 for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjsIter (myObjects); anObjsIter.More(); anObjsIter.Next())
247 const Handle(AIS_GlobalStatus)& aStatus = anObjsIter.Value();
248 if (aStatus->GraphicStatus() != AIS_DS_Displayed && theIsDisplayedOnly)
251 aStatus->SubIntensityOn();
252 myMainPM->Color (anObjsIter.Key(), aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
257 Handle(AIS_GlobalStatus) aStatus;
258 if (!myObjects.Find (theObject, aStatus))
261 if (aStatus->GraphicStatus() != AIS_DS_Displayed && theIsDisplayedOnly)
264 aStatus->SubIntensityOn();
265 myMainPM->Color (theObject, aSubStyle, theDispMode != -1 ? theDispMode : aStatus->DisplayMode());
269 //=======================================================================
270 //function : highlightWithSubintensity
272 //=======================================================================
273 void AIS_InteractiveContext::highlightWithSubintensity (const Handle(AIS_InteractiveObject)& theObject,
274 const Standard_Integer theMode) const
276 // the only differ with selection highlight is color, so
277 // sync transparency values
278 myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
280 myMainPM->Color (theObject, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
283 //=======================================================================
284 //function : highlightWithSubintensity
286 //=======================================================================
287 void AIS_InteractiveContext::highlightWithSubintensity (const Handle(SelectMgr_EntityOwner)& theOwner,
288 const Standard_Integer theMode) const
290 // the only differ with selection highlight is color, so
291 // sync transparency values
292 myStyles[Prs3d_TypeOfHighlight_SubIntensity]->SetTransparency (myStyles[Prs3d_TypeOfHighlight_Selected]->Transparency());
294 theOwner->HilightWithColor (myMainPM, myStyles[Prs3d_TypeOfHighlight_SubIntensity], theMode);
297 //=======================================================================
300 //=======================================================================
301 AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer theXPix,
302 const Standard_Integer theYPix,
303 const Handle(V3d_View)& theView,
304 const Standard_Boolean theToRedrawOnUpdate)
306 if (HasOpenedContext())
308 myWasLastMain = Standard_True;
309 return myLocalContexts (myCurLocalIndex)->MoveTo (theXPix, theYPix, theView, theToRedrawOnUpdate);
313 myCurHighlighted = 0;
314 myDetectedSeq.Clear();
316 if (theView->Viewer() != myMainVwr)
318 return AIS_SOD_Error;
322 myLastPicked = myLastinMain;
323 myWasLastMain = Standard_True;
324 AIS_StatusOfDetection aStatus = AIS_SOD_Nothing;
325 Standard_Boolean toUpdateViewer = Standard_False;
327 myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
328 myMainSel->Pick (theXPix, theYPix, theView);
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();
333 Standard_Integer aNewDetected = 0;
334 Standard_Boolean toIgnoreDetTop = Standard_False;
335 for (Standard_Integer aDetIter = 1; aDetIter <= aDetectedNb; ++aDetIter)
337 Handle(SelectMgr_EntityOwner) anOwner = myMainSel->Picked (aDetIter);
339 || !myFilters->IsOk (anOwner))
341 if (myPickingStrategy == SelectMgr_PickingStrategy_OnlyTopmost)
343 toIgnoreDetTop = Standard_True;
351 aNewDetected = aDetIter;
354 myDetectedSeq.Append (aDetIter);
357 if (aNewDetected >= 1)
359 myCurHighlighted = myDetectedSeq.Lower();
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)
367 Handle(SelectMgr_EntityOwner) aNewPickedOwner = myMainSel->Picked (aNewDetected);
368 if (aNewPickedOwner == myLastPicked && !aNewPickedOwner->IsForcedHilight())
370 return myLastPicked->IsSelected()
372 : AIS_SOD_OnlyOneDetected;
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.
380 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
382 clearDynamicHighlight();
383 toUpdateViewer = Standard_True;
386 // initialize myLastPicked field with currently detected object
387 myLastPicked = aNewPickedOwner;
388 myLastinMain = myLastPicked;
390 // highlight detected object if it is not selected or myToHilightSelected flag is true
391 if (myLastPicked->HasSelectable())
393 if (!myLastPicked->IsSelected() || myToHilightSelected)
395 highlightWithColor (myLastPicked, theView->Viewer());
396 toUpdateViewer = Standard_True;
399 aStatus = myLastPicked->IsSelected()
401 : AIS_SOD_OnlyOneDetected;
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;
409 if (!myLastPicked.IsNull() && myLastPicked->HasSelectable())
411 clearDynamicHighlight();
412 toUpdateViewer = Standard_True;
415 myLastinMain.Nullify();
416 myLastPicked.Nullify();
420 && theToRedrawOnUpdate)
422 theView->Viewer()->Update();
425 mylastmoveview = theView;
429 //=======================================================================
430 //function : AddSelect
432 //=======================================================================
433 AIS_StatusOfPick AIS_InteractiveContext::AddSelect (const Handle(SelectMgr_EntityOwner)& theObject)
435 if (HasOpenedContext())
437 return myLocalContexts(myCurLocalIndex)->AddSelect (theObject);
439 mySelection->AddSelect (theObject);
441 Standard_Integer aSelNum = NbSelected();
442 return (aSelNum == 0) ? AIS_SOP_NothingSelected
443 : (aSelNum == 1) ? AIS_SOP_OneSelected
444 : AIS_SOP_SeveralSelected;
447 //=======================================================================
450 //=======================================================================
451 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin,
452 const Standard_Integer theYPMin,
453 const Standard_Integer theXPMax,
454 const Standard_Integer theYPMax,
455 const Handle(V3d_View)& theView,
456 const Standard_Boolean toUpdateViewer)
458 // all objects detected by the selector are taken, previous current objects are emptied,
459 // new objects are put...
461 if (HasOpenedContext())
463 return myLocalContexts(myCurLocalIndex)->Select (theXPMin, theYPMin,
465 theView, toUpdateViewer);
468 ClearSelected (Standard_False);
470 Handle(StdSelect_ViewerSelector3d) aSelector;
472 if (theView->Viewer() == myMainVwr)
474 aSelector = myMainSel;
475 myWasLastMain = Standard_True;
478 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
479 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
481 const Handle(SelectMgr_EntityOwner)& aCurOwner = aSelector->Picked (aPickIter);
482 if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
485 mySelection->Select (aCurOwner);
486 aCurOwner->SetSelected (Standard_True);
489 HilightSelected (toUpdateViewer);
491 Standard_Integer aSelNum = NbSelected();
493 return (aSelNum == 0) ? AIS_SOP_NothingSelected
494 : (aSelNum == 1) ? AIS_SOP_OneSelected
495 : AIS_SOP_SeveralSelected;
499 //=======================================================================
501 //purpose : Selection by polyline
502 //=======================================================================
503 AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
504 const Handle(V3d_View)& theView,
505 const Standard_Boolean toUpdateViewer)
507 // all objects detected by the selector are taken, previous current objects are emptied,
508 // new objects are put...
510 if (HasOpenedContext())
512 return myLocalContexts(myCurLocalIndex)->Select (thePolyline, theView, toUpdateViewer);
515 ClearSelected (Standard_False);
517 Handle(StdSelect_ViewerSelector3d) aSelector;
519 if (theView->Viewer() == myMainVwr)
521 aSelector = myMainSel;
522 myWasLastMain = Standard_True;
525 aSelector->Pick (thePolyline, theView);
526 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
528 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
529 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
532 mySelection->Select (anOwner);
533 anOwner->SetSelected (Standard_True);
536 HilightSelected (toUpdateViewer);
538 Standard_Integer aSelNum = NbSelected();
540 return (aSelNum == 0) ? AIS_SOP_NothingSelected
541 : (aSelNum == 1) ? AIS_SOP_OneSelected
542 : AIS_SOP_SeveralSelected;
546 //=======================================================================
549 //=======================================================================
550 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
552 if (HasOpenedContext())
556 return myLocalContexts(myCurLocalIndex)->Select (toUpdateViewer);
560 myLocalContexts(myCurLocalIndex)->SetSelected (Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()), toUpdateViewer);
561 return AIS_SOP_OneSelected;
565 clearDynamicHighlight();
566 if (myWasLastMain && !myLastinMain.IsNull())
568 if (!myLastinMain->IsSelected() || myLastinMain->IsForcedHilight())
570 SetSelected (myLastinMain, Standard_False);
573 UpdateCurrentViewer();
579 unhighlightSelected (Standard_True);
581 mySelection->Clear();
582 if (toUpdateViewer && myWasLastMain)
584 UpdateCurrentViewer();
588 Standard_Integer aSelNum = NbSelected();
590 return (aSelNum == 0) ? AIS_SOP_NothingSelected
591 : (aSelNum == 1) ? AIS_SOP_OneSelected
592 : AIS_SOP_SeveralSelected;
595 //=======================================================================
596 //function : ShiftSelect
598 //=======================================================================
599 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
601 if (HasOpenedContext())
605 return myLocalContexts (myCurLocalIndex)->ShiftSelect (toUpdateViewer);
609 myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (myLastPicked, toUpdateViewer);
611 Standard_Integer aSelNum = NbSelected();
612 return (aSelNum == 0) ? AIS_SOP_NothingSelected
613 : (aSelNum == 1) ? AIS_SOP_OneSelected
614 : AIS_SOP_SeveralSelected;
618 clearDynamicHighlight();
619 if (myWasLastMain && !myLastinMain.IsNull())
621 AddOrRemoveSelected (myLastinMain, toUpdateViewer);
624 Standard_Integer aSelNum = NbSelected();
626 return (aSelNum == 0) ? AIS_SOP_NothingSelected
627 : (aSelNum == 1) ? AIS_SOP_OneSelected
628 : AIS_SOP_SeveralSelected;
631 //=======================================================================
632 //function : ShiftSelect
634 //=======================================================================
635 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin,
636 const Standard_Integer theYPMin,
637 const Standard_Integer theXPMax,
638 const Standard_Integer theYPMax,
639 const Handle(V3d_View)& theView,
640 const Standard_Boolean toUpdateViewer)
642 if (HasOpenedContext())
644 return myLocalContexts(myCurLocalIndex)->ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax,
645 theView, toUpdateViewer);
648 UnhilightSelected (Standard_False);
650 Handle(StdSelect_ViewerSelector3d) aSelector;
651 if (theView->Viewer() == myMainVwr)
653 aSelector = myMainSel;
654 myWasLastMain = Standard_True;
658 return AIS_SOP_NothingSelected;
661 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
662 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
664 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
665 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
668 AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
669 anOwner->SetSelected (aSelStatus == AIS_SS_Added);
672 HilightSelected (toUpdateViewer);
674 Standard_Integer aSelNum = NbSelected();
676 return (aSelNum == 0) ? AIS_SOP_NothingSelected
677 : (aSelNum == 1) ? AIS_SOP_OneSelected
678 : AIS_SOP_SeveralSelected;
682 //=======================================================================
683 //function : ShiftSelect
685 //=======================================================================
686 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
687 const Handle(V3d_View)& theView,
688 const Standard_Boolean toUpdateViewer)
690 if (HasOpenedContext())
692 return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer);
695 UnhilightSelected (Standard_False);
697 Handle(StdSelect_ViewerSelector3d) aSelector;
699 if (theView->Viewer() == myMainVwr)
701 aSelector= myMainSel;
702 myWasLastMain = Standard_True;
706 return AIS_SOP_NothingSelected;
709 aSelector->Pick (thePolyline, theView);
710 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
712 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
713 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
716 AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
717 anOwner->SetSelected (aSelStatus == AIS_SS_Added);
720 HilightSelected (toUpdateViewer);
722 Standard_Integer aSelNum = NbSelected();
724 return (aSelNum == 0) ? AIS_SOP_NothingSelected
725 : (aSelNum == 1) ? AIS_SOP_OneSelected
726 : AIS_SOP_SeveralSelected;
729 //=======================================================================
730 //function : SetCurrentObject
731 //purpose : OBSOLETE, please use SetSelected() instead
732 //TODO : Remove in process of local context deletion
733 //=======================================================================
734 void AIS_InteractiveContext::SetCurrentObject (const Handle(AIS_InteractiveObject)& theObject,
735 const Standard_Boolean theToUpdateViewer)
737 if (HasOpenedContext())
740 SetSelected (theObject, theToUpdateViewer);
743 //=======================================================================
744 //function : AddOrRemoveCurrentObject
745 //purpose : OBSOLETE, please use AddOrRemoveSelected() instead
746 //TODO : Remove in process of local context deletion
747 //=======================================================================
748 void AIS_InteractiveContext::AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj,
749 const Standard_Boolean theIsToUpdateViewer)
751 if (HasOpenedContext())
754 AddOrRemoveSelected (theObj, theIsToUpdateViewer);
756 //=======================================================================
757 //function : UpdateCurrent
758 //purpose : OBSOLETE, please use UpdateSelected() instead
759 //TODO : Remove in process of local context deletion
760 //=======================================================================
761 void AIS_InteractiveContext::UpdateCurrent()
763 UpdateSelected (Standard_True);
766 //=======================================================================
767 //function : IsCurrent
768 //purpose : OBSOLETE, please use IsSelected() instead
769 //TODO : Remove in process of local context deletion
770 //=======================================================================
771 Standard_Boolean AIS_InteractiveContext::IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const
773 return IsSelected (theObject);
776 //=======================================================================
777 //function : InitCurrent
778 //purpose : OBSOLETE, please use InitSelected() instead
779 //TODO : Remove in process of local context deletion
780 //=======================================================================
781 void AIS_InteractiveContext::InitCurrent()
783 if (HasOpenedContext())
789 //=======================================================================
790 //function : MoreCurrent
791 //purpose : OBSOLETE, please use MoreSelected() instead
792 //TODO : Remove in process of local context deletion
793 //=======================================================================
794 Standard_Boolean AIS_InteractiveContext::MoreCurrent() const
796 return !HasOpenedContext() && MoreSelected();
799 //=======================================================================
800 //function : NextCurrent
801 //purpose : OBSOLETE, please use NextSelected() instead
802 //TODO : Remove in process of local context deletion
803 //=======================================================================
804 void AIS_InteractiveContext::NextCurrent()
806 if (HasOpenedContext())
812 //=======================================================================
814 //purpose : OBSOLETE, please use SelectedInteractive() instead
815 //TODO : Remove in process of local context deletion
816 //=======================================================================
817 Handle(AIS_InteractiveObject) AIS_InteractiveContext::Current() const
819 return HasOpenedContext() ? NULL : SelectedInteractive();
822 //=======================================================================
823 //function : NbCurrents
824 //purpose : OBSOLETE, please use NbSelected() instead
825 //TODO : Remove in process of local context deletion
826 //=======================================================================
827 Standard_Integer AIS_InteractiveContext::NbCurrents()
829 return HasOpenedContext() ? -1 : NbSelected();
832 //=======================================================================
833 //function : HilightCurrents
834 //purpose : OBSOLETE, please use HilightSelected() instead
835 //TODO : Remove in process of local context deletion
836 //=======================================================================
837 void AIS_InteractiveContext::HilightCurrents (const Standard_Boolean theToUpdateViewer)
839 if (HasOpenedContext())
842 HilightSelected (theToUpdateViewer);
845 //=======================================================================
846 //function : UnhilightCurrents
847 //purpose : OBSOLETE, please use UnhilightSelected() instead
848 //TODO : Remove in process of local context deletion
849 //=======================================================================
850 void AIS_InteractiveContext::UnhilightCurrents (const Standard_Boolean theToUpdateViewer)
852 if (HasOpenedContext())
855 UnhilightSelected (theToUpdateViewer);
858 //=======================================================================
859 //function : ClearCurrents
860 //purpose : OBSOLETE, please use ClearCurrents() instead
861 //TODO : Remove in process of local context deletion
862 //=======================================================================
863 void AIS_InteractiveContext::ClearCurrents(const Standard_Boolean theToUpdateViewer)
865 if (HasOpenedContext())
868 ClearSelected (theToUpdateViewer);
872 //=======================================================================
873 //function : HilightSelected
875 //=======================================================================
876 void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdateViewer)
878 if (HasOpenedContext())
880 return myLocalContexts (myCurLocalIndex)->HilightPicked (theToUpdateViewer);
883 // In case of selection without using local context
884 clearDynamicHighlight();
885 AIS_MapOfObjSelectedOwners anObjOwnerMap;
886 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
888 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
889 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
890 const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObj, anOwner);
891 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind(anObj);
892 if (anOwner == anObj->GlobalSelOwner())
894 aState->SetHilightStatus (Standard_True);
895 aState->SetHilightStyle (anObjSelStyle);
897 anOwner->SetSelected (Standard_True);
898 if (!anOwner->IsAutoHilight())
900 NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
901 if (anObjOwnerMap.Find (anObj, aSeq))
903 aSeq->Append (anOwner);
907 aSeq = new SelectMgr_SequenceOfOwner();
908 aSeq->Append (anOwner);
909 anObjOwnerMap.Bind (anObj, aSeq);
914 const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, aState->DisplayMode());
915 anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
919 if (!anObjOwnerMap.IsEmpty())
921 for (AIS_MapOfObjSelectedOwners::Iterator anIter (anObjOwnerMap); anIter.More(); anIter.Next())
923 anIter.Key()->HilightSelected (myMainPM, *anIter.Value());
925 anObjOwnerMap.Clear();
928 if (theToUpdateViewer)
929 UpdateCurrentViewer();
932 //=======================================================================
933 //function : UnhilightSelected
935 //=======================================================================
936 void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
938 if (HasOpenedContext())
940 return myLocalContexts (myCurLocalIndex)->UnhilightPicked (theToUpdateViewer);
943 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
945 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
946 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
947 if (anOwner == anObj->GlobalSelOwner())
949 myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
952 anOwner->SetSelected (Standard_False);
953 anOwner->Unhilight (myMainPM);
956 if (theToUpdateViewer)
957 UpdateCurrentViewer();
961 //=======================================================================
962 //function : ClearSelected
964 //=======================================================================
965 void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateViewer)
967 if (HasOpenedContext())
968 return myLocalContexts (myCurLocalIndex)->ClearSelected (theToUpdateViewer);
970 if (NbSelected() == 0)
973 unhighlightSelected();
975 mySelection->Clear();
976 clearDynamicHighlight();
978 if (theToUpdateViewer)
979 UpdateCurrentViewer();
982 //=======================================================================
983 //function : UpdateSelected
985 //=======================================================================
986 void AIS_InteractiveContext::UpdateSelected (const Standard_Boolean theToUpdateViewer)
988 if (HasOpenedContext())
990 return myLocalContexts(myCurLocalIndex)->UpdateSelected (theToUpdateViewer);
993 HilightSelected (theToUpdateViewer);
996 //=======================================================================
997 //function : SetSelected
998 //purpose : Sets the whole object as selected and highlights it with selection color
999 //=======================================================================
1000 void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject,
1001 const Standard_Boolean theToUpdateViewer)
1003 if (HasOpenedContext())
1005 return myLocalContexts (myCurLocalIndex)->SetSelected (theObject, theToUpdateViewer);
1008 if (theObject.IsNull())
1013 if (!myObjects.IsBound (theObject))
1015 Display (theObject, Standard_False);
1017 if (!theObject->HasSelection (theObject->GlobalSelectionMode()))
1021 Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
1022 if (anOwner.IsNull())
1027 const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (theObject, anOwner);
1028 if (NbSelected() == 1 && myObjects (theObject)->IsHilighted())
1030 Handle(Prs3d_Drawer) aCustomStyle;
1031 if (HighlightStyle (theObject, aCustomStyle))
1033 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1035 HilightWithColor (theObject, anObjSelStyle, theToUpdateViewer);
1041 for (mySelection->Init(); mySelection->More(); mySelection->Next())
1043 const Handle(SelectMgr_EntityOwner) aSelOwner = mySelection->Value();
1044 if (!myFilters->IsOk (aSelOwner))
1049 Handle(AIS_InteractiveObject) aSelectable = Handle(AIS_InteractiveObject)::DownCast (aSelOwner->Selectable());
1050 Unhilight (aSelectable, Standard_False);
1051 aSelOwner->SetSelected (Standard_False);
1052 if (aSelOwner == aSelectable->GlobalSelOwner())
1054 myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False);
1058 // added to avoid untimely viewer update...
1059 mySelection->ClearAndSelect (anOwner);
1061 Handle(Prs3d_Drawer) aCustomStyle;
1062 if (HighlightStyle (theObject, aCustomStyle))
1064 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1066 HilightWithColor (theObject, anObjSelStyle, Standard_False);
1071 HilightWithColor (theObject, anObjSelStyle, Standard_False);
1073 anOwner->SetSelected (Standard_True);
1075 if (theToUpdateViewer)
1076 UpdateCurrentViewer();
1079 //=======================================================================
1080 //function : SetSelected
1081 //purpose : Sets the whole object as selected and highlights it with selection color
1082 //=======================================================================
1083 void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1084 const Standard_Boolean theToUpdateViewer)
1086 if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
1089 const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1090 const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObject, theOwner);
1091 if (NbSelected() == 1 && theOwner->IsSelected() && !theOwner->IsForcedHilight())
1093 Handle(Prs3d_Drawer) aCustomStyle;
1094 if (HighlightStyle (theOwner, aCustomStyle))
1096 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1098 const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
1099 theOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
1105 if (!myObjects.IsBound (anObject))
1106 Display (anObject, Standard_False);
1108 unhighlightSelected();
1110 mySelection->ClearAndSelect (theOwner);
1111 Handle(Prs3d_Drawer) aCustomStyle;
1112 if (!HighlightStyle (theOwner, aCustomStyle) ||
1113 (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle))
1115 theOwner->SetSelected (Standard_True);
1116 highlightSelected (theOwner);
1119 theOwner->SetSelected (Standard_True);
1120 if (theOwner == anObject->GlobalSelOwner())
1122 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
1123 aState->SetHilightStatus (Standard_True);
1124 aState->SetHilightStyle (anObjSelStyle);
1127 if (theToUpdateViewer)
1128 UpdateCurrentViewer();
1131 //=======================================================================
1132 //function : AddOrRemoveSelected
1133 //purpose : Adds or removes current object from AIS selection and highlights/unhighlights it.
1134 // Since this method makes sence only for neutral point selection of a whole object,
1135 // if 0 selection of the object is empty this method simply does nothing.
1136 //=======================================================================
1137 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
1138 const Standard_Boolean theToUpdateViewer)
1140 if (theObject.IsNull())
1143 if (HasOpenedContext())
1144 return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer);
1146 const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode();
1147 if (!myObjects.IsBound (theObject) || !theObject->HasSelection (aGlobalSelMode))
1150 setContextToObject (theObject);
1151 const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
1153 if (anOwner.IsNull() || !anOwner->HasSelectable())
1156 AddOrRemoveSelected (anOwner, theToUpdateViewer);
1158 //=======================================================================
1159 //function : AddOrRemoveSelected
1161 //=======================================================================
1163 void AIS_InteractiveContext::AddOrRemoveSelected (const TopoDS_Shape& aShap,
1164 const Standard_Boolean updateviewer)
1166 if(!HasOpenedContext()) {
1168 cout<<" Attempt to remove a selected shape with no opened local context"<<endl;
1173 myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(aShap,updateviewer);
1174 if(updateviewer) UpdateCurrentViewer();
1178 //=======================================================================
1179 //function : AddOrRemoveSelected
1180 //purpose : Allows to highlight or unhighlight the owner given depending on
1181 // its selection status
1182 //=======================================================================
1183 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1184 const Standard_Boolean theToUpdateViewer)
1186 if (HasOpenedContext())
1187 return myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected (theOwner, theToUpdateViewer);
1189 if (theOwner.IsNull() || !theOwner->HasSelectable())
1192 if (!myFilters->IsOk(theOwner) && !theOwner->IsSelected())
1195 AIS_SelectStatus aSelStat = mySelection->Select (theOwner);
1196 theOwner->SetSelected (aSelStat == AIS_SS_Added);
1197 const Handle(AIS_InteractiveObject) anObj =
1198 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1199 const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
1200 Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
1201 if (theOwner->IsSelected())
1203 highlightSelected (theOwner);
1206 aStatus->SetHilightStatus (Standard_True);
1207 aStatus->SetHilightStyle (getSelStyle (anObj, theOwner));
1212 if (theOwner->IsAutoHilight())
1214 theOwner->Unhilight (myMainPM);
1218 anObj->ClearSelected();
1220 aStatus->SetHilightStatus (Standard_False);
1221 aStatus->SetHilightStyle (Handle(Prs3d_Drawer)());
1224 if (theToUpdateViewer)
1225 UpdateCurrentViewer();
1229 //=======================================================================
1230 //function : IsSelected
1232 //=======================================================================
1233 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_InteractiveObject)& theObj) const
1235 if(HasOpenedContext())
1236 return myLocalContexts(myCurLocalIndex)->IsSelected (theObj);
1238 if (theObj.IsNull() || !myObjects.IsBound (theObj))
1239 return Standard_False;
1241 const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode();
1242 const TColStd_ListOfInteger& anActivatedModes = myObjects (theObj)->SelectionModes();
1243 Standard_Boolean isGlobalModeActivated = Standard_False;
1244 for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
1246 if (aModeIter.Value() == aGlobalSelMode)
1248 isGlobalModeActivated = Standard_True;
1252 if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated || theObj->GlobalSelOwner().IsNull())
1253 return Standard_False;
1255 return theObj->GlobalSelOwner()->IsSelected();
1258 //=======================================================================
1259 //function : IsSelected
1260 //purpose : Returns true is the owner given is selected
1261 //=======================================================================
1262 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const
1264 if (HasOpenedContext())
1265 return myLocalContexts(myCurLocalIndex)->IsSelected (theOwner);
1267 if (theOwner.IsNull())
1268 return Standard_False;
1270 return theOwner->IsSelected();
1273 //=======================================================================
1274 //function : InitSelected
1276 //=======================================================================
1277 void AIS_InteractiveContext::InitSelected()
1279 if (HasOpenedContext())
1281 myLocalContexts (myCurLocalIndex)->InitSelected();
1285 mySelection->Init();
1288 //=======================================================================
1289 //function : MoreSelected
1291 //=======================================================================
1292 Standard_Boolean AIS_InteractiveContext::MoreSelected() const
1294 if (HasOpenedContext())
1295 return myLocalContexts (myCurLocalIndex)->MoreSelected();
1297 return mySelection->More();
1300 //=======================================================================
1301 //function : NextSelected
1303 //=======================================================================
1304 void AIS_InteractiveContext::NextSelected()
1306 if(HasOpenedContext())
1308 return myLocalContexts (myCurLocalIndex)->NextSelected();
1311 mySelection->Next();
1314 //=======================================================================
1315 //function : HasSelectedShape
1317 //=======================================================================
1318 Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
1320 if(HasOpenedContext())
1322 return myLocalContexts(myCurLocalIndex)->HasSelectedShape();
1324 if (!mySelection->More())
1325 return Standard_False;
1327 const Handle(StdSelect_BRepOwner) anOwner =
1328 Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
1330 return !anOwner.IsNull() && anOwner->HasShape();
1333 //=======================================================================
1334 //function : SelectedShape
1336 //=======================================================================
1337 TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
1339 if (HasOpenedContext())
1341 return myLocalContexts (myCurLocalIndex)->SelectedShape();
1344 if (!mySelection->More())
1345 return TopoDS_Shape();
1347 const Handle(StdSelect_BRepOwner) anOwner =
1348 Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
1349 if (anOwner.IsNull() || !anOwner->HasSelectable())
1350 return TopoDS_Shape();
1352 return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location());
1355 //=======================================================================
1356 //function : SelectedInteractive
1358 //=======================================================================
1359 Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const
1361 if (HasOpenedContext())
1363 return myLocalContexts(myCurLocalIndex)->SelectedInteractive();
1366 return !mySelection->More()
1367 ? Handle(AIS_InteractiveObject)()
1368 : Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()->Selectable());
1370 //=======================================================================
1371 //function : SelectedOwner
1373 //=======================================================================
1374 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const
1376 if(HasOpenedContext())
1378 return myLocalContexts(myCurLocalIndex)->SelectedOwner();
1381 return !mySelection->More()
1382 ? Handle(SelectMgr_EntityOwner)()
1383 : mySelection->Value();
1386 //=======================================================================
1387 //function : EntityOwners
1389 //=======================================================================
1390 void AIS_InteractiveContext::EntityOwners(Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
1391 const Handle(AIS_InteractiveObject)& theIObj,
1392 const Standard_Integer theMode) const
1394 if ( theIObj.IsNull() )
1397 TColStd_ListOfInteger aModes;
1398 if ( theMode == -1 )
1399 ActivatedModes( theIObj, aModes );
1401 aModes.Append( theMode );
1403 if (theOwners.IsNull())
1404 theOwners = new SelectMgr_IndexedMapOfOwner();
1406 TColStd_ListIteratorOfListOfInteger anItr( aModes );
1407 for (; anItr.More(); anItr.Next() )
1409 int aMode = anItr.Value();
1410 if ( !theIObj->HasSelection( aMode ) )
1413 Handle(SelectMgr_Selection) aSel = theIObj->Selection(aMode);
1415 for ( aSel->Init(); aSel->More(); aSel->Next() )
1417 Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive()->BaseSensitive();
1418 if ( aEntity.IsNull() )
1421 Handle(SelectMgr_EntityOwner) aOwner =
1422 Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId());
1423 if ( !aOwner.IsNull() )
1424 theOwners->Add( aOwner );
1429 //=======================================================================
1430 //function : NbSelected
1432 //=======================================================================
1433 Standard_Integer AIS_InteractiveContext::NbSelected()
1435 Standard_Integer aNbSelected = 0;
1436 for (InitSelected(); MoreSelected(); NextSelected())
1444 //=======================================================================
1445 //function : HasApplicative
1447 //=======================================================================
1448 Standard_Boolean AIS_InteractiveContext::HasApplicative() const
1450 return SelectedInteractive()->HasOwner();
1453 //=======================================================================
1454 //function : Applicative
1456 //=======================================================================
1457 Handle(Standard_Transient) AIS_InteractiveContext::Applicative() const
1459 return SelectedInteractive()->GetOwner();
1462 //==================================================
1463 // Function: HasDetected
1465 //==================================================
1466 Standard_Boolean AIS_InteractiveContext::HasDetected() const
1468 if(HasOpenedContext())
1469 return myLocalContexts(myCurLocalIndex)->HasDetected();
1471 return !myLastPicked.IsNull();
1474 //=======================================================================
1475 //function : HasDetectedShape
1477 //=======================================================================
1479 Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const
1481 if(HasOpenedContext())
1482 return myLocalContexts(myCurLocalIndex)->HasDetectedShape();
1483 return Standard_False;
1486 //=======================================================================
1487 //function : DetectedShape
1489 //=======================================================================
1492 AIS_InteractiveContext::DetectedShape() const
1494 return myLocalContexts(myCurLocalIndex)->DetectedShape();
1497 //=======================================================================
1498 //function : DetectedInteractive
1500 //=======================================================================
1501 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedInteractive() const
1503 if (HasOpenedContext())
1504 return myLocalContexts(myCurLocalIndex)->DetectedInteractive();
1506 return Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
1509 //=======================================================================
1510 //function : HasNextDetected
1512 //=======================================================================
1513 Standard_Boolean AIS_InteractiveContext::HasNextDetected() const
1515 if (HasOpenedContext())
1517 return myLocalContexts(myCurLocalIndex)->HasNextDetected();
1520 return !myDetectedSeq.IsEmpty() && myCurHighlighted <= myDetectedSeq.Upper();
1524 //=======================================================================
1525 //function : DetectedOwner
1527 //=======================================================================
1528 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const
1530 if (HasOpenedContext())
1531 return myLocalContexts(myCurLocalIndex)->DetectedOwner();
1533 return myLastPicked;
1536 //=======================================================================
1537 //function : HilightNextDetected
1539 //=======================================================================
1540 Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
1541 const Standard_Boolean theToRedrawImmediate)
1543 if (HasOpenedContext())
1545 return myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate);
1548 myMainPM->ClearImmediateDraw();
1549 if (myDetectedSeq.IsEmpty())
1554 if (++myCurHighlighted > myDetectedSeq.Upper())
1556 myCurHighlighted = myDetectedSeq.Lower();
1558 const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
1559 if (anOwner.IsNull())
1564 highlightWithColor (anOwner, theView->Viewer());
1565 myLastPicked = anOwner;
1566 myLastinMain = myLastPicked;
1568 if (theToRedrawImmediate)
1570 myMainPM->RedrawImmediate (theView->Viewer());
1571 myMainVwr->RedrawImmediate();
1574 return myCurHighlighted;
1577 //=======================================================================
1578 //function : HilightPreviousDetected
1580 //=======================================================================
1581 Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
1582 const Standard_Boolean theToRedrawImmediate)
1584 if (HasOpenedContext())
1586 return myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate);
1589 myMainPM->ClearImmediateDraw();
1590 if (myDetectedSeq.IsEmpty())
1595 if (--myCurHighlighted < myDetectedSeq.Lower())
1597 myCurHighlighted = myDetectedSeq.Upper();
1599 const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
1600 if (anOwner.IsNull())
1605 highlightWithColor (anOwner, theView->Viewer());
1606 myLastPicked = anOwner;
1607 myLastinMain = myLastPicked;
1609 if (theToRedrawImmediate)
1611 myMainPM->RedrawImmediate (theView->Viewer());
1612 myMainVwr->RedrawImmediate();
1615 return myCurHighlighted;
1618 //=======================================================================
1619 //function : InitDetected
1621 //=======================================================================
1622 void AIS_InteractiveContext::InitDetected()
1624 if (HasOpenedContext())
1626 myLocalContexts (myCurLocalIndex)->InitDetected();
1630 if (!myDetectedSeq.IsEmpty())
1632 myCurDetected = myDetectedSeq.Lower();
1636 //=======================================================================
1637 //function : MoreDetected
1639 //=======================================================================
1640 Standard_Boolean AIS_InteractiveContext::MoreDetected() const
1642 if (HasOpenedContext())
1644 return myLocalContexts (myCurLocalIndex)->MoreDetected();
1647 return myCurDetected >= myDetectedSeq.Lower() && myCurDetected <= myDetectedSeq.Upper();
1650 //=======================================================================
1651 //function : NextDetected
1653 //=======================================================================
1654 void AIS_InteractiveContext::NextDetected()
1656 if (HasOpenedContext())
1658 myLocalContexts (myCurLocalIndex)->NextDetected();
1665 //=======================================================================
1666 //function : DetectedCurrentShape
1668 //=======================================================================
1669 const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
1671 if (HasOpenedContext())
1673 return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape();
1676 Standard_DISABLE_DEPRECATION_WARNINGS
1677 Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
1678 Standard_ENABLE_DEPRECATION_WARNINGS
1680 if (aCurrentShape.IsNull())
1682 return AIS_InteractiveContext_myDummyShape;
1685 return aCurrentShape->Shape();
1688 //=======================================================================
1689 //function : DetectedCurrentObject
1691 //=======================================================================
1692 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const
1694 if (HasOpenedContext())
1696 return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject();
1699 return MoreDetected()
1700 ? Handle(AIS_InteractiveObject)::DownCast (myMainSel->Picked (myDetectedSeq (myCurDetected))->Selectable())
1704 //=======================================================================
1705 //function : FirstSelectedObject
1707 //=======================================================================
1708 Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstSelectedObject()
1710 Handle(AIS_InteractiveObject) anObject;
1712 if (HasOpenedContext())
1718 return SelectedInteractive();
1723 //=======================================================================
1724 //function : RedrawImmediate
1725 //purpose : Redisplays immediate strucures of the viewer given according to their visibility
1726 //=======================================================================
1727 void AIS_InteractiveContext::RedrawImmediate (const Handle(V3d_Viewer)& theViewer)
1729 myMainPM->RedrawImmediate (theViewer);