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

    function cmdStruct = pGetCommands(obj, varargin)
%PGETCOMMANDS Create structure containing callback function handles
%
%  CMDSTRUCT = PGETCOMMANDS(OBJ) returns a structure containing all of the
%  callback function handles.  All of these callbacks take the object as
%  their only argument.
%
%  PGETCOMMANDS(OBJ, 'Command1', Func1, ...) allows the addition of extra
%  commands and associated function handles.

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


cmdStruct = struct( ...
    'ViewHistory', @i_viewhistory, ...
    'ConfigureHiddenItems', @i_edithiddenitems, ...
    'SaveInputs', @i_savevals, ...
    'ResetInputs', @i_resetvals, ...
    'CopyInputsFromTable', @i_tabletovals, ...
    'FillTables', @i_filltables, ...
    'ApplyFillAndSave', @i_fillandsave, ...
    'AutoTradeoff', @i_autotradeoff, ...
    varargin{:});



% Open the history viewer for the current table
function i_viewhistory(varargin)
obj = i_getobject(varargin{:});
pT = obj.MessageService.CurrentTable;
cghistorymanager('create',pT);


% Configure the hidden items for the current tradeoff
function i_edithiddenitems(varargin)
obj = i_getobject(varargin{:});
pTO = obj.MessageService.CurrentTradeoff;
[unused, haschanged] = guiHideExpressions(pTO.info);
if haschanged
    % Update the GUI
    obj.pStartLongAction;
    obj.MessageService.setTradeoff;
    obj.pEndLongAction;
end


% Save the current input settings
function i_savevals(varargin)
obj = i_getobject(varargin{:});
obj.MessageService.TradeoffServices.saveValues;


% Reset the inputs to last saved settings
function i_resetvals(varargin)
obj = i_getobject(varargin{:});
obj.pStartLongAction;
obj.MessageService.TradeoffServices.resetValue;
obj.pEndLongAction;


% Fill current cell in all tables in tradeoff
function i_filltables(varargin)
obj = i_getobject(varargin{:});
ms = obj.MessageService;
obj.pStartLongAction;
ms.TradeoffServices.applyTableFill;
obj.pEndLongAction;


% Perform table filling, save inputs and edit extrapolation mask
function i_fillandsave(varargin)
obj = i_getobject(varargin{:});
pT = i_getalltables(obj);
obj.pStartLongAction;
i_savevals(varargin{:});
i_filltables(varargin{:});
obj.pEndLongAction;


% Set inputs from current table cell
function i_tabletovals(varargin)
obj = i_getobject(varargin{:});
obj.pStartLongAction;
obj.MessageService.TradeoffServices.setValuesFromTable;
obj.pEndLongAction;


function i_autotradeoff(varargin)
obj = i_getobject(varargin{:});
obj.pStartLongAction;
pTO = obj.MessageService.CurrentTradeoff;
[unused, done] = autoTradeoff(pTO.info);
if done
    % Fire change events
    obj.MessageService.reset;
end
obj.pEndLongAction;


% Helper function that decodes the possible inputs and returns an object.
% reference
function obj = i_getobject(src, evt, obj)
if nargin==1
    obj = src;
elseif nargin~=3
    error('mbc:cgtradeoffgui:tradeoffBrowserDisplay:InvalidArgument', ...
        'Invalid calling syntax for callback function.');
end

% Helper function that gets all tables from tradeoff.
function pT = i_getalltables(obj)
pTO = obj.MessageService.CurrentTradeoff;
pT = pTO.getTable('all');