www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtradeoffgui/@tableGraphView/pDrawSurface.m

    function pDrawSurface(obj)
%PDRAWSURFACE Redraw the table surface
%
%  PDRAWSURFACE(OBJ) redraws the surface of table values.

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

%  $Revision: 1.1.6.4.10.1 $    $Date: 2013/09/20 15:09:37 $ 

if ~isempty(obj.MessageService) ...
        && ~isempty(obj.MessageService.CurrentTable) ...
        && ~isempty(obj.MessageService.CurrentTradeoff)
    
    hTable = info(obj.MessageService.CurrentTable);
    
    if obj.ShowValidFillPoints
        % Doing this now if required will save having to repeat the setting
        % of table inport breakpoints.
        obj.MessageService.TradeoffServices.setPointValues;
    end
    
    OK = setinportsforcells(hTable);
    if ~OK
        % There was a problem getting the table inputs set up.
        i_blanksurface(obj.hAxes, obj.hSurface);
        i_blankmask(obj.hValidFillMask);
    else
        % Get table values and x/y inputs
        pInp = obj.MessageService.TradeoffServices.pTableInputs;
        tblsz = getTableSize(hTable);
        if any(tblsz<2)
            i_blanksurface(obj.hAxes, obj.hSurface);
            i_blankmask(obj.hValidFillMask);
        else
            yD = pInp(1).getvalue;
            yL = mbcmakelimits(yD);
            yD = repmat(yD(:)', tblsz(2),1);
            xD = pInp(2).getvalue;
            xL = mbcmakelimits(xD);
            xD = repmat(xD(:), 1, tblsz(1));
            zD = get(hTable, 'values')';

            % X and Y are switched between table and graph because tables
            % and graphs fundamentally have opposite ideas of which way
            % round x and y go.
            set(obj.hSurface, 'XData', xD, 'YData', yD, 'ZData', zD, 'CData', zD);
            set(obj.hAxes, 'XLim', xL, 'YLim', yL);

            % Set labels to match inport names
            mbcxlabel(obj.hAxes, pInp(2).getname, 'Interpreter', 'none');
            mbcylabel(obj.hAxes, pInp(1).getname, 'Interpreter', 'none');

            % Redraw the mask if required
            if obj.ShowValidFillPoints
                pT = obj.MessageService.CurrentTable;
                hTO = obj.MessageService.CurrentTradeoff.info;
                [~, pMask] = getFillExpression(hTO, pT);

                % The inputs to the tradeoff have already been set if required.
                if isvalid(pMask)
                    isSwitchPoint = pMask.getSwitchGrid(pInp);
                    
                    set(obj.hValidFillMask, 'XData', xD(isSwitchPoint), ...
                        'YData', yD(isSwitchPoint), ...
                        'ZData', zD(isSwitchPoint));
                end
            else
                i_blankmask(obj.hValidFillMask);
            end
        end
    end

else
    % No trade off message service present
    i_blanksurface(obj.hAxes, obj.hSurface);
    i_blankmask(obj.hValidFillMask);
end
    


function i_blanksurface(hAx, hSurf)
set(hSurf, 'XData', [], 'YData', [], 'ZData', [], 'CData', []);
set(hAx, 'XLim', [-1 1], 'YLim', [-1 1]);
mbcxlabel(hAx, '');
mbcylabel(hAx, '');


function i_blankmask(hLine)
set(hLine, 'XData', [], 'YData', [], 'ZData', []);