1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-09 13:22:24 +03:00

0025467: Visualization - Possibility to remove AIS_LocalContext class

Deprecated functionality related to Local Context has been removed.

The following classes and types have been removed:
AIS_LocalContext, AIS_DataMapOfILC, AIS_LocalStatus, SelectMgr_SequenceOfSelector, SelectMgr_DataMapOfObjectSelectors.
Value AIS_DS_Temporary has been removed from enumeration AIS_DisplayStatus.

The following methods related to Local Context have been removed from AIS_InteractiveContext:
::HasOpenedContext(), ::HighestIndex(), ::LocalContext(),
::LocalSelector(), ::OpenLocalContext(), ::CloseLocalContext(),
::IndexOfCurrentLocal(), ::CloseAllContexts(), ::ResetOriginalState(),
::ClearLocalContext(), ::UseDisplayedObjects(), ::NotUseDisplayedObjects(),
::SetShapeDecomposition(), ::SetTemporaryAttributes(),
::ActivateStandardMode(), ::DeactivateStandardMode(), ::KeepTemporary(),
::SubIntensityOn(), ::SubIntensityOff(),
::ActivatedStandardModes(), ::IsInLocal()
and ::AddOrRemoveSelected() taking TopoDS_Shape.

The methods AIS_InteractiveContext::Display() and ::Load()
taking argument theToAllowDecomposition have been marked as deprecated;
the new methods without this unused argument should be used instead.
AIS_InteractiveContext::DisplayedObjects() - removed argument theOnlyFromNeutral.

SelectMgr_SelectionManager has been simplified so that now it support only single Viewer Selector.

The argument -local has been removed from Draw Harness commands vselmode, vremove, vdisplay, vdisplayall, verase.
This commit is contained in:
kgv
2018-06-20 08:48:40 +03:00
parent d9f79dae49
commit 68dcee028d
58 changed files with 449 additions and 7766 deletions

View File

@@ -5,8 +5,6 @@ SelectMgr_BaseFrustum.hxx
SelectMgr_CompositionFilter.cxx
SelectMgr_CompositionFilter.hxx
SelectMgr_CompositionFilter.lxx
SelectMgr_DataMapIteratorOfDataMapOfObjectSelectors.hxx
SelectMgr_DataMapOfObjectSelectors.hxx
SelectMgr_EntityOwner.cxx
SelectMgr_EntityOwner.hxx
SelectMgr_Filter.cxx
@@ -41,7 +39,6 @@ SelectMgr_SensitiveEntitySet.hxx
SelectMgr_SequenceOfFilter.hxx
SelectMgr_SequenceOfOwner.hxx
SelectMgr_SequenceOfSelection.hxx
SelectMgr_SequenceOfSelector.hxx
SelectMgr_SOPtr.hxx
SelectMgr_SortCriterion.hxx
SelectMgr_StateOfSelection.hxx

View File

@@ -1,20 +0,0 @@
// Copyright (c) 2015 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef SelectMgr_DataMapIteratorOfDataMapOfObjectSelectors_HeaderFile
#define SelectMgr_DataMapIteratorOfDataMapOfObjectSelectors_HeaderFile
#include <SelectMgr_DataMapOfObjectSelectors.hxx>
#endif

View File

@@ -1,29 +0,0 @@
// Created on: 1995-02-06
// Created by: Mister rmi
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef SelectMgr_DataMapOfObjectSelectors_HeaderFile
#define SelectMgr_DataMapOfObjectSelectors_HeaderFile
#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_SequenceOfSelector.hxx>
#include <TColStd_MapTransientHasher.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject),SelectMgr_SequenceOfSelector,TColStd_MapTransientHasher> SelectMgr_DataMapOfObjectSelectors;
typedef NCollection_DataMap<Handle(SelectMgr_SelectableObject),SelectMgr_SequenceOfSelector,TColStd_MapTransientHasher>::Iterator SelectMgr_DataMapIteratorOfDataMapOfObjectSelectors;
#endif

View File

