www.gusucode.com > mbctools 工具箱 matlab 源码程序 > mbctools/@mdevtestplan/private/DataCardFour.m
function lyt=DataCardFour(fH, iFace,LocalData) %DATACARDFOUR wizard pane for cluster settings % % lyt=DataCardFour(T, fH, iFace) % This function creates a layout that allows a user to change the % tolerances used to match the data to the design points as part of the % data selection wizard. % Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. % get up-to-date object if isa(fH, 'xregcontainer') lyt = fH; ud = get(lyt, 'UserData'); i_setValues(info(ud.pointer),ud); else [clusterlyt,ud] = i_createLyt(fH,LocalData); infoStr = 'Set up cluster algorithms to specify how data is matched to a design.'; lyt = xreglayerlayout( fH,... 'Elements', {mbcgui.container.InfoPane( 'Parent', fH,... 'Visible', 'off',... 'Title', 'Cluster settings',... 'InfoString', infoStr,... 'Center', clusterlyt )} ); % next and finish routines ud.finishFcn = @iCardFinish; end % data editor set(ud.DataEditor,'Value',ud.ModelData.OpenDataEditor) % last card feval(iFace.setFinishButton, 1); feval(iFace.setNextButton, 0); % set userdata in main layout set(lyt, 'UserData', ud); %-------------------------------------------------------------------------- function iCardFinish(ud, iFace) % finish wizard T= ud.pointer.info; % apply settings i_apply(T, ud); %-------------------------------------------------------------------------- function [lyt,ud] = i_createLyt(fH,ud) % main layout creation % otherwise we need to create the uicontrols for this panel. T= info(ud.pointer); if isExpData(T.DesignDev) % not matching to design so disable cluster options Enable= 'off'; else % matching design so enable cluster options Enable= 'on'; end % make a table to show the tolerances tableTitle = uicontrol('Parent',fH,... 'Style','text',... 'Visible', 'off', ... 'String','Input factor tolerances:',... 'Enable',Enable,... 'HorizontalAlignment','left'); factor_names= factorNames(model(T)); ud.Table = mbcwidgets.VariableEditorTable('parent', fH, ... 'Visible', 'off', ... 'enable',Enable,... 'ColumnWidth', 150, ... 'NameColumnHeader', 'Factor', ... 'ValueColumnHeader', 'Mean Tol.'); ud.Table.setVariables(factor_names, ones(size(factor_names)), repmat({0}, size(factor_names))); % make some controls to choose what to do with your clusters when they % appear SC = xregGui.SystemColorsDbl; choiceTitle = uicontrol('Parent',fH,... 'Style','text',... 'Enable',Enable,... 'Visible', 'off', ... 'String','Default data selection:',... 'HorizontalAlignment','left'); unmatchedChoice = uicontrol('Parent', fH,... 'Visible', 'off', ... 'BackgroundColor', SC.WINDOW_BG,... 'Enable',Enable,... 'Style', 'popupmenu',... 'String', {'Use', 'Do not use'}); unmatchedTxt = xregGui.labelcontrol('parent', fH, ... 'visible', 'off', ... 'enable',Enable,... 'String', 'Unmatched data:', ... 'LabelSize', 137, ... 'LabelSizeMode', 'absolute', ... 'ControlSize', 1, ... 'ControlSizeMode', 'relative', ... 'Control', unmatchedChoice); moreDataChoice = uicontrol('Parent', fH,... 'Visible', 'off', ... 'Enable',Enable,... 'BackgroundColor', SC.WINDOW_BG,... 'Style', 'popupmenu',... 'String', {'Use all data', 'Use closest match only'}); moreDataTxt = xregGui.labelcontrol('parent', fH, ... 'visible', 'off', ... 'enable',Enable,... 'String', 'Clusters with more data:', ... 'LabelSize', 137, ... 'LabelSizeMode', 'absolute', ... 'ControlSize', 1, ... 'ControlSizeMode', 'relative', ... 'Control', moreDataChoice); moreDesignChoice = uicontrol('Parent', fH,... 'Visible', 'off', ... 'Enable',Enable,... 'BackgroundColor', SC.WINDOW_BG,... 'Style', 'popupmenu',... 'String', {'Do not replace design points', 'Replace design with closest'}); moreDesignTxt = xregGui.labelcontrol('parent', fH, ... 'visible', 'off', ... 'enable',Enable,... 'String', 'Clusters with more design:', ... 'LabelSize', 137, ... 'LabelSizeMode', 'absolute', ... 'ControlSize', 1, ... 'ControlSizeMode', 'relative', ... 'Control', moreDesignChoice); choiceInfo = mbcgui.container.layoutpanel(... 'Parent', fH,... 'Visible', 'off', ... 'BorderType', 'etchedin', ... 'LayoutBorder', [10 10 10 10], ... 'Title', 'Data selection information'); mbcgui.container.addPanelEnable(choiceInfo, Enable); infoTxt = uicontrol('Parent',choiceInfo,... 'Style', 'text',... 'Enable',Enable,... 'String', '',... 'HorizontalAlignment', 'left'); set(choiceInfo, 'LayoutComponent', infoTxt); % get text to appear on callbacks set(unmatchedChoice, 'Callback', {@i_changeInfo, infoTxt, 1}); set(moreDataChoice, 'Callback', {@i_changeInfo, infoTxt, 2}); set(moreDesignChoice, 'Callback', {@i_changeInfo, infoTxt, 3}); ud.DataEditor= uicontrol('Parent', fH,... 'Visible', 'off', ... 'Style', 'checkbox',... 'HorizontalAlignment','right',... 'Value',1,... 'Callback',{@iDoOpenEditor,ud.ModelData},... 'String', 'Open Data Editor on completion'); lyt = xreggridbaglayout(fH, ... 'border',[7 0 7 10],... 'dimension', [10, 2], ... 'rowsizes', [15 5 20 5 20 5 20 15 -1 20], ... 'colsizes', [300 200], ... 'gapx', 40, ... 'mergeblock', {[9 10], [1 1]}, ... 'mergeblock', {[3 9], [2 2]}, ... 'elements', [{choiceTitle, [], unmatchedTxt, [], moreDataTxt, [], moreDesignTxt, [], choiceInfo []}, ... {tableTitle, [], ud.Table} cell(1,6) {ud.DataEditor}]); % save handles to choice controls ud.unmatchedChoice = unmatchedChoice; ud.moreDataChoice = moreDataChoice; ud.moreDesignChoice = moreDesignChoice; % set values for pane i_setValues(info(T),ud); %-------------------------------------------------------------------------- function i_changeInfo(src, evt, txtH, val) switch val case 1 %unmatched str = {'Unmatched data:',... '',... ['Choose whether or not to use data that is ',... 'not within tolerance of any design points']}; case 2 %more data str = {'Clusters with more data than design points:',... '',... ['Choose to use all data in the cluster or create a one-to-one ',... 'match of those data points closest to the design points and ',... 'use only these data.']}; case 3 %more design str = {'Clusters with more design than data points:',... '', ... ['All data in these clusters will be used. ',... 'Choose to write these data points into the actual ',... 'design, replacing those design points closest to the ',... 'data. Or choose to not write any points into the design.']}; end set(txtH,'String',str); %-------------------------------------------------------------------------- function i_setValues(T,ud) % get the tolerances from the TSSF tssf = T.DataLink.info; tol = get(tssf, 'tolerances'); ud.Table.VariableValues = num2cell(tol(:)); %-------------------------------------------------------------------------- function T = i_apply(T, ud) % Apply user choices to the TSSF clusters tssf = T.DataLink.info; % user choices % unmatchedVal 1=all 2=none % moreDataVal 1=all 2=closest % moreDesignVal 1=none 2=closest unmatchedVal = {'all', 'none'}; unmatchedVal = unmatchedVal{get(ud.unmatchedChoice,'Value')}; moreDataVal = {'all', 'closest'}; moreDataVal = moreDataVal{get(ud.moreDataChoice, 'Value')}; moreDesignVal = {'none', 'closest'}; moreDesignVal = moreDesignVal{get(ud.moreDesignChoice, 'Value')}; tssf = set(tssf,... {'defaultSelectionUnmatchedData',... 'defaultSelectionMoreData',... 'defaultSelectionMoreDesign',... 'defaultSelectionApply'},... {unmatchedVal,... moreDataVal,... moreDesignVal,... true}); % set user specified tolerances. This also runs the cluster alg on the tssf % and applies all the user-specified default settings newMnTol = abs([ud.Table.VariableValues{:}]); tssf = setTolerance(tssf, newMnTol); % get all of these changes back to the testplan T.DataLink.info = tssf; % update T on the heap xregpointer(T); %-------------------------------------------------------------------------- function iDoOpenEditor(h,~,ModelData) % update runtime pointer ModelData.OpenDataEditor = get(h,'Value');