]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Issue 0020629: EDF 1178 GUI : Keyboard free style in the OCC viewer
authorouv <ouv@opencascade.com>
Fri, 12 Feb 2010 11:50:56 +0000 (11:50 +0000)
committerouv <ouv@opencascade.com>
Fri, 12 Feb 2010 11:50:56 +0000 (11:50 +0000)
17 files changed:
doc/salome/gui/images/image110.png [new file with mode: 0755]
doc/salome/gui/images/occviewer_toolbar.png
doc/salome/gui/input/occ_3d_viewer.doc
doc/salome/gui/input/vtk_3d_viewer.doc
src/LightApp/LightApp_Application.cxx
src/LightApp/resources/LightApp.xml
src/OCCViewer/OCCViewer_ViewModel.cxx
src/OCCViewer/OCCViewer_ViewModel.h
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h
src/OCCViewer/resources/OCCViewer_images.ts
src/OCCViewer/resources/OCCViewer_msg_en.ts
src/OCCViewer/resources/occ_view_style_switch.png [new file with mode: 0755]
src/SUIT/SUIT_ViewModel.cxx
src/SUIT/SUIT_ViewModel.h
src/SVTK/resources/SVTK_msg_en.ts
src/SalomeApp/resources/SalomeApp.xml

diff --git a/doc/salome/gui/images/image110.png b/doc/salome/gui/images/image110.png
new file mode 100755 (executable)
index 0000000..b0a9c80
Binary files /dev/null and b/doc/salome/gui/images/image110.png differ
index 88941d0e83b7a7cbbddee8ddbd89273a34393ff8..3e87ca31b20b181e19ee259b842f29a0542527b3 100644 (file)
Binary files a/doc/salome/gui/images/occviewer_toolbar.png and b/doc/salome/gui/images/occviewer_toolbar.png differ
index c1cc99aa46d8af2ce380502e741cb8ae30e05810..fedf2017a9021c6b68cd8e505bc96dcd64bf7128 100644 (file)
@@ -15,6 +15,15 @@ button.
 or jpeg image format.</center>
 <hr>
 
+\image html image110.png
+\n <center><b>Interaction style switch</b> - allows to switch between standard and
+"keyboard free" interaction styles. "Keyboard free" style allow to process all
+view transformations without using keyboard (only by mouse) and perform selection
+in view by pressing "S" key. By default, rotation in this mode is performed by
+left mouse button, panning - by middle mouse button, zooming - by left and middle
+mouse buttons pressed simultaneously.</center>
+<hr>
+
 \image html image88.png
 \n <center><b>Show/Hide Trihedron</b> - shows or hides coordinate axes.</center>
 <hr>
index fbbd888505eff0c63cf9ab08b5fbb24cf1d29e99..8c4361de80f7115e8c38691a7e51223f1b07ab80 100644 (file)
@@ -15,6 +15,15 @@ button.
 or jpeg image format.</center>
 <hr>
 
+\image html image110.png
+\n <center><b>Interaction style switch</b> - allows to switch between standard and
+"keyboard free" interaction styles. "Keyboard free" style allow to process all
+view transformations without using keyboard (only by mouse) and perform selection
+in view by pressing "S" key. By default, rotation in this mode is performed by
+left mouse button, panning - by middle mouse button, zooming - by left and middle
+mouse buttons pressed simultaneously.</center>
+<hr>
+
 \image html image88.png
 \n <center><b>Show/Hide Trihedron</b> - shows or hides coordinate axes.</center>
 <hr>
index 8257b5f335ef1160b2534eb7a82c10d02c94d919..02a85782afdaaf4fd6593f9c29e5fa988dbe5a4a 100644 (file)
@@ -1349,6 +1349,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType
     u = resMgr->integerValue( "OCCViewer", "iso_number_u", u );
     v = resMgr->integerValue( "OCCViewer", "iso_number_v", v );
     vm->setIsos( u, v );
