www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgtradeoffgui/@setupUI/pGetCommands.m
function cmdStruct = pGetCommands(obj) %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. % Copyright 2000-2011 The MathWorks, Inc. and Ford Global Technologies, Inc. cmdStruct = struct( ... 'AddExistingTable', @i_addexisttable, ... 'AddNewTable', @i_addnewtable, ... 'RemoveTable', @i_removetable, ... 'EditTableFill', @i_editfill ... ); function i_editfill(varargin) obj = i_getobject(varargin{:}); pTO = obj.Tradeoff; pT = obj.TableSetup.SelectedTable; if ~isempty(pT) && ~isempty(pTO) obj.pStartLongAction; [to, ok] = guiSetFillExpression(pTO.info, pT); if ok obj.TableSetup.refresh; obj.ModelSetup.refresh; end obj.pEndLongAction; end function i_addnewtable(varargin) obj = i_getobject(varargin{:}); pTO = obj.Tradeoff; if ~isempty(pTO) obj.pStartLongAction; [to, ok] = guiAddNewTable(pTO.info); if ok obj.TableSetup.refresh; obj.ModelSetup.refresh; i_refreshstatus(obj); end obj.pEndLongAction; end function i_addexisttable(varargin) obj = i_getobject(varargin{:}); pTO = obj.Tradeoff; if ~isempty(pTO) obj.pStartLongAction; [to, ok] = guiAddTable(pTO.info); if ok obj.TableSetup.refresh; obj.ModelSetup.refresh; i_refreshstatus(obj); end obj.pEndLongAction; end function i_removetable(varargin) obj = i_getobject(varargin{:}); pTO = obj.Tradeoff; pT = obj.TableSetup.SelectedTable; if ~isempty(pT) && ~isempty(pTO) obj.pStartLongAction; % Pop up a dialog to make sure the user really wants to do this resp = questdlg(sprintf('Do you want to remove table "%s" from this tradeoff?', pT.getname),... 'Confirm Removal','Yes','No','Yes'); if strcmp(resp, 'Yes') removeTable(pTO.info, pT); obj.TableSetup.refresh; obj.ModelSetup.refresh; i_refreshstatus(obj); end obj.pEndLongAction; end % Helper function that updates menus, toolbars and tree function i_refreshstatus(obj) obj.Browser.doDrawTree(obj.Browser.CurrentNode,'refresh'); % Reset the enable status of tradeoff menu items menus = [obj.hChangeFillMenu; ... obj.hRemoveTableMenu]; buttons = [obj.hChangeFillButton; ... obj.hRemoveTableButton]; if obj.Tradeoff.numTables>0 set(menus, 'Enable', 'on'); set(buttons, 'Enable', 'on'); else set(menus, 'Enable', 'off'); set(buttons, 'Enable', 'off'); end % 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(message('mbc:cgtradeoffgui:setupUI:InvalidArgument')); end