www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgsurfview/@dataviewer/dataviewer.m

    function h=dataviewer(fig,plotoptions,statuscallback)
%DATAVIEWER
%
%  Constructor for the panel in the  CAGE surface viewer which displays the
%  actual plots.
%
% h = dataviewer(fig,plotoptions,statuscallback)

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

if (nargin==0)
    error(message('mbc:cgsurfview:dataviewer:TooFewInputs'));
end

h = cgsurfview.dataviewer;
h.fig = fig;

lineopts = cgsurfview.lineoptions; % shared
surfopts = cgsurfview.surfaceoptions; % shared
surfopts.connectToLineOptions(lineopts); % "Common Y/Z-Range" property is shared

% shortname: just an identifier
% name: the name the user sees
% vars: input labels
% displays: output labels
% createfcn: handle to function which creates the plot object
% optionsobj: object which manages the plot options, or empty
% checks: labels for "show boundary" checkboxes
% cancopy: true if this plot type can be copied to another figure
% reducedinputs: index of plot type to be used if too few inputs are supplied, or zero

p(1).shortname = 'surface';
p(1).name = 'Surface';
p(1).vars = {'X-axis','Y-axis'};
p(1).displays = {'Surface 1 Height','Surface 1 Shading','Surface 2 Height'};
p(1).createfcn = @i_surfaceplot;
p(1).optionsobj = surfopts;
p(1).checks = {'Mark points outside boundary'};
p(1).cancopy = true;
p(1).reducedinputs = 3; % Single Line
p(1).hascursormode = false;
p(1).data = [];

p(2).shortname = 'contour';
p(2).name = 'Contour';
p(2).vars = {'X-axis','Y-axis'};
p(2).displays = {'Contours'};
p(2).createfcn = @i_contourplot;
p(2).optionsobj = cgsurfview.contouroptions;
p(2).checks = {'Show boundary'};
p(2).cancopy = true;
p(2).reducedinputs = 0;
p(2).hascursormode = true;
p(2).data = [];

p(3).shortname = 'line';
p(3).name = 'Line';
p(3).vars = {'X-axis'};
p(3).displays =  {'Line 1','Line 2','Line 3'};
p(3).createfcn = @i_lineplot;
p(3).optionsobj = lineopts;
p(3).checks = {'Clip to boundary'};
p(3).cancopy = true;
p(3).reducedinputs = 4; % Single Value
p(3).hascursormode = true;
p(3).data = [];

p(4).shortname = 'point';
p(4).name = 'Single Value';
p(4).vars = {};
p(4).displays = {'Display value of'};
p(4).createfcn = @i_pointplot;
p(4).optionsobj = [];
p(4).checks = {};
p(4).cancopy = true;
p(4).reducedinputs = 0;
p(4).hascursormode = false;
p(4).data = [];

p(5).shortname = 'multiline';
p(5).name = 'Multiline';
p(5).vars = {'X-axis','Line colors'};
p(5).displays = {'Y-axis'};
p(5).createfcn = @i_multilineplot;
p(5).optionsobj = lineopts;
p(5).checks = {'Clip to boundary'};
p(5).cancopy = true;
p(5).reducedinputs = 3;
p(5).hascursormode = true;
p(5).data = [];

p(6).shortname = 'movie';
p(6).name = 'Movie';
p(6).vars = {'X-axis','Y-axis','Time'};
p(6).displays = {'Surface','Shading'};
p(6).createfcn = @i_movieplot;
p(6).optionsobj = surfopts;
p(6).checks = {'Mark points outside boundary'};
p(6).cancopy = false;
p(6).reducedinputs = 1; % Surface
p(6).hascursormode = false;
p(6).data = [];

p(7).shortname = 'table2';
p(7).name = '2-D Table';
p(7).vars = {'Rows','Columns'};
p(7).displays = {'Cell values'};
p(7).createfcn = @i_table2plot;
p(7).optionsobj = [];
p(7).checks = {'Mark cells outside boundary'};
p(7).cancopy = false;
p(7).reducedinputs = 8; % 1-D Table
p(7).hascursormode = false;
p(7).data = [];

p(8).shortname = 'table1';
p(8).name = '1-D Table';
p(8).vars = {'Input'};
p(8).displays = {'Column 1','Column 2','Column 3'};
p(8).createfcn = @i_table1plot;
p(8).optionsobj = [];
p(8).checks = {'Mark cells outside boundary'};
p(8).cancopy = false;
p(8).reducedinputs = 4; % Single Value
p(8).hascursormode = false;
p(8).data = [];

h.plottypes = p;

if nargin>1
    h.setPlotOptions(plotoptions);
end

if nargin>2
    h.statuscallback = statuscallback;
end

numplottypes=length(h.plottypes);
blankindex=numplottypes+1;

h.framedata = cell(blankindex,h.MaxPlots);
h.haserror = zeros(numplottypes,h.MaxPlots);

frames = cell(1,h.MaxPlots);
cards = cell(1,h.MaxPlots);
for k=1:h.MaxPlots
    frames{k} = mbcgui.container.titlebarpanel(...
        'Parent', fig);
    txt = uicontrol('Parent',frames{k},'Style','text','Enable', 'inactive', 'HitTest', 'off');
    h.framedata{blankindex, k} = txt;
    cards{k} = xregcardlayout(frames{k},'numcards',blankindex);
    attach(cards{k}, txt, blankindex);
    set(frames{k},'ContentHandle',{cards{k}});
end
h.plotcards = cards;
h.plotframes = frames;


% grid of views
h.plotgrid = xreggridbaglayout(fig, ...
    'gapx',2,'gapy',2);

% now create the "blank" card, which contains only a line of text.
txt = uicontrol('Parent',fig,'Style','text',...
    'HitTest', 'off', ...
    'Enable', 'inactive', ...
    'String','Click ''Evaluate Now'' to display data',...
    'Visible','off');
evaluatecard = xreglayerlayout(fig,'elements',{txt},...
    'border',[50 50 50 50]);

% create bottom level layout
h.layout=xregcardlayout(fig,'visible','off',...
    'numcards',blankindex);
attach(h.layout, h.plotgrid, 1);
attach(h.layout, evaluatecard, 2);

connect(h.layout, h, 'up');

h.show; % display the blank card first


%---------------
function plotobj = i_surfaceplot(obj,opts,panel) %#ok<*INUSL>

plotobj = cgsurfview.surfaceplot('Parent',panel,'PlotOptions',opts);

%----------------------
function plotobj = i_contourplot(obj,opts,panel)

plotobj = cgsurfview.contourplot('Parent',panel,'PlotOptions',opts);
    
%-------------------
function plotobj = i_lineplot(obj,opts,panel)

plotobj = cgsurfview.lineplot('Parent',panel,'PlotOptions',opts,'Type',1);

%-------------------
function plotobj = i_pointplot(obj,opts,panel)

plotobj = cgsurfview.pointplot('Parent',panel);

%-------------------
function plotobj = i_multilineplot(obj,opts,panel)

plotobj = cgsurfview.lineplot('Parent',panel,'PlotOptions',opts,'Type',2);

%-------------------
function plotobj = i_movieplot(obj,opts,panel)

plotobj = cgsurfview.movieplot('Parent',panel,'PlotOptions',opts);

%-------------------
function plotobj = i_table2plot(obj,opts,panel)

plotobj = cgsurfview.table2plot('Parent',panel);

%-------------------
function plotobj = i_table1plot(obj,opts,panel)

plotobj = cgsurfview.table1plot('Parent',panel);