+    vm->setInteractionStyle( resMgr->integerValue( "OCCViewer", "navigation_mode", vm->interactionStyle() ) );
     viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface
     new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr );
   }
@@ -1914,6 +1915,19 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   pref->setItemProperty( "min", 0, isoV );
   pref->setItemProperty( "max", 100000, isoV );
 
+  int occStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), occGroup,
+                                          LightApp_Preferences::Selector, "OCCViewer", "navigation_mode" );
+  QStringList aStyleModeList;
+  aStyleModeList.append( tr("PREF_STANDARD_STYLE") );
+  aStyleModeList.append( tr("PREF_KEYFREE_STYLE") );
+
+  QList<QVariant> aModeIndexesList;
+  aModeIndexesList.append(0);
+  aModeIndexesList.append(1);
+
+  pref->setItemProperty( "strings", aStyleModeList, occStyleMode );
+  pref->setItemProperty( "indexes", aModeIndexesList, occStyleMode );
+
   // VTK Viewer
   int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame );
   pref->setItemProperty( "columns", 2, vtkGen );
@@ -1924,10 +1938,6 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
   aProjModeList.append( tr("PREF_ORTHOGRAPHIC") );
   aProjModeList.append( tr("PREF_PERSPECTIVE") );
 
-  QList<QVariant> aModeIndexesList;
-  aModeIndexesList.append(0);
-  aModeIndexesList.append(1);
-
   pref->setItemProperty( "strings", aProjModeList, vtkProjMode );
   pref->setItemProperty( "indexes", aModeIndexesList, vtkProjMode );
 
@@ -1944,9 +1954,6 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref )
 
   int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), vtkGen,
                                           LightApp_Preferences::Selector, "VTKViewer", "navigation_mode" );
-  QStringList aStyleModeList;
-  aStyleModeList.append( tr("PREF_STANDARD_STYLE") );
-  aStyleModeList.append( tr("PREF_KEYFREE_STYLE") );
 
   pref->setItemProperty( "strings", aStyleModeList, vtkStyleMode );
   pref->setItemProperty( "indexes", aModeIndexesList, vtkStyleMode );
@@ -2180,6 +2187,25 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString
   }
 #endif
 
+#ifndef DISABLE_OCCVIEWER
+  if ( sec == QString( "OCCViewer" ) && param == QString( "navigation_mode" ) )
+  {
+    int mode = resMgr->integerValue( "OCCViewer", "navigation_mode", 0 );
+    QList<SUIT_ViewManager*> lst;
+    viewManagers( OCCViewer_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> it( lst );
+    while ( it.hasNext() )
+    {
+      SUIT_ViewModel* vm = it.next()->getViewModel();
+      if ( !vm || !vm->inherits( "OCCViewer_Viewer" ) )
+        continue;
+
+      OCCViewer_Viewer* occVM = (OCCViewer_Viewer*)vm;
+      occVM->setInteractionStyle( mode );
+    }
+  }
+#endif
+
 #ifndef DISABLE_VTKVIEWER
   if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) )
   {
index 42ea7105b863bb7467ab346b26de3fe5e968d887..706db084fa056bdb696ef86119da5c448e76dd5b 100644 (file)
     <parameter name="iso_number_u"   value="1" />
     <parameter name="iso_number_v"   value="1" />
     <parameter name="trihedron_size" value="100" />
+    <parameter name="navigation_mode" value="0" />
  </section>
  <section name="VTKViewer" >
     <!-- VTK viewer preferences -->
index 9e9753410bb88a12a661038bc3b66548ffb1bbb9..f931e0cdfe2df361c9e7b577b2afbf1e62e89482 100755 (executable)
@@ -35,6 +35,7 @@
 #include <QApplication>
 #include <QColorDialog>
 #include <QPalette>
+#include <QKeyEvent>
 #include <QMenu>
 #include <QMouseEvent>
 #include <QToolBar>
@@ -114,6 +115,9 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron, bool DisplayStaticTri
     myAISContext->Deactivate(myTrihedron);
   }
 
