www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgCompositeModel/propPageModel.m

    function hGrid = propPageModel(mdl, hGroup,hParent) 
%PROPPAGEMODEL property page for model
%    hGrid = propPageModel(mdl, hGroup,hParent)

%  Copyright 2009-2015 The MathWorks, Inc. and Ford Global Technologies, Inc.

if nargin<3
    hParent = hGroup.Parent;
end
if isempty(mdl.ModeLabels)
    NumModes=max(mdl.OpPoints(:,end));
    mdl.ModeLabels = cell(1,NumModes);
    for i=1:NumModes
        mdl.ModeLabels{i} = sprintf('Mode %d',i);
    end
else
    NumModes = length(mdl.ModeLabels);
end

hModelName = i_maketextcontrol(hParent, 'Response name:', getname(mdl), 100);
hModeName = i_maketextcontrol(hParent, 'Mode input:', mdl.symbols{end}, 100);

Labels = {'Mode', 'Name','Inputs'};
if size(mdl.OpPoints,2)==1
    Data = cell(NumModes,3);
    Labels{end+1}= 'Model';
    Widths = [40 80 110 110];
else
    Widths = [40 80 220];
    Data = cell(NumModes,2);
end

ModeInputs = mbcListString(mdl.symbols(1:mdl.NumLocalInputs));
for i=1:NumModes
    
    f= find(mdl.OpPoints(:,end)==i,1,'first');
    if ~isempty(f) && ~isempty(mdl.ActiveFactors)
        ModeInputs = mbcListString(mdl.symbols(mdl.ActiveFactors{f}));
    end
    Data{i,1} = i;
    Data{i,2} = mdl.ModeLabels{i};
    Data{i,3} = ModeInputs;
    if size(mdl.OpPoints,2)==1
        % add model list
        Data{i,4} = str_func(mdl.ModelList.Models{i});
    end
end

T = mbcwidgets.List('Parent',hParent, ...
    'SelectionMode', 'MultiRegion');
T.Peer.setColumnData(Labels);
T.Peer.setColumnWidths(Widths);
T.Peer.setData(Data);

hModeTitle = uicontrol('Parent',hParent, ...
    'Style','text',...
    'HorizontalAlignment','left',...
    'String','Modes:');
hModeGrid = xreggridbaglayout(hParent, ...
    'dimension', [5 1], ...
    'rowsizes', [15 15 5 15 -1], ...
    'elements', {hModelName,hModeName,[],hModeTitle T});

if size(mdl.OpPoints,2)>1
   % make a table of operating points
   DS = OpPointDataset(mdl);
   % table to display operating points
   T = mbcwidgets.List('Parent',hParent, ...
       'SelectionMode', 'MultiRegion');
   
   hTableTitle = uicontrol('Parent',hParent, ...
       'Style','text',...
       'HorizontalAlignment','left',...
       'String','Operating points:');
   Data = num2cell(DS.data(:,mdl.NumLocalInputs+1:mdl.NumInputs));
   ModeMap = DS.data(:,mdl.NumInputs+1:end);
   for i=1:size(DS.data,1)
       % list of modes for each operating point
       s= sprintf('%d,',find(ModeMap(i,:)));
       Data{i,end} = s(1:end-1);
   end
   T.Peer.setColumnData(DS.names(mdl.NumLocalInputs+1:mdl.NumInputs));
   T.Peer.setColumnWidths(repmat(80,1,length(DS.names)));
   T.Peer.setData(Data);
   
   hGrid = xreggridbaglayout(hParent, ...
       'dimension', [4 1], ...
       'rowsizes', [35+(NumModes+1)*25,5,15,-1], ...
       'elements', {hModeGrid,[],hTableTitle,T});
else
   hGrid = hModeGrid; 
end


function h = i_maketextcontrol(hParent, Label, Text, LabelSize)
h = xregGui.labelcontrol('parent', hParent, ...
    'LabelSizeMode', 'absolute', ...
    'LabelSize', LabelSize, ...
    'ControlSizeMode', 'relative', ...
    'ControlSize', 1, ...
    'String', Label, ...
    'Control', mbcgui.widget.Label('Parent', hParent, ...
    'HorizontalAlignment', 'left', ...
    'String', Text));