From 4ce7b50be7905bde9445f81243231e0031a9a26e Mon Sep 17 00:00:00 2001 From: rnv Date: Thu, 27 Feb 2014 10:59:19 +0400 Subject: [PATCH] Fix for the "0022466: [CEA 1047] Mesh stays selected when selection is disabled in the 3D view" issue. --- src/LightApp/LightApp_OCCSelector.cxx | 3 +++ src/LightApp/LightApp_VTKSelector.cxx | 6 +++++- src/OCCViewer/OCCViewer_ViewModel.cxx | 12 ++++++++++++ src/SVTK/SVTK_ViewModel.cxx | 17 +++++++++++++++++ 4 files changed, 37 insertions(+), 1 deletion(-) diff --git a/src/LightApp/LightApp_OCCSelector.cxx b/src/LightApp/LightApp_OCCSelector.cxx index 3e8b4eb18..6f78bc76a 100644 --- a/src/LightApp/LightApp_OCCSelector.cxx +++ b/src/LightApp/LightApp_OCCSelector.cxx @@ -85,6 +85,9 @@ void LightApp_OCCSelector::getSelection( SUIT_DataOwnerPtrList& aList ) const if ( !myViewer ) return; + if ( !myViewer->isSelectionEnabled() ) + return; + AIS_ListOfInteractive aSelList; myViewer->getSelectedObjects( aSelList ); for ( AIS_ListIteratorOfListOfInteractive anIt( aSelList ); anIt.More(); anIt.Next() ) diff --git a/src/LightApp/LightApp_VTKSelector.cxx b/src/LightApp/LightApp_VTKSelector.cxx index 015530eb9..79f9e735a 100644 --- a/src/LightApp/LightApp_VTKSelector.cxx +++ b/src/LightApp/LightApp_VTKSelector.cxx @@ -187,7 +187,11 @@ void LightApp_VTKSelector ::getSelection( SUIT_DataOwnerPtrList& aList ) const { - if(myViewer){ + if( myViewer ) { + if( SVTK_Viewer* aSViewer = dynamic_cast(myViewer) ) { + if( !aSViewer->isSelectionEnabled() ) + return; + } if(SUIT_ViewManager* aViewManager = myViewer->getViewManager()){ if(SVTK_ViewManager* aViewMgr = dynamic_cast(aViewManager)){ if(SVTK_ViewWindow* aView = dynamic_cast(aViewMgr->getActiveView())){ diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index c9e7f933a..242756b9f 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -533,6 +533,13 @@ void OCCViewer_Viewer::enableSelection(bool isEnabled) win->enableSelection( isEnabled ); } } + + + //clear current selection in the viewer + if(!isEnabled) { + myAISContext->ClearSelected( Standard_True ); + } + } /*! @@ -1015,6 +1022,11 @@ void OCCViewer_Viewer::setSelectionOptions( bool isPreselectionEnabled, bool isS { myPreselectionEnabled = isPreselectionEnabled; mySelectionEnabled = isSelectionEnabled; + //clear current selection in the viewer + + if(!mySelectionEnabled) { + myAISContext->ClearSelected( Standard_True ); + } } diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 1e00b2cfc..2f2477e99 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -504,6 +504,23 @@ void SVTK_Viewer::enableSelection(bool isEnabled) aView->SetSelectionEnabled( isEnabled ); } } + + if(!isEnabled) { + //clear current selection in the viewer + bool blocked = blockSignals( true ); + if ( SUIT_ViewManager* aViewMgr = getViewManager() ) { + if( SVTK_ViewWindow* aViewWindow = dynamic_cast( aViewMgr->getActiveView() ) ){ + if( SVTK_Selector* aSelector = aViewWindow->GetSelector() ) { + if(SVTK_View* aView = aViewWindow->getView()){ + aSelector->ClearIObjects(); + aView->onSelectionChanged(); + } + } + } + } + blockSignals( blocked ); + } + } /*! -- 2.39.2