From: asl Date: Wed, 1 Nov 2017 09:08:07 +0000 (+0300) Subject: Merge remote-tracking branch 'origin/pre/V8_3_BR' into hydro/imps_2017_salome_83 X-Git-Tag: v2.1~2^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9f57d6054a4065e334d5e0e1b0c887bb754bb5b5;hp=90b877330e64b44ab45e369747efabca003fba0b;p=modules%2Fgui.git Merge remote-tracking branch 'origin/pre/V8_3_BR' into hydro/imps_2017_salome_83 --- diff --git a/src/GraphicsView/GraphicsView_ViewPort.cxx b/src/GraphicsView/GraphicsView_ViewPort.cxx index dac64f7ce..40086a4f8 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.cxx +++ b/src/GraphicsView/GraphicsView_ViewPort.cxx @@ -850,6 +850,11 @@ void GraphicsView_ViewPort::zoom( double theX1, double theY1, double theX2, doub aTransform.scale( aZoom, aZoom ); double aM11 = aTransform.m11(); double aM22 = aTransform.m22(); + + + QGraphicsView::ViewportAnchor old_anchor = transformationAnchor(); + setTransformationAnchor( QGraphicsView::AnchorUnderMouse ); + // increasing of diagonal coefficients (>300) leads to a crash sometimes // at the values of 100 some primitives are drawn incorrectly if( qMax( aM11, aM22 ) < 100 ) @@ -858,6 +863,8 @@ void GraphicsView_ViewPort::zoom( double theX1, double theY1, double theX2, doub myIsTransforming = false; applyTransform(); + + setTransformationAnchor( old_anchor ); } //================================================================ diff --git a/src/GraphicsView/GraphicsView_ViewPort.h b/src/GraphicsView/GraphicsView_ViewPort.h index 4b5acfc2e..303f6f8f4 100644 --- a/src/GraphicsView/GraphicsView_ViewPort.h +++ b/src/GraphicsView/GraphicsView_ViewPort.h @@ -55,7 +55,9 @@ public: DraggingByMiddleButton = 0x0010, ImmediateContextMenu = 0x0020, ImmediateSelection = 0x0040, - Sketching = 0x0080 + Sketching = 0x0080, + + GlobalWheelScaling = 0x0100 }; Q_DECLARE_FLAGS( InteractionFlags, InteractionFlag ) diff --git a/src/GraphicsView/GraphicsView_Viewer.cxx b/src/GraphicsView/GraphicsView_Viewer.cxx index ddb9b18ee..a8e1511b2 100644 --- a/src/GraphicsView/GraphicsView_Viewer.cxx +++ b/src/GraphicsView/GraphicsView_Viewer.cxx @@ -37,6 +37,8 @@ #include #include +#include + // testing ImageViewer /* #include "GraphicsView_PrsImage.h" @@ -521,6 +523,16 @@ void GraphicsView_Viewer::handleWheel( QGraphicsSceneWheelEvent* e ) { if( GraphicsView_ViewPort* aViewPort = getActiveViewPort() ) { + if( aViewPort->hasInteractionFlag( GraphicsView_ViewPort::GlobalWheelScaling ) ) + { + const double d = 1.05; + double q = pow( d, e->delta()/120 ); + QGraphicsView::ViewportAnchor old_anchor = aViewPort->transformationAnchor(); + aViewPort->setTransformationAnchor( QGraphicsView::AnchorUnderMouse ); + aViewPort->scale( q, q ); + aViewPort->setTransformationAnchor( old_anchor ); + } + if( aViewPort->hasInteractionFlag( GraphicsView_ViewPort::WheelScaling ) ) { bool anIsScaleUp = e->delta() > 0; diff --git a/src/OCCViewer/OCCViewer_ViewManager.cxx b/src/OCCViewer/OCCViewer_ViewManager.cxx index c1f2b4d50..4e3b9d6b8 100755 --- a/src/OCCViewer/OCCViewer_ViewManager.cxx +++ b/src/OCCViewer/OCCViewer_ViewManager.cxx @@ -28,7 +28,8 @@ Constructor */ OCCViewer_ViewManager::OCCViewer_ViewManager( SUIT_Study* study, SUIT_Desktop* theDesktop, bool DisplayTrihedron ) -: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron ) ) +: SUIT_ViewManager( study, theDesktop, new OCCViewer_Viewer( DisplayTrihedron ) ), + myIsChainedOperations( false ) { setTitle( tr( "OCC_VIEW_TITLE" ) ); } @@ -50,3 +51,13 @@ void OCCViewer_ViewManager::contextMenuPopup( QMenu* popup ) // if it is necessary invoke method CreatePopup of ViewPort // be sure that existing QPopupMenu menu is used for that. } + +bool OCCViewer_ViewManager::isChainedOperations() const +{ + return myIsChainedOperations; +} + +void OCCViewer_ViewManager::setChainedOperations( bool isChainedOperations ) +{ + myIsChainedOperations = isChainedOperations; +} diff --git a/src/OCCViewer/OCCViewer_ViewManager.h b/src/OCCViewer/OCCViewer_ViewManager.h index c29474ebf..e4ac7c119 100755 --- a/src/OCCViewer/OCCViewer_ViewManager.h +++ b/src/OCCViewer/OCCViewer_ViewManager.h @@ -40,6 +40,12 @@ public: OCCViewer_Viewer* getOCCViewer() { return (OCCViewer_Viewer*) myViewModel; } virtual void contextMenuPopup( QMenu* ); + + bool isChainedOperations() const; + void setChainedOperations( bool ); + +private: + bool myIsChainedOperations; }; #endif diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.cxx b/src/OCCViewer/OCCViewer_ViewPort3d.cxx index e42313e63..2fabb182f 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.cxx +++ b/src/OCCViewer/OCCViewer_ViewPort3d.cxx @@ -628,6 +628,7 @@ void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e ) QApplication::syncX(); #endif QTimer::singleShot( 0, this, SLOT( repaintViewAfterMove() ) ); + emit vpResizeEvent( e ); } /*! diff --git a/src/OCCViewer/OCCViewer_ViewPort3d.h b/src/OCCViewer/OCCViewer_ViewPort3d.h index 994284898..01b0fc17a 100755 --- a/src/OCCViewer/OCCViewer_ViewPort3d.h +++ b/src/OCCViewer/OCCViewer_ViewPort3d.h @@ -102,6 +102,7 @@ signals: void vpChangeBackground( const Qtx::BackgroundData& ); void vpClosed(OCCViewer_ViewPort3d*); void vpMapped(OCCViewer_ViewPort3d*); + void vpResizeEvent( QResizeEvent* ); public slots: virtual bool synchronize( OCCViewer_ViewPort* ); diff --git a/src/OCCViewer/OCCViewer_ViewWindow.cxx b/src/OCCViewer/OCCViewer_ViewWindow.cxx index a4bce4220..cfeb79fb4 100644 --- a/src/OCCViewer/OCCViewer_ViewWindow.cxx +++ b/src/OCCViewer/OCCViewer_ViewWindow.cxx @@ -276,6 +276,7 @@ OCCViewer_ViewWindow::OCCViewer_ViewWindow( SUIT_Desktop* theDesktop, mySelectionEnabled = true; myCursorIsHand = false; + myPanningByBtn = false; clearViewAspects(); } @@ -625,6 +626,12 @@ void OCCViewer_ViewWindow::activateZoom() } +void OCCViewer_ViewWindow::onPanning() +{ + myPanningByBtn = true; + activatePanning(); +} + /*! \brief Start panning operation. @@ -1069,8 +1076,14 @@ void OCCViewer_ViewWindow::vpMouseReleaseEvent(QMouseEvent* theEvent) #if OCC_VERSION_LARGE <= 0x07000000 myViewPort->getView()->ZFitAll(); #endif - resetState(); - break; + { + OCCViewer_ViewManager* aMgr = dynamic_cast( getViewManager() ); + bool isChained = aMgr->isChainedOperations(); + bool isReset = !( myOperation==PANVIEW && myPanningByBtn && isChained ) || theEvent->button() == Qt::RightButton; + if( isReset ) + resetState(); + break; + } case PANGLOBAL: if ( theEvent->button() == Qt::LeftButton ) { @@ -1236,7 +1249,7 @@ void OCCViewer_ViewWindow::createActions() aAction = new QtxAction(tr("MNU_PAN_VIEW"), aResMgr->loadPixmap( "OCCViewer", tr( "ICON_OCCVIEWER_VIEW_PAN" ) ), tr( "MNU_PAN_VIEW" ), 0, this); aAction->setStatusTip(tr("DSC_PAN_VIEW")); - connect(aAction, SIGNAL(triggered()), this, SLOT(activatePanning())); + connect(aAction, SIGNAL(triggered()), this, SLOT(onPanning())); toolMgr()->registerAction( aAction, PanId ); // Global Panning diff --git a/src/OCCViewer/OCCViewer_ViewWindow.h b/src/OCCViewer/OCCViewer_ViewWindow.h index e83fe217e..c68465fa5 100755 --- a/src/OCCViewer/OCCViewer_ViewWindow.h +++ b/src/OCCViewer/OCCViewer_ViewWindow.h @@ -308,6 +308,7 @@ public slots: virtual void onRayTracing(); virtual void onEnvTexture(); virtual void onLightSource(); + virtual void onPanning(); virtual void activateSetRotationGravity(); virtual void activateSetRotationSelected( double theX, double theY, double theZ ); @@ -430,6 +431,7 @@ private: Handle(V3d_Plane) myReserveClipPlane; viewAspectList myViewAspects; + bool myPanningByBtn; }; #ifdef WIN32