]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Implement PAL7620 improvement: provide key-bindings for viewer operations, like zoomi...
authorvsr <vsr@opencascade.com>
Wed, 29 Dec 2004 05:41:54 +0000 (05:41 +0000)
committervsr <vsr@opencascade.com>
Wed, 29 Dec 2004 05:41:54 +0000 (05:41 +0000)
src/SALOMEGUI/PyInterp_base.cxx
src/SALOMEGUI/QAD_Desktop.cxx
src/SALOMEGUI/QAD_Desktop.h
src/SALOMEGUI/QAD_ViewFrame.h

index 08990e6e5559658968c07892cc0ceea050e9097c..ddc56b875e0afd8252fb6723036d42f21d68468e 100644 (file)
@@ -34,7 +34,7 @@ static int MYPYDEBUG = 0;
 #endif
 
 
-static QMutex myMutex(false);
+static QMutex myMutex(true);
 
 
 PyLockWrapper::PyLockWrapper(PyThreadState* theThreadState): 
index 49d457d6367e3f22c7848026e174b71cb4614e6f..1fc2858a117df4e39b979f00c6fbcbf6634f8873 100644 (file)
@@ -77,6 +77,7 @@
 #include "SALOME_Event.hxx"
 
 // QT Includes
+#include <qaccel.h>
 #include <qlabel.h>
 #include <qlayout.h>
 #include <qmessagebox.h>
@@ -119,6 +120,18 @@ extern "C"
 # include <string.h>
 }
 
+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()
 {
 }
-
index 83bc083c972ceb6c8f30bb1c09f3831fae75a4d8..35c71416e8726c46d93ec3ed892c600cc6bb0473 100644 (file)
@@ -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<int, int>                          myAccelMap;
 };
 
 /********************************************************************
index cdc9961aee19d3ac330decc1020d5babb77cc4d2..7ea86fb5fa03f17337564136d8f9782aea7c0ebe 100644 (file)
@@ -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