+  // set interaction style to standard
+  myInteractionStyle = 0;
+
   // selection
   mySelectionEnabled = true;
   myMultiSelectionEnabled = true;
@@ -153,6 +157,7 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view )
   if ( view ) {
     view->initLayout();
     view->initSketchers();
+    view->setInteractionStyle( interactionStyle() );
     
     OCCViewer_ViewPort3d* vp3d = view->getViewPort();
     if ( vp3d )
@@ -187,6 +192,9 @@ void OCCViewer_Viewer::setViewManager(SUIT_ViewManager* theViewManager)
 
     connect(theViewManager, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)), 
             this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
+
+    connect(theViewManager, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)), 
+            this, SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*)));
   }
 }
 
@@ -228,9 +236,11 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t
   if (theEvent->button() != Qt::LeftButton) return;
   if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
 
+  OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
+  if (!aView || aView->interactionStyle() != SUIT_ViewModel::STANDARD)
+    return;
 
   myEndPnt.setX(theEvent->x()); myEndPnt.setY(theEvent->y());
-  OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
   bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
   
   if (!aHasShift) emit deselection();
@@ -270,6 +280,52 @@ void OCCViewer_Viewer::onMouseRelease(SUIT_ViewWindow* theWindow, QMouseEvent* t
   emit selectionChanged();
 }
 
+/*!
+  SLOT: called on key press, processes selection in "key free" interaction style
+*/
+void OCCViewer_Viewer::onKeyPress(SUIT_ViewWindow* theWindow, QKeyEvent* theEvent)
+{
+  if (!mySelectionEnabled) return;
+  if (theEvent->key() != Qt::Key_S) return;
+  if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
+
+  OCCViewer_ViewWindow* aView = (OCCViewer_ViewWindow*) theWindow;
+  if (!aView || aView->interactionStyle() != SUIT_ViewModel::KEY_FREE)
+    return;
+
+  emit deselection();
+  myAISContext->Select();
+
+  emit selectionChanged();
+}
+
+/*!
+  \return interaction style
+*/
+int OCCViewer_Viewer::interactionStyle() const
+{
+  return myInteractionStyle;
+}
+
+/*!
+  Sets interaction style: 0 - standard, 1 - keyboard free interaction
+  \param theStyle - new interaction style
+*/
+void OCCViewer_Viewer::setInteractionStyle( const int theStyle )
+{
+  myInteractionStyle = theStyle;
+  //!! To be done for view windows
+  if ( !myViewManager )
+    return;
+
+  QVector<SUIT_ViewWindow*> wins = myViewManager->getViews();
+  for ( int i = 0; i < (int)wins.count(); i++ )
+  {
+    OCCViewer_ViewWindow* win = ::qobject_cast<OCCViewer_ViewWindow*>( wins.at( i ) );
+    if ( win )
+      win->setInteractionStyle( theStyle );
+  }
+}
 
 /*!
   Sets selection enabled status
index 9bf960ef9002fea9010945788b409f49029bfbf8..40c4e495fa16d02b9fe5680fd1a00d776f50dbc8 100755 (executable)
@@ -33,6 +33,7 @@
 #include <AIS_Trihedron.hxx>
 #include <AIS_InteractiveContext.hxx>
 
+class QKeyEvent;
 class QMouseEvent;
 
 class SUIT_ViewWindow;
@@ -124,6 +125,9 @@ public:
   Handle(AIS_InteractiveContext)  getAISContext()  const { return myAISContext; }
   Handle(AIS_Trihedron)           getTrihedron()   const { return myTrihedron; }
 
+  int                             interactionStyle() const;
+  void                            setInteractionStyle( const int );
+
   void                            enableSelection(bool isEnabled);
   bool                            isSelectionEnabled() const { return mySelectionEnabled; }
 
@@ -156,6 +160,7 @@ protected slots:
   void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
   void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
   void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
+  void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
 
   void onDumpView();
   void onChangeBgColor();
@@ -169,6 +174,8 @@ private:
 
   viewAspectList                  myViewAspects;
 
+  int                             myInteractionStyle;
+
   bool                            mySelectionEnabled;
   bool                            myMultiSelectionEnabled;
 
index 7bef0551e3817eab88f896d7e59c17ab5e43c1d3..65f1bc061d77534ac20fdf1eaa9296fe75620a94 100755 (executable)
@@ -48,6 +48,7 @@
 #include <QPainter>
 #include <QTime>
 #include <QImage>
+#include <QKeyEvent>
 #include <QMouseEvent>
 #include <QApplication>
 
@@ -214,6 +215,8 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop*     theDesktop,
 
   mypSketcher = 0;
   myCurSketch = -1;
+
+  myInteractionStyle = SUIT_ViewModel::STANDARD;
 }
 
 /*!
@@ -255,17 +258,18 @@ void OCCViewer_ViewWindow::initLayout()
   \return type of the operation
 */
 OCCViewer_ViewWindow::OperationType