@@ -16,93 +16,29 @@
#include <SelectMgr_SelectionManager.hxx>
#include <OSD_Environment.hxx>
#include <SelectMgr_DataMapIteratorOfDataMapOfObjectSelectors.hxx>
#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_Selection.hxx>
#include <SelectMgr_SequenceOfSelector.hxx>
#include <SelectMgr_ViewerSelector.hxx>
#include <Standard_Type.hxx>
#include <TCollection_AsciiString.hxx>
#include <TColStd_ListIteratorOfListOfInteger.hxx>
#include <TColStd_ListOfInteger.hxx>
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectionManager,Standard_Transient)
namespace
{
static bool containsSelector (const SelectMgr_SequenceOfSelector& theSelectorsSeq,
const Handle(SelectMgr_ViewerSelector)& theSelector)
{
for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (theSelectorsSeq); aSelectorIter.More(); aSelectorIter.Next())
{
if (aSelectorIter.Value() == theSelector)
{
return true;
}
}
return false;
}
}
//==================================================
// Function: Create
// Purpose :
//==================================================
SelectMgr_SelectionManager::SelectMgr_SelectionManager()
SelectMgr_SelectionManager::SelectMgr_SelectionManager (const Handle(SelectMgr_ViewerSelector)& theSelector)
: mySelector (theSelector)
{
//
}
//==================================================
// Function: Add
// Purpose :
//==================================================
void SelectMgr_SelectionManager::Add (const Handle(SelectMgr_ViewerSelector)& theSelector)
{
mySelectors.Add (theSelector);
}
//==================================================
// Function: Remove
// Purpose :
//==================================================
void SelectMgr_SelectionManager::Remove (const Handle(SelectMgr_ViewerSelector)& theSelector)
{
for (SelectMgr_DataMapIteratorOfDataMapOfObjectSelectors aSelIter (myLocal); aSelIter.More(); aSelIter.Next())
{
SelectMgr_SequenceOfSelector& theSelectors = myLocal.ChangeFind (aSelIter.Key());
for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (theSelectors); aSelectorIter.More(); aSelectorIter.Next())
{
if (aSelectorIter.Value() == theSelector)
{
theSelectors.Remove (aSelectorIter);
break;
}
}
}
mySelectors.Remove (theSelector);
}
//==================================================
// Function: Contains
// Purpose :
//==================================================
Standard_Boolean SelectMgr_SelectionManager::Contains (const Handle(SelectMgr_ViewerSelector)& theSelector) const
{
return mySelectors.Contains (theSelector);
}
//==================================================
// Function: Contains
// Purpose :
//==================================================
Standard_Boolean SelectMgr_SelectionManager::Contains (const Handle(SelectMgr_SelectableObject)& theObject) const
{
return myGlobal.Contains (theObject)
|| myLocal.IsBound (theObject);
return myGlobal.Contains (theObject);
}
//==================================================
@@ -124,63 +60,14 @@ void SelectMgr_SelectionManager::Load (const Handle(SelectMgr_SelectableObject)&
return;
myGlobal.Add(theObject);
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
if (!mySelector->Contains (theObject) && theObject->HasOwnPresentations())
{
const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key();
if (!aSelector->Contains (theObject) && theObject->HasOwnPresentations())
{
aSelector->AddSelectableObject (theObject);
}
mySelector->AddSelectableObject (theObject);
}
if (theMode != -1)
loadMode (theObject, theMode);
}
//==================================================
// Function: Load
// Purpose :
//==================================================
void SelectMgr_SelectionManager::Load (const Handle(SelectMgr_SelectableObject)& theObject,
const Handle(SelectMgr_ViewerSelector)& theSelector,
const Standard_Integer theMode)
{
mySelectors.Add (theSelector);
if (theMode != -1)
{
loadMode (theObject, theMode, theSelector);
}
if (theObject->HasOwnPresentations())
{
theSelector->AddSelectableObject (theObject);
}
if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject))
{
if (!containsSelector (*aSelectors, theSelector))
{
aSelectors->Append (theSelector);
}
}
else
{
if (!myGlobal.Contains (theObject))
{
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
{
Load (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theSelector, theMode);
}
if (!theObject->HasOwnPresentations())
return;
SelectMgr_SequenceOfSelector aGlobSelectors;
aGlobSelectors.Append (theSelector);
myLocal.Bind (theObject, aGlobSelectors);
}
}
}
//==================================================
// Function: Remove
// Purpose :
@@ -197,105 +84,34 @@ void SelectMgr_SelectionManager::Remove (const Handle(SelectMgr_SelectableObject
if (myGlobal.Contains (theObject))
{
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
if (mySelector->Contains (theObject))
{
const Handle(SelectMgr_ViewerSelector)& aCurSelector = aSelectorsIter.Key();
if (!aCurSelector->Contains (theObject))
{
continue;
}
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
aCurSelector->RemoveSelectionOfObject (theObject, aSelIter.Value());
mySelector->RemoveSelectionOfObject (theObject, aSelIter.Value());
aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Remove);
}
aCurSelector->RemoveSelectableObject (theObject);
mySelector->RemoveSelectableObject (theObject);
}
myGlobal.Remove (theObject);
}
else if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject))
{
for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (*aSelectors); aSelectorIter.More(); aSelectorIter.Next())
{
const Handle(SelectMgr_ViewerSelector)& aCurSelector = aSelectorIter.Value();
if (!aCurSelector->Contains (theObject))
continue;
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
aCurSelector->RemoveSelectionOfObject (theObject, aSelIter.Value());
aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Remove);
}
aCurSelector->RemoveSelectableObject (theObject);
}
myLocal.UnBind (theObject);
}
theObject->ClearSelections();
}
//==================================================
// Function: Remove
// Purpose :
//==================================================
void SelectMgr_SelectionManager::Remove (const Handle(SelectMgr_SelectableObject)& theObject,
const Handle(SelectMgr_ViewerSelector)& theSelector)
{
if (!theSelector->Contains (theObject))
return;
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
{
Remove (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theSelector);
}
if (!theObject->HasOwnPresentations())
return;
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
theSelector->RemoveSelectionOfObject (theObject, aSelIter.Value());
aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Remove);
}
theSelector->RemoveSelectableObject (theObject);
if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject))
{
for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (*aSelectors); aSelectorIter.More(); aSelectorIter.Next())
{
if (aSelectorIter.Value() == theSelector)
{
aSelectors->Remove (aSelectorIter);
break;
}
}
if (aSelectors->IsEmpty())
{
myLocal.UnBind (theObject);
}
}
}
//==================================================
// Function: Activate
// Purpose :
//==================================================
void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const Handle(SelectMgr_ViewerSelector)& theSelector)
const Standard_Integer theMode)
{
if (theMode == -1)
return;
if (!theSelector.IsNull() && !mySelectors.Contains (theSelector))
return;
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);
}
if (!theObject->HasOwnPresentations())
return;
@@ -310,26 +126,6 @@ void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObje
loadMode (theObject, theMode);
}
if (theSelector.IsNull())
{
if (myGlobal.Contains (theObject))
{
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
const Handle(SelectMgr_ViewerSelector)& aCurSelector = aSelectorsIter.Key();
Activate (theObject, theMode, aCurSelector);
}
}
else if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject))
{
for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (*aSelectors); aSelectorIter.More(); aSelectorIter.Next())
{
Handle(SelectMgr_ViewerSelector) aCurSelector = aSelectorIter.Value();
Activate (theObject, theMode, aCurSelector);
}
}
}
const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode);
switch (aSelection->UpdateStatus())
{
@@ -337,7 +133,7 @@ void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObje
{
if (theObject->HasSelection (theMode))
{
theSelector->RemoveSelectionOfObject (theObject, aSelection);
mySelector->RemoveSelectionOfObject (theObject, aSelection);
}
theObject->RecomputePrimitives (theMode);
// pass through SelectMgr_TOU_Partial
@@ -346,7 +142,7 @@ void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObje
case SelectMgr_TOU_Partial:
{
theObject->UpdateTransformations (aSelection);
theSelector->RebuildObjectsTree();
mySelector->RebuildObjectsTree();
break;
}
default:
@@ -359,14 +155,14 @@ void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObje
case SelectMgr_TBU_Add:
case SelectMgr_TBU_Renew:
{
theSelector->AddSelectionToObject (theObject, aSelection);
mySelector->AddSelectionToObject (theObject, aSelection);
break;
}
case SelectMgr_TBU_Remove:
{
if (aSelection->GetSelectionState() == SelectMgr_SOS_Deactivated)
{
theSelector->AddSelectionToObject (theObject, aSelection);
mySelector->AddSelectionToObject (theObject, aSelection);
}
break;
}
@@ -377,18 +173,7 @@ void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObje
if (myGlobal.Contains (theObject))
{
theSelector->Activate (theObject->Selection (theMode));
}
else
{
if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject))
{
if (!containsSelector (*aSelectors, theSelector))
{
aSelectors->Append (theSelector);
}
theSelector->Activate (theObject->Selection (theMode));
}
mySelector->Activate (theObject->Selection (theMode));
}
}
@@ -397,54 +182,32 @@ void SelectMgr_SelectionManager::Activate (const Handle(SelectMgr_SelectableObje
// Purpose :
//==================================================
void SelectMgr_SelectionManager::Deactivate (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const Handle(SelectMgr_ViewerSelector)& theSelector)
const Standard_Integer theMode)
{
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);
}
if (!theObject->HasOwnPresentations())
{
return;
}
if (!myGlobal.Contains(theObject)
&& !myLocal.IsBound (theObject))
if (!myGlobal.Contains(theObject))
{
return;
}
const Handle(SelectMgr_Selection)& aSel = theObject->Selection (theMode);
if (!theSelector.IsNull())
if (theMode == -1)
{
if (theMode == -1)
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
theSelector->Deactivate (aSelIter.Value());
}
mySelector->Deactivate (aSelIter.Value());
}
else if (!aSel.IsNull())
{
theSelector->Deactivate (aSel);
}
return;
}
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
else if (!aSel.IsNull())
{
const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorIter.Key();
if (theMode == -1)
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
aSelector->Deactivate (aSelIter.Value());
}
}
else if (!aSel.IsNull())
{
aSelector->Deactivate (aSel);
}
mySelector->Deactivate (aSel);
}
}
@@ -453,29 +216,27 @@ void SelectMgr_SelectionManager::Deactivate (const Handle(SelectMgr_SelectableOb
//purpose :
//=======================================================================
Standard_Boolean SelectMgr_SelectionManager::IsActivated (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const Handle(SelectMgr_ViewerSelector)& theSelector) const
const Standard_Integer theMode) const
{
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObject->Children()); anChildrenIter.More(); anChildrenIter.Next())
{
if (IsActivated (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector))
if (IsActivated (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode))
return Standard_True;
}
if (!theObject->HasOwnPresentations())
{
return Standard_False;
}
if (!myGlobal.Contains(theObject)
&& !myLocal.IsBound (theObject))
if (!myGlobal.Contains(theObject))
{
return Standard_False;
}
if (theMode == -1 && theSelector.IsNull())
if (theMode == -1)
{
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
if (IsActivated (theObject, aSelIter.Value()->Mode()))
if (mySelector->Status (aSelIter.Value()) == SelectMgr_SOS_Activated)
{
return Standard_True;
}
@@ -488,21 +249,8 @@ Standard_Boolean SelectMgr_SelectionManager::IsActivated (const Handle(SelectMgr
{
return Standard_False;
}
if (!theSelector.IsNull())
{
return theSelector->Status (aSelection) == SelectMgr_SOS_Activated;
}
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
{
const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorIter.Key();
if (aSelector->Status (aSelection) == SelectMgr_SOS_Activated)
{
return Standard_True;
}
}
return Standard_False;
return !aSelection.IsNull()
&& mySelector->Status (aSelection) == SelectMgr_SOS_Activated;
}
//=======================================================================
@@ -512,39 +260,27 @@ Standard_Boolean SelectMgr_SelectionManager::IsActivated (const Handle(SelectMgr
// or it was recomputed somehow
//=======================================================================
void SelectMgr_SelectionManager::ClearSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj,
const Standard_Integer theMode,
const Handle(SelectMgr_ViewerSelector)& theSelector)
const Standard_Integer theMode)
{
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObj->Children()); anChildrenIter.More(); anChildrenIter.Next())
{
ClearSelectionStructures (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector);
ClearSelectionStructures (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode);
}
if (!theObj->HasOwnPresentations())
{
return;
}
if (!myGlobal.Contains(theObj)
&& !myLocal.IsBound (theObj))
if (!myGlobal.Contains(theObj))
{
return;
}
if (theSelector.IsNull())
{
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key();
ClearSelectionStructures (theObj, theMode, aSelector);
}
return;
}
if (theMode != -1)
{
if (const Handle(SelectMgr_Selection)& aSelection = theObj->Selection (theMode))
{
theSelector->RemoveSelectionOfObject (theObj, aSelection);
mySelector->RemoveSelectionOfObject (theObj, aSelection);
aSelection->UpdateBVHStatus (SelectMgr_TBU_Add);
}
}
@@ -553,11 +289,11 @@ void SelectMgr_SelectionManager::ClearSelectionStructures (const Handle(SelectMg
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObj->Selections()); aSelIter.More(); aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
theSelector->RemoveSelectionOfObject (theObj, aSelection);
mySelector->RemoveSelectionOfObject (theObj, aSelection);
aSelection->UpdateBVHStatus (SelectMgr_TBU_Add);
}
}
theSelector->RebuildObjectsTree();
mySelector->RebuildObjectsTree();
}
//=======================================================================
@@ -566,38 +302,26 @@ void SelectMgr_SelectionManager::ClearSelectionStructures (const Handle(SelectMg
// defined by mode theMode to all viewer selectors contained that selection.
//=======================================================================
void SelectMgr_SelectionManager::RestoreSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj,
const Standard_Integer theMode,
const Handle(SelectMgr_ViewerSelector)& theSelector)
const Standard_Integer theMode)
{
for (PrsMgr_ListOfPresentableObjectsIter anChildrenIter (theObj->Children()); anChildrenIter.More(); anChildrenIter.Next())
{
RestoreSelectionStructures (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector);
RestoreSelectionStructures (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode);
}
if (!theObj->HasOwnPresentations())
{
return;
}
if (!myGlobal.Contains(theObj)
&& !myLocal.IsBound (theObj))
if (!myGlobal.Contains(theObj))
{
return;
}
if (theSelector.IsNull())
{
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key();
RestoreSelectionStructures (theObj, theMode, aSelector);
}
return;
}
if (theMode != -1)
{
if (const Handle(SelectMgr_Selection)& aSelection = theObj->Selection (theMode))
{
theSelector->AddSelectionToObject (theObj, aSelection);
mySelector->AddSelectionToObject (theObj, aSelection);
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
}
}
@@ -606,31 +330,11 @@ void SelectMgr_SelectionManager::RestoreSelectionStructures (const Handle(Select
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObj->Selections()); aSelIter.More(); aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
theSelector->AddSelectionToObject (theObj, aSelection);
mySelector->AddSelectionToObject (theObj, aSelection);
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
}
}
theSelector->RebuildObjectsTree();
}
//=======================================================================
//function : rebuildSelectionStructures
//purpose : Internal function that marks 1st level BVH of object theObj
// as outdated
//=======================================================================
void SelectMgr_SelectionManager::rebuildSelectionStructures (const Handle(SelectMgr_ViewerSelector)& theSelector)
{
if (!theSelector.IsNull())
{
theSelector->RebuildObjectsTree();
return;
}
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key();
rebuildSelectionStructures (aSelector);
}
mySelector->RebuildObjectsTree();
}
//==================================================
@@ -643,16 +347,11 @@ void SelectMgr_SelectionManager::recomputeSelectionMode (const Handle(SelectMgr_
{
theSelection->UpdateStatus (SelectMgr_TOU_Full);
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
{
const Handle(SelectMgr_ViewerSelector)& aCurSelector = aSelectorIter.Key();
ClearSelectionStructures (theObject, theMode, aCurSelector);
theObject->RecomputePrimitives (theMode);
RestoreSelectionStructures (theObject, theMode, aCurSelector);
theSelection->UpdateStatus (SelectMgr_TOU_None);
theSelection->UpdateBVHStatus (SelectMgr_TBU_None);
}
ClearSelectionStructures (theObject, theMode);
theObject->RecomputePrimitives (theMode);
RestoreSelectionStructures (theObject, theMode);
theSelection->UpdateStatus (SelectMgr_TOU_None);
theSelection->UpdateBVHStatus (SelectMgr_TBU_None);
}
//==================================================
@@ -690,8 +389,7 @@ void SelectMgr_SelectionManager::RecomputeSelection (const Handle(SelectMgr_Sele
{
return;
}
if (!myGlobal.Contains (theObject)
&& !myLocal.IsBound (theObject))
if (!myGlobal.Contains (theObject))
{
return;
}
@@ -736,7 +434,7 @@ void SelectMgr_SelectionManager::Update (const Handle(SelectMgr_SelectableObject
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
if (theIsForce)
if (theIsForce || mySelector->Status (aSelection) == SelectMgr_SOS_Activated)
{
switch (aSelection->UpdateStatus())
{
@@ -751,7 +449,7 @@ void SelectMgr_SelectionManager::Update (const Handle(SelectMgr_SelectableObject
case SelectMgr_TOU_Partial:
{
theObject->UpdateTransformations (aSelection);
rebuildSelectionStructures();
mySelector->RebuildObjectsTree();
break;
}
default:
@@ -760,100 +458,6 @@ void SelectMgr_SelectionManager::Update (const Handle(SelectMgr_SelectableObject
aSelection->UpdateStatus (SelectMgr_TOU_None);
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
}
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
{
const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorIter.Key();
Update (theObject, aSelector, Standard_False);
}
}
}
//==================================================
// Function: Update
// Purpose : Attention, it is required to know what is done...
//==================================================
void SelectMgr_SelectionManager::Update (const Handle(SelectMgr_SelectableObject)& theObject,
const Handle(SelectMgr_ViewerSelector)& theSelector,
const Standard_Boolean theIsForce)
{
if (!mySelectors.Contains (theSelector))
{
return;
}
if (!myGlobal.Contains (theObject))
{
const SelectMgr_SequenceOfSelector* aSelectors = myLocal.Seek (theObject);
if (aSelectors == NULL
|| !containsSelector (*aSelectors, theSelector))
{
return;
}
}
for (PrsMgr_ListOfPresentableObjectsIter aChildIter (theObject->Children()); aChildIter.More(); aChildIter.Next())
{
Update (Handle(SelectMgr_SelectableObject)::DownCast (aChildIter.Value()), theSelector, theIsForce);
}
if (!theObject->HasOwnPresentations())
{
return;
}
for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
if (theIsForce)
{
switch (aSelection->UpdateStatus())
{
case SelectMgr_TOU_Full:
{
ClearSelectionStructures (theObject, aSelection->Mode());
theObject->RecomputePrimitives (aSelection->Mode());
RestoreSelectionStructures (theObject, aSelection->Mode());
// pass through SelectMgr_TOU_Partial
}
Standard_FALLTHROUGH
case SelectMgr_TOU_Partial:
{
theObject->UpdateTransformations (aSelection);
rebuildSelectionStructures();
break;
}
default:
break;
}
aSelection->UpdateStatus (SelectMgr_TOU_None);
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
}
if (theSelector->Status (aSelection) == SelectMgr_SOS_Activated)
{
switch (aSelection->UpdateStatus())
{
case SelectMgr_TOU_Full:
{
ClearSelectionStructures (theObject, aSelection->Mode(), theSelector);
theObject->RecomputePrimitives (aSelection->Mode());
RestoreSelectionStructures (theObject, aSelection->Mode(), theSelector);
// pass through SelectMgr_TOU_Partial
}
Standard_FALLTHROUGH
case SelectMgr_TOU_Partial:
{
theObject->UpdateTransformations (aSelection);
theSelector->RebuildObjectsTree();
break;
}
default:
break;
}
aSelection->UpdateStatus (SelectMgr_TOU_None);
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
}
}
}
@@ -862,8 +466,7 @@ void SelectMgr_SelectionManager::Update (const Handle(SelectMgr_SelectableObject
// Purpose : Private Method
//==================================================
void SelectMgr_SelectionManager::loadMode (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const Handle(SelectMgr_ViewerSelector)& theSelector)
const Standard_Integer theMode)
{
if (theMode == -1)
{
@@ -887,29 +490,10 @@ void SelectMgr_SelectionManager::loadMode (const Handle(SelectMgr_SelectableObje
Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode);
theObject->AddSelection (aNewSel, theMode);
if (!theSelector.IsNull())
{
theSelector->AddSelectionToObject (theObject, aNewSel);
aNewSel->UpdateBVHStatus (SelectMgr_TBU_None);
return;
}
if (myGlobal.Contains (theObject))
{
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
{
const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorIter.Key();
aSelector->AddSelectionToObject (theObject, aNewSel);
aNewSel->UpdateBVHStatus (SelectMgr_TBU_None);
}
}
else if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject))
{
for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (*aSelectors); aSelectorIter.More(); aSelectorIter.Next())
{
aSelectorIter.Value()->AddSelectionToObject (theObject, aNewSel);
aNewSel->UpdateBVHStatus (SelectMgr_TBU_None);
}
mySelector->AddSelectionToObject (theObject, aNewSel);
aNewSel->UpdateBVHStatus (SelectMgr_TBU_None);
}
}
@@ -964,29 +548,12 @@ void SelectMgr_SelectionManager::SetSelectionSensitivity (const Handle(SelectMgr
const Standard_Integer aPrevSens = aSel->Sensitivity();
aSel->SetSensitivity (theNewSens);
if (myGlobal.Contains (theObject))
if (myGlobal.Contains (theObject)
&& mySelector->Contains (theObject))
{
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key();
if (aSelector->Contains (theObject))
{
aSelector->myTolerances.Decrement (aPrevSens);
aSelector->myTolerances.Add (theNewSens);
aSelector->myToUpdateTolerance = Standard_True;
}
}
}
if (myLocal.IsBound (theObject))
{
const SelectMgr_SequenceOfSelector& aSelectors = myLocal (theObject);
for (SelectMgr_SequenceOfSelector::Iterator aLocalIter (aSelectors); aLocalIter.More(); aLocalIter.Next())
{
Handle(SelectMgr_ViewerSelector)& aCurSel = aLocalIter.ChangeValue();
aCurSel->myTolerances.Decrement (aPrevSens);
aCurSel->myTolerances.Add (theNewSens);
aCurSel->myToUpdateTolerance = Standard_True;
}
mySelector->myTolerances.Decrement (aPrevSens);
mySelector->myTolerances.Add (theNewSens);
mySelector->myToUpdateTolerance = Standard_True;
}
}
@@ -996,28 +563,9 @@ void SelectMgr_SelectionManager::SetSelectionSensitivity (const Handle(SelectMgr
//=======================================================================
void SelectMgr_SelectionManager::UpdateSelection (const Handle(SelectMgr_SelectableObject)& theObject)
{
if (myGlobal.Contains (theObject))
if (myGlobal.Contains (theObject)
&& mySelector->Contains (theObject))
{
for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
const Handle(SelectMgr_ViewerSelector)& aSelector = 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);
}
}
mySelector->MoveSelectableObject (theObject);
}
}

View File

@@ -17,10 +17,8 @@
#ifndef _SelectMgr_SelectionManager_HeaderFile
#define _SelectMgr_SelectionManager_HeaderFile
#include <SelectMgr_DataMapOfObjectSelectors.hxx>
#include <SelectMgr_ViewerSelector.hxx>
#include <SelectMgr_TypeOfUpdate.hxx>
#include <TColStd_MapOfTransient.hxx>
class SelectMgr_SelectableObject;
@@ -33,16 +31,10 @@ class SelectMgr_SelectionManager : public Standard_Transient
public:
//! Constructs an empty selection manager object.
Standard_EXPORT SelectMgr_SelectionManager();
//! Adds the viewer selector theSelector to the list of known items.
Standard_EXPORT void Add (const Handle(SelectMgr_ViewerSelector)& theSelector);
//! Removes viewer selector theSelector from the list of known items.
Standard_EXPORT void Remove (const Handle(SelectMgr_ViewerSelector)& theSelector);
//! Returns true if the manager contains the viewer selector theSelector in a list of known items.
Standard_EXPORT Standard_Boolean Contains (const Handle(SelectMgr_ViewerSelector)& theSelector) const;
Standard_EXPORT SelectMgr_SelectionManager (const Handle(SelectMgr_ViewerSelector)& theSelector);
//! Return the Selector.
const Handle(SelectMgr_ViewerSelector)& Selector() const { return mySelector; }
//! Returns true if the manager contains the selectable object theObject.
Standard_EXPORT Standard_Boolean Contains (const Handle(SelectMgr_SelectableObject)& theObject) const;
@@ -52,50 +44,38 @@ public:
//! the selection will be recalculated.
Standard_EXPORT void Load (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Integer theMode = -1);
//! Loads and computes selection mode theMode (if it is not equal to -1) and adds selectable object to BVH tree.
//! Does not perform check of existence of theObject in global context before addition, but adds theSelector to local context.
Standard_EXPORT void Load (const Handle(SelectMgr_SelectableObject)& theObject, const Handle(SelectMgr_ViewerSelector)& theSelector, const Standard_Integer theMode = -1);
//! Removes selectable object theObject from all viewer selectors it was added to previously, removes it from all contexts
//! and clears all computed selections of theObject.
Standard_EXPORT void Remove (const Handle(SelectMgr_SelectableObject)& theObject);
//! Removes theObject from theSelector, does not clear selections and unbind theObject from context maps.
Standard_EXPORT void Remove (const Handle(SelectMgr_SelectableObject)& theObject, const Handle(SelectMgr_ViewerSelector)& theSelector);
//! Activates the selection mode theMode in the selector theSelector for the selectable object anObject.
//! By default, theMode is equal to 0. If theSelector is set to default (NULL), the selection with the mode theMode
//! will be activated in all the viewers available.
Standard_EXPORT void Activate (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode = 0,
const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)());
const Standard_Integer theMode = 0);
//! Deactivates mode theMode of theObject in theSelector. If theMode value is set to default (-1), all
//! active selection modes will be deactivated. Likewise, if theSelector value is set to default (NULL), theMode
//! will be deactivated in all viewer selectors.
Standard_EXPORT void Deactivate (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode = -1,
const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)());
const Standard_Integer theMode = -1);
//! Returns true if the selection with theMode is active for the selectable object theObject and selector theSelector.
//! If all parameters are set to default values, it returns it there is any active selection in any known viewer selector for
//! object theObject.
Standard_EXPORT Standard_Boolean IsActivated (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode = -1,
const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)()) const;
const Standard_Integer theMode = -1) const;
//! Removes sensitive entities from all viewer selectors
//! after method Clear() was called to the selection they belonged to
//! or it was recomputed somehow.
Standard_EXPORT void ClearSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj,
const Standard_Integer theMode = -1,
const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)());
const Standard_Integer theMode = -1);
//! Re-adds newly calculated sensitive entities of recomputed selection
//! defined by mode theMode to all viewer selectors contained that selection.
Standard_EXPORT void RestoreSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj,
const Standard_Integer theMode = -1,
const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)());
const Standard_Integer theMode = -1);
//! Recomputes activated selections of theObject for all known viewer selectors according to theMode specified.
//! If theMode is set to default (-1), then all activated selections will be recomputed. If theIsForce is set to true,
@@ -105,11 +85,7 @@ public:
//! Updates all selections of theObject in all viewer selectors according to its current update status.
//! If theIsForce is set to true, the call is equal to recomputation.
Standard_EXPORT void Update (const Handle(SelectMgr_SelectableObject)& theObject, const Standard_Boolean theIsForce = Standard_True);
//! Updates all selections of theObject in specified viewer selector according to its current update status.
//! If theIsForce is set to true, the call is equal to recomputation.
Standard_EXPORT void Update (const Handle(SelectMgr_SelectableObject)& theObject, const Handle(SelectMgr_ViewerSelector)& theSelector, const Standard_Boolean theIsForce = Standard_True);
//! Sets type of update of all selections of theObject to the given theType.
Standard_EXPORT void SetUpdateMode (const Handle(SelectMgr_SelectableObject)& theObject, const SelectMgr_TypeOfUpdate theType);
@@ -139,18 +115,12 @@ private:
//! viewer selector theSelector. If theSelector is set to default value (NULL), the selection mode
//! created will be added to all known viewer selectors.
Standard_EXPORT void loadMode (const Handle(SelectMgr_SelectableObject)& theObject,
const Standard_Integer theMode,
const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)());
//! Internal function that marks 1st level BVH of the object theObj as
//! outdated.
Standard_EXPORT void rebuildSelectionStructures (const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)());
const Standard_Integer theMode);
private:
NCollection_Map<Handle(SelectMgr_ViewerSelector)> mySelectors;
Handle(SelectMgr_ViewerSelector) mySelector;
NCollection_Map<Handle(SelectMgr_SelectableObject)> myGlobal;
SelectMgr_DataMapOfObjectSelectors myLocal;
};

View File

@@ -1,26 +0,0 @@
// Created on: 1995-02-06
// Created by: Mister rmi
// Copyright (c) 1995-1999 Matra Datavision
// Copyright (c) 1999-2014 OPEN CASCADE SAS
//
// This file is part of Open CASCADE Technology software library.
//
// This library is free software; you can redistribute it and/or modify it under
// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
//
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef SelectMgr_SequenceOfSelector_HeaderFile
#define SelectMgr_SequenceOfSelector_HeaderFile
#include <SelectMgr_ViewerSelector.hxx>
#include <NCollection_Sequence.hxx>
typedef NCollection_Sequence<Handle(SelectMgr_ViewerSelector)> SelectMgr_SequenceOfSelector;
#endif