source: trunk/src/plot_text.m @ 19

Last change on this file since 19 was 19, checked in by gostiaux, 11 years ago

the private files have been moved down to the root folder

File size: 3.2 KB
Line 
1%'plot_text': function for displaying the content of a Matlab structure in a figure
2%------------------------------------------------------------------------
3% function hdisplay=plot_text(FieldData,hdisplay_in)
4%
5% OUTPUT:
6% hdisplay: handle of the display edit box
7%
8%  INPUT:
9% FieldData: input Matlab structure
10% hdisplay_in: handles of the display box, if it is not defined create a new figure
11%
12%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
13%  Copyright Joel Sommeria, 2008, LEGI / CNRS-UJF-INPG, sommeria@coriolis-legi.org.
14%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
15%     This file is part of the toolbox UVMAT.
16%
17%     UVMAT is free software; you can redistribute it and/or modify
18%     it under the terms of the GNU General Public License as published by
19%     the Free Software Foundation; either version 2 of the License, or
20%     (at your option) any later version.
21%
22%     UVMAT is distributed in the hope that it will be useful,
23%     but WITHOUT ANY WARRANTY; without even the implied warranty of
24%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25%     GNU General Public License (file UVMAT/COPYING.txt) for more details.
26%AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
27
28function hdisplay=plot_text(FieldData,hdisplay_in)
29
30if exist('hdisplay_in','var') & ishandle(hdisplay_in) & isequal(get(hdisplay_in,'Type'),'uicontrol')
31    hdisplay=hdisplay_in;
32else
33    figure;%create new figure
34    hdisplay=uicontrol('Style','edit', 'Units','normalized','Position', [0 0 1 1],'Max',2,'FontName','monospaced');
35end
36   
37ff=fields(FieldData);%list of field names
38vv=struct2cell(FieldData);%list of field values
39
40for icell=1:length(vv)
41    Tabcell{icell,1}=ff{icell};
42    ss=vv{icell};
43    sizss=size(ss);
44    if isnumeric(ss)
45        if sizss(1)<=1 & length(ss)<5
46            displ{icell}=num2str(ss);
47        else
48            displ{icell}=[class(ss) ', size ' num2str(size(ss))];
49        end
50    elseif ischar(ss)
51        displ{icell}=ss;
52    elseif iscell(ss)
53        sizcell=size(ss);
54        if sizcell(1)==1 & length(sizcell)==2 %line cell
55           ssline='{''';
56           for icolumn=1:sizcell(2)
57               if isnumeric(ss{icolumn})
58                   if size(ss{icolumn},1)<=1 & length(ss{icolumn})<5
59                      sscolumn=num2str(ss{icolumn});%line vector
60                   else
61                      sscolumn=[class(ss{icolumn}) ', size ' num2str(size(ss{icolumn}))];
62                   end
63               elseif ischar(ss{icolumn})
64                   sscolumn=ss{icolumn};
65               else
66                   sscolumn=class(ss{icolumn});
67               end
68               if icolumn==1
69                   ssline=[ssline sscolumn];
70               else
71                   ssline=[ssline ''',''' sscolumn];
72               end
73           end
74           displ{icell}=[ssline '''}'];
75        else
76           displ{icell}=[class(ss) ', size ' num2str(sizcell)];
77        end
78    else
79        displ{icell}=class(ss);
80    end
81    Tabcell{icell,2}=displ{icell};
82end
83Tabchar=cell2tab(Tabcell,': ');
84set(hdisplay,'String', Tabchar)
85
86
Note: See TracBrowser for help on using the repository browser.