-OCCViewer_ViewWindow::getButtonState( QMouseEvent* theEvent )
+OCCViewer_ViewWindow::getButtonState( QMouseEvent* theEvent, int theInteractionStyle )
 {
   OperationType aOp = NOTHING;
-  if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::ZOOM]) &&
-      (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::ZOOM]) )
+  SUIT_ViewModel::InteractionStyle aStyle = (SUIT_ViewModel::InteractionStyle)theInteractionStyle;
+  if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ZOOM]) &&
+      (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ZOOM]) )
     aOp = ZOOMVIEW;
-  else if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[SUIT_ViewModel::PAN]) &&
-           (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::PAN]) )
+  else if( (theEvent->modifiers() == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::PAN]) &&
+           (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::PAN]) )
     aOp = PANVIEW;
-  else if( (theEvent->modifiers()  == SUIT_ViewModel::myStateMap[SUIT_ViewModel::ROTATE]) &&
-           (theEvent->button() == SUIT_ViewModel::myButtonMap[SUIT_ViewModel::ROTATE]) )
+  else if( (theEvent->modifiers()  == SUIT_ViewModel::myStateMap[aStyle][SUIT_ViewModel::ROTATE]) &&
+           (theEvent->buttons() == SUIT_ViewModel::myButtonMap[aStyle][SUIT_ViewModel::ROTATE]) )
     aOp = ROTATE;
 
   return aOp;
@@ -315,6 +319,10 @@ bool OCCViewer_ViewWindow::eventFilter( QObject* watched, QEvent* e )
       }
       return true;
 
+    case QEvent::KeyPress:
+      emit keyPressed(this, (QKeyEvent*) e);
+      return true;
+
     default:
       break;
     }
@@ -339,6 +347,17 @@ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent )
 {
   myStartX = theEvent->x();
   myStartY = theEvent->y();
+  int anInteractionStyle = interactionStyle();
+
+  // in "key free" interaction style zoom operation is activated by two buttons (simultaneously pressed),
+  // which are assigned for pan and rotate - these operations are activated immediately after pressing 
+  // of the first button, so it is necessary to switch to zoom when the second button is pressed
+  bool aSwitchToZoom = false;
+  if ( anInteractionStyle == SUIT_ViewModel::KEY_FREE && 
+       ( myOperation == PANVIEW || myOperation == ROTATE ) ) {
+    aSwitchToZoom = getButtonState( theEvent, anInteractionStyle ) == ZOOMVIEW;
+  }
+
   switch ( myOperation ) {
   case WINDOWFIT:
     if ( theEvent->button() == Qt::LeftButton )
@@ -356,20 +375,24 @@ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent )
     break;
 
   case PANVIEW:
-    if ( theEvent->button() == Qt::LeftButton )
+    if ( aSwitchToZoom )
+      activateZoom();
+    else if ( theEvent->button() == Qt::LeftButton )
       emit vpTransformationStarted ( PANVIEW );
     break;
 
   case ROTATE:
-    if ( theEvent->button() == Qt::LeftButton ) {
-            myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
-            emit vpTransformationStarted ( ROTATE );
-          }
+    if ( aSwitchToZoom )
+      activateZoom();
+    else if ( theEvent->button() == Qt::LeftButton ) {
+      myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint);
+      emit vpTransformationStarted ( ROTATE );
+    }
     break;
 
   default:
   /*  Try to activate a transformation */
