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);


 VERSION: $Id: ltpda_explorer.m,v 1.2 2008/08/04 12:54:29 hewitson Exp $

 HISTORY: 10-06-07 Diepholz
             Creation
 
 NOTE:      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

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

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

Generated on Mon 08-Sep-2008 13:18:47 by m2html © 2003