From: ouv Date: Tue, 12 Oct 2010 14:35:11 +0000 (+0000) Subject: Issue 0020938: EDF 1450 GEOM: center of zoom X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c2c55848da6676b22381c633e51752f0bf8f2f46;p=modules%2Fgui.git Issue 0020938: EDF 1450 GEOM: center of zoom --- diff --git a/doc/salome/gui/images/image157.png b/doc/salome/gui/images/image157.png index dec5836f9..3c4b5040b 100644 Binary files a/doc/salome/gui/images/image157.png and b/doc/salome/gui/images/image157.png differ diff --git a/doc/salome/gui/images/occviewer_toolbar.png b/doc/salome/gui/images/occviewer_toolbar.png index 3e87ca31b..0cc7d3e80 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/images/pref12.png b/doc/salome/gui/images/pref12.png index 5bea82dc1..bfbc61685 100755 Binary files a/doc/salome/gui/images/pref12.png and b/doc/salome/gui/images/pref12.png differ diff --git a/doc/salome/gui/input/occ_3d_viewer.doc b/doc/salome/gui/input/occ_3d_viewer.doc index 5bd68e886..6bc18820e 100644 --- a/doc/salome/gui/input/occ_3d_viewer.doc +++ b/doc/salome/gui/input/occ_3d_viewer.doc @@ -24,6 +24,12 @@ left mouse button, panning - by middle mouse button, zooming - by left and middl mouse buttons pressed simultaneously.
+\image html image111.png +\n
Zooming style switch - allows to switch between standard +(zooming at the center of the view) and advanced (zooming at the current cursor +position) zooming styles.
+
+ \image html image88.png \n
Show/Hide Trihedron - shows or hides coordinate axes.

