From 748c3d93f4d1a2b2ff8fae96ae8aa2faab27ea0b Mon Sep 17 00:00:00 2001 From: asv Date: Thu, 25 Aug 2005 13:21:00 +0000 Subject: [PATCH] Implementation of key accelerator events sent to viewers. --- src/VISUGUI/VisuGUI_Module.cxx | 116 ++++++++++++++++++++++++++++++++- src/VISUGUI/VisuGUI_Module.h | 14 ++++ 2 files changed, 129 insertions(+), 1 deletion(-) diff --git a/src/VISUGUI/VisuGUI_Module.cxx b/src/VISUGUI/VisuGUI_Module.cxx index b26c2686..de35766a 100644 --- a/src/VISUGUI/VisuGUI_Module.cxx +++ b/src/VISUGUI/VisuGUI_Module.cxx @@ -31,6 +31,8 @@ #include "SUIT_Study.h" #include "SUIT_Desktop.h" #include "SUIT_ResourceMgr.h" +#include "SUIT_Accel.h" +#include "SUIT_Session.h" #include "CAM_Module.h" @@ -43,6 +45,10 @@ #include "VVTK_ViewWindow.h" #include "VVTK_ViewModel.h" +#include "SVTK_ViewModel.h" +#include "SVTK_ViewManager.h" +#include "SVTK_Event.h" + #include "VisuGUI_Prs3dTools.h" #include "VISU_GaussPoints_i.hh" @@ -102,6 +108,11 @@ namespace VISU myViewManager->createViewWindow(); } + VVTK_ViewManager* getViewManager() + { + return myViewManager; + } + virtual ~Viewer() { @@ -165,6 +176,22 @@ VisuGUI_Module int aMenuId = createMenu( tr( "MEN_GAUSS" ), -1, -1, 30 ); //createMenu( GAUSS_CREATE_PRS, aMenuId, 10 ); + SUIT_Accel* accel = getApp()->accel(); + accel->setActionKey( SUIT_Accel::PanLeft, Key_Left, VVTK_Viewer::Type() ); + accel->setActionKey( SUIT_Accel::PanRight, Key_Right, VVTK_Viewer::Type() ); + accel->setActionKey( SUIT_Accel::PanUp, Key_Up, VVTK_Viewer::Type() ); + accel->setActionKey( SUIT_Accel::PanDown, Key_Down, VVTK_Viewer::Type() ); + accel->setActionKey( SUIT_Accel::ZoomIn, Key_PageUp, VVTK_Viewer::Type() ); + accel->setActionKey( SUIT_Accel::ZoomOut, Key_PageDown, VVTK_Viewer::Type() ); + accel->setActionKey( SUIT_Accel::RotateLeft, CTRL+Key_Left, VVTK_Viewer::Type() ); + accel->setActionKey( SUIT_Accel::RotateRight, CTRL+Key_Right, VVTK_Viewer::Type() ); + accel->setActionKey( SUIT_Accel::RotateUp, CTRL+Key_Up, VVTK_Viewer::Type() ); + accel->setActionKey( SUIT_Accel::RotateDown, CTRL+Key_Down, VVTK_Viewer::Type() ); + accel->setActionKey( PlusSpeedIncrementEvent, Key_Plus, VVTK_Viewer::Type() ); + accel->setActionKey( MinusSpeedIncrementEvent,Key_Minus, VVTK_Viewer::Type() ); + + connect( getApp(), SIGNAL( viewManagerAdded( SUIT_ViewManager* ) ), this, SLOT( OnViewManagerAdded (SUIT_ViewManager*) ) ); + // Prepare popup menus QString aSel_One_ObjBr("client='ObjectBrowser' and selcount=1"); QString aPrsAll ("'VISU::TSCALARMAP' 'VISU::TISOSURFACE' 'VISU::TDEFORMEDSHAPE' 'VISU::TCUTPLANES' " @@ -241,7 +268,7 @@ void VisuGUI_Module ::onCreateViewManager() { - new Viewer(this,myViewerMap); + new Viewer( this, myViewerMap ); } @@ -330,6 +357,93 @@ VisuGUI_Module CreatePrs3d(this); } +void +VisuGUI_Module +::OnViewManagerAdded(SUIT_ViewManager* viewMgr) +{ + QString type = viewMgr->getViewModel()->getType(); + if ( type == VVTK_Viewer::Type() ) + connect( viewMgr, SIGNAL( viewCreated( SUIT_ViewWindow* ) ), this, SLOT( OnViewCreated( SUIT_ViewWindow* ) ) ); +} + +void +VisuGUI_Module +::OnViewCreated(SUIT_ViewWindow* view) +{ + SVTK_ViewWindow* viewWindow = dynamic_cast( view ); + if ( viewWindow ) { + setProperty( viewWindow, "speed_increment" ); + setProperty( viewWindow, "spacemouse_func1_btn" ); + setProperty( viewWindow, "spacemouse_func2_btn" ); + setProperty( viewWindow, "spacemouse_func3_btn" ); + setProperty( viewWindow, "spacemouse_func4_btn" ); + setProperty( viewWindow, "spacemouse_func5_btn" ); + } +} + +void +VisuGUI_Module +::setProperty( SVTK_ViewWindow* viewWindow, const QString& pref ) +{ + if ( !viewWindow ) + return; + + SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); + SVTK_View* view = viewWindow->getView(); + int val; + if ( pref == "speed_increment" ) { + val = resMgr->integerValue( "VISU", pref, 10 ); + view->FireEvent( SetSpeedIncrementEvent, &val ); + } + else if ( pref == "spacemouse_func1_btn" ) { + val = resMgr->integerValue( "VISU", pref, 1 ); + view->FireEvent( SetSpaceMouseF1Event, &val ); + } + else if ( pref == "spacemouse_func2_btn" ) { + val = resMgr->integerValue( "VISU", pref, 2 ); + view->FireEvent( SetSpaceMouseF2Event, &val ); + } + else if ( pref == "spacemouse_func3_btn" ) { + val = resMgr->integerValue( "VISU", pref, 10 ); + view->FireEvent( SetSpaceMouseF3Event, &val ); + } + else if ( pref == "spacemouse_func4_btn" ) { + val = resMgr->integerValue( "VISU", pref, 11 ); + view->FireEvent( SetSpaceMouseF4Event, &val ); + } + else if ( pref == "spacemouse_func5_btn" ) { + val = resMgr->integerValue( "VISU", pref, 9 ); + view->FireEvent( SetSpaceMouseF5Event, &val ); + } +} + +void +VisuGUI_Module +::setProperty( SVTK_ViewManager* vm, const QString& prop ) +{ + if ( !vm ) + return; + + QPtrVector windows = vm->getViews(); + for ( int n = windows.count(), i = 0; i < n; i++ ) + setProperty( dynamic_cast( windows[i] ), prop ); +} + +void +VisuGUI_Module +::preferencesChanged( const QString& group, const QString& pref ) +{ + if ( group == "VISU" && ( pref == "speed_increment" || pref == "spacemouse_func1_btn" || + pref == "spacemouse_func2_btn" || pref == "spacemouse_func3_btn" || + pref == "spacemouse_func4_btn" || pref == "spacemouse_func5_btn" ) ) { + + // update properties of VVTK view windows + SUIT_ViewManager* vm = getApp()->getViewManager( VVTK_Viewer::Type(), false ); + if ( vm ) + setProperty( dynamic_cast( vm ), pref ); + } +} + void VisuGUI_Module:: OnEditGaussPoints() diff --git a/src/VISUGUI/VisuGUI_Module.h b/src/VISUGUI/VisuGUI_Module.h index 25c66540..ecc6c4cf 100644 --- a/src/VISUGUI/VisuGUI_Module.h +++ b/src/VISUGUI/VisuGUI_Module.h @@ -34,6 +34,7 @@ class SUIT_ViewManager; class SVTK_ViewManager; +class SVTK_ViewWindow; #include "MED_SharedPtr.hxx" @@ -66,6 +67,10 @@ public: void createPreferences(); + virtual + void + preferencesChanged( const QString&, const QString& ); + public slots: virtual @@ -86,12 +91,21 @@ protected slots: void OnCreateGaussPoints(); + void + OnViewCreated(SUIT_ViewWindow*); + + void + OnViewManagerAdded(SUIT_ViewManager*); + virtual void OnEditGaussPoints(); protected: VISU::TViewerMap myViewerMap; + + void setProperty( SVTK_ViewWindow*, const QString& ); // set a property (speed_increment, etc ) for SVTK ViewWindow + void setProperty( SVTK_ViewManager*, const QString& ); // set a property for SVTK ViewWindow // set only 1 property for all ViewWindows of given view manager }; #endif -- 2.39.2