// - use of optimisation in SelectMgr_ViewerSelector
// -> Best management in detected entities...
-#define BUC60569 //GG_051199 Enable to select the local context
-// in any case and especially in multi selection mode.
-// Note that right now when an hilighted owner is selected
-// this owner is unhilighted,this permits to see the selection!
-// Principle : an owner can have 3 state :
-// 1 : The owner is selected and no more highlightable
-// 0 : The owner is NOT selected
-// -1: The owner is selected but stay highlightable (NEW)
-
-// IMP230600 //GG Add protection on selection methodes
-// when nothing is selected
-
-#define BUC60726 //GG_040900 When nothing is detected,
-// Clear the last temporary stuff in any case
-
-#define BUC60765 //GG_121000 Avoid to raise when the same selection
-// is attached to several local context.
-
-#define BUC60771 //GG_261000 Avoid to crash after closing a view
-// containing a selected entity and creating a new one.
-
-#define BUC60774 //GG_261000 Returns right select status on
-// bounding-box selection type.
-
-#define BUC60818 //GG_300101 Enable detection even if
-// SetAutomaticHilight(FALSE) has been used.
-
-#define IMP300101 //GG Enable to use polygon highlighting
-
-#define BUC60876 //GG_050401 Clear selection always even
-// if the current highlight mode is not 0.
-
-#define BUC60953 //SAV_060701 For Select optimization. Selection by rectangle case.
-// for single selection no optimization done.
-
-#define IMP120701 //SZV made a shape valid for selection
-// when required.
-
-#define IMP160701 //SZV Add InitDetected(),MoreDetected(),NextDetected(),
-// DetectedCurrentShape(),DetectedCurrentObject()
-// methods
-
-#define OCC138 //VTN Avoding infinit loop in AddOrRemoveSelected method.
-
-#define OCC189 //SAV: 18/03/02 AIS_Selection::Objects() returns ListOfTransient
-// instead of array.
-
-#define USE_MAP //san : 18/04/03 USE_MAP - additional datamap is used to speed up access
-//to certain owners in AIS_Selection::myresult list
-
-#define OCC9026 //AEL Performance optimization of the FindSelectedOwnerFromShape() method.
-
-#include <AIS_LocalContext.jxx>
-#include <StdSelect_BRepOwner.hxx>
-#include <TColStd_ListOfInteger.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-#include <TColStd_MapOfTransient.hxx>
-#include <TColStd_MapIteratorOfMapOfTransient.hxx>
-#include <Prs3d_Presentation.hxx>
-#include <Prs3d_Drawer.hxx>
-#include <Prs3d_ShadingAspect.hxx>
+#include <AIS_InteractiveContext.hxx>
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_LocalContext.hxx>
#include <AIS_LocalStatus.hxx>
-#include <StdPrs_WFShape.hxx>
+#include <AIS_Selection.hxx>
+#include <AIS_Shape.hxx>
+#include <Aspect_Grid.hxx>
+#include <Geom_Transformation.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
#include <Graphic3d_Group.hxx>
+#include <NCollection_Map.hxx>
+#include <OSD_Environment.hxx>
+#include <Prs3d_Drawer.hxx>
+#include <Prs3d_Presentation.hxx>
+#include <Prs3d_ShadingAspect.hxx>
#include <Select3D_SensitiveTriangulation.hxx>
#include <SelectBasics_SensitiveEntity.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <NCollection_Map.hxx>
-
-#ifdef OCC9026
-#include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
-#endif
+#include <SelectMgr_EntityOwner.hxx>
+#include <SelectMgr_Filter.hxx>
+#include <SelectMgr_OrFilter.hxx>
+#include <SelectMgr_SelectableObject.hxx>
#include <SelectMgr_Selection.hxx>
+#include <SelectMgr_SelectionManager.hxx>
#include <SelectMgr_SequenceOfOwner.hxx>
-#include <OSD_Environment.hxx>
-
-#include <Geom_Transformation.hxx>
-#include <AIS_Selection.hxx>
-#include <Aspect_Grid.hxx>
-#ifdef IMP120701
-#include <AIS_Shape.hxx>
-#endif
+#include <Standard_Transient.hxx>
+#include <StdSelect_BRepOwner.hxx>
+#include <StdSelect_ViewerSelector3d.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListOfInteger.hxx>
+#include <TColStd_MapIteratorOfMapOfTransient.hxx>
+#include <TColStd_MapOfTransient.hxx>
+#include <V3d_View.hxx>
+namespace
+{
+ TopoDS_Shape AIS_myDummyShape;
+}
static Standard_Integer GetHiMod(const Handle(AIS_InteractiveObject)& IO)
{
return IO->HasHilightMode() ? IO->HilightMode():0;
}
+//=======================================================================
+//function : getHiStyle
+//purpose :
+//=======================================================================
+const Handle(Graphic3d_HighlightStyle)& AIS_LocalContext::getHiStyle (const Handle(SelectMgr_SelectableObject)& theObj) const
+{
+ const Handle(Prs3d_Drawer)& aHiDrawer = theObj->HilightAttributes();
+ return !aHiDrawer.IsNull() && aHiDrawer->HasOwnHighlightStyle()
+ ? aHiDrawer->HighlightStyle() : myCTX->HighlightStyle();
+}
+
+//=======================================================================
+//function : getSelStyle
+//purpose :
+//=======================================================================
+const Handle(Graphic3d_HighlightStyle)& AIS_LocalContext::getSelStyle (const Handle(AIS_InteractiveObject)& theObj) const
+{
+ const Handle(Prs3d_Drawer)& aHiDrawer = theObj->HilightAttributes();
+ return !aHiDrawer.IsNull() && aHiDrawer->HasOwnSelectionStyle()
+ ? aHiDrawer->SelectionStyle() : myCTX->SelectionStyle();
+}
+
//==================================================
// Function: MoveTo
// Purpose :
myCurDetected = 0;
myDetectedSeq.Clear();
+ myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
myMainVS->Pick (theXpix, theYpix, theView);
const Standard_Integer aDetectedNb = myMainVS->NbPicked();
// result of courses..
if (aDetectedNb == 0 || myDetectedSeq.IsEmpty())
{
- if (mylastindex != 0 && mylastindex <= myMapOfOwner.Extent())
+ if (mylastindex != 0 && mylastindex <= myMapOfOwner->Extent())
{
myMainPM->ClearImmediateDraw();
- Unhilight (myMapOfOwner (mylastindex), theView);
+ Unhilight (myMapOfOwner->FindKey (mylastindex), theView);
if (theToRedrawImmediate)
{
theView->RedrawImmediate();
}
}
+//=======================================================================
+//function : AddSelect
+//purpose :
+//=======================================================================
+AIS_StatusOfPick AIS_LocalContext::AddSelect (const Handle(SelectMgr_EntityOwner)& theObject)
+{
+ mySelection->AddSelect (theObject);
+
+ Standard_Integer aSelNum = mySelection->Extent();
+ return (aSelNum == 1) ? AIS_SOP_OneSelected
+ : (aSelNum > 1) ? AIS_SOP_SeveralSelected
+ : AIS_SOP_Error;
+}
+
//=======================================================================
//function : Select
//purpose :
UnhilightPicked (Standard_False);
}
- AIS_Selection::SetCurrentSelection (mySelName.ToCString());
-
Standard_Integer aDetIndex = DetectedIndex();
if (aDetIndex <= 0)
{
ClearSelected (toUpdateViewer);
- return (AIS_Selection::Extent() == 0) ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
+ return mySelection->IsEmpty() ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
}
- const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner (aDetIndex);
+ const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner->FindKey (aDetIndex);
ClearSelected (Standard_False);
if (!anOwner->IsSelected()) // anOwner is not selected
{
anOwner->SetSelected (Standard_True);
- AIS_Selection::Select (anOwner);
+ mySelection->Select (anOwner);
}
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
}
}
- return (AIS_Selection::Extent() == 1) ? AIS_SOP_OneSelected : AIS_SOP_SeveralSelected;
+ return (mySelection->Extent() == 1) ? AIS_SOP_OneSelected : AIS_SOP_SeveralSelected;
}
//=======================================================================
UnhilightPicked (Standard_False);
}
- AIS_Selection::SetCurrentSelection (mySelName.ToCString());
- Standard_Integer aSelNum = AIS_Selection::Extent();
-
- myMainVS->Init();
- if (!myMainVS->More())
+ Standard_Integer aSelNum = mySelection->Extent();
+ 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...
if (!anOwner->IsSelected())
{
anOwner->SetSelected (Standard_True);
- AIS_Selection::Select (anOwner);
+ mySelection->Select (anOwner);
}
}
}
}
}
- Standard_Integer aSelNum = AIS_Selection::Extent();
+ Standard_Integer aSelNum = mySelection->Extent();
return (aSelNum == 1) ? AIS_SOP_OneSelected
: (aSelNum > 1) ? AIS_SOP_SeveralSelected
{
myMainVS->Pick (thePolyline, theView);
- AIS_Selection::SetCurrentSelection (mySelName.ToCString());
-
- Standard_Integer aLastSelNum = AIS_Selection::Extent();
- myMainVS->Init();
- if (!myMainVS->More())
+ Standard_Integer aLastSelNum = mySelection->Extent();
+ 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...
if (!anOwner->IsSelected())
{
- AIS_Selection::AddSelect (anOwner);
+ mySelection->AddSelect (anOwner);
anOwner->SetSelected (Standard_True);
}
}
}
}
- Standard_Integer aSelNum = AIS_Selection::Extent();
+ Standard_Integer aSelNum = mySelection->Extent();
return (aSelNum == 1) ? AIS_SOP_OneSelected
: (aSelNum > 1) ? AIS_SOP_SeveralSelected
: AIS_SOP_Error;
AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const Standard_Boolean toUpdateViewer)
{
Standard_Integer aDetIndex = DetectedIndex();
- AIS_Selection::SetCurrentSelection (mySelName.ToCString());
if(aDetIndex > 0)
{
- AIS_Selection::SetCurrentSelection (mySelName.ToCString());
- Standard_Integer aSelNum = AIS_Selection::Extent();
- const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner (aDetIndex);
+ Standard_Integer aSelNum = mySelection->Extent();
+ const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner->FindKey (aDetIndex);
Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True;
- AIS_Selection::Select (anOwner);
+ mySelection->Select (anOwner);
anOwner->SetSelected (toSelect);
if(myAutoHilight)
{
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
}
}
-#ifdef BUC60774
- Standard_Integer NS = AIS_Selection::Extent();
+ Standard_Integer NS = mySelection->Extent();
if( NS == 1 ) return AIS_SOP_OneSelected;
else if( NS > 1 ) return AIS_SOP_SeveralSelected;
return aSelNum == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed;
-#endif
}
return AIS_SOP_Error;
}
{
myMainVS->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView);
- AIS_Selection::SetCurrentSelection (mySelName.ToCString());
- Standard_Integer aLastSelNum = AIS_Selection::Extent();
-
- myMainVS->Init();
- if (!myMainVS->More())
+ Standard_Integer aLastSelNum = mySelection->Extent();
+ 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;
- AIS_Selection::Select (anOwner);
+ mySelection->Select (anOwner);
anOwner->SetSelected (toSelect);
}
}
}
}
- Standard_Integer aSelNum = AIS_Selection::Extent();
+ Standard_Integer aSelNum = mySelection->Extent();
return (aSelNum == 1) ? AIS_SOP_OneSelected
: (aSelNum > 1) ? AIS_SOP_SeveralSelected
{
myMainVS->Pick (thePolyline, theView);
- AIS_Selection::SetCurrentSelection (mySelName.ToCString());
-
- Standard_Integer aLastSelNum = AIS_Selection::Extent();
- myMainVS->Init();
- if(!myMainVS->More())
+ Standard_Integer aLastSelNum = mySelection->Extent();
+ 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;
- AIS_Selection::Select (anOwner);
+ mySelection->Select (anOwner);
anOwner->SetSelected (toSelect);
}
}
}
}
- Standard_Integer aSelNum = AIS_Selection::Extent();
+ Standard_Integer aSelNum = mySelection->Extent();
return (aSelNum == 1) ? AIS_SOP_OneSelected
: (aSelNum > 1) ? AIS_SOP_SeveralSelected
const Standard_Integer aHilightMode = GetHiMod (Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()));
myMainPM->BeginImmediateDraw();
- theOwner->HilightWithColor (myMainPM, myCTX->HilightColor(), aHilightMode);
- myMainPM->EndImmediateDraw (theView);
+ theOwner->HilightWithColor (myMainPM, getHiStyle (theOwner->Selectable()), aHilightMode);
+ 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());
+ const Standard_Integer aHilightMode = GetHiMod (anObj);
if (IsSelected (theOwner))
{
if (theOwner->IsAutoHilight())
{
- theOwner->HilightWithColor (myMainPM, myCTX->SelectionColor(), aHilightMode);
+ theOwner->HilightWithColor (myMainPM, getSelStyle (anObj), aHilightMode);
}
}
else
//=======================================================================
//function : HilightPicked
-//purpose :
+//purpose :
//=======================================================================
-void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer)
+void AIS_LocalContext::HilightPicked (const Standard_Boolean theToUpdateviewer)
{
- Standard_Boolean updMain(Standard_False);
-
- Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
-#ifdef BUC60765
- if( Sel.IsNull() ) return;
-#endif
-
- typedef NCollection_DataMap <Handle(SelectMgr_SelectableObject), NCollection_Handle<SelectMgr_SequenceOfOwner> > SelectMgr_DataMapOfObjectOwners;
+ if (mySelection.IsNull())
+ {
+ return;
+ }
+
+ 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...
-#if !defined OCC189 && !defined USE_MAP
- const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
- for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++)
- {
- const Handle(Standard_Transient)& Tr = Obj(i);
-#else
- const AIS_NListTransient& Obj = Sel->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();
-#endif
- 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)*)&SO);
- updMain = Standard_True;
- }
- else
- updMain = Standard_True;
- }
- else
- updMain = Standard_True;
- Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
- Standard_Integer HM = GetHiMod(*((Handle(AIS_InteractiveObject)*)&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 Standard_Integer aHighMode = GetHiMod (anIO);
+ anOwner->HilightWithColor (myMainPM, getSelStyle (anIO), aHighMode);
+ 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;
+ }
- Standard_Boolean updMain(Standard_False);
-
- Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
-#ifdef BUC60765
- if( Sel.IsNull() ) return;
-#endif
- Handle (PrsMgr_PresentationManager3d) PM = myMainPM;
NCollection_Map<Handle(SelectMgr_SelectableObject)> anObjMap;
-
-#if !defined OCC189 && !defined USE_MAP
- const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
- for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
- const Handle(Standard_Transient)& Tr = Obj(i);
-#else
- const AIS_NListTransient& Obj = Sel->Objects();
- AIS_NListTransient::Iterator anIter( Obj );
- for(; anIter.More(); anIter.Next()){
- const Handle(Standard_Transient)& Tr = anIter.Value();
-#endif
- if(!Tr.IsNull()){
- const Handle(SelectMgr_EntityOwner)& Ownr =
- *((const Handle(SelectMgr_EntityOwner)*) &Tr);
- Standard_Integer HM(0);
- if(Ownr->HasSelectable()){
-#ifdef BUC60876
- Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
- Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&SO);
- anObjMap.Add (IO);
-
- HM = GetHiMod(IO);
-#endif
- Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(Ownr);
- if(BROwnr.IsNull() || !BROwnr->ComesFromDecomposition()){
-#ifndef BUC60876
- Handle(SelectMgr_SelectableObject) SO = Ownr->Selectable();
- Handle(AIS_InteractiveObject) IO = *((Handle(AIS_InteractiveObject)*)&SO);
- HM = GetHiMod(IO);
-#endif
- updMain = Standard_True;
- }
- else
- updMain = Standard_True;
- }
- 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);
+ Standard_Integer aHighMode = GetHiMod (anIO);
+ anOwner->Unhilight (myMainPM, aHighMode);
}
-
- 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){
-#ifdef BUC60774
+ if (theToUpdateViewer)
+ {
myCTX->CurrentViewer()->Update();
-#else
- if(updMain) myCTX->CurrentViewer()->Update();
-#endif
}
-
}
//=======================================================================
void AIS_LocalContext::
InitSelected()
{
- AIS_Selection::SetCurrentSelection(mySelName.ToCString());
- AIS_Selection::CurrentSelection()->Init();
+ mySelection->Init();
}
//==================================================
Standard_Boolean AIS_LocalContext::
MoreSelected() const
{
- return AIS_Selection::CurrentSelection()->More();
+ return mySelection->More();
}
//==================================================
void AIS_LocalContext::
NextSelected()
{
- AIS_Selection::CurrentSelection()->Next();
+ mySelection->Next();
}
//==================================================
-// Function:
+// Function: HasShape
// Purpose :
//==================================================
-Standard_Boolean AIS_LocalContext::
-HasShape() const
+Standard_Boolean AIS_LocalContext::HasShape() const
{
- Handle(Standard_Transient) Tr = AIS_Selection::CurrentSelection()->Value();
- if( Tr.IsNull() ) return Standard_False;
- Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&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 (AIS_Selection::CurrentSelection()->Extent() == 0)
- return Standard_False;
-
- Handle(Standard_Transient) aCurSelection = AIS_Selection::CurrentSelection()->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 = AIS_Selection::CurrentSelection()->Value();
- Handle(SelectMgr_EntityOwner) anEO = *((Handle(SelectMgr_EntityOwner)*)&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 = AIS_Selection::CurrentSelection()->Value();
- if( !Tr.IsNull() ) {
- Handle(SelectMgr_EntityOwner) EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
- Handle(SelectMgr_SelectableObject) SO;
- if(EO->HasSelectable()){
- SO = EO->Selectable();
- IO = *((Handle(AIS_InteractiveObject)*)&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 = AIS_Selection::CurrentSelection()->Value();
- if( !Tr.IsNull() )
- EO = *((Handle(SelectMgr_EntityOwner)*)&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();
}
//==================================================
if (anobj.IsNull() || anobj->IsAutoHilight())
return;
- AIS_Selection::SetCurrentSelection(mySelName.ToCString());
- Handle(AIS_Selection) Sel = AIS_Selection::CurrentSelection();
-
SelectMgr_SequenceOfOwner aSeq;
- for ( Sel->Init(); Sel->More(); Sel->Next() ){
- Handle(SelectMgr_EntityOwner) aOwner = Handle(SelectMgr_EntityOwner)::DownCast(Sel->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);
- AIS_Selection::SetCurrentSelection(mySelName.ToCString());
-
- Handle(AIS_Selection) Sel = AIS_Selection::CurrentSelection();
-#if !defined OCC189 && !defined USE_MAP
- const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
- for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
- const Handle(Standard_Transient)& Tr = Obj(i);
-#else
- const AIS_NListTransient& Obj = Sel->Objects();
- AIS_NListTransient::Iterator anIter( Obj );
- for(; anIter.More(); anIter.Next()){
- const Handle(Standard_Transient)& Tr = anIter.Value();
-#endif
- 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);
}
- AIS_Selection::Select();
+ mySelection->Clear();
mylastindex = 0;
}
continue;
}
- if (toClearDeactivated && !mySM->IsActivated (theIO, myMainVS, aMode))
+ if (toClearDeactivated && !mySM->IsActivated(theIO, aMode, myMainVS))
{
continue;
}
Handle(SelectMgr_Selection) aSelection = theIO->Selection(aMode);
for (aSelection->Init(); aSelection->More(); aSelection->Next())
{
- Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive();
+ Handle(SelectBasics_SensitiveEntity) anEntity = aSelection->Sensitive()->BaseSensitive();
if (anEntity.IsNull())
{
continue;
}
}
- // 2. Refresh context's detection and selection and keep only active owners
+ // 2. Refresh context's detection and selection and keep only active owners.
// Keep last detected object for lastindex initialization.
- Handle(SelectMgr_EntityOwner) aLastPicked = myMainVS->OnePicked();
+ Handle(SelectMgr_EntityOwner) aLastPicked;
+ if (IsValidIndex (mylastindex))
+ {
+ aLastPicked = myMapOfOwner->FindKey (mylastindex);
+ }
// Remove entity owners from detected sequences
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;
}
Standard_Boolean isAISRemainsDetected = Standard_False;
- // 3. Remove entity owners from AIS_Selection
+ // 3. AIS_Selection : remove entity owners from AIS_Selection
const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
- Handle(AIS_Selection) aSelection = AIS_Selection::Selection (mySelName.ToCString());
- AIS_NListTransient::Iterator anIter (aSelection->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;
}
{
isAISRemainsDetected = Standard_True;
}
-
- aRemoveEntites.Append (anOwner);
- anOwner->SetSelected (Standard_False);
- for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
+ else
{
- Unhilight (anOwner, aViewer->ActiveView());
+ aRemoveEntites.Append (anOwner);
+ anOwner->SetSelected (Standard_False);
+ for (V3d_ListOfViewIterator anActiveViewIter (aViewer->ActiveViewIterator()); anActiveViewIter.More(); anActiveViewIter.Next())
+ {
+ 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())
{
- aSelection->Select (anIterRemove.Value());
+ mySelection->Select (anIterRemove.Value());
}
- // 4. Remove entity owners from myMapOfOwner
+ // 4. AIS_LocalContext - myMapOfOwner : remove entity owners from myMapOfOwner
SelectMgr_IndexedMapOfOwner anOwnersToKeep;
- for (Standard_Integer anIdx = 1; anIdx <= myMapOfOwner.Extent(); anIdx++)
+ for (Standard_Integer anIdx = 1; anIdx <= myMapOfOwner->Extent(); anIdx++)
{
- Handle(SelectMgr_EntityOwner) anOwner = myMapOfOwner (anIdx);
+ Handle(SelectMgr_EntityOwner) anOwner = myMapOfOwner->FindKey (anIdx);
if (anOwner.IsNull())
{
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());
}
}
}
- myMapOfOwner.Clear();
- myMapOfOwner.Assign (anOwnersToKeep);
- mylastindex = myMapOfOwner.FindIndex (aLastPicked);
- if (!IsValidIndex (mylastindex))
+ myMapOfOwner->Clear();
+ myMapOfOwner->Assign (anOwnersToKeep);
+
+ if (myDetectedSeq.IsEmpty() && !aLastPicked.IsNull())
{
myMainPM->ClearImmediateDraw();
+ mylastindex = 0;
+ }
+ else if (!aLastPicked.IsNull())
+ {
+ // For a case when the last detected owner was unhilighted and removed as outdated we
+ // need to check if there were other detected owners with less priority. If yes then
+ // one from the remaining should be treated.
+ Standard_Integer anIndex = 1, aDetectedSeqLength = myDetectedSeq.Length();
+ for (; anIndex <= aDetectedSeqLength; anIndex++)
+ {
+ if (aLastPicked == myMainVS->Picked (myDetectedSeq.Value(anIndex)))
+ {
+ break; // detected owner was not removed
+ }
+ }
+ if (anIndex <= aDetectedSeqLength)
+ {
+ // Last detected owner was not removed, update mylastindex variable
+ mylastindex = myMapOfOwner->FindIndex (aLastPicked);
+ }
+ else
+ {
+ // 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.
+ manageDetected (myMainVS->Picked (myDetectedSeq.First()),
+ aViewer->ActiveViewIterator().Value(),
+ Standard_False);
+ }
}
+ // Renew iterator of ::DetectedCurrentObject()
if (!isAISRemainsDetected)
{
// Remove the interactive object from detected sequences
//1st case, owner already <anIObj> as owner
// and not separated is found...
- Handle(AIS_Selection) sel = AIS_Selection::Selection(mySelName.ToCString());
- //Standard_Boolean found(Standard_False);
- 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()->OwnerId();
- EO = *((Handle(SelectMgr_EntityOwner)*)&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(anIObj);
+ EO = new SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)anIObj);
}
ClearSelected(Standard_False);
- AIS_Selection::Select(EO);
+ mySelection->Select(EO);
EO->SetSelected (Standard_True);
HilightPicked(updateviewer);
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()->OwnerId();
- EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
- }
+ EO = anIObj->GlobalSelOwner();
}
if(EO.IsNull())
{
- EO = new SelectMgr_EntityOwner(anIObj);
+ EO = new SelectMgr_EntityOwner((const Handle(SelectMgr_SelectableObject)&)anIObj);
}
}
-
-// cout<<"AIS_LocalContext::AddOrRemoveSelected : Selection = "<<mySelName<<endl;
- const Handle(AIS_Selection)& S = AIS_Selection::Selection(mySelName.ToCString());
-
- if (!S.IsNull())
+
+ if (!mySelection.IsNull())
{
- AIS_SelectStatus aStatus = S->Select(EO);
+ AIS_SelectStatus aStatus = mySelection->Select(EO);
EO->SetSelected (aStatus == AIS_SS_Added);
}
Handle(SelectMgr_EntityOwner) EO = FindSelectedOwnerFromShape(Sh);
if (!EO.IsNull())
{
- AIS_Selection::Selection(mySelName.ToCString())->Select(EO);
+ mySelection->Select(EO);
EO->SetSelected (Standard_True);
}
HilightPicked (updateviewer);
Standard_Boolean toSelect = theOwner->IsSelected() ? Standard_False : Standard_True;
- AIS_Selection::Selection (mySelName.ToCString())->Select (theOwner);
+ mySelection->Select(theOwner);
theOwner->SetSelected (toSelect);
if(myAutoHilight)
//
//=======================================================================================================
- const Standard_Integer aNewIndex = myMapOfOwner.Contains (thePickOwner)
- ? myMapOfOwner.FindIndex (thePickOwner)
- : myMapOfOwner.Add (thePickOwner);
+ const Standard_Integer aNewIndex = myMapOfOwner->Contains (thePickOwner)
+ ? myMapOfOwner->FindIndex (thePickOwner)
+ : myMapOfOwner->Add (thePickOwner);
// For the advanced mesh selection mode the owner indices comparison
// is not effective because in that case only one owner manage the
{
myMainPM->ClearImmediateDraw();
if (mylastindex != 0
- && mylastindex <= myMapOfOwner.Extent())
+ && mylastindex <= myMapOfOwner->Extent())
{
- const Handle(SelectMgr_EntityOwner)& aLastOwner = myMapOfOwner (mylastindex);
+ const Handle(SelectMgr_EntityOwner)& aLastOwner = myMapOfOwner->FindKey (mylastindex);
Unhilight (aLastOwner, theView);
}
const TopoDS_Shape&
AIS_LocalContext::DetectedShape() const
{
- static TopoDS_Shape bidsh;
if(mylastindex != 0)
{
- Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(myMapOfOwner(mylastindex));
- if(BROwnr.IsNull()) return bidsh;
+ Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(myMapOfOwner->FindKey (mylastindex));
+ if(BROwnr.IsNull()) return AIS_myDummyShape;
return BROwnr->Shape();
}
- return bidsh;
+ return AIS_myDummyShape;
}
//=======================================================================
{
Handle(AIS_InteractiveObject) Iobj;
if(IsValidIndex(mylastindex)){
- Handle(SelectMgr_SelectableObject) SO = myMapOfOwner.FindKey(mylastindex)->Selectable();
- Iobj = *((Handle(AIS_InteractiveObject)*) &SO);
+ Handle(SelectMgr_SelectableObject) SO = myMapOfOwner->FindKey(mylastindex)->Selectable();
+ Iobj = Handle(AIS_InteractiveObject)::DownCast (SO);
}
return Iobj;
}
{
Handle(SelectMgr_EntityOwner) bid;
if(!IsValidIndex(mylastindex)) return bid;
- return myMapOfOwner.FindKey(mylastindex);
+ return myMapOfOwner->FindKey(mylastindex);
}
Standard_Boolean AIS_LocalContext::ComesFromDecomposition(const Standard_Integer PickedIndex) const
{
- const Handle(SelectMgr_EntityOwner)& OWN = myMapOfOwner.FindKey(PickedIndex);
+ const Handle(SelectMgr_EntityOwner)& OWN = myMapOfOwner->FindKey(PickedIndex);
Handle(SelectMgr_SelectableObject) aSel = OWN->Selectable();
if (myActiveObjects.IsBound (aSel)) { // debug of jmi
const Handle(AIS_LocalStatus)& Stat = myActiveObjects(aSel);
return Standard_False;
}
-
-//=======================================================================
-//function : DisplayAreas
-//purpose :
-//=======================================================================
-
-void AIS_LocalContext::DisplayAreas(const Handle(V3d_View)& aviou)
-{
- myMainVS->DisplayAreas(aviou);
-}
-
-//=======================================================================
-//function : ClearAreas
-//purpose :
-//=======================================================================
-
-void AIS_LocalContext::ClearAreas(const Handle(V3d_View)& aviou)
-{
- myMainVS->ClearAreas(aviou);
-}
-
//=======================================================================
//function : DisplaySensitive
//purpose :
//=======================================================================
Standard_Boolean AIS_LocalContext::IsShape(const Standard_Integer Index) const
{
-
- if(Handle(StdSelect_BRepOwner)::DownCast(myMapOfOwner.FindKey(Index)).IsNull())
+ Handle(SelectMgr_EntityOwner) aEO (myMapOfOwner->FindKey(Index));
+ if (aEO.IsNull() || ! aEO->IsKind(STANDARD_TYPE(StdSelect_BRepOwner)))
return Standard_False;
return
ComesFromDecomposition(Index);
Standard_Boolean AIS_LocalContext::IsValidForSelection(const Handle(AIS_InteractiveObject)& anIObj) const
{
-
-#ifdef IMP120701
+ const Handle(SelectMgr_SelectableObject)& aSelObj = anIObj; // to avoid ambiguity
// Shape was not transfered from AIS_Shape to EntityOwner
Handle(AIS_Shape) shape = Handle(AIS_Shape)::DownCast(anIObj);
if( !shape.IsNull() )
- return myFilters->IsOk(new StdSelect_BRepOwner(shape->Shape(),shape));
-#endif
- return myFilters->IsOk(new SelectMgr_EntityOwner(anIObj));
+ return myFilters->IsOk(new StdSelect_BRepOwner(shape->Shape(), aSelObj));
+ return myFilters->IsOk(new SelectMgr_EntityOwner(aSelObj));
}
}
myMainPM->BeginImmediateDraw();
- const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner (mylastindex);
+ const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner->FindKey (mylastindex);
const Standard_Integer aHilightMode = anOwner->HasSelectable()
? GetHiMod (Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()))
: 0;
- myMapOfOwner (mylastindex)->Unhilight (myMainPM, aHilightMode);
- myMainPM->EndImmediateDraw (theView);
+ myMapOfOwner->FindKey (mylastindex)->Unhilight (myMainPM, aHilightMode);
+ myMainPM->EndImmediateDraw (theView->Viewer());
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;
-
- Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
- if(Sel.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);
-#if !defined OCC189 && !defined USE_MAP
- const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
- for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
- const Handle(Standard_Transient)& Tr = Obj(i);
-#else
- const AIS_NListTransient& Obj = Sel->Objects();
- AIS_NListTransient::Iterator anIter( Obj );
- for(; anIter.More(); anIter.Next()){
- const Handle(Standard_Transient)& Tr = anIter.Value();
-#endif
- if(!Tr.IsNull()){
- EO = *((Handle(SelectMgr_EntityOwner)*)&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)();
}
//=======================================================================
//=======================================================================
Handle(SelectMgr_EntityOwner) AIS_LocalContext::FindSelectedOwnerFromShape(const TopoDS_Shape& sh) const
{
-#ifdef OCC9026
Handle(SelectMgr_EntityOwner) EO, bid;
-#else
- Handle(SelectMgr_EntityOwner) EO;
-#endif
if (sh.IsNull()) return EO;
- Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
- if(Sel.IsNull()) {
-#ifdef OCCT_DEBUG
- cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection "<<mySelName<<" Nulle "<<endl;
-#endif
+ if(mySelection.IsNull()) {
return EO;
}
Standard_Boolean found(Standard_False);
-#ifdef OCC9026
if (!found) {
- SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive aSensitiveIt (myMainVS->Primitives());
- for (; aSensitiveIt.More(); aSensitiveIt.Next()) {
- EO = Handle(SelectMgr_EntityOwner)::DownCast (aSensitiveIt.Value()->OwnerId());
+ NCollection_List<Handle(SelectBasics_EntityOwner)> anActiveOwners;
+ myMainVS->ActiveOwners (anActiveOwners);
+ for (NCollection_List<Handle(SelectBasics_EntityOwner)>::Iterator anOwnersIt (anActiveOwners); anOwnersIt.More(); anOwnersIt.Next())
+ {
+ EO = Handle(SelectMgr_EntityOwner)::DownCast (anOwnersIt.Value());
Handle(StdSelect_BRepOwner) BROwnr = Handle(StdSelect_BRepOwner)::DownCast(EO);
if (!BROwnr.IsNull() && BROwnr->HasShape() && BROwnr->Shape() == sh) {
found = Standard_True;
}
}
}
-#else
-#if !defined OCC189 && !defined USE_MAP
- const TColStd_Array1OfTransient& Obj = Sel->Objects()->Array1();
- for(Standard_Integer i =Obj.Lower();i<=Sel->NbStored();i++){
- const Handle(Standard_Transient)& Tr = Obj(i);
-#else
- const AIS_NListTransient& Obj = Sel->Objects();
- AIS_NListTransient::Iterator anIter( Obj );
- for(; anIter.More(); anIter.Next()){
- const Handle(Standard_Transient)& Tr = anIter.Value();
-#endif
- if(!Tr.IsNull()){
-
- EO = *((Handle(SelectMgr_EntityOwner)*)&Tr);
- if(EO->HasShape())
- if ( EO->Shape() == sh)
- found =Standard_True;
- break;
- }
- }
-#endif
if(found) return EO;
return bid;
}
-#ifdef IMP160701
//=======================================================================
//function : AIS_LocalContext::InitDetected
//purpose :
//=======================================================================
const TopoDS_Shape& AIS_LocalContext::DetectedCurrentShape() const
{
- static TopoDS_Shape aDummyShape;
-
Handle(AIS_Shape) aCurrentShape = Handle(AIS_Shape)::DownCast (DetectedCurrentObject());
if (aCurrentShape.IsNull())
{
- return aDummyShape;
+ return AIS_myDummyShape;
}
return aCurrentShape->Shape();
{
return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL;
}
-#endif
+
+//=======================================================================
+//function : RestoreActivatedModes
+//purpose :
+//=======================================================================
+void AIS_LocalContext::RestoreActivatedModes() const
+{
+ for (AIS_DataMapOfSelStat::Iterator anIter (myActiveObjects); anIter.More(); anIter.Next())
+ {
+ const TColStd_ListOfInteger& anActivatedModes = anIter.Value()->SelectionModes();
+ for (TColStd_ListIteratorOfListOfInteger aModesIter (anActivatedModes); aModesIter.More(); aModesIter.Next())
+ {
+ mySM->Activate (anIter.Key(), aModesIter.Value(), myMainVS);
+ }
+ }
+}