From: ouv Date: Fri, 12 Feb 2010 11:50:56 +0000 (+0000) Subject: Issue 0020629: EDF 1178 GUI : Keyboard free style in the OCC viewer X-Git-Tag: V5_1_4a1~33 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1d954dcdc96d30d30d446395408ac7d22192c2cc;p=modules%2Fgui.git Issue 0020629: EDF 1178 GUI : Keyboard free style in the OCC viewer --- diff --git a/doc/salome/gui/images/image110.png b/doc/salome/gui/images/image110.png new file mode 100755 index 000000000..b0a9c807e Binary files /dev/null and b/doc/salome/gui/images/image110.png differ diff --git a/doc/salome/gui/images/occviewer_toolbar.png b/doc/salome/gui/images/occviewer_toolbar.png index 88941d0e8..3e87ca31b 100644 Binary files a/doc/salome/gui/images/occviewer_toolbar.png and b/doc/salome/gui/images/occviewer_toolbar.png differ diff --git a/doc/salome/gui/input/occ_3d_viewer.doc b/doc/salome/gui/input/occ_3d_viewer.doc index c1cc99aa4..fedf2017a 100644 --- a/doc/salome/gui/input/occ_3d_viewer.doc +++ b/doc/salome/gui/input/occ_3d_viewer.doc @@ -15,6 +15,15 @@ button. or jpeg image format.
+\image html image110.png +\n
Interaction style switch - 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.
+
+ \image html image88.png \n
Show/Hide Trihedron - shows or hides coordinate axes.

diff --git a/doc/salome/gui/input/vtk_3d_viewer.doc b/doc/salome/gui/input/vtk_3d_viewer.doc index fbbd88850..8c4361de8 100644 --- a/doc/salome/gui/input/vtk_3d_viewer.doc +++ b/doc/salome/gui/input/vtk_3d_viewer.doc @@ -15,6 +15,15 @@ button. or jpeg image format.
+\image html image110.png +\n
Interaction style switch - 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.
+
+ \image html image88.png \n
Show/Hide Trihedron - shows or hides coordinate axes.

diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 8257b5f33..02a85782a 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -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 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 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 lst; + viewManagers( OCCViewer_Viewer::Type(), lst ); + QListIterator 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" )) ) { diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index 42ea7105b..706db084f 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -118,6 +118,7 @@ +
diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index 9e9753410..f931e0cdf 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -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 wins = myViewManager->getViews(); + for ( int i = 0; i < (int)wins.count(); i++ ) + { + OCCViewer_ViewWindow* win = ::qobject_cast( wins.at( i ) ); + if ( win ) + win->setInteractionStyle( theStyle ); + } +} /*! Sets selection enabled status diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index 9bf960ef9..40c4e495f 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -33,6 +33,7 @@ #include #include +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; diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 7bef0551e..65f1bc061 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -48,6 +48,7 @@ #include #include #include +#include #include #include @@ -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::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( 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 diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index b9c736756..15fd3b61a 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -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 diff --git a/src/OCCViewer/resources/OCCViewer_images.ts b/src/OCCViewer/resources/OCCViewer_images.ts index 895d4198a..843e89684 100644 --- a/src/OCCViewer/resources/OCCViewer_images.ts +++ b/src/OCCViewer/resources/OCCViewer_images.ts @@ -116,5 +116,9 @@ ICON_OCCVIEWER_AMBIENT occ_view_ambient.png + + ICON_OCCVIEWER_STYLE_SWITCH + occ_view_style_switch.png + diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.ts b/src/OCCViewer/resources/OCCViewer_msg_en.ts index c2fecf77b..6e88f1909 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_en.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_en.ts @@ -236,6 +236,14 @@ MNU_AMBIENT Toogle keep only ambient light + + DSC_STYLE_SWITCH + Interaction style switch + + + MNU_STYLE_SWITCH + Interaction style switch + OCC_IMAGE_FILES Images Files (*.bmp *.png *.jpg *.jpeg) diff --git a/src/OCCViewer/resources/occ_view_style_switch.png b/src/OCCViewer/resources/occ_view_style_switch.png new file mode 100755 index 000000000..b0a9c807e Binary files /dev/null and b/src/OCCViewer/resources/occ_view_style_switch.png differ diff --git a/src/SUIT/SUIT_ViewModel.cxx b/src/SUIT/SUIT_ViewModel.cxx index 406196185..e0bce381c 100755 --- a/src/SUIT/SUIT_ViewModel.cxx +++ b/src/SUIT/SUIT_ViewModel.cxx @@ -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]; } diff --git a/src/SUIT/SUIT_ViewModel.h b/src/SUIT/SUIT_ViewModel.h index dbc23627d..9c19d906f 100755 --- a/src/SUIT/SUIT_ViewModel.h +++ b/src/SUIT/SUIT_ViewModel.h @@ -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 StatesMap; - typedef QMap ButtonsMap; + typedef QMap StatesMap; + typedef QMap ButtonsMap; + + typedef QMap InteractionStyle2StatesMap; + typedef QMap 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 diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index a747d7b2b..ea331dcb4 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -202,7 +202,7 @@ DSC_SVTK_STYLE_SWITCH - Interactiion style switch + Interaction style switch MNU_SVTK_STYLE_SWITCH diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index 38ab2e1a1..75dd79a4a 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -125,6 +125,7 @@ +