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.6 2007/06/20 11:32:38 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.6 2007/06/20 11:32:38 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             else
0425               % Special case: Transform the date-number into a string
0426               if strcmp(selected, 'created')
0427                 str = datestr(val,31);
0428               else
0429                 str = num2str(val);
0430               end
0431             end
0432           else
0433             str = 'Matrix';
0434           end
0435 
0436         elseif ischar(val)
0437           str = val;
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           else
0498             str = 'Unknown class';
0499           end
0500 
0501         elseif iscell(val)
0502           for i = 1:min(length(val),3)
0503             if ischar(val{i})
0504               str = strcat(str, val{i});
0505             elseif isnumeric(val)
0506               str = strcat(str, num2str(val{i}));
0507             end
0508             if i < min(length(val),3)
0509               str = strcat(str, ',');
0510             end
0511           end
0512           if length(val) > 3
0513             str = strcat(str,'...');
0514           end
0515 
0516         end
0517 
0518         if ~isempty(c_str)
0519           c_str = strtrim(c_str);
0520           na = text(0.5,0.5,c_str);
0521           txt_extent = get(na, 'Extent');
0522           set(na, 'Position',            [0.5-txt_extent(3)/2, 0.5], ...
0523                   'HorizontalAlignment', 'left', ...
0524                   'Color',               'k',    ...
0525                   'FontWeight',          'bold', ...
0526                   'EdgeColor',           'k',    ...
0527                   'BackgroundColor',     'w',    ...
0528                   'Fontsize',            10,     ...
0529                   'Margin',              5);
0530         end
0531 
0532       end % ~isempty(val)
0533       set(txt4, 'string', str)
0534       set(tmp, 'UserData', cell_Data);
0535     end
0536 
0537 
0538 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0539 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0540 
0541 end
0542 
0543 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0544 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0545     function nodes = myExpfcn4(tree,value)
0546 
0547       tmp = tree.FigureComponent;
0548       S = get(tmp, 'UserData');
0549       s = S{1};
0550       cNode = S{2};
0551       [val, cNode] = getcNodevalue(cNode, s);
0552       fnames = fieldnames(val);
0553 
0554       % Set the path to the *.gif files
0555       % This tis the current path of this function + 'exp_struct_icons'
0556       eval (sprintf('pth = which(''%s'');',mfilename))
0557       index = find(pth==filesep);
0558       pth = pth(1:max(index));
0559       pth = [pth 'exp_struct_icons' filesep];
0560 
0561       [n,m] = size(val);
0562       count = 0;
0563 
0564       %% Vector or Matrix
0565       if m>1 || n>1
0566 
0567         if isa(val, 'ao')
0568           iconpath =[pth,'analysis_object.gif'];
0569         else
0570           iconpath =[pth,'struct_icon.gif'];
0571         end
0572 
0573         %% Vector
0574         if m==1 || n==1
0575           L = length(val);
0576 
0577           for J = 1:L
0578             count = count + 1;
0579             cNode = S{2};
0580 
0581             level = cNode.getLevel;
0582             fname = strcat(cNode.getValue, '(', num2str(J),')');
0583 
0584             if level==0 && ~isempty(S{3}) && numel(S{3}) == numel(S{1})
0585               node_str = S{3}(J);
0586             else
0587               node_str = fname;
0588             end
0589 
0590             nodes(count) =  ltpda_uitreenode(fname, node_str, iconpath, 0);
0591           end
0592         %% Matrix
0593         else
0594 
0595           for ii=1:n
0596             for jj=1:m
0597               count = count + 1;
0598               cNode = S{2};
0599               fname = [cNode.getValue '(' num2str(ii) ',' num2str(jj) ')'];
0600               nodes(count) =  ltpda_uitreenode(fname, fname, iconpath, 0);
0601             end
0602           end
0603 
0604         end
0605       %% Struct, Object or single value
0606       else
0607         %%
0608         for i=1:length(fnames)
0609           count = count + 1;
0610           x = getfield(val,fnames{i});
0611 
0612           if isa(x, 'ao')
0613             iconpath =[pth,'analysis_object.gif'];
0614           elseif isa(x, 'tsdata')
0615             iconpath =[pth,'ts_data.gif'];
0616           elseif isa(x, 'fsdata')
0617             iconpath =[pth,'fs_data.gif'];
0618           elseif isa(x, 'xydata')
0619             iconpath =[pth,'xy_data.gif'];
0620           elseif isa(x, 'cdata')
0621             iconpath =[pth,'c_data.gif'];
0622           elseif isa(x, 'history')
0623             iconpath =[pth,'history.gif'];
0624           elseif isa(x, 'plist')
0625             iconpath =[pth,'plist.gif'];
0626 
0627           elseif isstruct(x)
0628             if length(x) > 1
0629               iconpath =[pth,'structarray_icon.gif'];
0630             else
0631               iconpath =[pth,'struct_icon.gif'];
0632             end
0633           elseif isnumeric(x)
0634             iconpath =[pth,'double_icon.gif'];
0635           elseif iscell(x)
0636             iconpath =[pth,'cell_icon.gif'];
0637           elseif ischar(x)
0638             iconpath =[pth,'char_icon.gif'];
0639           elseif islogical(x)
0640             iconpath =[pth,'logic_icon.gif'];
0641           elseif isobject(x)
0642             iconpath =[pth,'obj_icon.gif'];
0643           else
0644             iconpath =[pth,'unknown_icon.gif'];
0645           end
0646 
0647           if isstruct(x) || isobject(x)
0648             isLeaf = 0;
0649           else
0650             isLeaf = 1;
0651           end
0652 
0653           nodes(count) = ltpda_uitreenode(fnames{i}, fnames{i}, iconpath, isLeaf);
0654         end
0655       end
0656 
0657       if (count == 0)
0658         nodes = [];
0659       end
0660     end
0661 
0662 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0663 
0664     function cNode = nodeWillExpand_cb4(tree,ev)
0665         cNode = ev.getCurrentNode;
0666         tmp = tree.FigureComponent;
0667         cell_Data = get(tmp, 'UserData');
0668         cell_Data{2} = cNode;
0669         set(tmp, 'UserData', cell_Data);
0670     end
0671 
0672 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0673     function [val, displayed, cNode] = getcNodevalue(cNode, s)
0674 
0675       fields = {};
0676       while cNode.getLevel ~=0
0677         fields = [fields; cNode.getValue];
0678         c = findstr(cNode.getValue, '(');
0679         if ~isempty(c) && cNode.getLevel ~=0
0680           cNode = cNode.getParent;
0681         end
0682 
0683         if  cNode.getLevel ==0, break; end
0684         cNode = cNode.getParent;
0685       end
0686 
0687       val = s;
0688 
0689         if ~isempty(fields)
0690           L=length(fields);
0691           displayed = fields{L};
0692           % create the variable: displayed
0693           for j = L-1:-1:1
0694             displayed = strcat(displayed, '.', fields{j});
0695           end
0696 
0697           for i = L:-1:1
0698             field = fields{i};
0699             von = findstr(field,'(');
0700             bis = findstr(field,')');
0701             if ~isempty(von)
0702 
0703               idx = field(von+1:bis-1);
0704               field = field(1:von-1);
0705               if (strcmp(field, cNode.getValue))
0706                 cmd = sprintf('val = val(%s);',idx);
0707                 eval(cmd);
0708               else
0709                 cmd = sprintf('val = getfield(val, field, {%s});',idx);
0710                 eval(cmd);
0711               end
0712 
0713             else
0714               val = getfield(val, field);
0715             end
0716           end
0717         else
0718           displayed = cNode.getValue;
0719           return;
0720         end
0721     end
0722 
0723 
0724 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
0725     function c_str = split_by_comma(str, pref)
0726 
0727       if nargin < 2
0728         pref = '';
0729       end
0730 
0731       c_str = {};
0732       c_str{1} = str;
0733       index    = find(str==',');
0734       von      = 1;
0735       for ii = 1:length(index)
0736         bis = index(ii)-1;
0737         c_str{ii} = [pref str(von:bis)];
0738         von = bis + 2;
0739       end
0740       if ~isempty(index)
0741         c_str{ii+1} = [pref str(von:end)];
0742       end
0743 
0744       c_str = strtrim(c_str);
0745     end
0746

Generated on Wed 04-Jul-2007 19:03:10 by m2html © 2003