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

Generated on Fri 07-Mar-2008 15:46:43 by m2html © 2003