www.gusucode.com > mbcexpr 工具箱 matlab 源码程序 > mbcexpr/cgeditnomvalues.m
function changed = cgeditnomvalues(pValues) %CGEDITNOMVALUES Pop up a dialog for editing the nominal values of variables % % CHANGED = CGEDITNOMVALUES(PVALUES) opens a small dialog that allows the % user to edit the nominal values of the variables in PVALUES. CHANGED is % a logical vector the same length as PVALUES that indicates which of the % variables' values have been altered. % Copyright 2000-2010 The MathWorks, Inc. and Ford Global Technologies, Inc. hFig = xregdialog('Name', 'Edit Set Points'); xregcenterfigure(hFig, [350 300]); txt = uicontrol('Parent', hFig, ... 'Style', 'text', ... 'HorizontalAlignment', 'left', ... 'Enable', 'inactive', ... 'String', ['Warning: changing a value here will update the set point', ... ' of the variable everywhere in CAGE. This could alter the result of some', ... ' calculations and may change the appearance of any displays that depend on', ... ' the variable.']); pChanges = xregGui.RunTimePointer(false(size(pValues))); t = mbcwidgets.VariableEditorTable('parent', hFig, ... 'ValueChangedCallback', {@i_EditTable,pChanges}); cginitinputs(t, null(xregpointer, 0), pValues); hOK = uicontrol('Parent', hFig, ... 'Style', 'pushbutton', ... 'String', 'OK', ... 'Callback', 'set(gcbf, ''tag'', ''ok'', ''visible'', ''off'');'); hCanc = uicontrol('Parent', hFig, ... 'Style', 'pushbutton', ... 'String', 'Cancel', ... 'Callback', 'set(gcbf, ''visible'', ''off'');'); hHelp = cghelpbutton(hFig, 'CGSETNOMINALVALUES'); lyt = xreggridbaglayout(hFig, ... 'packstatus', 'off', ... 'dimension', [5, 4], ... 'rowsizes', [60 2 -1 7 25], ... 'colsizes', [-1 65 65 65], ... 'border', [7 7 7 7], ... 'gapx', 7, ... 'mergeblock', {[1 1], [1 4]}, ... 'mergeblock', {[3 3], [1 4]}, ... 'elements', {txt, [], t, [], [], ... [], [], [], [], hOK, ... [], [], [], [], hCanc, ... [], [], [], [], hHelp}); hFig.LayoutManager = lyt; set(lyt, 'packstatus', 'on'); hFig.showDialog(hOK); tg = get(hFig, 'Tag'); if strcmp(tg, 'ok') changed = pChanges.info; for n = 1:length(pValues) if changed(n) V = t.getNumericValues(n); pValues(n).info = pValues(n).setnomvalue(V{1}(1)); end end else changed = false(size(pValues)); end function i_EditTable(src, evt, pChanges) pChanges.info(evt.data.Rows) = true;