1 // Created on: 1995-02-15
2 // Created by: Roberc Coublanc
3 // Copyright (c) 1995-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 // ROB JAN/07/98 : Improve Storage of detected entities
19 // AGV OCT/23/03 : Optimize the method SortResult() (OCC4201)
21 #include <BVH_Tree.hxx>
23 #include <OSD_Environment.hxx>
24 #include <Precision.hxx>
25 #include <SelectMgr_ViewerSelector.hxx>
26 #include <SelectMgr_CompareResults.hxx>
27 #include <SelectBasics_EntityOwner.hxx>
28 #include <SelectBasics_SensitiveEntity.hxx>
29 #include <SelectBasics_PickResult.hxx>
30 #include <SelectMgr_EntityOwner.hxx>
31 #include <SelectMgr_SortCriterion.hxx>
32 #include <SelectMgr_SensitiveEntitySet.hxx>
33 #include <SortTools_QuickSortOfInteger.hxx>
34 #include <TColStd_Array1OfInteger.hxx>
35 #include <TCollection_AsciiString.hxx>
36 #include <TColStd_HArray1OfInteger.hxx>
37 #include <TColStd_ListOfInteger.hxx>
40 //=======================================================================
41 // function: SelectMgr_ToleranceMap
42 // purpose : Sets tolerance values to -1.0
43 //=======================================================================
44 SelectMgr_ToleranceMap::SelectMgr_ToleranceMap()
47 myCustomTolerance = -1.0;
50 //=======================================================================
51 // function: ~SelectMgr_ToleranceMap
53 //=======================================================================
54 SelectMgr_ToleranceMap::~SelectMgr_ToleranceMap()
59 //=======================================================================
61 // purpose : Adds the value given to map, checks if the current tolerance value
62 // should be replaced by theTolerance
63 //=======================================================================
64 void SelectMgr_ToleranceMap::Add (const Standard_Real& theTolerance)
66 if (myTolerances.IsBound (theTolerance))
68 Standard_Integer& aFreq = myTolerances.ChangeFind (theTolerance);
71 if (aFreq == 1 && theTolerance != myLargestKey)
72 myLargestKey = Max (theTolerance, myLargestKey);
76 if (myTolerances.IsEmpty())
78 myTolerances.Bind (theTolerance, 1);
79 myLargestKey = theTolerance;
83 myTolerances.Bind (theTolerance, 1);
84 myLargestKey = Max (theTolerance, myLargestKey);
88 //=======================================================================
89 // function: Decrement
90 // purpose : Decrements a counter of the tolerance given, checks if the current tolerance value
91 // should be recalculated
92 //=======================================================================
93 void SelectMgr_ToleranceMap::Decrement (const Standard_Real& theTolerance)
95 if (myTolerances.IsBound (theTolerance))
97 Standard_Integer& aFreq = myTolerances.ChangeFind (theTolerance);
100 if (Abs (theTolerance - myLargestKey) < Precision::Confusion() && aFreq == 0)
103 for (NCollection_DataMap<Standard_Real, Standard_Integer>::Iterator anIter (myTolerances); anIter.More(); anIter.Next())
105 if (anIter.Value() != 0)
106 myLargestKey = Max (myLargestKey, anIter.Key());
112 //=======================================================================
113 // function: Tolerance
114 // purpose : Returns a current tolerance that must be applied
115 //=======================================================================
116 Standard_Real SelectMgr_ToleranceMap::Tolerance()
118 return myCustomTolerance < 0.0 ? myLargestKey : myCustomTolerance;
121 //=======================================================================
122 // function: SetCustomTolerance
123 // purpose : Sets tolerance to the given one and disables adaptive checks
124 //=======================================================================
125 void SelectMgr_ToleranceMap::SetCustomTolerance (const Standard_Real theTolerance)
127 myCustomTolerance = theTolerance;
130 //=======================================================================
131 // function: ResetDefaults
132 // purpose : Unsets a custom tolerance and enables adaptive checks
133 //=======================================================================
134 void SelectMgr_ToleranceMap::ResetDefaults()
136 myCustomTolerance = -1.0;
139 //==================================================
140 // Function: Initialize
142 //==================================================
143 SelectMgr_ViewerSelector::SelectMgr_ViewerSelector():
144 preferclosest(Standard_True),
146 myToUpdateTolerance (Standard_True),
148 myIsLeftChildQueuedFirst (Standard_False),
151 mySelectableObjects = new SelectMgr_SelectableObjectSet();
155 //==================================================
156 // Function: Activate
158 //==================================================
159 void SelectMgr_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theSelection)
161 for (theSelection->Init(); theSelection->More(); theSelection->Next())
163 theSelection->Sensitive()->SetActiveForSelection();
166 theSelection->SetSelectionState (SelectMgr_SOS_Activated);
168 myTolerances.Add (theSelection->Sensitivity());
169 mytolerance = myTolerances.Tolerance();
170 myToUpdateTolerance = Standard_True;
174 //==================================================
175 // Function: Deactivate
177 //==================================================
178 void SelectMgr_ViewerSelector::Deactivate (const Handle(SelectMgr_Selection)& theSelection)
180 for (theSelection->Init(); theSelection->More(); theSelection->Next())
182 theSelection->Sensitive()->ResetSelectionActiveStatus();
185 theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
187 myTolerances.Decrement (theSelection->Sensitivity());
188 mytolerance = myTolerances.Tolerance();
189 myToUpdateTolerance = Standard_True;
192 //==================================================
195 //==================================================
196 void SelectMgr_ViewerSelector::Clear()
199 myMapOfDetected.Clear();
202 //=======================================================================
203 // function: isToScaleFrustum
204 // purpose : Checks if the entity given requires to scale current selecting frustum
205 //=======================================================================
206 Standard_Boolean SelectMgr_ViewerSelector::isToScaleFrustum (const Handle(SelectBasics_SensitiveEntity)& theEntity)
208 return mySelectingVolumeMgr.GetActiveSelectionType() == SelectMgr_SelectingVolumeManager::Point
209 && theEntity->SensitivityFactor() < myTolerances.Tolerance();
212 //=======================================================================
213 // function: scaleAndTransform
214 // purpose : Applies given scale and transformation matrices to the default selecting volume manager
215 //=======================================================================
216 SelectMgr_SelectingVolumeManager SelectMgr_ViewerSelector::scaleAndTransform (const Standard_Real theScale,
217 const gp_Trsf& theTrsf)
219 SelectMgr_SelectingVolumeManager aMgr;
221 if (theScale > Precision::Angular())
223 aMgr = mySelectingVolumeMgr.Scale (theScale);
226 if (theTrsf.Form() != gp_Identity)
228 aMgr = aMgr.GetActiveSelectionType() == SelectMgr_SelectingVolumeManager::Unknown ?
229 mySelectingVolumeMgr.Transform (theTrsf) : aMgr.Transform (theTrsf);
235 //=======================================================================
236 // function: checkOverlap
237 // purpose : Internal function that checks if a particular sensitive
238 // entity theEntity overlaps current selecting volume precisely
239 //=======================================================================
240 void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_SensitiveEntity)& theEntity,
241 const Standard_Integer theEntityIdx,
242 SelectMgr_SelectingVolumeManager& theMgr)
244 const Handle(SelectMgr_EntityOwner)& anOwner =
245 Handle(SelectMgr_EntityOwner)::DownCast (theEntity->OwnerId());
247 SelectBasics_PickResult aPickResult;
248 if (theEntity->Matches (theMgr, aPickResult))
250 if (!anOwner.IsNull())
252 if (HasDepthClipping (anOwner) && theMgr.GetActiveSelectionType() == SelectMgr_SelectingVolumeManager::Point)
254 Standard_Boolean isClipped = theMgr.IsClipped (anOwner->Selectable()->GetClipPlanes(),
255 aPickResult.Depth());
260 Standard_Integer aPriority = anOwner->Priority();
262 SelectMgr_SortCriterion aCriterion (aPriority, aPickResult.Depth(), aPickResult.DistToGeomCenter(), theEntity->SensitivityFactor() / 33, preferclosest);
263 if (mystored.Contains (anOwner))
265 if (theMgr.GetActiveSelectionType() != 1)
267 SelectMgr_SortCriterion& aPrevCriterion = mystored.ChangeFromKey (anOwner);
268 if (aCriterion > aPrevCriterion)
270 aPrevCriterion = aCriterion;
271 myMapOfDetected.ChangeFind (anOwner) = theEntityIdx;
277 mystored.Add (anOwner, aCriterion);
278 myMapOfDetected.Bind (anOwner, theEntityIdx);
284 //=======================================================================
285 // function: traverseObject
286 // purpose : Internal function that checks if there is possible overlap
287 // between some entity of selectable object theObject and
288 // current selecting volume
289 //=======================================================================
290 void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_SelectableObject)& theObject)
292 NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet =
293 myMapOfObjectSensitives.ChangeFind (theObject);
295 if (anEntitySet->Size() == 0)
298 const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& aSensitivesTree = anEntitySet->BVH();
300 SelectMgr_SelectingVolumeManager aMgr = theObject->HasTransformation() ?
301 mySelectingVolumeMgr.Transform (theObject->InversedTransformation()) : mySelectingVolumeMgr;
303 NCollection_DataMap<Handle(Standard_Type), SelectMgr_SelectingVolumeManager> aScaledTrnsfFrustums;
305 Standard_Integer aNode = 0; // a root node
306 if (!aMgr.Overlaps (aSensitivesTree->MinPoint (0),
307 aSensitivesTree->MaxPoint (0)))
311 Standard_Integer aStack[32];
312 Standard_Integer aHead = -1;
315 if (!aSensitivesTree->IsOuter (aNode))
317 const Standard_Integer aLeftChildIdx = aSensitivesTree->LeftChild (aNode);
318 const Standard_Integer aRightChildIdx = aSensitivesTree->RightChild (aNode);
319 const Standard_Boolean isLeftChildIn = aMgr.Overlaps (aSensitivesTree->MinPoint (aLeftChildIdx),
320 aSensitivesTree->MaxPoint (aLeftChildIdx));
321 const Standard_Boolean isRightChildIn = aMgr.Overlaps (aSensitivesTree->MinPoint (aRightChildIdx),
322 aSensitivesTree->MaxPoint (aRightChildIdx));
326 aNode = aLeftChildIdx;
328 aStack[aHead] = aRightChildIdx;
330 else if (isLeftChildIn
333 aNode = isLeftChildIn ? aLeftChildIdx : aRightChildIdx;
342 aNode = aStack[aHead];
348 Standard_Integer aStartIdx = aSensitivesTree->BegPrimitive (aNode);
349 Standard_Integer anEndIdx = aSensitivesTree->EndPrimitive (aNode);
350 for (Standard_Integer anIdx = aStartIdx; anIdx <= anEndIdx; ++anIdx)
352 const Handle(SelectMgr_SensitiveEntity)& aSensitive =
353 anEntitySet->GetSensitiveById (anIdx);
354 if (aSensitive->IsActiveForSelection())
356 const Handle(SelectBasics_SensitiveEntity)& anEnt = aSensitive->BaseSensitive();
357 SelectMgr_SelectingVolumeManager aTmpMgr = aMgr;
358 if (isToScaleFrustum (anEnt))
360 if (!aScaledTrnsfFrustums.IsBound (anEnt->DynamicType()))
362 aScaledTrnsfFrustums.Bind (anEnt->DynamicType(),
363 scaleAndTransform (anEnt->SensitivityFactor(), theObject->InversedTransformation()));
366 aTmpMgr = aScaledTrnsfFrustums.Find (anEnt->DynamicType());
368 checkOverlap (anEnt, anIdx, aTmpMgr);
376 aNode = aStack[aHead];
382 //=======================================================================
383 // function: TraverseSensitives
384 // purpose : Traverses BVH containing all added selectable objects and
385 // finds candidates for further search of overlap
386 //=======================================================================
387 void SelectMgr_ViewerSelector::TraverseSensitives()
390 myMapOfDetected.Clear();
392 if (mySelectableObjects->Size() == 0)
395 const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& anObjectsTree = mySelectableObjects->BVH();
397 Standard_Integer aNode = 0;
398 if (!mySelectingVolumeMgr.Overlaps (anObjectsTree->MinPoint (0),
399 anObjectsTree->MaxPoint (0)))
403 Standard_Integer aStack[32];
404 Standard_Integer aHead = -1;
407 if (!anObjectsTree->IsOuter (aNode))
409 const Standard_Integer aLeftChildIdx = anObjectsTree->LeftChild (aNode);
410 const Standard_Integer aRightChildIdx = anObjectsTree->RightChild (aNode);
411 const Standard_Boolean isLeftChildIn =
412 mySelectingVolumeMgr.Overlaps (anObjectsTree->MinPoint (aLeftChildIdx),
413 anObjectsTree->MaxPoint (aLeftChildIdx));
414 const Standard_Boolean isRightChildIn =
415 mySelectingVolumeMgr.Overlaps (anObjectsTree->MinPoint (aRightChildIdx),
416 anObjectsTree->MaxPoint (aRightChildIdx));
420 aNode = aLeftChildIdx;
422 aStack[aHead] = aRightChildIdx;
424 else if (isLeftChildIn
427 aNode = isLeftChildIn ? aLeftChildIdx : aRightChildIdx;
436 aNode = aStack[aHead];
442 Standard_Integer aStartIdx = anObjectsTree->BegPrimitive (aNode);
443 Standard_Integer anEndIdx = anObjectsTree->EndPrimitive (aNode);
444 for (Standard_Integer anIdx = aStartIdx; anIdx <= anEndIdx; ++anIdx)
446 traverseObject (mySelectableObjects->GetObjectById (anIdx));
453 aNode = aStack[aHead];
461 //==================================================
464 //==================================================
465 Handle(SelectMgr_EntityOwner) SelectMgr_ViewerSelector
468 Standard_Integer RankInMap = myIndexes->Value (myCurRank);
469 const Handle(SelectBasics_EntityOwner)& toto = mystored.FindKey(RankInMap);
470 Handle(SelectMgr_EntityOwner) Ownr = *((Handle(SelectMgr_EntityOwner)*) &toto);
476 //=======================================================================
479 //=======================================================================
480 Standard_Boolean SelectMgr_ViewerSelector::More()
482 if(mystored.Extent()==0) return Standard_False;
483 if(myCurRank==0) return Standard_False;
484 return myCurRank <= myIndexes->Length();
487 //==================================================
488 // Function: OnePicked
489 // Purpose : only the best one is chosen
490 // depend on priority and mindist...
491 //==================================================
493 Handle(SelectMgr_EntityOwner) SelectMgr_ViewerSelector
499 Standard_Integer RankInMap = myIndexes->Value (myIndexes->Lower());
500 const Handle(SelectBasics_EntityOwner)& toto = mystored.FindKey(RankInMap);
501 Handle(SelectMgr_EntityOwner) Ownr = *((Handle(SelectMgr_EntityOwner)*) &toto);
505 Handle (SelectMgr_EntityOwner) NullObj; //returns a null Handle if there was not successfull pick...
510 //=======================================================================
511 //function : NbPicked
513 //=======================================================================
515 Standard_Integer SelectMgr_ViewerSelector::NbPicked() const
517 return mystored.Extent();
519 //=======================================================================
522 //=======================================================================
523 Handle(SelectMgr_EntityOwner) SelectMgr_ViewerSelector::Picked(const Standard_Integer aRank) const
526 Handle(SelectMgr_EntityOwner) anOwner;
527 if (aRank < 1 || aRank > NbPicked())
529 Standard_Integer anOwnerIdx = myIndexes->Value (aRank);
532 const Handle(SelectBasics_EntityOwner)& aStoredOwner = mystored.FindKey (anOwnerIdx);
533 anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aStoredOwner);
537 //===================================================
539 // INTERNAL METHODS ....
541 //==================================================
543 //==================================================
544 // Function: Contains
546 //==================================================
547 Standard_Boolean SelectMgr_ViewerSelector::Contains (const Handle(SelectMgr_SelectableObject)& theObject) const
549 return mySelectableObjects->Contains (theObject);
552 //==================================================
553 // Function: ActiveModes
554 // Purpose : return all the modes with a given state for an object
555 //==================================================
556 Standard_Boolean SelectMgr_ViewerSelector::Modes (const Handle(SelectMgr_SelectableObject)& theSelectableObject,
557 TColStd_ListOfInteger& theModeList,
558 const SelectMgr_StateOfSelection theWantedState) const
560 Standard_Boolean hasActivatedStates = mySelectableObjects->Contains (theSelectableObject);
561 for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next())
563 if (theWantedState == SelectMgr_SOS_Any)
565 theModeList.Append (theSelectableObject->CurrentSelection()->Mode());
567 else if (theWantedState == theSelectableObject->CurrentSelection()->GetSelectionState())
569 theModeList.Append (theSelectableObject->CurrentSelection()->Mode());
573 return hasActivatedStates;
576 //==================================================
577 // Function: IsActive
579 //==================================================
580 Standard_Boolean SelectMgr_ViewerSelector::IsActive (const Handle(SelectMgr_SelectableObject)& theSelectableObject,
581 const Standard_Integer theMode) const
583 if (!mySelectableObjects->Contains (theSelectableObject))
584 return Standard_False;
586 for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next())
588 if (theMode == theSelectableObject->CurrentSelection()->Mode())
590 return theSelectableObject->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated;
594 return Standard_False;
597 //==================================================
598 // Function: IsInside
600 //==================================================
601 Standard_Boolean SelectMgr_ViewerSelector::IsInside (const Handle(SelectMgr_SelectableObject)& theSelectableObject,
602 const Standard_Integer theMode) const
604 if (!mySelectableObjects->Contains (theSelectableObject))
605 return Standard_False;
607 for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next())
609 if (theMode == theSelectableObject->CurrentSelection()->Mode())
611 return theSelectableObject->CurrentSelection()->GetSelectionState() != SelectMgr_SOS_Unknown;
615 return Standard_False;
619 //=======================================================================
622 //=======================================================================
624 SelectMgr_StateOfSelection SelectMgr_ViewerSelector::Status (const Handle(SelectMgr_Selection)& theSelection) const
626 return theSelection->GetSelectionState();
629 //==================================================
631 // Purpose : gives Information about selectors
632 //==================================================
634 TCollection_AsciiString SelectMgr_ViewerSelector::Status (const Handle(SelectMgr_SelectableObject)& theSelectableObject) const
636 TCollection_AsciiString aStatus ("Status Object :\n\t");
638 for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next())
640 if (theSelectableObject->CurrentSelection()->GetSelectionState() != SelectMgr_SOS_Unknown)
642 aStatus = aStatus + "Mode " +
643 TCollection_AsciiString (theSelectableObject->CurrentSelection()->Mode()) +
645 if (theSelectableObject->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated)
647 aStatus = aStatus + " Active \n\t";
651 aStatus = aStatus + " Inactive \n\t";
656 if (mySelectableObjects->Contains (theSelectableObject))
658 aStatus = aStatus + "Not Present in the selector\n\n";
664 //=======================================================================
665 //function : SortResult
666 //purpose : there is a certain number of entities ranged by criteria
667 // (depth, size, priority, mouse distance from borders or
668 // CDG of the detected primitive. Parsing :
669 // maximum priorities .
670 // then a reasonable compromise between depth and distance...
671 // finally the ranges are stored in myindexes depending on the parsing.
672 // so, it is possible to only read
673 //=======================================================================
674 void SelectMgr_ViewerSelector::SortResult()
676 if(mystored.IsEmpty()) return;
678 const Standard_Integer anExtent = mystored.Extent();
679 if(myIndexes.IsNull() || anExtent != myIndexes->Length())
680 myIndexes = new TColStd_HArray1OfInteger (1, anExtent);
683 TColStd_Array1OfInteger& thearr = myIndexes->ChangeArray1();
685 // indices from 1 to N are loaded
687 for (I=1; I <= anExtent; I++)
690 SortTools_QuickSortOfInteger::Sort (thearr,
691 SelectMgr_CompareResults(mystored));
694 //=======================================================================
695 //function : HasDepthClipping
697 //=======================================================================
698 Standard_Boolean SelectMgr_ViewerSelector::HasDepthClipping (const Handle(SelectMgr_EntityOwner)& /*theOwner*/) const
700 return Standard_False;
703 //=======================================================================
704 // function : AddSelectableObject
705 // purpose : Adds new object to the map of selectable objects
706 //=======================================================================
707 void SelectMgr_ViewerSelector::AddSelectableObject (const Handle(SelectMgr_SelectableObject)& theObject)
709 if (!myMapOfObjectSensitives.IsBound (theObject))
711 mySelectableObjects->Append (theObject);
712 NCollection_Handle<SelectMgr_SensitiveEntitySet> anEntitySet = new SelectMgr_SensitiveEntitySet();
713 myMapOfObjectSensitives.Bind (theObject, anEntitySet);
717 //=======================================================================
718 // function : AddSelectionToObject
719 // purpose : Adds new selection to the object and builds its BVH tree
720 //=======================================================================
721 void SelectMgr_ViewerSelector::AddSelectionToObject (const Handle(SelectMgr_SelectableObject)& theObject,
722 const Handle(SelectMgr_Selection)& theSelection)
724 if (myMapOfObjectSensitives.IsBound (theObject))
726 NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet =
727 myMapOfObjectSensitives.ChangeFind (theObject);
728 anEntitySet->Append (theSelection);
733 AddSelectableObject (theObject);
734 AddSelectionToObject (theObject, theSelection);
738 //=======================================================================
739 // function : RemoveSelectableObject
740 // purpose : Removes selectable object from map of selectable ones
741 //=======================================================================
742 void SelectMgr_ViewerSelector::RemoveSelectableObject (const Handle(SelectMgr_SelectableObject)& theObject)
744 if (myMapOfObjectSensitives.IsBound (theObject))
746 myMapOfObjectSensitives.UnBind (theObject);
747 mySelectableObjects->Remove (theObject);
751 //=======================================================================
752 // function : RemoveSelectionOfObject
753 // purpose : Removes selection of the object and marks its BVH tree
755 //=======================================================================
756 void SelectMgr_ViewerSelector::RemoveSelectionOfObject (const Handle(SelectMgr_SelectableObject)& theObject,
757 const Handle(SelectMgr_Selection)& theSelection)
759 if (myMapOfObjectSensitives.IsBound (theObject))
761 NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet =
762 myMapOfObjectSensitives.ChangeFind (theObject);
763 anEntitySet->Remove (theSelection);
767 //=======================================================================
768 // function : RebuildObjectsTree
769 // purpose : Marks BVH of selectable objects for rebuild
770 //=======================================================================
771 void SelectMgr_ViewerSelector::RebuildObjectsTree (const Standard_Boolean theIsForce)
773 mySelectableObjects->MarkDirty();
777 mySelectableObjects->BVH();
781 //=======================================================================
782 // function : RebuildSensitivesTree
783 // purpose : Marks BVH of sensitive entities of particular selectable
784 // object for rebuild
785 //=======================================================================
786 void SelectMgr_ViewerSelector::RebuildSensitivesTree (const Handle(SelectMgr_SelectableObject)& theObject,
787 const Standard_Boolean theIsForce)
789 if (!mySelectableObjects->Contains (theObject))
792 NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet = myMapOfObjectSensitives.ChangeFind (theObject);
793 anEntitySet->MarkDirty();
801 //=======================================================================
802 // function : resetSelectionActivationStatus
803 // purpose : Marks all added sensitive entities of all objects as
805 //=======================================================================
806 void SelectMgr_ViewerSelector::resetSelectionActivationStatus()
808 SelectMgr_MapOfObjectSensitivesIterator aSensitivesIter (myMapOfObjectSensitives);
809 for ( ; aSensitivesIter.More(); aSensitivesIter.Next())
811 NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet =
812 aSensitivesIter.ChangeValue();
813 Standard_Integer anEntitiesNb = anEntitySet->Size();
814 for (Standard_Integer anIdx = 0; anIdx < anEntitiesNb; ++anIdx)
816 anEntitySet->GetSensitiveById (anIdx)->ResetSelectionActiveStatus();
821 //=======================================================================
822 // function : DetectedEntity
823 // purpose : Returns sensitive entity that was detected during the
824 // previous run of selection algorithm
825 //=======================================================================
826 const Handle(SelectBasics_SensitiveEntity)& SelectMgr_ViewerSelector::DetectedEntity() const
828 const Handle(SelectMgr_EntityOwner)& anOwner = myDetectedIter.Key();
829 const Handle(SelectMgr_SelectableObject)& anObject = anOwner->Selectable();
830 const NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet =
831 myMapOfObjectSensitives.Find (anObject);
833 return anEntitySet->GetSensitiveById (myDetectedIter.Value())->BaseSensitive();
836 //=======================================================================
837 // function : ActiveOwners
838 // purpose : Returns the list of active entity owners
839 //=======================================================================
840 void SelectMgr_ViewerSelector::ActiveOwners (NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners) const
842 for (SelectMgr_MapOfObjectSensitivesIterator anIter (myMapOfObjectSensitives); anIter.More(); anIter.Next())
844 const NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet = anIter.Value();
845 Standard_Integer anEntitiesNb = anEntitySet->Size();
846 for (Standard_Integer anIdx = 0; anIdx < anEntitiesNb; ++anIdx)
848 if (anEntitySet->GetSensitiveById (anIdx)->IsActiveForSelection())
850 theOwners.Append (anEntitySet->GetSensitiveById (anIdx)->BaseSensitive()->OwnerId());