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

    function pPlotNext(obj)
%PPLOTNEXT  Private method: changes the Z-data of the plot

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


t = getVariableValues(obj.PlotData,3);

slider_val = get(obj.hSlider,'Value');

% Find the index of the value in t nearest to the slider and select it.
[ignore,index] = min(abs(t-slider_val));
set(obj.hSlider,'Value',t(index));

if isempty(obj.PlotData)
    obj.reset;
    return;
end

if isempty(obj.hColorMap)
    error(message('mbc:cgsurfview:movieplot:InvalidState1'));
end

vardata = obj.vardata;

% Extract Z-data for surface
ztemp = getValues(obj.PlotData,1); % We always have zdata
vardata.z = ztemp(:,:,index);

% Extract C-data for surface.  If we have a second set of data to plot,
% use this.  Otherwise, just use the Z-data again.
vardata.c = obj.cdata(:,:,index);

% Check for constrait data
if getConstraintOptions(obj.PlotData) % only one option
    c =  getConstraints(obj.PlotData);
    if ~isempty(c)
        constraints = c(:,:,index);
    else
        constraints = [];
    end
else
    constraints = [];
end

% draw (or re-draw) surface
if isempty(obj.hSurface)
    h = obj.hAxes;
else
    h = obj.hSurface;
end
obj.hSurface = cgsurfview.draw_surface(h,...
    vardata, ...
    constraints, ...
    obj.hColorMap, ...
    obj.PlotOptions, ...
    obj.crange);

% use the title of the axes to show the value of time if necessary
if obj.PlotOptions.show_time
    tname = getVariableName(obj.PlotData,3);
    mbctitle(obj.hAxes, [tname ' = ' num2str(t(index))]);
end