Home > m > gui > ao_browser > explore_ao.m

explore_ao

PURPOSE ^

EXPLORE_AO for exploring analysis objects and plotting/displaying their fields

SYNOPSIS ^

function explore_ao(varargin)

DESCRIPTION ^

 EXPLORE_AO for exploring analysis objects and plotting/displaying their fields

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

 DESCRIPTION: EXPLORE_AO for exploring analysis objects and plotting/displaying
              their fields. It is possible to browse througth the history tree
              to see only a part of this tree. If the user will use the plot
              function the plot will be printed in a new figure.

 CALL:    explore_ao;              % Read the ao's from the'base' workspace
          explore_ao(ao);
          explore_ao(ao_vector);
          explore_ao(ao_matrix);

 HINT:    The idea and the core source code are taken from:
            Hassan Lahdili (hassan.lahdili@crc.ca)
            Communications Research Centre (CRC) | Advanced Audio Systems (AAS)
            www.crc.ca | www.crc.ca/aas
            Ottawa. Canada
            CRC Advanced Audio Systems - Ottawa 16/02/2005 2004-2005

 VERSION: $Id: explore_ao.m,v 1.8 2007/07/30 12:09:28 ingo Exp $

 HISTORY: 10-06-07 Diepholz
             Creation

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function explore_ao(varargin)
0002 % EXPLORE_AO for exploring analysis objects and plotting/displaying their fields
0003 %
0004 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0005 %
0006 % DESCRIPTION: EXPLORE_AO for exploring analysis objects and plotting/displaying
0007 %              their fields. It is possible to browse througth the history tree
0008 %              to see only a part of this tree. If the user will use the plot
0009 %              function the plot will be printed in a new figure.
0010 %
0011 % CALL:    explore_ao;              % Read the ao's from the'base' workspace
0012 %          explore_ao(ao);
0013 %          explore_ao(ao_vector);
0014 %          explore_ao(ao_matrix);
0015 %
0016 % HINT:    The idea and the core source code are taken from:
0017 %            Hassan Lahdili (hassan.lahdili@crc.ca)
0018 %            Communications Research Centre (CRC) | Advanced Audio Systems (AAS)
0019 %            www.crc.ca | www.crc.ca/aas
0020 %            Ottawa. Canada
0021 %            CRC Advanced Audio Systems - Ottawa 16/02/2005 2004-2005
0022 %
0023 % VERSION: $Id: explore_ao.m,v 1.8 2007/07/30 12:09:28 ingo Exp $
0024 %
0025 % HISTORY: 10-06-07 Diepholz
0026 %             Creation
0027 %
0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0029 
0030 
0031 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0032 %        Define the Positions         %
0033 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0034 
0035 % figure position
0036 FIG_X   = .150;
0037 FIG_Y   = .150;
0038 FIG_dX  = .700;
0039 FIG_dY = .600;
0040 
0041 % tree position
0042 TREE_X  = .000;
0043 TREE_Y  = .000;
0044 TREE_dX = .350;
0045 TREE_dY = 1.000;
0046 
0047 % plot field position
0048 PLOT_X  = .370;
0049 PLOT_Y  = .105;
0050 PLOT_dX = .610;
0051 PLOT_dY = .720;
0052 
0053 % display field position
0054 DISP_X  = TREE_X;
0055 DISP_Y  = .750;
0056 DISP_dX = TREE_dX;
0057 DISP_dY = 1-DISP_Y;
0058 
0059 % explorer name position
0060 EXPL_NAME_dX = .370;
0061 EXPL_NAME_dY = .045;
0062 EXPL_NAME_X  = PLOT_X+(PLOT_dX-EXPL_NAME_dX)/2;
0063 EXPL_NAME_Y  = .030;
0064 % EXPL_NAME_Y  = .065;
0065 
0066 % info fields position
0067 N_INFOS = 3;
0068 
0069 INFO_X  = PLOT_X;
0070 INFO_Y  = .915;
0071 INFO_dX = PLOT_dX / N_INFOS;
0072 INFO_dY = .034;
0073 
0074 BG_COLOR = [.925 .914 .847];
0075 
0076 MAX_HIST_DEPTH = 4;
0077 
0078 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0079 %           Check the input           %
0080 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0081 
0082 a      = [];
0083 ao_value = [];
0084 ao_name  = {};
0085 
0086 % Read the ao's from the 'base' workspace
0087 if nargin==0
0088 
0089   tree_name = 'ao_ws';
0090 
0091   ws_vars = evalin('base','whos');
0092 
0093   for ii=1:length(ws_vars)
0094     if strcmp(ws_vars(ii).class, 'ao')
0095 
0096       cmd = sprintf('a = evalin(''base'', ''%s'');', ws_vars(ii).name);
0097       eval(cmd)
0098 
0099       % the ao in the workspace is a single value
0100       if length(a) == 1
0101         %       a = reshape(a, 1, []);
0102         ao_value       = [ao_value a];
0103         ao_name{end+1} = ws_vars(ii).name;
0104       else
0105 
0106         [n,m] = size(a);
0107 
0108         % the ao in the workspace is a vector
0109         if n == 1 || m == 1
0110 
0111           for jj=1:length(a)
0112             ao_value       = [ao_value a(jj)];
0113             ao_name{end+1} = [ws_vars(ii).name '(' num2str(jj) ')'];
0114           end
0115 
0116         % the ao in the workspace is a matrix
0117         elseif n > 1 && m > 1
0118 
0119           for gg = 1:n
0120             for hh = 1:m
0121               ao_value       = [ao_value a(gg,hh)];
0122               ao_name{end+1} = [ws_vars(ii).name '(' num2str(gg) ',' num2str(hh) ')'];
0123             end
0124           end
0125 
0126         else
0127           error ('### this should not happen.');
0128         end
0129 
0130       end
0131 
0132     end
0133   end
0134 
0135 elseif nargin == 1
0136 
0137   tree_name = inputname(1);
0138   ao_value  = varargin{:};
0139   ao_name   = inputname(1);
0140 
0141 else
0142   error ('### only use no or one input.')
0143 end
0144 
0145 fig_name = ['explore the analysis object: ' tree_name];
0146 
0147 % Define figure
0148 fig = figure('Units',       'normalized',     ...
0149              'NextPlot',    'add',            ...
0150              'NumberTitle', 'off',            ...
0151              'Toolbar',     'none',           ...
0152              'name',         fig_name,        ...
0153              'Color',        BG_COLOR,        ...
0154              'Position',    [FIG_X  FIG_Y     ...
0155                              FIG_dX FIG_dY]);
0156 
0157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0158 %           Define the tree           %
0159 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0160 
0161 root = ltpda_uitreenode(tree_name, tree_name, [], false);
0162 tree = ltpda_uitree( fig,'Root',       root,             ...
0163                          'ExpandFcn', @myExpfcn4);
0164 set(tree, 'Units',                 'normalized',         ...
0165           'position',               [TREE_X  TREE_Y      ...
0166                                      TREE_dX TREE_dY],   ...
0167           'NodeWillExpandCallback', @nodeWillExpand_cb4, ...
0168           'NodeSelectedCallback',   @nodeSelected_cb4);
0169 tmp = tree.FigureComponent;
0170 cell_Data = cell(3,1);
0171 
0172 % cell_Data{1} = varargin{:};
0173 cell_Data{1} = ao_value;
0174 cell_Data{3} = ao_name;
0175 
0176 set(tmp, 'UserData', cell_Data);
0177 
0178 
0179 % Define the plot field
0180 haxes = axes('Units',   'normalized',       ...
0181              'Position', [PLOT_X  PLOT_Y    ...
0182                           PLOT_dX PLOT_dY], ...
0183              'Box',     'on',               ...
0184              'XTick',    [],                ...
0185              'YTick',    []);
0186 
0187 box  off;
0188 axis off;
0189 
0190 % Define the info fields 'name'
0191 txt1 = uicontrol('String',          '',                 ...
0192                  'Units',           'normalized',       ...
0193                  'Style',           'Edit',             ...
0194                  'Position',         [INFO_X  INFO_Y    ...
0195                                       INFO_dX INFO_dY], ...
0196                  'BackgroundColor',   BG_COLOR);
0197 % Define the info fields 'size'
0198 txt2 = uicontrol('String',         '',                          ...
0199                  'Units',          'normalized',                ...
0200                  'Style',          'Edit',                      ...
0201                  'Position',        [(INFO_X+INFO_dX) INFO_Y    ...
0202                                       INFO_dX          INFO_dY],...
0203                  'BackgroundColor',   BG_COLOR);
0204 % Define the info fields 'class'
0205 txt3 = uicontrol('String',         '',                          ...
0206                  'Units',          'normalized',                ...
0207                  'Style',          'Edit',                      ...
0208                  'Position',        [(INFO_X+2*INFO_dX) INFO_Y  ...
0209                                       INFO_dX          INFO_dY],...
0210                  'BackgroundColor',   BG_COLOR);
0211 % Define the info fields 'value'
0212 txt4 = uicontrol('String',         '',                          ...
0213                  'Units',          'normalized',                ...
0214                  'Style',          'Edit',                      ...
0215                  'Position',        [  INFO_X  (INFO_Y-INFO_dY) ...
0216                                      3*INFO_dX  INFO_dY],       ...
0217                  'BackgroundColor',   BG_COLOR);
0218 
0219 % Define the info fields 'value'
0220 txt5 = uicontrol('String',          '',                  ...
0221                  'Units',           'normalized',        ...
0222                  'Style',           'listbox',           ...
0223                  'Visible',         'off',               ...
0224                  'Fontsize',         8,                  ...
0225                  'Position',        [DISP_X   DISP_Y     ...
0226                                      DISP_dX  DISP_dY],  ...
0227                  'BackgroundColor',  BG_COLOR);
0228 
0229 
0230 
0231 % Define the decription of the info fields
0232 col1 = uicontrol('String',         'Name',                   ...
0233                  'Units',          'normalized',             ...
0234                  'Style',          'Text',                   ...
0235                  'Position',        [INFO_X  (INFO_Y+INFO_dY)...
0236                                      INFO_dX  INFO_dY],      ...
0237                  'BackgroundColor',  BG_COLOR);
0238 col2 = uicontrol('String',         'Size',                            ...
0239                  'Units',          'normalized',                      ...
0240                  'Style',          'Text',                            ...
0241                  'Position',        [(INFO_X+INFO_dX) (INFO_Y+INFO_dY)...
0242                                       INFO_dX          INFO_dY],      ...
0243                  'BackgroundColor',   BG_COLOR);
0244 col3 = uicontrol('String',         'Class',                             ...
0245                  'Units',          'normalized',                        ...
0246                  'Style',          'Text',                              ...
0247                  'Position',        [(INFO_X+2*INFO_dX) (INFO_Y+INFO_dY)...
0248                                       INFO_dX            INFO_dY],      ...
0249                  'BackgroundColor',   BG_COLOR);
0250 
0251 % Define the name of the explorer
0252 expl_name = uicontrol('String',         'Analysis Object explorer',  ...
0253                       'Units',          'normalized',                ...
0254                       'Style',          'text',                      ...
0255                       'Position',        [EXPL_NAME_X  EXPL_NAME_Y   ...
0256                                           EXPL_NAME_dX EXPL_NAME_dY],...
0257                       'ForeGroundColor', [0.2 0.4 1],                ...
0258                       'FontSize',         18,                        ...
0259                       'FontWeight',     'bold',                      ...
0260                       'FontAngle',      'italic');
0261 
0262 tree_menu  = uicontextmenu();
0263 tree_menu1 = uimenu(tree_menu, 'Label',   'Plot', ...
0264                                'Callback', @f_tree_menu1);
0265 tree_menu2 = uimenu(tree_menu, 'Label',   'Display', ...
0266                                'Callback', @f_tree_menu2);
0267 
0268 disp_menu  = uicontextmenu;
0269 disp_menu1 = uimenu(disp_menu, 'Label',   'close', ...
0270                                'Callback', @f_disp_menu1);
0271 
0272 set(tree.Tree, 'MousePressedCallback', @mouse_cb);
0273 set(tree.Tree, 'UIContextMenu', tree_menu);
0274 
0275 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0276 % Mouse Pressed Handler
0277     function mouse_cb(h, ev)
0278         if ev.getModifiers()== ev.META_MASK
0279           % Workaround to set the y position
0280           % Workaround to set the x position
0281           vis = get(get(ev, 'Component'), 'VisibleRect');
0282           x_width  = get(get(ev, 'Component'), 'Width');
0283           y_height = get(get(ev, 'Component'), 'Height');
0284 
0285           new_x =  ev.getX-vis(1);
0286           new_y = -ev.getY+y_height-(y_height-vis(4));
0287           set(tree_menu, 'Position',  [new_x new_y], ...
0288                          'Visible',  'on');
0289         end
0290 
0291     end
0292 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0293     function f_disp_menu1(h, ev)
0294       set(txt5, 'Visible', 'off')
0295       set(tree, 'position', [TREE_X  TREE_Y    ...
0296                              TREE_dX TREE_dY])
0297     end
0298 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0299     function f_tree_menu1(h,ev)
0300         plotselected_cb;
0301     end
0302 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0303     function f_tree_menu2(h,ev)
0304         displayselected_cb;
0305     end
0306 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0307     function plotselected_cb(h, ev)
0308 
0309       tmp =  tree.FigureComponent;
0310       S = get(tmp, 'UserData');
0311       s = S{1};
0312       cNode = S{2};
0313       [val, plotted, cNode] = getcNodevalue(cNode, s);
0314 
0315       cla(haxes)
0316 
0317       if (isa(val,'history'))
0318         if length(val) == 1
0319           figure;
0320           plot (val);
0321           ii = strfind(plotted, 'inhists');
0322           title(haxes, sprintf('History-Level: %d', length(ii)+1))
0323         else
0324           na = text(0.5,0.5,'Select the left or right branch.');
0325           set(na, 'HorizontalAlignment', 'center', ...
0326             'Color',               'r',      ...
0327             'FontWeight',          'bold',   ...
0328             'EdgeColor',           'k',      ...
0329             'BackgroundColor',     'w',      ...
0330             'Fontsize',             10,      ...
0331             'Margin',               5);
0332         end
0333       elseif isa(val,'fsdata') || isa(val,'tsdata') || ...
0334              isa(val,'xydata') || isa(val,'cdata')
0335         figure;
0336         plot(ao(val))
0337       % Is the parent node == 'data' so plot data
0338       else
0339 
0340         cNode  = S{2};
0341         parent = '';
0342 
0343         if cNode.getLevel >= 1
0344           parent  = cNode.getParent;
0345         end
0346 
0347         if strcmp(parent.getValue, 'data')
0348           grandpa = parent.getParent;
0349           grandpa_val = grandpa.getValue;
0350           von = findstr(grandpa_val,'(');
0351           bis = findstr(grandpa_val,')');
0352           if ~isempty(von) && ~isempty(bis)
0353             index = grandpa_val(von+1:bis-1);
0354           else
0355             index = '1';
0356           end
0357 
0358           eval (sprintf('val = S{1}(%s);',index))
0359           figure;
0360           plot(val);
0361         end
0362 
0363       end
0364 
0365     end
0366 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0367     function displayselected_cb(h, ev)
0368       tmp =  tree. FigureComponent;
0369       S = get(tmp, 'UserData');
0370       s = S{1};
0371       cNode = S{2};
0372       [val, displayed, cNode] = getcNodevalue(cNode, s);
0373 
0374       text1 = '';
0375       if isobject(val)
0376         text1 = display(val);
0377       else
0378         disp(val)
0379       end
0380 
0381       % some sisplay outputs contains '\n' <-> char(10)
0382       % text can not display this character so replace it with '   '
0383       text1 = strrep(text1, char(10), '  ');
0384 
0385       set(tree, 'position', [TREE_X  TREE_Y      ...
0386                              TREE_dX TREE_dY-DISP_dY]);
0387       set(txt5, 'string', text1);
0388       set(txt5, 'Visible', 'on');
0389       set(txt5, 'UIContextMenu', disp_menu);
0390     end
0391 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0392 
0393     function cNode = nodeSelected_cb4(tree,ev)
0394       cNode = ev.getCurrentNode;
0395       tmp = tree.FigureComponent;
0396       cell_Data = get(tmp, 'UserData');
0397       cell_Data{2} = cNode;
0398       s = cell_Data{1};
0399       val = s;
0400       plotted = cNode.getValue;
0401       selected = plotted;
0402       [val, plotted, cNode] = getcNodevalue(cNode, val);
0403       set(txt1, 'string', selected)
0404       set(txt2, 'string', strcat(num2str(size(val,1)),'x',num2str(size(val,2))) )
0405       set(txt3, 'string', class(val))
0406 
0407       str = ' ';
0408       c_str = {};
0409       cla(haxes)
0410 
0411       if ~isempty(val)
0412 
0413         if isnumeric(val)
0414           %normalize the vector
0415           si = size(val);
0416           if si(1) > si(2)
0417             val = val.';
0418           else
0419             val = val;
0420           end
0421           if size(val,1) == 1 || size(val,2) == 1
0422             if length(val) > 3
0423               str = strcat(num2str(val(1:3)), '  ...');
0424             end
0425           else
0426             str = 'Matrix';
0427           end
0428 
0429         elseif ischar(val)
0430           str = val;
0431 
0432         elseif islogical(val)
0433           if val
0434             str = 'true';
0435           else
0436             str = 'false';
0437           end
0438 
0439         elseif isobject(val)
0440           if isa(val, 'ao')
0441             str = 'Analysis Object';
0442           elseif isa(val, 'cdata')
0443             str = 'C-Data Object';
0444           elseif isa(val, 'fsdata')
0445             str = 'Frequency-Series Object';
0446           elseif isa(val, 'tsdata')
0447             str = 'Time-Series Object';
0448           elseif isa(val, 'xydata')
0449             str = 'X-Y Data Object';
0450 
0451           elseif isa(val, 'history')
0452             str = 'History Object';
0453             if length(val) == 1
0454               pl = plist(param('max_depth', MAX_HIST_DEPTH));
0455               plot(haxes, val, pl);
0456               ii = strfind(plotted, 'inhists');
0457               title(haxes, sprintf('History-Level: %d', length(ii)+1))
0458             else
0459               c_str{1} = 'Select the left or right branch.';
0460             end
0461 
0462           elseif isa(val, 'param')
0463             if length(val) == 1
0464               str   = char(val);
0465               c_str = split_by_comma(str);
0466             else
0467               for ii = 1:length(val)
0468                 str = char(val(ii));
0469                 c_str1 = split_by_comma(str, '- ');
0470                 c_str(end+1:end+length(c_str1)) = c_str1;
0471               end
0472             end
0473             str = 'Parameter Object';
0474 
0475           elseif isa(val, 'plist')
0476             for ii=1:length(val.params)
0477               str = char(val.params(ii));
0478               c_str1 = split_by_comma(str, '- ');
0479               c_str(end+1:end+length(c_str1)) = c_str1;
0480             end
0481             str = 'Parameter List Object';
0482 
0483           elseif isa(val, 'mfir')
0484             str = 'FIR Filter Object';
0485           elseif isa(val, 'miir')
0486             str = 'IIR Filter Object';
0487           elseif isa(val, 'pole')
0488             str = 'Pole Object';
0489           elseif isa(val, 'provenance')
0490             str = 'Provenance Object';
0491           elseif isa(val, 'pzmodel')
0492             str = 'Pole Zero Object';
0493           elseif isa(val, 'specwin')
0494             str = 'Spectral Window Object';
0495           elseif isa(val, 'zero')
0496             str = 'Zero Object';
0497           elseif isa(val, 'time')
0498             str = 'Time Object';
0499           else
0500             str = 'Unknown class';
0501           end
0502 
0503         elseif iscell(val)
0504           for i = 1:min(length(val),3)
0505             if ischar(val{i})
0506               str = strcat(str, val{i});
0507             elseif isnumeric(val)
0508               str = strcat(str, num2str(val{i}));
0509             end
0510             if i < min(length(val),3)
0511               str = strcat(str, ',');
0512             end
0513           end
0514           if length(val) > 3
0515             str = strcat(str,'...');
0516           end
0517 
0518         end
0519 
0520         if ~isempty(c_str)
0521           c_str = strtrim(c_str);
0522           na = text(0.5,0.5,c_str);
0523           txt_extent = get(na, 'Extent');
0524           set(na, 'Position',            [0.5-txt_extent(3)/2, 0.5], ...
0525                   'HorizontalAlignment', 'left', ...
0526                   'Color',               'k',    ...
0527                   'FontWeight',          'bold', ...
0528                   'EdgeColor',           'k',    ...
0529                   'BackgroundColor',     'w',    ...
0530                   'Fontsize',            10,     ...
0531                   'Margin',              5);
0532         end
0533 
0534       else % ~isempty(val)
0535         str = 'The field is empty';
0536       end
0537       set(txt4, 'string', str)
0538       set(tmp, 'UserData', cell_Data);
0539     end
0540 
0541 
0542 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0543 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0544 
0545 end
0546 
0547 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0548 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0549     function nodes = myExpfcn4(tree,value)
0550 
0551       tmp = tree.FigureComponent;
0552       S = get(tmp, 'UserData');
0553       s = S{1};
0554       cNode = S{2};
0555       [val, cNode] = getcNodevalue(cNode, s);
0556       fnames = fieldnames(val);
0557 
0558       % Set the path to the *.gif files
0559       % This tis the current path of this function + 'exp_struct_icons'
0560       pth = '';
0561       eval (sprintf('pth = which(''%s'');',mfilename))
0562       index = find(pth==filesep, 1, 'last');
0563       pth = pth(1:index);
0564       pth = [pth 'exp_struct_icons' filesep];
0565 
0566       [n,m] = size(val);
0567       count = 0;
0568 
0569       %% Vector or Matrix
0570       if m>1 || n>1
0571 
0572         if isa(val, 'ao')
0573           iconpath =[pth,'analysis_object.gif'];
0574         else
0575           iconpath =[pth,'struct_icon.gif'];
0576         end
0577 
0578         %% Vector
0579         if m==1 || n==1
0580           L = length(val);
0581 
0582           for J = 1:L
0583             count = count + 1;
0584             cNode = S{2};
0585 
0586             level = cNode.getLevel;
0587             fname = strcat(cNode.getValue, '(', num2str(J),')');
0588 
0589             if level==0 && ~isempty(S{3}) && numel(S{3}) == numel(S{1})
0590               node_str = S{3}(J);
0591             else
0592               node_str = fname;
0593             end
0594 
0595             nodes(count) =  ltpda_uitreenode(fname, node_str, iconpath, 0);
0596           end
0597         %% Matrix
0598         else
0599 
0600           for ii=1:n
0601             for jj=1:m
0602               count = count + 1;
0603               cNode = S{2};
0604               fname = [cNode.getValue '(' num2str(ii) ',' num2str(jj) ')'];
0605               nodes(count) =  ltpda_uitreenode(fname, fname, iconpath, 0);
0606             end
0607           end
0608 
0609         end
0610       %% Struct, Object or single value
0611       else
0612         %%
0613         for i=1:length(fnames)
0614           count = count + 1;
0615           x = getfield(val,fnames{i});
0616 
0617           if isa(x, 'ao')
0618             iconpath =[pth,'analysis_object.gif'];
0619           elseif isa(x, 'tsdata')
0620             iconpath =[pth,'ts_data.gif'];
0621           elseif isa(x, 'fsdata')
0622             iconpath =[pth,'fs_data.gif'];
0623           elseif isa(x, 'xydata')
0624             iconpath =[pth,'xy_data.gif'];
0625           elseif isa(x, 'cdata')
0626             iconpath =[pth,'c_data.gif'];
0627           elseif isa(x, 'history')
0628             iconpath =[pth,'history.gif'];
0629           elseif isa(x, 'plist')
0630             iconpath =[pth,'plist.gif'];
0631 
0632           elseif isstruct(x)
0633             if length(x) > 1
0634               iconpath =[pth,'structarray_icon.gif'];
0635             else
0636               iconpath =[pth,'struct_icon.gif'];
0637             end
0638           elseif isnumeric(x)
0639             iconpath =[pth,'double_icon.gif'];
0640           elseif iscell(x)
0641             iconpath =[pth,'cell_icon.gif'];
0642           elseif ischar(x)
0643             iconpath =[pth,'char_icon.gif'];
0644           elseif islogical(x)
0645             iconpath =[pth,'logic_icon.gif'];
0646           elseif isobject(x)
0647             iconpath =[pth,'obj_icon.gif'];
0648           else
0649             iconpath =[pth,'unknown_icon.gif'];
0650           end
0651 
0652           if isstruct(x) || isobject(x)
0653             isLeaf = 0;
0654           else
0655             isLeaf = 1;
0656           end
0657 
0658           nodes(count) = ltpda_uitreenode(fnames{i}, fnames{i}, iconpath, isLeaf);
0659         end
0660       end
0661 
0662       if (count == 0)
0663         nodes = [];
0664       end
0665     end
0666 
0667 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0668 
0669     function cNode = nodeWillExpand_cb4(tree,ev)
0670         cNode = ev.getCurrentNode;
0671         tmp = tree.FigureComponent;
0672         cell_Data = get(tmp, 'UserData');
0673         cell_Data{2} = cNode;
0674         set(tmp, 'UserData', cell_Data);
0675     end
0676 
0677 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0678     function [val, displayed, cNode] = getcNodevalue(cNode, s)
0679 
0680       fields = {};
0681       while cNode.getLevel ~=0
0682         fields = [fields; cNode.getValue];
0683         c = findstr(cNode.getValue, '(');
0684         if ~isempty(c) && cNode.getLevel ~=0
0685           cNode = cNode.getParent;
0686         end
0687 
0688         if  cNode.getLevel ==0, break; end
0689         cNode = cNode.getParent;
0690       end
0691 
0692       val = s;
0693 
0694         if ~isempty(fields)
0695           L=length(fields);
0696           displayed = fields{L};
0697           % create the variable: displayed
0698           for j = L-1:-1:1
0699             displayed = strcat(displayed, '.', fields{j});
0700           end
0701 
0702           for i = L:-1:1
0703             field = fields{i};
0704             von = findstr(field,'(');
0705             bis = findstr(field,')');
0706             if ~isempty(von)
0707 
0708               idx = field(von+1:bis-1);
0709               field = field(1:von-1);
0710               if (strcmp(field, cNode.getValue))
0711                 cmd = sprintf('val = val(%s);',idx);
0712                 eval(cmd);
0713               else
0714                 cmd = sprintf('val = getfield(val, field, {%s});',idx);
0715                 eval(cmd);
0716               end
0717 
0718             else
0719               val = getfield(val, field);
0720             end
0721           end
0722         else
0723           displayed = cNode.getValue;
0724           return;
0725         end
0726     end
0727 
0728 
0729 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0730     function c_str = split_by_comma(str, pref)
0731 
0732       if nargin < 2
0733         pref = '';
0734       end
0735 
0736       c_str = {};
0737       c_str{1} = str;
0738       index    = find(str==',');
0739       von      = 1;
0740       for ii = 1:length(index)
0741         bis = index(ii)-1;
0742         c_str{ii} = [pref str(von:bis)];
0743         von = bis + 2;
0744       end
0745       if ~isempty(index)
0746         c_str{ii+1} = [pref str(von:end)];
0747       end
0748 
0749       c_str = strtrim(c_str);
0750     end
0751

Generated on Mon 03-Sep-2007 12:12:34 by m2html © 2003