% NAME: magnifyOnFigure
% AUTHOR: David Fernandez Prim (david.fernandez.prim@gmail.com)
% PURPOSE: Shows a functional zoom tool, suitable for publishing of zoomed
% images and 2D plots
%
% INPUT ARGUMENTS:
% figureHandle [double 1x1]: graphic handle of the target figure
% axesHandle [double 1x1]: graphic handle of the target axes.
%
% OUTPUT ARGUMENTS:
% none
%
% SINTAX:
% 1) magnifyOnFigure;
% $ Adds magnifier on the first axes of the current figure, with
% default behavior.
%
% 2) magnifyOnFigure( figureHandle );
% $ Adds magnifier on the first axes of the figure with handle
% 'figureHandle', with default behavior.
%
% 3) magnifyOnFigure( figureHandle, 'property1', value1,... );
% $ Adds magnifier on the first axes of the figure with handle
% 'figureHandle', with modified behavior.
%
% 4) magnifyOnFigure( axesHandle );
% $ Adds magnifier on the axes with handle 'axesHandle', with
% default behavior.
%
% 5) magnifyOnFigure( axesHandle, 'property1', value1,... );
% $ Adds magnifier on the axes with handle 'axesHandle', with
% modified behavior.
%
% 6) Consecutive calls to this function (in any of the syntaxes
% exposed above) produce multiple selectable magnifiers on the target axes.
%
% USAGE EXAMPLES: see script 'magnifyOnFigure_examples.m'
%
% PROPERTIES:
% 'magnifierShape': 'Shape of the magnifier ('rectangle' or 'ellipse' allowed, 'rectangle' as default)
% 'secondaryAxesFaceColor': ColorSpec
% 'edgeWidth' Color of the box surrounding the secondary
% axes, magnifier and link. Default 1
% 'edgeColor': Color of the box surrounding the secondary
% axes, magnifier and link. Default 'black'
% 'displayLinkStyle': Style of the link. 'none', 'straight' or
% 'edges', with 'straight' as default.
% 'mode': 'manual' or 'interactive' (allowing
% adjustments through mouse/keyboard). Default
% 'interactive'.
% 'units' Units in which the position vectors are
% given. Only 'pixels' currently supported
% 'initialPositionSecondaryAxes': Initial position vector ([left bottom width height])
% of secondary axes, in pixels
% 'initialPositionMagnifier': Initial position vector ([left bottom width height])
% of magnifier, in pixels
% 'secondaryAxesXLim': Initial XLim value of the secondary axes
% 'secondaryAxesYLim': Initial YLim value of the secondary axes
% 'frozenZoomAspectRatio': Specially useful for images, forces the use of the same zoom
% factor on both X and Y axes, in order to keep the aspect ratio
% ('on' or 'off' allowed, 'off' by default
%
% HOT KEYS (active if 'mode' set to 'interactive')
%
% -In a figure with multiple tool instances
% 'Tab': Switch the focus from one magnifier instance
% to the next one on the current figure.
% 'Mouse pointer on secondary axes or magnifier of a tool+double left click'
% Regain focus
%
% -On the focused magnifier instance
% 'up arrow': Moves magnifier 1 pixel upwards
% 'down arrow': Moves magnifier 1 pixel downwards
% 'left arrow': Moves magnifier 1 pixel to the left
% 'right arrow': Moves magnifier 1 pixel to the right
% 'Shift+up arrow': Expands magnifier 10% on the Y-axis
% 'Shift+down arrow': Compress magnifier 10% on the Y-axis
% 'Shift+left arrow': Compress magnifier 10% on the X-axis
% 'Shift+right arrow': Expands magnifier 10% on the X-axis
% 'Control+up arrow': Moves secondary axes 1 pixel upwards
% 'Control+down arrow': Moves secondary axes 1 pixel downwards
% 'Control+left arrow': Moves secondary axes 1 pixel to the left
% 'Control+right arrow': Moves secondary axes 1 pixel to the right
% 'Alt+up arrow': Expands secondary axes 10% on the Y-axis
% 'Alt+down arrow': Compress secondary axes 10% on the Y-axis
% 'Alt+left arrow': Compress secondary axes 10% on the X-axis
% 'Alt+right arrow': Expands secondary axes 10% on the X-axis
% 'PageUp': Increase additional zooming factor on X-axis
% 'PageDown': Decrease additional zooming factor on X-axis
% 'Shift+PageUp': Increase additional zooming factor on Y-axis
% 'Shift+PageDown': Decrease additional zooming factor on Y-axis
% 'Control+Q': Resets the additional zooming factors to 0
% 'Control+A': Displays position of secondary axes and
% magnifier in the command window
% 'Control+D': Deletes the focused tool
% 'Control+I': Shows/hides the tool identifier (red
% background color when the tool has the focus,
% black otherwise)
% 'Mouse pointer on magnifier+left click' Drag magnifier to any
% direction
% 'Mouse pointer on secondary axes+left click' Drag secondary axes in any
% direction
%
% TODO:
% - Use another axes copy as magnifier instead of rectangle (no ticks).
% - Adapt to work on 3D plots.
% - Add tip tool with interface description?.
%
% KNOWN ISSUES:
% - Secondary axes are not updated when the zoomming or panning tools of the figure are used.
% - Degraded performance for big data sets or big window sizes.
% - The size and position of the magnifier are modified for
% 'PaperPositionMode' equal to 'auto', when the figure is printed to file
% through 'print'
% CHANGE HISTORY:
function magnifyOnFigure( varargin )
clear global appDataStruct
global appDataStruct
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%CHECK OUTPUT ARGUMENTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
switch nargout
case 0
%Correct
outputObjectExpected = false;
case 1
%tool object expected at the output
outputObjectExpected = false;
otherwise
error('Number of output arguments not supported.');
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%CHECK INPUT ARGUMENTS
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin == 0
%Initialize 'appDataStructuct' with default values
appDataStruct = initializeToolStruct();
%Set figure handle
appDataStruct.figureHandle = gcf;
% Get number of axes in the same figure
childHandle = get(appDataStruct.figureHandle, 'Children');
iAxes = find(strcmpi(get(childHandle, 'Type'), 'axes'));
% If no target axes specified, select the first found as mainAxes
appDataStruct.mainAxesHandle = childHandle( iAxes(end) );
elseif nargin > 0
if isstruct(varargin{1})
%Initialize 'appDataStructuct' with existent structure
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
【达摩老生出品,必属精品,亲测校正,质量保证】 资源名:图形放大_magnifyOnFigure_matlab 资源类型:matlab项目全套源码 源码说明: 全部项目源码都是经过测试校正后百分百成功运行的,如果您下载后不能运行可联系我进行指导或者更换。 适合人群:新手及有一定经验的开发人员
资源推荐
资源详情
资源评论
收起资源包目录
图形放大_magnifyOnFigure_matlab.zip (2个子文件)
图形放大_magnifyOnFigure_matlab
magnifyOnFigure.m 95KB
magnifyOnFigure_examples.m 6KB
共 2 条
- 1
资源评论
阿里matlab建模师
- 粉丝: 3377
- 资源: 2786
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功