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();
428 //=======================================================================
429 //function : AddSelect
431 //=======================================================================
432 AIS_StatusOfPick AIS_InteractiveContext::AddSelect (const Handle(SelectMgr_EntityOwner)& theObject)
434 if (HasOpenedContext())
436 return myLocalContexts(myCurLocalIndex)->AddSelect (theObject);
438 mySelection->AddSelect (theObject);
440 Standard_Integer aSelNum = NbSelected();
441 return (aSelNum == 0) ? AIS_SOP_NothingSelected
442 : (aSelNum == 1) ? AIS_SOP_OneSelected
443 : AIS_SOP_SeveralSelected;
446 //=======================================================================
449 //=======================================================================
450 AIS_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)
457 // all objects detected by the selector are taken, previous current objects are emptied,
458 // new objects are put...
460 if (HasOpenedContext())
462 return myLocalContexts(myCurLocalIndex)->Select (theXPMin, theYPMin,
464 theView, toUpdateViewer);
467 ClearSelected (Standard_False);
469 Handle(StdSelect_ViewerSelector3d) aSelector;
471 if (theView->Viewer() == myMainVwr)
473 aSelector = myMainSel;
474 myWasLastMain = Standard_True;
477 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
478 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
480 const Handle(SelectMgr_EntityOwner)& aCurOwner = aSelector->Picked (aPickIter);
481 if (aCurOwner.IsNull() || !aCurOwner->HasSelectable() || !myFilters->IsOk (aCurOwner))
484 mySelection->Select (aCurOwner);
485 aCurOwner->SetSelected (Standard_True);
488 HilightSelected (toUpdateViewer);
490 Standard_Integer aSelNum = NbSelected();
492 return (aSelNum == 0) ? AIS_SOP_NothingSelected
493 : (aSelNum == 1) ? AIS_SOP_OneSelected
494 : AIS_SOP_SeveralSelected;
498 //=======================================================================
500 //purpose : Selection by polyline
501 //=======================================================================
502 AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline,
503 const Handle(V3d_View)& theView,
504 const Standard_Boolean toUpdateViewer)
506 // all objects detected by the selector are taken, previous current objects are emptied,
507 // new objects are put...
509 if (HasOpenedContext())
511 return myLocalContexts(myCurLocalIndex)->Select (thePolyline, theView, toUpdateViewer);
514 ClearSelected (Standard_False);
516 Handle(StdSelect_ViewerSelector3d) aSelector;
518 if (theView->Viewer() == myMainVwr)
520 aSelector = myMainSel;
521 myWasLastMain = Standard_True;
524 aSelector->Pick (thePolyline, theView);
525 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
527 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
528 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
531 mySelection->Select (anOwner);
532 anOwner->SetSelected (Standard_True);
535 HilightSelected (toUpdateViewer);
537 Standard_Integer aSelNum = NbSelected();
539 return (aSelNum == 0) ? AIS_SOP_NothingSelected
540 : (aSelNum == 1) ? AIS_SOP_OneSelected
541 : AIS_SOP_SeveralSelected;
545 //=======================================================================
548 //=======================================================================
549 AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer)
551 if (HasOpenedContext())
555 return myLocalContexts(myCurLocalIndex)->Select (toUpdateViewer);
559 myLocalContexts(myCurLocalIndex)->SetSelected (Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable()), toUpdateViewer);
560 return AIS_SOP_OneSelected;
564 clearDynamicHighlight();
565 if (myWasLastMain && !myLastinMain.IsNull())
567 if (!myLastinMain->IsSelected() || myLastinMain->IsForcedHilight())
569 SetSelected (myLastinMain, Standard_False);
572 UpdateCurrentViewer();
578 unhighlightSelected (Standard_True);
580 mySelection->Clear();
581 if (toUpdateViewer && myWasLastMain)
583 UpdateCurrentViewer();
587 Standard_Integer aSelNum = NbSelected();
589 return (aSelNum == 0) ? AIS_SOP_NothingSelected
590 : (aSelNum == 1) ? AIS_SOP_OneSelected
591 : AIS_SOP_SeveralSelected;
594 //=======================================================================
595 //function : ShiftSelect
597 //=======================================================================
598 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
600 if (HasOpenedContext())
604 return myLocalContexts (myCurLocalIndex)->ShiftSelect (toUpdateViewer);
608 myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (myLastPicked, toUpdateViewer);
610 Standard_Integer aSelNum = NbSelected();
611 return (aSelNum == 0) ? AIS_SOP_NothingSelected
612 : (aSelNum == 1) ? AIS_SOP_OneSelected
613 : AIS_SOP_SeveralSelected;
617 clearDynamicHighlight();
618 if (myWasLastMain && !myLastinMain.IsNull())
620 AddOrRemoveSelected (myLastinMain, toUpdateViewer);
623 Standard_Integer aSelNum = NbSelected();
625 return (aSelNum == 0) ? AIS_SOP_NothingSelected
626 : (aSelNum == 1) ? AIS_SOP_OneSelected
627 : AIS_SOP_SeveralSelected;
630 //=======================================================================
631 //function : ShiftSelect
633 //=======================================================================
634 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin,
635 const Standard_Integer theYPMin,
636 const Standard_Integer theXPMax,
637 const Standard_Integer theYPMax,
638 const Handle(V3d_View)& theView,
639 const Standard_Boolean toUpdateViewer)
641 if (HasOpenedContext())
643 return myLocalContexts(myCurLocalIndex)->ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax,
644 theView, toUpdateViewer);
647 UnhilightSelected (Standard_False);
649 Handle(StdSelect_ViewerSelector3d) aSelector;
650 if (theView->Viewer() == myMainVwr)
652 aSelector = myMainSel;
653 myWasLastMain = Standard_True;
657 return AIS_SOP_NothingSelected;
660 aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
661 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
663 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
664 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
667 AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
668 anOwner->SetSelected (aSelStatus == AIS_SS_Added);
671 HilightSelected (toUpdateViewer);
673 Standard_Integer aSelNum = NbSelected();
675 return (aSelNum == 0) ? AIS_SOP_NothingSelected
676 : (aSelNum == 1) ? AIS_SOP_OneSelected
677 : AIS_SOP_SeveralSelected;
681 //=======================================================================
682 //function : ShiftSelect
684 //=======================================================================
685 AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline,
686 const Handle(V3d_View)& theView,
687 const Standard_Boolean toUpdateViewer)
689 if (HasOpenedContext())
691 return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer);
694 UnhilightSelected (Standard_False);
696 Handle(StdSelect_ViewerSelector3d) aSelector;
698 if (theView->Viewer() == myMainVwr)
700 aSelector= myMainSel;
701 myWasLastMain = Standard_True;
705 return AIS_SOP_NothingSelected;
708 aSelector->Pick (thePolyline, theView);
709 for (Standard_Integer aPickIter = 1; aPickIter <= aSelector->NbPicked(); ++aPickIter)
711 const Handle(SelectMgr_EntityOwner) anOwner = aSelector->Picked (aPickIter);
712 if (anOwner.IsNull() || !anOwner->HasSelectable() || !myFilters->IsOk (anOwner))
715 AIS_SelectStatus aSelStatus = mySelection->Select (anOwner);
716 anOwner->SetSelected (aSelStatus == AIS_SS_Added);
719 HilightSelected (toUpdateViewer);
721 Standard_Integer aSelNum = NbSelected();
723 return (aSelNum == 0) ? AIS_SOP_NothingSelected
724 : (aSelNum == 1) ? AIS_SOP_OneSelected
725 : AIS_SOP_SeveralSelected;
728 //=======================================================================
729 //function : SetCurrentObject
730 //purpose : OBSOLETE, please use SetSelected() instead
731 //TODO : Remove in process of local context deletion
732 //=======================================================================
733 void AIS_InteractiveContext::SetCurrentObject (const Handle(AIS_InteractiveObject)& theObject,
734 const Standard_Boolean theToUpdateViewer)
736 if (HasOpenedContext())
739 SetSelected (theObject, theToUpdateViewer);
742 //=======================================================================
743 //function : AddOrRemoveCurrentObject
744 //purpose : OBSOLETE, please use AddOrRemoveSelected() instead
745 //TODO : Remove in process of local context deletion
746 //=======================================================================
747 void AIS_InteractiveContext::AddOrRemoveCurrentObject (const Handle(AIS_InteractiveObject)& theObj,
748 const Standard_Boolean theIsToUpdateViewer)
750 if (HasOpenedContext())
753 AddOrRemoveSelected (theObj, theIsToUpdateViewer);
755 //=======================================================================
756 //function : UpdateCurrent
757 //purpose : OBSOLETE, please use UpdateSelected() instead
758 //TODO : Remove in process of local context deletion
759 //=======================================================================
760 void AIS_InteractiveContext::UpdateCurrent()
762 UpdateSelected (Standard_True);
765 //=======================================================================
766 //function : IsCurrent
767 //purpose : OBSOLETE, please use IsSelected() instead
768 //TODO : Remove in process of local context deletion
769 //=======================================================================
770 Standard_Boolean AIS_InteractiveContext::IsCurrent (const Handle(AIS_InteractiveObject)& theObject) const
772 return IsSelected (theObject);
775 //=======================================================================
776 //function : InitCurrent
777 //purpose : OBSOLETE, please use InitSelected() instead
778 //TODO : Remove in process of local context deletion
779 //=======================================================================
780 void AIS_InteractiveContext::InitCurrent()
782 if (HasOpenedContext())
788 //=======================================================================
789 //function : MoreCurrent
790 //purpose : OBSOLETE, please use MoreSelected() instead
791 //TODO : Remove in process of local context deletion
792 //=======================================================================
793 Standard_Boolean AIS_InteractiveContext::MoreCurrent() const
795 return !HasOpenedContext() && MoreSelected();
798 //=======================================================================
799 //function : NextCurrent
800 //purpose : OBSOLETE, please use NextSelected() instead
801 //TODO : Remove in process of local context deletion
802 //=======================================================================
803 void AIS_InteractiveContext::NextCurrent()
805 if (HasOpenedContext())
811 //=======================================================================
813 //purpose : OBSOLETE, please use SelectedInteractive() instead
814 //TODO : Remove in process of local context deletion
815 //=======================================================================
816 Handle(AIS_InteractiveObject) AIS_InteractiveContext::Current() const
818 return HasOpenedContext() ? NULL : SelectedInteractive();
821 //=======================================================================
822 //function : NbCurrents
823 //purpose : OBSOLETE, please use NbSelected() instead
824 //TODO : Remove in process of local context deletion
825 //=======================================================================
826 Standard_Integer AIS_InteractiveContext::NbCurrents()
828 return HasOpenedContext() ? -1 : NbSelected();
831 //=======================================================================
832 //function : HilightCurrents
833 //purpose : OBSOLETE, please use HilightSelected() instead
834 //TODO : Remove in process of local context deletion
835 //=======================================================================
836 void AIS_InteractiveContext::HilightCurrents (const Standard_Boolean theToUpdateViewer)
838 if (HasOpenedContext())
841 HilightSelected (theToUpdateViewer);
844 //=======================================================================
845 //function : UnhilightCurrents
846 //purpose : OBSOLETE, please use UnhilightSelected() instead
847 //TODO : Remove in process of local context deletion
848 //=======================================================================
849 void AIS_InteractiveContext::UnhilightCurrents (const Standard_Boolean theToUpdateViewer)
851 if (HasOpenedContext())
854 UnhilightSelected (theToUpdateViewer);
857 //=======================================================================
858 //function : ClearCurrents
859 //purpose : OBSOLETE, please use ClearCurrents() instead
860 //TODO : Remove in process of local context deletion
861 //=======================================================================
862 void AIS_InteractiveContext::ClearCurrents(const Standard_Boolean theToUpdateViewer)
864 if (HasOpenedContext())
867 ClearSelected (theToUpdateViewer);
871 //=======================================================================
872 //function : HilightSelected
874 //=======================================================================
875 void AIS_InteractiveContext::HilightSelected (const Standard_Boolean theToUpdateViewer)
877 if (HasOpenedContext())
879 return myLocalContexts (myCurLocalIndex)->HilightPicked (theToUpdateViewer);
882 // In case of selection without using local context
883 clearDynamicHighlight();
884 AIS_MapOfObjSelectedOwners anObjOwnerMap;
885 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
887 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
888 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
889 const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObj, anOwner);
890 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind(anObj);
891 if (anOwner == anObj->GlobalSelOwner())
893 aState->SetHilightStatus (Standard_True);
894 aState->SetHilightStyle (anObjSelStyle);
896 anOwner->SetSelected (Standard_True);
897 if (!anOwner->IsAutoHilight())
899 NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq;
900 if (anObjOwnerMap.Find (anObj, aSeq))
902 aSeq->Append (anOwner);
906 aSeq = new SelectMgr_SequenceOfOwner();
907 aSeq->Append (anOwner);
908 anObjOwnerMap.Bind (anObj, aSeq);
913 const Standard_Integer aHiMode = getHilightMode (anObj, anObjSelStyle, aState->DisplayMode());
914 anOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
918 if (!anObjOwnerMap.IsEmpty())
920 for (AIS_MapOfObjSelectedOwners::Iterator anIter (anObjOwnerMap); anIter.More(); anIter.Next())
922 anIter.Key()->HilightSelected (myMainPM, *anIter.Value());
924 anObjOwnerMap.Clear();
927 if (theToUpdateViewer)
928 UpdateCurrentViewer();
931 //=======================================================================
932 //function : UnhilightSelected
934 //=======================================================================
935 void AIS_InteractiveContext::UnhilightSelected (const Standard_Boolean theToUpdateViewer)
937 if (HasOpenedContext())
939 return myLocalContexts (myCurLocalIndex)->UnhilightPicked (theToUpdateViewer);
942 for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
944 const Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
945 const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
946 if (anOwner == anObj->GlobalSelOwner())
948 myObjects.ChangeFind (anObj)->SetHilightStatus (Standard_False);
951 anOwner->SetSelected (Standard_False);
952 anOwner->Unhilight (myMainPM);
955 if (theToUpdateViewer)
956 UpdateCurrentViewer();
960 //=======================================================================
961 //function : ClearSelected
963 //=======================================================================
964 void AIS_InteractiveContext::ClearSelected (const Standard_Boolean theToUpdateViewer)
966 if (HasOpenedContext())
967 return myLocalContexts (myCurLocalIndex)->ClearSelected (theToUpdateViewer);
969 if (NbSelected() == 0)
972 unhighlightSelected();
974 mySelection->Clear();
975 clearDynamicHighlight();
977 if (theToUpdateViewer)
978 UpdateCurrentViewer();
981 //=======================================================================
982 //function : UpdateSelected
984 //=======================================================================
985 void AIS_InteractiveContext::UpdateSelected (const Standard_Boolean theToUpdateViewer)
987 if (HasOpenedContext())
989 return myLocalContexts(myCurLocalIndex)->UpdateSelected (theToUpdateViewer);
992 HilightSelected (theToUpdateViewer);
995 //=======================================================================
996 //function : SetSelected
997 //purpose : Sets the whole object as selected and highlights it with selection color
998 //=======================================================================
999 void AIS_InteractiveContext::SetSelected (const Handle(AIS_InteractiveObject)& theObject,
1000 const Standard_Boolean theToUpdateViewer)
1002 if (HasOpenedContext())
1004 return myLocalContexts (myCurLocalIndex)->SetSelected (theObject, theToUpdateViewer);
1007 if (theObject.IsNull())
1012 if (!myObjects.IsBound (theObject))
1014 Display (theObject, Standard_False);
1016 if (!theObject->HasSelection (theObject->GlobalSelectionMode()))
1020 Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
1021 if (anOwner.IsNull())
1026 const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (theObject, anOwner);
1027 if (NbSelected() == 1 && myObjects (theObject)->IsHilighted())
1029 Handle(Prs3d_Drawer) aCustomStyle;
1030 if (HighlightStyle (theObject, aCustomStyle))
1032 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1034 HilightWithColor (theObject, anObjSelStyle, theToUpdateViewer);
1040 for (mySelection->Init(); mySelection->More(); mySelection->Next())
1042 const Handle(SelectMgr_EntityOwner) aSelOwner = mySelection->Value();
1043 if (!myFilters->IsOk (aSelOwner))
1048 Handle(AIS_InteractiveObject) aSelectable = Handle(AIS_InteractiveObject)::DownCast (aSelOwner->Selectable());
1049 Unhilight (aSelectable, Standard_False);
1050 aSelOwner->SetSelected (Standard_False);
1051 if (aSelOwner == aSelectable->GlobalSelOwner())
1053 myObjects.ChangeFind (aSelectable)->SetHilightStatus (Standard_False);
1057 // added to avoid untimely viewer update...
1058 mySelection->ClearAndSelect (anOwner);
1060 Handle(Prs3d_Drawer) aCustomStyle;
1061 if (HighlightStyle (theObject, aCustomStyle))
1063 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1065 HilightWithColor (theObject, anObjSelStyle, Standard_False);
1070 HilightWithColor (theObject, anObjSelStyle, Standard_False);
1072 anOwner->SetSelected (Standard_True);
1074 if (theToUpdateViewer)
1075 UpdateCurrentViewer();
1078 //=======================================================================
1079 //function : SetSelected
1080 //purpose : Sets the whole object as selected and highlights it with selection color
1081 //=======================================================================
1082 void AIS_InteractiveContext::SetSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1083 const Standard_Boolean theToUpdateViewer)
1085 if (theOwner.IsNull() || !theOwner->HasSelectable() || !myFilters->IsOk (theOwner))
1088 const Handle(AIS_InteractiveObject) anObject = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1089 const Handle(Prs3d_Drawer)& anObjSelStyle = getSelStyle (anObject, theOwner);
1090 if (NbSelected() == 1 && theOwner->IsSelected() && !theOwner->IsForcedHilight())
1092 Handle(Prs3d_Drawer) aCustomStyle;
1093 if (HighlightStyle (theOwner, aCustomStyle))
1095 if (!aCustomStyle.IsNull() && anObjSelStyle != aCustomStyle)
1097 const Standard_Integer aHiMode = anObject->HasHilightMode() ? anObject->HilightMode() : 0;
1098 theOwner->HilightWithColor (myMainPM, anObjSelStyle, aHiMode);
1104 if (!myObjects.IsBound (anObject))
1105 Display (anObject, Standard_False);
1107 unhighlightSelected();
1109 mySelection->ClearAndSelect (theOwner);
1110 Handle(Prs3d_Drawer) aCustomStyle;
1111 if (!HighlightStyle (theOwner, aCustomStyle) ||
1112 (!aCustomStyle.IsNull() && aCustomStyle != anObjSelStyle))
1114 theOwner->SetSelected (Standard_True);
1115 highlightSelected (theOwner);
1118 theOwner->SetSelected (Standard_True);
1119 if (theOwner == anObject->GlobalSelOwner())
1121 Handle(AIS_GlobalStatus)& aState = myObjects.ChangeFind (anObject);
1122 aState->SetHilightStatus (Standard_True);
1123 aState->SetHilightStyle (anObjSelStyle);
1126 if (theToUpdateViewer)
1127 UpdateCurrentViewer();
1130 //=======================================================================
1131 //function : AddOrRemoveSelected
1132 //purpose : Adds or removes current object from AIS selection and highlights/unhighlights it.
1133 // Since this method makes sence only for neutral point selection of a whole object,
1134 // if 0 selection of the object is empty this method simply does nothing.
1135 //=======================================================================
1136 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(AIS_InteractiveObject)& theObject,
1137 const Standard_Boolean theToUpdateViewer)
1139 if (theObject.IsNull())
1142 if (HasOpenedContext())
1143 return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer);
1145 const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode();
1146 if (!myObjects.IsBound (theObject) || !theObject->HasSelection (aGlobalSelMode))
1149 setContextToObject (theObject);
1150 const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
1152 if (anOwner.IsNull() || !anOwner->HasSelectable())
1155 AddOrRemoveSelected (anOwner, theToUpdateViewer);
1157 //=======================================================================
1158 //function : AddOrRemoveSelected
1160 //=======================================================================
1162 void AIS_InteractiveContext::AddOrRemoveSelected (const TopoDS_Shape& aShap,
1163 const Standard_Boolean updateviewer)
1165 if(!HasOpenedContext()) {
1167 cout<<" Attempt to remove a selected shape with no opened local context"<<endl;
1172 myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(aShap,updateviewer);
1173 if(updateviewer) UpdateCurrentViewer();
1177 //=======================================================================
1178 //function : AddOrRemoveSelected
1179 //purpose : Allows to highlight or unhighlight the owner given depending on
1180 // its selection status
1181 //=======================================================================
1182 void AIS_InteractiveContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner,
1183 const Standard_Boolean theToUpdateViewer)
1185 if (HasOpenedContext())
1186 return myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected (theOwner, theToUpdateViewer);
1188 if (theOwner.IsNull() || !theOwner->HasSelectable())
1191 if (!myFilters->IsOk(theOwner) && !theOwner->IsSelected())
1194 AIS_SelectStatus aSelStat = mySelection->Select (theOwner);
1195 theOwner->SetSelected (aSelStat == AIS_SS_Added);
1196 const Handle(AIS_InteractiveObject) anObj =
1197 Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
1198 const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
1199 Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
1200 if (theOwner->IsSelected())
1202 highlightSelected (theOwner);
1205 aStatus->SetHilightStatus (Standard_True);
1206 aStatus->SetHilightStyle (getSelStyle (anObj, theOwner));
1211 if (theOwner->IsAutoHilight())
1213 theOwner->Unhilight (myMainPM);
1217 anObj->ClearSelected();
1219 aStatus->SetHilightStatus (Standard_False);
1220 aStatus->SetHilightStyle (Handle(Prs3d_Drawer)());
1223 if (theToUpdateViewer)
1224 UpdateCurrentViewer();
1228 //=======================================================================
1229 //function : IsSelected
1231 //=======================================================================
1232 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(AIS_InteractiveObject)& theObj) const
1234 if(HasOpenedContext())
1235 return myLocalContexts(myCurLocalIndex)->IsSelected (theObj);
1237 if (theObj.IsNull() || !myObjects.IsBound (theObj))
1238 return Standard_False;
1240 const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode();
1241 const TColStd_ListOfInteger& anActivatedModes = myObjects (theObj)->SelectionModes();
1242 Standard_Boolean isGlobalModeActivated = Standard_False;
1243 for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
1245 if (aModeIter.Value() == aGlobalSelMode)
1247 isGlobalModeActivated = Standard_True;
1251 if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated || theObj->GlobalSelOwner().IsNull())
1252 return Standard_False;
1254 return theObj->GlobalSelOwner()->IsSelected();
1257 //=======================================================================
1258 //function : IsSelected
1259 //purpose : Returns true is the owner given is selected
1260 //=======================================================================
1261 Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const
1263 if (HasOpenedContext())
1264 return myLocalContexts(myCurLocalIndex)->IsSelected (theOwner);
1266 if (theOwner.IsNull())
1267 return Standard_False;
1269 return theOwner->IsSelected();
1272 //=======================================================================
1273 //function : InitSelected
1275 //=======================================================================
1276 void AIS_InteractiveContext::InitSelected()
1278 if (HasOpenedContext())
1280 myLocalContexts (myCurLocalIndex)->InitSelected();
1284 mySelection->Init();
1287 //=======================================================================
1288 //function : MoreSelected
1290 //=======================================================================
1291 Standard_Boolean AIS_InteractiveContext::MoreSelected() const
1293 if (HasOpenedContext())
1294 return myLocalContexts (myCurLocalIndex)->MoreSelected();
1296 return mySelection->More();
1299 //=======================================================================
1300 //function : NextSelected
1302 //=======================================================================
1303 void AIS_InteractiveContext::NextSelected()
1305 if(HasOpenedContext())
1307 return myLocalContexts (myCurLocalIndex)->NextSelected();
1310 mySelection->Next();
1313 //=======================================================================
1314 //function : HasSelectedShape
1316 //=======================================================================
1317 Standard_Boolean AIS_InteractiveContext::HasSelectedShape() const
1319 if(HasOpenedContext())
1321 return myLocalContexts(myCurLocalIndex)->HasSelectedShape();
1323 if (!mySelection->More())
1324 return Standard_False;
1326 const Handle(StdSelect_BRepOwner) anOwner =
1327 Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
1329 return !anOwner.IsNull() && anOwner->HasShape();
1332 //=======================================================================
1333 //function : SelectedShape
1335 //=======================================================================
1336 TopoDS_Shape AIS_InteractiveContext::SelectedShape() const
1338 if (HasOpenedContext())
1340 return myLocalContexts (myCurLocalIndex)->SelectedShape();
1343 if (!mySelection->More())
1344 return TopoDS_Shape();
1346 const Handle(StdSelect_BRepOwner) anOwner =
1347 Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
1348 if (anOwner.IsNull() || !anOwner->HasSelectable())
1349 return TopoDS_Shape();
1351 return anOwner->Shape().Located (anOwner->Location() * anOwner->Shape().Location());
1354 //=======================================================================
1355 //function : SelectedInteractive
1357 //=======================================================================
1358 Handle(AIS_InteractiveObject) AIS_InteractiveContext::SelectedInteractive() const
1360 if (HasOpenedContext())
1362 return myLocalContexts(myCurLocalIndex)->SelectedInteractive();
1365 return !mySelection->More()
1366 ? Handle(AIS_InteractiveObject)()
1367 : Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()->Selectable());
1369 //=======================================================================
1370 //function : SelectedOwner
1372 //=======================================================================
1373 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::SelectedOwner() const
1375 if(HasOpenedContext())
1377 return myLocalContexts(myCurLocalIndex)->SelectedOwner();
1380 return !mySelection->More()
1381 ? Handle(SelectMgr_EntityOwner)()
1382 : mySelection->Value();
1385 //=======================================================================
1386 //function : EntityOwners
1388 //=======================================================================
1389 void AIS_InteractiveContext::EntityOwners(Handle(SelectMgr_IndexedMapOfOwner)& theOwners,
1390 const Handle(AIS_InteractiveObject)& theIObj,
1391 const Standard_Integer theMode) const
1393 if ( theIObj.IsNull() )
1396 TColStd_ListOfInteger aModes;
1397 if ( theMode == -1 )
1398 ActivatedModes( theIObj, aModes );
1400 aModes.Append( theMode );
1402 if (theOwners.IsNull())
1403 theOwners = new SelectMgr_IndexedMapOfOwner();
1405 TColStd_ListIteratorOfListOfInteger anItr( aModes );
1406 for (; anItr.More(); anItr.Next() )
1408 int aMode = anItr.Value();
1409 if ( !theIObj->HasSelection( aMode ) )
1412 Handle(SelectMgr_Selection) aSel = theIObj->Selection(aMode);
1414 for ( aSel->Init(); aSel->More(); aSel->Next() )
1416 Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive()->BaseSensitive();
1417 if ( aEntity.IsNull() )
1420 Handle(SelectMgr_EntityOwner) aOwner =
1421 Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId());
1422 if ( !aOwner.IsNull() )
1423 theOwners->Add( aOwner );
1428 //=======================================================================
1429 //function : NbSelected
1431 //=======================================================================
1432 Standard_Integer AIS_InteractiveContext::NbSelected()
1434 Standard_Integer aNbSelected = 0;
1435 for (InitSelected(); MoreSelected(); NextSelected())
1443 //=======================================================================
1444 //function : HasApplicative
1446 //=======================================================================
1447 Standard_Boolean AIS_InteractiveContext::HasApplicative() const
1449 return SelectedInteractive()->HasOwner();
1452 //=======================================================================
1453 //function : Applicative
1455 //=======================================================================
1456 Handle(Standard_Transient) AIS_InteractiveContext::Applicative() const
1458 return SelectedInteractive()->GetOwner();
1461 //==================================================
1462 // Function: HasDetected
1464 //==================================================
1465 Standard_Boolean AIS_InteractiveContext::HasDetected() const
1467 if(HasOpenedContext())
1468 return myLocalContexts(myCurLocalIndex)->HasDetected();
1470 return !myLastPicked.IsNull();
1473 //=======================================================================
1474 //function : HasDetectedShape
1476 //=======================================================================
1478 Standard_Boolean AIS_InteractiveContext::HasDetectedShape() const
1480 if(HasOpenedContext())
1481 return myLocalContexts(myCurLocalIndex)->HasDetectedShape();
1482 return Standard_False;
1485 //=======================================================================
1486 //function : DetectedShape
1488 //=======================================================================
1491 AIS_InteractiveContext::DetectedShape() const
1493 return myLocalContexts(myCurLocalIndex)->DetectedShape();
1496 //=======================================================================
1497 //function : DetectedInteractive
1499 //=======================================================================
1500 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedInteractive() const
1502 if (HasOpenedContext())
1503 return myLocalContexts(myCurLocalIndex)->DetectedInteractive();
1505 return Handle(AIS_InteractiveObject)::DownCast (myLastPicked->Selectable());
1508 //=======================================================================
1509 //function : HasNextDetected
1511 //=======================================================================
1512 Standard_Boolean AIS_InteractiveContext::HasNextDetected() const
1514 if (HasOpenedContext())
1516 return myLocalContexts(myCurLocalIndex)->HasNextDetected();
1519 return !myDetectedSeq.IsEmpty() && myCurHighlighted <= myDetectedSeq.Upper();
1523 //=======================================================================
1524 //function : DetectedOwner
1526 //=======================================================================
1527 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedOwner() const
1529 if (HasOpenedContext())
1530 return myLocalContexts(myCurLocalIndex)->DetectedOwner();
1532 return myLastPicked;
1535 //=======================================================================
1536 //function : HilightNextDetected
1538 //=======================================================================
1539 Standard_Integer AIS_InteractiveContext::HilightNextDetected (const Handle(V3d_View)& theView,
1540 const Standard_Boolean theToRedrawImmediate)
1542 if (HasOpenedContext())
1544 return myLocalContexts (myCurLocalIndex)->HilightNextDetected (theView, theToRedrawImmediate);
1547 myMainPM->ClearImmediateDraw();
1548 if (myDetectedSeq.IsEmpty())
1553 if (++myCurHighlighted > myDetectedSeq.Upper())
1555 myCurHighlighted = myDetectedSeq.Lower();
1557 const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
1558 if (anOwner.IsNull())
1563 highlightWithColor (anOwner, theView->Viewer());
1564 myLastPicked = anOwner;
1565 myLastinMain = myLastPicked;
1567 if (theToRedrawImmediate)
1569 myMainPM->RedrawImmediate (theView->Viewer());
1570 myMainVwr->RedrawImmediate();
1573 return myCurHighlighted;
1576 //=======================================================================
1577 //function : HilightPreviousDetected
1579 //=======================================================================
1580 Standard_Integer AIS_InteractiveContext::HilightPreviousDetected (const Handle(V3d_View)& theView,
1581 const Standard_Boolean theToRedrawImmediate)
1583 if (HasOpenedContext())
1585 return myLocalContexts (myCurLocalIndex)->HilightPreviousDetected (theView, theToRedrawImmediate);
1588 myMainPM->ClearImmediateDraw();
1589 if (myDetectedSeq.IsEmpty())
1594 if (--myCurHighlighted < myDetectedSeq.Lower())
1596 myCurHighlighted = myDetectedSeq.Upper();
1598 const Handle(SelectMgr_EntityOwner)& anOwner = myMainSel->Picked (myDetectedSeq (myCurHighlighted));
1599 if (anOwner.IsNull())
1604 highlightWithColor (anOwner, theView->Viewer());
1605 myLastPicked = anOwner;
1606 myLastinMain = myLastPicked;
1608 if (theToRedrawImmediate)
1610 myMainPM->RedrawImmediate (theView->Viewer());
1611 myMainVwr->RedrawImmediate();
1614 return myCurHighlighted;
1617 //=======================================================================
1618 //function : InitDetected
1620 //=======================================================================
1621 void AIS_InteractiveContext::InitDetected()
1623 if (HasOpenedContext())
1625 myLocalContexts (myCurLocalIndex)->InitDetected();
1629 if (!myDetectedSeq.IsEmpty())
1631 myCurDetected = myDetectedSeq.Lower();
1635 //=======================================================================
1636 //function : MoreDetected
1638 //=======================================================================
1639 Standard_Boolean AIS_InteractiveContext::MoreDetected() const
1641 if (HasOpenedContext())
1643 return myLocalContexts (myCurLocalIndex)->MoreDetected();
1646 return myCurDetected >= myDetectedSeq.Lower() && myCurDetected <= myDetectedSeq.Upper();
1649 //=======================================================================
1650 //function : NextDetected
1652 //=======================================================================
1653 void AIS_InteractiveContext::NextDetected()
1655 if (HasOpenedContext())
1657 myLocalContexts (myCurLocalIndex)->NextDetected();
1664 //=======================================================================
1665 //function : DetectedCurrentOwner
1667 //=======================================================================
1668 Handle(SelectMgr_EntityOwner) AIS_InteractiveContext::DetectedCurrentOwner() const
1670 if (HasOpenedContext())
1672 return myLocalContexts (myCurLocalIndex)->DetectedCurrentOwner();
1675 return MoreDetected()
1676 ? myMainSel->Picked (myDetectedSeq (myCurDetected))
1677 : Handle(SelectMgr_EntityOwner)();
1680 //=======================================================================
1681 //function : DetectedCurrentShape
1683 //=======================================================================
1684 const TopoDS_Shape& AIS_InteractiveContext::DetectedCurrentShape() const
1686 if (HasOpenedContext())
1688 return myLocalContexts(myCurLocalIndex)->DetectedCurrentShape();
1691 Standard_DISABLE_DEPRECATION_WARNINGS
1692 Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
1693 Standard_ENABLE_DEPRECATION_WARNINGS
1695 if (aCurrentShape.IsNull())
1697 return AIS_InteractiveContext_myDummyShape;
1700 return aCurrentShape->Shape();
1703 //=======================================================================
1704 //function : DetectedCurrentObject
1706 //=======================================================================
1707 Handle(AIS_InteractiveObject) AIS_InteractiveContext::DetectedCurrentObject() const
1709 if (HasOpenedContext())
1711 return myLocalContexts(myCurLocalIndex)->DetectedCurrentObject();
1714 return MoreDetected()
1715 ? Handle(AIS_InteractiveObject)::DownCast (myMainSel->Picked (myDetectedSeq (myCurDetected))->Selectable())
1719 //=======================================================================
1720 //function : FirstSelectedObject
1722 //=======================================================================
1723 Handle(AIS_InteractiveObject) AIS_InteractiveContext::FirstSelectedObject()
1725 Handle(AIS_InteractiveObject) anObject;
1727 if (HasOpenedContext())
1733 return SelectedInteractive();
1738 //=======================================================================
1739 //function : RedrawImmediate
1740 //purpose : Redisplays immediate strucures of the viewer given according to their visibility
1741 //=======================================================================
1742 void AIS_InteractiveContext::RedrawImmediate (const Handle(V3d_Viewer)& theViewer)
1744 myMainPM->RedrawImmediate (theViewer);