Mercurial > hg > ltpda
comparison m-toolbox/m/gui/gltpda/g_AnnotationUpdate.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 g_AnnotationUpdate(paramlist,varargin) | |
2 % Update the block annotation (the text below the block) with all the | |
3 % current parameters | |
4 | |
5 global selBlocks paramEnabled | |
6 | |
7 annotation = ''; | |
8 numparams = nparams(paramlist); | |
9 firstpar = 1; | |
10 | |
11 if strcmpi(get_param(gcbh,'Tag'),'arithmetic') | |
12 eq = get(findobj('Tag','equationField'),'String'); | |
13 if ~isempty(eq) | |
14 if numel(eq)>40, eq(1:end-25) = []; eq = ['...',eq]; end | |
15 for nn=1:length(selBlocks) | |
16 set_param(selBlocks(nn),'AttributesFormatString',eq); | |
17 end | |
18 end | |
19 return | |
20 end | |
21 | |
22 for kk=1:numparams | |
23 if paramEnabled(kk) | |
24 paramkey = paramlist.params(kk).key; | |
25 try %#ok<ALIGN> | |
26 if strcmpi(paramkey(1:7),'addPar_'), paramkey(1:7)=[]; end | |
27 catch, end | |
28 paramval = paramlist.params(kk).val; | |
29 switch class(paramval) | |
30 case 'specwin' | |
31 windowName = paramval.type; | |
32 windowlength = size(paramval.win,2); | |
33 if firstpar==1 % it's the first parameter | |
34 annotation = ['(specwin) ',windowName,',',num2str(windowlength)]; | |
35 firstpar=2; | |
36 else % it's not the first parameter | |
37 annotation = [annotation,'\n','(specwin) ',windowName,',',num2str(windowlength)]; | |
38 end | |
39 if strcmp(windowName,'Kaiser') | |
40 windowPsll = paramval.psll; | |
41 annotation = [annotation,',',num2str(windowPsll)]; | |
42 end | |
43 case 'double' | |
44 paramval = mat2str(paramval); | |
45 if numel(paramval)>25, paramval=['...',paramval(end-25:end)]; end | |
46 if firstpar==1, annotation=[lower(paramkey),' ',paramval]; firstpar=2; | |
47 else annotation = [annotation,'\n',lower(paramkey),' ',num2str(paramval)]; | |
48 end | |
49 case 'char' | |
50 if numel(paramval)>25, paramval=['...',paramval(end-25:end)]; end | |
51 paramval = strrep(paramval,'''''',''''); | |
52 if firstpar==1, annotation=[lower(paramkey),' ',paramval]; firstpar=2; | |
53 else annotation = [annotation,'\n',lower(paramkey),' ',paramval]; | |
54 end | |
55 case 'logical' | |
56 if paramval, paramval = 'true'; else paramval = 'false'; end | |
57 if firstpar==1, annotation=[lower(paramkey),' ',paramval]; firstpar=2; | |
58 else annotation = [annotation,'\n',lower(paramkey),' ',paramval]; | |
59 end | |
60 case 'pzmodel' | |
61 if firstpar==1, annotation='(pzmodel)'; firstpar=2; | |
62 else annotation = [annotation,'\n','(pzmodel)']; | |
63 end | |
64 case 'cell' | |
65 if isa(paramval{1},'char') && strcmp(paramval{1},'(-->)'), strParKey = '(-->)'; | |
66 else strParKey = utils.prog.cell2str(paramval); | |
67 end | |
68 if firstpar==1 | |
69 annotation = [lower(paramkey),' ',strParKey]; firstpar=2; | |
70 else annotation = [annotation,'\n',lower(paramkey),' ',strParKey]; | |
71 end | |
72 case 'pz' | |
73 for mm=1:numel(paramval) | |
74 poleFreqs(mm,1) = paramval(mm).f; | |
75 poleQs(mm,1) = paramval(mm).q; | |
76 if ~isnan(poleQs(mm,1)) | |
77 poleFQs{mm,1}=strcat(num2str(poleFreqs(mm,1)),',',num2str(poleQs(mm,1))); | |
78 else | |
79 poleFQs{mm,1}=num2str(poleFreqs(mm,1)); | |
80 end | |
81 end | |
82 poleFQs=char(poleFQs); | |
83 if firstpar==1 | |
84 annotation = ['pz ',poleFQs(1,:)]; firstpar=2; | |
85 for j=2:size(poleFQs,1), annotation = [annotation,'\n','(pz) ',poleFQs(j,:)]; end | |
86 else | |
87 annotation = [annotation,'\n','pole ',poleFQs(1,:)]; | |
88 for j=2:size(poleFQs,1), annotation = [annotation,'\n','(pz) ',poleFQs(j,:)]; end | |
89 end | |
90 end | |
91 end | |
92 end | |
93 % Finally set the block annotation: | |
94 for nn=1:length(selBlocks), set_param(selBlocks(nn),'AttributesFormatString',annotation); end | |
95 end |