[Feature] Zoom at mouse position
Stacking program, astrometric (plate) solver, fits file viewer
Brought to you by:
han59
I would like to propose the small change from the attached diff in astap_main.pas, it affects only a handful of lines but has a great impact on usability: When the mouse wheel is used for zooming the zoom center will always be the mouse position, if menu or hotkey is used the center will remain panel1 midpoint as before.
With this change you can quickly zoom into a region of interest without having to pan at all, you will quickly develop an intuitive knowledge where to place the mouse before tirning the wheel to make it end up in exactly the position where you want it. It will be the same intuitive zoom behavior that is also used by Gimp or other graphics programs.
Please see the attached diff
Thanks. That is a very interesting approach. With this you will zoom faster to the place of interest.
I have added a limit such that mouse positions outside image1 are clamped within the image1. So the image doesn't scroll away if the mouse is outside the image.
procedure zoom(mousewheelfactor:double;MousePos: TPoint);
var
maxw : double;
begin
{$ifdef mswindows}
maxw:=65535; {will be 1.2*65535}
{$else}
{$ifdef CPUARM}
maxw:=4000;{struggeling if above}
{$else}
maxw:=15000;
{$endif}
{$endif}
if ( ((mainwindow.image1.width<=maxw) or (mousewheelfactor<1){zoom out}) and {increased to 65535 for Windows only. Was above 12000 unequal stretch}
((mainwindow.image1.width>=100 ) or (mousewheelfactor>1){zoom in}) )
then
begin
{limit the mouse positions to positions within the image1}
mousepos.x:=max(MousePos.X,mainwindow.Image1.Left);
mousepos.y:=max(MousePos.Y,mainwindow.Image1.top);
mousepos.x:=min(MousePos.X,mainwindow.Image1.Left+mainwindow.image1.width);
mousepos.y:=min(MousePos.Y,mainwindow.Image1.top++mainwindow.image1.height);
end;
end;
Last edit: han.k 2020-10-10
just did some more cleanup in the procedure posted before.
It is probably also better to center the image1 in panel1 and not left. Furthermore the arrow keys are not functional.
Released as development version 0.9.428 or as code
http://www.hnsky.org/astap_amd64.rpm
http://www.hnsky.org/astap_amd64.deb
This looks good, working as expected.
Thnaks for the assistance. I see the same behavior for AstroimageJ.