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

    function plot(obj, svdata)
%PLOT Draws a surface plot
%
%  PLOT(OBJ, SVDATA)

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


cla(obj.hAxes);
set(obj.hAxes, 'Box', obj.PlotOptions.box);
cbvisible = false;

vardata = cgsurfview.setup_axes(obj.hAxes,getVariables(svdata));

hasdata = hasData(svdata);

cb = obj.hColorBar;

% if no colour data is specified, use the surface height itself
% and omit the colour bar
zdata = getValues(svdata,1);
if ~hasdata(2)
	cdata = zdata;
	set(obj.Display,'elements',{obj.hAxisPanel},'dimension',[1 1],'colsizes',-1,'rowsizes',-1);
else
	% use the colour bar
    cdata = getValues(svdata,2);
	set(obj.Display,...
        'dimension',[3 3], ...
        'colsizes',[-1 60 0], ...
        'rowsizes', [10 -1 10], ...
        'mergeblock', {[1 3], [1 1]}, ...
        'gapx',5, ...
        'elements',{obj.hAxisPanel, [], [], [], cb});
	% the colour bar needs a smaller border than the main axes
	cbvisible = true;
end

vardata.z = zdata;
vardata.c = cdata;

if cbvisible    
    if isempty(obj.hRangeListener)
        % Create a new listener.  Don't assign a callback yet.
        obj.hRangeListener = handle.listener(cb,'RangeChanged',[]);
    end
    
    % Set the callback for the existing listener.  This saves us the
    % overhead or creating a new one each time.
    obj.hRangeListener.Callback = {@i_ColourRangeChange, obj, vardata,...
        getConstraints(svdata), svdata.datasetnames{1}};
    
    set(cb, 'Visible', obj.Visible);
else
    set(cb, 'Visible', 'off');
end

rangedata = cdata;
if getConstraintOptions(svdata) % only one option
    svc = getConstraints(svdata);
    if ~isempty(svc)
        % select only those inside the boundary
        rangedata = rangedata(svc<=0);
    end
end
clim = mbcmakelimits(rangedata, 'round');
if cbvisible
    cb.setRange(clim);
end

obj.hSurface1 = cgsurfview.draw_surface(obj.hAxes, ...
    vardata, ...
    getConstraints(svdata), ...
    obj.cmap1, ...
    obj.PlotOptions, ...
    clim);
xregGui.setLegendData(obj.hSurface1, svdata.datasetnames{1});

if hasdata(3)
    vardata.z = getValues(svdata,3);
    vardata.c = getValues(svdata,3);

    % second surface
    obj.hSurface2 = cgsurfview.draw_surface(obj.hAxes,vardata,getConstraints(svdata),obj.cmap2,obj.PlotOptions);
    xregGui.setLegendData(obj.hSurface2,svdata.datasetnames{3});
end

obj.PlotData = svdata;

obj.pSetZRange;



%-------------------------
% obj,cb, data, cmap, h (surface handle)
function i_ColourRangeChange(src, evt, obj, vardata, constraints, DispName)
if isgraphics(obj.hSurface1)
    delete(obj.hSurface1);
end

obj.hSurface1 = cgsurfview.draw_surface(obj.hAxes, ...
    vardata, ...
    constraints, ...
    src.ColorMap, ...
    obj.PlotOptions, ...
    [src.Min, src.Max]);
xregGui.setLegendData(obj.hSurface1, DispName);