annotate aim-mat/tools/@parameter/set.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 20ada0af3d7d
children
rev   line source
tomwalters@0 1 % method of class @parameter
tomwalters@0 2 %
bleeck@3 3 % (c) 2011, University of Southampton
bleeck@3 4 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 5 % download of current version is on the soundsoftware site:
bleeck@3 6 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 7 % documentation and everything is on http://www.acousticscale.org
tomwalters@0 8 function param=set(param,text,newvalue,inbox)
tomwalters@0 9 %% sets the parameter value in the parameter "text" in the panel "inbox" to
tomwalters@0 10 %% the value "value".
tomwalters@0 11 % if its a float then the unit is assumed to be the one with wich the
tomwalters@0 12 % parameter was first defined
tomwalters@0 13
tomwalters@0 14 if nargin<4
tomwalters@0 15 inbox='all';
tomwalters@0 16 end
tomwalters@0 17
tomwalters@0 18 cont=param.entries;
tomwalters@0 19 nr=getentrynumberbytext(param,text,inbox);
tomwalters@0 20 if nr>0
tomwalters@0 21 type=cont{nr}.type;
tomwalters@0 22 if strcmp(type,'float') || strcmp(type,'slider')
tomwalters@0 23 unit=cont{nr}.orgunit;
tomwalters@0 24 param=setas(param,text,newvalue,unit,inbox); %call new with unit
tomwalters@0 25 return
tomwalters@0 26 else
tomwalters@0 27 param.entries{nr}.value=newvalue; % set the value in the class structure
tomwalters@0 28 end
tomwalters@0 29 if isfield(cont{nr},'handle') && ishandle(cont{nr}.handle{1}) % and set in the gui as well
tomwalters@0 30 hand=cont{nr}.handle{1};
tomwalters@0 31 if strcmp(type,'float') || strcmp(type,'string') || strcmp(type,'filename') || strcmp(type,'directoryname')
tomwalters@0 32 set(hand,'String',newvalue);
tomwalters@0 33 elseif strcmp(type,'int') % ints are capped
tomwalters@0 34 if isnumeric(newvalue)
tomwalters@0 35 intnewvalue=round(newvalue);
tomwalters@0 36 if length(intnewvalue)==1
tomwalters@0 37 set(hand,'String',intnewvalue);
tomwalters@0 38 else
tomwalters@0 39 set(hand,'String',num2str(intnewvalue));
tomwalters@0 40 end
tomwalters@0 41 param.entries{nr}.value=intnewvalue; % set the value in the class structure
tomwalters@0 42 else
tomwalters@0 43 set(hand,'String',newvalue);
tomwalters@0 44 end
tomwalters@0 45 else
tomwalters@0 46 if strcmp(type,'pop-up menu')
tomwalters@0 47 cont=param.entries{nr}.possible_values;
tomwalters@0 48 for i=1:length(cont)
tomwalters@0 49 if strcmp(cont{i},newvalue)
tomwalters@0 50 set(hand,'value',i);
tomwalters@0 51 end
tomwalters@0 52 end
tomwalters@0 53 else
tomwalters@0 54 set(hand,'value',newvalue); % could be bool
tomwalters@0 55 end
tomwalters@0 56 end
tomwalters@0 57 end
tomwalters@0 58 return
tomwalters@0 59 else
tomwalters@0 60 error('setvalue::error, the entry does not exist');
tomwalters@0 61 end