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=add(param,type,text,argument4,argument5,argument6,argument7,argument8,argument9)
|
tomwalters@0
|
9 % add a new parameter to the structure
|
tomwalters@0
|
10 % and set its inital state variables
|
tomwalters@0
|
11
|
tomwalters@0
|
12 cont=param.entries;
|
tomwalters@0
|
13 newentrynr=length(cont)+1;
|
tomwalters@0
|
14
|
tomwalters@0
|
15 % each entry must be one of the following types:
|
tomwalters@0
|
16 % float (% floats can have an UNIT)
|
tomwalters@0
|
17 % int
|
tomwalters@0
|
18 % string
|
tomwalters@0
|
19 % bool (checkbox)
|
tomwalters@0
|
20 % button
|
tomwalters@0
|
21 % radiobutton (radiobutton)
|
tomwalters@0
|
22 % filename (a button and a string box)
|
tomwalters@0
|
23 % directoryname (a button and a string box)
|
tomwalters@0
|
24 % pop-up menu (a couple of strings)
|
tomwalters@0
|
25 % slider (a float plus a slider)
|
tomwalters@0
|
26 %
|
tomwalters@0
|
27 % it can also be a panel that is a subpanel that contains different uicontrols for example radiobuttons
|
tomwalters@0
|
28
|
tomwalters@0
|
29 if strcmp(type,'panel')
|
tomwalters@0
|
30 param.panelinfo.panelcount=0; % reset the counter because the next n entries are in this panel
|
tomwalters@0
|
31 param.panelinfo.is_in_panel=1; % flag for the next ones
|
tomwalters@0
|
32 param.panelinfo.count_panels_up_to=argument4; % so many are coming
|
tomwalters@0
|
33 param.panelinfo.current_panel=text;
|
tomwalters@0
|
34 end
|
tomwalters@0
|
35
|
tomwalters@0
|
36 % every entry is part of a panel. Either of type 'all' or of the given
|
tomwalters@0
|
37 % subpanels
|
tomwalters@0
|
38 if ~isfield(param.panelinfo,'panelcount') || ~param.panelinfo.is_in_panel
|
tomwalters@0
|
39 cont{newentrynr}.panel='all';
|
tomwalters@0
|
40 else
|
tomwalters@0
|
41 cont{newentrynr}.panel=param.panelinfo.current_panel;
|
tomwalters@0
|
42 param.panelinfo.panelcount=param.panelinfo.panelcount+1;
|
tomwalters@0
|
43 if param.panelinfo.panelcount>param.panelinfo.count_panels_up_to
|
tomwalters@0
|
44 param.panelinfo.is_in_panel=0;
|
tomwalters@0
|
45 end
|
tomwalters@0
|
46 end
|
tomwalters@0
|
47
|
tomwalters@0
|
48
|
tomwalters@0
|
49 cont{newentrynr}.type=type;
|
tomwalters@0
|
50 cont{newentrynr}.enable=1; % enable it by default
|
tomwalters@0
|
51
|
tomwalters@0
|
52 % each entry has a text that characterises it uniqly:
|
tomwalters@0
|
53 cont{newentrynr}.text=text;
|
tomwalters@0
|
54
|
tomwalters@0
|
55 % each entry can have an callback function that is called after it looses
|
tomwalters@0
|
56 % its focus or is pressed:
|
tomwalters@0
|
57 cont{newentrynr}.callback='';
|
tomwalters@0
|
58
|
tomwalters@0
|
59
|
tomwalters@0
|
60 % set the tooltip as the name (currently for debugging)
|
tomwalters@0
|
61 cont{newentrynr}.tooltiptext=cont{newentrynr}.text;
|
tomwalters@0
|
62
|
tomwalters@0
|
63 switch type
|
tomwalters@0
|
64 case {'int'}
|
tomwalters@0
|
65 % 1 2 3 4 5 6
|
tomwalters@0
|
66 % object type name val minval maxval
|
tomwalters@0
|
67 % eg params=add(params,'int','min bins above thres',2, 0, inf);
|
tomwalters@0
|
68
|
tomwalters@0
|
69 if nargin>=4
|
tomwalters@0
|
70 cont{newentrynr}.value=argument4;
|
tomwalters@0
|
71 else
|
tomwalters@0
|
72 cont{newentrynr}.value=0;
|
tomwalters@0
|
73 end
|
tomwalters@0
|
74 if nargin<5
|
tomwalters@0
|
75 cont{newentrynr}.minvalue=intmin;
|
tomwalters@0
|
76 else
|
tomwalters@0
|
77 cont{newentrynr}.minvalue=argument5;
|
tomwalters@0
|
78 end
|
tomwalters@0
|
79 if nargin<6
|
tomwalters@0
|
80 cont{newentrynr}.maxvalue=intmax;
|
tomwalters@0
|
81 else
|
tomwalters@0
|
82 cont{newentrynr}.maxvalue=argument6;
|
tomwalters@0
|
83 end
|
tomwalters@0
|
84
|
tomwalters@0
|
85 case {'float'}
|
tomwalters@0
|
86 % 1 2 3 4 5 6 7 8
|
tomwalters@0
|
87 % object type name unittype val userunit minval maxval
|
tomwalters@0
|
88 % eg params=add(params,'float','window start',unit_time,0, 'ms', 0 ,lenstim);
|
tomwalters@0
|
89 if ~isobject(argument4) % without a unit its a unit_none and argument4 is the value
|
tomwalters@0
|
90 if isnumeric(argument4)
|
tomwalters@0
|
91 cont{newentrynr}.stringvalue=num2str(argument4);
|
tomwalters@0
|
92 cont{newentrynr}.rawvalue=argument4;
|
tomwalters@0
|
93 else
|
tomwalters@0
|
94 cont{newentrynr}.stringvalue=argument4;
|
tomwalters@0
|
95 cont{newentrynr}.rawvalue=str2num(argument4);
|
tomwalters@0
|
96 end
|
tomwalters@0
|
97 cont{newentrynr}.unittype=unit_none;
|
tomwalters@0
|
98 cont{newentrynr}.orgunit=unit_none;
|
tomwalters@0
|
99 else
|
tomwalters@0
|
100 cont{newentrynr}.unittype=argument4; % the general unit (eg unit_time)
|
tomwalters@0
|
101 if ischar(argument5)
|
tomwalters@0
|
102 cont{newentrynr}.stringvalue=argument5;
|
tomwalters@0
|
103 else
|
tomwalters@0
|
104 cont{newentrynr}.stringvalue=num2str(argument5);
|
tomwalters@0
|
105 end
|
tomwalters@0
|
106 if ~isa(argument4,'unit_none')
|
tomwalters@0
|
107 cont{newentrynr}.orgunit=argument6; % the definition unit (later used in calls with set)
|
tomwalters@0
|
108 if ischar(argument5) && ~strcmp(argument5,'auto')
|
tomwalters@0
|
109 cont{newentrynr}.rawvalue=fromunits(argument4,str2num(argument5),argument6);
|
tomwalters@0
|
110 elseif ~strcmp(argument5,'auto')
|
tomwalters@0
|
111 cont{newentrynr}.rawvalue=fromunits(argument4,argument5,argument6);
|
tomwalters@0
|
112 else
|
tomwalters@0
|
113 cont{newentrynr}.rawvalue='auto';
|
tomwalters@0
|
114 end
|
tomwalters@0
|
115 else
|
tomwalters@0
|
116 if exist('argument6','var') && isnumeric(argument6)
|
tomwalters@0
|
117 temp=argument7;
|
tomwalters@0
|
118 argument7=argument6;
|
tomwalters@0
|
119 argument8=temp;
|
tomwalters@0
|
120 end
|
tomwalters@0
|
121 cont{newentrynr}.orgunit=''; % the definition unit (later used in calls with set)
|
tomwalters@0
|
122 cont{newentrynr}.rawvalue=argument5;
|
tomwalters@0
|
123 end
|
tomwalters@0
|
124 end % without unit
|
tomwalters@0
|
125 if nargin<7
|
tomwalters@0
|
126 cont{newentrynr}.minvalue=-inf;
|
tomwalters@0
|
127 else
|
tomwalters@0
|
128 cont{newentrynr}.minvalue=argument7;
|
tomwalters@0
|
129 end
|
tomwalters@0
|
130 if nargin<8
|
tomwalters@0
|
131 cont{newentrynr}.maxvalue=+inf;
|
tomwalters@0
|
132 else
|
tomwalters@0
|
133 cont{newentrynr}.maxvalue=argument8;
|
tomwalters@0
|
134 end
|
tomwalters@0
|
135
|
tomwalters@0
|
136
|
tomwalters@0
|
137 case {'slider'}
|
tomwalters@0
|
138 % 1 2 3 4 5 6 7 8 9
|
tomwalters@0
|
139 % object type name unittype val userunit minval maxval logornot
|
tomwalters@0
|
140 % eg params=add(params,'slider','slidval',unit_time, 0, 'ms', 0 , inf, islog);
|
tomwalters@0
|
141 if ~isobject(argument4) % without a unit its a unit_none and argument4 is the value
|
tomwalters@0
|
142 if isnumeric(argument4)
|
tomwalters@0
|
143 cont{newentrynr}.stringvalue=num2str(argument4);
|
tomwalters@0
|
144 cont{newentrynr}.rawvalue=argument4;
|
tomwalters@0
|
145 else
|
tomwalters@0
|
146 cont{newentrynr}.stringvalue=argument4;
|
tomwalters@0
|
147 cont{newentrynr}.rawvalue=str2num(argument4);
|
tomwalters@0
|
148 end
|
tomwalters@0
|
149 cont{newentrynr}.unittype=unit_none;
|
tomwalters@0
|
150 cont{newentrynr}.orgunit=unit_none;
|
tomwalters@0
|
151 if nargin<7 % is log or not
|
tomwalters@0
|
152 tmp=1;
|
tomwalters@0
|
153 else
|
tomwalters@0
|
154 tmp=argument7;
|
tomwalters@0
|
155 end
|
tomwalters@0
|
156 argument7=argument5; % minvalue
|
tomwalters@0
|
157 argument8=argument6; % maxvalue must be there!
|
tomwalters@0
|
158 argument9=tmp;
|
tomwalters@0
|
159 else
|
tomwalters@0
|
160 cont{newentrynr}.unittype=argument4; % the general unit (eg unit_time)
|
tomwalters@0
|
161 if ischar(argument5)
|
tomwalters@0
|
162 cont{newentrynr}.stringvalue=argument5;
|
tomwalters@0
|
163 else
|
tomwalters@0
|
164 cont{newentrynr}.stringvalue=num2str(argument5);
|
tomwalters@0
|
165 end
|
tomwalters@0
|
166 if ~isa(argument4,'unit_none')
|
tomwalters@0
|
167 cont{newentrynr}.orgunit=argument6; % the definition unit (later used in calls with set)
|
tomwalters@0
|
168 if ischar(argument5) && ~strcmp(argument5,'auto')
|
tomwalters@0
|
169 cont{newentrynr}.rawvalue=fromunits(argument4,str2num(argument5),argument6);
|
tomwalters@0
|
170 elseif ~strcmp(argument5,'auto')
|
tomwalters@0
|
171 cont{newentrynr}.rawvalue=fromunits(argument4,argument5,argument6);
|
tomwalters@0
|
172 else
|
tomwalters@0
|
173 cont{newentrynr}.rawvalue='auto';
|
tomwalters@0
|
174 end
|
tomwalters@0
|
175 else
|
tomwalters@0
|
176 if exist('argument6','var') && isnumeric(argument6)
|
tomwalters@0
|
177 temp=argument7;
|
tomwalters@0
|
178 argument7=argument6;
|
tomwalters@0
|
179 argument8=temp;
|
tomwalters@0
|
180 end
|
tomwalters@0
|
181 cont{newentrynr}.orgunit=''; % the definition unit (later used in calls with set)
|
tomwalters@0
|
182 cont{newentrynr}.rawvalue=argument5;
|
tomwalters@0
|
183 end
|
tomwalters@0
|
184 end % without unit
|
tomwalters@0
|
185 if ~exist('argument7','var')
|
tomwalters@0
|
186 cont{newentrynr}.minvalue=-inf;
|
tomwalters@0
|
187 else
|
tomwalters@0
|
188 cont{newentrynr}.minvalue=argument7;
|
tomwalters@0
|
189 end
|
tomwalters@0
|
190 if ~exist('argument8','var')
|
tomwalters@0
|
191 cont{newentrynr}.maxvalue=+inf;
|
tomwalters@0
|
192 else
|
tomwalters@0
|
193 cont{newentrynr}.maxvalue=argument8;
|
tomwalters@0
|
194 end
|
tomwalters@0
|
195 if ~exist('argument9','var')
|
tomwalters@0
|
196 cont{newentrynr}.islog=0;
|
tomwalters@0
|
197 else
|
tomwalters@0
|
198 cont{newentrynr}.islog=argument9;
|
tomwalters@0
|
199 end
|
tomwalters@0
|
200 if isa(cont{newentrynr}.orgunit,'unit_none')
|
tomwalters@0
|
201 cont{newentrynr}.editscaler=1;
|
tomwalters@0
|
202 else
|
tomwalters@0
|
203 cont{newentrynr}.editscaler=tounits(argument4,1,argument6);
|
tomwalters@0
|
204 cont{newentrynr}.minvalue=fromunits(argument4,cont{newentrynr}.minvalue,argument6);
|
tomwalters@0
|
205 cont{newentrynr}.maxvalue=fromunits(argument4,cont{newentrynr}.maxvalue,argument6);
|
tomwalters@0
|
206 end
|
tomwalters@0
|
207 cont{newentrynr}.nreditdigits=4;
|
tomwalters@0
|
208
|
tomwalters@0
|
209 % 1 2 3 4 5
|
tomwalters@0
|
210 % object type name val other value
|
tomwalters@0
|
211 % params=add(params,'bool','swap dimensions','true','othervalue');
|
tomwalters@0
|
212 case {'bool','radiobutton'}
|
tomwalters@0
|
213 if nargin<4
|
tomwalters@0
|
214 argument4='';
|
tomwalters@0
|
215 end
|
tomwalters@0
|
216 if ischar(argument4)
|
tomwalters@0
|
217 if strcmp(argument4,'true')
|
tomwalters@0
|
218 cont{newentrynr}.value=1;
|
tomwalters@0
|
219 else
|
tomwalters@0
|
220 cont{newentrynr}.value=0;
|
tomwalters@0
|
221 end
|
tomwalters@0
|
222 else
|
tomwalters@0
|
223 cont{newentrynr}.value=argument4;
|
tomwalters@0
|
224 end
|
tomwalters@0
|
225 cont{newentrynr}.tooltiptext=[cont{newentrynr}.panel ': ' cont{newentrynr}.text];
|
tomwalters@0
|
226 cont{newentrynr}.enables={}; % these are the ones that are switched on by me
|
tomwalters@0
|
227 cont{newentrynr}.enables_inbox={};
|
tomwalters@0
|
228 cont{newentrynr}.disables={}; % and these are switched off
|
tomwalters@0
|
229 cont{newentrynr}.disables_inbox={};
|
tomwalters@0
|
230 if nargin==5
|
tomwalters@0
|
231 cont{newentrynr}.userdata=argument5;
|
tomwalters@0
|
232 end
|
tomwalters@0
|
233
|
tomwalters@0
|
234
|
tomwalters@0
|
235 % 1 2 3 4 5
|
tomwalters@0
|
236 % object type name callback default
|
tomwalters@0
|
237 % params=add(params,'button','analyse','ret=fkt(d,params,''plot'');',1);
|
tomwalters@0
|
238 case 'button'
|
tomwalters@0
|
239 cont{newentrynr}.value=0;
|
tomwalters@0
|
240 if strcmp(text,'OK')
|
tomwalters@0
|
241 cont{newentrynr}.callback='close';
|
tomwalters@0
|
242 if nargin==4 && isnumeric(argument4)
|
tomwalters@0
|
243 cont{newentrynr}.isdefaultbutton=argument4;
|
tomwalters@0
|
244 else
|
tomwalters@0
|
245 cont{newentrynr}.isdefaultbutton=0;
|
tomwalters@0
|
246 end
|
tomwalters@0
|
247 else
|
tomwalters@0
|
248 cont{newentrynr}.callback=argument4;
|
tomwalters@0
|
249 end
|
tomwalters@0
|
250 cont{newentrynr}.tooltiptext=['button: ' cont{newentrynr}.text];
|
tomwalters@0
|
251 if nargin==5 && isnumeric(argument5)
|
tomwalters@0
|
252 cont{newentrynr}.isdefaultbutton=argument5;
|
tomwalters@0
|
253 else
|
tomwalters@0
|
254 if ~strcmp(text,'OK')
|
tomwalters@0
|
255 cont{newentrynr}.isdefaultbutton=0;
|
tomwalters@0
|
256 end
|
tomwalters@0
|
257 end
|
tomwalters@0
|
258
|
tomwalters@0
|
259 case 'pop-up menu'
|
tomwalters@0
|
260 cont{newentrynr}.value=argument4{1};
|
tomwalters@0
|
261 cont{newentrynr}.numeric_value=1;
|
tomwalters@0
|
262 cont{newentrynr}.possible_values=argument4;
|
tomwalters@0
|
263 cont{newentrynr}.tooltiptext=['pop-up menu: ' cont{newentrynr}.text];
|
tomwalters@0
|
264
|
tomwalters@0
|
265 % 1 2 3 4 5
|
tomwalters@0
|
266 % object type name strvalue length of window
|
tomwalters@0
|
267 % dstruct=add(dstruct,'string','comment',WHATcomment,30);
|
tomwalters@0
|
268 case 'string'
|
tomwalters@0
|
269 cont{newentrynr}.value=argument4;
|
tomwalters@0
|
270 if nargin>=5
|
tomwalters@0
|
271 cont{newentrynr}.width=argument5;
|
tomwalters@0
|
272 else
|
tomwalters@0
|
273 cont{newentrynr}.width=-1;
|
tomwalters@0
|
274 end
|
tomwalters@0
|
275 cont{newentrynr}.tooltiptext=['string: ' cont{newentrynr}.text];
|
tomwalters@0
|
276
|
tomwalters@0
|
277 % 1 2 3 4
|
tomwalters@0
|
278 % object type name nr rows
|
tomwalters@0
|
279 % dstruct=add(dstruct,'panel','unit type',10);
|
tomwalters@0
|
280 case 'panel'
|
tomwalters@0
|
281 cont{newentrynr}.panel=text;
|
tomwalters@0
|
282 cont{newentrynr}.tooltiptext=['panel: ' cont{newentrynr}.text];
|
tomwalters@0
|
283 cont{newentrynr}.nr_elements=argument4;
|
tomwalters@0
|
284 case 'filename'
|
tomwalters@0
|
285 if nargin<4
|
tomwalters@0
|
286 cont{newentrynr}.value='';
|
tomwalters@0
|
287 else
|
tomwalters@0
|
288 cont{newentrynr}.value=argument4;
|
tomwalters@0
|
289 end
|
tomwalters@0
|
290 cont{newentrynr}.tooltiptext=['file name: ' cont{newentrynr}.text];
|
tomwalters@0
|
291 case 'directoryname'
|
tomwalters@0
|
292 if nargin<4
|
tomwalters@0
|
293 cont{newentrynr}.value='';
|
tomwalters@0
|
294 else
|
tomwalters@0
|
295 cont{newentrynr}.value=argument4;
|
tomwalters@0
|
296 end
|
tomwalters@0
|
297 cont{newentrynr}.tooltiptext=['directry name: ' cont{newentrynr}.text];
|
tomwalters@0
|
298 otherwise
|
tomwalters@0
|
299 error(sprintf('dont know type ''%s''',type))
|
tomwalters@0
|
300 end
|
tomwalters@0
|
301
|
tomwalters@0
|
302
|
tomwalters@0
|
303
|
tomwalters@0
|
304 % save them
|
tomwalters@0
|
305 param.entries=cont; |