#include <TColStd_ListOfInteger.hxx>
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
+IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectionManager,MMgt_TShared)
+
static Standard_Integer FindIndex (const SelectMgr_SequenceOfSelector& theSelectorsSeq,
const Handle(SelectMgr_ViewerSelector)& theSelector)
{
{
if (!myGlobal.Contains (theObject))
{
- if (theObject->HasOwnPresentations())
- {
- SelectMgr_SequenceOfSelector aSelectors;
- aSelectors.Append (theSelector);
- myLocal.Bind (theObject, aSelectors);
- }
- else
+ for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
{
- for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
- {
- Load (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theSelector, theMode);
- }
+ Load (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theSelector, theMode);
}
+ if (!theObject->HasOwnPresentations())
+ return;
+
+ SelectMgr_SequenceOfSelector aSelectors;
+ aSelectors.Append (theSelector);
+ myLocal.Bind (theObject, aSelectors);
}
}
}
//==================================================
void SelectMgr_SelectionManager::Remove (const Handle(SelectMgr_SelectableObject)& theObject)
{
+ for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
+ {
+ Remove (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()));
+ }
+
+ if (!theObject->HasOwnPresentations())
+ return;
+
if (myGlobal.Contains (theObject))
{
for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
SelectMgr_SequenceOfSelector& aSelectors = myLocal.ChangeFind (theObject);
for (Standard_Integer aSelectorsIdx = 1; aSelectorsIdx <= aSelectors.Length(); aSelectorsIdx++)
{
- Handle(SelectMgr_ViewerSelector) aCurSelector =
- Handle(SelectMgr_ViewerSelector)::DownCast (aSelectors (aSelectorsIdx));
+ Handle(SelectMgr_ViewerSelector) aCurSelector = aSelectors (aSelectorsIdx);
if (!aCurSelector->Contains (theObject))
continue;
myLocal.UnBind (theObject);
}
- else if (!theObject->HasOwnPresentations())
- {
- for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
- {
- Remove (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()));
- }
- }
theObject->ClearSelections();
}
if (!theSelector.IsNull() && !mySelectors.Contains (theSelector))
return;
- if (!theObject->HasOwnPresentations())
+ for (PrsMgr_ListOfPresentableObjectsIter anChildIter (theObject->Children()); anChildIter.More(); anChildIter.Next())
{
- for (PrsMgr_ListOfPresentableObjectsIter anChildIter (theObject->Children()); anChildIter.More(); anChildIter.Next())
- {
- Activate (Handle(SelectMgr_SelectableObject)::DownCast (anChildIter.Value()), theMode, theSelector);
- }
+ Activate (Handle(SelectMgr_SelectableObject)::DownCast (anChildIter.Value()), theMode, theSelector);
+ }
+ if (!theObject->HasOwnPresentations())
return;
- }
Standard_Boolean isComputed = Standard_False;
if (theObject->HasSelection (theMode))
SelectMgr_SequenceOfSelector& theSelectors = myLocal.ChangeFind (theObject);
for (Standard_Integer aSelectorIdx = 1; aSelectorIdx <= theSelectors.Length(); aSelectorIdx++)
{
- Handle(SelectMgr_ViewerSelector) aCurSelector =
- Handle(SelectMgr_ViewerSelector)::DownCast (theSelectors (aSelectorIdx));
+ Handle(SelectMgr_ViewerSelector) aCurSelector = theSelectors (aSelectorIdx);
Activate (theObject, theMode, aCurSelector);
}
}
if (myGlobal.Contains (theObject))
{
- if (theMode != 0 && theSelector->IsActive (theObject, 0))
+ const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode();
+ if (theMode != aGlobalSelMode && theSelector->IsActive (theObject, aGlobalSelMode))
{
- theSelector->Deactivate (theObject->Selection (0));
+ theSelector->Deactivate (theObject->Selection (aGlobalSelMode));
}
theSelector->Activate (theObject->Selection (theMode));
}
const Standard_Integer theMode,
const Handle(SelectMgr_ViewerSelector)& theSelector)
{
-
- if (!theObject->HasOwnPresentations())
+ for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
{
- for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
- {
- Deactivate (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector);
- }
+ Deactivate (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector);
+ }
+ if (!theObject->HasOwnPresentations())
return;
- }
Standard_Boolean isInGlobal = myGlobal.Contains (theObject);
Standard_Boolean hasSelection = theMode == -1 ? Standard_True : theObject->HasSelection (theMode);
const Standard_Integer theMode,
const Handle(SelectMgr_ViewerSelector)& theSelector) const
{
- if (!theObject->HasOwnPresentations())
+ for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
{
- for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
- {
- if (IsActivated (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector))
- return Standard_True;
- }
+ if (IsActivated (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector))
+ return Standard_True;
+ }
+ if (!theObject->HasOwnPresentations())
return Standard_False;
- }
if (!(myGlobal.Contains (theObject) || myLocal.IsBound (theObject)))
return Standard_False;
}
}
+//==================================================
+// Function: recomputeSelectionMode
+// Purpose :
+//==================================================
+void SelectMgr_SelectionManager::recomputeSelectionMode (const Handle(SelectMgr_SelectableObject)& theObject,
+ const Handle(SelectMgr_Selection)& theSelection,
+ const Standard_Integer theMode)
+{
+ theSelection->UpdateStatus (SelectMgr_TOU_Full);
+
+ for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
+ {
+ Handle(SelectMgr_ViewerSelector) aCurSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key());
+
+ ClearSelectionStructures (theObject, theMode, aCurSelector);
+ theObject->RecomputePrimitives (theMode);
+ RestoreSelectionStructures (theObject, theMode, aCurSelector);
+ theSelection->UpdateStatus (SelectMgr_TOU_None);
+ theSelection->UpdateBVHStatus (SelectMgr_TBU_None);
+ }
+}
+
//==================================================
// Function: Update
// Purpose :
if (!(myGlobal.Contains (theObject) || myLocal.IsBound (theObject)))
return;
- for(theObject->Init(); theObject->More(); theObject->Next())
+ if (theMode == -1)
{
- const Handle(SelectMgr_Selection)& aSelection = theObject->CurrentSelection();
- aSelection->UpdateStatus (SelectMgr_TOU_Full);
- Standard_Integer aSelMode = aSelection->Mode();
-
- for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
+ for (theObject->Init(); theObject->More(); theObject->Next())
{
- Handle(SelectMgr_ViewerSelector) aCurSelector (Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key()));
- if (aCurSelector->Status (aSelection) == SelectMgr_SOS_Activated)
- {
- ClearSelectionStructures (theObject, aSelMode, aCurSelector);
- theObject->RecomputePrimitives(aSelMode);
- RestoreSelectionStructures (theObject, aSelMode, aCurSelector);
- aSelection->UpdateStatus (SelectMgr_TOU_None);
- aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
- }
+ const Handle(SelectMgr_Selection)& aSelection = theObject->CurrentSelection();
+ Standard_Integer aSelMode = aSelection->Mode();
+ recomputeSelectionMode (theObject, aSelection, aSelMode);
}
}
+ else
+ {
+ if (!theObject->HasSelection (theMode))
+ return;
+
+ const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode);
+ recomputeSelectionMode (theObject, aSelection, theMode);
+ }
}
//=======================================================================
}
}
}
+
+//=======================================================================
+//function : UpdateSelection
+//purpose :
+//=======================================================================
+void SelectMgr_SelectionManager::UpdateSelection (const Handle(SelectMgr_SelectableObject)& theObject)
+{
+ if (myGlobal.Contains (theObject))
+ {
+ for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
+ {
+ Handle(SelectMgr_ViewerSelector) aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key());
+ if (aSelector->Contains (theObject))
+ {
+ aSelector->MoveSelectableObject (theObject);
+ }
+ }
+ }
+
+ if (myLocal.IsBound (theObject))
+ {
+ const SelectMgr_SequenceOfSelector& aSelectors = myLocal (theObject);
+ for (SelectMgr_SequenceOfSelector::Iterator aSelectorsIter (aSelectors); aSelectorsIter.More(); aSelectorsIter.Next())
+ {
+ Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.ChangeValue();
+ if (aSelector->Contains (theObject))
+ {
+ aSelector->MoveSelectableObject (theObject);
+ }
+ }
+ }
+}