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

Generated on Tue 22-Jan-2008 10:39:13 by m2html © 2003