www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgdatasetnode/private/pr_RefreshExprList.m

    function d = pr_RefreshExprList(d,select_index,option,unitfilter)
%d = pr_RefreshExprList(d,select_index,option,unitfilter)
%  option = 'outputs','dataset','feature','project'
% call with select_index = expression index to make that expression selected
% call with select_index = -1 to keep current expression selected

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



list = d.Handles.ExprList;

if nargin>1
    if select_index<0
        select_index = list.Selected;
    end
else
    select_index = [];
end

if isempty(d.Exprs.ptrs)
    ind = [];
    title = '';
else
    switch option
    case {'cage','project'}
        ind = d.Exprs.FilterIndex{1};
        title = 'Project Expressions';
    case {'outputs','all'}
        ind = d.Exprs.FilterIndex{2};
        title = 'Output Expressions (Project and Data Set)';
    case 'feature'
        ind = d.Exprs.FilterIndex{3};
        title = 'Features and Models';
    case 'dataset'
        ind = d.Exprs.FilterIndex{4};
        title = 'Data Set Factors';
    otherwise
        error(message('mbc:cgdatasetnode:InvalidOption'));
    end
end

if isempty(ind)
    configureEmptyList(d.Handles.ExprList,...
        'No expressions.',...
        title);
else
   configureExprList(d.Handles.ExprList);
    % no filtering by units available anymore
    configureTitle(d.Handles.ExprList,title,'');
    
    d.Exprs.BottomShown = ind;
    
    [ListData,IconData,ind] = i_getListData(d,ind);
  
    refreshList(list,ListData,IconData,ind,select_index);
    
end

function [ListData,IconData,ind] = i_getListData(d,ind)

ListData = cell(length(ind),3);
IconData = cell(length(ind),1);

tradeofftypestr = get(cgtypes.cgtradeofftype, 'typestring');

DoDisplay = false(length(ind),1);
for i=1:length(ind)
    n = ind(i);
    if strcmp(d.Exprs.types(n), 'Feature')
        FeatureOK = i_CheckFeature(d.Exprs.ptrs(n).info);
    else
        FeatureOK = 1;
    end
    if ~strcmp(d.Exprs.types{n}, tradeofftypestr) && FeatureOK
        ListData(i,:) = {d.Exprs.names{n},d.Exprs.types{n},d.Exprs.infos{n}};
        IconData{i} = d.Exprs.iconfiles{n};
        DoDisplay(i) = true;
    end
end
    
ListData = ListData(DoDisplay,:);
IconData = IconData(DoDisplay);
ind = ind(DoDisplay);
    

%--------------------------------------------------------------------------
function FeatureOK = i_CheckFeature(F)
%--------------------------------------------------------------------------
% This stops empty and partially empty features being shown in the 
% expression list.
eq = get(F,'equation');

FeatureOK =  ~isempty(eq);