www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@xregmultigraph2d/copyobj.m

    function new=copyobj(gr,p)
%  GRAPH2D/COPYOBJ   copyobj for xregmultigraph2d object
%   new = copyobj(gr,parent)

%  Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc.


% Bail if we've not been given a graph2d object
if ~isa(gr,'xregmultigraph2d')
   error(message('mbc:xregmultigraph2d:InvalidObject'))
end

new = xregmultigraph2d(p);
% Copy properties
ud1 = get(gr.axes,'UserData');
% clear callbacks
ud1.callback = [];
ud1.singlecallback = [];
ud1.multicallback = [];
ud1.lines = [];
ud1.patches = [];
ud1.contextmenu = [];
set(new.axes,'UserData',ud1);
% Copy data
% copy of object in the patch
% tdata in xfactor
% xdata in xtext
% cdata in yfactor
% ydata in ytext
% visible in badim
xdata = get(gr.xtext,'UserData');
cdata = get(gr.yfactor,'UserData');
ydata = get(gr.ytext,'UserData');

% set position
newpos = ud1.pos; 
newpos([1 2]) = [10 10];
set(new.xfactor,'String',get(gr.xfactor,'String'),'Value',get(gr.xfactor,'Value'));
set(new.yfactor,'String',get(gr.yfactor,'String'),'Value',get(gr.yfactor,'Value'));
set(new,'visible','on','position',newpos,...
    'backgroundcolor',get(gr,'BackgroundColor'),...
    'tableptr',ud1.tableptr,...
    'frame',get(gr,'frame'),...
    'data',xdata,...
    'ydata',ydata,...
    'cdata',cdata,...
    'factors',ud1.xfactors,...
    'cfactor',ud1.colorfactor,...
    'title',get(get(gr.axes,'Title'),'String'),...
    'colorlimitstyle',get(gr.colorbar,'limitstyle'));
relrange = [get(gr.colorbar,'relminrange') get(gr.colorbar,'relmaxrange')];
if length(relrange)~=2, relrange = [0 1]; end
set(new.colorbar,'currentfactor',get(gr.colorbar,'currentfactor'),...
    'userange',get(gr.colorbar,'userange'),...
    'relrange',relrange);
pr_plot(new);