1 |
function wid=get_fig_id(fign) |
---|
2 |
%GET_FIG_ID - get the Window Manager's Resource ID for a given figure |
---|
3 |
% GET_FIG_ID is a function which returns the Window Manager's |
---|
4 |
% Resource ID for the figure number passed to it. This ID |
---|
5 |
% is the HEXIDECIMAL identification number assigned to the |
---|
6 |
% figure window by the window manager, NOT MATLAB. |
---|
7 |
% It is the same number that the X command xwininfo returns |
---|
8 |
% as part of its output. |
---|
9 |
% |
---|
10 |
% Within the animation loop, use the following to get the |
---|
11 |
% frame into an image file: |
---|
12 |
% ecom =['!import -border 0 -window ' wid 'image??.gif']; |
---|
13 |
% eval(ecom) |
---|
14 |
% |
---|
15 |
|
---|
16 |
if nargin~=1 |
---|
17 |
disp('Must have 1 input argument to GET_FIG_ID'); |
---|
18 |
return |
---|
19 |
end |
---|
20 |
|
---|
21 |
if ~isfig(fign) |
---|
22 |
disp('Input figure number is NOT a current figure number'); |
---|
23 |
return |
---|
24 |
end |
---|
25 |
|
---|
26 |
% |
---|
27 |
win_name=get(fign,'Name'); |
---|
28 |
numtitle=get(fign,'NumberTitle'); |
---|
29 |
|
---|
30 |
% set figure name to "Temp Fig Name", for X-resource purposes. |
---|
31 |
set(fign,'NumberTitle','off') |
---|
32 |
set(fign,'Name',deblank('TempFigName')) |
---|
33 |
drawnow |
---|
34 |
|
---|
35 |
evalcom= ['!xwininfo -name ''TempFigName '' > /tmp/win.dat']; |
---|
36 |
eval(evalcom) |
---|
37 |
|
---|
38 |
set(fign,'NumberTitle',numtitle) |
---|
39 |
set(fign,'Name',win_name) |
---|
40 |
|
---|
41 |
|
---|
42 |
% Read /tmp/win.dat to retrieve the Resource Manager's HEX ID |
---|
43 |
% for the passed figure number |
---|
44 |
|
---|
45 |
fid=fopen('/tmp/win.dat','r'); |
---|
46 |
line=fgets(fid); |
---|
47 |
line=fgets(fid); |
---|
48 |
fclose(fid); |
---|
49 |
|
---|
50 |
%parse line to get hex window id |
---|
51 |
colons=findstr(line,':'); |
---|
52 |
subline=line(colons(2)+2:length(line)); |
---|
53 |
spaces=findstr(line,' '); |
---|
54 |
wid=subline(1:spaces(1)); |
---|
55 |
|
---|
56 |
disp(['Current Fig ID = ' wid]) |
---|