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

    function [optim, OK] = guiParameterEditor(optim)
%GUIPARAMETEREDITOR Display a dialog for editing optimization parameters
%
%  [OBJ, OK] = GUIPARAMETEREDITOR(OBJ) displays a dialog that allows the
%  user to edit the parameters for the optimization.

%  Copyright 2005-2010 The MathWorks, Inc. and Ford Global Technologies, Inc.


om = getParameters(optim);
hFig = xregdialog('Name', 'Optimization Parameters');
xregcenterfigure(hFig, [500 500]);
    
pParam = xregGui.RunTimePointer(om);
L = gui_setup(om, 'layout', {}, hFig, pParam, xregoptmgr);

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'));

% Check whether to allow user to change the run interface version
v = getScriptRunAPIMode(optim);
availmodes = [0 3 2];
if v==-1
    apimode = getRunAPIMode(optim);
    en = 'on';
else
    apimode = v;
    en = 'off';
end
ifaceidx = find(apimode==availmodes);

SC = xregGui.SystemColorsDbl;
hRunVer = uicontrol('Parent', hFig, ...
    'Style', 'popupmenu', ...
    'BackgroundColor', SC.WINDOW_BG, ...
    'String', {'Most recent version', 'MBC version 3', 'MBC version 2'}, ...
    'Value', ifaceidx);
hRunVerLabel = xregGui.labelcontrol('Parent', hFig, ...
    'string', 'Interface version to use when running optimization:', ...
    'ControlSizeMode', 'absolute', ...
    'ControlSize', 120, ...
    'LabelSizeMode', 'absolute', ...
    'LabelSize', 260, ...
    'Control', hRunVer, ...
    'Enable', en);

L = xreggridbaglayout(hFig, ...
    'packstatus', 'off', ...
    'dimension', [3 5], ...
    'rowsizes', [-1 20 25], ...
    'colsizes', [0 -1 65 65 0], ...
    'gap', 7, ...
    'border', [0 7 0 0], ...
    'mergeblock', {[1 1], [1 5]}, ...
    'mergeblock', {[2 2], [2 4]}, ...
    'elements', {L, [], [], [], hRunVerLabel, [], [], [], hOK, [], [], hCancel});

hFig.LayoutManager = L;
set(L, 'packstatus', 'on');

hFig.showDialog(hOK);

OK = strcmpi(get(hFig, 'Tag'), 'ok');
if OK
    optim = setParameters(optim, pParam.info);
    
    ifaceidx = get(hRunVer, 'Value');
    ifaceenabled = get(hRunVer, 'Enable');
    if strcmp(ifaceenabled, 'on')
        % Only set the optim mode flag if the current display came from
        % there, and not the script setup.
        optim = setRunAPIMode(optim, availmodes(ifaceidx));
    end
end
hFig.delete;