Mercurial > hg > ltpda
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m-toolbox/m/gui/gltpda/g_AnnotationUpdate.m Wed Nov 23 19:22:13 2011 +0100 @@ -0,0 +1,95 @@ +function g_AnnotationUpdate(paramlist,varargin) + % Update the block annotation (the text below the block) with all the + % current parameters + + global selBlocks paramEnabled + + annotation = ''; + numparams = nparams(paramlist); + firstpar = 1; + + if strcmpi(get_param(gcbh,'Tag'),'arithmetic') + eq = get(findobj('Tag','equationField'),'String'); + if ~isempty(eq) + if numel(eq)>40, eq(1:end-25) = []; eq = ['...',eq]; end + for nn=1:length(selBlocks) + set_param(selBlocks(nn),'AttributesFormatString',eq); + end + end + return + end + + for kk=1:numparams + if paramEnabled(kk) + paramkey = paramlist.params(kk).key; + try %#ok<ALIGN> + if strcmpi(paramkey(1:7),'addPar_'), paramkey(1:7)=[]; end + catch, end + paramval = paramlist.params(kk).val; + switch class(paramval) + case 'specwin' + windowName = paramval.type; + windowlength = size(paramval.win,2); + if firstpar==1 % it's the first parameter + annotation = ['(specwin) ',windowName,',',num2str(windowlength)]; + firstpar=2; + else % it's not the first parameter + annotation = [annotation,'\n','(specwin) ',windowName,',',num2str(windowlength)]; + end + if strcmp(windowName,'Kaiser') + windowPsll = paramval.psll; + annotation = [annotation,',',num2str(windowPsll)]; + end + case 'double' + paramval = mat2str(paramval); + if numel(paramval)>25, paramval=['...',paramval(end-25:end)]; end + if firstpar==1, annotation=[lower(paramkey),' ',paramval]; firstpar=2; + else annotation = [annotation,'\n',lower(paramkey),' ',num2str(paramval)]; + end + case 'char' + if numel(paramval)>25, paramval=['...',paramval(end-25:end)]; end + paramval = strrep(paramval,'''''',''''); + if firstpar==1, annotation=[lower(paramkey),' ',paramval]; firstpar=2; + else annotation = [annotation,'\n',lower(paramkey),' ',paramval]; + end + case 'logical' + if paramval, paramval = 'true'; else paramval = 'false'; end + if firstpar==1, annotation=[lower(paramkey),' ',paramval]; firstpar=2; + else annotation = [annotation,'\n',lower(paramkey),' ',paramval]; + end + case 'pzmodel' + if firstpar==1, annotation='(pzmodel)'; firstpar=2; + else annotation = [annotation,'\n','(pzmodel)']; + end + case 'cell' + if isa(paramval{1},'char') && strcmp(paramval{1},'(-->)'), strParKey = '(-->)'; + else strParKey = utils.prog.cell2str(paramval); + end + if firstpar==1 + annotation = [lower(paramkey),' ',strParKey]; firstpar=2; + else annotation = [annotation,'\n',lower(paramkey),' ',strParKey]; + end + case 'pz' + for mm=1:numel(paramval) + poleFreqs(mm,1) = paramval(mm).f; + poleQs(mm,1) = paramval(mm).q; + if ~isnan(poleQs(mm,1)) + poleFQs{mm,1}=strcat(num2str(poleFreqs(mm,1)),',',num2str(poleQs(mm,1))); + else + poleFQs{mm,1}=num2str(poleFreqs(mm,1)); + end + end + poleFQs=char(poleFQs); + if firstpar==1 + annotation = ['pz ',poleFQs(1,:)]; firstpar=2; + for j=2:size(poleFQs,1), annotation = [annotation,'\n','(pz) ',poleFQs(j,:)]; end + else + annotation = [annotation,'\n','pole ',poleFQs(1,:)]; + for j=2:size(poleFQs,1), annotation = [annotation,'\n','(pz) ',poleFQs(j,:)]; end + end + end + end + end + % Finally set the block annotation: + for nn=1:length(selBlocks), set_param(selBlocks(nn),'AttributesFormatString',annotation); end +end