www.gusucode.com > mbcdata 工具箱 matlab 源码程序 > mbcdata/@cgcalinput/createImportActions.m
function A = createImportActions(obj, PostImportCB) %CREATEIMPORTACTIONS Get action objects for importing. % % A = CREATEIMPORTACTIONS(OBJ, POSTIMPORTCB) returns an action object to % represent the available import actions. This may be either a single % action or an action group, depending on what import sources are % available. POSTIMPORTCB is a callback that will be executed after the % calibration data is imported. The calibration data structure will be % provided to the callback as event data. % Copyright 2005 The MathWorks, Inc. if nargin<2 PostImportCB = ''; end % Get the available options for import [fcns, names, fileFlags] = getinputfunctions(obj); NFile = sum(fileFlags); NNonFile = length(fileFlags)-NFile; if NNonFile==0 && NFile==0 A = []; elseif NNonFile==0 A = mbcmultiview.Action({@i_importcalfile, obj, PostImportCB}, ... 'Calibration...', 'Import calibration file'); else % Need a submenu group for the different sources Asub = []; if NFile>0 Asub = mbcmultiview.Action({@i_importcalfile, obj, PostImportCB}, ... 'File...', 'Import calibration file'); end for n = find(~fileFlags) Asub = [Asub, mbcmultiview.Action({@i_importother, fcns{n},obj, PostImportCB}, ... sprintf('%s...', names{n}), ... sprintf('Import from %s', names{n}))]; end A = mbcmultiview.ActionGroup; A.MenuType = 'submenu'; A.Actions = Asub; end function i_importcalfile(src, evt, obj, PostCB) [obj, s, ok] = guiImportFileType(obj); if ok evt.data = s; xregcallback(PostCB, obj, evt); end function i_importother(src, evt, fcn, obj, PostCB) obj.inputFcn = fcn; s = import(obj); if ~isempty(s) evt.data = s; xregcallback(PostCB, obj, evt); end