Salome HOME
Merge remote-tracking branch 'origin/pre/V8_3_BR' into hydro/imps_2017_salome_83
authorasl <asl@opencascade.com>
Wed, 1 Nov 2017 09:08:07 +0000 (12:08 +0300)
committerasl <asl@opencascade.com>
Wed, 1 Nov 2017 09:08:07 +0000 (12:08 +0300)
src/GraphicsView/GraphicsView_ViewPort.cxx
src/GraphicsView/GraphicsView_ViewPort.h
src/GraphicsView/GraphicsView_Viewer.cxx
src/OCCViewer/OCCViewer_ViewManager.cxx
src/OCCViewer/OCCViewer_ViewManager.h
src/OCCViewer/OCCViewer_ViewPort3d.cxx
src/OCCViewer/OCCViewer_ViewPort3d.h
src/OCCViewer/OCCViewer_ViewWindow.cxx
src/OCCViewer/OCCViewer_ViewWindow.h

index dac64f7ceedc12f3b3b784277a701824bb833471..40086a4f8c9754e8b4a0bed8a673c5db99d75643 100644 (file)
@@ -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 );
 }
 
 //================================================================
index 4b5acfc2eaf637505d4c54aefd2b98bd53dedb31..303f6f8f44ac3020055dd3372cc01a48effb851f 100644 (file)
@@ -55,7 +55,9 @@ public:
     DraggingByMiddleButton = 0x0010,
     ImmediateContextMenu   = 0x0020,
     ImmediateSelection     = 0x0040,
-    Sketching              = 0x0080
+    Sketching              = 0x0080,
+
+    GlobalWheelScaling     = 0x0100
   };
   Q_DECLARE_FLAGS( InteractionFlags, InteractionFlag )
 
index ddb9b18ee76eb74250d1793f2bfc1c5766c09611..a8e1511b2c360aec3bb3d834f2eda335abd788f5 100644 (file)
@@ -37,6 +37,8 @@
 #include <QKeyEvent>
 #include <QMenu>
 
+#include <math.h>
+
 // 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;
index c1f2b4d5032af4a3b404de1a3be66828fcc2cc37..4e3b9d6b86ae8006ba745165e3f6a35dc4d77c34 100755 (executable)
@@ -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;
+}
index c29474ebfcd24436f76bfd717c900747978a59a1..e4ac7c119d71d7b6fea4222f6ef6e40f45bd6578 100755 (executable)
@@ -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
index e42313e63ca0c8447004da69e05d5544cc7323c4..2fabb182f916260db90c80eabb27176c536177b4 100755 (executable)
@@ -628,6 +628,7 @@ void OCCViewer_ViewPort3d::resizeEvent( QResizeEvent* e )
     QApplication::syncX();
 #endif
   QTimer::singleShot( 0, this, SLOT( repaintViewAfterMove() ) );
+  emit vpResizeEvent( e );
 }
 
 /*!
index 99428489804e23f294917cd1d090782ed98f5f5f..01b0fc17a018424758c70f8feb5463660e6b3322 100755 (executable)
@@ -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* );
index a4bce4220b4e3d0040794c9f2ae7b8446b4b8331..cfeb79fb49f605a791e11bdaf7784d9edb151968 100644 (file)
@@ -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<OCCViewer_ViewManager*>( 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
index e83fe217e196b2c0694af66308e5aafb0f0937d6..c68465fa5d0a8134e05df96995674f5232b452c1 100755 (executable)
@@ -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