www.gusucode.com > mbcmodels 工具箱 matlab 源码程序 > mbcmodels/@xregmodswitch/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 % Display model origination info, plus model description INFO = getinfo(mdl); projfile = 'Unknown'; mdlpath = 'Unknown'; loadEn = 'off'; if ~isempty(INFO); if isfield(INFO, 'Parent') && exist(INFO.Parent, 'file') [~,f,~]= fileparts(INFO.Parent); projfile = f; loadEn = 'on'; end if isfield(INFO, 'path') mdlpath = INFO.path; end end hFile = i_maketextcontrol(hParent, 'Model project file:', projfile, 90); hModelPath = i_maketextcontrol(hParent, 'Model path:', mdlpath, 90); hModelLoad = uicontrol('Parent', hParent, ... 'Style', 'pushbutton', ... 'Enable', loadEn, ... 'String', 'Load Model', ... 'Callback', {@i_loadmodel, hGroup}); sOp = mdl.symbols(mdl.getSwitchFactors); sLocal = mdl.symbols(1:mdl.NumLocalInputs); hOther = i_maketextcontrol(hParent, 'Inputs:', mbcListString(sLocal), 60); hTableTitle = uicontrol('Parent',hParent, ... 'Style','text',... 'HorizontalAlignment','left',... 'String','Operating points:'); % table to display operating points T = mbcwidgets.List('Parent',hParent, ... 'SelectionMode', 'MultiRegion'); d = str_func(mdl.ModelList); T.Peer.setColumnData([sOp(:);{'Model'}]); T.Peer.setColumnWidths([repmat(80,1,length(sOp)),150]); T.Peer.setData([num2cell(mdl.OpPoints) d(:)]); hGrid = xreggridbaglayout(hParent, ... 'dimension', [8 2], ... 'rowsizes', [25 10 15 10 15 5,15,-1], ... 'colsizes', [-1 75], ... 'mergeblock', {[5 5], [1 2]}, ... 'mergeblock', {[6 6], [1 2]}, ... 'mergeblock', {[7 7], [1 2]}, ... 'mergeblock', {[8 8], [1 2]}, ... 'elements', {hFile, [], hModelPath, [], hOther,[],hTableTitle,T,... hModelLoad,[],[],[],[],[],[],[]}); 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)); function i_loadmodel(~, ~, hGroup) m = get(hGroup.getObject, 'model'); minfo = getinfo( m ); if ~isfield(minfo, 'Parent') || exist( minfo.Parent, 'file')~=2 % Can't find project return else projfile = minfo.Parent; h = MBrowser; if h.GUIExists h = MBrowser; figure(h.Figure); drawnow; % is this file the current project if strcmp(projfile, projectfile(h.RootNode.info)) % Project is already loaded OK = 1; else % Load project into Model Browser OK = h.OpenProject( projfile ); end else % Start Model Browser and open project mbcmodel( projfile ); OK = 1; h = MBrowser; end % We loaded the project ok - now find this model in the tree if OK && isfield(minfo, 'path') p = findnode(h.RootNode.info, minfo.path); if p~=0 if p~= h.CurrentNode % Select the node h.SelectNode(p); end end end end