www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtradeoffgui/@tableCentricUI/pMakeInputsMenu.m

    function pMakeInputsMenu(obj)
%PMAKEINPUTSMENU Create Inputs menu objects
%
%  PMAKEINPUTSMENU(OBJ) creates items below the Inputs menu.  If no Inputs
%  menu item has been set, no items are created.

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


if isempty(obj.InputsMenu)
    return
end

cmdStruct = obj.pGetCommands;
hInputs = obj.InputsMenu;

set(hInputs, 'Callback', {@i_updateinputsmenus, obj});
uimenu(hInputs, ...
    'Label', '&Reset to Last Saved Values', ...
    'Callback', {cmdStruct.ResetInputs, obj});
uimenu(hInputs, ...
    'Label', 'Set to &Table Value', ...
    'Callback', {cmdStruct.CopyInputsFromTable, obj});
find_menus(1) = uimenu(hInputs, ...
    'Label', 'Find Mi&nimum of Y vs X', ...
    'Callback', {cmdStruct.MinimizeInput, obj}, ...
    'Separator', 'on', ...
    'Enable', 'off');
find_menus(2) = uimenu(hInputs, ...
    'Label', 'Find Ma&ximum of Y vs X', ...
    'Callback', {cmdStruct.MaximizeInput, obj}, ...
    'Enable', 'off');
find_menus(3) = uimenu(hInputs, ...
    'Label', 'Find Turning &Point of Y vs X', ...
    'Callback', {cmdStruct.TurningOfInput, obj}, ...
    'Enable', 'off');
obj.InputFindMenus = find_menus;
uimenu(hInputs, ...
    'Interruptible', 'on', ...
    'Label', '&Automated Tradeoff', ...
    'Separator', 'on', ...
    'Callback', {cmdStruct.AutoTradeoff, obj});



function i_updateinputsmenus(src, evt, obj)
% Set the correct enable status/labels on the Inputs menu items.
hGraph = obj.GraphsView;
pIn = hGraph.SelectedInput;
pOut = hGraph.SelectedOutput;

if isnull(pIn) || isnull(pOut)
    set(obj.InputFindMenus, 'Enable', 'off', ...
        {'Label'}, {'Find Minimum of Y vs X'; ...
        'Find Maximum of Y vs X'; ...
        'Find Turning Point of Y vs X'});
else
    sIn = pIn.getname;
    sOut = pOut.getname;
    set(obj.InputFindMenus, 'Enable', 'on', ...
        {'Label'}, {sprintf('Find Minimum of %s vs %s', sOut, sIn); ...
        sprintf('Find Maximum of %s vs %s', sOut, sIn); ...
        sprintf('Find Turning Point of %s vs %s', sOut, sIn)});
end