// - 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_LocalStatus.hxx>
-#include <StdPrs_WFShape.hxx>
#include <Graphic3d_ArrayOfTriangles.hxx>
#include <Graphic3d_Group.hxx>
#include <Select3D_SensitiveTriangulation.hxx>
+#include <StdSelect_ViewerSelector3d.hxx>
#include <SelectBasics_SensitiveEntity.hxx>
#include <TCollection_AsciiString.hxx>
#include <NCollection_Map.hxx>
+#include <Visual3d_View.hxx>
-#ifdef OCC9026
-#include <SelectMgr_DataMapIteratorOfDataMapOfIntegerSensitive.hxx>
-#endif
#include <SelectMgr_Selection.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
-
static Standard_Integer GetHiMod(const Handle(AIS_InteractiveObject)& IO)
{
myCurDetected = 0;
myDetectedSeq.Clear();
+ myFilters->SetDisabledObjects (theView->View()->HiddenObjects());
myMainVS->Pick (theXpix, theYpix, theView);
const Standard_Integer aDetectedNb = myMainVS->NbPicked();
{
if (mylastindex != 0 && mylastindex <= myMapOfOwner.Extent())
{
+ myMainPM->ClearImmediateDraw();
Unhilight (myMapOfOwner (mylastindex), theView);
if (theToRedrawImmediate)
{
if(myAutoHilight)
{
+ myMainPM->ClearImmediateDraw();
const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
{
}
}
-#ifdef BUC60774
Standard_Integer NS = AIS_Selection::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;
}
return;
}
- myMainPM->ClearImmediateDraw();
const Standard_Integer aHilightMode = GetHiMod (Handle(AIS_InteractiveObject)::DownCast (theOwner->Selectable()));
if (IsSelected (theOwner))
{
//=======================================================================
void AIS_LocalContext::HilightPicked(const Standard_Boolean updateviewer)
{
- 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;
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())
{
const Handle(Standard_Transient)& Tr = anIter.Value();
-#endif
if(!Tr.IsNull()){
const Handle(SelectMgr_EntityOwner)& Ownr =
*((const Handle(SelectMgr_EntityOwner)*) &Tr);
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() )
{
myMainPM->ClearImmediateDraw();
- 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);
}
anIter1.Key()->ClearSelected();
}
- if(updateviewer){
-#ifdef BUC60774
+ if(updateviewer)
myCTX->CurrentViewer()->Update();
-#else
- if(updMain) myCTX->CurrentViewer()->Update();
-#endif
- }
-
}
//=======================================================================
return (hasshape&&comes);
}
+//================================================================
+// Function : HasSelectedShape
+// Purpose : Checks if there is a selected shape regardless of its decomposition status
+//================================================================
+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())
+ {
+ return Standard_False;
+ }
+ return aBrepOwner->HasShape();
+}
+
//==================================================
// Function:
// Purpose :
{
return TopoDS_Shape();
}
+
return aBRO->Shape().Located (aBRO->Location() * aBRO->Shape().Location());
}
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);
}
//==================================================
-// Function: ClearSelected
+// Function: ClearOutdatedSelection
// Purpose :
//==================================================
-void AIS_LocalContext::ClearSelected (const Handle(AIS_InteractiveObject)& theIO,
- const Standard_Boolean toUpdateViewer)
+void AIS_LocalContext::ClearOutdatedSelection (const Handle(AIS_InteractiveObject)& theIO,
+ const Standard_Boolean toClearDeactivated)
{
+ // 1. Collect selectable entities
+ SelectMgr_IndexedMapOfOwner aValidOwners;
+
+ const TColStd_ListOfInteger& aModes = SelectionModes (theIO);
+
+ TColStd_ListIteratorOfListOfInteger aModeIter (aModes);
+ for (; aModeIter.More(); aModeIter.Next())
+ {
+ int aMode = aModeIter.Value();
+ if (!theIO->HasSelection(aMode))
+ {
+ continue;
+ }
+
+ 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()->BaseSensitive();
+ if (anEntity.IsNull())
+ {
+ continue;
+ }
+
+ Handle(SelectMgr_EntityOwner) anOwner =
+ Handle(SelectMgr_EntityOwner)::DownCast (anEntity->OwnerId());
+
+ if (anOwner.IsNull())
+ {
+ continue;
+ }
+
+ aValidOwners.Add(anOwner);
+ }
+ }
+
+ // 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();
- // Remove the interactive object from detected sequence
- for (Standard_Integer anIdx = 1; anIdx <= myAISDetectedSeq.Length(); ++anIdx)
+ // Remove entity owners from detected sequences
+ for (Standard_Integer anIdx = 1; anIdx <= myDetectedSeq.Length(); ++anIdx)
{
- Handle(AIS_InteractiveObject) aDetectedIO = myAISDetectedSeq.Value (anIdx);
- if (!aDetectedIO.IsNull() && aDetectedIO == theIO)
+ Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myDetectedSeq (anIdx));
+ if (anOwner.IsNull() || anOwner->Selectable() != theIO || aValidOwners.Contains (anOwner))
{
- myAISDetectedSeq.Remove (anIdx--);
+ continue;
+ }
+
+ myDetectedSeq.Remove (anIdx--);
+
+ if (anIdx < myCurDetected)
+ {
+ myCurDetected--;
}
}
+ myCurDetected = Max (myCurDetected, 1);
- Standard_Integer aHilightMode = theIO->HasHilightMode() ? theIO->HilightMode() : 0;
+ Standard_Boolean isAISRemainsDetected = Standard_False;
- // 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;
continue;
}
- aRemoveEntites.Append (anOwner);
-
- if (IsSelected (anOwner))
+ if (aValidOwners.Contains (anOwner))
+ {
+ isAISRemainsDetected = Standard_True;
+ }
+ else
{
- anOwner->Unhilight (myMainPM, aHilightMode);
+ aRemoveEntites.Append (anOwner);
+ anOwner->SetSelected (Standard_False);
+ for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews())
+ {
+ Unhilight (anOwner, aViewer->ActiveView());
+ }
}
}
AIS_NListTransient::Iterator anIterRemove (aRemoveEntites);
aSelection->Select (anIterRemove.Value());
}
- // Remove entity owners from myMapOfOwner
+ // 4. AIS_LocalContext - myMapOfOwner : remove entity owners from myMapOfOwner
SelectMgr_IndexedMapOfOwner anOwnersToKeep;
- const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer();
for (Standard_Integer anIdx = 1; anIdx <= myMapOfOwner.Extent(); anIdx++)
{
Handle(SelectMgr_EntityOwner) anOwner = myMapOfOwner (anIdx);
continue;
}
- if (anOwner->Selectable() != theIO)
+ if (anOwner->Selectable() != theIO || aValidOwners.Contains (anOwner))
{
anOwnersToKeep.Add (anOwner);
}
myMapOfOwner.Clear();
myMapOfOwner.Assign (anOwnersToKeep);
mylastindex = myMapOfOwner.FindIndex (aLastPicked);
+ if (!IsValidIndex (mylastindex))
+ {
+ myMainPM->ClearImmediateDraw();
+ }
- if (toUpdateViewer)
+ if (!isAISRemainsDetected)
{
- aViewer->Update();
+ // Remove the interactive object from detected sequences
+ for (Standard_Integer anIdx = 1; anIdx <= myAISDetectedSeq.Length(); ++anIdx)
+ {
+ Handle(AIS_InteractiveObject) aDetectedIO = myAISDetectedSeq.Value (anIdx);
+ if (aDetectedIO.IsNull() || aDetectedIO != theIO)
+ {
+ continue;
+ }
+
+ myAISDetectedSeq.Remove (anIdx--);
+
+ if (anIdx < myAISCurDetected)
+ {
+ myAISCurDetected--;
+ }
+ }
+ myAISCurDetected = Max (myAISCurDetected, 1);
}
}
const Handle(SelectMgr_Selection)& SIOBJ = anIObj->Selection(0);
SIOBJ->Init();
if(SIOBJ->More()){
- Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->OwnerId();
+ Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->BaseSensitive()->OwnerId();
EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
}
}
{
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);
+ if(SIOBJ->More()){
+ Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->BaseSensitive()->OwnerId();
+ EO = *((Handle(SelectMgr_EntityOwner)*)&BO);
}
}
if(EO.IsNull())
{
if (thePickOwner.IsNull())
{
+ myMainPM->ClearImmediateDraw();
if (theToRedrawImmediate)
{
theView->RedrawImmediate();
if (aNewIndex != mylastindex
|| thePickOwner->IsForcedHilight())
{
+ myMainPM->ClearImmediateDraw();
if (mylastindex != 0
&& mylastindex <= myMapOfOwner.Extent())
{
mylastindex = aNewIndex;
}
- if (mylastindex)
+ if (mylastindex != 0)
{
mylastgood = mylastindex;
}
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::IsValidForSelection(const Handle(AIS_InteractiveObject)& anIObj) const
{
-#ifdef IMP120701
// 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));
}
{
myCurDetected = 1;
}
- Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myCurDetected);
+ Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myDetectedSeq (myCurDetected));
if (anOwner.IsNull())
{
return 0;
return 0;
}
+ const Standard_Integer aLen = myDetectedSeq.Length();
if (--myCurDetected < 1)
{
- myCurDetected = 1;
+ myCurDetected = aLen;
}
- Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myCurDetected);
+ Handle(SelectMgr_EntityOwner) anOwner = myMainVS->Picked (myDetectedSeq (myCurDetected));
if (anOwner.IsNull())
{
return 0;
Handle(AIS_Selection) Sel = AIS_Selection::Selection(mySelName.ToCString());
if(Sel.IsNull()) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection "
<<mySelName<<" Nulle "<<endl;
#endif
return EO;
}
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(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 DEB
+#ifdef OCCT_DEBUG
cout<<"\t\tAIS_LocalCOntext::FindSelectedOwnerFromShape : Selection "<<mySelName<<" Nulle "<<endl;
#endif
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)>::Iterator anOwnersIt (myMainVS->ActiveOwners());
+ for (; 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 :
{
return MoreDetected() ? myAISDetectedSeq(myAISCurDetected) : NULL;
}
-#endif