namespace
{
- TopoDS_Shape AIS_myDummyShape;
-}
-
-static Standard_Integer GetHiMod(const Handle(AIS_InteractiveObject)& IO)
-{
- return IO->HasHilightMode() ? IO->HilightMode():0;
+ TopoDS_Shape AIS_LocalContext_myDummyShape;
}
//==================================================
//function : AddSelect
//purpose :
//=======================================================================
-AIS_StatusOfPick AIS_LocalContext::AddSelect (const Handle(Standard_Transient)& theObject)
+AIS_StatusOfPick AIS_LocalContext::AddSelect (const Handle(SelectMgr_EntityOwner)& theObject)
{
mySelection->AddSelect (theObject);
if (aDetIndex <= 0)
{
ClearSelected (toUpdateViewer);
- return (mySelection->Extent() == 0) ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
+ return mySelection->IsEmpty() ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
}
const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner->FindKey (aDetIndex);
if (myAutoHilight)
{
const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
- for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
+ for (V3d_ListOfViewIterator anActiveViewIter (aViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
{
- Unhilight (anOwner, aViewer->ActiveView());
+ Unhilight (anOwner, anActiveViewIter.Value());
}
// advanced selection highlighting mechanism
}
Standard_Integer aSelNum = mySelection->Extent();
-
- myMainVS->Init();
- if (!myMainVS->More())
+ if (myMainVS->NbPicked() == 0)
{
ClearSelected (toUpdateViewer);
mylastindex = 0;
ClearSelected (Standard_False);
- for (myMainVS->Init(); myMainVS->More(); myMainVS->Next())
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainVS->NbPicked(); ++aPickIter)
{
- const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked();
+ const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked (aPickIter);
if (myFilters->IsOk (anOwner))
{
// it can be helpful to classify this owner immediately...
myMainVS->Pick (thePolyline, theView);
Standard_Integer aLastSelNum = mySelection->Extent();
- myMainVS->Init();
- if (!myMainVS->More())
+ if (myMainVS->NbPicked() == 0)
{
// Nothing is selected clear selection.
ClearSelected (toUpdateViewer);
// Clear previous selection without update to process this selection
ClearSelected (Standard_False);
- for (myMainVS->Init(); myMainVS->More(); myMainVS->Next())
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainVS->NbPicked(); ++aPickIter)
{
- const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked();
+ const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked (aPickIter);
if (myFilters->IsOk (anOwner))
{
// it can be helpful to classify this owner immediately...
{
myMainPM->ClearImmediateDraw();
const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
- for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
+ for (V3d_ListOfViewIterator anActiveViewIter (aViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
{
- Unhilight (anOwner, aViewer->ActiveView());
+ Unhilight (anOwner, anActiveViewIter.Value());
}
// advanced selection highlighting mechanism
myMainVS->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
Standard_Integer aLastSelNum = mySelection->Extent();
-
- myMainVS->Init();
- if (!myMainVS->More())
+ if (myMainVS->NbPicked() == 0)
{
// Nothing is selected clear selection, but don't clear the selection
// as it is shift selection and previous selection matters.
UnhilightPicked (Standard_False);
}
- for (myMainVS->Init(); myMainVS->More(); myMainVS->Next())
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainVS->NbPicked(); ++aPickIter)
{
- const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked();
+ const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked (aPickIter);
if(myFilters->IsOk (anOwner))
{
Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True;
myMainVS->Pick (thePolyline, theView);
Standard_Integer aLastSelNum = mySelection->Extent();
- myMainVS->Init();
- if(!myMainVS->More())
+ if (myMainVS->NbPicked() == 0)
{
// Nothing is selected clear selection, but don't clear the selection
// as it is shift selection and previous selection matters.
UnhilightPicked (Standard_False);
}
- for (myMainVS->Init(); myMainVS->More(); myMainVS->Next())
+ for (Standard_Integer aPickIter = 1; aPickIter <= myMainVS->NbPicked(); ++aPickIter)
{
- const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked();
+ const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked (aPickIter);
if (myFilters->IsOk (anOwner))
{
Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True;
return;
}
- const Standard_Integer aHilightMode = GetHiMod (Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()));
+ const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
+ const Handle(Prs3d_Drawer)& aHiStyle = myCTX->getHiStyle (anObj, theOwner);
+ const Standard_Integer aHiMode = myCTX->getHilightMode (anObj, aHiStyle, -1);
myMainPM->BeginImmediateDraw();
- theOwner->HilightWithColor (myMainPM, myCTX->HilightColor(), aHilightMode);
+ theOwner->HilightWithColor (myMainPM, aHiStyle, aHiMode);
myMainPM->EndImmediateDraw (theView->Viewer());
}
return;
}
- const Standard_Integer aHilightMode = GetHiMod (Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()));
+ const Handle(AIS_InteractiveObject) anObj = Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable());
if (IsSelected (theOwner))
{
if (theOwner->IsAutoHilight())
{
- theOwner->HilightWithColor (myMainPM, myCTX->SelectionColor(), aHilightMode);
+ const Handle(Prs3d_Drawer)& aSelStyle = myCTX->getSelStyle (anObj, theOwner);
+ const Standard_Integer aHiMode = myCTX->getHilightMode (anObj, aSelStyle, -1);
+ theOwner->HilightWithColor (myMainPM, aSelStyle, aHiMode);
}
}
else
{
- theOwner->Unhilight (myMainPM, aHilightMode);
+ theOwner->Unhilight (myMainPM);
}
}
//=======================================================================
//function : HilightPicked
-//purpose :
+//purpose :
//=======================================================================
-void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer)
+void AIS_LocalContext::HilightPicked (const Standard_Boolean theToUpdateviewer)
{
- if( mySelection.IsNull() ) return;
+ if (mySelection.IsNull())
+ {
+ return;
+ }
- typedef NCollection_DataMap <Handle(SelectMgr_SelectableObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > SelectMgr_DataMapOfObjectOwners;
+ typedef NCollection_Shared<SelectMgr_SequenceOfOwner> SelectMgr_HSequenceOfOwner;
+ typedef NCollection_DataMap <Handle(SelectMgr_SelectableObject), Handle(SelectMgr_HSequenceOfOwner) > SelectMgr_DataMapOfObjectOwners;
SelectMgr_DataMapOfObjectOwners aMap;
- Handle (PrsMgr_PresentationManager3d) PM = myMainPM;
-
// to avoid problems when there is a loop searching for selected objects...
- const AIS_NListTransient& Obj = mySelection->Objects();
- AIS_NListTransient::Iterator anIter( Obj );
- for(; anIter.More(); anIter.Next())
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- const Handle(Standard_Transient)& Tr = anIter.Value();
- if(!Tr.IsNull()){
- const Handle(SelectMgr_EntityOwner)& Ownr =
- *((const Handle(SelectMgr_EntityOwner)*) &Tr);
- Handle(AIS_InteractiveObject) IO;
- if(Ownr->HasSelectable()){
- Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(Ownr);
- if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
- Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
- IO = Handle(AIS_InteractiveObject)::DownCast (SO);
- }
- }
- Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
- Standard_Integer HM = GetHiMod(Handle(AIS_InteractiveObject)::DownCast (SO));
- if ( Ownr->IsAutoHilight() )
- Ownr->HilightWithColor(PM,myCTX->SelectionColor(),HM);
- else if ( aMap.IsBound (SO) )
- aMap(SO)->Append ( Ownr );
- else {
- NCollection_Handle<SelectMgr_SequenceOfOwner> aSeq = new SelectMgr_SequenceOfOwner;
- aSeq->Append ( Ownr );
- aMap.Bind ( SO, aSeq );
- }
+ const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value();
+ Handle(SelectMgr_SelectableObject) aSelObj = anOwner->Selectable();
+ if (anOwner->IsAutoHilight())
+ {
+ Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(aSelObj);
+ const Handle(Prs3d_Drawer)& aSelStyle = myCTX->getSelStyle (anIO, anOwner);
+ const Standard_Integer aHiMode = myCTX->getHilightMode (anIO, aSelStyle, -1);
+ anOwner->HilightWithColor (myMainPM, aSelStyle, aHiMode);
+ continue;
+ }
+
+ Handle(SelectMgr_HSequenceOfOwner) aSeq;
+ if (aMap.Find (aSelObj, aSeq))
+ {
+ aSeq->Append (anOwner);
+ }
+ else
+ {
+ aSeq = new SelectMgr_HSequenceOfOwner();
+ aSeq->Append (anOwner);
+ aMap.Bind (aSelObj, aSeq);
}
}
- for ( SelectMgr_DataMapOfObjectOwners::Iterator aMapIter(aMap);
- aMapIter.More(); aMapIter.Next() )
+ for (SelectMgr_DataMapOfObjectOwners::Iterator aMapIter (aMap); aMapIter.More(); aMapIter.Next())
{
aMapIter.Key()->HilightSelected (myMainPM, *aMapIter.Value());
}
- if (updateviewer)
+ if (theToUpdateviewer)
{
myCTX->CurrentViewer()->Update();
}
}
//==================================================
-// Function:
+// Function: UnhilightPicked
// Purpose :
//==================================================
-void AIS_LocalContext::UnhilightPicked (const Standard_Boolean updateviewer)
+void AIS_LocalContext::UnhilightPicked (const Standard_Boolean theToUpdateViewer)
{
myMainPM->ClearImmediateDraw();
+ if (mySelection.IsNull())
+ {
+ return;
+ }
- if( mySelection.IsNull() ) return;
- Handle (PrsMgr_PresentationManager3d) PM = myMainPM;
NCollection_Map<Handle(SelectMgr_SelectableObject)> anObjMap;
-
- const AIS_NListTransient& Obj = mySelection->Objects();
- AIS_NListTransient::Iterator anIter( Obj );
- for(; anIter.More(); anIter.Next()){
- const Handle(Standard_Transient)& Tr = anIter.Value();
- if(!Tr.IsNull()){
- const Handle(SelectMgr_EntityOwner)& Ownr =
- *((const Handle(SelectMgr_EntityOwner)*) &Tr);
- Standard_Integer HM(0);
- if(Ownr->HasSelectable()){
- Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
- Handle(AIS_InteractiveObject) IO = Handle(AIS_InteractiveObject)::DownCast (SO);
- anObjMap.Add (IO);
-
- HM = GetHiMod(IO);
- Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(Ownr);
- if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
- }
- }
- Ownr->Unhilight(PM,HM);
- }
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
+ {
+ const Handle(SelectMgr_EntityOwner)& anOwner = aSelIter.Value();
+ Handle(SelectMgr_SelectableObject) aSelObj = anOwner->Selectable();
+ Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (aSelObj);
+ anObjMap.Add (aSelObj);
+ anOwner->Unhilight (myMainPM);
}
-
- for (NCollection_Map<Handle(SelectMgr_SelectableObject)>::Iterator anIter1 ( anObjMap );
- anIter1.More(); anIter1.Next() )
+
+ for (NCollection_Map<Handle(SelectMgr_SelectableObject)>::Iterator aMapIter (anObjMap);
+ aMapIter.More(); aMapIter.Next())
{
- if ( !anIter1.Key()->IsAutoHilight() )
- anIter1.Key()->ClearSelected();
+ if (!aMapIter.Key()->IsAutoHilight())
+ {
+ aMapIter.Key()->ClearSelected();
+ }
}
- if(updateviewer)
+ if (theToUpdateViewer)
+ {
myCTX->CurrentViewer()->Update();
+ }
}
//=======================================================================
}
//==================================================
-// Function:
+// Function: HasShape
// Purpose :
//==================================================
-Standard_Boolean AIS_LocalContext::
-HasShape() const
+Standard_Boolean AIS_LocalContext::HasShape() const
{
- Handle(Standard_Transient) Tr = mySelection->Value();
- if( Tr.IsNull() ) return Standard_False;
- Handle(SelectMgr_EntityOwner) EO = Handle(SelectMgr_EntityOwner)::DownCast (Tr);
- Handle(StdSelect_BRepOwner) BRO = Handle(StdSelect_BRepOwner)::DownCast(EO);
- if(BRO.IsNull()) return Standard_False;
- Standard_Boolean hasshape = BRO->HasShape();
- Standard_Boolean comes = BRO->ComesFromDecomposition();
- return (hasshape&&comes);
+ if (!mySelection->More())
+ {
+ return Standard_False;
+ }
+
+ Handle(StdSelect_BRepOwner) aBROwner = Handle(StdSelect_BRepOwner)::DownCast(mySelection->Value());
+ return !aBROwner.IsNull()
+ && aBROwner->HasShape()
+ && aBROwner->ComesFromDecomposition();
}
//================================================================
//================================================================
Standard_Boolean AIS_LocalContext::HasSelectedShape() const
{
- if (mySelection->Extent() == 0)
- return Standard_False;
-
- Handle(Standard_Transient) aCurSelection = mySelection->Value();
- if (aCurSelection.IsNull())
- return Standard_False;
-
- Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (aCurSelection);
- Handle(StdSelect_BRepOwner) aBrepOwner = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
- if (aBrepOwner.IsNull())
+ if (!mySelection->More())
{
return Standard_False;
}
- return aBrepOwner->HasShape();
+
+ Handle(StdSelect_BRepOwner) aBrepOwner = Handle(StdSelect_BRepOwner)::DownCast (mySelection->Value());
+ return !aBrepOwner.IsNull()
+ && aBrepOwner->HasShape();
}
//==================================================
-// Function:
+// Function: SelectedShape
// Purpose :
//==================================================
TopoDS_Shape AIS_LocalContext::SelectedShape() const
{
- Handle(Standard_Transient) aTr = mySelection->Value();
- Handle(SelectMgr_EntityOwner) anEO = Handle(SelectMgr_EntityOwner)::DownCast (aTr);
- Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(anEO);
- if( aBRO.IsNull() )
+ if (!mySelection->More())
+ {
+ return TopoDS_Shape();
+ }
+
+ Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(mySelection->Value());
+ if (aBRO.IsNull())
{
return TopoDS_Shape();
}
}
//==================================================
-// Function:
+// Function: SelectedInteractive
// Purpose :
//==================================================
-Handle(AIS_InteractiveObject) AIS_LocalContext::
-SelectedInteractive() const
+Handle(AIS_InteractiveObject) AIS_LocalContext::SelectedInteractive() const
{
- Handle(AIS_InteractiveObject) IO;
- Handle(Standard_Transient) Tr = mySelection->Value();
- if( !Tr.IsNull() ) {
- Handle(SelectMgr_EntityOwner) EO = Handle(SelectMgr_EntityOwner)::DownCast (Tr);
- Handle(SelectMgr_SelectableObject) SO;
- if(EO->HasSelectable()){
- SO = EO->Selectable();
- IO = Handle(AIS_InteractiveObject)::DownCast (SO);
- }
- }
- return IO;
+ return !mySelection->More()
+ ? Handle(AIS_InteractiveObject)()
+ : Handle(AIS_InteractiveObject)::DownCast (mySelection->Value()->Selectable());
}
+
//==================================================
-// Function:
+// Function: SelectedOwner
// Purpose :
//==================================================
-Handle(SelectMgr_EntityOwner) AIS_LocalContext::
-SelectedOwner() const
+Handle(SelectMgr_EntityOwner) AIS_LocalContext::SelectedOwner() const
{
- Handle(SelectMgr_EntityOwner) EO;
- Handle(Standard_Transient) Tr = mySelection->Value();
- if( !Tr.IsNull() )
- EO = Handle(SelectMgr_EntityOwner)::DownCast (Tr);
- return EO;
+ return !mySelection->More()
+ ? Handle(SelectMgr_EntityOwner)()
+ : mySelection->Value();
}
//==================================================
// Function:
// Purpose :
//==================================================
-Standard_Boolean AIS_LocalContext::
-HasApplicative() const
+Standard_Boolean AIS_LocalContext::HasApplicative() const
{
- Handle(AIS_InteractiveObject) IO = SelectedInteractive();
- if( IO.IsNull() ) return Standard_False;
- return IO->HasOwner();
+ Handle(AIS_InteractiveObject) anIO = SelectedInteractive();
+ return !anIO.IsNull()
+ && anIO->HasOwner();
}
//==================================================
return;
SelectMgr_SequenceOfOwner aSeq;
- for (mySelection->Init(); mySelection->More(); mySelection->Next() ){
- Handle(SelectMgr_EntityOwner) aOwner = Handle(SelectMgr_EntityOwner)::DownCast(mySelection->Value());
-
- if ( !aOwner.IsNull() && aOwner->HasSelectable() && aOwner->Selectable() == anobj )
- aSeq.Append( aOwner );
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
+ {
+ if (aSelIter.Value()->IsSameSelectable (anobj))
+ {
+ aSeq.Append (aSelIter.Value());
+ }
}
if ( aSeq.Length() )
void AIS_LocalContext::ClearSelected (const Standard_Boolean updateviewer)
{
UnhilightPicked(updateviewer);
-
- const AIS_NListTransient& Obj = mySelection->Objects();
- AIS_NListTransient::Iterator anIter( Obj );
- for(; anIter.More(); anIter.Next()){
- const Handle(Standard_Transient)& Tr = anIter.Value();
- if(!Tr.IsNull())
- {
- (*((const Handle(SelectMgr_EntityOwner)*)&Tr))->SetSelected (Standard_False);
- }
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
+ {
+ aSelIter.Value()->SetSelected (Standard_False);
}
- mySelection->Select();
+ mySelection->Clear();
mylastindex = 0;
}
for (Standard_Integer anIdx = 1; anIdx <= myDetectedSeq.Length(); ++anIdx)
{
Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myDetectedSeq (anIdx));
- if (anOwner.IsNull() || anOwner->Selectable() != theIO || aValidOwners.Contains (anOwner))
+ if (anOwner.IsNull() || !anOwner->IsSameSelectable (theIO) || aValidOwners.Contains (anOwner))
{
continue;
}
// 3. AIS_Selection : remove entity owners from AIS_Selection
const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
- AIS_NListTransient::Iterator anIter (mySelection->Objects());
- AIS_NListTransient aRemoveEntites;
- for (; anIter.More(); anIter.Next())
+ NCollection_List<Handle(SelectMgr_EntityOwner)> aRemoveEntites;
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
{
- Handle(SelectMgr_EntityOwner) anOwner = Handle(SelectMgr_EntityOwner)::DownCast (anIter.Value());
- if (anOwner.IsNull() || anOwner->Selectable() != theIO)
+ Handle(SelectMgr_EntityOwner) anOwner = aSelIter.Value();
+ if (!anOwner->IsSameSelectable (theIO))
{
continue;
}
{
aRemoveEntites.Append (anOwner);
anOwner->SetSelected (Standard_False);
- for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
+ for (V3d_ListOfViewIterator anActiveViewIter (aViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
{
- Unhilight (anOwner, aViewer->ActiveView());
+ Unhilight (anOwner, anActiveViewIter.Value());
}
}
}
- AIS_NListTransient::Iterator anIterRemove (aRemoveEntites);
- for (; anIterRemove.More(); anIterRemove.Next())
+
+ for (NCollection_List<Handle(SelectMgr_EntityOwner)>::Iterator anIterRemove (aRemoveEntites);
+ anIterRemove.More(); anIterRemove.Next())
{
mySelection->Select (anIterRemove.Value());
}
continue;
}
- if (anOwner->Selectable() != theIO || aValidOwners.Contains (anOwner))
+ if (!anOwner->IsSameSelectable (theIO) || aValidOwners.Contains (anOwner))
{
anOwnersToKeep.Add (anOwner);
}
else
{
- for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
+ for (V3d_ListOfViewIterator anActiveViewIter (aViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
{
- Unhilight (anOwner, aViewer->ActiveView());
+ Unhilight (anOwner, anActiveViewIter.Value());
}
}
}
// Last detected owner was removed. First object from sequence become detected.
// Pass any active view because in current implementation the highlighting is
// synchronized in all view.
- aViewer->InitActiveViews();
manageDetected (myMainVS->Picked (myDetectedSeq.First()),
- aViewer->ActiveView(),
+ aViewer->ActiveViewIterator().Value(),
Standard_False);
}
}
//1st case, owner already <anIObj> as owner
// and not separated is found...
- Handle(Standard_Transient) Tr;
Handle(SelectMgr_EntityOwner) EO = FindSelectedOwnerFromIO(anIObj);
if(EO.IsNull()){
- //check if in selection number 0 there is an owner that can be triturated...
- if(anIObj->HasSelection(0)){
- const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
- SIOBJ->Init();
- if(SIOBJ->More()){
- Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->BaseSensitive()->OwnerId();
- EO = Handle(SelectMgr_EntityOwner)::DownCast (BO);
- }
+ //check if global selection there is an owner that can be triturated...
+ if (anIObj->HasSelection (anIObj->GlobalSelectionMode()))
+ {
+ EO = anIObj->GlobalSelOwner();
}
if(EO.IsNull())
EO = new SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)anIObj);
if (EO.IsNull())
{
- if(anIObj->HasSelection(0))
+ if(anIObj->HasSelection (anIObj->GlobalSelectionMode()))
{
- const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
- SIOBJ->Init();
- if(SIOBJ->More()){
- Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->BaseSensitive()->OwnerId();
- EO = Handle(SelectMgr_EntityOwner)::DownCast (BO);
- }
+ EO = anIObj->GlobalSelOwner();
}
if(EO.IsNull())
{
if(mylastindex != 0)
{
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(myMapOfOwner->FindKey (mylastindex));
- if(BROwnr.IsNull()) return AIS_myDummyShape;
+ if(BROwnr.IsNull()) return AIS_LocalContext_myDummyShape;
return BROwnr->Shape();
}
- return AIS_myDummyShape;
+ return AIS_LocalContext_myDummyShape;
}
//=======================================================================
//purpose :
//=======================================================================
Standard_Boolean AIS_LocalContext::UnhilightLastDetected (const Handle(V3d_View)& theView)
+{
+ return UnhilightLastDetected (theView->Viewer());
+}
+
+//=======================================================================
+//function : UnhilightLastDetected
+//purpose :
+//=======================================================================
+Standard_Boolean AIS_LocalContext::UnhilightLastDetected (const Handle(V3d_Viewer)& theViewer)
{
if (!IsValidIndex (mylastindex))
{
myMainPM->BeginImmediateDraw();
const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner->FindKey (mylastindex);
- const Standard_Integer aHilightMode = anOwner->HasSelectable()
- ? GetHiMod (Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()))
- : 0;
-
- myMapOfOwner->FindKey (mylastindex)->Unhilight (myMainPM, aHilightMode);
- myMainPM->EndImmediateDraw (theView->Viewer());
+ anOwner->Unhilight (myMainPM);
+ myMainPM->EndImmediateDraw (theViewer);
mylastindex = 0;
return Standard_True;
}
//function : FindSelectedOwnerFromIO
//purpose : it is checked if one of the selected owners really presents IObj
//=======================================================================
-Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromIO
- (const Handle(AIS_InteractiveObject)& anIObj) const
+Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromIO (const Handle(AIS_InteractiveObject)& theObj) const
{
Handle(SelectMgr_EntityOwner) EO,bid;
- if (anIObj.IsNull()) return EO;
-
- if(mySelection.IsNull()) {
-#ifdef OCCT_DEBUG
- cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection "
- <<mySelName<<" Nulle "<<endl;
-#endif
- return EO;
+ if (theObj.IsNull()
+ || mySelection.IsNull())
+ {
+ return Handle(SelectMgr_EntityOwner)();
}
- Standard_Boolean found(Standard_False);
- const AIS_NListTransient& Obj = mySelection->Objects();
- AIS_NListTransient::Iterator anIter( Obj );
- for(; anIter.More(); anIter.Next()){
- const Handle(Standard_Transient)& Tr = anIter.Value();
- if(!Tr.IsNull()){
- EO = Handle(SelectMgr_EntityOwner)::DownCast (Tr);
- if(EO->HasSelectable()){
- Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(EO);
- if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
- if (anIObj == EO->Selectable()){
- found =Standard_True;
- break;
- }
- }
- }
+
+ for (AIS_NListOfEntityOwner::Iterator aSelIter (mySelection->Objects()); aSelIter.More(); aSelIter.Next())
+ {
+ if (!aSelIter.Value()->IsSameSelectable (theObj))
+ {
+ continue;
+ }
+
+ Handle(StdSelect_BRepOwner) aBROwner = Handle(StdSelect_BRepOwner)::DownCast(aSelIter.Value());
+ if (aBROwner.IsNull()
+ || !aBROwner->ComesFromDecomposition())
+ {
+ return aSelIter.Value();
}
}
- if(found) return EO;
- return bid;
+ return Handle(SelectMgr_EntityOwner)();
}
//=======================================================================
if (sh.IsNull()) return EO;
if(mySelection.IsNull()) {
-#ifdef OCCT_DEBUG
- cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection "<<mySelName<<" Nulle "<<endl;
-#endif
return EO;
}
if (aCurrentShape.IsNull())
{
- return AIS_myDummyShape;
+ return AIS_LocalContext_myDummyShape;
}
return aCurrentShape->Shape();