From ff4c9a27179d5b56d2a6b4c66c7dff15a0fef4d9 Mon Sep 17 00:00:00 2001 From: akl Date: Wed, 28 May 2014 09:11:20 +0400 Subject: [PATCH] Implementation of 'Show' and 'Show Only' actions from popup menu for selected objects in Dependency tree. --- src/DependencyTree/CMakeLists.txt | 2 +- .../DependencyTree_ViewModel.cxx | 81 ++++++++++++++++++- src/DependencyTree/DependencyTree_ViewModel.h | 4 + 3 files changed, 83 insertions(+), 4 deletions(-) diff --git a/src/DependencyTree/CMakeLists.txt b/src/DependencyTree/CMakeLists.txt index 30d86cbad..36d212005 100644 --- a/src/DependencyTree/CMakeLists.txt +++ b/src/DependencyTree/CMakeLists.txt @@ -74,12 +74,12 @@ SET(DependencyTree_HEADERS DependencyTree.h DependencyTree_Object.h DependencyTree_Arrow.h - DependencyTree_ViewModel.h ) # header files / to be processed by moc SET(_moc_HEADERS DependencyTree_View.h + DependencyTree_ViewModel.h ) # --- sources --- diff --git a/src/DependencyTree/DependencyTree_ViewModel.cxx b/src/DependencyTree/DependencyTree_ViewModel.cxx index deb504074..b3301b981 100644 --- a/src/DependencyTree/DependencyTree_ViewModel.cxx +++ b/src/DependencyTree/DependencyTree_ViewModel.cxx @@ -17,14 +17,24 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -#include - #include "DependencyTree_ViewModel.h" + #include "DependencyTree_View.h" +#include "GEOM_Displayer.h" +#include #include +#include +#include +#include +#include +#include +#include +#include +#include #include +#include #include DependencyTree_ViewModel::DependencyTree_ViewModel( const QString& title ) @@ -42,6 +52,68 @@ DependencyTree_ViewModel::~DependencyTree_ViewModel() { } +void activateOCCViewer() { +} + +void DependencyTree_ViewModel::onShowSelected() +{ + std::cout<<"\n\n\n\n *****onShowSelected " << std::endl; + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; + + app->getViewManager(OCCViewer_Viewer::Type(), /*create=*/true); + + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + SalomeApp_Study* appStudy = dynamic_cast(app->activeStudy()); + GEOM_Displayer* disp = new GEOM_Displayer( appStudy ); + + OCCViewer_ViewManager* anOCCVM = (OCCViewer_ViewManager*) app->getViewManager( OCCViewer_Viewer::Type(), /*create=*/true ); + + if ( SUIT_ViewModel* vmod = anOCCVM->getViewModel() ) { + if ( SALOME_View* aViewFrame = dynamic_cast( vmod ) ) { + SALOME_ListIteratorOfListIO Iter( aSelList ); + for ( ; Iter.More(); Iter.Next() ) { + disp->Display( Iter.Value(), false, aViewFrame ); + } + aViewFrame->Repaint(); + } + } +} + +void DependencyTree_ViewModel::onShowOnlySelected() +{ + std::cout<<"\n\n\n\n *****onShowOnlySelected " << std::endl; + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + if ( !app ) return; + + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if ( !aSelMgr ) return; + + SALOME_ListIO aSelList; + aSelMgr->selectedObjects(aSelList); + + SalomeApp_Study* appStudy = dynamic_cast(app->activeStudy()); + GEOM_Displayer* disp = new GEOM_Displayer( appStudy ); + + OCCViewer_ViewManager* anOCCVM = (OCCViewer_ViewManager*) app->getViewManager( OCCViewer_Viewer::Type(), /*create=*/true ); + + if ( SUIT_ViewModel* vmod = anOCCVM->getViewModel() ) { + if ( SALOME_View* aViewFrame = dynamic_cast( vmod ) ) { + disp->EraseAll( true, false, aViewFrame ); + SALOME_ListIteratorOfListIO Iter( aSelList ); + for ( ; Iter.More(); Iter.Next() ) { + disp->Display( Iter.Value(), false, aViewFrame ); + } + aViewFrame->Repaint(); + } + } +} + void DependencyTree_ViewModel::contextMenuPopup( QMenu* theMenu ) { GraphicsView_Viewer::contextMenuPopup( theMenu ); @@ -51,12 +123,15 @@ void DependencyTree_ViewModel::contextMenuPopup( QMenu* theMenu ) { int aNbSelected = aViewPort->nbSelected(); std::cout<<"\n aNbSelected " << aNbSelected << std::endl; + if( aNbSelected > 0 ) { + theMenu->addAction( tr( "MEN_DISPLAY" ), this, SLOT( onShowSelected() ) ); + theMenu->addAction( tr( "MEN_DISPLAY_ONLY" ), this, SLOT( onShowOnlySelected() ) ); + } } } - //SUIT_ViewWindow* DependencyTree_ViewModel::createView( SUIT_Desktop* theDesktop ) //{ // DependencyTree_ViewWindow* aViewFrame; diff --git a/src/DependencyTree/DependencyTree_ViewModel.h b/src/DependencyTree/DependencyTree_ViewModel.h index 3223a00dc..e41fd8156 100644 --- a/src/DependencyTree/DependencyTree_ViewModel.h +++ b/src/DependencyTree/DependencyTree_ViewModel.h @@ -22,6 +22,7 @@ class DependencyTree_ViewModel: public GraphicsView_Viewer { + Q_OBJECT public: @@ -35,5 +36,8 @@ public: // static QString Type() { return "DependencyTree"; } +private slots: + void onShowSelected(); + void onShowOnlySelected(); }; -- 2.39.2