from
tmark.m
by J. Caspar
Annotation class which generates peak marks that are automatically updated when axes are rescaled.
|
| trestore(hdl)
|
function TM = trestore(hdl)
%TRESTORE Restore tmarks in reloaded figures to functional objects.
%
%Usage: TM = trestore(hdl)
% trestore(tfind) %restore all marks in gcf (1 axis only)
% trestore(hdl) %restore hdl (hdl is to annotation object
%
%NOTE: Because annotation objects are not parented to a specific axis it
%is ambiguous as to the correct parent axis for a tmark reloaded in a
%figure containing multiple axes. Using trestore(tfind) assumes all tmarks
%in the active figure are associated with gca. In a figure with multiple
%axes this may be incorrect. Use manual selection to assign tmarks in this
%case. In the event that restored marks are assigned to the wrong axis,
%this can be fixed by using tedit to reassign them to the correct axis:
% tedit(fs,'hdlAx',newgca).
%
%Inputs
%======
% hdl .................... Handle to an annotation object which is a
% tmark in a figure reloaded from disk.
% As an alternative hdl may be a single figure or axis
% handle in which case embedded tmarks will be
% identified and converted automatically.
%
%Outputs
%=======
% TM ..................... Cell array of modified tmarks
%
%See also: tmark tedit tfind tmulti
if ~ismember('hdl',who)
hdl = gcf;
end
if numel(hdl) == 1
if ishandle(hdl)
switch get(hdl,'type')
case 'figure'
hdl = tfind(hdl);
case 'axis'
hdl = tfind(get(hdl,'parent'));
otherwise
end
end
end
TM = cell(0);
for k=1:numel(hdl)
if ~ishandle(hdl(k))
warning('Invalid handle provided as argument')
continue
end
ud = get(hdl(k),'userdata');
if ~isfield(ud,'tmark')
warning('Specified handle is not a tmark')
end
T = ud.tmark;
T = tmarkrestore(T,hdl(k),gca);
TM{end+1} = T;
end
|
|
Contact us at files@mathworks.com