Mercurial > hg > ltpda
comparison m-toolbox/m/gui/ao_browser/ltpda_explorer.m @ 0:f0afece42f48
Import.
author | Daniele Nicolodi <nicolodi@science.unitn.it> |
---|---|
date | Wed, 23 Nov 2011 19:22:13 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f0afece42f48 |
---|---|
1 % LTPDA_EXPLORER for exploring analysis objects and plotting/displaying their fields | |
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
3 % | |
4 % DESCRIPTION: LTPDA_EXPLORER for exploring analysis objects and plotting/displaying | |
5 % their fields. It is possible to browse througth the history tree | |
6 % to see only a part of this tree. If the user will use the plot | |
7 % function the plot will be printed in a new figure. | |
8 % | |
9 % CALL: ltpda_explorer; % Read the ao's from the'base' workspace | |
10 % ltpda_explorer(ao); | |
11 % ltpda_explorer(ao_vector); | |
12 % ltpda_explorer(ao_matrix); | |
13 % | |
14 % | |
15 % VERSION: $Id: ltpda_explorer.m,v 1.13 2011/05/10 04:50:58 hewitson Exp $ | |
16 % | |
17 % HISTORY: 10-06-07 Diepholz | |
18 % Creation | |
19 % | |
20 % NOTE: The idea and the core source code are taken from: | |
21 % Hassan Lahdili (hassan.lahdili@crc.ca) | |
22 % Communications Research Centre (CRC) | Advanced Audio Systems (AAS) | |
23 % www.crc.ca | www.crc.ca/aas | |
24 % Ottawa. Canada | |
25 % CRC Advanced Audio Systems - Ottawa 16/02/2005 2004-2005 | |
26 % | |
27 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
28 | |
29 function ltpda_explorer(varargin) | |
30 | |
31 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
32 % Define the Positions % | |
33 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
34 | |
35 % figure position | |
36 % FIG_X = .150; | |
37 % FIG_Y = .150; | |
38 % FIG_dX = .700; | |
39 % FIG_dY = .600; | |
40 | |
41 FONT_SIZE = 13; | |
42 | |
43 FIG_X = 150; | |
44 FIG_Y = 150; | |
45 FIG_dX = 700; | |
46 FIG_dY = 600; | |
47 | |
48 | |
49 % tree position | |
50 TREE_X = .000; | |
51 TREE_Y = .000; | |
52 TREE_dX = .350; | |
53 TREE_dY = 1.000; | |
54 | |
55 % plot field position | |
56 PLOT_X = .45; | |
57 PLOT_Y = .15; | |
58 PLOT_dX = .5; | |
59 PLOT_dY = .7; | |
60 | |
61 % display field position | |
62 DISP_X = TREE_X; | |
63 DISP_Y = .750; | |
64 DISP_dX = TREE_dX; | |
65 DISP_dY = 1-DISP_Y; | |
66 | |
67 % explorer name position | |
68 EXPL_NAME_dX = .370; | |
69 EXPL_NAME_dY = .045; | |
70 EXPL_NAME_X = PLOT_X+(PLOT_dX-EXPL_NAME_dX)/2; | |
71 EXPL_NAME_Y = .030; | |
72 % EXPL_NAME_Y = .065; | |
73 | |
74 % info fields position | |
75 N_INFOS = 3; | |
76 | |
77 INFO_X = PLOT_X; | |
78 INFO_Y = .915; | |
79 INFO_dX = PLOT_dX / N_INFOS; | |
80 INFO_dY = .06; | |
81 | |
82 BG_COLOR = [.925 .914 .847]; | |
83 | |
84 MAX_HIST_DEPTH = 4; | |
85 | |
86 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
87 % Check the input % | |
88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
89 | |
90 | |
91 tree_name = 'objects'; | |
92 obj = []; | |
93 obj_value = {}; | |
94 obj_name = {}; | |
95 | |
96 % Read the objects from the 'base' workspace | |
97 | |
98 if nargin == 0 | |
99 ws_vars = evalin('base','whos'); | |
100 | |
101 elseif nargin == 1 | |
102 tmp = varargin{1}; | |
103 | |
104 if iscell(tmp) | |
105 ws_vars = []; | |
106 for jj = 1:length(tmp) | |
107 ws_vars(jj).name = [inputname(1) '{' num2str(jj) '}']; | |
108 ws_vars(jj).class = class(tmp{jj}); | |
109 ws_vars(jj).obj = tmp{jj}; | |
110 end | |
111 | |
112 elseif numel(tmp)>1 | |
113 ws_vars = []; | |
114 for jj=1:numel(tmp) | |
115 ws_vars(jj).name = [inputname(1) '(' num2str(jj) ')']; | |
116 ws_vars(jj).class = class(tmp(jj)); | |
117 ws_vars(jj).obj = tmp(jj); | |
118 end | |
119 | |
120 else | |
121 ws_vars = whos('tmp'); | |
122 ws_vars.name = inputname(1); | |
123 ws_vars.obj = tmp; | |
124 end | |
125 | |
126 else | |
127 error ('##########'); | |
128 end | |
129 | |
130 | |
131 for mm=1:length(ws_vars) | |
132 | |
133 if nargin == 0 | |
134 obj = evalin('base', ws_vars(mm).name); | |
135 elseif nargin == 1 | |
136 obj = ws_vars(mm).obj; | |
137 else | |
138 error('#####'); | |
139 end | |
140 | |
141 if utils.helper.isobject(obj) | |
142 | |
143 % the object in the workspace is a single value | |
144 if numel(obj) == 1 | |
145 obj_value{end+1} = obj; | |
146 obj_name{end+1} = [ws_vars(mm).class ':' ws_vars(mm).name]; | |
147 else | |
148 | |
149 [n,m] = size(obj); | |
150 | |
151 % the ao in the workspace is a vector | |
152 if n == 1 || m == 1 | |
153 | |
154 for jj=1:length(obj) | |
155 obj_value{end+1} = obj(jj); | |
156 obj_name{end+1} = [ws_vars(mm).class ':' ws_vars(mm).name '(' num2str(jj) ')']; | |
157 end | |
158 | |
159 % the ao in the workspace is a matrix | |
160 elseif n > 1 && m > 1 | |
161 | |
162 for gg = 1:n | |
163 for hh = 1:m | |
164 obj_value{end+1} = obj(gg,hh); | |
165 obj_name{end+1} = [ws_vars(mm).class ':' ws_vars(mm).name '(' num2str(gg) ',' num2str(hh) ')']; | |
166 end | |
167 end | |
168 | |
169 else | |
170 error ('### this should not happen.'); | |
171 end | |
172 | |
173 end | |
174 | |
175 end | |
176 end | |
177 | |
178 | |
179 fig_name = 'Exploring objects'; | |
180 | |
181 % Define figure | |
182 fig = figure('NextPlot', 'add', ... | |
183 'NumberTitle', 'off', ... | |
184 'Toolbar', 'none', ... | |
185 'name', fig_name, ... | |
186 'Color', BG_COLOR, ... | |
187 'ToolBar', 'none', ... | |
188 'NextPlot', 'new', ... | |
189 'MenuBar', 'none',... | |
190 'Position', [FIG_X FIG_Y ... | |
191 FIG_dX FIG_dY]); | |
192 | |
193 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
194 % Define the tree % | |
195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
196 | |
197 root = uitreenode('v0', tree_name, tree_name, [], false); | |
198 tree = uitree('v0', fig, 'Root',root, 'ExpandFcn', @myExpfcn4); | |
199 set(tree, 'Units', 'normalized') | |
200 drawnow; | |
201 set(tree, 'position', [TREE_X TREE_Y TREE_dX TREE_dY]); %, ... | |
202 set(tree, 'NodeWillExpandCallback', @nodeWillExpand_cb4, ... | |
203 'NodeSelectedCallback', @nodeSelected_cb4); | |
204 | |
205 tmp = tree.FigureComponent; | |
206 cell_Data = cell(3,1); | |
207 | |
208 % cell_Data{1} = varargin{:}; | |
209 cell_Data{1} = obj_value; | |
210 cell_Data{3} = obj_name; | |
211 | |
212 warning('off','MATLAB:hg:JavaSetHGProperty'); | |
213 set(tmp, 'UserData', cell_Data); | |
214 warning('on','MATLAB:hg:JavaSetHGProperty'); | |
215 | |
216 % Define the plot field | |
217 haxes = axes('Units', 'normalized', ... | |
218 'Position', [PLOT_X PLOT_Y ... | |
219 PLOT_dX PLOT_dY], ... | |
220 'Box', 'on', ... | |
221 'XTick', [], ... | |
222 'YTick', []); | |
223 | |
224 box off; | |
225 axis off; | |
226 | |
227 % Define the info fields 'name' | |
228 txt1 = uicontrol('String', '', ... | |
229 'Units', 'normalized', ... | |
230 'Style', 'Edit', ... | |
231 'FontSize', FONT_SIZE, ... | |
232 'Position', [INFO_X INFO_Y ... | |
233 INFO_dX INFO_dY], ... | |
234 'BackgroundColor', BG_COLOR); | |
235 % Define the info fields 'size' | |
236 txt2 = uicontrol('String', '', ... | |
237 'Units', 'normalized', ... | |
238 'Style', 'Edit', ... | |
239 'FontSize', FONT_SIZE, ... | |
240 'Position', [(INFO_X+INFO_dX) INFO_Y ... | |
241 INFO_dX INFO_dY],... | |
242 'BackgroundColor', BG_COLOR); | |
243 % Define the info fields 'class' | |
244 txt3 = uicontrol('String', '', ... | |
245 'Units', 'normalized', ... | |
246 'Style', 'Edit', ... | |
247 'FontSize', FONT_SIZE, ... | |
248 'Position', [(INFO_X+2*INFO_dX) INFO_Y ... | |
249 INFO_dX INFO_dY],... | |
250 'BackgroundColor', BG_COLOR); | |
251 % Define the info fields 'value' | |
252 txt4 = uicontrol('String', '', ... | |
253 'Units', 'normalized', ... | |
254 'Style', 'Edit', ... | |
255 'FontSize', FONT_SIZE, ... | |
256 'Position', [ INFO_X (INFO_Y-INFO_dY) ... | |
257 3*INFO_dX INFO_dY], ... | |
258 'BackgroundColor', BG_COLOR); | |
259 | |
260 % Define the info fields 'value' | |
261 txt5 = uicontrol('String', '', ... | |
262 'Units', 'normalized', ... | |
263 'Style', 'listbox', ... | |
264 'Visible', 'off', ... | |
265 'Fontsize', 8, ... | |
266 'FontSize', FONT_SIZE, ... | |
267 'Position', [DISP_X DISP_Y ... | |
268 DISP_dX DISP_dY], ... | |
269 'BackgroundColor', BG_COLOR); | |
270 | |
271 | |
272 | |
273 % Define the decription of the info fields | |
274 col1 = uicontrol('String', 'Name', ... | |
275 'Units', 'normalized', ... | |
276 'Style', 'Text', ... | |
277 'FontSize', FONT_SIZE, ... | |
278 'Position', [INFO_X (INFO_Y+INFO_dY)... | |
279 INFO_dX INFO_dY], ... | |
280 'BackgroundColor', BG_COLOR); | |
281 col2 = uicontrol('String', 'Size', ... | |
282 'Units', 'normalized', ... | |
283 'Style', 'Text', ... | |
284 'FontSize', FONT_SIZE, ... | |
285 'Position', [(INFO_X+INFO_dX) (INFO_Y+INFO_dY)... | |
286 INFO_dX INFO_dY], ... | |
287 'BackgroundColor', BG_COLOR); | |
288 col3 = uicontrol('String', 'Class', ... | |
289 'Units', 'normalized', ... | |
290 'Style', 'Text', ... | |
291 'FontSize', FONT_SIZE, ... | |
292 'Position', [(INFO_X+2*INFO_dX) (INFO_Y+INFO_dY)... | |
293 INFO_dX INFO_dY], ... | |
294 'BackgroundColor', BG_COLOR); | |
295 | |
296 % Define the name of the explorer | |
297 expl_name = uicontrol('String', 'LTPDA Object explorer', ... | |
298 'Units', 'normalized', ... | |
299 'Style', 'text', ... | |
300 'Position', [EXPL_NAME_X-.05 EXPL_NAME_Y ... | |
301 EXPL_NAME_dX+.1 EXPL_NAME_dY],... | |
302 'ForeGroundColor', [0.2 0.4 1], ... | |
303 'BackGroundColor', BG_COLOR, ... | |
304 'FontSize', 18, ... | |
305 'FontWeight', 'bold', ... | |
306 'FontAngle', 'italic'); | |
307 | |
308 tree_menu = uicontextmenu(); | |
309 tree_menu1 = uimenu(tree_menu, 'Label', 'Plot', ... | |
310 'Callback', @f_tree_menu1); | |
311 tree_menu2 = uimenu(tree_menu, 'Label', 'Display', ... | |
312 'Callback', @f_tree_menu2); | |
313 | |
314 disp_menu = uicontextmenu; | |
315 disp_menu1 = uimenu(disp_menu, 'Label', 'close', ... | |
316 'Callback', @f_disp_menu1); | |
317 | |
318 warning('off','MATLAB:hg:JavaSetHGProperty'); | |
319 set(tree.Tree, 'MousePressedCallback', @mouse_cb); | |
320 set(tree.Tree, 'UIContextMenu', tree_menu); | |
321 set(tree.Tree, 'Font', javax.swing.plaf.FontUIResource('Dialog', 0, FONT_SIZE)) | |
322 warning('on','MATLAB:hg:JavaSetHGProperty'); | |
323 | |
324 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
325 % Mouse Pressed Handler | |
326 function mouse_cb(h, ev) | |
327 if ev.getModifiers()== ev.META_MASK | |
328 % Workaround to set the y position | |
329 % Workaround to set the x position | |
330 vis = get(get(ev, 'Component'), 'VisibleRect'); | |
331 x_width = get(get(ev, 'Component'), 'Width'); | |
332 y_height = get(get(ev, 'Component'), 'Height'); | |
333 | |
334 new_x = ev.getX-vis(1); | |
335 new_y = -ev.getY+y_height-(y_height-vis(4)); | |
336 set(tree_menu, 'Position', [new_x new_y], ... | |
337 'Visible', 'on'); | |
338 end | |
339 | |
340 end | |
341 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
342 function f_disp_menu1(h, ev) | |
343 set(txt5, 'Visible', 'off') | |
344 set(tree, 'position', [TREE_X TREE_Y ... | |
345 TREE_dX TREE_dY]) | |
346 end | |
347 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
348 function f_tree_menu1(h,ev) | |
349 plotselected_cb; | |
350 end | |
351 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
352 function f_tree_menu2(h,ev) | |
353 displayselected_cb; | |
354 end | |
355 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
356 function plotselected_cb(h, ev) | |
357 | |
358 tmp = tree.FigureComponent; | |
359 S = get(tmp, 'UserData'); | |
360 s = S{1}; | |
361 cNode = S{2}; | |
362 [val, plotted, cNode] = getcNodevalue(cNode, s); | |
363 | |
364 cla(haxes) | |
365 box off; | |
366 axis off; | |
367 | |
368 %%%%% Plot history object %%%%% | |
369 if (isa(val,'history')) | |
370 if length(val) == 1 | |
371 figure; | |
372 plot(val); | |
373 ii = strfind(plotted, 'inhists'); | |
374 title(haxes, sprintf('History-Level: %d', length(ii)+1)) | |
375 else | |
376 na = text(0.5,0.5,'Select the left or right branch.'); | |
377 set(na, 'HorizontalAlignment', 'center', ... | |
378 'Color', 'r', ... | |
379 'FontWeight', 'bold', ... | |
380 'EdgeColor', 'k', ... | |
381 'BackgroundColor', 'w', ... | |
382 'Fontsize', 10, ... | |
383 'Margin', 5); | |
384 end | |
385 | |
386 %%%%% Plot data object %%%%% | |
387 elseif isa(val,'fsdata') || isa(val,'tsdata') || ... | |
388 isa(val,'xydata') || isa(val,'cdata') | |
389 aoin = getcNodevalue(S{2}.getParent, s); | |
390 iplot(aoin) | |
391 | |
392 %%%%% Plot the AO object %%%%% | |
393 elseif isa(val, 'ao') | |
394 iplot(val) | |
395 | |
396 %%%%% Plot mfir and miir object %%%%% | |
397 elseif isa(val, 'mfir') || isa(val, 'miir') | |
398 resp(val) | |
399 | |
400 %%%%% Plot pzmodel object %%%%% | |
401 elseif isa(val, 'pzmodel') | |
402 resp(val) | |
403 | |
404 %%%%% Is the parent node == 'data' so plot data %%%%% | |
405 else | |
406 | |
407 cNode = S{2}; | |
408 | |
409 if cNode.getLevel >= 1 | |
410 obj = getcNodevalue(S{2}.getParent, s); | |
411 | |
412 if isa(obj, 'ltpda_data') | |
413 aoin = getcNodevalue(S{2}.getParent.getParent, s); | |
414 iplot(aoin); | |
415 elseif isa(obj, 'ao') | |
416 iplot(obj); | |
417 end | |
418 end | |
419 | |
420 end | |
421 | |
422 end | |
423 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
424 function displayselected_cb(h, ev) | |
425 tmp = tree.FigureComponent; | |
426 S = get(tmp, 'UserData'); | |
427 s = S{1}; | |
428 cNode = S{2}; | |
429 [val, displayed, cNode] = getcNodevalue(cNode, s); | |
430 | |
431 text1 = ''; | |
432 if isobject(val) | |
433 text1 = display(val); | |
434 else | |
435 disp(val) | |
436 end | |
437 | |
438 % some sisplay outputs contains '\n' <-> char(10) | |
439 % text can not display this character so replace it with ' ' | |
440 text1 = strrep(text1, char(10), ' '); | |
441 | |
442 set(tree, 'position', [TREE_X TREE_Y ... | |
443 TREE_dX TREE_dY-DISP_dY]); | |
444 set(txt5, 'string', text1); | |
445 set(txt5, 'Visible', 'on'); | |
446 set(txt5, 'UIContextMenu', disp_menu); | |
447 end | |
448 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
449 | |
450 function cNode = nodeSelected_cb4(tree,ev) | |
451 cNode = ev.getCurrentNode; | |
452 tmp = tree.FigureComponent; | |
453 warning('off','MATLAB:hg:JavaSetHGProperty'); | |
454 cell_Data = get(tmp, 'UserData'); | |
455 warning('on','MATLAB:hg:JavaSetHGProperty'); | |
456 cell_Data{2} = cNode; | |
457 s = cell_Data{1}; | |
458 val = s; | |
459 plotted = cNode.getValue; | |
460 selected = plotted; | |
461 [val, plotted, cNode] = getcNodevalue(cNode, val); | |
462 set(txt1, 'string', selected) | |
463 set(txt2, 'string', strcat(num2str(size(val,1)),'x',num2str(size(val,2))) ) | |
464 set(txt3, 'string', class(val)) | |
465 | |
466 str = ' '; | |
467 c_str = {}; | |
468 cla(haxes) | |
469 axesSize = get(haxes,'Position'); | |
470 axesSize = axesSize + [-.07 -.05 .09 0.05]; | |
471 plotPanel = findobj(gcf,'Tag','plotPanel'); | |
472 if isempty(plotPanel), plotPanel = uipanel('Position',axesSize,'Tag','plotPanel','BorderType','none','BackgroundColor',[.925 .914 .847]); end | |
473 delete(get(plotPanel,'Children')) | |
474 box off; | |
475 axis off; | |
476 | |
477 if ~isempty(val) | |
478 | |
479 if isnumeric(val) | |
480 % normalize the vector | |
481 si = size(val); | |
482 if si(1) > si(2) | |
483 val = val.'; | |
484 else | |
485 val = val; | |
486 end | |
487 if size(val,1) == 1 || size(val,2) == 1 | |
488 if length(val) > 3 | |
489 str = strcat(num2str(val(1:3)), ' ...'); | |
490 else | |
491 str = num2str(val); | |
492 end | |
493 else | |
494 str = 'Matrix'; | |
495 end | |
496 | |
497 elseif ischar(val) | |
498 str = val; | |
499 | |
500 elseif islogical(val) | |
501 if val | |
502 str = 'true'; | |
503 else | |
504 str = 'false'; | |
505 end | |
506 | |
507 elseif isobject(val) | |
508 if isa(val, 'ao') | |
509 str = 'Analysis Object'; | |
510 if ~isa(val.data, 'cdata') | |
511 iplot(val,plist('Figure',plotPanel)); | |
512 else | |
513 iplot(val,plist('Figure',plotPanel)); | |
514 end | |
515 elseif isa(val, 'cdata') | |
516 str = 'C-Data Object'; | |
517 aoin = getcNodevalue(ev.getCurrentNode.getParent, s); | |
518 elseif isa(val, 'fsdata') | |
519 str = 'Frequency-Series Object'; | |
520 aoin = getcNodevalue(ev.getCurrentNode.getParent, s); | |
521 iplot(aoin,plist('Figure',plotPanel)); | |
522 elseif isa(val, 'tsdata') | |
523 str = 'Time-Series Object'; | |
524 aoin = getcNodevalue(ev.getCurrentNode.getParent, s); | |
525 iplot(aoin,plist('Figure',plotPanel)); | |
526 elseif isa(val, 'xydata') | |
527 str = 'X-Y Data Object'; | |
528 aoin = getcNodevalue(ev.getCurrentNode.getParent, s); | |
529 iplot(aoin,plist('Figure',plotPanel)); | |
530 elseif isa(val, 'xyzdata') | |
531 str = 'X-Y-Z Data Object'; | |
532 elseif isa(val, 'history') | |
533 str = 'History Object'; | |
534 if length(val) == 1 | |
535 pl = plist(param('stop_option', MAX_HIST_DEPTH)); | |
536 plot(haxes, val, pl); | |
537 ii = strfind(plotted, 'inhists'); | |
538 title(haxes, sprintf('History-Level: %d', length(ii)+1)) | |
539 else | |
540 c_str{1} = 'Select the left or right branch.'; | |
541 end | |
542 | |
543 elseif isa(val, 'param') | |
544 if length(val) == 1 | |
545 str = char(val); | |
546 c_str = split_by_comma(str); | |
547 else | |
548 for ii = 1:length(val) | |
549 str = char(val(ii)); | |
550 c_str1 = split_by_comma(str, '- '); | |
551 c_str(end+1:end+length(c_str1)) = c_str1; | |
552 end | |
553 end | |
554 str = 'Parameter Object'; | |
555 | |
556 elseif isa(val, 'plist') | |
557 if numel(val) > 1 | |
558 c_str{1} = 'select a plist'; | |
559 else | |
560 for ii=1:length(val.params) | |
561 | |
562 str = char(val.params(ii)); | |
563 c_str1 = split_by_comma(str, '- '); | |
564 c_str(end+1:end+length(c_str1)) = strrep(c_str1, '_', '\_'); | |
565 end | |
566 end | |
567 str = 'Parameter List Object'; | |
568 | |
569 elseif isa(val, 'mfir') | |
570 str = 'FIR Filter Object'; | |
571 elseif isa(val, 'miir') | |
572 str = 'IIR Filter Object'; | |
573 elseif isa(val, 'provenance') | |
574 str = 'Provenance Object'; | |
575 elseif isa(val, 'pzmodel') | |
576 str = 'Pole Zero Object'; | |
577 elseif isa(val, 'specwin') | |
578 str = 'Spectral Window Object'; | |
579 elseif isa(val, 'pz') | |
580 str = 'Pole/Zero Object'; | |
581 elseif isa(val, 'time') | |
582 str = 'Time Object'; | |
583 elseif isa(val, 'timespan') | |
584 str = 'Time span Object'; | |
585 elseif isa(val, 'ssm') | |
586 str = 'statespace model Object'; | |
587 elseif isa(val, 'unit') | |
588 str = 'Unit Object'; | |
589 elseif isa(val, 'minfo') | |
590 str = 'Method info Object'; | |
591 else | |
592 cl = class(val); | |
593 str = sprintf('%s%s Object', upper(cl(1)), lower(cl(2:end))); | |
594 end | |
595 | |
596 elseif iscell(val) | |
597 for i = 1:min(length(val),3) | |
598 if ischar(val{i}) | |
599 str = strcat(str, val{i}); | |
600 elseif isnumeric(val) | |
601 str = strcat(str, num2str(val{i})); | |
602 end | |
603 if i < min(length(val),3) | |
604 str = strcat(str, ','); | |
605 end | |
606 end | |
607 if length(val) > 3 | |
608 str = strcat(str,'...'); | |
609 end | |
610 | |
611 end | |
612 | |
613 if ~isempty(c_str) | |
614 c_str = strtrim(c_str); | |
615 na = text(0.5,0.5,c_str); | |
616 txt_extent = get(na, 'Extent'); | |
617 set(na, 'Position', [0.5-txt_extent(3)/2, 0.5], ... | |
618 'HorizontalAlignment', 'left', ... | |
619 'Color', 'k', ... | |
620 'FontWeight', 'bold', ... | |
621 'EdgeColor', 'k', ... | |
622 'BackgroundColor', 'w', ... | |
623 'Fontsize', 10, ... | |
624 'Margin', 5); | |
625 end | |
626 | |
627 else % ~isempty(val) | |
628 str = 'The field is empty'; | |
629 end | |
630 set(txt4, 'string', str) | |
631 warning('off','MATLAB:hg:JavaSetHGProperty'); | |
632 set(tmp, 'UserData', cell_Data); | |
633 warning('on','MATLAB:hg:JavaSetHGProperty'); | |
634 end | |
635 | |
636 | |
637 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
638 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
639 | |
640 end | |
641 | |
642 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
643 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
644 function nodes = myExpfcn4(tree,value) | |
645 | |
646 tmp = tree.FigureComponent; | |
647 warning('off','MATLAB:hg:JavaSetHGProperty'); | |
648 S = get(tmp, 'UserData'); | |
649 warning('on','MATLAB:hg:JavaSetHGProperty'); | |
650 s = S{1}; | |
651 cNode = S{2}; | |
652 [val, cNode] = getcNodevalue(cNode, s); | |
653 | |
654 % Set the path to the *.gif files | |
655 % This tis the current path of this function + 'exp_struct_icons' | |
656 pth = ''; | |
657 eval (sprintf('pth = which(''%s'');',mfilename)) | |
658 index = find(pth==filesep, 1, 'last'); | |
659 pth = pth(1:index); | |
660 pth = [pth 'exp_struct_icons' filesep]; | |
661 | |
662 [n,m] = size(val); | |
663 count = 0; | |
664 | |
665 %%% Vector or Matrix | |
666 if m>1 || n>1 | |
667 | |
668 if isa(val, 'ao') | |
669 iconpath =[pth,'analysis_object.gif']; | |
670 else | |
671 iconpath =[pth,'struct_icon.gif']; | |
672 end | |
673 | |
674 %%% Vector | |
675 if m==1 || n==1 | |
676 L = length(val); | |
677 | |
678 for J = 1:L | |
679 count = count + 1; | |
680 cNode = S{2}; | |
681 | |
682 level = cNode.getLevel; | |
683 fname = strcat(cNode.getValue, '(', num2str(J),')'); | |
684 | |
685 if level==0 && ~isempty(S{3}) && numel(S{3}) == numel(S{1}) | |
686 node_str = S{3}(J); | |
687 else | |
688 node_str = fname; | |
689 end | |
690 | |
691 nodes(count) = uitreenode('v0',fname, node_str, iconpath, 0); | |
692 end | |
693 %%% Matrix | |
694 else | |
695 | |
696 for ii=1:n | |
697 for jj=1:m | |
698 count = count + 1; | |
699 cNode = S{2}; | |
700 fname = [cNode.getValue '(' num2str(ii) ',' num2str(jj) ')']; | |
701 nodes(count) = uitreenode('v0',fname, fname, iconpath, 0); | |
702 end | |
703 end | |
704 | |
705 end | |
706 %%% Struct, Object or single value | |
707 else | |
708 %%% | |
709 val = val; | |
710 if ~isempty(val) | |
711 fnames = fieldnames(val); | |
712 else | |
713 fnames = {}; | |
714 end | |
715 | |
716 for i=1:length(fnames) | |
717 count = count + 1; | |
718 x = getfield(val,fnames{i}); | |
719 | |
720 if isa(x, 'ao') | |
721 iconpath =[pth,'analysis_object.gif']; | |
722 elseif isa(x, 'tsdata') | |
723 iconpath =[pth,'ts_data.gif']; | |
724 elseif isa(x, 'fsdata') | |
725 iconpath =[pth,'fs_data.gif']; | |
726 elseif isa(x, 'xydata') | |
727 iconpath =[pth,'xy_data.gif']; | |
728 elseif isa(x, 'cdata') | |
729 iconpath =[pth,'c_data.gif']; | |
730 elseif isa(x, 'history') | |
731 iconpath =[pth,'history.gif']; | |
732 elseif isa(x, 'plist') | |
733 iconpath =[pth,'plist.gif']; | |
734 | |
735 elseif isstruct(x) | |
736 if length(x) > 1 | |
737 iconpath =[pth,'structarray_icon.gif']; | |
738 else | |
739 iconpath =[pth,'struct_icon.gif']; | |
740 end | |
741 elseif isnumeric(x) | |
742 iconpath =[pth,'double_icon.gif']; | |
743 elseif iscell(x) | |
744 iconpath =[pth,'cell_icon.gif']; | |
745 elseif ischar(x) | |
746 iconpath =[pth,'char_icon.gif']; | |
747 elseif islogical(x) | |
748 iconpath =[pth,'logic_icon.gif']; | |
749 elseif isobject(x) | |
750 iconpath =[pth,'obj_icon.gif']; | |
751 else | |
752 iconpath =[pth,'unknown_icon.gif']; | |
753 end | |
754 | |
755 if isstruct(x) || isobject(x) | |
756 isLeaf = 0; | |
757 else | |
758 isLeaf = 1; | |
759 end | |
760 | |
761 nodes(count) = uitreenode('v0',fnames{i}, fnames{i}, iconpath, isLeaf); | |
762 end | |
763 end | |
764 | |
765 if (count == 0) | |
766 nodes = []; | |
767 end | |
768 end | |
769 | |
770 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
771 | |
772 function cNode = nodeWillExpand_cb4(tree,ev) | |
773 cNode = ev.getCurrentNode; | |
774 tmp = tree.FigureComponent; | |
775 warning('off','MATLAB:hg:JavaSetHGProperty'); | |
776 cell_Data = get(tmp, 'UserData'); | |
777 cell_Data{2} = cNode; | |
778 set(tmp, 'UserData', cell_Data); | |
779 warning('on','MATLAB:hg:JavaSetHGProperty'); | |
780 end | |
781 | |
782 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
783 function [val, displayed, cNode] = getcNodevalue(cNode, s) | |
784 | |
785 fields = {}; | |
786 while cNode.getLevel ~=0 | |
787 fields = [fields; cNode.getValue]; | |
788 c = findstr(cNode.getValue, '('); | |
789 if ~isempty(c) && cNode.getLevel ~=0 | |
790 cNode = cNode.getParent; | |
791 end | |
792 | |
793 if cNode.getLevel ==0, break; end | |
794 cNode = cNode.getParent; | |
795 end | |
796 | |
797 val = s; | |
798 | |
799 if ~isempty(fields) | |
800 L=length(fields); | |
801 displayed = fields{L}; | |
802 % create the variable: displayed | |
803 for j = L-1:-1:1 | |
804 displayed = strcat(displayed, '.', fields{j}); | |
805 end | |
806 | |
807 for i = L:-1:1 | |
808 field = fields{i}; | |
809 von = findstr(field,'('); | |
810 bis = findstr(field,')'); | |
811 if ~isempty(von) | |
812 | |
813 idx = field(von+1:bis-1); | |
814 field = field(1:von-1); | |
815 if (strcmp(field, cNode.getValue)) | |
816 cmd = sprintf('val = val(%s);',idx); | |
817 eval(cmd); | |
818 if iscell(val) && numel(val) == 1 | |
819 val = val{1}; | |
820 else | |
821 error('################ MAch mich neu'); | |
822 end | |
823 else | |
824 cmd = sprintf('val = getfield(val, field, {%s});',idx); | |
825 eval(cmd); | |
826 if iscell(val) && numel(val) == 1 | |
827 val = val{1}; | |
828 end | |
829 | |
830 end | |
831 | |
832 else | |
833 if iscell(val) && numel(val) == 1 | |
834 val = val{1}; | |
835 elseif numel(val) ~= 1 | |
836 error('################ MAch mich neu'); | |
837 end | |
838 val = getfield(val, field); | |
839 end | |
840 end | |
841 else | |
842 displayed = cNode.getValue; | |
843 if iscell(val) && numel(val) == 1 | |
844 val = val{1}; | |
845 else | |
846 end | |
847 return; | |
848 end | |
849 end | |
850 | |
851 | |
852 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
853 function c_str = split_by_comma(str, pref) | |
854 | |
855 if nargin < 2 | |
856 pref = ''; | |
857 end | |
858 | |
859 c_str = {}; | |
860 c_str{1} = str; | |
861 index = find(str==','); | |
862 von = 1; | |
863 for ii = 1:length(index) | |
864 bis = index(ii)-1; | |
865 c_str{ii} = [pref str(von:bis)]; | |
866 von = bis + 2; | |
867 end | |
868 if ~isempty(index) | |
869 c_str{ii+1} = [pref str(von:end)]; | |
870 end | |
871 | |
872 c_str = strtrim(c_str); | |
873 end |