www.gusucode.com > mbcguitools 工具箱 matlab 源码程序 > mbcguitools/@mvgraph1d/copyobj.m
function newobj=copyobj(obj,fig) %COPYOBJ Create a copy of an object in a new figure % % NEWOBJ=COPYOBJ(OBJ,FIG) creates a replica of the object % OBJ in the figure FIG. % % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. % Copy data structure newobj=obj; % Create a new panel newobj.panel = uipanel('Parent', fig, ... 'Units', 'pixels', ... 'Position', get(obj.panel, 'Position'), ... 'Visible', get(obj.panel, 'Visible'), ... 'BorderType', 'line', ... 'HighlightColor', get(obj.panel, 'HighlightColor'), ... 'BackgroundColor', get(obj.panel, 'BackgroundColor'), ... 'HitTest', 'off'); % copy graphics objects newobj.badim=mbcgui.widget.Image('Parent', newobj.panel, ... 'Visible', get(obj.badim, 'Visible'), ... 'Position', get(obj.badim, 'Position'), ... 'ImageFile', pr_badim); newobj.axes=copyobj(obj.axes,newobj.panel); newobj.hist.axes=copyobj(obj.hist.axes,newobj.panel); newobj.factortext=copyobj(obj.factortext,newobj.panel); newobj.factorsel=copyobj(obj.factorsel,newobj.panel); % find new patch and line objects newobj.line=get(newobj.axes,'Children'); newobj.hist.patch=get(newobj.hist.axes,'Children'); % Setup callback cb=get(obj.factorsel,'Callback'); set(newobj.factorsel,'Callback',[cb(1), {newobj}]);