diff --git a/doc/salome/gui/input/salome_preferences.doc b/doc/salome/gui/input/salome_preferences.doc index 19688a32b..cab6274df 100644 --- a/doc/salome/gui/input/salome_preferences.doc +++ b/doc/salome/gui/input/salome_preferences.doc @@ -97,6 +97,13 @@ operations are assigned to the buttons differently: rotation is made with the left button, translation with the right and zoom with both pressed in the same time. +
  • Zooming mode - this option allows to choose a zooming mode.
  • +
  • [+]/[-] Speed Increment - defines the number of units by which the speed increases or respectively decreases after pressing [+] or [-] keyboard buttons.
  • diff --git a/doc/salome/gui/input/vtk_3d_viewer.doc b/doc/salome/gui/input/vtk_3d_viewer.doc index a33ab8e16..e5b73f294 100644 --- a/doc/salome/gui/input/vtk_3d_viewer.doc +++ b/doc/salome/gui/input/vtk_3d_viewer.doc @@ -24,6 +24,13 @@ left mouse button, panning - by middle mouse button, zooming - by left and middl mouse buttons pressed simultaneously.
    +\image html image111.png +\n
    Zooming style switch - allows to switch between standard +(zooming at the center of the view) and advanced (zooming at the current cursor +position) zooming styles. The second mode is available only for parallel +(non-perspective) view's mode.
    +
    + \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 88c744fc7..f6c5c1752 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1355,6 +1355,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType v = resMgr->integerValue( "OCCViewer", "iso_number_v", v ); vm->setIsos( u, v ); vm->setInteractionStyle( resMgr->integerValue( "OCCViewer", "navigation_mode", vm->interactionStyle() ) ); + vm->setZoomingStyle( resMgr->integerValue( "OCCViewer", "zooming_mode", vm->zoomingStyle() ) ); viewMgr->setViewModel( vm );// custom view model, which extends SALOME_View interface new LightApp_OCCSelector( (OCCViewer_Viewer*)viewMgr->getViewModel(), mySelMgr ); } @@ -1377,6 +1378,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) ); vm->setStaticTrihedronVisible( resMgr->booleanValue( "VTKViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) ); vm->setInteractionStyle( resMgr->integerValue( "VTKViewer", "navigation_mode", vm->interactionStyle() ) ); + vm->setZoomingStyle( resMgr->integerValue( "VTKViewer", "zooming_mode", vm->zoomingStyle() ) ); vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ), resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) ); vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ), @@ -1968,6 +1970,15 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "strings", aStyleModeList, occStyleMode ); pref->setItemProperty( "indexes", aModeIndexesList, occStyleMode ); + int occZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), occGroup, + LightApp_Preferences::Selector, "OCCViewer", "zooming_mode" ); + QStringList aZoomingStyleModeList; + aZoomingStyleModeList.append( tr("PREF_ZOOMING_AT_CENTER") ); + aZoomingStyleModeList.append( tr("PREF_ZOOMING_AT_CURSOR") ); + + pref->setItemProperty( "strings", aZoomingStyleModeList, occZoomingStyleMode ); + pref->setItemProperty( "indexes", aModeIndexesList, occZoomingStyleMode ); + // VTK Viewer int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame ); pref->setItemProperty( "columns", 2, vtkGen ); @@ -1998,7 +2009,11 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "strings", aStyleModeList, vtkStyleMode ); pref->setItemProperty( "indexes", aModeIndexesList, vtkStyleMode ); - pref->addPreference( "", vtkGroup, LightApp_Preferences::Space ); + int vtkZoomingStyleMode = pref->addPreference( tr( "PREF_ZOOMING" ), vtkGen, + LightApp_Preferences::Selector, "VTKViewer", "zooming_mode" ); + + pref->setItemProperty( "strings", aZoomingStyleModeList, vtkZoomingStyleMode ); + pref->setItemProperty( "indexes", aModeIndexesList, vtkZoomingStyleMode ); int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen, LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" ); @@ -2254,6 +2269,25 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } #endif +#ifndef DISABLE_OCCVIEWER + if ( sec == QString( "OCCViewer" ) && param == QString( "zooming_mode" ) ) + { + int mode = resMgr->integerValue( "OCCViewer", "zooming_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->setZoomingStyle( mode ); + } + } +#endif + #ifndef DISABLE_VTKVIEWER if ( sec == QString( "VTKViewer" ) && (param == QString( "trihedron_size" ) || param == QString( "relative_size" )) ) { @@ -2344,6 +2378,27 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } #endif +#ifndef DISABLE_VTKVIEWER + if ( sec == QString( "VTKViewer" ) && param == QString( "zooming_mode" ) ) + { + int mode = resMgr->integerValue( "VTKViewer", "zooming_mode", 0 ); + QList lst; +#ifndef DISABLE_SALOMEOBJECT + viewManagers( SVTK_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "SVTK_Viewer" ) ) + continue; + + SVTK_Viewer* vtkVM = dynamic_cast( vm ); + if( vtkVM ) vtkVM->setZoomingStyle( mode ); + } +#endif + } +#endif + #ifndef DISABLE_VTKVIEWER if ( sec == QString( "VTKViewer" ) && param == QString( "show_static_trihedron" ) ) { diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index ba6c4c54e..a37ebf1b4 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -123,6 +123,7 @@ +
    @@ -132,6 +133,7 @@ + diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index aaa62e008..419eadaad 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -134,6 +134,18 @@ The changes will be applied on the next application session. PREF_KEYFREE_STYLE Keyboard free style + + PREF_ZOOMING + Zooming: + + + PREF_ZOOMING_AT_CENTER + Relative to the view's center + + + PREF_ZOOMING_AT_CURSOR + Relative to the cursor + PREF_INCREMENTAL_SPEED Speed increment: diff --git a/src/OCCViewer/Makefile.am b/src/OCCViewer/Makefile.am index 4d56e731b..887374043 100755 --- a/src/OCCViewer/Makefile.am +++ b/src/OCCViewer/Makefile.am @@ -108,7 +108,9 @@ dist_salomeres_DATA = \ resources/occ_view_top.png \ resources/occ_view_triedre.png \ resources/occ_view_zoom.png \ - resources/occ_view_rotation_point.png + resources/occ_view_rotation_point.png \ + resources/occ_view_style_switch.png \ + resources/occ_view_zooming_style_switch.png nodist_salomeres_DATA = \ OCCViewer_images.qm \ diff --git a/src/OCCViewer/OCCViewer_ViewModel.cxx b/src/OCCViewer/OCCViewer_ViewModel.cxx index caea77326..3e3c962aa 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.cxx +++ b/src/OCCViewer/OCCViewer_ViewModel.cxx @@ -119,6 +119,9 @@ OCCViewer_Viewer::OCCViewer_Viewer( bool DisplayTrihedron, bool DisplayStaticTri // set interaction style to standard myInteractionStyle = 0; + // set zooming style to standard + myZoomingStyle = 0; + // selection mySelectionEnabled = true; myMultiSelectionEnabled = true; @@ -159,6 +162,7 @@ void OCCViewer_Viewer::initView( OCCViewer_ViewWindow* view ) view->initLayout(); view->initSketchers(); view->setInteractionStyle( interactionStyle() ); + view->setZoomingStyle( zoomingStyle() ); OCCViewer_ViewPort3d* vp3d = view->getViewPort(); if ( vp3d ) @@ -328,6 +332,34 @@ void OCCViewer_Viewer::setInteractionStyle( const int theStyle ) } } +/*! + \return zooming style +*/ +int OCCViewer_Viewer::zoomingStyle() const +{ + return myZoomingStyle; +} + +/*! + Sets zooming style: 0 - standard, 1 - advanced (at cursor) + \param theStyle - new zooming style +*/ +void OCCViewer_Viewer::setZoomingStyle( const int theStyle ) +{ + myZoomingStyle = 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->setZoomingStyle( theStyle ); + } +} + /*! Sets selection enabled status \param isEnabled - new status diff --git a/src/OCCViewer/OCCViewer_ViewModel.h b/src/OCCViewer/OCCViewer_ViewModel.h index fc0463e79..8a61c8b46 100755 --- a/src/OCCViewer/OCCViewer_ViewModel.h +++ b/src/OCCViewer/OCCViewer_ViewModel.h @@ -170,6 +170,9 @@ public: int interactionStyle() const; void setInteractionStyle( const int ); + int zoomingStyle() const; + void setZoomingStyle( const int ); + void enableSelection(bool isEnabled); bool isSelectionEnabled() const { return mySelectionEnabled; } @@ -217,6 +220,7 @@ private: viewAspectList myViewAspects; int myInteractionStyle; + int myZoomingStyle; bool mySelectionEnabled; bool myMultiSelectionEnabled; diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index f59075989..e49b93b51 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -59,7 +59,8 @@ OCCViewer_ViewPort3d::OCCViewer_ViewPort3d( QWidget* parent, const Handle( V3d_V myScale( 1.0 ), myDegenerated( true ), myAnimate( false ), - myBusy( true ) + myBusy( true ), + myIsAdvancedZoomingEnabled( false ) { selectVisualId(); @@ -308,6 +309,15 @@ void OCCViewer_ViewPort3d::fitRect( const QRect& rect ) activeView()->WindowFit( rect.left(), rect.top(), rect.right(), rect.bottom() ); } +/*! + Inits 'zoom' transformation. [ protected ] +*/ +void OCCViewer_ViewPort3d::startZoomAtPoint( int x, int y ) +{ + if ( !activeView().IsNull() && isAdvancedZoomingEnabled() ) + activeView()->StartZoomAtPoint( x, y ); +} + /*! Called at 'zoom' transformation. [ virtual protected ] */ @@ -317,7 +327,10 @@ void OCCViewer_ViewPort3d::zoom( int x0, int y0, int x, int y ) // as OCCT respects a sign of only dx, // but we want both signes to be taken into account //activeView()->Zoom( x0, y0, x, y ); - activeView()->Zoom( x0 + y0, 0, x + y, 0 ); + if ( isAdvancedZoomingEnabled() ) + activeView()->ZoomAtPoint( x0, y0, x, y ); + else + activeView()->Zoom( x0 + y0, 0, x + y, 0 ); } } diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.h b/src/OCCViewer/OCCViewer_ViewPort3d.h index 469ce17cb..125fcfa93 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.h +++ b/src/OCCViewer/OCCViewer_ViewPort3d.h @@ -69,6 +69,7 @@ public: virtual void pan( int , int ); virtual void setCenter( int , int ); virtual void fitRect( const QRect& ); + virtual void startZoomAtPoint( int, int ); virtual void zoom( int, int, int, int ); virtual void fitAll( bool keepScale = false, bool withZ = true, bool upd = true ); @@ -77,6 +78,9 @@ public: virtual void endRotation(); bool isBusy() {return myBusy;} // check that View Port is fully initialized + void setAdvancedZoomingEnabled( const bool theState ) { myIsAdvancedZoomingEnabled = theState; } + bool isAdvancedZoomingEnabled() const { return myIsAdvancedZoomingEnabled; } + protected: // EVENTS virtual void paintEvent( QPaintEvent* ); @@ -100,6 +104,7 @@ private: bool myAnimate; bool myBusy; double myScale; + bool myIsAdvancedZoomingEnabled; }; #ifdef WIN32 diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index 3f542c61d..c52efe0ca 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -385,20 +385,26 @@ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent ) break; case ZOOMVIEW: - if ( theEvent->button() == Qt::LeftButton ) + if ( theEvent->button() == Qt::LeftButton ) { + myViewPort->startZoomAtPoint( myStartX, myStartY ); emit vpTransformationStarted ( ZOOMVIEW ); + } break; case PANVIEW: - if ( aSwitchToZoom ) + if ( aSwitchToZoom ) { + myViewPort->startZoomAtPoint( myStartX, myStartY ); activateZoom(); + } else if ( theEvent->button() == Qt::LeftButton ) emit vpTransformationStarted ( PANVIEW ); break; case ROTATE: - if ( aSwitchToZoom ) + if ( aSwitchToZoom ) { + myViewPort->startZoomAtPoint( myStartX, myStartY ); activateZoom(); + } else if ( theEvent->button() == Qt::LeftButton ) { myViewPort->startRotation(myStartX, myStartY, myCurrPointType, mySelectedPoint); emit vpTransformationStarted ( ROTATE ); @@ -409,7 +415,8 @@ void OCCViewer_ViewWindow::vpMousePressEvent( QMouseEvent* theEvent ) /* Try to activate a transformation */ switch ( getButtonState(theEvent, anInteractionStyle) ) { case ZOOMVIEW: - activateZoom(); + myViewPort->startZoomAtPoint( myStartX, myStartY ); + activateZoom(); break; case PANVIEW: activatePanning(); @@ -1160,12 +1167,20 @@ void OCCViewer_ViewWindow::createActions() toolMgr()->registerAction( aAction, AmbientId ); // Switch between interaction styles - aAction = new QtxAction(tr("MNU_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ), + aAction = new QtxAction(tr("MNU_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_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 ); + + // Switch between zooming styles + aAction = new QtxAction(tr("MNU_ZOOMING_STYLE_SWITCH"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_ZOOMING_STYLE_SWITCH" ) ), + tr( "MNU_ZOOMING_STYLE_SWITCH" ), 0, this); + aAction->setStatusTip(tr("DSC_ZOOMING_STYLE_SWITCH")); + aAction->setCheckable(true); + connect(aAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool))); + toolMgr()->registerAction( aAction, SwitchZoomingStyleId ); } /*! @@ -1177,6 +1192,7 @@ void OCCViewer_ViewWindow::createToolBar() toolMgr()->append( DumpId, tid ); toolMgr()->append( SwitchInteractionStyleId, tid ); + toolMgr()->append( SwitchZoomingStyleId, tid ); if( myModel->trihedronActivated() ) toolMgr()->append( TrihedronShowId, tid ); @@ -1566,6 +1582,19 @@ void OCCViewer_ViewWindow::onSwitchInteractionStyle( bool on ) a->setChecked( on ); } +/*! + \brief Toogles advanced zooming style (relatively to the cursor position) on/off +*/ +void OCCViewer_ViewWindow::onSwitchZoomingStyle( bool on ) +{ + myViewPort->setAdvancedZoomingEnabled( on ); + + // update action state if method is called outside + QtxAction* a = dynamic_cast( toolMgr()->action( SwitchZoomingStyleId ) ); + if ( a->isChecked() != on ) + a->setChecked( on ); +} + /*! \brief Get current interaction style \return interaction style @@ -1584,6 +1613,24 @@ void OCCViewer_ViewWindow::setInteractionStyle( const int theStyle ) onSwitchInteractionStyle( theStyle == (int)SUIT_ViewModel::KEY_FREE ); } +/*! + \brief Get current zooming style + \return zooming style +*/ +int OCCViewer_ViewWindow::zoomingStyle() const +{ + return myViewPort->isAdvancedZoomingEnabled() ? 1 : 0; +} + +/*! + \brief Set current zooming style + \param theStyle zooming style +*/ +void OCCViewer_ViewWindow::setZoomingStyle( const int theStyle ) +{ + onSwitchZoomingStyle( theStyle == 1 ); +} + /*! \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 02300ef18..3850bb2a5 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -51,7 +51,7 @@ public: enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId, ChangeRotationPointId, RotationId, FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, CloneId, ClippingId, MemId, RestoreId, - TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId, SwitchInteractionStyleId }; + TrihedronShowId, AxialScaleId, GraduatedAxesId, AmbientId, SwitchInteractionStyleId, SwitchZoomingStyleId }; enum OperationType{ NOTHING, PANVIEW, ZOOMVIEW, ROTATE, PANGLOBAL, WINDOWFIT, FITALLVIEW, RESETVIEW, @@ -90,6 +90,9 @@ public: int interactionStyle() const; void setInteractionStyle( const int ); + int zoomingStyle() const; + void setZoomingStyle( const int ); + void setTransformEnabled( const OperationType, const bool ); bool transformEnabled( const OperationType ) const; @@ -119,6 +122,7 @@ public slots: void onTrihedronShow(); void setRestoreFlag(); void onSwitchInteractionStyle( bool on ); + void onSwitchZoomingStyle( bool on ); void activateSetRotationGravity(); void activateSetRotationSelected( double theX, double theY, double theZ ); diff --git a/src/OCCViewer/resources/OCCViewer_images.ts b/src/OCCViewer/resources/OCCViewer_images.ts index bcc888b20..429a1ad1b 100644 --- a/src/OCCViewer/resources/OCCViewer_images.ts +++ b/src/OCCViewer/resources/OCCViewer_images.ts @@ -124,5 +124,9 @@ ICON_OCCVIEWER_STYLE_SWITCH occ_view_style_switch.png + + ICON_OCCVIEWER_ZOOMING_STYLE_SWITCH + occ_view_zooming_style_switch.png + diff --git a/src/OCCViewer/resources/OCCViewer_msg_en.ts b/src/OCCViewer/resources/OCCViewer_msg_en.ts index aea134ee6..c19bb5d05 100644 --- a/src/OCCViewer/resources/OCCViewer_msg_en.ts +++ b/src/OCCViewer/resources/OCCViewer_msg_en.ts @@ -231,6 +231,14 @@ MNU_STYLE_SWITCH Interaction style switch + + DSC_ZOOMING_STYLE_SWITCH + Zooming style switch + + + MNU_ZOOMING_STYLE_SWITCH + Zooming style switch + OCC_IMAGE_FILES Images Files (*.bmp *.png *.jpg *.jpeg) diff --git a/src/OCCViewer/resources/occ_view_zooming_style_switch.png b/src/OCCViewer/resources/occ_view_zooming_style_switch.png new file mode 100755 index 000000000..8f3a48670 Binary files /dev/null and b/src/OCCViewer/resources/occ_view_zooming_style_switch.png differ diff --git a/src/SVTK/Makefile.am b/src/SVTK/Makefile.am index 3842a639f..232e9ef83 100755 --- a/src/SVTK/Makefile.am +++ b/src/SVTK/Makefile.am @@ -128,6 +128,7 @@ dist_salomeres_DATA=\ resources/vtk_view_perspective.png \ resources/vtk_view_parameters.png \ resources/vtk_view_style_switch.png \ + resources/vtk_view_zooming_style_switch.png \ resources/vtk_view_recording_start.png \ resources/vtk_view_recording_play.png \ resources/vtk_view_recording_pause.png \ diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index b9cd1aec0..ec679bdcb 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -93,7 +93,8 @@ SVTK_InteractorStyle::SVTK_InteractorStyle(): myControllerIncrement(SVTK_ControllerIncrement::New()), myControllerOnKeyDown(SVTK_ControllerOnKeyDown::New()), myHighlightSelectionPointActor(SVTK_Actor::New()), - myRectBand(0) + myRectBand(0), + myIsAdvancedZoomingEnabled(false) { myPointPicker->Delete(); @@ -289,8 +290,22 @@ void SVTK_InteractorStyle::DollyXY(int dx, int dy) double zoomFactor = pow((double)1.1, dxf + dyf); vtkCamera *aCam = GetCurrentRenderer()->GetActiveCamera(); - if (aCam->GetParallelProjection()) + if (aCam->GetParallelProjection()) { + int x0 = 0, y0 = 0, x1 = 0, y1 = 0; + if( IsAdvancedZoomingEnabled() ) { // zoom relatively to the cursor + int* aSize = GetCurrentRenderer()->GetRenderWindow()->GetSize(); + int w = aSize[0]; + int h = aSize[1]; + x0 = w / 2; + y0 = h / 2; + x1 = myOtherPoint.x(); + y1 = h - myOtherPoint.y(); + TranslateView( x0, y0, x1, y1 ); + } aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor); + if( IsAdvancedZoomingEnabled() ) + TranslateView( x1, y1, x0, y0 ); + } else{ aCam->Dolly(zoomFactor); // Move camera in/out along projection direction GetCurrentRenderer()->ResetCameraClippingRange(); diff --git a/src/SVTK/SVTK_InteractorStyle.h b/src/SVTK/SVTK_InteractorStyle.h index 51bb52657..f002752e5 100644 --- a/src/SVTK/SVTK_InteractorStyle.h +++ b/src/SVTK/SVTK_InteractorStyle.h @@ -228,6 +228,9 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle int CurrentState() const { return State; } + void SetAdvancedZoomingEnabled( const bool theState ) { myIsAdvancedZoomingEnabled = theState; } + bool IsAdvancedZoomingEnabled() const { return myIsAdvancedZoomingEnabled; } + protected: SVTK_InteractorStyle(); ~SVTK_InteractorStyle(); @@ -350,6 +353,8 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle bool myBBFirstCheck; QRubberBand* myRectBand; //!< selection rectangle rubber band + + bool myIsAdvancedZoomingEnabled; }; #ifdef WIN32 diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 35c168563..58d4e47d8 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -80,6 +80,7 @@ SVTK_Viewer::SVTK_Viewer() myIncrementMode = 0; myProjMode = 0; myStyle = 0; + myZoomingStyle = 0; mySpaceBtn[0] = 1; mySpaceBtn[1] = 2; mySpaceBtn[2] = 9; @@ -134,6 +135,7 @@ SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop ) aViewWindow->SetStaticTrihedronVisible( isStaticTrihedronVisible() ); aViewWindow->SetProjectionMode( projectionMode() ); aViewWindow->SetInteractionStyle( interactionStyle() ); + aViewWindow->SetZoomingStyle( zoomingStyle() ); aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() ); aViewWindow->SetSpacemouseButtons( spacemouseBtn(1), spacemouseBtn(2), spacemouseBtn(3) ); @@ -262,6 +264,32 @@ void SVTK_Viewer::setInteractionStyle( const int theStyle ) } } +/*! + \return zooming style +*/ +int SVTK_Viewer::zoomingStyle() const +{ + return myZoomingStyle; +} + +/*! + Sets zooming style: 0 - standard, 1 - advanced (at cursor) + \param theStyle - new zooming style +*/ +void SVTK_Viewer::setZoomingStyle( const int theStyle ) +{ + myZoomingStyle = theStyle; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( uint i = 0; i < aViews.count(); i++ ) + { + if ( TViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetZoomingStyle( theStyle ); + } + } +} + /*! \return incremental speed value */ diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index cf4ca31fe..5e038d2c7 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -96,6 +96,12 @@ public: //! Sets interaction style void setInteractionStyle( const int ); + //! Gets zooming style + int zoomingStyle() const; + + //! Sets zooming style + void setZoomingStyle( const int ); + //! Get incremental speed (see #SVTK_InteractorStyle::ControllerIncrement) int incrementalSpeed() const; @@ -175,6 +181,7 @@ private: int myIncrementMode; int myProjMode; int myStyle; + int myZoomingStyle; int mySpaceBtn[3]; }; diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 440bf08ce..a0118be86 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -171,9 +171,9 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) myViewParameterDlg = new SVTK_ViewParameterDlg ( getAction( ViewParametersId ), this, "SVTK_ViewParameterDlg" ); - SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New(); - myInteractor->PushInteractorStyle(aStyle); - aStyle->Delete(); + myDefaultInteractorStyle = SVTK_InteractorStyle::New(); + myInteractor->PushInteractorStyle(myDefaultInteractorStyle); + myDefaultInteractorStyle->Delete(); myRecorder = SVTK_Recorder::New(); @@ -680,6 +680,15 @@ void SVTK_ViewWindow::SetInteractionStyle(const int theStyle) onSwitchInteractionStyle( theStyle==1 ); } +/*! + Sets actual zooming style + \param theStyle - type of zooming style ( 0 - standard, 1 - advanced (at cursor) ) +*/ +void SVTK_ViewWindow::SetZoomingStyle(const int theStyle) +{ + onSwitchZoomingStyle( theStyle==1 ); +} + /*! Switches "keyboard free" interaction style on/off */ @@ -710,6 +719,22 @@ void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn) if ( a->isChecked() != theOn ) a->setChecked( theOn ); } +/*! + Toogles advanced zooming style (relatively to the cursor position) on/off +*/ +void SVTK_ViewWindow::onSwitchZoomingStyle( bool theOn ) +{ + if( myDefaultInteractorStyle.GetPointer() ) + myDefaultInteractorStyle->SetAdvancedZoomingEnabled( theOn ); + if( myKeyFreeInteractorStyle.GetPointer() ) + myKeyFreeInteractorStyle->SetAdvancedZoomingEnabled( theOn ); + + // update action state if method is called outside + QtxAction* a = getAction( SwitchZoomingStyleId ); + if ( a->isChecked() != theOn ) + a->setChecked( theOn ); +} + /*! Sets incremental speed \param theValue - new incremental speed @@ -1549,8 +1574,14 @@ void SVTK_ViewWindow::activateStartPointSelection() */ void SVTK_ViewWindow::onPerspectiveMode() { + bool anIsParallelMode = toolMgr()->action( ParallelModeId )->isChecked(); + + // advanced zooming is not available in perspective mode + if( QtxAction* anAction = getAction( SwitchZoomingStyleId ) ) + anAction->setEnabled( anIsParallelMode ); + vtkCamera* aCamera = getRenderer()->GetActiveCamera(); - aCamera->SetParallelProjection(toolMgr()->action( ParallelModeId )->isChecked()); + aCamera->SetParallelProjection(anIsParallelMode); GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST); } @@ -1764,6 +1795,15 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr) connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool))); mgr->registerAction( anAction, SwitchInteractionStyleId ); + // Switch between zomming styles + anAction = new QtxAction(tr("MNU_SVTK_ZOOMING_STYLE_SWITCH"), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ZOOMING_STYLE_SWITCH" ) ), + tr( "MNU_SVTK_ZOOMING_STYLE_SWITCH" ), 0, this); + anAction->setStatusTip(tr("DSC_SVTK_ZOOMING_STYLE_SWITCH")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool))); + mgr->registerAction( anAction, SwitchZoomingStyleId ); + // Start recording myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"), theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ), @@ -1809,6 +1849,7 @@ void SVTK_ViewWindow::createToolBar() mgr->append( DumpId, myToolBar ); mgr->append( SwitchInteractionStyleId, myToolBar ); + mgr->append( SwitchZoomingStyleId, myToolBar ); mgr->append( ViewTrihedronId, myToolBar ); QtxMultiAction* aScaleAction = new QtxMultiAction( this ); diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 9d6e24707..9c2f82700 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -59,6 +59,7 @@ class SVTK_NonIsometricDlg; class SVTK_UpdateRateDlg; class SVTK_CubeAxesDlg; class SVTK_SetRotationPointDlg; +class SVTK_InteractorStyle; class SVTK_KeyFreeInteractorStyle; class SVTK_ViewParameterDlg; class SVTK_Recorder; @@ -220,6 +221,9 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow //! Redirect the request to #SVTK_MainWindow::SetInteractionStyle virtual void SetInteractionStyle( const int ); + //! Redirect the request to #SVTK_MainWindow::SetZoomingStyle + virtual void SetZoomingStyle( const int ); + //! Redirect the request to #SVTK_MainWindow::SetSpacemouseButtons virtual void SetSpacemouseButtons( const int, const int, const int ); @@ -294,6 +298,7 @@ public slots: void onViewParameters(bool theIsActivate); void onSwitchInteractionStyle(bool theOn); + void onSwitchZoomingStyle(bool theOn); void onStartRecording(); void onPlayRecording(); @@ -373,6 +378,7 @@ protected: FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId, ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate, ParallelModeId, ProjectionModeId, ViewParametersId, SwitchInteractionStyleId, + SwitchZoomingStyleId, StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId }; @@ -381,6 +387,7 @@ protected: SVTK_ViewModelBase* myModel; SVTK_RenderWindowInteractor* myInteractor; + vtkSmartPointer myDefaultInteractorStyle; vtkSmartPointer myKeyFreeInteractorStyle; QString myVisualParams; // used for delayed setting of view parameters diff --git a/src/SVTK/resources/SVTK_images.ts b/src/SVTK/resources/SVTK_images.ts index 2236a59ba..6150f90b3 100644 --- a/src/SVTK/resources/SVTK_images.ts +++ b/src/SVTK/resources/SVTK_images.ts @@ -56,6 +56,10 @@ ICON_SVTK_STYLE_SWITCH vtk_view_style_switch.png + + ICON_SVTK_ZOOMING_STYLE_SWITCH + vtk_view_zooming_style_switch.png + ICON_SVTK_RECORDING_START vtk_view_recording_start.png diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index 8593ed6fa..643a2aa37 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -187,6 +187,14 @@ MNU_SVTK_STYLE_SWITCH Interaction Style Switch + + DSC_SVTK_ZOOMING_STYLE_SWITCH + Zooming style switch + + + MNU_SVTK_ZOOMING_STYLE_SWITCH + Zomming style switch + SVTK_FontWidget diff --git a/src/SVTK/resources/vtk_view_zooming_style_switch.png b/src/SVTK/resources/vtk_view_zooming_style_switch.png new file mode 100755 index 000000000..8f3a48670 Binary files /dev/null and b/src/SVTK/resources/vtk_view_zooming_style_switch.png differ diff --git a/src/SalomeApp/resources/SalomeApp.xml b/src/SalomeApp/resources/SalomeApp.xml index 0a037a064..692930817 100644 --- a/src/SalomeApp/resources/SalomeApp.xml +++ b/src/SalomeApp/resources/SalomeApp.xml @@ -130,6 +130,7 @@ +
    @@ -146,6 +147,7 @@ +