aTypOfSel, aPriority, aDeflection, aDeviationAngle);
Handle(SelectMgr_SelectableObject) aThis (this);
- for (theSelection->Init(); theSelection->More(); theSelection->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (theSelection->Sensitive()->BaseSensitive()->OwnerId());
+ Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelEntIter.Value()->BaseSensitive()->OwnerId());
anOwner->Set (aThis);
}
myReference->RecomputePrimitives (theMode);
}
- for (TheRefSel->Init(); TheRefSel->More(); TheRefSel->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (TheRefSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- aSensitive = Handle(Select3D_SensitiveEntity)::DownCast (TheRefSel->Sensitive()->BaseSensitive());
+ aSensitive = Handle(Select3D_SensitiveEntity)::DownCast (aSelEntIter.Value()->BaseSensitive());
if (!aSensitive.IsNull())
{
// Get the copy of SE3D
Shapes2EntitiesMap;
if (!myReference->HasSelection (theMode))
+ {
myReference->RecomputePrimitives (theMode);
-
- const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection (theMode);
+ }
+ const Handle(SelectMgr_Selection)& aRefSel = myReference->Selection (theMode);
if (aRefSel->IsEmpty() || aRefSel->UpdateStatus() == SelectMgr_TOU_Full)
{
myReference->RecomputePrimitives (theMode);
}
-
- Handle(StdSelect_BRepOwner) anOwner;
- TopLoc_Location aDummyLoc;
- Handle(Select3D_SensitiveEntity) aSE, aNewSE;
+ // Fill in the map of subshapes and corresponding sensitive entities associated with aMode
Shapes2EntitiesMap aShapes2EntitiesMap;
-
- SensitiveList aSEList;
- TopoDS_Shape aSubShape;
-
- // Fill in the map of subshapes and corresponding
- // sensitive entities associated with aMode
- for (aRefSel->Init(); aRefSel->More(); aRefSel->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aRefSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- aSE = Handle(Select3D_SensitiveEntity)::DownCast (aRefSel->Sensitive()->BaseSensitive());
- if(!aSE.IsNull())
+ if (Handle(Select3D_SensitiveEntity) aSE = Handle(Select3D_SensitiveEntity)::DownCast (aSelEntIter.Value()->BaseSensitive()))
{
- anOwner = Handle(StdSelect_BRepOwner)::DownCast (aSE->OwnerId());
- if(!anOwner.IsNull())
+ if (Handle(StdSelect_BRepOwner) anOwner = Handle(StdSelect_BRepOwner)::DownCast (aSE->OwnerId()))
{
- aSubShape = anOwner->Shape();
+ const TopoDS_Shape& aSubShape = anOwner->Shape();
if(!aShapes2EntitiesMap.IsBound (aSubShape))
{
- aShapes2EntitiesMap.Bind (aSubShape, aSEList);
+ aShapes2EntitiesMap.Bind (aSubShape, SensitiveList());
}
aShapes2EntitiesMap (aSubShape).Append (aSE);
}
// Fill in selection from aShapes2EntitiesMap
for (Shapes2EntitiesMap::Iterator aMapIt (aShapes2EntitiesMap); aMapIt.More(); aMapIt.Next())
{
- aSEList = aMapIt.Value();
- anOwner = new StdSelect_BRepOwner (aMapIt.Key(),
- this,
- aSEList.First()->OwnerId()->Priority(),
- Standard_True);
+ const SensitiveList& aSEList = aMapIt.Value();
+ Handle(StdSelect_BRepOwner) anOwner = new StdSelect_BRepOwner (aMapIt.Key(), this, aSEList.First()->OwnerId()->Priority(), Standard_True);
anOwner->SetLocation (Transformation());
-
for (SensitiveList::Iterator aListIt (aSEList); aListIt.More(); aListIt.Next())
{
- aSE = aListIt.Value();
-
- aNewSE = aSE->GetConnected();
+ Handle(Select3D_SensitiveEntity) aSE = aListIt.Value();
+ Handle(Select3D_SensitiveEntity) aNewSE = aSE->GetConnected();
aNewSE->Set (anOwner);
-
theSelection->Add (aNewSE);
}
}
Handle(AIS_InteractiveContext) aNullContext;
for (AIS_DataMapIteratorOfDataMapOfIOStatus anObjIter (myObjects); anObjIter.More(); anObjIter.Next())
{
- Handle(AIS_InteractiveObject) anObj = anObjIter.Key();
+ const Handle(AIS_InteractiveObject)& anObj = anObjIter.Key();
anObj->SetContext (aNullContext);
- for (anObj->Init(); anObj->More(); anObj->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
{
- anObj->CurrentSelection()->UpdateBVHStatus (SelectMgr_TBU_Renew);
+ aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Renew);
}
}
}
return;
}
- Standard_Boolean isFound = Standard_False;
- for (mySelection->Init(); mySelection->More(); mySelection->Next())
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()->Selectable());
+ Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable());
Display (anObj, Standard_False);
- isFound = Standard_True;
}
- if (isFound && theToUpdateViewer)
+ if (theToUpdateViewer && !mySelection->Objects().IsEmpty())
{
myMainVwr->Update();
}
return;
}
- Standard_Boolean isFound = Standard_False;
- mySelection->Init();
- while (mySelection->More())
+ Standard_Boolean isFound = Standard_False;
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Init (mySelection->Objects()))
{
- Handle(SelectMgr_EntityOwner) anOwner = mySelection->Value();
- Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable());
-
+ Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (aSelIter.Value()->Selectable());
Erase (anObj, Standard_False);
isFound = Standard_True;
-
- mySelection->Init();
}
if (isFound && theToUpdateViewer)
const Standard_Real theMargin,
const Standard_Boolean theToUpdate)
{
- const Handle(AIS_Selection)& aSelection = HasOpenedContext() ?
- myLocalContexts(myCurLocalIndex)->Selection() : mySelection;
-
+ const Handle(AIS_Selection)& aSelection = HasOpenedContext()
+ ? myLocalContexts(myCurLocalIndex)->Selection()
+ : mySelection;
Bnd_Box aBndSelected;
-
AIS_MapOfObjectOwners anObjectOwnerMap;
- for (aSelection->Init(); aSelection->More(); aSelection->Next())
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (aSelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_EntityOwner)& anOwner = aSelection->Value();
+ const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value();
Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable());
if (anObj->IsInfinite())
{
{
Display (theObject, Standard_False);
}
- if (!theObject->HasSelection (theObject->GlobalSelectionMode()))
- {
- return;
- }
+
Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
if (anOwner.IsNull())
{
return;
}
- for (mySelection->Init(); mySelection->More(); mySelection->Next())
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_EntityOwner) aSelOwner = mySelection->Value();
+ const Handle(SelectMgr_EntityOwner)& aSelOwner = aSelIter.Value();
if (!myFilters->IsOk (aSelOwner))
{
continue;
const Standard_Boolean theToUpdateViewer)
{
if (theObject.IsNull())
+ {
return;
+ }
if (HasOpenedContext())
+ {
return myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (theObject, theToUpdateViewer);
+ }
- const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode();
- if (!myObjects.IsBound (theObject) || !theObject->HasSelection (aGlobalSelMode))
+ if (!myObjects.IsBound (theObject))
+ {
return;
+ }
- setContextToObject (theObject);
const Handle(SelectMgr_EntityOwner) anOwner = theObject->GlobalSelOwner();
-
- if (anOwner.IsNull() || !anOwner->HasSelectable())
- return;
-
- AddOrRemoveSelected (anOwner, theToUpdateViewer);
+ if (!anOwner.IsNull()
+ && anOwner->HasSelectable())
+ {
+ AddOrRemoveSelected (anOwner, theToUpdateViewer);
+ }
}
//=======================================================================
//function : AddOrRemoveSelected
AIS_SelectStatus aSelStat = mySelection->Select (theOwner);
theOwner->SetSelected (aSelStat == AIS_SS_Added);
- const Handle(AIS_InteractiveObject) anObj =
- Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
+ const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
const Standard_Boolean isGlobal = anObj->GlobalSelOwner() == theOwner;
Handle(AIS_GlobalStatus)& aStatus = myObjects.ChangeFind (anObj);
if (theOwner->IsSelected())
const Standard_Integer aGlobalSelMode = theObj->GlobalSelectionMode();
const TColStd_ListOfInteger& anActivatedModes = myObjects (theObj)->SelectionModes();
- Standard_Boolean isGlobalModeActivated = Standard_False;
for (TColStd_ListIteratorOfListOfInteger aModeIter (anActivatedModes); aModeIter.More(); aModeIter.Next())
{
if (aModeIter.Value() == aGlobalSelMode)
{
- isGlobalModeActivated = Standard_True;
- break;
+ if (Handle(SelectMgr_EntityOwner) aGlobOwner = theObj->GlobalSelOwner())
+ {
+ return aGlobOwner->IsSelected();
+ }
+ return Standard_False;
}
}
- if (!theObj->HasSelection (aGlobalSelMode) || !isGlobalModeActivated || theObj->GlobalSelOwner().IsNull())
- return Standard_False;
-
- return theObj->GlobalSelOwner()->IsSelected();
+ return Standard_False;
}
//=======================================================================
Standard_Boolean AIS_InteractiveContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const
{
if (HasOpenedContext())
+ {
return myLocalContexts(myCurLocalIndex)->IsSelected (theOwner);
-
- if (theOwner.IsNull())
- return Standard_False;
-
- return theOwner->IsSelected();
+ }
+ return !theOwner.IsNull()
+ && theOwner->IsSelected();
}
//=======================================================================
const Handle(AIS_InteractiveObject)& theIObj,
const Standard_Integer theMode) const
{
- if ( theIObj.IsNull() )
- return;
+ if (theIObj.IsNull())
+ {
+ return;
+ }
TColStd_ListOfInteger aModes;
- if ( theMode == -1 )
- ActivatedModes( theIObj, aModes );
+ if (theMode == -1)
+ {
+ ActivatedModes (theIObj, aModes);
+ }
else
- aModes.Append( theMode );
+ {
+ aModes.Append (theMode);
+ }
if (theOwners.IsNull())
+ {
theOwners = new SelectMgr_IndexedMapOfOwner();
+ }
- TColStd_ListIteratorOfListOfInteger anItr( aModes );
- for (; anItr.More(); anItr.Next() )
+ for (TColStd_ListIteratorOfListOfInteger anItr (aModes); anItr.More(); anItr.Next())
{
- int aMode = anItr.Value();
- if ( !theIObj->HasSelection( aMode ) )
+ const int aMode = anItr.Value();
+ const Handle(SelectMgr_Selection)& aSel = theIObj->Selection (aMode);
+ if (aSel.IsNull())
+ {
continue;
+ }
- Handle(SelectMgr_Selection) aSel = theIObj->Selection(aMode);
-
- for ( aSel->Init(); aSel->More(); aSel->Next() )
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- Handle(SelectBasics_SensitiveEntity) aEntity = aSel->Sensitive()->BaseSensitive();
- if ( aEntity.IsNull() )
- continue;
-
- Handle(SelectMgr_EntityOwner) aOwner =
- Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId());
- if ( !aOwner.IsNull() )
- theOwners->Add( aOwner );
+ if (Handle(SelectBasics_SensitiveEntity) aEntity = aSelEntIter.Value()->BaseSensitive())
+ {
+ if (Handle(SelectMgr_EntityOwner) aOwner = Handle(SelectMgr_EntityOwner)::DownCast(aEntity->OwnerId()))
+ {
+ theOwners->Add (aOwner);
+ }
+ }
}
}
}
{
if (myActiveObjects.IsBound (anInteractive))
{
- if (anInteractive->HasSelection (ActivationMode))
+ if (const Handle(SelectMgr_Selection)& aSel = anInteractive->Selection (ActivationMode))
{
- const Handle(SelectMgr_Selection)& aSel = anInteractive->Selection (ActivationMode);
if (aSel->GetSelectionState() != SelectMgr_SOS_Activated)
{
if (!myMainVS->Contains (anInteractive))
void AIS_LocalContext::LoadContextObjects()
{
- AIS_ListIteratorOfListOfInteractive It;
- if(myLoadDisplayed) {
- AIS_ListOfInteractive LL;
- myCTX->DisplayedObjects(LL,Standard_True);
- Handle(AIS_LocalStatus) Att;
- for (It.Initialize(LL);It.More();It.Next()){
- const Handle(AIS_InteractiveObject)& anObj = It.Value();
- Att= new AIS_LocalStatus();
- Att->SetDecomposition((anObj->AcceptShapeDecomposition() && myAcceptStdMode));
- Att->SetTemporary(Standard_False);
- Att->SetHilightMode(anObj->HasHilightMode()? anObj->HilightMode(): 0);
- for (anObj->Init(); anObj->More(); anObj->Next())
- {
- const Handle(SelectMgr_Selection)& aSel = anObj->CurrentSelection();
- aSel->SetSelectionState (SelectMgr_SOS_Deactivated);
- }
- myActiveObjects.Bind(anObj,Att);
+ if (!myLoadDisplayed)
+ {
+ return;
+ }
+
+ AIS_ListOfInteractive LL;
+ myCTX->DisplayedObjects(LL,Standard_True);
+ for (AIS_ListIteratorOfListOfInteractive It (LL); It.More(); It.Next())
+ {
+ const Handle(AIS_InteractiveObject)& anObj = It.Value();
+ Handle(AIS_LocalStatus) Att = new AIS_LocalStatus();
+ Att->SetDecomposition((anObj->AcceptShapeDecomposition() && myAcceptStdMode));
+ Att->SetTemporary(Standard_False);
+ Att->SetHilightMode(anObj->HasHilightMode()? anObj->HilightMode(): 0);
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
+ {
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ aSel->SetSelectionState (SelectMgr_SOS_Deactivated);
}
+ myActiveObjects.Bind(anObj,Att);
}
}
{
// 1. Collect selectable entities
SelectMgr_IndexedMapOfOwner aValidOwners;
-
const TColStd_ListOfInteger& aModes = SelectionModes (theIO);
-
- TColStd_ListIteratorOfListOfInteger aModeIter (aModes);
- for (; aModeIter.More(); aModeIter.Next())
+ for (TColStd_ListIteratorOfListOfInteger aModeIter (aModes); aModeIter.More(); aModeIter.Next())
{
- int aMode = aModeIter.Value();
+ const int aMode = aModeIter.Value();
if (!theIO->HasSelection(aMode))
{
continue;
continue;
}
- Handle(SelectMgr_Selection) aSelection = theIO->Selection(aMode);
- for (aSelection->Init(); aSelection->More(); aSelection->Next())
+ const Handle(SelectMgr_Selection)& aSelection = theIO->Selection (aMode);
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive();
- if (anEntity.IsNull())
+ if (Handle(SelectBasics_SensitiveEntity) anEntity = aSelEntIter.Value()->BaseSensitive())
{
- continue;
- }
-
- Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
-
- if (anOwner.IsNull())
- {
- continue;
+ if (Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId()))
+ {
+ aValidOwners.Add (anOwner);
+ }
}
-
- aValidOwners.Add(anOwner);
}
}
//=======================================================================
//function : AIS_MultipleConnectedInteractive
-//purpose :
+//purpose :
//=======================================================================
AIS_MultipleConnectedInteractive::AIS_MultipleConnectedInteractive()
- : AIS_InteractiveObject (PrsMgr_TOP_AllView)
+: AIS_InteractiveObject (PrsMgr_TOP_AllView)
{
myHasOwnPresentations = Standard_False;
- myAssemblyOwner = NULL;
}
//=======================================================================
void AIS_MultipleConnectedInteractive::ComputeSelection (const Handle(SelectMgr_Selection)& /*theSelection*/,
const Standard_Integer theMode)
{
- if (theMode != 0)
+ if (theMode == 0)
{
- for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
- {
- Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
- if (aChild.IsNull())
- {
- continue;
- }
-
- if (!aChild->HasSelection (theMode))
- {
- aChild->RecomputePrimitives (theMode);
- }
-
- Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection (theMode);
- aChild->ComputeSelection (aSelection, theMode);
- }
+ return;
}
-}
-
-//=======================================================================
-//function : GlobalSelOwner
-//purpose :
-//=======================================================================
-Handle(SelectMgr_EntityOwner) AIS_MultipleConnectedInteractive::GlobalSelOwner() const
-{
- return myAssemblyOwner;
-}
-//=======================================================================
-//function : HasSelection
-//purpose :
-//=======================================================================
-Standard_Boolean AIS_MultipleConnectedInteractive::HasSelection (const Standard_Integer theMode) const
-{
for (PrsMgr_ListOfPresentableObjectsIter anIter (Children()); anIter.More(); anIter.Next())
{
Handle(AIS_InteractiveObject) aChild = Handle(AIS_InteractiveObject)::DownCast (anIter.Value());
if (aChild.IsNull())
+ {
continue;
+ }
if (!aChild->HasSelection (theMode))
- return Standard_False;
- }
+ {
+ aChild->RecomputePrimitives (theMode);
+ }
- return Standard_True;
+ Handle(SelectMgr_Selection) aSelection = new SelectMgr_Selection (theMode);
+ aChild->ComputeSelection (aSelection, theMode);
+ }
}
//=======================================================================
//! may be decomposed into sub-shapes for dynamic selection.
Standard_EXPORT virtual Standard_Boolean AcceptShapeDecomposition() const Standard_OVERRIDE;
- //! Returns the owner of mode for selection of object as a whole
- Standard_EXPORT virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE;
+ //! Returns common entity owner if the object is an assembly
+ virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const Standard_OVERRIDE { return myAssemblyOwner; }
- //! Returns true if a selection corresponding to the selection mode theMode was computed for all
- //! children of multiple connected interactive object.
- Standard_EXPORT virtual Standard_Boolean HasSelection (const Standard_Integer theMode) const Standard_OVERRIDE;
+ //! Returns the owner of mode for selection of object as a whole
+ virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const Standard_OVERRIDE { return myAssemblyOwner; }
//! Assigns interactive context.
Standard_EXPORT virtual void SetContext (const Handle(AIS_InteractiveContext)& theCtx) Standard_OVERRIDE;
//! Computes the selection for whole subtree in scene hierarchy.
Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
+protected:
+
+ Handle(SelectMgr_EntityOwner) myAssemblyOwner;
+
};
DEFINE_STANDARD_HANDLE(AIS_MultipleConnectedInteractive, AIS_InteractiveObject)
{
myresult.Clear();
myResultMap.Clear();
+ myIterator = AIS_NListOfEntityOwner::Iterator();
}
//=======================================================================
//============================================================================
void IVtkOCC_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theSelection)
{
- for (theSelection->Init(); theSelection->More(); theSelection->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- theSelection->Sensitive()->SetActiveForSelection();
+ aSelEntIter.Value()->SetActiveForSelection();
}
theSelection->SetSelectionState (SelectMgr_SOS_Activated);
//============================================================================
void IVtkOCC_ViewerSelector::Deactivate (const Handle(SelectMgr_Selection)& theSelection)
{
- for (theSelection->Init(); theSelection->More(); theSelection->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- theSelection->Sensitive()->ResetSelectionActiveStatus();
+ aSelEntIter.Value()->ResetSelectionActiveStatus();
}
theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
#include <Graphic3d_TransformPers.hxx>
#include <Graphic3d_TransModeFlags.hxx>
#include <Graphic3d_ZLayerId.hxx>
+#include <Prs3d_Drawer.hxx>
#include <PrsMgr_ListOfPresentableObjects.hxx>
#include <PrsMgr_Presentation.hxx>
#include <PrsMgr_Presentations.hxx>
if(AISObj->HasSelection(4)) {
//Handle(SelectMgr_Selection)& aSelection = AISObj->Selection(4);
const Handle(SelectMgr_Selection)& aSelection = AISObj->Selection(4);
- if(!aSelection.IsNull()) {
- for(aSelection->Init();aSelection->More();aSelection->Next()) {
- Handle(StdSelect_BRepOwner) aO = Handle(StdSelect_BRepOwner)::DownCast(aSelection->Sensitive()->BaseSensitive()->OwnerId());
+ if(!aSelection.IsNull())
+ {
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
+ {
+ Handle(StdSelect_BRepOwner) aO = Handle(StdSelect_BRepOwner)::DownCast(aSelEntIter.Value()->BaseSensitive()->OwnerId());
aO->SetHilightMode(Draw::Atoi(argv[1]));
}
}
SelectMgr_SelectingVolumeManager.hxx
SelectMgr_Selection.cxx
SelectMgr_Selection.hxx
-SelectMgr_Selection.lxx
SelectMgr_SelectionManager.cxx
SelectMgr_SelectionManager.hxx
SelectMgr_SensitiveEntity.cxx
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectableObject,PrsMgr_PresentableObject)
-static Standard_Integer Search (const SelectMgr_SequenceOfSelection& seq,
- const Handle (SelectMgr_Selection)& theSel)
+namespace
{
- Standard_Integer ifound=0;
- for (Standard_Integer i=1;i<=seq.Length()&& ifound==0;i++)
- {if(theSel == seq.Value(i)) ifound=i;}
- return ifound;
-}
+ Handle(SelectMgr_Selection) THE_NULL_SELECTION;
+ Handle(SelectMgr_EntityOwner) THE_NULL_ENTITYOWNER;
+}
//==================================================
// Function: SelectMgr_SelectableObject
SelectMgr_SelectableObject::SelectMgr_SelectableObject (const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d)
: PrsMgr_PresentableObject (aTypeOfPresentation3d),
- myAssemblyOwner (NULL),
myAutoHilight (Standard_True),
+ mycurrent (0),
myGlobalSelMode (0)
{
//
//==================================================
SelectMgr_SelectableObject::~SelectMgr_SelectableObject()
{
- for (Standard_Integer aSelIdx = 1; aSelIdx <= myselections.Length(); ++aSelIdx)
- {
- myselections.Value (aSelIdx)->Clear();
- }
-}
-
-//==================================================
-// Function: HasSelection
-// Purpose :
-//==================================================
-Standard_Boolean SelectMgr_SelectableObject::HasSelection (const Standard_Integer theMode) const
-{
- for (Standard_Integer aSelIdx = 1; aSelIdx <= myselections.Length(); ++aSelIdx)
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
{
- if (((myselections.Value (aSelIdx))->Mode()) == theMode)
- return Standard_True;
+ aSelIter.Value()->Clear();
}
- return Standard_False;
}
//==================================================
//==================================================
void SelectMgr_SelectableObject::RecomputePrimitives()
{
- for (Standard_Integer aSelIdx = 1; aSelIdx <= myselections.Length(); aSelIdx++)
- {
- RecomputePrimitives (myselections.ChangeValue (aSelIdx)->Mode());
- }
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
+ {
+ RecomputePrimitives (aSelIter.Value()->Mode());
+ }
}
//==================================================
//==================================================
void SelectMgr_SelectableObject::RecomputePrimitives (const Standard_Integer theMode)
{
- Handle(PrsMgr_PresentableObject) aPrsParent (Parent());
- Handle(SelectMgr_SelectableObject) aSelParent = Handle(SelectMgr_SelectableObject)::DownCast (aPrsParent);
-
- for (Standard_Integer aSelIdx =1; aSelIdx <= myselections.Length(); aSelIdx++ )
+ SelectMgr_SelectableObject* aSelParent = dynamic_cast<SelectMgr_SelectableObject* > (Parent());
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
{
- if (myselections.Value (aSelIdx)->Mode() == theMode)
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ if (aSel->Mode() == theMode)
{
- myselections (aSelIdx)->Clear();
- ComputeSelection (myselections (aSelIdx), theMode);
- myselections (aSelIdx)->UpdateStatus (SelectMgr_TOU_Partial);
- myselections (aSelIdx)->UpdateBVHStatus (SelectMgr_TBU_Renew);
- if (theMode == 0 && ! aSelParent.IsNull() && ! aSelParent->GetAssemblyOwner().IsNull())
+ aSel->Clear();
+ ComputeSelection (aSel, theMode);
+ aSel->UpdateStatus (SelectMgr_TOU_Partial);
+ aSel->UpdateBVHStatus (SelectMgr_TBU_Renew);
+ if (theMode == 0 && aSelParent != NULL)
{
- SetAssemblyOwner (aSelParent->GetAssemblyOwner(), theMode);
+ if (const Handle(SelectMgr_EntityOwner)& anAsmOwner = aSelParent->GetAssemblyOwner())
+ {
+ SetAssemblyOwner (anAsmOwner, theMode);
+ }
}
return;
}
Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode);
ComputeSelection (aNewSel, theMode);
- if (theMode == 0 && ! aSelParent.IsNull() && ! aSelParent->GetAssemblyOwner().IsNull())
+ if (theMode == 0 && aSelParent != NULL)
{
- SetAssemblyOwner (aSelParent->GetAssemblyOwner(), theMode);
+ if (const Handle(SelectMgr_EntityOwner)& anAsmOwner = aSelParent->GetAssemblyOwner())
+ {
+ SetAssemblyOwner (anAsmOwner, theMode);
+ }
}
aNewSel->UpdateStatus (SelectMgr_TOU_Partial);
// Function: ClearSelections
// Purpose :
//==================================================
-void SelectMgr_SelectableObject::ClearSelections(const Standard_Boolean update)
+void SelectMgr_SelectableObject::ClearSelections (const Standard_Boolean theToUpdate)
{
- for (Standard_Integer i =1; i<= myselections.Length(); i++ ) {
- myselections.Value(i)->Clear();
- myselections.Value (i)->UpdateBVHStatus (SelectMgr_TBU_Remove);
- if(update)
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
+ {
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ aSel->Clear();
+ aSel->UpdateBVHStatus (SelectMgr_TBU_Remove);
+ if (theToUpdate)
{
- myselections.Value(i)->UpdateStatus(SelectMgr_TOU_Full);
+ aSel->UpdateStatus (SelectMgr_TOU_Full);
}
}
}
// Purpose :
//==================================================
-const Handle(SelectMgr_Selection)& SelectMgr_SelectableObject
-::Selection(const Standard_Integer aMode) const
+const Handle(SelectMgr_Selection)& SelectMgr_SelectableObject::Selection (const Standard_Integer theMode) const
{
- Standard_Boolean Found = Standard_False;
- Standard_Integer Rank=0;
- for (Standard_Integer i=1;i<=myselections.Length() && !Found;i++)
+ if (theMode == -1)
+ {
+ return THE_NULL_SELECTION;
+ }
+
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
+ {
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ if (aSel->Mode() == theMode)
{
- if((myselections.Value(i))->Mode()==aMode){ Found = Standard_True;
- Rank=i;}}
- return myselections.Value(Rank);
+ return aSel;
+ }
+ }
+ return THE_NULL_SELECTION;
}
-
//==================================================
// Function: AddSelection
// Purpose :
//==================================================
-void SelectMgr_SelectableObject
-::AddSelection(const Handle(SelectMgr_Selection)& aSel,
- const Standard_Integer aMode)
+void SelectMgr_SelectableObject::AddSelection (const Handle(SelectMgr_Selection)& theSel,
+ const Standard_Integer theMode)
{
- Standard_Boolean isReplaced = Standard_False;
- if(aSel->IsEmpty())
+ if(theSel->IsEmpty())
{
- ComputeSelection(aSel, aMode);
- aSel->UpdateStatus(SelectMgr_TOU_Partial);
- aSel->UpdateBVHStatus (SelectMgr_TBU_Add);
+ ComputeSelection(theSel, theMode);
+ theSel->UpdateStatus(SelectMgr_TOU_Partial);
+ theSel->UpdateBVHStatus (SelectMgr_TBU_Add);
}
- if (HasSelection(aMode))
+
+ Standard_Boolean isReplaced = Standard_False;
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_Selection)& temp= Selection(aMode);
- Standard_Integer I = Search(myselections,temp);
- if(I!=0)
+ if (aSelIter.Value()->Mode() == theMode)
{
- myselections.Remove(I);
isReplaced = Standard_True;
+ myselections.Remove (aSelIter);
+ break;
}
}
- myselections.Append(aSel);
+ myselections.Append (theSel);
if (isReplaced)
{
myselections.Last()->UpdateBVHStatus (SelectMgr_TBU_Renew);
}
- if (aMode == 0)
+ if (theMode == 0)
{
- Handle(PrsMgr_PresentableObject) aPrsParent (Parent());
- Handle(SelectMgr_SelectableObject) aSelParent = Handle(SelectMgr_SelectableObject)::DownCast (aPrsParent);
- if (! aSelParent.IsNull() && ! aSelParent->GetAssemblyOwner().IsNull())
+ SelectMgr_SelectableObject* aSelParent = dynamic_cast<SelectMgr_SelectableObject* > (Parent());
+ if (aSelParent != NULL)
{
- SetAssemblyOwner (aSelParent->GetAssemblyOwner(), aMode);
+ if (const Handle(SelectMgr_EntityOwner)& anAsmOwner = aSelParent->GetAssemblyOwner())
+ {
+ SetAssemblyOwner (anAsmOwner, theMode);
+ }
}
}
}
-
-
//=======================================================================
//function : ReSetTransformation
-//purpose :
+//purpose :
//=======================================================================
void SelectMgr_SelectableObject::ResetTransformation()
{
- for (Init(); More(); Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_Selection) & aSel = CurrentSelection();
- for (aSel->Init(); aSel->More(); aSel->Next())
- {
- aSel->UpdateStatus(SelectMgr_TOU_Partial);
- aSel->UpdateBVHStatus (SelectMgr_TBU_None);
- }
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ aSel->UpdateStatus (SelectMgr_TOU_Partial);
+ aSel->UpdateBVHStatus (SelectMgr_TBU_None);
}
PrsMgr_PresentableObject::ResetTransformation();
//=======================================================================
//function : UpdateTransformation
-//purpose :
+//purpose :
//=======================================================================
void SelectMgr_SelectableObject::UpdateTransformation()
{
- for (Init(); More(); Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
{
- CurrentSelection()->UpdateStatus (SelectMgr_TOU_Partial);
+ aSelIter.Value()->UpdateStatus (SelectMgr_TOU_Partial);
}
PrsMgr_PresentableObject::UpdateTransformation();
//=======================================================================
//function : UpdateTransformation
-//purpose :
+//purpose :
//=======================================================================
-void SelectMgr_SelectableObject::UpdateTransformations(const Handle(SelectMgr_Selection)& Sel)
+void SelectMgr_SelectableObject::UpdateTransformations (const Handle(SelectMgr_Selection)& theSel)
{
- TopLoc_Location aSelfLocation (Transformation());
- Handle(Select3D_SensitiveEntity) SE;
- if(aSelfLocation.IsIdentity()) return;
- for(Sel->Init();Sel->More();Sel->Next()){
- SE = Handle(Select3D_SensitiveEntity)::DownCast (Sel->Sensitive()->BaseSensitive());
- if(!SE.IsNull()){
- const Handle(SelectBasics_EntityOwner)& aEOwner = SE->OwnerId();
- Handle(SelectMgr_EntityOwner) aMgrEO =
- Handle(SelectMgr_EntityOwner)::DownCast (aEOwner);
- if (!aMgrEO.IsNull())
+ const TopLoc_Location aSelfLocation (Transformation());
+ if (aSelfLocation.IsIdentity())
+ {
+ return;
+ }
+
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
+ {
+ if (Handle(Select3D_SensitiveEntity) aSensEntity = Handle(Select3D_SensitiveEntity)::DownCast (aSelEntIter.Value()->BaseSensitive()))
+ {
+ const Handle(SelectBasics_EntityOwner)& aEOwner = aSensEntity->OwnerId();
+ if (Handle(SelectMgr_EntityOwner) aMgrEO = Handle(SelectMgr_EntityOwner)::DownCast (aEOwner))
+ {
aMgrEO->SetLocation (aSelfLocation);
+ }
}
}
}
//=======================================================================
//function : HilightSelected
-//purpose :
+//purpose :
//=======================================================================
-void SelectMgr_SelectableObject::HilightSelected
- ( const Handle(PrsMgr_PresentationManager3d)&,
- const SelectMgr_SequenceOfOwner&)
+void SelectMgr_SelectableObject::HilightSelected (const Handle(PrsMgr_PresentationManager3d)&,
+ const SelectMgr_SequenceOfOwner&)
{
throw Standard_NotImplemented("SelectMgr_SelectableObject::HilightSelected");
}
//=======================================================================
//function : ClearSelected
-//purpose :
+//purpose :
//=======================================================================
-void SelectMgr_SelectableObject::ClearSelected ()
+void SelectMgr_SelectableObject::ClearSelected()
{
- if( !mySelectionPrs.IsNull() )
+ if(!mySelectionPrs.IsNull())
+ {
mySelectionPrs->Clear();
+ }
}
//=======================================================================
//=======================================================================
//function : HilightOwnerWithColor
-//purpose :
+//purpose :
//=======================================================================
void SelectMgr_SelectableObject::HilightOwnerWithColor (const Handle(PrsMgr_PresentationManager3d)&,
const Handle(Prs3d_Drawer)&,
}
//=======================================================================
-//function : MaxFaceNodes
-//purpose :
+//function : IsAutoHilight
+//purpose :
//=======================================================================
-Standard_Boolean SelectMgr_SelectableObject::IsAutoHilight () const
+Standard_Boolean SelectMgr_SelectableObject::IsAutoHilight() const
{
return myAutoHilight;
}
//=======================================================================
-//function : MaxFaceNodes
-//purpose :
+//function : SetAutoHilight
+//purpose :
//=======================================================================
void SelectMgr_SelectableObject::SetAutoHilight ( const Standard_Boolean newAutoHilight )
{
//=======================================================================
//function : GetHilightPresentation
-//purpose :
+//purpose :
//=======================================================================
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetHilightPresentation (const Handle(PrsMgr_PresentationManager3d)& theMgr)
{
//=======================================================================
//function : GetSelectPresentation
-//purpose :
+//purpose :
//=======================================================================
Handle(Prs3d_Presentation) SelectMgr_SelectableObject::GetSelectPresentation (const Handle(PrsMgr_PresentationManager3d)& theMgr)
{
myHilightPrs->SetZLayer (theLayerId);
// update all entity owner presentations
- for (Init (); More () ;Next ())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_Selection)& aSel = CurrentSelection();
- for (aSel->Init (); aSel->More (); aSel->Next ())
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- Handle(Select3D_SensitiveEntity) aEntity =
- Handle(Select3D_SensitiveEntity)::DownCast (aSel->Sensitive()->BaseSensitive());
- if (!aEntity.IsNull())
+ if (Handle(Select3D_SensitiveEntity) aEntity = Handle(Select3D_SensitiveEntity)::DownCast (aSelEntIter.Value()->BaseSensitive()))
{
- Handle(SelectMgr_EntityOwner) aOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aEntity->OwnerId());
- if (!aOwner.IsNull())
+ if (Handle(SelectMgr_EntityOwner) aOwner = Handle(SelectMgr_EntityOwner)::DownCast (aEntity->OwnerId()))
+ {
aOwner->SetZLayer (theLayerId);
+ }
}
}
}
{
if (theMode == -1)
{
- for (Init(); More(); Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_Selection)& aSel = CurrentSelection();
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
aSel->UpdateStatus (SelectMgr_TOU_Full);
}
-
return;
}
- for (Init(); More(); Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
{
- if (CurrentSelection()->Mode() == theMode)
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ if (aSel->Mode() == theMode)
{
- CurrentSelection()->UpdateStatus (SelectMgr_TOU_Full);
+ aSel->UpdateStatus (SelectMgr_TOU_Full);
return;
}
}
{
if (theMode == -1)
{
- for (Standard_Integer aModeIter = 1; aModeIter <= myselections.Length(); ++aModeIter)
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
{
- Handle(SelectMgr_Selection)& aSel = myselections.ChangeValue (aModeIter);
- for (aSel->Init(); aSel->More(); aSel->Next())
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- aSel->Sensitive()->BaseSensitive()->Set (theOwner);
+ aSelEntIter.Value()->BaseSensitive()->Set (theOwner);
}
}
-
return;
}
- if (!HasSelection (theMode))
- return;
-
- for (Standard_Integer aModeIter = 1; aModeIter <= myselections.Length(); ++aModeIter)
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
{
- if (myselections.Value (aModeIter)->Mode() == theMode)
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ if (aSel->Mode() == theMode)
{
- Handle(SelectMgr_Selection)& aSel = myselections.ChangeValue (aModeIter);
- for (aSel->Init(); aSel->More(); aSel->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- aSel->Sensitive()->BaseSensitive()->Set (theOwner);
+ aSelEntIter.Value()->BaseSensitive()->Set (theOwner);
}
return;
}
}
}
-//=======================================================================
-//function : GetAssemblyOwner
-//purpose : Returns common entity owner if it is an assembly
-//=======================================================================
-const Handle(SelectMgr_EntityOwner)& SelectMgr_SelectableObject::GetAssemblyOwner() const
-{
- return myAssemblyOwner;
-}
-
//=======================================================================
//function : BndBoxOfSelected
//purpose :
return Bnd_Box();
Bnd_Box aBnd;
- for (Init(); More(); Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (myselections); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_Selection)& aSel = CurrentSelection();
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
if (aSel->GetSelectionState() != SelectMgr_SOS_Activated)
continue;
- for (aSel->Init(); aSel->More(); aSel->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- const Handle(SelectMgr_EntityOwner) anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aSel->Sensitive()->BaseSensitive()->OwnerId());
+ const Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelEntIter.Value()->BaseSensitive()->OwnerId());
if (theOwners->Contains (anOwner))
{
- Select3D_BndBox3d aBox = aSel->Sensitive()->BaseSensitive()->BoundingBox();
+ Select3D_BndBox3d aBox = aSelEntIter.Value()->BaseSensitive()->BoundingBox();
aBnd.Update (aBox.CornerMin().x(), aBox.CornerMin().y(), aBox.CornerMin().z(),
aBox.CornerMax().x(), aBox.CornerMax().y(), aBox.CornerMax().z());
}
//=======================================================================
Handle(SelectMgr_EntityOwner) SelectMgr_SelectableObject::GlobalSelOwner() const
{
- Handle(SelectMgr_EntityOwner) anOwner;
-
- if (!HasSelection (myGlobalSelMode))
- return anOwner;
-
const Handle(SelectMgr_Selection)& aGlobalSel = Selection (myGlobalSelMode);
- if (aGlobalSel->IsEmpty())
- return anOwner;
-
- aGlobalSel->Init();
- anOwner =
- Handle(SelectMgr_EntityOwner)::DownCast (aGlobalSel->Sensitive()->BaseSensitive()->OwnerId());
+ if (!aGlobalSel.IsNull()
+ && !aGlobalSel->IsEmpty())
+ {
+ return Handle(SelectMgr_EntityOwner)::DownCast (aGlobalSel->Entities().First()->BaseSensitive()->OwnerId());
+ }
+ return THE_NULL_ENTITYOWNER;
+}
- return anOwner;
+//=======================================================================
+//function : GetAssemblyOwner
+//purpose :
+//=======================================================================
+const Handle(SelectMgr_EntityOwner)& SelectMgr_SelectableObject::GetAssemblyOwner() const
+{
+ return THE_NULL_ENTITYOWNER;
}
#ifndef _SelectMgr_SelectableObject_HeaderFile
#define _SelectMgr_SelectableObject_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <SelectMgr_SequenceOfSelection.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Standard_Integer.hxx>
-#include <Standard_Boolean.hxx>
#include <PrsMgr_PresentableObject.hxx>
+#include <PrsMgr_PresentationManager3d.hxx>
#include <PrsMgr_TypeOfPresentation3d.hxx>
+#include <SelectMgr_IndexedMapOfOwner.hxx>
+#include <SelectMgr_SequenceOfSelection.hxx>
#include <SelectMgr_Selection.hxx>
-#include <PrsMgr_PresentationManager3d.hxx>
#include <SelectMgr_SequenceOfOwner.hxx>
-#include <Quantity_NameOfColor.hxx>
-#include <Graphic3d_ZLayerId.hxx>
-#include <SelectMgr_IndexedMapOfOwner.hxx>
+
class SelectMgr_EntityOwner;
class Prs3d_Presentation;
class Standard_NotImplemented;
class SelectMgr_SelectionManager;
-class Bnd_Box;
-
-
-class SelectMgr_SelectableObject;
-DEFINE_STANDARD_HANDLE(SelectMgr_SelectableObject, PrsMgr_PresentableObject)
//! A framework to supply the structure of the object to be
//! selected. At the first pick, this structure is created by
//! completely) when some selection mode is activated not for the first time.
Standard_EXPORT void ClearSelections (const Standard_Boolean update = Standard_False);
- //! Returns the selection Selection having the selection mode aMode.
- Standard_EXPORT const Handle(SelectMgr_Selection)& Selection (const Standard_Integer aMode) const;
-
- //! Returns true if a selection corresponding to the
- //! selection mode theMode was computed for this object.
- Standard_EXPORT virtual Standard_Boolean HasSelection (const Standard_Integer theMode) const;
-
+ //! Returns the selection having specified selection mode or NULL.
+ Standard_EXPORT const Handle(SelectMgr_Selection)& Selection (const Standard_Integer theMode) const;
+
+ //! Returns true if a selection corresponding to the selection mode theMode was computed for this object.
+ Standard_Boolean HasSelection (const Standard_Integer theMode) const { return !Selection (theMode).IsNull(); }
+
+ //! Return the sequence of selections.
+ const SelectMgr_SequenceOfSelection& Selections() const { return myselections; }
+
//! Begins the iteration scanning for sensitive primitives.
- void Init()
- {
- mycurrent = 1;
- }
+ Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
+ void Init() { mycurrent = 1; }
//! Continues the iteration scanning for sensitive primitives.
- Standard_Boolean More() const
- {
- return mycurrent <= myselections.Length();
- }
+ Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
+ Standard_Boolean More() const { return mycurrent <= myselections.Length(); }
//! Continues the iteration scanning for sensitive primitives.
- void Next()
- {
- mycurrent++;
- }
+ Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
+ void Next() { ++mycurrent; }
//! Returns the current selection in this framework.
- const Handle(SelectMgr_Selection)& CurrentSelection() const
- {
- return myselections (mycurrent);
- }
+ Standard_DEPRECATED("Deprecated method, Selections() should be used instead")
+ const Handle(SelectMgr_Selection)& CurrentSelection() const { return myselections (mycurrent); }
Standard_EXPORT void ResetTransformation() Standard_OVERRIDE;
//! Sets common entity owner for assembly sensitive object entities
Standard_EXPORT void SetAssemblyOwner (const Handle(SelectMgr_EntityOwner)& theOwner, const Standard_Integer theMode = -1);
-
- //! Returns common entity owner if the object is an assembly
- Standard_EXPORT const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const;
-
+
//! Returns a bounding box of sensitive entities with the owners given
//! if they are a part of activated selection
Standard_EXPORT Bnd_Box BndBoxOfSelected (const Handle(SelectMgr_IndexedMapOfOwner)& theOwners);
//! Returns the owner of mode for selection of object as a whole
Standard_EXPORT virtual Handle(SelectMgr_EntityOwner) GlobalSelOwner() const;
+ //! Returns common entity owner if the object is an assembly
+ Standard_EXPORT virtual const Handle(SelectMgr_EntityOwner)& GetAssemblyOwner() const;
+
protected:
Standard_EXPORT SelectMgr_SelectableObject(const PrsMgr_TypeOfPresentation3d aTypeOfPresentation3d = PrsMgr_TOP_AllView);
protected:
SelectMgr_SequenceOfSelection myselections;
- Handle(SelectMgr_EntityOwner) myAssemblyOwner;
Handle(Prs3d_Presentation) mySelectionPrs;
Handle(Prs3d_Presentation) myHilightPrs;
Standard_Boolean myAutoHilight;
};
+DEFINE_STANDARD_HANDLE(SelectMgr_SelectableObject, PrsMgr_PresentableObject)
+
#endif // _SelectMgr_SelectableObject_HeaderFile
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <Standard_NullObject.hxx>
-
#include <SelectBasics_EntityOwner.hxx>
+
#include <SelectMgr_Selection.hxx>
+#include <Standard_NullObject.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_Selection,Standard_Transient)
// Purpose :
//==================================================
SelectMgr_Selection::SelectMgr_Selection (const Standard_Integer theModeIdx)
-: myMode (theModeIdx),
+: myEntityIter (0),
+ myMode (theModeIdx),
mySelectionState (SelectMgr_SOS_Unknown),
myBVHUpdateStatus (SelectMgr_TBU_None),
mySensFactor (2),
//==================================================
void SelectMgr_Selection::Add (const Handle(SelectBasics_SensitiveEntity)& theSensitive)
{
- // if input is null:
- // in debug mode raise exception
- Standard_NullObject_Raise_if
- (theSensitive.IsNull(), "Null sensitive entity is added to the selection");
+ // if input is null: in debug mode raise exception
+ Standard_NullObject_Raise_if (theSensitive.IsNull(), "Null sensitive entity is added to the selection");
+ if (theSensitive.IsNull())
+ {
+ // in release mode do not add
+ return;
+ }
- // in release mode do not add
- if (!theSensitive.IsNull())
+ Handle(SelectMgr_SensitiveEntity) anEntity = new SelectMgr_SensitiveEntity (theSensitive);
+ myEntities.Append (anEntity);
+ if (mySelectionState == SelectMgr_SOS_Activated
+ && !anEntity->IsActiveForSelection())
{
- Handle(SelectMgr_SensitiveEntity) anEntity = new SelectMgr_SensitiveEntity (theSensitive);
- myEntities.Append (anEntity);
- if (mySelectionState == SelectMgr_SOS_Activated &&
- !anEntity->IsActiveForSelection())
- {
- anEntity->SetActiveForSelection();
- }
+ anEntity->SetActiveForSelection();
+ }
- if (myIsCustomSens)
- {
- anEntity->BaseSensitive()->SetSensitivityFactor (mySensFactor);
- }
- else
- {
- mySensFactor = Max (mySensFactor,
- anEntity->BaseSensitive()->SensitivityFactor());
- }
+ if (myIsCustomSens)
+ {
+ anEntity->BaseSensitive()->SetSensitivityFactor (mySensFactor);
+ }
+ else
+ {
+ mySensFactor = Max (mySensFactor, anEntity->BaseSensitive()->SensitivityFactor());
}
}
myEntities.Clear();
}
-//==================================================
-// Function: IsEmpty
-// Purpose :
-//==================================================
-Standard_Boolean SelectMgr_Selection::IsEmpty() const
-{
- return myEntities.IsEmpty();
-}
-
-//==================================================
-// function: GetEntityById
-// purpose : Returns sensitive entity stored by
-// index theIdx in entites vector
-//==================================================
-Handle(SelectMgr_SensitiveEntity)& SelectMgr_Selection::GetEntityById (const Standard_Integer theIdx)
-{
- return myEntities.ChangeValue (theIdx);
-}
-
-//==================================================
-// function: GetSelectionState
-// purpose : Returns status of selection
-//==================================================
-SelectMgr_StateOfSelection SelectMgr_Selection::GetSelectionState() const
-{
- return mySelectionState;
-}
-
-//==================================================
-// function: SetSelectionState
-// purpose : Sets status of selection
-//==================================================
-void SelectMgr_Selection::SetSelectionState (const SelectMgr_StateOfSelection theState) const
-{
- mySelectionState = theState;
-}
-
-//==================================================
-// function: Sensitivity
-// purpose : Returns sensitivity of the selection
-//==================================================
-Standard_Integer SelectMgr_Selection::Sensitivity() const
-{
- return mySensFactor;
-}
-
//==================================================
// function: SetSensitivity
// purpose : Changes sensitivity of the selection and all its entities to the given value.
#define _SelectMgr_Selection_HeaderFile
#include <NCollection_Vector.hxx>
-
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-#include <Standard_Type.hxx>
-
-#include <SelectMgr_TypeOfUpdate.hxx>
-#include <Standard_Transient.hxx>
#include <SelectMgr_SensitiveEntity.hxx>
#include <SelectMgr_StateOfSelection.hxx>
#include <SelectMgr_TypeOfBVHUpdate.hxx>
+#include <SelectMgr_TypeOfUpdate.hxx>
-class Standard_NullObject;
class SelectBasics_SensitiveEntity;
//! Represents the state of a given selection mode for a
//! - mode 6 : selection of the constituent solids.
class SelectMgr_Selection : public Standard_Transient
{
-
+ DEFINE_STANDARD_RTTIEXT(SelectMgr_Selection, Standard_Transient)
public:
//! Constructs a selection object defined by the selection mode IdMode.
Standard_EXPORT void Destroy();
- //! Adds the sensitive primitive aprimitive to the list of
- //! stored entities in this object.
+ //! Adds the sensitive primitive to the list of stored entities in this object.
//! Raises NullObject if the primitive is a null handle.
Standard_EXPORT void Add (const Handle(SelectBasics_SensitiveEntity)& theSensitive);
Standard_EXPORT void Clear();
//! returns true if no sensitive entity is stored.
- Standard_EXPORT Standard_Boolean IsEmpty() const;
+ Standard_Boolean IsEmpty() const { return myEntities.IsEmpty(); }
//! returns the selection mode represented by this selection
- Standard_Integer Mode() const;
+ Standard_Integer Mode() const { return myMode; }
+
+ //! Return entities.
+ const NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& Entities() const { return myEntities; }
+
+ //! Return entities.
+ NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>& ChangeEntities() { return myEntities; }
//! Begins an iteration scanning for sensitive primitives.
- void Init();
+ Standard_DEPRECATED("Deprecated method, Entities() should be used instead")
+ void Init() { myEntityIter = myEntities.Lower(); }
//! Continues the iteration scanning for sensitive
//! primitives with the mode defined in this framework.
- Standard_Boolean More() const;
+ Standard_DEPRECATED("Deprecated method, Entities() should be used instead")
+ Standard_Boolean More() const { return myEntityIter <= myEntities.Upper(); }
//! Returns the next sensitive primitive found in the
//! iteration. This is a scan for entities with the mode
//! defined in this framework.
- void Next();
+ Standard_DEPRECATED("Deprecated method, Entities() should be used instead")
+ void Next() { ++myEntityIter; }
//! Returns any sensitive primitive in this framework.
- const Handle(SelectMgr_SensitiveEntity)& Sensitive() const;
+ Standard_DEPRECATED("Deprecated method, Entities() should be used instead")
+ const Handle(SelectMgr_SensitiveEntity)& Sensitive() const { return myEntities.Value (myEntityIter); }
//! Returns the flag UpdateFlag.
//! This flage gives the update status of this framework
//! - full
//! - partial, or
//! - none.
- SelectMgr_TypeOfUpdate UpdateStatus() const;
+ SelectMgr_TypeOfUpdate UpdateStatus() const { return myUpdateStatus; }
- void UpdateStatus (const SelectMgr_TypeOfUpdate theStatus);
+ void UpdateStatus (const SelectMgr_TypeOfUpdate theStatus) { myUpdateStatus = theStatus; }
- void UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus);
+ void UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus) { myBVHUpdateStatus = theStatus; }
- SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const;
+ SelectMgr_TypeOfBVHUpdate BVHUpdateStatus() const { return myBVHUpdateStatus; }
//! Returns status of selection
- Standard_EXPORT SelectMgr_StateOfSelection GetSelectionState() const;
+ SelectMgr_StateOfSelection GetSelectionState() const { return mySelectionState; }
//! Sets status of selection
- Standard_EXPORT void SetSelectionState (const SelectMgr_StateOfSelection theState) const;
+ void SetSelectionState (const SelectMgr_StateOfSelection theState) const { mySelectionState = theState; }
//! Returns sensitivity of the selection
- Standard_EXPORT Standard_Integer Sensitivity() const;
+ Standard_Integer Sensitivity() const { return mySensFactor; }
//! Changes sensitivity of the selection and all its entities to the given value.
//! IMPORTANT: This method does not update any outer selection structures, so for
//! proper updates use SelectMgr_SelectionManager::SetSelectionSensitivity method.
Standard_EXPORT void SetSensitivity (const Standard_Integer theNewSens);
- DEFINE_STANDARD_RTTIEXT(SelectMgr_Selection,Standard_Transient)
-
-protected:
-
- //! Returns sensitive entity stored by index theIdx in entites vector
- Standard_EXPORT Handle(SelectMgr_SensitiveEntity)& GetEntityById (const Standard_Integer theIdx);
-
private:
- NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> myEntities;
- NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator myEntityIter;
- Standard_Integer myMode;
- SelectMgr_TypeOfUpdate myUpdateStatus;
- mutable SelectMgr_StateOfSelection mySelectionState;
- mutable SelectMgr_TypeOfBVHUpdate myBVHUpdateStatus;
- Standard_Integer mySensFactor;
- Standard_Boolean myIsCustomSens;
+ NCollection_Vector<Handle(SelectMgr_SensitiveEntity)> myEntities;
+ Standard_Integer myEntityIter;
+ Standard_Integer myMode;
+ SelectMgr_TypeOfUpdate myUpdateStatus;
+ mutable SelectMgr_StateOfSelection mySelectionState;
+ mutable SelectMgr_TypeOfBVHUpdate myBVHUpdateStatus;
+ Standard_Integer mySensFactor;
+ Standard_Boolean myIsCustomSens;
};
DEFINE_STANDARD_HANDLE(SelectMgr_Selection, Standard_Transient)
-#include <SelectMgr_Selection.lxx>
-
#endif
+++ /dev/null
-// Copyright (c) 1998-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.
-
-// =======================================================================
-// function : Mode
-// purpose :
-// =======================================================================
-inline Standard_Integer SelectMgr_Selection::Mode() const
-{
- return myMode;
-}
-
-// =======================================================================
-// function : Init
-// purpose :
-// =======================================================================
-inline void SelectMgr_Selection::Init()
-{
- myEntityIter.Init (myEntities);
-}
-
-// =======================================================================
-// function : More
-// purpose :
-// =======================================================================
-inline Standard_Boolean SelectMgr_Selection::More() const
-{
- return myEntityIter.More();
-}
-
-// =======================================================================
-// function : Next
-// purpose :
-// =======================================================================
-inline void SelectMgr_Selection::Next()
-{
- myEntityIter.Next();
-}
-
-// =======================================================================
-// function : Sensitive
-// purpose :
-// =======================================================================
-inline const Handle(SelectMgr_SensitiveEntity)& SelectMgr_Selection::Sensitive() const
-{
- return myEntityIter.Value();
-}
-
-// =======================================================================
-// function : UpdateStatus
-// purpose :
-// =======================================================================
-inline void SelectMgr_Selection::UpdateStatus(const SelectMgr_TypeOfUpdate theStatus)
-{
- myUpdateStatus = theStatus;
-}
-
-// =======================================================================
-// function : UpdateStatus
-// purpose :
-// =======================================================================
-inline SelectMgr_TypeOfUpdate SelectMgr_Selection::UpdateStatus() const
-{
- return myUpdateStatus;
-}
-
-// =======================================================================
-// function : UpdateBVHStatus
-// purpose :
-// =======================================================================
-inline void SelectMgr_Selection::UpdateBVHStatus (const SelectMgr_TypeOfBVHUpdate theStatus)
-{
- myBVHUpdateStatus = theStatus;
-}
-
-// =======================================================================
-// function : BVHUpdateStatus
-// purpose :
-// =======================================================================
-inline SelectMgr_TypeOfBVHUpdate SelectMgr_Selection::BVHUpdateStatus() const
-{
- return myBVHUpdateStatus;
-}
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <SelectMgr_SelectionManager.hxx>
#include <OSD_Environment.hxx>
#include <SelectMgr_DataMapIteratorOfDataMapOfObjectSelectors.hxx>
#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_Selection.hxx>
-#include <SelectMgr_SelectionManager.hxx>
#include <SelectMgr_SequenceOfSelector.hxx>
#include <SelectMgr_ViewerSelector.hxx>
#include <Standard_Type.hxx>
IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_SelectionManager,Standard_Transient)
-static Standard_Integer FindIndex (const SelectMgr_SequenceOfSelector& theSelectorsSeq,
- const Handle(SelectMgr_ViewerSelector)& theSelector)
+namespace
{
- Standard_Integer aFoundIdx = 0;
-
- for (Standard_Integer anIdx = 1; anIdx <= theSelectorsSeq.Length() && aFoundIdx==0; anIdx++)
+ static bool containsSelector (const SelectMgr_SequenceOfSelector& theSelectorsSeq,
+ const Handle(SelectMgr_ViewerSelector)& theSelector)
{
- if (theSelector == theSelectorsSeq.Value (anIdx))
- aFoundIdx = anIdx;
+ for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (theSelectorsSeq); aSelectorIter.More(); aSelectorIter.Next())
+ {
+ if (aSelectorIter.Value() == theSelector)
+ {
+ return true;
+ }
+ }
+ return false;
}
-
- return aFoundIdx;
}
//==================================================
// Function: Create
// Purpose :
//==================================================
-SelectMgr_SelectionManager::SelectMgr_SelectionManager() {}
+SelectMgr_SelectionManager::SelectMgr_SelectionManager()
+{
+ //
+}
//==================================================
// Function: Add
for (SelectMgr_DataMapIteratorOfDataMapOfObjectSelectors aSelIter (myLocal); aSelIter.More(); aSelIter.Next())
{
SelectMgr_SequenceOfSelector& theSelectors = myLocal.ChangeFind (aSelIter.Key());
- Standard_Integer aRank = FindIndex (theSelectors, theSelector);
- if (aRank != 0 && aRank <= theSelectors.Length())
- theSelectors.Remove (aRank);
+ for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (theSelectors); aSelectorIter.More(); aSelectorIter.Next())
+ {
+ if (aSelectorIter.Value() == theSelector)
+ {
+ theSelectors.Remove (aSelectorIter);
+ break;
+ }
+ }
}
- if (mySelectors.Contains (theSelector))
- mySelectors.Remove (theSelector);
+ mySelectors.Remove (theSelector);
}
//==================================================
//==================================================
Standard_Boolean SelectMgr_SelectionManager::Contains (const Handle(SelectMgr_SelectableObject)& theObject) const
{
- if (myGlobal.Contains (theObject))
- return Standard_True;
-
- if (myLocal.IsBound (theObject))
- return Standard_True;
-
- return Standard_False;
+ return myGlobal.Contains (theObject)
+ || myLocal.IsBound (theObject);
}
//==================================================
return;
myGlobal.Add(theObject);
- for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
+ for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
- Handle(SelectMgr_ViewerSelector) aSelector =
- Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key());
+ const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key();
if (!aSelector->Contains (theObject) && theObject->HasOwnPresentations())
{
aSelector->AddSelectableObject (theObject);
const Handle(SelectMgr_ViewerSelector)& theSelector,
const Standard_Integer theMode)
{
- if (!mySelectors.Contains (theSelector))
- {
- mySelectors.Add (theSelector);
- }
-
+ mySelectors.Add (theSelector);
if (theMode != -1)
+ {
loadMode (theObject, theMode, theSelector);
+ }
if (theObject->HasOwnPresentations())
+ {
theSelector->AddSelectableObject (theObject);
+ }
- if (myLocal.IsBound (theObject))
+ if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject))
{
- SelectMgr_SequenceOfSelector& aSelectors = myLocal.ChangeFind (theObject);
- if (FindIndex (aSelectors, theSelector) == 0)
+ if (!containsSelector (*aSelectors, theSelector))
{
- aSelectors.Append (theSelector);
+ aSelectors->Append (theSelector);
}
}
else
if (!theObject->HasOwnPresentations())
return;
- SelectMgr_SequenceOfSelector aSelectors;
- aSelectors.Append (theSelector);
- myLocal.Bind (theObject, aSelectors);
+ SelectMgr_SequenceOfSelector aGlobSelectors;
+ aGlobSelectors.Append (theSelector);
+ myLocal.Bind (theObject, aGlobSelectors);
}
}
}
-
//==================================================
// Function: Remove
// Purpose :
if (myGlobal.Contains (theObject))
{
- for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
+ for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
- Handle(SelectMgr_ViewerSelector) aCurSelector =
- Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key());
-
+ const Handle(SelectMgr_ViewerSelector)& aCurSelector = aSelectorsIter.Key();
if (!aCurSelector->Contains (theObject))
+ {
continue;
+ }
- for (theObject->Init(); theObject->More(); theObject->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
- aCurSelector->RemoveSelectionOfObject (theObject, theObject->CurrentSelection());
- theObject->CurrentSelection()->UpdateBVHStatus (SelectMgr_TBU_Remove);
+ aCurSelector->RemoveSelectionOfObject (theObject, aSelIter.Value());
+ aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Remove);
}
aCurSelector->RemoveSelectableObject (theObject);
}
myGlobal.Remove (theObject);
}
- else if (myLocal.IsBound (theObject))
+ else if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject))
{
- SelectMgr_SequenceOfSelector& aSelectors = myLocal.ChangeFind (theObject);
- for (Standard_Integer aSelectorsIdx = 1; aSelectorsIdx <= aSelectors.Length(); aSelectorsIdx++)
+ for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (*aSelectors); aSelectorIter.More(); aSelectorIter.Next())
{
- Handle(SelectMgr_ViewerSelector) aCurSelector = aSelectors (aSelectorsIdx);
+ const Handle(SelectMgr_ViewerSelector)& aCurSelector = aSelectorIter.Value();
if (!aCurSelector->Contains (theObject))
continue;
- for (theObject->Init(); theObject->More(); theObject->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
- aCurSelector->RemoveSelectionOfObject (theObject, theObject->CurrentSelection());
- theObject->CurrentSelection()->UpdateBVHStatus (SelectMgr_TBU_Remove);
+ aCurSelector->RemoveSelectionOfObject (theObject, aSelIter.Value());
+ aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Remove);
}
aCurSelector->RemoveSelectableObject (theObject);
}
{
Remove (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theSelector);
}
-
if (!theObject->HasOwnPresentations())
return;
- for (theObject->Init(); theObject->More(); theObject->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
- theSelector->RemoveSelectionOfObject (theObject, theObject->CurrentSelection());
- theObject->CurrentSelection()->UpdateBVHStatus (SelectMgr_TBU_Remove);
+ theSelector->RemoveSelectionOfObject (theObject, aSelIter.Value());
+ aSelIter.Value()->UpdateBVHStatus (SelectMgr_TBU_Remove);
}
-
theSelector->RemoveSelectableObject (theObject);
- if (myLocal.IsBound (theObject))
+ if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject))
{
- SelectMgr_SequenceOfSelector& aSelectors = myLocal.ChangeFind (theObject);
- for (Standard_Integer aSelectorIdx = 1; aSelectorIdx <= aSelectors.Length(); aSelectorIdx++)
+ for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (*aSelectors); aSelectorIter.More(); aSelectorIter.Next())
{
- if (aSelectors (aSelectorIdx) == theSelector)
+ if (aSelectorIter.Value() == theSelector)
{
- aSelectors.Remove (aSelectorIdx);
+ aSelectors->Remove (aSelectorIter);
break;
}
}
- if (aSelectors.IsEmpty())
+ if (aSelectors->IsEmpty())
{
myLocal.UnBind (theObject);
}
{
Activate (Handle(SelectMgr_SelectableObject)::DownCast (anChildIter.Value()), theMode, theSelector);
}
-
if (!theObject->HasOwnPresentations())
return;
Standard_Boolean isComputed = Standard_False;
- if (theObject->HasSelection (theMode))
+ if (const Handle(SelectMgr_Selection)& aSelOld = theObject->Selection (theMode))
{
- isComputed = theObject->Selection (theMode)->IsEmpty() ? 0 : 1;
+ isComputed = !aSelOld->IsEmpty();
}
-
if (!isComputed)
+ {
loadMode (theObject, theMode);
+ }
if (theSelector.IsNull())
{
if (myGlobal.Contains (theObject))
{
- for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
+ for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
- Handle(SelectMgr_ViewerSelector) aCurSelector =
- Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key());
+ const Handle(SelectMgr_ViewerSelector)& aCurSelector = aSelectorsIter.Key();
Activate (theObject, theMode, aCurSelector);
}
}
- else if (myLocal.IsBound (theObject))
+ else if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject))
{
- SelectMgr_SequenceOfSelector& theSelectors = myLocal.ChangeFind (theObject);
- for (Standard_Integer aSelectorIdx = 1; aSelectorIdx <= theSelectors.Length(); aSelectorIdx++)
+ for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (*aSelectors); aSelectorIter.More(); aSelectorIter.Next())
{
- Handle(SelectMgr_ViewerSelector) aCurSelector = theSelectors (aSelectorIdx);
+ Handle(SelectMgr_ViewerSelector) aCurSelector = aSelectorIter.Value();
Activate (theObject, theMode, aCurSelector);
}
}
}
const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode);
-
switch (aSelection->UpdateStatus())
{
- case SelectMgr_TOU_Full:
- if (theObject->HasSelection (theMode))
- theSelector->RemoveSelectionOfObject (theObject, aSelection);
- theObject->RecomputePrimitives (theMode);
- case SelectMgr_TOU_Partial:
- if(theObject->HasTransformation())
- theObject->UpdateTransformations (aSelection);
- theSelector->RebuildObjectsTree();
- break;
- default:
- break;
+ case SelectMgr_TOU_Full:
+ {
+ if (theObject->HasSelection (theMode))
+ {
+ theSelector->RemoveSelectionOfObject (theObject, aSelection);
+ }
+ theObject->RecomputePrimitives (theMode);
+ // pass through SelectMgr_TOU_Partial
+ }
+ case SelectMgr_TOU_Partial:
+ {
+ if(theObject->HasTransformation())
+ {
+ theObject->UpdateTransformations (aSelection);
+ }
+ theSelector->RebuildObjectsTree();
+ break;
+ }
+ default:
+ break;
}
aSelection->UpdateStatus(SelectMgr_TOU_None);
switch (aSelection->BVHUpdateStatus())
{
- case SelectMgr_TBU_Add:
- case SelectMgr_TBU_Renew:
- theSelector->AddSelectionToObject (theObject, aSelection);
- break;
- case SelectMgr_TBU_Remove:
- if (aSelection->GetSelectionState() == SelectMgr_SOS_Deactivated)
+ case SelectMgr_TBU_Add:
+ case SelectMgr_TBU_Renew:
+ {
theSelector->AddSelectionToObject (theObject, aSelection);
- break;
- default:
- break;
+ break;
+ }
+ case SelectMgr_TBU_Remove:
+ {
+ if (aSelection->GetSelectionState() == SelectMgr_SOS_Deactivated)
+ {
+ theSelector->AddSelectionToObject (theObject, aSelection);
+ }
+ break;
+ }
+ default:
+ break;
}
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
if (myGlobal.Contains (theObject))
{
const Standard_Integer aGlobalSelMode = theObject->GlobalSelectionMode();
- if (theMode != aGlobalSelMode && theSelector->IsActive (theObject, aGlobalSelMode))
+ if (theMode != aGlobalSelMode
+ && theSelector->IsActive (theObject, aGlobalSelMode))
{
theSelector->Deactivate (theObject->Selection (aGlobalSelMode));
}
}
else
{
- if (myLocal.IsBound (theObject))
+ if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject))
{
- if (FindIndex (myLocal.Find (theObject), theSelector) == 0)
- (myLocal.ChangeFind (theObject)).Append (theSelector);
+ if (!containsSelector (*aSelectors, theSelector))
+ {
+ aSelectors->Append (theSelector);
+ }
theSelector->Activate (theObject->Selection (theMode));
}
}
{
Deactivate (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector);
}
-
if (!theObject->HasOwnPresentations())
+ {
return;
+ }
+ if (!myGlobal.Contains(theObject)
+ && !myLocal.IsBound (theObject))
+ {
+ return;
+ }
- Standard_Boolean isInGlobal = myGlobal.Contains (theObject);
- Standard_Boolean hasSelection = theMode == -1 ? Standard_True : theObject->HasSelection (theMode);
-
- if (theSelector.IsNull())
+ const Handle(SelectMgr_Selection)& aSel = theObject->Selection (theMode);
+ if (!theSelector.IsNull())
{
- Handle(SelectMgr_ViewerSelector) aSelector;
- for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
+ if (theMode == -1)
{
- aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key());
- if (isInGlobal || myLocal.IsBound (theObject))
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
- if (theMode == -1)
- {
- for (theObject->Init(); theObject->More(); theObject->Next())
- {
- aSelector->Deactivate (theObject->CurrentSelection());
- }
- }
- else
- {
- if (hasSelection)
- aSelector->Deactivate (theObject->Selection (theMode));
- }
+ theSelector->Deactivate (aSelIter.Value());
}
}
+ else if (!aSel.IsNull())
+ {
+ theSelector->Deactivate (aSel);
+ }
+ return;
}
- else
+
+ for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
{
+ const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorIter.Key();
if (theMode == -1)
{
- for (theObject->Init(); theObject->More(); theObject->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
- theSelector->Deactivate (theObject->CurrentSelection());
+ aSelector->Deactivate (aSelIter.Value());
}
}
- else
- if (hasSelection)
- theSelector->Deactivate (theObject->Selection (theMode));
+ else if (!aSel.IsNull())
+ {
+ aSelector->Deactivate (aSel);
+ }
}
}
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)))
+ }
+ if (!myGlobal.Contains(theObject)
+ && !myLocal.IsBound (theObject))
+ {
return Standard_False;
+ }
if (theMode == -1 && theSelector.IsNull())
{
- for (theObject->Init(); theObject->More(); theObject->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
- if (IsActivated (theObject, theObject->CurrentSelection()->Mode()))
+ if (IsActivated (theObject, aSelIter.Value()->Mode()))
+ {
return Standard_True;
+ }
}
-
return Standard_False;
}
- if (!theObject->HasSelection (theMode))
- return Standard_False;
-
const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode);
- if (theSelector.IsNull())
+ if (aSelection.IsNull())
{
- for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
- {
- Handle(SelectMgr_ViewerSelector) aSelector (Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key()));
- if (aSelector->Status (aSelection) == SelectMgr_SOS_Activated)
- return Standard_True;
- }
+ return Standard_False;
}
- else
+
+ 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;
}
}
if (!theObj->HasOwnPresentations())
+ {
+ return;
+ }
+ if (!myGlobal.Contains(theObj)
+ && !myLocal.IsBound (theObj))
+ {
return;
+ }
if (theSelector.IsNull())
{
- if (!(myGlobal.Contains (theObj) || myLocal.IsBound(theObj)))
- return;
-
- TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors);
- Handle(SelectMgr_ViewerSelector) aSelector;
- for( ; aSelectorsIter.More(); aSelectorsIter.Next())
+ for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
- aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key());
+ const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key();
ClearSelectionStructures (theObj, theMode, aSelector);
}
+ return;
}
- else
- {
- if (!(myGlobal.Contains (theObj) || myLocal.IsBound (theObj)))
- return;
- if (theMode != -1)
+ if (theMode != -1)
+ {
+ if (const Handle(SelectMgr_Selection)& aSelection = theObj->Selection (theMode))
{
- if (theObj->HasSelection (theMode))
- {
- const Handle(SelectMgr_Selection)& aSelection = theObj->Selection (theMode);
- if (theObj->HasSelection (theMode))
- {
- theSelector->RemoveSelectionOfObject (theObj, aSelection);
- aSelection->UpdateBVHStatus (SelectMgr_TBU_Add);
- }
- }
+ theSelector->RemoveSelectionOfObject (theObj, aSelection);
+ aSelection->UpdateBVHStatus (SelectMgr_TBU_Add);
}
- else
+ }
+ else
+ {
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObj->Selections()); aSelIter.More(); aSelIter.Next())
{
- for (theObj->Init(); theObj->More(); theObj->Next())
- {
- const Handle(SelectMgr_Selection)& aSelection = theObj->CurrentSelection();
- theSelector->RemoveSelectionOfObject (theObj, aSelection);
- aSelection->UpdateBVHStatus (SelectMgr_TBU_Add);
- }
+ const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
+ theSelector->RemoveSelectionOfObject (theObj, aSelection);
+ aSelection->UpdateBVHStatus (SelectMgr_TBU_Add);
}
- theSelector->RebuildObjectsTree();
}
+ theSelector->RebuildObjectsTree();
}
//=======================================================================
{
RestoreSelectionStructures (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theMode, theSelector);
}
-
if (!theObj->HasOwnPresentations())
+ {
+ return;
+ }
+ if (!myGlobal.Contains(theObj)
+ && !myLocal.IsBound (theObj))
+ {
return;
+ }
if (theSelector.IsNull())
{
- if (!(myGlobal.Contains (theObj) || myLocal.IsBound(theObj)))
- return;
-
- TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors);
- Handle(SelectMgr_ViewerSelector) aSelector;
- for( ; aSelectorsIter.More(); aSelectorsIter.Next())
+ for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
- aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key());
+ const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key();
RestoreSelectionStructures (theObj, theMode, aSelector);
}
+ return;
}
- else
- {
- if (!(myGlobal.Contains (theObj) || myLocal.IsBound (theObj)))
- return;
- if (theMode != -1)
+ if (theMode != -1)
+ {
+ if (const Handle(SelectMgr_Selection)& aSelection = theObj->Selection (theMode))
{
- if (theObj->HasSelection (theMode))
- {
- const Handle(SelectMgr_Selection)& aSelection = theObj->Selection (theMode);
- if (theObj->HasSelection (theMode))
- {
- theSelector->AddSelectionToObject (theObj, aSelection);
- aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
- }
- }
+ theSelector->AddSelectionToObject (theObj, aSelection);
+ aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
}
- else
+ }
+ else
+ {
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObj->Selections()); aSelIter.More(); aSelIter.Next())
{
- for (theObj->Init(); theObj->More(); theObj->Next())
- {
- const Handle(SelectMgr_Selection)& aSelection = theObj->CurrentSelection();
- theSelector->AddSelectionToObject (theObj, aSelection);
- aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
- }
+ const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
+ theSelector->AddSelectionToObject (theObj, aSelection);
+ aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
}
- theSelector->RebuildObjectsTree();
}
+ theSelector->RebuildObjectsTree();
}
//=======================================================================
//=======================================================================
void SelectMgr_SelectionManager::rebuildSelectionStructures (const Handle(SelectMgr_ViewerSelector)& theSelector)
{
- if (theSelector.IsNull())
+ if (!theSelector.IsNull())
{
- Handle(SelectMgr_ViewerSelector) aSelector;
- for(TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
- {
- aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key());
- rebuildSelectionStructures (aSelector);
- }
+ theSelector->RebuildObjectsTree();
+ return;
}
- else
+
+ for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
- theSelector->RebuildObjectsTree();
+ const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key();
+ rebuildSelectionStructures (aSelector);
}
}
{
theSelection->UpdateStatus (SelectMgr_TOU_Full);
- for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
+ for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
{
- Handle(SelectMgr_ViewerSelector) aCurSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key());
+ const Handle(SelectMgr_ViewerSelector)& aCurSelector = aSelectorIter.Key();
ClearSelectionStructures (theObject, theMode, aCurSelector);
theObject->RecomputePrimitives (theMode);
{
RecomputeSelection (Handle(SelectMgr_SelectableObject)::DownCast (anChildrenIter.Value()), theIsForce, theMode);
}
-
if (!theObject->HasOwnPresentations())
+ {
return;
-
- if (!(myGlobal.Contains (theObject) || myLocal.IsBound (theObject)))
+ }
+ if (!myGlobal.Contains (theObject)
+ && !myLocal.IsBound (theObject))
+ {
return;
+ }
if (theMode == -1)
{
- for (theObject->Init(); theObject->More(); theObject->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_Selection)& aSelection = theObject->CurrentSelection();
- Standard_Integer aSelMode = aSelection->Mode();
+ const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
+ const 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);
+ if (const Handle(SelectMgr_Selection)& aSelection = theObject->Selection (theMode))
+ {
+ recomputeSelectionMode (theObject, aSelection, theMode);
+ }
}
}
{
Update (Handle(SelectMgr_SelectableObject)::DownCast (aChildIter.Value()), theIsForce);
}
-
if (!theObject->HasOwnPresentations())
+ {
return;
+ }
- for (theObject->Init(); theObject->More(); theObject->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_Selection)& aSelection = theObject->CurrentSelection();
+ const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
if (theIsForce)
{
switch (aSelection->UpdateStatus())
{
- case SelectMgr_TOU_Full:
- ClearSelectionStructures (theObject, aSelection->Mode());
- theObject->RecomputePrimitives (aSelection->Mode()); // no break on purpose...
- RestoreSelectionStructures (theObject, aSelection->Mode());
- case SelectMgr_TOU_Partial:
- theObject->UpdateTransformations (aSelection);
- rebuildSelectionStructures();
- break;
- default:
- break;
+ case SelectMgr_TOU_Full:
+ {
+ ClearSelectionStructures (theObject, aSelection->Mode());
+ theObject->RecomputePrimitives (aSelection->Mode()); // no break on purpose...
+ RestoreSelectionStructures (theObject, aSelection->Mode());
+ // pass through SelectMgr_TOU_Partial
+ }
+ case SelectMgr_TOU_Partial:
+ {
+ theObject->UpdateTransformations (aSelection);
+ rebuildSelectionStructures();
+ break;
+ }
+ default:
+ break;
}
aSelection->UpdateStatus (SelectMgr_TOU_None);
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
}
- for (TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
+ for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorIter (mySelectors); aSelectorIter.More(); aSelectorIter.Next())
{
- Handle(SelectMgr_ViewerSelector) aSelector (Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key()));
+ const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorIter.Key();
Update (theObject, aSelector, Standard_False);
}
}
const Standard_Boolean theIsForce)
{
if (!mySelectors.Contains (theSelector))
+ {
return;
+ }
- Standard_Boolean isKnown = myGlobal.Contains (theObject);
- if (!isKnown)
- isKnown = (myLocal.IsBound (theObject) && (FindIndex (myLocal.Find (theObject), theSelector) != 0));
- if (!isKnown)
- 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 (theObject->Init(); theObject->More(); theObject->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_Selection)& aSelection = theObject->CurrentSelection();
+ 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());
- case SelectMgr_TOU_Partial:
- theObject->UpdateTransformations (aSelection);
- rebuildSelectionStructures();
- break;
- default:
- break;
+ case SelectMgr_TOU_Full:
+ {
+ ClearSelectionStructures (theObject, aSelection->Mode());
+ theObject->RecomputePrimitives (aSelection->Mode());
+ RestoreSelectionStructures (theObject, aSelection->Mode());
+ // pass through SelectMgr_TOU_Partial
+ }
+ case SelectMgr_TOU_Partial:
+ {
+ theObject->UpdateTransformations (aSelection);
+ rebuildSelectionStructures();
+ break;
+ }
+ default:
+ break;
}
aSelection->UpdateStatus (SelectMgr_TOU_None);
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
{
switch (aSelection->UpdateStatus())
{
- case SelectMgr_TOU_Full:
- ClearSelectionStructures (theObject, aSelection->Mode(), theSelector);
- theObject->RecomputePrimitives (aSelection->Mode());
- RestoreSelectionStructures (theObject, aSelection->Mode(), theSelector);
- case SelectMgr_TOU_Partial:
- if (theObject->HasTransformation())
+ case SelectMgr_TOU_Full:
{
- theObject->UpdateTransformations (aSelection);
- theSelector->RebuildObjectsTree();
+ ClearSelectionStructures (theObject, aSelection->Mode(), theSelector);
+ theObject->RecomputePrimitives (aSelection->Mode());
+ RestoreSelectionStructures (theObject, aSelection->Mode(), theSelector);
+ // pass through SelectMgr_TOU_Partial
}
- break;
- default:
- break;
+ case SelectMgr_TOU_Partial:
+ {
+ if (theObject->HasTransformation())
+ {
+ theObject->UpdateTransformations (aSelection);
+ theSelector->RebuildObjectsTree();
+ }
+ break;
+ }
+ default:
+ break;
}
- aSelection->UpdateStatus(SelectMgr_TOU_None);
+ aSelection->UpdateStatus (SelectMgr_TOU_None);
aSelection->UpdateBVHStatus (SelectMgr_TBU_None);
}
}
const Handle(SelectMgr_ViewerSelector)& theSelector)
{
if (theMode == -1)
+ {
return;
+ }
- if (!theObject->HasSelection (theMode))
+ if (const Handle(SelectMgr_Selection)& aSelOld = theObject->Selection (theMode))
{
- Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode);
- theObject->AddSelection (aNewSel, theMode);
- if (theSelector.IsNull())
+ if (aSelOld->IsEmpty())
{
- if (myGlobal.Contains (theObject))
- {
- TColStd_MapIteratorOfMapOfTransient aSelectorIter (mySelectors);
- for ( ; aSelectorIter.More(); aSelectorIter.Next())
- {
- Handle(SelectMgr_ViewerSelector) aSelector =
- Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorIter.Key());
- aSelector->AddSelectionToObject (theObject, aNewSel);
- aNewSel->UpdateBVHStatus (SelectMgr_TBU_None);
- }
- }
- else if (myLocal.IsBound (theObject))
+ if (aSelOld->BVHUpdateStatus() == SelectMgr_TBU_Remove)
{
- const SelectMgr_SequenceOfSelector& aSelectors = myLocal (theObject);
- for (Standard_Integer aSelectorIdx = 1; aSelectorIdx <= aSelectors.Length(); ++aSelectorIdx)
- {
- aSelectors (aSelectorIdx)->AddSelectionToObject (theObject, aNewSel);
- aNewSel->UpdateBVHStatus (SelectMgr_TBU_None);
- }
+ Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode);
+ theObject->AddSelection (aNewSel, theMode);
+ aNewSel->UpdateBVHStatus (SelectMgr_TBU_Remove);
+ aNewSel->SetSelectionState (SelectMgr_SOS_Deactivated);
}
}
- else
+ return;
+ }
+
+ 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())
{
- theSelector->AddSelectionToObject (theObject, aNewSel);
+ const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorIter.Key();
+ aSelector->AddSelectionToObject (theObject, aNewSel);
aNewSel->UpdateBVHStatus (SelectMgr_TBU_None);
}
}
- else if (theObject->Selection (theMode)->IsEmpty())
+ else if (SelectMgr_SequenceOfSelector* aSelectors = myLocal.ChangeSeek (theObject))
{
- if (theObject->Selection (theMode)->BVHUpdateStatus() == SelectMgr_TBU_Remove)
+ for (SelectMgr_SequenceOfSelector::Iterator aSelectorIter (*aSelectors); aSelectorIter.More(); aSelectorIter.Next())
{
- Handle(SelectMgr_Selection) aNewSel = new SelectMgr_Selection (theMode);
- theObject->AddSelection (aNewSel, theMode);
- theObject->Selection (theMode)->UpdateBVHStatus (SelectMgr_TBU_Remove);
- theObject->Selection (theMode)->SetSelectionState (SelectMgr_SOS_Deactivated);
+ aSelectorIter.Value()->AddSelectionToObject (theObject, aNewSel);
+ aNewSel->UpdateBVHStatus (SelectMgr_TBU_None);
}
}
}
void SelectMgr_SelectionManager::SetUpdateMode (const Handle(SelectMgr_SelectableObject)& theObject,
const SelectMgr_TypeOfUpdate theType)
{
- for (theObject->Init(); theObject->More(); theObject->Next())
- theObject->CurrentSelection()->UpdateStatus (theType);
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theObject->Selections()); aSelIter.More(); aSelIter.Next())
+ {
+ aSelIter.Value()->UpdateStatus (theType);
+ }
}
//=======================================================================
const Standard_Integer theMode,
const SelectMgr_TypeOfUpdate theType)
{
- if (theObject->HasSelection (theMode))
- theObject->Selection (theMode)->UpdateStatus (theType);
+ if (const Handle(SelectMgr_Selection)& aSel = theObject->Selection (theMode))
+ {
+ aSel->UpdateStatus (theType);
+ }
}
//=======================================================================
const Standard_Integer theMode,
const Standard_Integer theNewSens)
{
- Standard_ASSERT_RAISE (theNewSens > 0,
- "Error! Selection sensitivity have positive value.");
+ Standard_ASSERT_RAISE (theNewSens > 0, "Error! Selection sensitivity have positive value.");
+ if (theObject.IsNull())
+ {
+ return;
+ }
- if (theObject.IsNull() || !theObject->HasSelection (theMode))
+ const Handle(SelectMgr_Selection)& aSel = theObject->Selection (theMode);
+ if (theObject.IsNull())
+ {
return;
+ }
- Handle(SelectMgr_Selection) aSel = theObject->Selection (theMode);
const Standard_Integer aPrevSens = aSel->Sensitivity();
aSel->SetSensitivity (theNewSens);
-
- if (!(myGlobal.Contains (theObject) || myLocal.IsBound (theObject)))
- return;
-
if (myGlobal.Contains (theObject))
{
- for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
+ for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
- Handle(SelectMgr_ViewerSelector) aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key());
+ const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key();
if (aSelector->Contains (theObject))
{
aSelector->myTolerances.Decrement (aPrevSens);
{
if (myGlobal.Contains (theObject))
{
- for (TColStd_MapIteratorOfMapOfTransient aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
+ for (NCollection_Map<Handle(SelectMgr_ViewerSelector)>::Iterator aSelectorsIter (mySelectors); aSelectorsIter.More(); aSelectorsIter.Next())
{
- Handle(SelectMgr_ViewerSelector) aSelector = Handle(SelectMgr_ViewerSelector)::DownCast (aSelectorsIter.Key());
+ const Handle(SelectMgr_ViewerSelector)& aSelector = aSelectorsIter.Key();
if (aSelector->Contains (theObject))
{
aSelector->MoveSelectableObject (theObject);
#ifndef _SelectMgr_SelectionManager_HeaderFile
#define _SelectMgr_SelectionManager_HeaderFile
-#include <Standard.hxx>
-#include <Standard_Type.hxx>
-
-#include <TColStd_MapOfTransient.hxx>
#include <SelectMgr_DataMapOfObjectSelectors.hxx>
-#include <Standard_Transient.hxx>
#include <SelectMgr_ViewerSelector.hxx>
-#include <Standard_Boolean.hxx>
-#include <Standard_Integer.hxx>
#include <SelectMgr_TypeOfUpdate.hxx>
-class SelectMgr_SelectableObject;
-
+#include <TColStd_MapOfTransient.hxx>
-class SelectMgr_SelectionManager;
-DEFINE_STANDARD_HANDLE(SelectMgr_SelectionManager, Standard_Transient)
+class SelectMgr_SelectableObject;
-//! A framework to manage selection from the point of
-//! view of viewer selectors. These can be added and
-//! removed, and selection modes can be activated and
-//! deactivated. In addition, objects may be known to all
-//! selectors or only to some.
+//! A framework to manage selection from the point of view of viewer selectors.
+//! These can be added and removed, and selection modes can be activated and deactivated.
+//! In addition, objects may be known to all selectors or only to some.
class SelectMgr_SelectionManager : public Standard_Transient
{
-
+ DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectionManager, Standard_Transient)
public:
-
//! Constructs an empty selection manager object.
Standard_EXPORT SelectMgr_SelectionManager();
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 existance of theObject in global context before addition, but adds theSelector to local context.
+ //! 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
//! 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 = NULL);
+ Standard_EXPORT void Activate (const Handle(SelectMgr_SelectableObject)& theObject,
+ const Standard_Integer theMode = 0,
+ const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)());
//! Deactivates mode theMode of theObject in theSelector. If theMode value is set to default (-1), all
- //! avtive selection modes will be deactivated. Likewise, if theSelector value is set to default (NULL), theMode
+ //! 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 = NULL);
+ Standard_EXPORT void Deactivate (const Handle(SelectMgr_SelectableObject)& theObject,
+ const Standard_Integer theMode = -1,
+ const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)());
//! 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 = NULL) const;
+ Standard_EXPORT Standard_Boolean IsActivated (const Handle(SelectMgr_SelectableObject)& theObject,
+ const Standard_Integer theMode = -1,
+ const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)()) 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 = NULL);
+ Standard_EXPORT void ClearSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj,
+ const Standard_Integer theMode = -1,
+ const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)());
- //! Re-adds newely calculated sensitive entities of recomputed selection
+ //! 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 = NULL);
+ Standard_EXPORT void RestoreSelectionStructures (const Handle(SelectMgr_SelectableObject)& theObj,
+ const Standard_Integer theMode = -1,
+ const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)());
//! 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,
//! Re-adds selectable object in BVHs in all viewer selectors.
Standard_EXPORT void UpdateSelection (const Handle(SelectMgr_SelectableObject)& theObj);
- DEFINE_STANDARD_RTTIEXT(SelectMgr_SelectionManager,Standard_Transient)
-
protected:
//! Recomputes given selection mode and updates BVHs in all viewer selectors
const Handle(SelectMgr_Selection)& theSelection,
const Standard_Integer theMode);
-
private:
-
//! Loads and creates selection structures for object theObject with mode theMode in specified
//! 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 = NULL);
+ 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 = NULL);
+ Standard_EXPORT void rebuildSelectionStructures (const Handle(SelectMgr_ViewerSelector)& theSelector = Handle(SelectMgr_ViewerSelector)());
- TColStd_MapOfTransient mySelectors;
- TColStd_MapOfTransient myGlobal;
- SelectMgr_DataMapOfObjectSelectors myLocal;
+private:
+ NCollection_Map<Handle(SelectMgr_ViewerSelector)> mySelectors;
+ NCollection_Map<Handle(SelectMgr_SelectableObject)> myGlobal;
+ SelectMgr_DataMapOfObjectSelectors myLocal;
};
-
-
-
-
-
+DEFINE_STANDARD_HANDLE(SelectMgr_SelectionManager, Standard_Transient)
#endif // _SelectMgr_SelectionManager_HeaderFile
//=======================================================================
void SelectMgr_SensitiveEntitySet::Append (const Handle(SelectMgr_Selection)& theSelection)
{
- for (theSelection->Init(); theSelection->More(); theSelection->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- if (!theSelection->Sensitive()->BaseSensitive()->IsKind (STANDARD_TYPE(Select3D_SensitiveEntity)))
+ if (!aSelEntIter.Value()->BaseSensitive()->IsKind (STANDARD_TYPE(Select3D_SensitiveEntity)))
{
- theSelection->Sensitive()->ResetSelectionActiveStatus();
+ aSelEntIter.Value()->ResetSelectionActiveStatus();
continue;
}
- mySensitives.Add (theSelection->Sensitive());
+ mySensitives.Add (aSelEntIter.Value());
}
MarkDirty();
}
//=======================================================================
void SelectMgr_SensitiveEntitySet::Remove (const Handle(SelectMgr_Selection)& theSelection)
{
- for (theSelection->Init(); theSelection->More(); theSelection->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- Standard_Integer anEntIdx = mySensitives.FindIndex (theSelection->Sensitive());
- if (!anEntIdx)
+ const Standard_Integer anEntIdx = mySensitives.FindIndex (aSelEntIter.Value());
+ if (anEntIdx == 0)
+ {
continue;
+ }
if (anEntIdx != mySensitives.Size())
{
//==================================================
void SelectMgr_ViewerSelector::Activate (const Handle(SelectMgr_Selection)& theSelection)
{
- for (theSelection->Init(); theSelection->More(); theSelection->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- theSelection->Sensitive()->SetActiveForSelection();
+ aSelEntIter.Value()->SetActiveForSelection();
}
theSelection->SetSelectionState (SelectMgr_SOS_Activated);
//==================================================
void SelectMgr_ViewerSelector::Deactivate (const Handle(SelectMgr_Selection)& theSelection)
{
- for (theSelection->Init(); theSelection->More(); theSelection->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- theSelection->Sensitive()->ResetSelectionActiveStatus();
+ aSelEntIter.Value()->ResetSelectionActiveStatus();
}
theSelection->SetSelectionState (SelectMgr_SOS_Deactivated);
const SelectMgr_StateOfSelection theWantedState) const
{
Standard_Boolean hasActivatedStates = Contains (theSelectableObject);
- for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theSelectableObject->Selections()); aSelIter.More(); aSelIter.Next())
{
if (theWantedState == SelectMgr_SOS_Any)
{
- theModeList.Append (theSelectableObject->CurrentSelection()->Mode());
+ theModeList.Append (aSelIter.Value()->Mode());
}
- else if (theWantedState == theSelectableObject->CurrentSelection()->GetSelectionState())
+ else if (theWantedState == aSelIter.Value()->GetSelectionState())
{
- theModeList.Append (theSelectableObject->CurrentSelection()->Mode());
+ theModeList.Append (aSelIter.Value()->Mode());
}
}
if (!Contains (theSelectableObject))
return Standard_False;
- for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next())
- {
- if (theMode == theSelectableObject->CurrentSelection()->Mode())
- {
- return theSelectableObject->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated;
- }
- }
-
- return Standard_False;
+ const Handle(SelectMgr_Selection)& aSel = theSelectableObject->Selection (theMode);
+ return !aSel.IsNull()
+ && aSel->GetSelectionState() == SelectMgr_SOS_Activated;
}
//==================================================
if (!Contains (theSelectableObject))
return Standard_False;
- for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next())
- {
- if (theMode == theSelectableObject->CurrentSelection()->Mode())
- {
- return theSelectableObject->CurrentSelection()->GetSelectionState() != SelectMgr_SOS_Unknown;
- }
- }
-
- return Standard_False;
+ const Handle(SelectMgr_Selection)& aSel = theSelectableObject->Selection (theMode);
+ return !aSel.IsNull()
+ && aSel->GetSelectionState() != SelectMgr_SOS_Unknown;
}
TCollection_AsciiString SelectMgr_ViewerSelector::Status (const Handle(SelectMgr_SelectableObject)& theSelectableObject) const
{
TCollection_AsciiString aStatus ("Status Object :\n\t");
-
- for (theSelectableObject->Init(); theSelectableObject->More(); theSelectableObject->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (theSelectableObject->Selections()); aSelIter.More(); aSelIter.Next())
{
- if (theSelectableObject->CurrentSelection()->GetSelectionState() != SelectMgr_SOS_Unknown)
+ if (aSelIter.Value()->GetSelectionState() != SelectMgr_SOS_Unknown)
{
- aStatus = aStatus + "Mode " +
- TCollection_AsciiString (theSelectableObject->CurrentSelection()->Mode()) +
- " present - ";
- if (theSelectableObject->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated)
- {
- aStatus = aStatus + " Active \n\t";
- }
- else
- {
- aStatus = aStatus + " Inactive \n\t";
- }
+ aStatus = aStatus + "Mode " + TCollection_AsciiString (aSelIter.Value()->Mode()) + " present - "
+ + (aSelIter.Value()->GetSelectionState() == SelectMgr_SOS_Activated ? " Active \n\t" : " Inactive \n\t");
}
}
//==================================================
void StdSelect_BRepSelectionTool::PreBuildBVH (const Handle(SelectMgr_Selection)& theSelection)
{
- for (theSelection->Init(); theSelection->More(); theSelection->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- const Handle(SelectBasics_SensitiveEntity)& aSensitive = theSelection->Sensitive()->BaseSensitive();
+ const Handle(SelectBasics_SensitiveEntity)& aSensitive = aSelEntIter.Value()->BaseSensitive();
if (aSensitive->NbSubElements() >= BVH_PRIMITIVE_LIMIT)
{
aSensitive->BVH();
theMaxParam);
// loading of selectables...
- for (theSelection->Init(); theSelection->More(); theSelection->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- Handle(SelectMgr_EntityOwner) anOwner
- = Handle(SelectMgr_EntityOwner)::DownCast (theSelection->Sensitive()->BaseSensitive()->OwnerId());
+ Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aSelEntIter.Value()->BaseSensitive()->OwnerId());
anOwner->Set (theSelectableObj);
}
//=======================================================================
void StdSelect_ViewerSelector3d::DisplaySensitive (const Handle(V3d_View)& theView)
{
- SelectMgr_SelectableObjectSet::Iterator aSelectableIt (mySelectableObjects);
-
- for (; aSelectableIt.More(); aSelectableIt.Next())
+ for (SelectMgr_SelectableObjectSet::Iterator aSelectableIt (mySelectableObjects); aSelectableIt.More(); aSelectableIt.Next())
{
- const Handle (SelectMgr_SelectableObject)& anObj = aSelectableIt.Value();
-
Handle(Graphic3d_Structure) aStruct = new Graphic3d_Structure (theView->Viewer()->StructureManager());
-
- for (anObj->Init(); anObj->More(); anObj->Next())
+ const Handle (SelectMgr_SelectableObject)& anObj = aSelectableIt.Value();
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
{
- if (anObj->CurrentSelection()->GetSelectionState() == SelectMgr_SOS_Activated)
+ if (aSelIter.Value()->GetSelectionState() == SelectMgr_SOS_Activated)
{
- computeSensitivePrs (aStruct, anObj->CurrentSelection(), anObj->Transformation(), Handle(Graphic3d_TransformPers)());
+ computeSensitivePrs (aStruct, aSelIter.Value(), anObj->Transformation(), Handle(Graphic3d_TransformPers)());
}
}
myStructs.Append (aStruct);
}
- for (Standard_Integer aStructIdx = 1; aStructIdx <= myStructs.Length(); ++aStructIdx)
+ for (Graphic3d_SequenceOfStructure::Iterator aStructIter (myStructs); aStructIter.More(); aStructIter.Next())
{
- Handle(Graphic3d_Structure)& aStruct = myStructs.ChangeValue (aStructIdx);
+ Handle(Graphic3d_Structure)& aStruct = aStructIter.ChangeValue();
aStruct->SetDisplayPriority (10);
aStruct->Display();
}
//=======================================================================
void StdSelect_ViewerSelector3d::ClearSensitive (const Handle(V3d_View)& theView)
{
- for (Standard_Integer aStructIdx = 1; aStructIdx <= myStructs.Length(); ++aStructIdx)
+ for (Graphic3d_SequenceOfStructure::Iterator aStructIter (myStructs); aStructIter.More(); aStructIter.Next())
{
- myStructs.Value (aStructIdx)->Remove();
+ aStructIter.ChangeValue()->Remove();
}
-
myStructs.Clear();
if (!theView.IsNull())
Handle(Graphic3d_Group) aSensGroup = theStructure->NewGroup();
Quantity_Color aColor (Quantity_NOC_INDIANRED3);
- Handle(Graphic3d_AspectMarker3d) aMarkerAspect =
- new Graphic3d_AspectMarker3d (Aspect_TOM_O_PLUS, aColor, 2.0);
+ Handle(Graphic3d_AspectMarker3d) aMarkerAspect =new Graphic3d_AspectMarker3d (Aspect_TOM_O_PLUS, aColor, 2.0);
aSensGroup->SetPrimitivesAspect (aMarkerAspect);
- aSensGroup->SetPrimitivesAspect (
- new Graphic3d_AspectLine3d (Quantity_NOC_GRAY40, Aspect_TOL_SOLID, 2.0));
+ aSensGroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (Quantity_NOC_GRAY40, Aspect_TOL_SOLID, 2.0));
Handle(Graphic3d_Group) anAreaGroup = theStructure->NewGroup();
- anAreaGroup->SetPrimitivesAspect (
- new Graphic3d_AspectLine3d (Quantity_NOC_AQUAMARINE1, Aspect_TOL_DASH, 1.0));
+ anAreaGroup->SetPrimitivesAspect (new Graphic3d_AspectLine3d (Quantity_NOC_AQUAMARINE1, Aspect_TOL_DASH, 1.0));
TColgp_SequenceOfPnt aSeqLines, aSeqFree;
TColStd_SequenceOfInteger aSeqBnds;
-
- for (theSel->Init(); theSel->More(); theSel->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (theSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- Handle(Select3D_SensitiveEntity) Ent =
- Handle(Select3D_SensitiveEntity)::DownCast(theSel->Sensitive()->BaseSensitive());
+ Handle(Select3D_SensitiveEntity) Ent = Handle(Select3D_SensitiveEntity)::DownCast(aSelEntIter.Value()->BaseSensitive());
const Standard_Boolean hasloc = theLoc.Form() != gp_Identity;
//==============
for (SelectMgr_SelectableObjectSet::Iterator anObjIter (theSelObjects); anObjIter.More(); anObjIter.Next())
{
const Handle(SelectMgr_SelectableObject)& anObj = anObjIter.Value();
- for (anObj->Init(); anObj->More(); anObj->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_Selection)& aSel = anObj->CurrentSelection();
- for (aSel->Init(); aSel->More(); aSel->Next())
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- const Handle(SelectMgr_SensitiveEntity)& aSens = aSel->Sensitive();
+ const Handle(SelectMgr_SensitiveEntity)& aSens = aSelEntIter.Value();
if (!myMapEntityColors.IsBound (aSens->BaseSensitive()))
{
Quantity_Color aColor;
for (SelectMgr_SelectableObjectSet::Iterator anObjIter (theSelObjects); anObjIter.More(); anObjIter.Next())
{
const Handle(SelectMgr_SelectableObject)& anObj = anObjIter.Value();
- for (anObj->Init(); anObj->More(); anObj->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anObj->Selections()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_Selection)& aSel = anObj->CurrentSelection();
- for (aSel->Init(); aSel->More(); aSel->Next())
+ const Handle(SelectMgr_Selection)& aSel = aSelIter.Value();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSel->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- const Handle(SelectMgr_SensitiveEntity)& aSens = aSel->Sensitive();
+ const Handle(SelectMgr_SensitiveEntity)& aSens = aSelEntIter.Value();
const Handle(SelectBasics_EntityOwner)& anOwner = aSens->BaseSensitive()->OwnerId();
if (!myMapOwnerColors.IsBound (anOwner))
{
Standard_Integer aSelectionMode = -1;
const Handle(SelectMgr_SelectableObject)& aSelectable = myMainSel->Picked (thePicked)->Selectable();
const Handle(SelectBasics_SensitiveEntity)& anEntity = myMainSel->PickedEntity (thePicked);
- for (aSelectable->Init(); aSelectable->More(); aSelectable->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (aSelectable->Selections()); aSelIter.More(); aSelIter.Next())
{
- const Handle(SelectMgr_Selection)& aSelection = aSelectable->CurrentSelection();
- for (aSelection->Init(); aSelection->More(); aSelection->Next())
+ const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- if (aSelection->Sensitive()->BaseSensitive() == anEntity)
+ if (aSelEntIter.Value()->BaseSensitive() == anEntity)
{
aSelectionMode = aSelection->Mode();
break;
puts "============"
-puts "OCC24966"
+puts "0024966: Visualization - Problem in local selection mode with selected objects staying in the viewer after erase"
+puts "Selected entity owners coming from decomposition are not erased in local selection context"
puts "============"
puts ""
-####################################################################################
-# Visualization - Problem in local selection mode with selected objects staying
-# in the viewer after erase
-# Selected entity owners coming from decomposition are not erased in local selection
-# context
-####################################################################################
+pload MODELING VISUALIZATION
+vclear
vinit View1
-pload ALL
-vinit
vertex p1 100 100 0
vertex p2 150 300 0
vselect 0 0 2500 2500
verase -local
-if { "[vreadpixel 261 204 rgb name]" != "BLACK" } {
- puts "Error : Selection is not erased."
-}
+if { "[vreadpixel 261 204 rgb name]" != "BLACK" } { puts "Error : Selection is not erased." }
vdump ${imagedir}/${casename}.png
puts "============"
-puts "CR24996"
+puts "0024996: Visualization - newly displayed objects are clipped until first camera movement"
puts "============"
puts ""
-#######################################################################
-# Visualization - newly displayed objects are clipped until first camera movement
-#######################################################################
box b1 0 0 0 1 2 3
box b2 3 2 1 1 2 3
box b3 5 -4 0 1 2 3
-vinit
vclear
+vinit View1
vaxo
-vsetdispmode 0
-vdisplay b1
+vdisplay -dispMode 0 b1
vfit
vzoom 0.25
-vdisplay b2 b3
+vdisplay -dispMode 0 b2 b3
-set anImage ${imagedir}/${casename}.png
-vdump ${anImage}
+vdump ${imagedir}/${casename}.png
int aRowId = Row();
int aCurrentIndex = 0;
- for (anIO->Init(); anIO->More() && anOwner.IsNull(); anIO->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More() && anOwner.IsNull(); aSelIter.Next())
{
- const Handle(SelectMgr_Selection)& aSelection = anIO->CurrentSelection();
- for (aSelection->Init(); aSelection->More() && anOwner.IsNull(); aSelection->Next())
+ const Handle(SelectMgr_Selection)& aSelection = aSelIter.Value();
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More() && anOwner.IsNull(); aSelEntIter.Next())
{
- Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
+ Handle(SelectMgr_SensitiveEntity) anEntity = aSelEntIter.Value();
const Handle(SelectBasics_SensitiveEntity)& aBase = anEntity->BaseSensitive();
if (!aBase.IsNull())
{
// =======================================================================
int VInspector_ItemPresentableObject::initRowCount() const
{
- int aRows = 0;
Handle(AIS_InteractiveObject) anIO = GetInteractiveObject();
- if (anIO.IsNull())
- return aRows;
- // iteration through sensitive privitives
- for (anIO->Init(); anIO->More(); anIO->Next())
- aRows++;
-
- return aRows;
+ return !anIO.IsNull()
+ ? anIO->Selections().Size()
+ : 0;
}
// =======================================================================
// =======================================================================
int VInspector_ItemSelection::initRowCount() const
{
- int aRows = 0;
Handle(SelectMgr_Selection) aSelection = getSelection();
- for (aSelection->Init(); aSelection->More(); aSelection->Next())
- aRows++;
-
- return aRows;
+ return aSelection->Entities().Size();
}
// =======================================================================
if (aState == SelectMgr_SOS_Activated || aState == SelectMgr_SOS_Any)
{
Handle(AIS_InteractiveContext) aContext = GetContext();
- for (mySelection->Init(); mySelection->More(); mySelection->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (mySelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- const Handle(SelectBasics_EntityOwner)& anOwner = mySelection->Sensitive()->BaseSensitive()->OwnerId();
+ const Handle(SelectBasics_EntityOwner)& anOwner = aSelEntIter.Value()->BaseSensitive()->OwnerId();
if (VInspector_Tools::IsOwnerSelected(aContext, anOwner))
aNbSelected++;
}
int aRowId = Row();
int aCurrentId = 0;
- for (anIO->Init(); anIO->More(); anIO->Next(), aCurrentId++)
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next(), aCurrentId++)
{
if (aCurrentId != aRowId)
continue;
- mySelection = anIO->CurrentSelection();
+ mySelection = aSelIter.Value();
break;
}
TreeModel_ItemBase::Init();
int aRowId = Row();
int aCurrentId = 0;
- for (aSelection->Init(); aSelection->More(); aSelection->Next(), aCurrentId++)
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next(), aCurrentId++)
{
if (aCurrentId != aRowId)
continue;
- myEntity = aSelection->Sensitive();
+ myEntity = aSelEntIter.Value();
break;
}
TreeModel_ItemBase::Init();
Handle(AIS_InteractiveObject) anIO = aIt.Value();
if (anIO.IsNull())
continue;
- for (anIO->Init(); anIO->More(); anIO->Next())
+ for (SelectMgr_SequenceOfSelection::Iterator aSelIter (anIO->Selections()); aSelIter.More(); aSelIter.Next())
{
- Handle(SelectMgr_Selection) aSelection = anIO->CurrentSelection();
+ Handle(SelectMgr_Selection) aSelection = aSelIter.Value();
if (aSelection.IsNull())
continue;
- for (aSelection->Init(); aSelection->More(); aSelection->Next())
+ for (NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator aSelEntIter (aSelection->Entities()); aSelEntIter.More(); aSelEntIter.Next())
{
- Handle(SelectMgr_SensitiveEntity) anEntity = aSelection->Sensitive();
+ Handle(SelectMgr_SensitiveEntity) anEntity = aSelEntIter.Value();
if (anEntity.IsNull())
continue;
const Handle(SelectBasics_SensitiveEntity)& aBase = anEntity->BaseSensitive();