Code covered by the BSD License  

Highlights from
zoom2cursor

5.0

5.0 | 10 ratings Rate this file 10 Downloads (last 30 days) File Size: 3.76 KB File ID: #2902
image thumbnail

zoom2cursor

by Brett Shoelson

 

02 Jan 2003 (Updated 19 Feb 2003)

Dynamic, scalable zoom following the motion of the cursor; also displays the current position.

Editor's Notes:

This file was a File Exchange Pick of the Week

| Watch this File

File Information
Description

% FUNCTION ZOOM2CURSOR
% ZOOM2CURSOR, without arguments, will activate the current axis, create a text box showing the current position of the mouse pointer (similar to pixval), and automatically zoom the image to the location of the cursor as it is moved. The zoomed display dynamically scrolls with the motion of the cursor.
%
% By default, the function zooms to 50% of the image in the axis.
%
% BUTTON CLICKS:
% Left-clicking will zoom in further, and right-clicking will zoom out.
% Shift-clicking (or simultaneously clicking the left and right mouse buttons) at any point will display the original (un-zoomed) image, as will moving the cursor outside of the current axis. The zoom percentage is restored when the mouse is moved.
% Double-clicking zooms out to the original image, modifying the zoom percentage.
%
% Tested under R12.1 and R13.
%
% Written by Brett Shoelson, Ph.D. (shoelson@helix.nih.gov, shoelson@hotmail.com)
% 12/26/02
% 2/16/03; Rev 2: Program is more robust; fixes a bug when window is resized.
%Incremental increase/decrease in zoom percent (on mouseclick) has been reduced.
%ALSO: Now works with images, surfaces, lines (and thus plots), and patches (rather than just images)

Acknowledgements
This submission has inspired the following:
zinput
MATLAB release MATLAB 6.5 (R13)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (12)
26 Apr 2003 Paul Koola

Excellent feature for Visual data exploration.

14 Jul 2003 Berthold Käferstein

Very cool utility to simplify the work with plots!

09 Jun 2004 Andy Bliss

Very nice! I was contemplating writing something like this, but I was glad to find that someone else had already accomplished the daunting task.

29 Sep 2004 Anne Carpenter

Nice work! Just what I needed, and it works great on R14 on a Mac.

17 Jun 2005 Plamen Stoyanov  
09 Nov 2005 paul calvert

VERY VERY VERY nice!!
A nice improvement would be to have an 'escape' mode to allow selecting a different figure or subplot ..or just plain 'exit' of the function....

25 Apr 2006 Engamba Bobin

Very good work. Will help me greatly.
How do you exit, assuming you can? Or do you just have to close the figure?

23 Sep 2007 Moshe Ufnik

Very elegant

29 Nov 2007 Ahmad Samy

Excellent usage of figure handles.
Waiting for your next work

06 Oct 2009 Charles Attard

Very useful, thanks.
For those wondering how to exit the function, just click on 'X'.

I've found useful to create a 'exit_zoom2cursor' function.
If you're interested, comment the statement 'endbutton = ...'
And call this function:

function exit_zoom2cursor
zoomparams = getappdata(gcf,'zoomparams');
if isempty(zoomparams)
    return;
end;
set(gcf,'windowbuttonmotionfcn',zoomparams.oldwbmf);
set(zoomparams.currax,'units',zoomparams.oldaxunits,'xlim',zoomparams.oldxlim,'ylim',zoomparams.oldylim);
set(get(zoomparams.currax,'children'),'buttondownfcn',zoomparams.bdfcnold,'busyaction',zoomparams.baold);
set(gcf,'pointer',zoomparams.oldpointer,'doublebuffer',zoomparams.dbold);

25 Mar 2011 Mohammed El-Said

Great work,
it is really useful,
Thanks for Sharing...

01 Apr 2011 Brett Shoelson

Thanks for all the feedback.... Regarding EXIT functionality, doesn't clicking on the "x" (lower left) suffice?

Please login to add a comment or rating.
Updates
19 Feb 2003

Program is more robust; fixes a bug when window is resized.
% Incremental increase/decrease in zoom percent (on mouseclick) has been reduced.
%Also: Now works with images, surfaces, lines (and thus plots), and patches (rather than just images)

Tag Activity for this File
Tag Applied By Date/Time
gui Brett Shoelson 22 Oct 2008 06:55:44
display Brett Shoelson 22 Oct 2008 06:55:44
annotation Brett Shoelson 22 Oct 2008 06:55:44
zoom cursor pan motion dynamic scroll position Brett Shoelson 22 Oct 2008 06:55:44

Contact us at files@mathworks.com