comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:f0afece42f48
1 function paramcommand = g_RetrievePlist(varargin)
2 % Retrieve the name of the function from the block, then asks for
3 % parameters.
4
5 global params paramEnabled paramSets
6
7 try functionname = varargin{1};
8 catch
9 childpath = find_system(gcbh,'LookUnderMasks','all','BlockType','M-S-Function');
10 functionname = get_param(childpath,'Tag');
11 end
12
13 if isempty(functionname)
14 description = get_param(gcbh,'Description');
15 funcname = findstr('functionName=',description);
16 if funcname
17 i = funcname+14;
18 while ~strcmp(description(i),';'), i=i+1; end
19 functionname = description(funcname+14:i-2);
20 end
21 end
22
23 if isempty(functionname)
24 functionname = g_setmethod();
25 end
26
27 setappdata(0,'ltpda_currFunctionName',functionname);
28
29 try
30 switch functionname
31 case 'generic'
32 paramcommand = 'functionName=''generic'';params=plist();paramEnabled=[];';
33 return
34 case 'arithmetic'
35 paramcommand = 'functionName=''arithmetic'';params=plist(''alpha'',''-->'',''beta'',''-->'');';
36 return
37 otherwise
38 [func,currClass] = strtok(get(gcbh,'Tag'));
39 currClass(1)=[];
40 infoObj = eval([currClass,'.getInfo(''',functionname,''')']);
41
42 if numel(infoObj.sets) > 1
43 paramSets = plist('sets',infoObj.sets,'currSet',1);
44 paramcommand = ['paramSets=',string(paramSets),';','params=plist();'];
45 elseif numel(infoObj.sets) == 1 && nparams(infoObj.plists)
46 paramEnabled = zeros(1,nparams(infoObj.plists));
47 paramcommand = ['params=',string(infoObj.plists),'; paramEnabled=',mat2str(paramEnabled),';'];
48 else
49 paramcommand = 'params=plist();';
50 end
51
52 end
53 catch ME
54 disp(sprintf('Error: unable to retrieve the parameters required by the function "%s". Maybe it''s not supported yet?',functionname));
55 ErrorFuncNotSupported();
56 rethrow(ME)
57 end
58
59
60
61 %----------------------------------------------------------------------
62 function ErrorFuncNotSupported(varargin)
63 % Recalled whenever the parameters call fails
64
65 % Text: '[...] Maybe it''s not supported yet?'
66 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');
67 end
68 %----------------------------------------------------------------------
69
70 end