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

    function d = show(node, cgb, d)
%SHOW Configure the browser display for tables
%
%  DATA = SHOW(NODE, CGB, DATA) configures the browser's table node view.

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

ParentNode = Parent(node);
pT = getdata(node);
NumAx = pT.getNumAxes;
IsTableEmpty = pT.isempty;

% Decide whether we are being viewed as part of a feature or not
if isa(ParentNode.info, 'cgfeaturenode')
    d.FeaturePointer = ParentNode.getdata;
else
    d.FeaturePointer = xregpointer;
end

if pT.getNumAxes==1
    d.Handles.Editor1D.settable(pT);
else
    d.Handles.Editor2D.settable(pT);
end
% display dependencies
A = getConnections(project(node));
CurrentItem = find(A,'data',pT);
idxUsers = getAllUsers(A,CurrentItem);
idxUsers = idxUsers(ismember(A.Type(idxUsers),{'Feature','Tradeoff','Optimization','Dataset'}));
d.Handles.FillersList.Items = A.pNode(idxUsers);


d.SuppressViewUpdate = true;


% Set the editor for the table dimensions
set(d.Handles.TopCard, 'CurrentCard', NumAx);

% Set a message if the table needs to be initialised
if IsTableEmpty
    if ~isempty(d.ShownMessageID)
        cgb.removeStatusMsg(d.ShownMessageID);
    end
    d.ShownMessageID = cgb.addStatusMsg(['This table needs to be set up in the' ...
        ' Calibration Manager before any further analysis can be done']);
end

% Enable the appropriate menu items and toolbar buttons
menuEn = repmat({'off'}, 27,1);
tbEn = repmat({'off'}, 8,1);

% Always show history menu and properties menu
menuEn = i_setcellvalues(menuEn, [1 16], 'on');

% Always show context menu items
menuEn = i_setcellvalues(menuEn, 17:26, 'on');

if ~isnull(d.FeaturePointer)
    % Enable comparison pane switching
    menuEn{2} = 'on';
end
if ~IsTableEmpty
    % Enable standard table ops
    menuEn = i_setcellvalues(menuEn, [6 9:10 13:15], 'on');
    tbEn = i_setcellvalues(tbEn, [1 4:8], 'on');
    
    % inversion requires non constant
    V = get(pT.info,'values');
    if length(unique(V(:)))>1 && pT.issimpletable
        menuEn = i_setcellvalues(menuEn, 8, 'on');
        tbEn = i_setcellvalues(tbEn, 3, 'on');
    end
    
end
cgp = root(node);
if ~IsTableEmpty  && ~(isempty(cgp.getmodels) && isempty(getDatasets(pT,cgp)))
    % requires a model or a fill
    if ~isnull(d.FeaturePointer) || (d.FeaturePointer==0 && pT.issimpletable)
        % fill table
        menuEn = i_setcellvalues(menuEn, 7, 'on');
        tbEn = i_setcellvalues(tbEn, 2, 'on');
    end


    if pT.issimpletable && ~isempty(cgp.getmodels)
        % generate mask from PEV and boundary (requires model)
        menuEn = i_setcellvalues(menuEn, [11 12], 'on');
    end    

end


if NumAx==2
    % Enable rotate/edit options in View menu
    menuEn = i_setcellvalues(menuEn, [2:5 27], 'on');
end

vm = d.Handles.ViewMenu;
tm = d.Handles.TableMenu;
cm = d.Handles.TableContext;
set([vm.History; ...
    vm.RotateSurf; ...
    vm.EditSurf; ...
    vm.RightHandRule;...
    vm.LeftHandRule;...
    tm.Init; ...
    tm.Fill; ...
    tm.Invert; ...
    tm.MathEdit; ...
    tm.ExtrapMask; ...
    tm.PEMask; ...
    tm.BoundaryMask; ...
    tm.Extrapolate; ...
    tm.Locks; ...
    tm.ConvToModel; ...
    tm.Props; ...
    cm.MaskAddSel; ...
    cm.MaskRemoveSel; ...
    cm.MaskClear; ...
    cm.MaskCopy; ...
    cm.LocksAddSel; ...
    cm.LocksRemoveSel; ...
    cm.LocksAddAll; ...
    cm.LocksClear; ...
    cm.LocksCopy; ...
    cm.MathEdit; ...
    vm.TableShading
    ], ...
    {'Enable'}, menuEn);

tb = d.Handles.Toolbar;
set([tb.Init
    tb.Fill
    tb.Invert
    tb.MaskAdd
    tb.MaskRemove
    tb.LockAdd
    tb.LockRemove
    tb.Extrapolate], ...
    {'Enable'}, tbEn);
% check uselocks 
status = pT.getUseLocksInExtrapolation();
set(tm.UseLocks,'Checked',mbconoff(status));


function c = i_setcellvalues(c, ind, val)
for n = ind(:)'
    c{n} = val;
end


function pData = getDatasets(pT,cgp)

pData = findItem(info(cgp),'Type','Dataset','data');
Found = true(size(pData));
tableinps = getinports(info(pT));
for i=1:length(pData)
    op= info(pData(i));
    d= get(op,'Data');
    % data set must be non empty and all table inputs must be in data set
    Found(i) = ~isempty(d) && all(ismember(tableinps,get(op,'ptrlist')));
end
pData = pData(Found);