mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-04 18:06:22 +03:00
0030853: Visualization, AIS_ViewController - fix 1 pixel Y shift while zooming
Fixed error in math converting Y-down mouse coordinates into Y-up within AIS_ViewController::handleZoom(). Added flags ToStickToRayOnZoom()/ToStickToRayOnRotation() enabled by default, which will project picked point onto ray at mouse cursor to preserve focus on zoom out.
This commit is contained in:
parent
a3a3ff3d33
commit
9460f8c0b9
@ -48,6 +48,8 @@ AIS_ViewController::AIS_ViewController()
|
||||
myToAllowZFocus (true),
|
||||
myToAllowHighlight (true),
|
||||
myToAllowDragging (true),
|
||||
myToStickToRayOnZoom (true),
|
||||
myToStickToRayOnRotation (true),
|
||||
//
|
||||
myWalkSpeedAbsolute (1.5f),
|
||||
myWalkSpeedRelative (0.1f),
|
||||
@ -1393,9 +1395,9 @@ void AIS_ViewController::handleZoom (const Handle(V3d_View)& theView,
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
theView->Window()->Size (aWinSize.x(), aWinSize.y());
|
||||
const Graphic3d_Vec2d aPanFromCenterPx (double(theParams.Point.x()) - 0.5 * double(aWinSize.x()),
|
||||
double(theParams.Point.y()) - 0.5 * double(aWinSize.y()));
|
||||
double(aWinSize.y() - theParams.Point.y() - 1) - 0.5 * double(aWinSize.y()));
|
||||
aDxy.x() += -aViewDims1.X() * aPanFromCenterPx.x() / double(aWinSize.x());
|
||||
aDxy.y() += aViewDims1.X() * aPanFromCenterPx.y() / double(aWinSize.x());
|
||||
aDxy.y() += -aViewDims1.Y() * aPanFromCenterPx.y() / double(aWinSize.y());
|
||||
}
|
||||
|
||||
//theView->Translate (aCam, aDxy.x(), aDxy.y());
|
||||
@ -1661,7 +1663,7 @@ gp_Pnt AIS_ViewController::GravityPoint (const Handle(AIS_InteractiveContext)& t
|
||||
}
|
||||
|
||||
gp_Pnt aPnt;
|
||||
if (PickPoint (aPnt, theCtx, theView, aCursor, false))
|
||||
if (PickPoint (aPnt, theCtx, theView, aCursor, myToStickToRayOnRotation))
|
||||
{
|
||||
return aPnt;
|
||||
}
|
||||
@ -1882,12 +1884,9 @@ void AIS_ViewController::handleCameraActions (const Handle(AIS_InteractiveContex
|
||||
|
||||
if (!theView->Camera()->IsOrthographic())
|
||||
{
|
||||
// what is more natural to user - point on ray or point exactly on geometry in corner cases?
|
||||
const bool toStickToRay = false; // true;
|
||||
|
||||
gp_Pnt aPnt;
|
||||
if (aZoomParams.HasPoint()
|
||||
&& PickPoint (aPnt, theCtx, theView, aZoomParams.Point, toStickToRay))
|
||||
&& PickPoint (aPnt, theCtx, theView, aZoomParams.Point, myToStickToRayOnZoom))
|
||||
{
|
||||
handleZoom (theView, aZoomParams, &aPnt);
|
||||
continue;
|
||||
@ -1895,7 +1894,7 @@ void AIS_ViewController::handleCameraActions (const Handle(AIS_InteractiveContex
|
||||
|
||||
Graphic3d_Vec2i aWinSize;
|
||||
theView->Window()->Size (aWinSize.x(), aWinSize.y());
|
||||
if (PickPoint (aPnt, theCtx, theView, aWinSize / 2, toStickToRay))
|
||||
if (PickPoint (aPnt, theCtx, theView, aWinSize / 2, myToStickToRayOnZoom))
|
||||
{
|
||||
aZoomParams.ResetPoint(); // do not pretend to zoom at 'nothing'
|
||||
handleZoom (theView, aZoomParams, &aPnt);
|
||||
|
@ -152,6 +152,18 @@ public: //! @name global parameters
|
||||
//! Set if dynamic highlight on mouse move is allowed.
|
||||
void SetAllowDragging (bool theToEnable) { myToAllowDragging = theToEnable; }
|
||||
|
||||
//! Return TRUE if picked point should be projected to picking ray on zooming at point; TRUE by default.
|
||||
bool ToStickToRayOnZoom() const { return myToStickToRayOnZoom; }
|
||||
|
||||
//! Set if picked point should be projected to picking ray on zooming at point.
|
||||
void SetStickToRayOnZoom (bool theToEnable) { myToStickToRayOnZoom = theToEnable; }
|
||||
|
||||
//! Return TRUE if picked point should be projected to picking ray on rotating around point; TRUE by default.
|
||||
bool ToStickToRayOnRotation() const { return myToStickToRayOnRotation; }
|
||||
|
||||
//! Set if picked point should be projected to picking ray on rotating around point.
|
||||
void SetStickToRayOnRotation (bool theToEnable) { myToStickToRayOnRotation = theToEnable; }
|
||||
|
||||
//! Return TRUE if pitch direction should be inverted while processing Aspect_VKey_NavLookUp/Aspect_VKey_NavLookDown; FALSE by default.
|
||||
bool ToInvertPitch() const { return myToInvertPitch; }
|
||||
|
||||
@ -600,6 +612,8 @@ protected:
|
||||
Standard_Boolean myToAllowZFocus; //!< enable ZFocus change; TRUE by default
|
||||
Standard_Boolean myToAllowHighlight; //!< enable dynamic highlight on mouse move; TRUE by default
|
||||
Standard_Boolean myToAllowDragging; //!< enable dragging object; TRUE by default
|
||||
Standard_Boolean myToStickToRayOnZoom; //!< project picked point to ray while zooming at point, TRUE by default
|
||||
Standard_Boolean myToStickToRayOnRotation; //!< project picked point to ray while rotating around point; TRUE by default
|
||||
|
||||
Standard_ShortReal myWalkSpeedAbsolute; //!< normal walking speed, in m/s; 1.5 by default
|
||||
Standard_ShortReal myWalkSpeedRelative; //!< walking speed relative to scene bounding box; 0.1 by default
|
||||
|
Loading…
x
Reference in New Issue
Block a user