Mercurial > hg > ltpda
diff m-toolbox/m/gui/gltpda/g_RetrievePlist.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/m/gui/gltpda/g_RetrievePlist.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,70 @@ +function paramcommand = g_RetrievePlist(varargin) + % Retrieve the name of the function from the block, then asks for + % parameters. + + global params paramEnabled paramSets + + try functionname = varargin{1}; + catch + childpath = find_system(gcbh,'LookUnderMasks','all','BlockType','M-S-Function'); + functionname = get_param(childpath,'Tag'); + end + + if isempty(functionname) + description = get_param(gcbh,'Description'); + funcname = findstr('functionName=',description); + if funcname + i = funcname+14; + while ~strcmp(description(i),';'), i=i+1; end + functionname = description(funcname+14:i-2); + end + end + + if isempty(functionname) + functionname = g_setmethod(); + end + + setappdata(0,'ltpda_currFunctionName',functionname); + + try + switch functionname + case 'generic' + paramcommand = 'functionName=''generic'';params=plist();paramEnabled=[];'; + return + case 'arithmetic' + paramcommand = 'functionName=''arithmetic'';params=plist(''alpha'',''-->'',''beta'',''-->'');'; + return + otherwise + [func,currClass] = strtok(get(gcbh,'Tag')); + currClass(1)=[]; + infoObj = eval([currClass,'.getInfo(''',functionname,''')']); + + if numel(infoObj.sets) > 1 + paramSets = plist('sets',infoObj.sets,'currSet',1); + paramcommand = ['paramSets=',string(paramSets),';','params=plist();']; + elseif numel(infoObj.sets) == 1 && nparams(infoObj.plists) + paramEnabled = zeros(1,nparams(infoObj.plists)); + paramcommand = ['params=',string(infoObj.plists),'; paramEnabled=',mat2str(paramEnabled),';']; + else + paramcommand = 'params=plist();'; + end + + end + catch ME + disp(sprintf('Error: unable to retrieve the parameters required by the function "%s". Maybe it''s not supported yet?',functionname)); + ErrorFuncNotSupported(); + rethrow(ME) + end + + + + %---------------------------------------------------------------------- + function ErrorFuncNotSupported(varargin) + % Recalled whenever the parameters call fails + + % Text: '[...] Maybe it''s not supported yet?' + uicontrol('Parent',currPanel,'BackgroundColor',backColor,'Units','pixels','HorizontalAlignment','center','Position',[(panelDimens(4)-300)/2 panelDimens(4)-100-100 300 30],'String','Error: unable to retrieve the parameters required by this function. Maybe it''s not supported yet?','Visible','on','Style','text'); + end + %---------------------------------------------------------------------- + +end \ No newline at end of file