tomwalters@0
|
1 % method of class @parameter
|
tomwalters@0
|
2 %
|
tomwalters@0
|
3 % (c) 2003, University of Cambridge
|
tomwalters@0
|
4 % Stefan Bleeck (stefan@bleeck.de)
|
tomwalters@0
|
5 % http://www.mrc-cbu.cam.ac.uk/cnbh/aimmanual/tools/parameter
|
tomwalters@0
|
6 % $Date: 2006-01-10 14:50:30 +0000 (Tue, 10 Jan 2006) $
|
tomwalters@0
|
7 function param=setas(param,text,value,unit,inbox)
|
tomwalters@0
|
8 %% sets the parameter value in the parameter "text" in the panel "inbox" to
|
tomwalters@0
|
9 %% the value "value".
|
tomwalters@0
|
10 % param must be of type float or int
|
tomwalters@0
|
11
|
tomwalters@0
|
12 if nargin<5
|
tomwalters@0
|
13 inbox='all';
|
tomwalters@0
|
14 end
|
tomwalters@0
|
15
|
tomwalters@0
|
16 % cont=param.entries;
|
tomwalters@0
|
17 nr=getentrynumberbytext(param,text,inbox);
|
tomwalters@0
|
18 if nr>0
|
tomwalters@0
|
19 if isequal(value,'auto');
|
tomwalters@0
|
20 param.entries{nr}.rawvalue=value;
|
tomwalters@0
|
21 param.entries{nr}.stringvalue=value; % set the string value
|
tomwalters@0
|
22 else
|
tomwalters@0
|
23 if ~ischar(value)
|
tomwalters@0
|
24 unittype=param.entries{nr}.unittype;
|
tomwalters@0
|
25 if ~isa(unittype,'unit_none')
|
tomwalters@0
|
26 rawval=fromunits(unittype,value,unit);
|
tomwalters@0
|
27 else
|
tomwalters@0
|
28 rawval=value;
|
tomwalters@0
|
29 end
|
tomwalters@0
|
30 param.entries{nr}.rawvalue=rawval; % set the value in the class structure with the raw value
|
tomwalters@0
|
31 param.entries{nr}.stringvalue=num2str(rawval); % set the string value
|
tomwalters@0
|
32 else
|
tomwalters@0
|
33 param.entries{nr}.stringvalue=value; % set the string value
|
tomwalters@0
|
34 param.entries{nr}.rawvalue=str2num(value);
|
tomwalters@0
|
35 end
|
tomwalters@0
|
36 end
|
tomwalters@0
|
37 if isfield(param.entries{nr},'handle') && ishandle(param.entries{nr}.handle{1}) % and set in the gui as well
|
tomwalters@0
|
38 if strcmp(type,'float')
|
tomwalters@0
|
39 hand=param.entries{nr}.handle{1};
|
tomwalters@0
|
40 if isequal(value,'auto');
|
tomwalters@0
|
41 set(hand,'String',value); % set the string as given
|
tomwalters@0
|
42 else
|
tomwalters@0
|
43 if ~ischar(value)
|
tomwalters@0
|
44 if length(value)==1
|
tomwalters@0
|
45 set(hand,'String',num2str(value)); % translate to string
|
tomwalters@0
|
46 else
|
tomwalters@0
|
47 set(hand,'String',param.entries{nr}.stringvalue); % set the string as given
|
tomwalters@0
|
48 end
|
tomwalters@0
|
49 if ~isa(unittype,'unit_none')
|
tomwalters@0
|
50 unitnr=findunit(unittype,unit);
|
tomwalters@0
|
51 if length(param.entries{nr}.handle)>=2 && ishandle(param.entries{nr}.handle{2}) % and set in the gui as well
|
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 end
|
tomwalters@0
|
55 else % its a string format
|
tomwalters@0
|
56 set(hand,'String',value); % set the string as given
|
tomwalters@0
|
57 end
|
tomwalters@0
|
58 end
|
tomwalters@0
|
59 else
|
tomwalters@0
|
60 sec=param.entries{nr}.slidereditcontrol;
|
tomwalters@0
|
61
|
tomwalters@0
|
62 end
|
tomwalters@0
|
63 return
|
tomwalters@0
|
64 else
|
tomwalters@0
|
65 error('setvalue::error, the entry does not exist');
|
tomwalters@0
|
66 end
|