www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtradeoffgui/@tableSetupList/refresh.m
function refresh(obj) %REFRESH Update list contents % % REFRESH(OBJ) recreates the list of table items in the tradeoff. % Copyright 2000-2011 The MathWorks, Inc. and Ford Global Technologies, Inc. if isempty(obj.TradeoffPointer) || numTables(obj.TradeoffPointer.info)==0 obj.hList.Data = []; set(obj.hTableText, 'String', {'Table size:'; 'Table inputs:'}); else % Save current selection so it can be reset later pT = obj.SelectedTable; % Clear current list % Build a new list pInfo = getAllTableData(obj.TradeoffPointer.info); objInfo = infoarray(pInfo(:, 1)); pFill = pInfo(:,2); fillInfo = cell(size(objInfo)); fillInfo(pFill~=0) = infoarray(pFill(pFill~=0)); sz = getTableSize(objInfo{1}); pInp = getinports(objInfo{1}); set(obj.hTableText, 'String', {sprintf('Table size: %d rows, %d columns', sz(1), sz(2)); ... sprintf('Table inputs: %s, %s', pInp(1).getname, pInp(2).getname)}); Data = cell(size(pInfo,1),3); Icons = Data; for n = 1:size(pInfo,1) Data{n,1} = getname(objInfo{n}); Icons{n,1} = iconfile(objInfo{n}); if ~isempty(fillInfo{n}) Data{n,2} = getname(fillInfo{n}); Icons{n,2} = iconfile(fillInfo{n}); % Get inputs to this model that are not going into the tables pInpThis = setdiff(getinports(fillInfo{n}), pInp); if ~isempty(pInpThis) Data{n,3} = mbcListString( pveceval(pInpThis, @getname),' ' ); end else Data{n,3} = '-'; end end obj.hList.Data = Data; obj.hList.Icons = Icons; obj.hList.UserData = pInfo; if ~isempty(pT) obj.hList.SelectedRow = find( pT==pInfo(:, 1) ); set([obj.hMenuEditFill, obj.hMenuRemove],'Enable','on') else set([obj.hMenuEditFill, obj.hMenuRemove],'Enable','off') end end