-    switch ( getButtonState(theEvent) ) {
+    switch ( getButtonState(theEvent, anInteractionStyle) ) {
     case ZOOMVIEW:
             activateZoom();
       break;
@@ -743,7 +766,9 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent )
     {
       int aState = theEvent->modifiers();
       int aButton = theEvent->buttons();
-      if ( aButton == Qt::LeftButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) {
+      int anInteractionStyle = interactionStyle();
+      if ( anInteractionStyle == SUIT_ViewModel::STANDARD && 
+           aButton == Qt::LeftButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) {
         myDrawRect = myEnableDrawMode;
         if ( myDrawRect ) {
           drawRect();
@@ -755,7 +780,8 @@ void OCCViewer_ViewWindow::vpMouseMoveEvent( QMouseEvent* theEvent )
           }
         }
       }
-      else if ( aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) {
+      else if ( anInteractionStyle == SUIT_ViewModel::STANDARD && 
+                aButton == Qt::RightButton && ( aState == Qt::NoModifier || Qt::ShiftModifier ) ) {
         OCCViewer_ViewSketcher* sketcher = 0;
         QList<OCCViewer_ViewSketcher*>::Iterator it;
         for ( it = mySketchers.begin(); it != mySketchers.end() && !sketcher; ++it )
@@ -1099,6 +1125,14 @@ void OCCViewer_ViewWindow::createActions()
   aAction->setStatusTip(tr("DSC_AMBIENT"));
   connect(aAction, SIGNAL(triggered()), this, SLOT(onAmbientToogle()));
   toolMgr()->registerAction( aAction, AmbientId );
+
+  // Switch between interaction styles
+  aAction = new QtxAction(tr("MNU_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
+                          tr( "MNU_STYLE_SWITCH" ), 0, this);
+  aAction->setStatusTip(tr("DSC_STYLE_SWITCH"));
+  aAction->setCheckable(true);
+  connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
+  toolMgr()->registerAction( aAction, SwitchInteractionStyleId );
 }
 
 /*!
@@ -1109,6 +1143,7 @@ void OCCViewer_ViewWindow::createToolBar()
   int tid = toolMgr()->createToolBar( tr( "LBL_TOOLBAR_LABEL" ), false );
 
   toolMgr()->append( DumpId, tid );
+  toolMgr()->append( SwitchInteractionStyleId, tid );
   if( myModel->trihedronActivated() ) 
     toolMgr()->append( TrihedronShowId, tid );
 
@@ -1425,6 +1460,37 @@ void OCCViewer_ViewWindow::onTrihedronShow()
   myModel->toggleTrihedron();
 }
 
+/*!
+  \brief Switches "keyboard free" interaction style on/off
+*/
+void OCCViewer_ViewWindow::onSwitchInteractionStyle( bool on )
+{
+  myInteractionStyle = on ? (int)SUIT_ViewModel::KEY_FREE : (int)SUIT_ViewModel::STANDARD;
+
+  // update action state if method is called outside
+  QtxAction* a = dynamic_cast<QtxAction*>( toolMgr()->action( SwitchInteractionStyleId ) );
+  if ( a->isChecked() != on )
+    a->setChecked( on );
+}
+
+/*!
+  \brief Get current interaction style
+  \return interaction style
+*/
+int OCCViewer_ViewWindow::interactionStyle() const
+{
+  return myInteractionStyle;
+}
+
+/*!
+  \brief Set current interaction style
+  \param theStyle interaction style
+*/
+void OCCViewer_ViewWindow::setInteractionStyle( const int theStyle )
+{
+  onSwitchInteractionStyle( theStyle == (int)SUIT_ViewModel::KEY_FREE );
+}
+
 /*!
   \brief Dump view window contents to the pixmap.
   \return pixmap containing all scene rendered in the window
index b9c736756fb9a8cf6c68e026c39ec21984237b5e..15fd3b61a8d6528f11f64289b3584f3b6f16969f 100755 (executable)
@@ -49,7 +49,7 @@ public:
   enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
          ChangeRotationPointId, RotationId,
          FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId,
-         TrihedronShowId, AxialScaleId, AmbientId };
+         TrihedronShowId, AxialScaleId, AmbientId, SwitchInteractionStyleId };
 
   enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, 
                       PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW,
@@ -84,6 +84,9 @@ public:
   OCCViewer_ViewSketcher* getSketcher( const int );
 
   void                    activateSketching( int );
+
+  int                     interactionStyle() const;
+  void                    setInteractionStyle( const int );
  
 public slots:
   void onFrontView();
@@ -109,6 +112,7 @@ public slots:
   void onRestoreView();
   void onTrihedronShow();
   void setRestoreFlag();
+  void onSwitchInteractionStyle( bool on );
 
   void activateSetRotationGravity();
   void activateSetRotationSelected( double theX, double theY, double theZ );
@@ -151,7 +155,7 @@ protected:
   void createActions();
   void createToolBar();
  
-  virtual OperationType getButtonState(QMouseEvent* theEvent);
+  virtual OperationType getButtonState(QMouseEvent* theEvent, int theInteractionStyle);
 
   viewAspect getViewParams() const;
 
@@ -203,6 +207,8 @@ private:
   QtxAction* mySetRotationPointAction;
 
   QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band
+
+  int myInteractionStyle;
 };
 
 #ifdef WIN32
index 895d4198afc1197d2d6ecee254422956d55ffca3..843e896848c7526ea8a48fe5fdc0afad57b75aa2 100644 (file)
         <source>ICON_OCCVIEWER_AMBIENT</source>
         <translation>occ_view_ambient.png</translation>
     </message>
+    <message>
+        <source>ICON_OCCVIEWER_STYLE_SWITCH</source>
+        <translation>occ_view_style_switch.png</translation>
+    </message>
 </context>
 </TS>
index c2fecf77b6b9e7326c8e36264584f10a7da68a0a..6e88f1909ac98654ed986c57b9a0754c3d156613 100644 (file)
         <source>MNU_AMBIENT</source>
         <translation>Toogle keep only ambient light</translation>
     </message>
+    <message>
+        <source>DSC_STYLE_SWITCH</source>
+        <translation>Interaction style switch</translation>
+    </message>
+    <message>
+        <source>MNU_STYLE_SWITCH</source>
+        <translation>Interaction style switch</translation>
+    </message>
     <message>
         <source>OCC_IMAGE_FILES</source>
         <translation>Images Files (*.bmp *.png *.jpg *.jpeg)</translation>
diff --git a/src/OCCViewer/resources/occ_view_style_switch.png b/src/OCCViewer/resources/occ_view_style_switch.png
new file mode 100755 (executable)
index 0000000..b0a9c80
Binary files /dev/null and b/src/OCCViewer/resources/occ_view_style_switch.png differ
index 4061961857d147fc5efe7d862f7c73f01d7a8e96..e0bce381cd17e08c79cfd66b20f598979def806a 100755 (executable)
@@ -24,8 +24,8 @@
 #include "SUIT_ViewModel.h"
 #include "SUIT_ViewWindow.h"
 
-SUIT_ViewModel::StatesMap SUIT_ViewModel::myStateMap;
-SUIT_ViewModel::ButtonsMap SUIT_ViewModel::myButtonMap;
+SUIT_ViewModel::InteractionStyle2StatesMap SUIT_ViewModel::myStateMap;
+SUIT_ViewModel::InteractionStyle2ButtonsMap SUIT_ViewModel::myButtonMap;
 
 static bool isInitialized = false;
 
@@ -36,17 +36,31 @@ SUIT_ViewModel::SUIT_ViewModel()
   {
     isInitialized = true;
 
-    SUIT_ViewModel::myStateMap[ZOOM]  = Qt::ControlModifier;
-    SUIT_ViewModel::myButtonMap[ZOOM] = Qt::LeftButton;
+    // standard interaction style
+    SUIT_ViewModel::myStateMap[STANDARD][ZOOM]  = Qt::ControlModifier;
+    SUIT_ViewModel::myButtonMap[STANDARD][ZOOM] = Qt::LeftButton;
 
-    SUIT_ViewModel::myStateMap[PAN]   = Qt::ControlModifier;
-    SUIT_ViewModel::myButtonMap[PAN]  = Qt::MidButton;
+    SUIT_ViewModel::myStateMap[STANDARD][PAN]   = Qt::ControlModifier;
+    SUIT_ViewModel::myButtonMap[STANDARD][PAN]  = Qt::MidButton;
 
-    SUIT_ViewModel::myStateMap[ROTATE]  = Qt::ControlModifier;
-    SUIT_ViewModel::myButtonMap[ROTATE] = Qt::RightButton;
+    SUIT_ViewModel::myStateMap[STANDARD][ROTATE]  = Qt::ControlModifier;
+    SUIT_ViewModel::myButtonMap[STANDARD][ROTATE] = Qt::RightButton;
 
-    SUIT_ViewModel::myStateMap[FIT_AREA]  = Qt::ControlModifier;
-    SUIT_ViewModel::myButtonMap[FIT_AREA] = Qt::RightButton;
+    SUIT_ViewModel::myStateMap[STANDARD][FIT_AREA]  = Qt::ControlModifier;
+    SUIT_ViewModel::myButtonMap[STANDARD][FIT_AREA] = Qt::RightButton;
+
+    // "key free" interaction style
+    SUIT_ViewModel::myStateMap[KEY_FREE][ZOOM]  = Qt::NoModifier;
+    SUIT_ViewModel::myButtonMap[KEY_FREE][ZOOM] = Qt::LeftButton | Qt::MidButton;
+
+    SUIT_ViewModel::myStateMap[KEY_FREE][PAN]   = Qt::NoModifier;
+    SUIT_ViewModel::myButtonMap[KEY_FREE][PAN]  = Qt::MidButton;
+
+    SUIT_ViewModel::myStateMap[KEY_FREE][ROTATE]  = Qt::NoModifier;
+    SUIT_ViewModel::myButtonMap[KEY_FREE][ROTATE] = Qt::LeftButton;
+
+    SUIT_ViewModel::myStateMap[KEY_FREE][FIT_AREA]  = Qt::NoModifier; // unused
+    SUIT_ViewModel::myButtonMap[KEY_FREE][FIT_AREA] = Qt::NoButton;   // unused
   }
   myViewManager = 0;
 }
@@ -85,10 +99,11 @@ SUIT_ViewManager* SUIT_ViewModel::getViewManager() const
  *\param theState - adding state to state map operations.
  *\param theButton - adding state to button map operations.
  */
-void SUIT_ViewModel::setHotButton( HotOperation theOper, Qt::KeyboardModifier theState, Qt::MouseButton theButton )
+void SUIT_ViewModel::setHotButton( InteractionStyle theInteractionStyle, HotOperation theOper,
+                                   Qt::KeyboardModifiers theState, Qt::MouseButtons theButton )
 {
-  myStateMap[theOper]  = theState;
-  myButtonMap[theOper] = theButton;
+  myStateMap[theInteractionStyle][theOper]  = theState;
+  myButtonMap[theInteractionStyle][theOper] = theButton;
 }
 
 /*! Gets hot button for operation \a theOper.
@@ -96,8 +111,9 @@ void SUIT_ViewModel::setHotButton( HotOperation theOper, Qt::KeyboardModifier th
  *\param theState - output state from state map operations.
  *\param theButton - output state from button map operations.
 */
-void SUIT_ViewModel::getHotButton( HotOperation theOper, Qt::KeyboardModifier& theState, Qt::MouseButton& theButton )
+void SUIT_ViewModel::getHotButton( InteractionStyle theInteractionStyle, HotOperation theOper,
+                                   Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton )
 {
-  theState  = myStateMap[theOper];
-  theButton = myButtonMap[theOper];
+  theState  = myStateMap[theInteractionStyle][theOper];
+  theButton = myButtonMap[theInteractionStyle][theOper];
 }
index dbc23627d3f30fda49f6552ce07c11d030b13b1c..9c19d906f0afb7491276b594b4b41893b59a891d 100755 (executable)
@@ -47,9 +47,13 @@ class SUIT_EXPORT SUIT_ViewModel : public QObject
         Q_OBJECT
 public:
   enum HotOperation { PAN, ZOOM, ROTATE, FIT_AREA };
+  enum InteractionStyle { STANDARD, KEY_FREE };
 
-  typedef QMap<HotOperation, Qt::KeyboardModifier> StatesMap;
-  typedef QMap<HotOperation, Qt::MouseButton>      ButtonsMap;
+  typedef QMap<HotOperation, Qt::KeyboardModifiers> StatesMap;
+  typedef QMap<HotOperation, Qt::MouseButtons>      ButtonsMap;
+
+  typedef QMap<InteractionStyle, StatesMap>         InteractionStyle2StatesMap;
+  typedef QMap<InteractionStyle, ButtonsMap>        InteractionStyle2ButtonsMap;
   
   SUIT_ViewModel();
   virtual ~SUIT_ViewModel();
@@ -63,17 +67,17 @@ public:
 
   virtual void      contextMenuPopup( QMenu* ) {}
 
-  static void       setHotButton( HotOperation theOper, Qt::KeyboardModifier theState,
-                                  Qt::MouseButton theButton );
-  static void       getHotButton( HotOperation theOper, Qt::KeyboardModifier& theState,
-                                  Qt::MouseButton& theButton );
+  static void       setHotButton( InteractionStyle theInteractionStyle, HotOperation theOper,
+                                  Qt::KeyboardModifiers theState, Qt::MouseButtons theButton );
+  static void       getHotButton( InteractionStyle theInteractionStyle, HotOperation theOper,
+                                  Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton );
 
 protected:
   SUIT_ViewManager* myViewManager;
 
 public:
-  static StatesMap  myStateMap;
-  static ButtonsMap myButtonMap;
+  static InteractionStyle2StatesMap  myStateMap;
+  static InteractionStyle2ButtonsMap myButtonMap;
 };
 
 #ifdef WIN32
index a747d7b2bac011bd75db250d809e547495ff807d..ea331dcb4746113604164f8f16be2532eef2b4d9 100644 (file)
     </message>
     <message>
         <source>DSC_SVTK_STYLE_SWITCH</source>
-        <translation>Interactiion style switch</translation>
+        <translation>Interaction style switch</translation>
     </message>
     <message>
         <source>MNU_SVTK_STYLE_SWITCH</source>
index 38ab2e1a16f47d75c7988255a63989b756242a01..75dd79a4af7d10120f18c8b4e302eb7307980e07 100644 (file)
     <parameter name="iso_number_u"   value="1" />
     <parameter name="iso_number_v"   value="1" />
     <parameter name="trihedron_size" value="100" />
+    <parameter name="navigation_mode" value="0"/>
  </section>
  <section name="VTKViewer" >
     <!-- VTK viewer preferences -->