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

Generated on Tue 26-Feb-2008 10:52:52 by m2html © 2003