www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgsurfview/@dataviewer/copyToFigure.m
function fig = copyToFigure(obj) %COPYTOFIGURE Returns a figure containing a copy of the current plots % % FIG = COPYTOFIGURE(OBJ) creates a copy of the view in a new figure. The % created figure is invisible. % Copyright 2000-2011 The MathWorks, Inc. and Ford Global Technologies, Inc. plottype = obj.currentplottype; if ~obj.plottypes(plottype).cancopy error(message('mbc:cgsurfview:datasel:InvalidOperation', obj.plottypes( plottype ).name)); end dim = get(obj.plotgrid,'dimension'); fig = figure('Visible','off', ... 'MenuBar','none', ... 'ToolBar', 'none', ... 'NumberTitle', 'off', ... 'Color', get(0, 'DefaultUicontrolBackgroundColor'), ... 'Renderer','zbuffer'); d = obj.framedata; vc = obj.visiblecards; e = cell(dim); valid = 0; for i=1:numel(vc) pt = vc(i); % type for *this* plot (which may have reduced inputs) if pt<size(d,1) % non-error plottype if obj.plottypes(pt).cancopy plotobj = d{pt,i}; e{i} = plotobj.copyToFigure(fig); valid = 1; else errordlg(['Can''t print plots of type ' obj.plottypes(pt).name],'Print Error'); end end end if valid % Create a grid of views, but without using MBC layouts basepos = get(0, 'DefaultAxesPosition'); if numel(e)==1 set(e{1},'Units','Normalized',... 'Position',basepos); elseif numel(e)==2 basepos(3) = basepos(3)-0.5;% / 2; % half width set(e{1},'Units','Normalized',... 'Position', basepos); % left set(e{2},'Units','Normalized',... 'Position',basepos + [0.5 0 0 0]); % right else basepos(3) = basepos(3)-0.5; basepos(4) = basepos(4)-0.5; set(e{1},'Units','Normalized',... 'Position',basepos + [0 0.5 0 0]); % top left set(e{2},'Units','Normalized',... 'Position',basepos + [0.5 0.5 0 0]); % top right set(e{3},'Units','Normalized',... 'Position',basepos); % bottom left (the origin) if numel(e)>3 && ~isempty(e{4}) set(e{4},'Units','Normalized',... 'Position',basepos + [0.5 0 0 0]); % bottom right end end else delete(fig); fig = []; end