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

    function [obj, OK] = guiEditConstraintTol(obj)
%GUIEDITCONSTRAINTTOL Display a dialog for editing the constraint tolerance.
%
%   [OBJ, OK] = GUIEDITCONSTRAINTTOL(OBJ) displays a small dialog with a
%   field for editing the constraint tolerance used in the output views.

%   Copyright 2006-2015 The MathWorks, Inc.

hFig = xregdialog('Name', 'Constraint Tolerance', ...
    'Tag', 'OptimOutputConstraintTolerance');
xregcenterfigure(hFig, [350 135]);

infoStr = ['The constraint tolerance value set here is used to highlight ', ...
    'infeasible constraint values in the display.  Constraint values that ', ...
    'are greater than this value are shown with a yellow background.'];
hInfo = mbcgui.container.InfoPane('Parent', hFig, ...
    'InfoHeight', 45, ...
    'InfoString', infoStr);

Val = getConstraintTol(obj);
hEdit = mbcgui.widget.Spinner('Parent', hFig, ...
    'Min', 0, ...
    'ClickIncrementMode', 'auto', ...
    'Value', Val);
hLabel = xregGui.labelcontrol('Parent', hFig, ...
    'LabelSizeMode', 'absolute', ...
    'LabelSize', 150, ...
    'ControlSize', 80, ...
    'String', 'Constraint highlight tolerance:', ...
    'Control', hEdit);

% OK/Cancel dialog controls
hOK = uicontrol('Parent', hFig, ...
    'String', 'OK', ...
    'Style', 'pushbutton', ...
    'Callback', @(src, evt) set(hFig, 'Tag', 'ok', 'Visible', 'off'));
hCancel = uicontrol('Parent', hFig, ...
    'String', 'Cancel', ...
    'Style', 'pushbutton', ...
    'Callback', @(src, evt) set(hFig, 'Visible', 'off'));

lyt = xreggridbaglayout(hFig, ...
    'Dimension', [4, 5], ...
    'Rowsizes', [60 20 -1 25], ...
    'Colsizes', [0 -1 65 65 0], ...
    'Gapx', 7, ...
    'Gapy', 10, ...
    'Border', [0 7 0 0], ...
    'Mergeblock', {[1 1], [1 5]}, ...
    'Mergeblock', {[2 2], [2 4]}, ...
    'Elements', {hInfo, [], [], [], ...
    [], hLabel, [], [], ...
    [], [], [], hOK, ...
    [], [], [], hCancel});
hFig.LayoutManager = lyt;
set(lyt, 'packstatus', 'on');

hFig.showDialog(hOK);


tg = get(hFig, 'Tag');
OK = strcmp(tg, 'ok');
if OK
    obj = setConstraintTol(obj, hEdit.Value);
end
delete(hFig);