⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 draggable.m

📁 医学图像处理matlab工具箱
💻 M
字号:
function draggable(h,varargin)% DRAGGABLE - Make it so that a graphics object can be dragged in a figure.%   This function makes an object interactive by allowing it to be dragged%   accross a set of axes, following or not certain constraints. This%   allows for intuitive control elements which are not buttons or other%   standard GUI objects, and which reside inside an axis. Typical use%   involve markers on an axis, whose position alters the output of a%   computation or display% %   >> draggable(h);%   %   makes the object with handle "h" draggable. Use the "Position" property%   of the object to retrieve its position, by issuing a get(h,'Position')%   command.%%   >> draggable(h,...,motionfcn)%%   where "motionfcn" is a function handle, executes the given function%   while the object is dragged. Handle h is passed to motionfcn as an%   argument. Argument "motionfcn" can be put anywhere after handle "h".%%   >> draggable(h,...,constraint,p);%%   enables the object with handle "h" to be dragged, with a constraint.%   Arguments "constraint" (a string) and "p" (a vector) can be put%   anywhere after handle "h".%%   The argument "constraint" may be one of the following strings:%%       'n' or 'none':          The object is unconstrained (default).%       'h' or 'horizontal':    The object can only be moved horizontally.%       'v' or 'vertical':      The object can only be moved vertically.%%   The argument "p" is an optional parameter which depends upon the%   constraint type:%%   Constraint      p                   Description%   -----------------------------------------------------------------------%%   'none'          [x1 x2 y1 y2]       Drag range (for the object's outer%                                       limits, from x1 to x2 on the x-axis%                                       and from y1 to y2 on the y-axis).%                                       Default is the current axes range.%                                       Use "inf" if no limit is desired.%%   'horizontal'    [xmin xmax]         Drag range (for the object's outer%                                       limits). Default is the x-axis%                                       range. Use "inf" if no limit is%                                       desired.%%   'vertical'      [ymin ymax]         Drag range (for the object's outer%                                       limits). Default is the y-axis%                                       range. Use "inf" if no limit is%                                       desired.%%   -----------------------------------------------------------------------%%   >> draggable(h,...,renderer);%%   where renderer is one of 'painters', 'zbuffer' or 'opengl', uses the%   corresponding renderer for the figure while the graphical object whose%   handle is h is being dragged. By default, zbuffer is used since it is%   the only renderer that offers both acceptable performance and a%   guaranteed correct behavior with draggable. The 'painters' renderer is%   too slow, while the 'opengl' renderer's behavior with draggable depends%   ont the graphics driver used and may differ from what is expected. %%   >> draggable(h,'off')%%   returns object h to its original, non-draggable state.%%   See the source code (e.g. by issuing "type draggable" at the Matlab %   prompt) for implementation notes and the copyright notice.% VERSION INFORMATION:% 2003-11-20:   Initially submitted to MatlabCentral.Com% 2004-01-06:   Addition of the renderer option, as proposed by Ohad Gal%               as a feedback on MatlabCentral.Com.% 2004-02-18:   Bugfix: now works with 1-element plots and line objects% 2004-03-04:   Bugfix: sanitized the way the object's new position is%               computed; it now always follow the mouse even after the%               mouse pointer was out of the axes.% 2004-03-05:   Bugfix: movement when mouse is out of the axes is now%               definitely correct ;)% IMPLEMENTATION NOTES:%% This function uses the dragged object's "ButtonDownFcn" function and set it% so that the objec becomes draggable. Any previous "ButtonDownFcn" is thus% lost during operation, but is retrieved after issuing the draggable(h,'off')% command.%% Information about the object's behavior is also stored in the object's% 'UserData' property, using setappdata() and getappdata(). The original% 'UserData' property is restored after issuing the draggable(h,'off')% command.%% The corresponding figure's "WindowButtonDownFcn", "WindowButtonUpFcn" and% "WindowButtonMotionFcn" functions.  During operation, those functions are% set by DRAGGABLE; however, the original ones are restored after the user% stops dragging the object.%% By default, DRAGGABLE also switches the figure's renderer to 'zbuffer'% during operation: 'painters' is not fast enough and 'opengl' sometimes% produce curious results. However there may be a need to switch to another% renderer, so the user can now specify a specific figure renderer during% object drag (thanks to Ohad Gal for the suggestion).%% The "motionfcn" function handle is called at each displacement, after the% object's position is updated, using "feval(motionfcn,h)", where h is the% object's handle.%% TO DO:%% 1 - For now, DRAGGABLE allows only one object at a time to be draggable. In% the future, draggable(h), where h is a vector of handles, will create a% group of objects that will all be dragged when one of them is selected.% ==============================================================================% Copyright (C) 2003, 2004% Francois Bouffard% fbouffar@gel.ulaval.ca% Universit

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -