From: vsr Date: Wed, 29 Dec 2004 05:41:54 +0000 (+0000) Subject: Implement PAL7620 improvement: provide key-bindings for viewer operations, like zoomi... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=00f5899e4055b31a5e763b71a1b1b1220fc14512;p=modules%2Fkernel.git Implement PAL7620 improvement: provide key-bindings for viewer operations, like zooming, panning, rotating. --- diff --git a/src/SALOMEGUI/PyInterp_base.cxx b/src/SALOMEGUI/PyInterp_base.cxx index 08990e6e5..ddc56b875 100644 --- a/src/SALOMEGUI/PyInterp_base.cxx +++ b/src/SALOMEGUI/PyInterp_base.cxx @@ -34,7 +34,7 @@ static int MYPYDEBUG = 0; #endif -static QMutex myMutex(false); +static QMutex myMutex(true); PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState): diff --git a/src/SALOMEGUI/QAD_Desktop.cxx b/src/SALOMEGUI/QAD_Desktop.cxx index 49d457d63..1fc2858a1 100644 --- a/src/SALOMEGUI/QAD_Desktop.cxx +++ b/src/SALOMEGUI/QAD_Desktop.cxx @@ -77,6 +77,7 @@ #include "SALOME_Event.hxx" // QT Includes +#include #include #include #include @@ -119,6 +120,18 @@ extern "C" # include } +enum { voPanLeft, + voPanRight, + voPanUp, + voPanDown, + voZoomIn, + voZoomOut, + voZoomFit, + voRotateLeft, + voRotateRight, + voRotateUp, + voRotateDown }; + QAD_ResourceMgr* QAD_Desktop::resourceMgr = 0; QPalette* QAD_Desktop::palette = 0; @@ -1066,6 +1079,35 @@ void QAD_Desktop::createActions() QAD_ASSERT( connect( helpAboutAction, SIGNAL(activated()), this, SLOT( onHelpAbout() ))); helpAboutAction->addTo( &myHelpPopup ); myStdActions.insert(HelpAboutId, helpAboutAction ); + + /* additional key accelerators */ + QAccel* accel = new QAccel( this ); + // pan left + myAccelMap[ accel->insertItem( CTRL+Key_Left ) ] = voPanLeft; + // pan right + myAccelMap[ accel->insertItem( CTRL+Key_Right ) ] = voPanRight; + // pan up + myAccelMap[ accel->insertItem( CTRL+Key_Up ) ] = voPanUp; + // pan down + myAccelMap[ accel->insertItem( CTRL+Key_Down ) ] = voPanDown; + // zoom in + myAccelMap[ accel->insertItem( CTRL+Key_Plus ) ] = voZoomIn; + // zoom out + myAccelMap[ accel->insertItem( CTRL+Key_Minus ) ] = voZoomOut; + // zoom in + myAccelMap[ accel->insertItem( CTRL+Key_Equal ) ] = voZoomIn; + // fit all + myAccelMap[ accel->insertItem( CTRL+Key_Asterisk ) ] = voZoomFit; + // rotate left + myAccelMap[ accel->insertItem( ALT+Key_Left ) ] = voRotateLeft; + // rotate right + myAccelMap[ accel->insertItem( ALT+Key_Right ) ] = voRotateRight; + // rotate up + myAccelMap[ accel->insertItem( ALT+Key_Up ) ] = voRotateUp; + // rotate down + myAccelMap[ accel->insertItem( ALT+Key_Down ) ] = voRotateDown; + // connect signal to slot + connect( accel, SIGNAL( activated(int) ), this, SLOT( onKeyAccel(int) ) ); } updateActions(); } @@ -4062,6 +4104,52 @@ void QAD_Desktop::onViewPopupStatusText( int id ) } } +/* Processes additinal key accelerators, e.g. viewer incremental transfomrations */ +void QAD_Desktop::onKeyAccel( int id ) +{ + if ( myAccelMap.find( id ) != myAccelMap.end() ) { + int cmd = myAccelMap[ id ]; + if ( myActiveApp != 0 && myActiveApp->getActiveStudy() != 0 && myActiveApp->getActiveStudy()->getActiveStudyFrame() != 0 ) { + QAD_ViewFrame* vf = myActiveApp->getActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + switch ( cmd ) { + case voPanLeft: + vf->onPanLeft(); + break; + case voPanRight: + vf->onPanRight(); + break; + case voPanUp: + vf->onPanUp(); + break; + case voPanDown: + vf->onPanDown(); + break; + case voZoomIn: + vf->onZoomIn(); + break; + case voZoomOut: + vf->onZoomOut(); + break; + case voZoomFit: + vf->onViewFitAll(); + break; + case voRotateLeft: + vf->onRotateLeft(); + break; + case voRotateRight: + vf->onRotateRight(); + break; + case voRotateUp: + vf->onRotateUp(); + break; + case voRotateDown: + vf->onRotateDown(); + break; + } + } + } +} + /********************************************************************* ** Class: AppSelectionDlg ** Descr: Dialog for the selection of the application when several @@ -4160,4 +4248,3 @@ void Desktop_AppSelectionDlg::onAppSelected( int id ) void Desktop_AppSelectionDlg::onHelp() { } - diff --git a/src/SALOMEGUI/QAD_Desktop.h b/src/SALOMEGUI/QAD_Desktop.h index 83bc083c9..35c71416e 100644 --- a/src/SALOMEGUI/QAD_Desktop.h +++ b/src/SALOMEGUI/QAD_Desktop.h @@ -268,6 +268,7 @@ protected slots: void onComboActiveComponent( const QString & , bool isLoadData); void onCascade(); + void onKeyAccel( int id ); /* NRI void onHelpWindowClosed(); */ protected: @@ -346,6 +347,7 @@ private: bool _islibso; ComponentMap myComponents; + QMap myAccelMap; }; /******************************************************************** diff --git a/src/SALOMEGUI/QAD_ViewFrame.h b/src/SALOMEGUI/QAD_ViewFrame.h index cdc9961ae..7ea86fb5f 100644 --- a/src/SALOMEGUI/QAD_ViewFrame.h +++ b/src/SALOMEGUI/QAD_ViewFrame.h @@ -94,7 +94,11 @@ public: virtual void Activate( QAD_Study* ) {} // this method is called when parent window of view frame is activated -protected slots: +public slots: + /* basic view operations, + most of them are pure virtual + and should be redefined in derived classes + */ virtual void onViewPan() = 0; virtual void onViewZoom() = 0; virtual void onViewFitAll() = 0; @@ -111,6 +115,19 @@ protected slots: virtual void onViewTrihedron() = 0; virtual void onViewDump(); + /* view incremental transformation operations. + virtual, can be redefined in derived classes + */ + virtual void onPanLeft() {} + virtual void onPanRight() {} + virtual void onPanUp() {} + virtual void onPanDown() {} + virtual void onZoomIn() {} + virtual void onZoomOut() {} + virtual void onRotateLeft() {} + virtual void onRotateRight() {} + virtual void onRotateUp() {} + virtual void onRotateDown() {} }; #endif