Zoom with anchor point under the mouse

karim

CAD community veteran
Hi, I am back!

I have a program based on the occQt Code (https://github.com/eryar/occQt). The only problem I have is the zoom does not take the mouse position as the anchor point.
I want to zoom to the location under the mouse. How to proceed ? thanks.
 

karim

CAD community veteran
Unfortunately I did not save the link, but some one had a working solution.
// 1. pan from the zoom-centre-point to the centre of window,
// 2. zoom,
// 3. pan back from the centre of window to the the zoom-centre-point.

// GetClientRect (o_cl_rect);
// GetView()->SetImmediateUpdate (false);
// GetView()->Pan (o_cl_rect.Width()/2.0-pt.x, pt.y-o_cl_rect.Height()/2.0);
// GetView()->Zoom(...);
// GetView()->SetImmediateUpdate (true);
// GetView()->Pan (pt.x-o_cl_rect.Width()/2.0, o_cl_rect.Height()/2.0-pt.y);
 
Top