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 <SelectBasics_EntityOwner.hxx>
27 #include <SelectBasics_SensitiveEntity.hxx>
28 #include <SelectBasics_PickResult.hxx>
29 #include <SelectMgr_EntityOwner.hxx>
30 #include <SelectMgr_SortCriterion.hxx>
31 #include <SelectMgr_SensitiveEntitySet.hxx>
32 #include <TColStd_Array1OfInteger.hxx>
33 #include <TCollection_AsciiString.hxx>
34 #include <TColStd_HArray1OfInteger.hxx>
35 #include <TColStd_ListOfInteger.hxx>
40 // Comparison operator for sorting selection results
45 CompareResults (const SelectMgr_IndexedDataMapOfOwnerCriterion& aMapOfCriterion)
46 : myMapOfCriterion (aMapOfCriterion)
50 Standard_Boolean operator() (Standard_Integer theLeft, Standard_Integer theRight) const
52 return myMapOfCriterion.FindFromIndex(theLeft) > myMapOfCriterion.FindFromIndex(theRight);
56 void operator = (const CompareResults&);
59 const SelectMgr_IndexedDataMapOfOwnerCriterion& myMapOfCriterion;
63 //=======================================================================
64 // function: SelectMgr_ToleranceMap
65 // purpose : Sets tolerance values to -1.0
66 //=======================================================================
67 SelectMgr_ToleranceMap::SelectMgr_ToleranceMap()
70 myCustomTolerance = -1.0;
73 //=======================================================================
74 // function: ~SelectMgr_ToleranceMap
76 //=======================================================================
77 SelectMgr_ToleranceMap::~SelectMgr_ToleranceMap()
82 //=======================================================================
84 // purpose : Adds the value given to map, checks if the current tolerance value
85 // should be replaced by theTolerance
86 //=======================================================================
87 void SelectMgr_ToleranceMap::Add (const Standard_Real& theTolerance)
89 if (myTolerances.IsBound (theTolerance))
91 Standard_Integer& aFreq = myTolerances.ChangeFind (theTolerance);
94 if (aFreq == 1 && theTolerance != myLargestKey)
95 myLargestKey = Max (theTolerance, myLargestKey);
99 if (myTolerances.IsEmpty())
101 myTolerances.Bind (theTolerance, 1);
102 myLargestKey = theTolerance;
106 myTolerances.Bind (theTolerance, 1);
107 myLargestKey = Max (theTolerance, myLargestKey);
111 //=======================================================================
112 // function: Decrement
113 // purpose : Decrements a counter of the tolerance given, checks if the current tolerance value
114 // should be recalculated
115 //=======================================================================
116 void SelectMgr_ToleranceMap::Decrement (const Standard_Real& theTolerance)
118 if (myTolerances.IsBound (theTolerance))
120 Standard_Integer& aFreq = myTolerances.ChangeFind (theTolerance);
123 if (Abs (theTolerance - myLargestKey) < Precision::Confusion() && aFreq == 0)
126 for (NCollection_DataMap<Standard_Real, Standard_Integer>::Iterator anIter (myTolerances); anIter.More(); anIter.Next())
128 if (anIter.Value() != 0)
129 myLargestKey = Max (myLargestKey, anIter.Key());
135 //==================================================
136 // Function: Initialize
138 //==================================================
139 SelectMgr_ViewerSelector::SelectMgr_ViewerSelector():
140 preferclosest(Standard_True),
141 myToUpdateTolerance (Standard_True),
143 myIsLeftChildQueuedFirst (Standard_False),
146 mySelectableObjects = new SelectMgr_SelectableObjectSet();
150 //==================================================
151 // Function: Activate
153 //==================================================
154 void SelectMgr_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theSelection)
156 for (theSelection->Init(); theSelection->More(); theSelection->Next())
158 theSelection->Sensitive()->SetActiveForSelection();
161 theSelection->SetSelectionState (SelectMgr_SOS_Activated);
163 myTolerances.Add (theSelection->Sensitivity());
164 myToUpdateTolerance = Standard_True;
168 //==================================================
169 // Function: Deactivate
171 //==================================================
172 void SelectMgr_ViewerSelector::Deactivate (const Handle(SelectMgr_Selection)& theSelection)
174 for (theSelection->Init(); theSelection->More(); theSelection->Next())
176 theSelection->Sensitive()->ResetSelectionActiveStatus();
179 theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
181 myTolerances.Decrement (theSelection->Sensitivity());
182 myToUpdateTolerance = Standard_True;
185 //==================================================
188 //==================================================
189 void SelectMgr_ViewerSelector::Clear()
192 myMapOfDetected.Clear();
195 //=======================================================================
196 // function: isToScaleFrustum
197 // purpose : Checks if the entity given requires to scale current selecting frustum
198 //=======================================================================
199 Standard_Boolean SelectMgr_ViewerSelector::isToScaleFrustum (const Handle(SelectBasics_SensitiveEntity)& theEntity)
201 return mySelectingVolumeMgr.GetActiveSelectionType() == SelectMgr_SelectingVolumeManager::Point
202 && sensitivity (theEntity) < myTolerances.Tolerance();
205 //=======================================================================
206 // function: scaleAndTransform
207 // purpose : Applies given scale and transformation matrices to the default selecting volume manager
208 //=======================================================================
209 SelectMgr_SelectingVolumeManager SelectMgr_ViewerSelector::scaleAndTransform (const Standard_Real theScale,
210 const gp_Trsf& theTrsf)
212 SelectMgr_SelectingVolumeManager aMgr;
214 if (theScale > Precision::Angular())
216 aMgr = mySelectingVolumeMgr.Scale (theScale);
219 if (theTrsf.Form() != gp_Identity)
221 aMgr = aMgr.GetActiveSelectionType() == SelectMgr_SelectingVolumeManager::Unknown ?
222 mySelectingVolumeMgr.Transform (theTrsf) : aMgr.Transform (theTrsf);
228 //=======================================================================
229 // function: sensitivity
230 // purpose : In case if custom tolerance is set, this method will return sum of entity
231 // sensitivity and custom tolerance.
232 //=======================================================================
233 Standard_Real SelectMgr_ViewerSelector::sensitivity (const Handle(SelectBasics_SensitiveEntity)& theEntity) const
235 return myTolerances.IsCustomTolSet() ?
236 theEntity->SensitivityFactor() + myTolerances.CustomTolerance() : theEntity->SensitivityFactor();
239 //=======================================================================
240 // function: checkOverlap
241 // purpose : Internal function that checks if a particular sensitive
242 // entity theEntity overlaps current selecting volume precisely
243 //=======================================================================
244 void SelectMgr_ViewerSelector::checkOverlap (const Handle(SelectBasics_SensitiveEntity)& theEntity,
245 const Standard_Integer theEntityIdx,
246 SelectMgr_SelectingVolumeManager& theMgr)
248 Handle(SelectMgr_EntityOwner) anOwner (Handle(SelectMgr_EntityOwner)::DownCast (theEntity->OwnerId()));
250 SelectBasics_PickResult aPickResult;
251 if (theEntity->Matches (theMgr, aPickResult))
253 if (!anOwner.IsNull())
255 if (HasDepthClipping (anOwner) && theMgr.GetActiveSelectionType() == SelectMgr_SelectingVolumeManager::Point)
257 Standard_Boolean isClipped = theMgr.IsClipped (anOwner->Selectable()->GetClipPlanes(),
258 aPickResult.Depth());
263 Standard_Integer aPriority = anOwner->Priority();
265 SelectMgr_SortCriterion aCriterion (aPriority, aPickResult.Depth(), aPickResult.DistToGeomCenter(), theEntity->SensitivityFactor() / 33, preferclosest);
266 if (mystored.Contains (anOwner))
268 if (theMgr.GetActiveSelectionType() != 1)
270 SelectMgr_SortCriterion& aPrevCriterion = mystored.ChangeFromKey (anOwner);
271 if (aCriterion > aPrevCriterion)
273 aPrevCriterion = aCriterion;
274 myMapOfDetected.ChangeFind (anOwner) = theEntityIdx;
280 mystored.Add (anOwner, aCriterion);
281 myMapOfDetected.Bind (anOwner, theEntityIdx);
287 //=======================================================================
288 // function: traverseObject
289 // purpose : Internal function that checks if there is possible overlap
290 // between some entity of selectable object theObject and
291 // current selecting volume
292 //=======================================================================
293 void SelectMgr_ViewerSelector::traverseObject (const Handle(SelectMgr_SelectableObject)& theObject)
295 NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet =
296 myMapOfObjectSensitives.ChangeFind (theObject);
298 if (anEntitySet->Size() == 0)
301 const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& aSensitivesTree = anEntitySet->BVH();
303 SelectMgr_SelectingVolumeManager aMgr = theObject->HasTransformation() ?
304 mySelectingVolumeMgr.Transform (theObject->InversedTransformation()) : mySelectingVolumeMgr;
306 NCollection_DataMap<Handle(Standard_Type), SelectMgr_SelectingVolumeManager> aScaledTrnsfFrustums;
308 Standard_Integer aNode = 0; // a root node
309 if (!aMgr.Overlaps (aSensitivesTree->MinPoint (0),
310 aSensitivesTree->MaxPoint (0)))
314 Standard_Integer aStack[32];
315 Standard_Integer aHead = -1;
318 if (!aSensitivesTree->IsOuter (aNode))
320 const Standard_Integer aLeftChildIdx = aSensitivesTree->LeftChild (aNode);
321 const Standard_Integer aRightChildIdx = aSensitivesTree->RightChild (aNode);
322 const Standard_Boolean isLeftChildIn = aMgr.Overlaps (aSensitivesTree->MinPoint (aLeftChildIdx),
323 aSensitivesTree->MaxPoint (aLeftChildIdx));
324 const Standard_Boolean isRightChildIn = aMgr.Overlaps (aSensitivesTree->MinPoint (aRightChildIdx),
325 aSensitivesTree->MaxPoint (aRightChildIdx));
329 aNode = aLeftChildIdx;
331 aStack[aHead] = aRightChildIdx;
333 else if (isLeftChildIn
336 aNode = isLeftChildIn ? aLeftChildIdx : aRightChildIdx;
345 aNode = aStack[aHead];
351 Standard_Integer aStartIdx = aSensitivesTree->BegPrimitive (aNode);
352 Standard_Integer anEndIdx = aSensitivesTree->EndPrimitive (aNode);
353 for (Standard_Integer anIdx = aStartIdx; anIdx <= anEndIdx; ++anIdx)
355 const Handle(SelectMgr_SensitiveEntity)& aSensitive =
356 anEntitySet->GetSensitiveById (anIdx);
357 if (aSensitive->IsActiveForSelection())
359 const Handle(SelectBasics_SensitiveEntity)& anEnt = aSensitive->BaseSensitive();
360 SelectMgr_SelectingVolumeManager aTmpMgr = aMgr;
361 if (isToScaleFrustum (anEnt))
363 if (!aScaledTrnsfFrustums.IsBound (anEnt->DynamicType()))
365 aScaledTrnsfFrustums.Bind (anEnt->DynamicType(),
366 scaleAndTransform (sensitivity (anEnt), theObject->InversedTransformation()));
369 aTmpMgr = aScaledTrnsfFrustums.Find (anEnt->DynamicType());
371 checkOverlap (anEnt, anIdx, aTmpMgr);
379 aNode = aStack[aHead];
385 //=======================================================================
386 // function: TraverseSensitives
387 // purpose : Traverses BVH containing all added selectable objects and
388 // finds candidates for further search of overlap
389 //=======================================================================
390 void SelectMgr_ViewerSelector::TraverseSensitives()
393 myMapOfDetected.Clear();
395 if (mySelectableObjects->Size() == 0)
398 const NCollection_Handle<BVH_Tree<Standard_Real, 3> >& anObjectsTree = mySelectableObjects->BVH();
400 Standard_Integer aNode = 0;
401 if (!mySelectingVolumeMgr.Overlaps (anObjectsTree->MinPoint (0),
402 anObjectsTree->MaxPoint (0)))
406 Standard_Integer aStack[32];
407 Standard_Integer aHead = -1;
410 if (!anObjectsTree->IsOuter (aNode))
412 const Standard_Integer aLeftChildIdx = anObjectsTree->LeftChild (aNode);
413 const Standard_Integer aRightChildIdx = anObjectsTree->RightChild (aNode);
414 const Standard_Boolean isLeftChildIn =
415 mySelectingVolumeMgr.Overlaps (anObjectsTree->MinPoint (aLeftChildIdx),
416 anObjectsTree->MaxPoint (aLeftChildIdx));
417 const Standard_Boolean isRightChildIn =
418 mySelectingVolumeMgr.Overlaps (anObjectsTree->MinPoint (aRightChildIdx),
419 anObjectsTree->MaxPoint (aRightChildIdx));
423 aNode = aLeftChildIdx;
425 aStack[aHead] = aRightChildIdx;
427 else if (isLeftChildIn
430 aNode = isLeftChildIn ? aLeftChildIdx : aRightChildIdx;
439 aNode = aStack[aHead];
445 Standard_Integer aStartIdx = anObjectsTree->BegPrimitive (aNode);
446 Standard_Integer anEndIdx = anObjectsTree->EndPrimitive (aNode);
447 for (Standard_Integer anIdx = aStartIdx; anIdx <= anEndIdx; ++anIdx)
449 traverseObject (mySelectableObjects->GetObjectById (anIdx));
456 aNode = aStack[aHead];
464 //==================================================
467 //==================================================
468 Handle(SelectMgr_EntityOwner) SelectMgr_ViewerSelector
471 Standard_Integer RankInMap = myIndexes->Value (myCurRank);
472 const Handle(SelectBasics_EntityOwner)& toto = mystored.FindKey(RankInMap);
473 Handle(SelectMgr_EntityOwner) Ownr = Handle(SelectMgr_EntityOwner)::DownCast (toto);
479 //=======================================================================
482 //=======================================================================
483 Standard_Boolean SelectMgr_ViewerSelector::More()
485 if(mystored.Extent()==0) return Standard_False;
486 if(myCurRank==0) return Standard_False;
487 return myCurRank <= myIndexes->Length();
490 //==================================================
491 // Function: OnePicked
492 // Purpose : only the best one is chosen
493 // depend on priority and mindist...
494 //==================================================
496 Handle(SelectMgr_EntityOwner) SelectMgr_ViewerSelector
502 Standard_Integer RankInMap = myIndexes->Value (myIndexes->Lower());
503 const Handle(SelectBasics_EntityOwner)& toto = mystored.FindKey(RankInMap);
504 Handle(SelectMgr_EntityOwner) Ownr = Handle(SelectMgr_EntityOwner)::DownCast (toto);
508 Handle (SelectMgr_EntityOwner) NullObj; //returns a null Handle if there was not successfull pick...
513 //=======================================================================
514 //function : NbPicked
516 //=======================================================================
518 Standard_Integer SelectMgr_ViewerSelector::NbPicked() const
520 return mystored.Extent();
522 //=======================================================================
525 //=======================================================================
526 Handle(SelectMgr_EntityOwner) SelectMgr_ViewerSelector::Picked(const Standard_Integer aRank) const
529 Handle(SelectMgr_EntityOwner) anOwner;
530 if (aRank < 1 || aRank > NbPicked())
532 Standard_Integer anOwnerIdx = myIndexes->Value (aRank);
535 const Handle(SelectBasics_EntityOwner)& aStoredOwner = mystored.FindKey (anOwnerIdx);
536 anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aStoredOwner);
540 //===================================================
542 // INTERNAL METHODS ....
544 //==================================================
546 //==================================================
547 // Function: Contains
549 //==================================================
550 Standard_Boolean SelectMgr_ViewerSelector::Contains (const Handle(SelectMgr_SelectableObject)& theObject) const
552 return mySelectableObjects->Contains (theObject);
555 //==================================================
556 // Function: ActiveModes
557 // Purpose : return all the modes with a given state for an object
558 //==================================================
559 Standard_Boolean SelectMgr_ViewerSelector::Modes (const Handle(SelectMgr_SelectableObject)& theSelectableObject,
560 TColStd_ListOfInteger& theModeList,
561 const SelectMgr_StateOfSelection theWantedState) const
563 Standard_Boolean hasActivatedStates = mySelectableObjects->Contains (theSelectableObject);
564 for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next())
566 if (theWantedState == SelectMgr_SOS_Any)
568 theModeList.Append (theSelectableObject->CurrentSelection()->Mode());
570 else if (theWantedState == theSelectableObject->CurrentSelection()->GetSelectionState())
572 theModeList.Append (theSelectableObject->CurrentSelection()->Mode());
576 return hasActivatedStates;
579 //==================================================
580 // Function: IsActive
582 //==================================================
583 Standard_Boolean SelectMgr_ViewerSelector::IsActive (const Handle(SelectMgr_SelectableObject)& theSelectableObject,
584 const Standard_Integer theMode) const
586 if (!mySelectableObjects->Contains (theSelectableObject))
587 return Standard_False;
589 for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next())
591 if (theMode == theSelectableObject->CurrentSelection()->Mode())
593 return theSelectableObject->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated;
597 return Standard_False;
600 //==================================================
601 // Function: IsInside
603 //==================================================
604 Standard_Boolean SelectMgr_ViewerSelector::IsInside (const Handle(SelectMgr_SelectableObject)& theSelectableObject,
605 const Standard_Integer theMode) const
607 if (!mySelectableObjects->Contains (theSelectableObject))
608 return Standard_False;
610 for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next())
612 if (theMode == theSelectableObject->CurrentSelection()->Mode())
614 return theSelectableObject->CurrentSelection()->GetSelectionState() != SelectMgr_SOS_Unknown;
618 return Standard_False;
622 //=======================================================================
625 //=======================================================================
627 SelectMgr_StateOfSelection SelectMgr_ViewerSelector::Status (const Handle(SelectMgr_Selection)& theSelection) const
629 return theSelection->GetSelectionState();
632 //==================================================
634 // Purpose : gives Information about selectors
635 //==================================================
637 TCollection_AsciiString SelectMgr_ViewerSelector::Status (const Handle(SelectMgr_SelectableObject)& theSelectableObject) const
639 TCollection_AsciiString aStatus ("Status Object :\n\t");
641 for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next())
643 if (theSelectableObject->CurrentSelection()->GetSelectionState() != SelectMgr_SOS_Unknown)
645 aStatus = aStatus + "Mode " +
646 TCollection_AsciiString (theSelectableObject->CurrentSelection()->Mode()) +
648 if (theSelectableObject->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated)
650 aStatus = aStatus + " Active \n\t";
654 aStatus = aStatus + " Inactive \n\t";
659 if (mySelectableObjects->Contains (theSelectableObject))
661 aStatus = aStatus + "Not Present in the selector\n\n";
667 //=======================================================================
668 //function : SortResult
669 //purpose : there is a certain number of entities ranged by criteria
670 // (depth, size, priority, mouse distance from borders or
671 // CDG of the detected primitive. Parsing :
672 // maximum priorities .
673 // then a reasonable compromise between depth and distance...
674 // finally the ranges are stored in myindexes depending on the parsing.
675 // so, it is possible to only read
676 //=======================================================================
677 void SelectMgr_ViewerSelector::SortResult()
679 if(mystored.IsEmpty()) return;
681 const Standard_Integer anExtent = mystored.Extent();
682 if(myIndexes.IsNull() || anExtent != myIndexes->Length())
683 myIndexes = new TColStd_HArray1OfInteger (1, anExtent);
686 TColStd_Array1OfInteger& thearr = myIndexes->ChangeArray1();
688 // indices from 1 to N are loaded
690 for (I=1; I <= anExtent; I++)
693 std::sort (thearr.begin(), thearr.end(), CompareResults (mystored));
697 //=======================================================================
698 //function : HasDepthClipping
700 //=======================================================================
701 Standard_Boolean SelectMgr_ViewerSelector::HasDepthClipping (const Handle(SelectMgr_EntityOwner)& /*theOwner*/) const
703 return Standard_False;
706 //=======================================================================
707 // function : AddSelectableObject
708 // purpose : Adds new object to the map of selectable objects
709 //=======================================================================
710 void SelectMgr_ViewerSelector::AddSelectableObject (const Handle(SelectMgr_SelectableObject)& theObject)
712 if (!myMapOfObjectSensitives.IsBound (theObject))
714 mySelectableObjects->Append (theObject);
715 NCollection_Handle<SelectMgr_SensitiveEntitySet> anEntitySet = new SelectMgr_SensitiveEntitySet();
716 myMapOfObjectSensitives.Bind (theObject, anEntitySet);
720 //=======================================================================
721 // function : AddSelectionToObject
722 // purpose : Adds new selection to the object and builds its BVH tree
723 //=======================================================================
724 void SelectMgr_ViewerSelector::AddSelectionToObject (const Handle(SelectMgr_SelectableObject)& theObject,
725 const Handle(SelectMgr_Selection)& theSelection)
727 if (myMapOfObjectSensitives.IsBound (theObject))
729 NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet =
730 myMapOfObjectSensitives.ChangeFind (theObject);
731 anEntitySet->Append (theSelection);
736 AddSelectableObject (theObject);
737 AddSelectionToObject (theObject, theSelection);
741 //=======================================================================
742 // function : RemoveSelectableObject
743 // purpose : Removes selectable object from map of selectable ones
744 //=======================================================================
745 void SelectMgr_ViewerSelector::RemoveSelectableObject (const Handle(SelectMgr_SelectableObject)& theObject)
747 if (myMapOfObjectSensitives.IsBound (theObject))
749 myMapOfObjectSensitives.UnBind (theObject);
750 mySelectableObjects->Remove (theObject);
754 //=======================================================================
755 // function : RemoveSelectionOfObject
756 // purpose : Removes selection of the object and marks its BVH tree
758 //=======================================================================
759 void SelectMgr_ViewerSelector::RemoveSelectionOfObject (const Handle(SelectMgr_SelectableObject)& theObject,
760 const Handle(SelectMgr_Selection)& theSelection)
762 if (myMapOfObjectSensitives.IsBound (theObject))
764 NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet =
765 myMapOfObjectSensitives.ChangeFind (theObject);
766 anEntitySet->Remove (theSelection);
770 //=======================================================================
771 // function : RebuildObjectsTree
772 // purpose : Marks BVH of selectable objects for rebuild
773 //=======================================================================
774 void SelectMgr_ViewerSelector::RebuildObjectsTree (const Standard_Boolean theIsForce)
776 mySelectableObjects->MarkDirty();
780 mySelectableObjects->BVH();
784 //=======================================================================
785 // function : RebuildSensitivesTree
786 // purpose : Marks BVH of sensitive entities of particular selectable
787 // object for rebuild
788 //=======================================================================
789 void SelectMgr_ViewerSelector::RebuildSensitivesTree (const Handle(SelectMgr_SelectableObject)& theObject,
790 const Standard_Boolean theIsForce)
792 if (!mySelectableObjects->Contains (theObject))
795 NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet = myMapOfObjectSensitives.ChangeFind (theObject);
796 anEntitySet->MarkDirty();
804 //=======================================================================
805 // function : resetSelectionActivationStatus
806 // purpose : Marks all added sensitive entities of all objects as
808 //=======================================================================
809 void SelectMgr_ViewerSelector::ResetSelectionActivationStatus()
811 SelectMgr_MapOfObjectSensitivesIterator aSensitivesIter (myMapOfObjectSensitives);
812 for ( ; aSensitivesIter.More(); aSensitivesIter.Next())
814 NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet =
815 aSensitivesIter.ChangeValue();
816 Standard_Integer anEntitiesNb = anEntitySet->Size();
817 for (Standard_Integer anIdx = 0; anIdx < anEntitiesNb; ++anIdx)
819 anEntitySet->GetSensitiveById (anIdx)->ResetSelectionActiveStatus();
824 //=======================================================================
825 // function : DetectedEntity
826 // purpose : Returns sensitive entity that was detected during the
827 // previous run of selection algorithm
828 //=======================================================================
829 const Handle(SelectBasics_SensitiveEntity)& SelectMgr_ViewerSelector::DetectedEntity() const
831 const Handle(SelectMgr_EntityOwner)& anOwner = myDetectedIter.Key();
832 const Handle(SelectMgr_SelectableObject)& anObject = anOwner->Selectable();
833 const NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet =
834 myMapOfObjectSensitives.Find (anObject);
836 return anEntitySet->GetSensitiveById (myDetectedIter.Value())->BaseSensitive();
839 //=======================================================================
840 // function : ActiveOwners
841 // purpose : Returns the list of active entity owners
842 //=======================================================================
843 void SelectMgr_ViewerSelector::ActiveOwners (NCollection_List<Handle(SelectBasics_EntityOwner)>& theOwners) const
845 for (SelectMgr_MapOfObjectSensitivesIterator anIter (myMapOfObjectSensitives); anIter.More(); anIter.Next())
847 const NCollection_Handle<SelectMgr_SensitiveEntitySet>& anEntitySet = anIter.Value();
848 Standard_Integer anEntitiesNb = anEntitySet->Size();
849 for (Standard_Integer anIdx = 0; anIdx < anEntitiesNb; ++anIdx)
851 if (anEntitySet->GetSensitiveById (anIdx)->IsActiveForSelection())
853 theOwners.Append (anEntitySet->GetSensitiveById (anIdx)->BaseSensitive()->OwnerId());
859 //=======================================================================
860 //function : AllowOverlapDetection
861 //purpose : Sets the detection type: if theIsToAllow is false,
862 // only fully included sensitives will be detected, otherwise
863 // the algorithm will mark both included and overlapped entities
865 //=======================================================================
866 void SelectMgr_ViewerSelector::AllowOverlapDetection (const Standard_Boolean theIsToAllow)
868 mySelectingVolumeMgr.AllowOverlapDetection (theIsToAllow);