diff --git a/src/AIS/AIS_ViewController.cxx b/src/AIS/AIS_ViewController.cxx index 9a463779af..2ab3858d52 100644 --- a/src/AIS/AIS_ViewController.cxx +++ b/src/AIS/AIS_ViewController.cxx @@ -1510,6 +1510,10 @@ void AIS_ViewController::handlePanning (const Handle(V3d_View)& theView) AbortViewAnimation(); const Handle(Graphic3d_Camera)& aCam = theView->Camera(); + aCam->SetPanningVector(aCam->PanningVector() + + gp_Vec2d(theView->Convert(myGL.Panning.Delta.x()), + theView->Convert(myGL.Panning.Delta.y()))); + if (aCam->IsOrthographic() || !hasPanningAnchorPoint()) { diff --git a/src/Graphic3d/Graphic3d_Camera.hxx b/src/Graphic3d/Graphic3d_Camera.hxx index 17875b5c74..2d93ecd9f7 100644 --- a/src/Graphic3d/Graphic3d_Camera.hxx +++ b/src/Graphic3d/Graphic3d_Camera.hxx @@ -289,6 +289,17 @@ public: myRotationPoint = theRotationPoint; }; + //! Get panning translation. + //! @return the panning translation. + gp_Vec2d PanningVector() const { return myPanningVector; } + + //! Sets panning translation. + //! @param thePanningVector [in] the panning translation. + void SetPanningVector(const gp_Vec2d &thePanningVector) + { + myPanningVector = thePanningVector; + }; + //! Get distance of Eye from camera Center. //! @return the distance. Standard_Real Distance() const { return myDistance; } @@ -854,6 +865,7 @@ private: gp_Dir myDirection;//!< Camera view direction (from eye) gp_Pnt myEye; //!< Camera eye position gp_Pnt myRotationPoint; + gp_Vec2d myPanningVector; Standard_Real myDistance; //!< distance from Eye to Center gp_XYZ myAxialScale; //!< World axial scale. diff --git a/src/OpenGl/OpenGl_View.cxx b/src/OpenGl/OpenGl_View.cxx index d6b9b776a9..6def227cf8 100644 --- a/src/OpenGl/OpenGl_View.cxx +++ b/src/OpenGl/OpenGl_View.cxx @@ -2599,6 +2599,9 @@ void OpenGl_View::renderGrid() aTranslationInv.SetColumn (3, -aRotationVec); OpenGl_Mat4 aWorldViewStateCorrected = aTranslationInv * aWorldViewCurrent * aTranslation; aPosition.ChangeCoord() += gp_XYZ (aWorldViewStateCorrected (0, 3), aWorldViewStateCorrected (1, 3), -aZFar); + + gp_XYZ aPanningVector (aCamera->PanningVector().X(), aCamera->PanningVector().Y(), 0.0); + aPosition.ChangeCoord() -= aPanningVector; } OpenGl_Mat4 aTranslation; aTranslation.SetColumn (3, Graphic3d_Vec4 ((float)aPosition.X(), (float)aPosition.Y(), (float)aPosition.Z(), 1.0));