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=setas(param,text,value,unit,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 % param must be of type float or slider
|
tomwalters@0
|
12
|
tomwalters@0
|
13 if nargin<5
|
tomwalters@0
|
14 inbox='all';
|
tomwalters@0
|
15 end
|
tomwalters@0
|
16
|
tomwalters@0
|
17 % cont=param.entries;
|
tomwalters@0
|
18 nr=getentrynumberbytext(param,text,inbox);
|
tomwalters@0
|
19 if nr>0
|
tomwalters@0
|
20 if isequal(value,'auto');
|
tomwalters@0
|
21 param.entries{nr}.rawvalue=value;
|
tomwalters@0
|
22 param.entries{nr}.stringvalue=value; % set the string value
|
tomwalters@0
|
23 else
|
tomwalters@0
|
24 if ~ischar(value)
|
tomwalters@0
|
25 unittype=param.entries{nr}.unittype;
|
tomwalters@0
|
26 if ~isa(unittype,'unit_none')
|
tomwalters@0
|
27 rawval=fromunits(unittype,value,unit);
|
tomwalters@0
|
28 else
|
tomwalters@0
|
29 rawval=value;
|
tomwalters@0
|
30 end
|
tomwalters@0
|
31 param.entries{nr}.rawvalue=rawval; % set the value in the class structure with the raw value
|
tomwalters@0
|
32 param.entries{nr}.stringvalue=num2str(rawval); % set the string value
|
tomwalters@0
|
33 else
|
tomwalters@0
|
34 param.entries{nr}.stringvalue=value; % set the string value
|
tomwalters@0
|
35 param.entries{nr}.rawvalue=str2num(value);
|
tomwalters@0
|
36 end
|
tomwalters@0
|
37 end
|
tomwalters@0
|
38 if isfield(param.entries{nr},'handle') && ishandle(param.entries{nr}.handle{1}) % and set in the gui as well
|
tomwalters@0
|
39 if strcmp(param.entries{nr}.type,'float')
|
tomwalters@0
|
40 hand=param.entries{nr}.handle{1};
|
tomwalters@0
|
41 if isequal(value,'auto');
|
tomwalters@0
|
42 set(hand,'String',value); % set the string as given
|
tomwalters@0
|
43 else
|
tomwalters@0
|
44 if ~ischar(value)
|
tomwalters@0
|
45 if length(value)==1
|
tomwalters@0
|
46 set(hand,'String',num2str(value)); % translate to string
|
tomwalters@0
|
47 else
|
tomwalters@0
|
48 set(hand,'String',param.entries{nr}.stringvalue); % set the string as given
|
tomwalters@0
|
49 end
|
tomwalters@0
|
50 if ~isa(unittype,'unit_none')
|
tomwalters@0
|
51 unitnr=findunit(unittype,unit);
|
tomwalters@0
|
52 set(param.entries{nr}.handle{2},'value',unitnr); % set the unit to the given one
|
tomwalters@0
|
53 end
|
tomwalters@0
|
54 else % its a string format
|
tomwalters@0
|
55 set(hand,'String',value); % set the string as given
|
tomwalters@0
|
56 end
|
tomwalters@0
|
57 end
|
tomwalters@0
|
58 else % it must be a slider
|
tomwalters@0
|
59 secombi=param.entries{nr}.slidereditcombi;
|
tomwalters@0
|
60 if ~isa(unittype,'unit_none')
|
tomwalters@0
|
61 unitnr=findunit(unittype,unit);
|
tomwalters@0
|
62 set(param.entries{nr}.handle{2},'value',unitnr); % set the unit to the given one
|
tomwalters@0
|
63 editscaler=tounits(unittype,1,unit);
|
tomwalters@0
|
64 secombi.editscaler=editscaler;
|
tomwalters@0
|
65 end
|
tomwalters@0
|
66 secombi=slidereditcontrol_set_raweditvalue(secombi,value);
|
tomwalters@0
|
67 param.entries{nr}.slidereditcontrol=secombi;
|
tomwalters@0
|
68 end
|
tomwalters@0
|
69 return
|
tomwalters@0
|
70 end
|
tomwalters@0
|
71 else
|
tomwalters@0
|
72 error('setvalue::error, the entry does not exist');
|
tomwalters@0
|
73 end
|