diff --git a/src/AIS/AIS_InteractiveContext.cxx b/src/AIS/AIS_InteractiveContext.cxx index 1a84aaca44..46a326202a 100644 --- a/src/AIS/AIS_InteractiveContext.cxx +++ b/src/AIS/AIS_InteractiveContext.cxx @@ -121,7 +121,7 @@ mgrSelector(new SelectMgr_SelectionManager()), myMainPM(new PrsMgr_PresentationManager3d(MainViewer->Viewer())), myMainVwr(MainViewer), myMainSel(new StdSelect_ViewerSelector3d()), -myToHilightSelected( Standard_False ), +myToHilightSelected( Standard_True ), myFilters(new SelectMgr_OrFilter()), myDefaultDrawer(new Prs3d_Drawer()), myDefaultColor(Quantity_NOC_GOLDENROD), diff --git a/src/AIS/AIS_InteractiveContext_1.cxx b/src/AIS/AIS_InteractiveContext_1.cxx index c5a906e47a..73cebca4fa 100644 --- a/src/AIS/AIS_InteractiveContext_1.cxx +++ b/src/AIS/AIS_InteractiveContext_1.cxx @@ -267,67 +267,61 @@ AIS_StatusOfDetection AIS_InteractiveContext::MoveTo (const Standard_Integer th //function : Select //purpose : //======================================================================= - -AIS_StatusOfPick AIS_InteractiveContext::Select(const Standard_Integer XPMin, - const Standard_Integer YPMin, - const Standard_Integer XPMax, - const Standard_Integer YPMax, - const Handle(V3d_View)& aView, - const Standard_Boolean updateviewer) +AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Integer theXPMin, + const Standard_Integer theYPMin, + const Standard_Integer theXPMax, + const Standard_Integer theYPMax, + const Handle(V3d_View)& theView, + const Standard_Boolean toUpdateViewer) { // all objects detected by the selector are taken, previous current objects are emptied, // new objects are put... - if(HasOpenedContext()) - return myLocalContexts(myCurLocalIndex)->Select(XPMin,YPMin,XPMax,YPMax,aView,updateviewer); - - ClearCurrents(Standard_False); - // OCC11904 - local variables made non-static - it looks and works better like this - Handle(StdSelect_ViewerSelector3d) selector; - - if(aView->Viewer()== myMainVwr) { - selector= myMainSel; - myWasLastMain = Standard_True;} - - selector->Pick(XPMin,YPMin,XPMax,YPMax,aView); - AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); - -#ifdef OCC9657 - AIS_MapOfInteractive theSelectedObj; - for( selector->Init(); selector->More(); selector->Next() ) + if (HasOpenedContext()) { - Handle( AIS_InteractiveObject ) anObj = - Handle( AIS_InteractiveObject )::DownCast( selector->Picked()->Selectable() ); - if( !anObj.IsNull() ) - theSelectedObj.Add( anObj ); + return myLocalContexts(myCurLocalIndex)->Select (theXPMin, theYPMin, + theXPMax, theYPMax, + theView, toUpdateViewer); } - AIS_MapIteratorOfMapOfInteractive anIt( theSelectedObj ); - for( ; anIt.More(); anIt.Next() ) + + ClearCurrents (Standard_False); + + Handle(StdSelect_ViewerSelector3d) aSelector; + + if (theView->Viewer() == myMainVwr) { - AIS_Selection::Select( anIt.Key() ); - anIt.Key()->State(1); + aSelector = myMainSel; + myWasLastMain = Standard_True; } -#else - for(selector->Init();selector->More();selector->Next()){ - const Handle(SelectMgr_SelectableObject)& SO = selector->Picked()->Selectable(); - if(!SO.IsNull()){ -#ifdef OCC138 - AIS_Selection::Select(SO); - (*((Handle(AIS_InteractiveObject)*)&SO))->State(1); -#else - (*((Handle(AIS_InteractiveObject)*)&SO))->State(1); - AIS_Selection::Select(SO); -#endif //OCC138 + + aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); + AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); + + AIS_MapOfInteractive anObjectsToSelect; + for (aSelector->Init(); aSelector->More(); aSelector->Next()) + { + Handle(AIS_InteractiveObject) anObj = + Handle(AIS_InteractiveObject)::DownCast (aSelector->Picked()->Selectable()); + if (!anObj.IsNull()) + { + anObjectsToSelect.Add (anObj); } } -#endif //OCC9657 - HilightCurrents(updateviewer); - - Standard_Integer NS = NbCurrents(); - if(NS==0) return AIS_SOP_NothingSelected; - if(NS==1) return AIS_SOP_OneSelected; - return AIS_SOP_SeveralSelected; + AIS_MapIteratorOfMapOfInteractive anIt (anObjectsToSelect); + for ( ; anIt.More(); anIt.Next()) + { + AIS_Selection::Select (anIt.Key()); + anIt.Key()->State (1); + } + + HilightCurrents (toUpdateViewer); + + Standard_Integer aSelNum = NbCurrents(); + + return (aSelNum == 0) ? AIS_SOP_NothingSelected + : (aSelNum == 1) ? AIS_SOP_OneSelected + : AIS_SOP_SeveralSelected; } @@ -335,64 +329,56 @@ AIS_StatusOfPick AIS_InteractiveContext::Select(const Standard_Integer XPMin, //function : Select //purpose : Selection by polyline //======================================================================= - -AIS_StatusOfPick AIS_InteractiveContext::Select(const TColgp_Array1OfPnt2d& aPolyline, - const Handle(V3d_View)& aView, - const Standard_Boolean updateviewer) +AIS_StatusOfPick AIS_InteractiveContext::Select (const TColgp_Array1OfPnt2d& thePolyline, + const Handle(V3d_View)& theView, + const Standard_Boolean toUpdateViewer) { // all objects detected by the selector are taken, previous current objects are emptied, // new objects are put... - if(HasOpenedContext()) - return myLocalContexts(myCurLocalIndex)->Select(aPolyline,aView,updateviewer); - - ClearCurrents(Standard_False); - // OCC11904 - local variables made non-static - it looks and works better like this - Handle(StdSelect_ViewerSelector3d) selector; - - if(aView->Viewer()== myMainVwr) { - selector= myMainSel; - myWasLastMain = Standard_True;} - - selector->Pick(aPolyline,aView); - AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); - - -#ifdef OCC9657 - AIS_MapOfInteractive theSelectedObj; - for( selector->Init(); selector->More(); selector->Next() ) + if (HasOpenedContext()) { - Handle( AIS_InteractiveObject ) anObj = - Handle( AIS_InteractiveObject )::DownCast( selector->Picked()->Selectable() ); - if( !anObj.IsNull() ) - theSelectedObj.Add( anObj ); + return myLocalContexts(myCurLocalIndex)->Select (thePolyline, theView, toUpdateViewer); } - AIS_MapIteratorOfMapOfInteractive anIt( theSelectedObj ); - for( ; anIt.More(); anIt.Next() ) + + ClearCurrents (Standard_False); + + Handle(StdSelect_ViewerSelector3d) aSelector; + + if (theView->Viewer() == myMainVwr) { - AIS_Selection::Select( anIt.Key() ); - anIt.Key()->State(1); + aSelector = myMainSel; + myWasLastMain = Standard_True; } -#else - for(selector->Init();selector->More();selector->Next()){ - const Handle(SelectMgr_SelectableObject)& SO = selector->Picked()->Selectable(); - if(!SO.IsNull()){ -#ifdef OCC138 - AIS_Selection::Select(SO); - (*((Handle(AIS_InteractiveObject)*)&SO))->State(1); -#else - (*((Handle(AIS_InteractiveObject)*)&SO))->State(1); - AIS_Selection::Select(SO); -#endif //OCC138 + + aSelector->Pick (thePolyline, theView); + AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); + + AIS_MapOfInteractive anObjectsToSelect; + for (aSelector->Init(); aSelector->More(); aSelector->Next()) + { + Handle(AIS_InteractiveObject) anObj = + Handle( AIS_InteractiveObject )::DownCast (aSelector->Picked()->Selectable()); + if (!anObj.IsNull()) + { + anObjectsToSelect.Add (anObj); } } -#endif //OCC9657 - HilightCurrents(updateviewer); - - Standard_Integer NS = NbCurrents(); - if(NS==0) return AIS_SOP_NothingSelected; - if(NS==1) return AIS_SOP_OneSelected; - return AIS_SOP_SeveralSelected; + + AIS_MapIteratorOfMapOfInteractive anIt (anObjectsToSelect); + for ( ; anIt.More(); anIt.Next()) + { + AIS_Selection::Select (anIt.Key()); + anIt.Key()->State (1); + } + + HilightCurrents (toUpdateViewer); + + Standard_Integer aSelNum = NbCurrents(); + + return (aSelNum == 0) ? AIS_SOP_NothingSelected + : (aSelNum == 1) ? AIS_SOP_OneSelected + : AIS_SOP_SeveralSelected; } @@ -400,175 +386,204 @@ AIS_StatusOfPick AIS_InteractiveContext::Select(const TColgp_Array1OfPnt2d& aPol //function : Select //purpose : //======================================================================= - -AIS_StatusOfPick AIS_InteractiveContext::Select(const Standard_Boolean updateviewer) +AIS_StatusOfPick AIS_InteractiveContext::Select (const Standard_Boolean toUpdateViewer) { - if(HasOpenedContext()){ + if (HasOpenedContext()) + { if(myWasLastMain) - return myLocalContexts(myCurLocalIndex)->Select(updateviewer); + { + return myLocalContexts(myCurLocalIndex)->Select (toUpdateViewer); + } else + { + myLocalContexts(myCurLocalIndex)->SetSelected (myLastPicked, toUpdateViewer); + return AIS_SOP_OneSelected; + } + } + + if (myWasLastMain && !myLastinMain.IsNull()) + { + if(myLastinMain->State() != 1) + { + SetCurrentObject (myLastinMain,Standard_False); + if(toUpdateViewer) { - myLocalContexts(myCurLocalIndex)->SetSelected(myLastPicked,updateviewer); - return AIS_SOP_OneSelected; - } - } -// AIS_StatusOfPick PS(AIS_SOP_NothingSelected); - if(myWasLastMain && !myLastinMain.IsNull()){ - if(myLastinMain->State()!=1){ - SetCurrentObject(myLastinMain,Standard_False); - if(updateviewer) - UpdateCurrentViewer();} - } - else{ - AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); - Handle(AIS_Selection) S = AIS_Selection::CurrentSelection(); - Handle(Standard_Transient) Tr; - Handle(AIS_InteractiveObject) IO; - - for(S->Init();S->More();S->Next()){ - Tr = S->Value(); - IO = (*((Handle(AIS_InteractiveObject)*)&Tr)); - IO->State(0); - Unhilight(IO,Standard_False); - if(myObjects.IsBound(IO)){ // anti-plantage-rob - if(myObjects(IO)->IsSubIntensityOn()) - HilightWithColor(IO,mySubIntensity,Standard_False); + UpdateCurrentViewer(); } } - + } + else + { + AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); + Handle(AIS_Selection) aSelection = AIS_Selection::CurrentSelection(); + Handle(AIS_InteractiveObject) anObj; + for (aSelection->Init(); aSelection->More(); aSelection->Next()) + { + anObj = Handle(AIS_InteractiveObject)::DownCast (aSelection->Value()); + anObj->State (0); + Unhilight (anObj,Standard_False); + if (myObjects.IsBound (anObj) && myObjects(anObj)->IsSubIntensityOn()) + { + HilightWithColor (anObj, mySubIntensity, Standard_False); + } + } + AIS_Selection::Select(); - if(updateviewer){ - if(myWasLastMain) + if (toUpdateViewer && myWasLastMain) + { UpdateCurrentViewer(); } } - Standard_Integer NS = NbCurrents(); - if(NS==0) return AIS_SOP_NothingSelected; - if(NS==1) return AIS_SOP_OneSelected; - return AIS_SOP_SeveralSelected; + + Standard_Integer aSelNum = NbCurrents(); + + return (aSelNum == 0) ? AIS_SOP_NothingSelected + : (aSelNum == 1) ? AIS_SOP_OneSelected + : AIS_SOP_SeveralSelected; } //======================================================================= //function : ShiftSelect //purpose : //======================================================================= - -AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect(const Standard_Boolean updateviewer) +AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Boolean toUpdateViewer) { - if(HasOpenedContext()){ + if (HasOpenedContext()) + { if(myWasLastMain) - return myLocalContexts(myCurLocalIndex)->ShiftSelect(updateviewer); - else{ - myLocalContexts(myCurLocalIndex)->AddOrRemoveSelected(myLastPicked,updateviewer); - Standard_Integer NS =NbSelected(); - if(NS==0) return AIS_SOP_NothingSelected; - if(NS==1) return AIS_SOP_OneSelected; - return AIS_SOP_SeveralSelected; - } - } - if(myWasLastMain && !myLastinMain.IsNull()) - AddOrRemoveCurrentObject(myLastinMain,updateviewer); - - Standard_Integer NS = NbCurrents(); - if(NS==0) return AIS_SOP_NothingSelected; - if(NS==1) return AIS_SOP_OneSelected; - return AIS_SOP_SeveralSelected; -} - - -//======================================================================= -//function : ShiftSelect -//purpose : -//======================================================================= - -AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect(const Standard_Integer XPMin, - const Standard_Integer YPMin, - const Standard_Integer XPMax, - const Standard_Integer YPMax, - const Handle(V3d_View)& aView, - const Standard_Boolean updateviewer) -{ - - if(HasOpenedContext()) - return myLocalContexts(myCurLocalIndex)->ShiftSelect(XPMin,YPMin,XPMax,YPMax,aView,updateviewer); - - UnhilightCurrents(Standard_False); - // OCC11904 - local variables made non-static - it looks and works better like this - Handle(StdSelect_ViewerSelector3d) selector; - - if(aView->Viewer()== myMainVwr) { - selector= myMainSel; - myWasLastMain = Standard_True;} - else - return AIS_SOP_NothingSelected; - - selector->Pick(XPMin,YPMin,XPMax,YPMax,aView); - AIS_Selection::SetCurrentSelection(myCurrentName.ToCString()); - for(selector->Init();selector->More();selector->Next()){ - const Handle(SelectMgr_SelectableObject)& SO = selector->Picked()->Selectable(); - if(!SO.IsNull()){ - AIS_SelectStatus SelStat = AIS_Selection::Select(SO); - Standard_Integer mod = (SelStat==AIS_SS_Added)?1:0; - (*((Handle(AIS_InteractiveObject)*)&SO))->State(mod); - } - } - - HilightCurrents(updateviewer); - - Standard_Integer NS =NbCurrents(); - if(NS==0) return AIS_SOP_NothingSelected; - if(NS==1) return AIS_SOP_OneSelected; - return AIS_SOP_SeveralSelected; - -} - -//======================================================================= -//function : ShiftSelect -//purpose : -//======================================================================= - -AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect( const TColgp_Array1OfPnt2d& aPolyline, - const Handle(V3d_View)& aView, - const Standard_Boolean updateviewer ) -{ - if( HasOpenedContext() ) - return myLocalContexts( myCurLocalIndex )->ShiftSelect( aPolyline, aView, updateviewer ); - - UnhilightCurrents( Standard_False ); - // OCC11904 - local variables made non-static - it looks and works better like this - Handle(StdSelect_ViewerSelector3d) selector; - - if( aView->Viewer() == myMainVwr ) { - selector= myMainSel; - myWasLastMain = Standard_True; + { + return myLocalContexts (myCurLocalIndex)->ShiftSelect (toUpdateViewer); } else - return AIS_SOP_NothingSelected; + { + myLocalContexts (myCurLocalIndex)->AddOrRemoveSelected (myLastPicked, toUpdateViewer); - selector->Pick( aPolyline, aView ); - - AIS_Selection::SetCurrentSelection( myCurrentName.ToCString() ); - for( selector->Init(); selector->More(); selector->Next() ) { - const Handle(SelectMgr_SelectableObject)& SO = selector->Picked()->Selectable(); - if( !SO.IsNull() ) { - AIS_SelectStatus SelStat = AIS_Selection::Select( SO ); - Standard_Integer mod = ( SelStat == AIS_SS_Added ) ? 1 : 0; - (*((Handle(AIS_InteractiveObject)*)&SO))->State( mod ); - } + Standard_Integer aSelNum = NbSelected(); + return (aSelNum == 0) ? AIS_SOP_NothingSelected + : (aSelNum == 1) ? AIS_SOP_OneSelected + : AIS_SOP_SeveralSelected; } - - HilightCurrents( updateviewer ); - Standard_Integer NS = NbCurrents(); - if( NS == 0 ) return AIS_SOP_NothingSelected; - if( NS == 1 ) return AIS_SOP_OneSelected; - return AIS_SOP_SeveralSelected; + } + + if (myWasLastMain && !myLastinMain.IsNull()) + { + AddOrRemoveCurrentObject (myLastinMain, toUpdateViewer); + } + + Standard_Integer aCurrentSelNum = NbCurrents(); + + return (aCurrentSelNum == 0) ? AIS_SOP_NothingSelected + : (aCurrentSelNum == 1) ? AIS_SOP_OneSelected + : AIS_SOP_SeveralSelected; +} + +//======================================================================= +//function : ShiftSelect +//purpose : +//======================================================================= +AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const Standard_Integer theXPMin, + const Standard_Integer theYPMin, + const Standard_Integer theXPMax, + const Standard_Integer theYPMax, + const Handle(V3d_View)& theView, + const Standard_Boolean toUpdateViewer) +{ + if (HasOpenedContext()) + { + return myLocalContexts(myCurLocalIndex)->ShiftSelect (theXPMin, theYPMin, theXPMax, theYPMax, + theView, toUpdateViewer); + } + + UnhilightCurrents (Standard_False); + + Handle(StdSelect_ViewerSelector3d) aSelector; + if (theView->Viewer() == myMainVwr) + { + aSelector = myMainSel; + myWasLastMain = Standard_True; + } + else + { + return AIS_SOP_NothingSelected; + } + + aSelector->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); + AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); + for (aSelector->Init(); aSelector->More(); aSelector->Next()) + { + Handle(AIS_InteractiveObject) anObjToSelect = Handle(AIS_InteractiveObject)::DownCast (aSelector->Picked()->Selectable()); + if (!anObjToSelect.IsNull()) + { + AIS_SelectStatus aSelStatus = AIS_Selection::Select (anObjToSelect); + Standard_Integer aState = (aSelStatus == AIS_SS_Added) ? 1 : 0; + anObjToSelect->State (aState); + } + } + + HilightCurrents (toUpdateViewer); + + Standard_Integer aSelNum = NbCurrents(); + + return (aSelNum == 0) ? AIS_SOP_NothingSelected + : (aSelNum == 1) ? AIS_SOP_OneSelected + : AIS_SOP_SeveralSelected; + +} + +//======================================================================= +//function : ShiftSelect +//purpose : +//======================================================================= +AIS_StatusOfPick AIS_InteractiveContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline, + const Handle(V3d_View)& theView, + const Standard_Boolean toUpdateViewer) +{ + if (HasOpenedContext()) + { + return myLocalContexts(myCurLocalIndex)->ShiftSelect (thePolyline, theView, toUpdateViewer); + } + + UnhilightCurrents (Standard_False); + + Handle(StdSelect_ViewerSelector3d) aSelector; + + if (theView->Viewer() == myMainVwr) + { + aSelector= myMainSel; + myWasLastMain = Standard_True; + } + else + { + return AIS_SOP_NothingSelected; + } + + aSelector->Pick (thePolyline, theView); + + AIS_Selection::SetCurrentSelection (myCurrentName.ToCString()); + for (aSelector->Init(); aSelector->More(); aSelector->Next()) + { + Handle(AIS_InteractiveObject) anObjToSelect = Handle(AIS_InteractiveObject)::DownCast (aSelector->Picked()->Selectable()); + if (!anObjToSelect.IsNull()) + { + AIS_SelectStatus aSelStatus = AIS_Selection::Select (anObjToSelect); + Standard_Integer aState = (aSelStatus == AIS_SS_Added ) ? 1 : 0; + anObjToSelect->State (aState); + } + } + + HilightCurrents (toUpdateViewer); + + Standard_Integer aSelNum = NbCurrents(); + + return (aSelNum == 0) ? AIS_SOP_NothingSelected + : (aSelNum == 1) ? AIS_SOP_OneSelected + : AIS_SOP_SeveralSelected; } //======================================================================= //function : SetCurrentObject //purpose : //======================================================================= - void AIS_InteractiveContext::SetCurrentObject(const Handle(AIS_InteractiveObject)& anIObj, const Standard_Boolean updateviewer) { diff --git a/src/AIS/AIS_LocalContext.cdl b/src/AIS/AIS_LocalContext.cdl index 7b57e5ca6b..1cca3f4768 100644 --- a/src/AIS/AIS_LocalContext.cdl +++ b/src/AIS/AIS_LocalContext.cdl @@ -323,9 +323,9 @@ is aShape : Shape from TopoDS; updateviewer : Boolean from Standard=Standard_True); - AddOrRemoveSelected(me : mutable; - Ownr : EntityOwner from SelectMgr; - updateviewer : Boolean from Standard=Standard_True); + AddOrRemoveSelected(me : mutable; + theOwner : EntityOwner from SelectMgr; + toUpdateViewer : Boolean from Standard = Standard_True); diff --git a/src/AIS/AIS_LocalContext.cxx b/src/AIS/AIS_LocalContext.cxx index ae6f8684ea..1e815ee64d 100644 --- a/src/AIS/AIS_LocalContext.cxx +++ b/src/AIS/AIS_LocalContext.cxx @@ -712,7 +712,7 @@ void AIS_LocalContext::Terminate (const Standard_Boolean theToUpdate) Handle(Standard_Transient) Tr; for(S->Init();S->More();S->Next()){ Tr = S->Value(); - (*((Handle(SelectMgr_EntityOwner)*)&Tr))->State(0); + (*((Handle(SelectMgr_EntityOwner)*)&Tr))->SetSelected (Standard_False); } diff --git a/src/AIS/AIS_LocalContext_1.cxx b/src/AIS/AIS_LocalContext_1.cxx index e84de81de8..30f05e2ee8 100644 --- a/src/AIS/AIS_LocalContext_1.cxx +++ b/src/AIS/AIS_LocalContext_1.cxx @@ -181,332 +181,336 @@ AIS_StatusOfDetection AIS_LocalContext::MoveTo (const Standard_Integer theXpix, } } -//================================================== -// Function: -// Purpose : -//================================================== -AIS_StatusOfPick AIS_LocalContext::Select(const Standard_Boolean updateviewer) +//======================================================================= +//function : Select +//purpose : +//======================================================================= +AIS_StatusOfPick AIS_LocalContext::Select (const Standard_Boolean toUpdateViewer) { - if(myAutoHilight) - UnhilightPicked(Standard_False); - - Standard_Integer DI = DetectedIndex(); - AIS_Selection::SetCurrentSelection(mySelName.ToCString()); - Standard_Integer NbSel = AIS_Selection::Extent(); - - if(DI<=0){ - ClearSelected(updateviewer); - return NbSel== 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed; + if (myAutoHilight) + { + UnhilightPicked (Standard_False); } - const Handle(SelectMgr_EntityOwner)& EO = myMapOfOwner(DI); + AIS_Selection::SetCurrentSelection (mySelName.ToCString()); -#ifdef BUC60569 - ClearSelected(Standard_False); - Standard_Integer state = EO->State(); - if( state < 1 ){ - EO->State(1); - if( state == 0 ) AIS_Selection::Select(EO); + Standard_Integer aDetIndex = DetectedIndex(); + if (aDetIndex <= 0) + { + ClearSelected (toUpdateViewer); + return (AIS_Selection::Extent() == 0) ? AIS_SOP_NothingSelected : AIS_SOP_Removed; } -#else - if(!IsSelected(EO)) - AIS_Selection::ClearAndSelect(EO); -#endif - + + const Handle(SelectMgr_EntityOwner)& anOwner = myMapOfOwner (aDetIndex); + + ClearSelected (Standard_False); + + if (!anOwner->IsSelected()) // anOwner is not selected + { + anOwner->SetSelected (Standard_True); + AIS_Selection::Select (anOwner); + } + if (myAutoHilight) { const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer(); for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) { - Unhilight (EO, aViewer->ActiveView()); + Unhilight (anOwner, aViewer->ActiveView()); } // advanced selection highlighting mechanism - if (!EO->IsAutoHilight() && EO->HasSelectable()) + if (!anOwner->IsAutoHilight() && anOwner->HasSelectable()) { - Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(EO->Selectable()); + Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast(anOwner->Selectable()); UpdateSelected (anIO, Standard_False); } - if (updateviewer) + if (toUpdateViewer) { myCTX->CurrentViewer()->Update(); } } - return ( AIS_Selection::Extent() == 1)? AIS_SOP_OneSelected : AIS_SOP_SeveralSelected ; + + return (AIS_Selection::Extent() == 1) ? AIS_SOP_OneSelected : AIS_SOP_SeveralSelected; } -//================================================== -// Function: -// Purpose : -//================================================== -AIS_StatusOfPick AIS_LocalContext::Select(const Standard_Integer XPMin, - const Standard_Integer YPMin, - const Standard_Integer XPMax, - const Standard_Integer YPMax, - const Handle(V3d_View)& aView, - const Standard_Boolean updateviewer) + +//======================================================================= +//function : Select +//purpose : +//======================================================================= +AIS_StatusOfPick AIS_LocalContext::Select (const Standard_Integer theXPMin, + const Standard_Integer theYPMin, + const Standard_Integer theXPMax, + const Standard_Integer theYPMax, + const Handle(V3d_View)& theView, + const Standard_Boolean toUpdateViewer) { - if(aView->Viewer()== myCTX->CurrentViewer()){ - myMainVS->Pick( XPMin,YPMin,XPMax,YPMax,aView); - if (myAutoHilight) UnhilightPicked(Standard_False); - - AIS_Selection::SetCurrentSelection(mySelName.ToCString()); - Standard_Integer LastExt = AIS_Selection::Extent(); - - myMainVS->Init(); - if(!myMainVS->More()) { - ClearSelected(updateviewer); - mylastindex=0; - return LastExt == 0 ? AIS_SOP_NothingSelected:AIS_SOP_Removed; + if (theView->Viewer() == myCTX->CurrentViewer()) + { + myMainVS->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); + if (myAutoHilight) + { + UnhilightPicked (Standard_False); } - ClearSelected(Standard_False); - - for(myMainVS->Init();myMainVS->More();myMainVS->Next()){ - const Handle(SelectMgr_EntityOwner)& OWNR = myMainVS->Picked(); - if(myFilters->IsOk(OWNR)){ - // it can be helpfil to classify this owner immediately... -#ifdef BUC60569 - Standard_Integer state = OWNR->State(); - if( state < 1 ){ -#ifdef BUC60953 - if( state == 0 ) AIS_Selection::Select(OWNR); - OWNR->State(1); -#else - OWNR->State(1); - if( state == 0 ) AIS_Selection::Select(OWNR); -#endif //BUC60953 - } -#else //BUC60569 - if(!IsSelected(OWNR)){ - OWNR->State(1); - AIS_Selection::Select(OWNR); - } -#endif //BUC60569 + AIS_Selection::SetCurrentSelection (mySelName.ToCString()); + Standard_Integer aSelNum = AIS_Selection::Extent(); + + myMainVS->Init(); + if (!myMainVS->More()) + { + ClearSelected (toUpdateViewer); + mylastindex = 0; + return aSelNum == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed; + } + + ClearSelected (Standard_False); + + for (myMainVS->Init(); myMainVS->More(); myMainVS->Next()) + { + const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked(); + if (myFilters->IsOk (anOwner)) + { + // it can be helpful to classify this owner immediately... + if (!anOwner->IsSelected()) + { + anOwner->SetSelected (Standard_True); + AIS_Selection::Select (anOwner); + } } } - if (myAutoHilight) - HilightPicked(updateviewer); + + if (myAutoHilight) + { + HilightPicked (toUpdateViewer); + } } -#ifdef BUC60774 - Standard_Integer NS = AIS_Selection::Extent(); - if( NS == 1 ) return AIS_SOP_OneSelected; - else if( NS > 1 ) return AIS_SOP_SeveralSelected; -#endif - return AIS_SOP_Error; + + Standard_Integer aSelNum = AIS_Selection::Extent(); + + return (aSelNum == 1) ? AIS_SOP_OneSelected + : (aSelNum > 1) ? AIS_SOP_SeveralSelected + : AIS_SOP_Error; } - - //================================================== -// Function: -// Purpose : +// Function: Select +// Purpose : Selection by polyline //================================================== -AIS_StatusOfPick AIS_LocalContext::ShiftSelect(const Standard_Boolean updateviewer) +AIS_StatusOfPick AIS_LocalContext::Select (const TColgp_Array1OfPnt2d& thePolyline, + const Handle(V3d_View)& theView, + const Standard_Boolean toUpdateViewer) { - Standard_Integer I = DetectedIndex(); - if(I>0){ - - AIS_Selection::SetCurrentSelection(mySelName.ToCString()); -#ifdef BUC60774 - Standard_Integer NbSel = AIS_Selection::Extent(); -#endif - const Handle(SelectMgr_EntityOwner)& EO = myMapOfOwner(I); -#ifdef BUC60569 - Standard_Integer mod = EO->State()==0 ? -1 : 0; -#else - Standard_Integer mod = EO->State()==0 ? 1 : 0; -#endif + if (theView->Viewer() == myCTX->CurrentViewer()) + { + myMainVS->Pick (thePolyline, theView); -#ifdef BUC60953 - AIS_Selection::Select(EO); - EO->State(mod); -#else - EO->State(mod); + AIS_Selection::SetCurrentSelection (mySelName.ToCString()); + + Standard_Integer aLastSelNum = AIS_Selection::Extent(); + myMainVS->Init(); + if (!myMainVS->More()) + { + // Nothing is selected clear selection. + ClearSelected (toUpdateViewer); + mylastindex = 0; + + // Return state to know if something was unselected + return aLastSelNum == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed; + } + + if (myAutoHilight) + { + UnhilightPicked (Standard_False); + } + + // Clear previous selection without update to process this selection + ClearSelected (Standard_False); + + for (myMainVS->Init(); myMainVS->More(); myMainVS->Next()) + { + const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked(); + if (myFilters->IsOk (anOwner)) + { + // it can be helpful to classify this owner immediately... + if (!anOwner->IsSelected()) + { + AIS_Selection::AddSelect (anOwner); + anOwner->SetSelected (Standard_True); + } + } + } + + if (myAutoHilight) + { + HilightPicked (toUpdateViewer); + } + } + + Standard_Integer aSelNum = AIS_Selection::Extent(); + return (aSelNum == 1) ? AIS_SOP_OneSelected + : (aSelNum > 1) ? AIS_SOP_SeveralSelected + : AIS_SOP_Error; +} + +//======================================================================= +//function : ShiftSelect +//purpose : +//======================================================================= +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_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True; + AIS_Selection::Select (anOwner); + anOwner->SetSelected (toSelect); - AIS_Selection::Select(EO); -#endif - if(myAutoHilight) { const Handle(V3d_Viewer)& aViewer = myCTX->CurrentViewer(); for (aViewer->InitActiveViews(); aViewer->MoreActiveViews(); aViewer->NextActiveViews()) { - Unhilight (EO, aViewer->ActiveView()); + Unhilight (anOwner, aViewer->ActiveView()); } // advanced selection highlighting mechanism - if (!EO->IsAutoHilight() && EO->HasSelectable()) + if (!anOwner->IsAutoHilight() && anOwner->HasSelectable()) { - Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (EO->Selectable()); + Handle(AIS_InteractiveObject) anIO = Handle(AIS_InteractiveObject)::DownCast (anOwner->Selectable()); UpdateSelected (anIO, Standard_False); } - if (updateviewer) + if (toUpdateViewer) { myCTX->CurrentViewer()->Update(); } } + #ifdef BUC60774 Standard_Integer NS = AIS_Selection::Extent(); if( NS == 1 ) return AIS_SOP_OneSelected; else if( NS > 1 ) return AIS_SOP_SeveralSelected; - return NbSel== 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed; + return aSelNum == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed; #endif } return AIS_SOP_Error; } -//================================================== -// Function: the already selected objects are unselected -// Purpose : others are selected. -//================================================== -AIS_StatusOfPick AIS_LocalContext::ShiftSelect(const Standard_Integer XPMin, - const Standard_Integer YPMin, - const Standard_Integer XPMax, - const Standard_Integer YPMax, - const Handle(V3d_View)& aView, - const Standard_Boolean updateviewer) + +//======================================================================= +//function : ShiftSelect +//purpose : +//======================================================================= +AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const Standard_Integer theXPMin, + const Standard_Integer theYPMin, + const Standard_Integer theXPMax, + const Standard_Integer theYPMax, + const Handle(V3d_View)& theView, + const Standard_Boolean toUpdateViewer) { myMainPM->ClearImmediateDraw(); - if(aView->Viewer()== myCTX->CurrentViewer()) { - myMainVS->Pick( XPMin,YPMin,XPMax,YPMax,aView); -#ifdef BUC60774 - AIS_Selection::SetCurrentSelection(mySelName.ToCString()); - Standard_Integer LastExt = AIS_Selection::Extent(); -#endif + if (theView->Viewer() == myCTX->CurrentViewer()) + { + myMainVS->Pick (theXPMin, theYPMin, theXPMax, theYPMax, theView); + + AIS_Selection::SetCurrentSelection (mySelName.ToCString()); + Standard_Integer aLastSelNum = AIS_Selection::Extent(); + myMainVS->Init(); - if(!myMainVS->More()) -#ifdef BUC60774 - return LastExt == 0 ? AIS_SOP_NothingSelected:AIS_SOP_Removed; -#else - return AIS_SOP_NothingSelected; // no effet if click on empty space -#endif + if (!myMainVS->More()) + { + // Nothing is selected clear selection, but don't clear the selection + // as it is shift selection and previous selection matters. + // Return state to know if something was unselected + return aLastSelNum == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed; + } - AIS_Selection::SetCurrentSelection(mySelName.ToCString()); - if (myAutoHilight) UnhilightPicked(Standard_False); - - for(myMainVS->Init();myMainVS->More();myMainVS->Next()){ - const Handle(SelectMgr_EntityOwner)& EO = myMainVS->Picked(); - if(myFilters->IsOk(EO)){ -#ifdef BUC60569 - Standard_Integer mod = EO->State()==0 ? -1 : 0; -#else - Standard_Integer mod = EO->State()==0 ? 1 : 0; -#endif + if (myAutoHilight) + { + UnhilightPicked (Standard_False); + } -#ifdef BUC60953 - AIS_Selection::Select(EO); - EO->State(mod); -#else - EO->State(mod); - AIS_Selection::Select(EO); -#endif + for (myMainVS->Init(); myMainVS->More(); myMainVS->Next()) + { + const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked(); + if(myFilters->IsOk (anOwner)) + { + Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True; + AIS_Selection::Select (anOwner); + anOwner->SetSelected (toSelect); } } - if (myAutoHilight) HilightPicked(updateviewer); - + + if (myAutoHilight) + { + HilightPicked (toUpdateViewer); + } } -#ifdef BUC60774 - Standard_Integer NS = AIS_Selection::Extent(); - if( NS == 1 ) return AIS_SOP_OneSelected; - else if( NS > 1 ) return AIS_SOP_SeveralSelected; -#endif - return AIS_SOP_Error; + + Standard_Integer aSelNum = AIS_Selection::Extent(); + + return (aSelNum == 1) ? AIS_SOP_OneSelected + : (aSelNum > 1) ? AIS_SOP_SeveralSelected + : AIS_SOP_Error; } //================================================== // Function: Select // Purpose : Selection by polyline //================================================== -AIS_StatusOfPick AIS_LocalContext::Select(const TColgp_Array1OfPnt2d& aPolyline, - const Handle(V3d_View)& aView, - const Standard_Boolean updateviewer) +AIS_StatusOfPick AIS_LocalContext::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyline, + const Handle(V3d_View)& theView, + const Standard_Boolean toUpdateViewer) { - if(aView->Viewer()== myCTX->CurrentViewer()){ - myMainVS->Pick(aPolyline,aView); - if (myAutoHilight) UnhilightPicked(Standard_False); - - AIS_Selection::SetCurrentSelection(mySelName.ToCString()); - Standard_Integer LastExt = AIS_Selection::Extent(); - + if (theView->Viewer() == myCTX->CurrentViewer()) + { + myMainVS->Pick (thePolyline, theView); + + AIS_Selection::SetCurrentSelection (mySelName.ToCString()); + + Standard_Integer aLastSelNum = AIS_Selection::Extent(); myMainVS->Init(); - if(!myMainVS->More()) { - ClearSelected(updateviewer); - mylastindex=0; - return LastExt == 0 ? AIS_SOP_NothingSelected:AIS_SOP_Removed; + if(!myMainVS->More()) + { + // Nothing is selected clear selection, but don't clear the selection + // as it is shift selection and previous selection matters. + // Return state to know if something was unselected + return aLastSelNum == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed; } - ClearSelected(Standard_False); + if (myAutoHilight) + { + UnhilightPicked (Standard_False); + } - for(myMainVS->Init();myMainVS->More();myMainVS->Next()){ - const Handle(SelectMgr_EntityOwner)& OWNR = myMainVS->Picked(); - if(myFilters->IsOk(OWNR)){ - // it can be helpfil to classify this owner immediately... -#ifdef BUC60953 - Standard_Integer state = OWNR->State(); - if( state < 1 ){ - if( state == 0 ) AIS_Selection::AddSelect(OWNR); - OWNR->State(1); - } -#else - if(!IsSelected(OWNR)){ - OWNR->State(1); - AIS_Selection::AddSelect(OWNR); - } -#endif //BUC60953 + for (myMainVS->Init(); myMainVS->More(); myMainVS->Next()) + { + const Handle(SelectMgr_EntityOwner)& anOwner = myMainVS->Picked(); + if (myFilters->IsOk (anOwner)) + { + Standard_Boolean toSelect = anOwner->IsSelected() ? Standard_False : Standard_True; + AIS_Selection::Select (anOwner); + anOwner->SetSelected (toSelect); } } - - if (myAutoHilight) - HilightPicked(updateviewer); - } -#ifdef BUC60774 - Standard_Integer NS = AIS_Selection::Extent(); - if( NS == 1 ) return AIS_SOP_OneSelected; - else if( NS > 1 ) return AIS_SOP_SeveralSelected; -#endif - return AIS_SOP_Error; -} - -//================================================== -// Function: Select -// Purpose : Selection by polyline -//================================================== -AIS_StatusOfPick AIS_LocalContext::ShiftSelect( const TColgp_Array1OfPnt2d& aPolyline, - const Handle(V3d_View)& aView, - const Standard_Boolean updateviewer ) -{ - if( aView->Viewer() == myCTX->CurrentViewer() ) { - myMainVS->Pick( aPolyline, aView ); - - AIS_Selection::SetCurrentSelection( mySelName.ToCString() ); - Standard_Integer LastExt = AIS_Selection::Extent(); - myMainVS->Init(); - if( !myMainVS->More() ) - return LastExt == 0 ? AIS_SOP_NothingSelected : AIS_SOP_Removed; - - AIS_Selection::SetCurrentSelection( mySelName.ToCString() ); - - if ( myAutoHilight ) - UnhilightPicked( Standard_False ); - for( myMainVS->Init(); myMainVS->More(); myMainVS->Next() ) { - const Handle(SelectMgr_EntityOwner)& EO = myMainVS->Picked(); - if( myFilters->IsOk( EO ) ) { - Standard_Integer mod = EO->State() == 0 ? -1 : 0; - AIS_Selection::Select(EO); - EO->State( mod ); - } - } - if ( myAutoHilight ) - HilightPicked( updateviewer ); + if (myAutoHilight) + { + HilightPicked (toUpdateViewer); } - Standard_Integer NS = AIS_Selection::Extent(); - if( NS == 1 ) - return AIS_SOP_OneSelected; - else if( NS > 1 ) - return AIS_SOP_SeveralSelected; - return AIS_SOP_Error; + } + + Standard_Integer aSelNum = AIS_Selection::Extent(); + + return (aSelNum == 1) ? AIS_SOP_OneSelected + : (aSelNum > 1) ? AIS_SOP_SeveralSelected + : AIS_SOP_Error; } //================================================== @@ -713,15 +717,9 @@ Standard_Boolean AIS_LocalContext::IsSelected(const Handle(AIS_InteractiveObject //purpose : //======================================================================= -Standard_Boolean AIS_LocalContext::IsSelected(const Handle(SelectMgr_EntityOwner)& Ownr) const +Standard_Boolean AIS_LocalContext::IsSelected (const Handle(SelectMgr_EntityOwner)& theOwner) const { - if (Ownr.IsNull()) return Standard_False; -#ifdef BUC60569 - Standard_Boolean state = (Ownr->State()!=0); -#else - Standard_Boolean state = (Ownr->State()==1); -#endif - return state; + return !theOwner.IsNull() && theOwner->IsSelected(); } //================================================== @@ -893,7 +891,7 @@ void AIS_LocalContext::UpdateSelected(const Handle(AIS_InteractiveObject)& anobj // Function: ClearSelected // Purpose : //================================================== -void AIS_LocalContext::ClearSelected(const Standard_Boolean updateviewer) +void AIS_LocalContext::ClearSelected (const Standard_Boolean updateviewer) { UnhilightPicked(updateviewer); AIS_Selection::SetCurrentSelection(mySelName.ToCString()); @@ -909,8 +907,9 @@ void AIS_LocalContext::ClearSelected(const Standard_Boolean updateviewer) for(; anIter.More(); anIter.Next()){ const Handle(Standard_Transient)& Tr = anIter.Value(); #endif - if(!Tr.IsNull()){ - (*((const Handle(SelectMgr_EntityOwner)*)&Tr))->State(0); + if(!Tr.IsNull()) + { + (*((const Handle(SelectMgr_EntityOwner)*)&Tr))->SetSelected (Standard_False); } } AIS_Selection::Select(); @@ -950,13 +949,10 @@ void AIS_LocalContext::SetSelected(const Handle(AIS_InteractiveObject)& anIObj, } ClearSelected(Standard_False); -#ifdef OCC138 + AIS_Selection::Select(EO); - EO->State(1); -#else - EO->State(1); - AIS_Selection::Select(EO); -#endif + EO->SetSelected (Standard_True); + HilightPicked(updateviewer); } @@ -974,42 +970,34 @@ void AIS_LocalContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)& Handle(SelectMgr_EntityOwner) EO; EO = FindSelectedOwnerFromIO(anIObj); -#ifndef OCC138 - if(!EO.IsNull()) - EO->State(0); - else{ -#else - if(EO.IsNull()) { -#endif - if(anIObj->HasSelection(0)){ + + if (EO.IsNull()) + { + 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); + if(SIOBJ->More()) + { + Handle(SelectBasics_EntityOwner) BO = SIOBJ->Sensitive()->OwnerId(); + EO = *((Handle(SelectMgr_EntityOwner)*)&BO); } } - if(EO.IsNull()) + if(EO.IsNull()) + { EO = new SelectMgr_EntityOwner(anIObj); -#ifndef OCC138 - EO->State(1); -#endif + } } // cout<<"AIS_LocalContext::AddOrRemoveSelected : Selection = "<Select(EO); - if(aStatus == AIS_SS_Added) - EO->State(1); - else - EO->State(0); + EO->SetSelected (aStatus == AIS_SS_Added); } -#else - if(!S.IsNull()) - S->Select(EO); -#endif + HilightPicked(updateviewer); } @@ -1020,42 +1008,33 @@ void AIS_LocalContext::AddOrRemoveSelected(const Handle(AIS_InteractiveObject)& void AIS_LocalContext::AddOrRemoveSelected(const TopoDS_Shape& Sh, const Standard_Boolean updateviewer) { - UnhilightPicked(Standard_False); + UnhilightPicked (Standard_False); Handle(SelectMgr_EntityOwner) EO = FindSelectedOwnerFromShape(Sh); - if(!EO.IsNull()){ -// cout<<"AIS_LocalContext::AddOrRemoveSelected(sh) : Selection = "<Select(EO); - EO->State(1); -#else - EO->State(1); - AIS_Selection::Selection(mySelName.ToCString())->Select(EO); -#endif + EO->SetSelected (Standard_True); } - HilightPicked(updateviewer); + HilightPicked (updateviewer); } -void AIS_LocalContext::AddOrRemoveSelected(const Handle(SelectMgr_EntityOwner)& Ownr, - const Standard_Boolean updateviewer) -{ - //Not Yet Implemented +void AIS_LocalContext::AddOrRemoveSelected (const Handle(SelectMgr_EntityOwner)& theOwner, + const Standard_Boolean toUpdateViewer) +{ if(myAutoHilight) - UnhilightPicked(Standard_False); -// cout<<"AIS_LocalContext::AddOrRemoveSelected(ownr) : Selection = "<State()==0 ? 1 : 0; -#ifdef OCC138 - AIS_Selection::Selection(mySelName.ToCString())->Select(Ownr); + Standard_Boolean toSelect = theOwner->IsSelected() ? Standard_False : Standard_True; + + AIS_Selection::Selection (mySelName.ToCString())->Select (theOwner); + theOwner->SetSelected (toSelect); - Ownr->State(mod); -#else - Ownr->State(mod); - - AIS_Selection::Selection(mySelName.ToCString())->Select(Ownr); -#endif if(myAutoHilight) - HilightPicked(updateviewer); + { + HilightPicked (toUpdateViewer); + } } //================================================== @@ -1128,8 +1107,7 @@ void AIS_LocalContext::manageDetected (const Handle(SelectMgr_EntityOwner)& theP if (myAutoHilight) { - if (thePickOwner->State() <= 0 - || myCTX->ToHilightSelected()) + if (!thePickOwner->IsSelected() || myCTX->ToHilightSelected()) { Hilight (thePickOwner, theView); } diff --git a/src/MeshVS/MeshVS_MeshOwner.cxx b/src/MeshVS/MeshVS_MeshOwner.cxx index 5d4c9dcfcc..6fafebf276 100644 --- a/src/MeshVS/MeshVS_MeshOwner.cxx +++ b/src/MeshVS/MeshVS_MeshOwner.cxx @@ -123,7 +123,7 @@ void MeshVS_MeshOwner::SetDetectedEntities (const Handle(TColStd_HPackedMapOfInt { myDetectedNodes = Nodes; myDetectedElems = Elems; - if( State() ) State( 0 ); + if (IsSelected()) SetSelected (Standard_False); } //================================================================ diff --git a/src/SelectMgr/SelectMgr_EntityOwner.cdl b/src/SelectMgr/SelectMgr_EntityOwner.cdl index 148a1ea005..d08eeadf11 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.cdl +++ b/src/SelectMgr/SelectMgr_EntityOwner.cdl @@ -130,20 +130,33 @@ is --very Internal method (to be used in selection process only...) + SetSelected(me:mutable;theIsSelected : Boolean from Standard); + ---C++: inline + ---Purpose:Set the state of the owner. + -- @param theIsSelected [in] shows if owner is selected. + IsSelected(me) returns Boolean from Standard; + ---C++: inline + ---Purpose: @return Standard_True if the owner is selected. + State(me:mutable;aStatus:Integer from Standard); - ---C++: inline + ---C++: inline + ---Purpose:Set the state of the owner. + -- The method is deprecated. Use SetSelected() instead. + State(me) returns Integer from Standard; - ---C++: inline + ---C++: inline + -- @return 1 if the owner is selected and 0 otherwise. + -- The method is deprecated. Use IsSelected() instead. IsAutoHilight ( me ) returns Boolean from Standard is virtual; ---Purpose: if owner is not auto hilighted, for group contains many such owners -- will be called one method HilightSelected of SelectableObject - + IsForcedHilight ( me ) returns Boolean from Standard is virtual; ---Purpose: if this method returns TRUE the owner will allways call method -- Hilight for SelectableObject when the owner is detected. By default -- it always return FALSE. - + SetZLayer ( me : mutable; thePrsMgr : PresentationManager from PrsMgr; theLayerId : Integer from Standard ) @@ -153,6 +166,11 @@ is fields mySelectable : SOPtr; - mystate : Integer from Standard; + + myIsSelected : Boolean from Standard; + ---Purpose: Describes selection state of this owner: + -- Standard_False: the owner not selected + -- Standard_True: the owner is selected. + end EntityOwner; diff --git a/src/SelectMgr/SelectMgr_EntityOwner.cxx b/src/SelectMgr/SelectMgr_EntityOwner.cxx index 1071e8e9c4..cc670f6246 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.cxx +++ b/src/SelectMgr/SelectMgr_EntityOwner.cxx @@ -25,14 +25,14 @@ SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Standard_Integer aPriority): SelectBasics_EntityOwner(aPriority), mySelectable(NULL), -mystate(0) +myIsSelected (Standard_False) { } SelectMgr_EntityOwner::SelectMgr_EntityOwner(const Handle(SelectMgr_SelectableObject)& aSO, const Standard_Integer aPriority): SelectBasics_EntityOwner(aPriority), -mystate(0) +myIsSelected (Standard_False) { mySelectable = aSO.operator->(); } diff --git a/src/SelectMgr/SelectMgr_EntityOwner.lxx b/src/SelectMgr/SelectMgr_EntityOwner.lxx index eacf544523..cad8ed7699 100644 --- a/src/SelectMgr/SelectMgr_EntityOwner.lxx +++ b/src/SelectMgr/SelectMgr_EntityOwner.lxx @@ -15,7 +15,13 @@ // commercial license or contractual agreement. inline Standard_Integer SelectMgr_EntityOwner::State() const -{return mystate;} +{ return myIsSelected ? 1 : 0; } inline void SelectMgr_EntityOwner::State(const Standard_Integer aStatus) -{mystate = aStatus;} +{ myIsSelected = (aStatus == 1);} + +inline Standard_Boolean SelectMgr_EntityOwner::IsSelected() const +{ return myIsSelected; } + +inline void SelectMgr_EntityOwner::SetSelected (const Standard_Boolean theIsSelected) +{ myIsSelected = theIsSelected; } diff --git a/src/ViewerTest/ViewerTest_EventManager.cdl b/src/ViewerTest/ViewerTest_EventManager.cdl index e3c69651c7..73f2d123d1 100644 --- a/src/ViewerTest/ViewerTest_EventManager.cdl +++ b/src/ViewerTest/ViewerTest_EventManager.cdl @@ -49,6 +49,9 @@ is ---C++: inline ---C++: return const& + GetCurrentPosition (me; theXPix, theYPix: out Integer from Standard); + ---Purpose: Gets current mouse position. It tracks change of mouse position + -- with mouse drugging or with DRAW command call (vmoveto). fields myCtx : InteractiveContext from AIS; diff --git a/src/ViewerTest/ViewerTest_EventManager.cxx b/src/ViewerTest/ViewerTest_EventManager.cxx index 2b531c598e..cba9c35486 100644 --- a/src/ViewerTest/ViewerTest_EventManager.cxx +++ b/src/ViewerTest/ViewerTest_EventManager.cxx @@ -242,3 +242,9 @@ void ViewerTest_EventManager::ShiftSelect (const TColgp_Array1OfPnt2d& thePolyli } myView->Redraw(); } + +void ViewerTest_EventManager::GetCurrentPosition (Standard_Integer& theXPix, Standard_Integer& theYPix) const +{ + theXPix = myX; + theYPix = myY; +} diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index bdd04f983b..345a2441e3 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -6649,6 +6649,70 @@ static int VFrustumCulling (Draw_Interpretor& theDI, return 0; } +//======================================================================= +//function : VHighlightSelected +//purpose : +//======================================================================= +static int VHighlightSelected (Draw_Interpretor& theDI, + Standard_Integer theArgNb, + const char** theArgVec) +{ + if (ViewerTest::GetAISContext().IsNull()) + { + std::cout << theArgVec[0] << " error : Context is not created. Please call vinit before.\n"; + return 1; + } + + const Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); + + if (theArgNb < 2) + { + theDI << (aContext->ToHilightSelected() ? "on" : "off"); + return 0; + } + + if (theArgNb != 2) + { + std::cout << theArgVec[0] << " error : wrong number of parameters." + << "Type 'help" << theArgVec[0] << "' for more information."; + return 1; + } + + // Parse parameter + TCollection_AsciiString aMode (theArgVec[1]); + aMode.LowerCase(); + Standard_Boolean toEnable = Standard_False; + if (aMode.IsEqual ("on")) + { + toEnable = Standard_True; + } + else if (aMode.IsEqual ("off")) + { + toEnable = Standard_False; + } + else + { + toEnable = Draw::Atoi (theArgVec[1]) != 0; + } + + if (toEnable != aContext->ToHilightSelected()) + { + aContext->SetToHilightSelected (toEnable); + + // Move cursor to null position and back to process updating of detection + // and highlighting of selected object immediatly. + Standard_Integer aPixX = 0; + Standard_Integer aPixY = 0; + const Handle(ViewerTest_EventManager)& anEventManager = ViewerTest::CurrentEventManager(); + + anEventManager->GetCurrentPosition (aPixX, aPixY); + anEventManager->MoveTo (0, 0); + anEventManager->MoveTo (aPixX, aPixY); + } + + return 0; +} + //======================================================================= //function : ViewerCommands //purpose : @@ -7017,4 +7081,9 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) theCommands.Add("vfrustumculling", "vfrustumculling [toEnable]: enables/disables objects clipping", __FILE__,VFrustumCulling,group); + theCommands.Add("vhighlightselected", + "vhighlightselected [0|1] or vhighlightselected [on|off]: enables/disables highlighting of selected objects.\n" + "Without arguments it shows if highlighting of selected objects is enabled now.", + __FILE__,VHighlightSelected,group); + } diff --git a/tests/bugs/vis/bug23649_1 b/tests/bugs/vis/bug23649_1 new file mode 100644 index 0000000000..9a5d3fbd08 --- /dev/null +++ b/tests/bugs/vis/bug23649_1 @@ -0,0 +1,34 @@ +puts "============" +puts "CR23649" +puts "============" +puts "" + +####################################################################### +# 0023649: Different behaviour of highlighting after shift selection. +# It tests default functionality of highlighting +# during shift selection of sub-shapes (local context). +####################################################################### + +set anImage1 $imagedir/${casename}_Selection.png +set anImage2 $imagedir/${casename}_HighlightFirst.png +set anImage3 $imagedir/${casename}_HighlightSecond.png + +box b 1 2 3 +vinit +vdisplay b +vfit +vselmode b 2 1 +#select the first edge +vselect 232 368 +#select the second edge +vselect 165 278 1 +vmoveto 0 0 +vdump ${anImage1} + +#highlight the first edge - it should NOT be highlightable by default +vmoveto 232 368 +vdump ${anImage2} + +#highlight the second edge - it should NOT be highlightable by default +vmoveto 165 278 +vdump ${anImage3} \ No newline at end of file diff --git a/tests/bugs/vis/bug23649_2 b/tests/bugs/vis/bug23649_2 new file mode 100644 index 0000000000..dddc281e25 --- /dev/null +++ b/tests/bugs/vis/bug23649_2 @@ -0,0 +1,35 @@ +puts "============" +puts "CR23649" +puts "============" +puts "" + +####################################################################### +# 0023649: Different behaviour of highlighting after shift selection +# It tests highlighting of selected sub-shapes. +# This mode is option of interactive context. +####################################################################### + +set anImage1 $imagedir/${casename}_HighlightFirst.png +set anImage2 $imagedir/${casename}_HighlightSecond.png + +box b 1 2 3 +vinit +vdisplay b +vfit +vselmode b 2 1 +#select the first edge +vselect 232 368 +#select the second edge +vselect 165 278 1 +vmoveto 0 0 + +#enable 'highlight selected' mode +vhighlightselected on + +#highlight the first edge - it should be highlightable by default +vmoveto 232 368 +vdump ${anImage1} + +#highlight the second edge - it should be highlightable by default +vmoveto 165 278 +vdump ${anImage2} \ No newline at end of file diff --git a/tests/bugs/vis/bug23649_3 b/tests/bugs/vis/bug23649_3 new file mode 100644 index 0000000000..dced33d705 --- /dev/null +++ b/tests/bugs/vis/bug23649_3 @@ -0,0 +1,34 @@ +puts "============" +puts "CR23649" +puts "============" +puts "" + +####################################################################### +# 0023649: Different behaviour of highlighting after shift selection. +# It tests default functionality of highlighting +# during shift selection of shapes (neutral point). +####################################################################### + +set anImage1 $imagedir/${casename}_Selection.png +set anImage2 $imagedir/${casename}_HighlightFirst.png +set anImage3 $imagedir/${casename}_HighlightSecond.png + +box a 2 0 0 3 2 1 +box b 1 2 3 +vinit +vdisplay a b +vfit +#select the first shape +vselect 70 230 +#select the second shape +vselect 200 360 1 +vmoveto 0 0 +vdump ${anImage1} + +#highlight the first edge - it should NOT be highlightable by default +vmoveto 70 230 +vdump ${anImage2} + +#highlight the second edge - it should NOT be highlightable by default +vmoveto 200 360 +vdump ${anImage3} \ No newline at end of file diff --git a/tests/bugs/vis/bug23649_4 b/tests/bugs/vis/bug23649_4 new file mode 100644 index 0000000000..9292942e86 --- /dev/null +++ b/tests/bugs/vis/bug23649_4 @@ -0,0 +1,35 @@ +puts "============" +puts "CR23649" +puts "============" +puts "" + +####################################################################### +# 0023649: Different behaviour of highlighting after shift selection +# It tests highlighting of selected shapes (neutral point). +# This mode is option of interactive context. +####################################################################### + +set anImage1 $imagedir/${casename}_HighlightFirst.png +set anImage2 $imagedir/${casename}_HighlightSecond.png + +box a 2 0 0 3 2 1 +box b 1 2 3 +vinit +vdisplay a b +vfit +#select the first shape +vselect 70 230 +#select the second shape +vselect 200 360 1 +vmoveto 0 0 + +#enable 'highlight selected' mode +vhighlightselected on + +#highlight the first edge - it should be highlightable by default +vmoveto 70 230 +vdump ${anImage1} + +#highlight the second edge - it should be highlightable by default +vmoveto 200 360 +vdump ${anImage2} \ No newline at end of file diff --git a/tests/bugs/vis/bug597_2 b/tests/bugs/vis/bug597_2 index f49ae714b3..2ea54ede9f 100755 --- a/tests/bugs/vis/bug597_2 +++ b/tests/bugs/vis/bug597_2 @@ -15,7 +15,7 @@ puts "" restore [locate_data_file buc60569a.rle] result tclean result vinit - +vhighlightselected 0 checkshape result BUC60569 result