Home > chronux_1_50 > spikesort > UIsubzoom.m

UIsubzoom

PURPOSE ^

UIsubzoom Adds a context menu for zooming subplots to full figure.

SYNOPSIS ^

function ax = UIsubzoom(ax)

DESCRIPTION ^

UIsubzoom        Adds a context menu for zooming subplots to full figure.
   UIsubzoom creates a context menu for the current axes that allows the
   user to move the current axes to a zoomed position filling (most of)
   the parent figure.  Unchecking the zoom option restores axes to their
   position before the most recent zoom.

   If the targeted axes contain one or more image objects, the context 
   menu is added to all image objects in addition to the axes.  If
   UIsubzoom is called on axes that already have this context menu, it
   will further link the context menu to any image objects that do not
   already have it.

   UIsubzoom(HANDLE) associates the menu with the axes specified by
   HANDLE.

   AXHANDLE = UIsubzoom(...) returns a handle to the parent axes
   associated with the new context menu.

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function ax = UIsubzoom(ax)
0002 %UIsubzoom        Adds a context menu for zooming subplots to full figure.
0003 %   UIsubzoom creates a context menu for the current axes that allows the
0004 %   user to move the current axes to a zoomed position filling (most of)
0005 %   the parent figure.  Unchecking the zoom option restores axes to their
0006 %   position before the most recent zoom.
0007 %
0008 %   If the targeted axes contain one or more image objects, the context
0009 %   menu is added to all image objects in addition to the axes.  If
0010 %   UIsubzoom is called on axes that already have this context menu, it
0011 %   will further link the context menu to any image objects that do not
0012 %   already have it.
0013 %
0014 %   UIsubzoom(HANDLE) associates the menu with the axes specified by
0015 %   HANDLE.
0016 %
0017 %   AXHANDLE = UIsubzoom(...) returns a handle to the parent axes
0018 %   associated with the new context menu.
0019 
0020 state = warning;  warning off;
0021 
0022 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Setup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0023 if (nargin < 1),  ax = gca;  end;
0024 if (isempty(ax)), error('No object currently selected.'); end;
0025 switch get(ax, 'Type'),   % restrict to valid objects ...
0026     case 'axes',    % do something here
0027     otherwise,      error(['UIsubzoom not defined for objects of type ' get(h, 'Type') '.']);
0028 end
0029 
0030 info.targetaxs = ax;
0031 info.targetfig = get(ax, 'Parent');
0032 
0033 %%%%%%%%%%%%%%%%%%%%%%%%% Create Context Menu %%%%%%%%%%%%%%%%%%%%%%%%
0034 imgkids = findobj(ax, 'Type', 'image');  % remember image objs
0035 for h = [imgkids(:)' ax];
0036     menu = find_uimenu(h, 'subzoom', 'Expand axes', @CB_subzoom);
0037     if (isempty(get(menu, 'UserData'))),
0038         set(menu, 'UserData', info);
0039     end
0040 end
0041 
0042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Cleanup %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0043 if (nargout == 0), clear ax;  end
0044 
0045 warning(state);

Generated on Mon 09-Oct-2006 00:54:52 by m2html © 2003