Home > m > gui > ao_browser > ltpda_explorer.m

ltpda_explorer

PURPOSE ^

LTPDA_EXPLORER for exploring analysis objects and plotting/displaying their fields

SYNOPSIS ^

function ltpda_explorer(varargin)

DESCRIPTION ^

 LTPDA_EXPLORER for exploring analysis objects and plotting/displaying their fields

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

 DESCRIPTION: LTPDA_EXPLORER 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:    ltpda_explorer;              % Read the ao's from the'base' workspace
          ltpda_explorer(ao);
          ltpda_explorer(ao_vector);
          ltpda_explorer(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: ltpda_explorer.m,v 1.1 2008/03/17 20:50:11 hewitson Exp $

 HISTORY: 10-06-07 Diepholz
             Creation

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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

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

Generated on Mon 31-Mar-2008 21:41:00 by m2html © 2003