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 |
% Call as: wid=get_fig_id(fign); |
---|
11 |
% |
---|
12 |
% Calls: none |
---|
13 |
% |
---|
14 |
% Within the animation loop, use the following to get the |
---|
15 |
% frame into an image file: |
---|
16 |
% ecom =['!import -border 0 -window ' wid 'image??.gif']; |
---|
17 |
% eval(ecom) |
---|
18 |
% |
---|
19 |
|
---|
20 |
if nargin~=1 |
---|
21 |
disp('Must have 1 input argument to GET_FIG_ID'); |
---|
22 |
return |
---|
23 |
end |
---|
24 |
|
---|
25 |
if ~isfig(fign) |
---|
26 |
disp('Input figure number is NOT a current figure number'); |
---|
27 |
return |
---|
28 |
end |
---|
29 |
|
---|
30 |
% |
---|
31 |
win_name=get(fign,'Name'); |
---|
32 |
numtitle=get(fign,'NumberTitle'); |
---|
33 |
|
---|
34 |
% set figure name to "Temp Fig Name", for X-resource purposes. |
---|
35 |
set(fign,'NumberTitle','off') |
---|
36 |
set(fign,'Name',deblank('TempFigName')) |
---|
37 |
drawnow |
---|
38 |
|
---|
39 |
evalcom= ['!xwininfo -name ''TempFigName '' > /tmp/win.dat']; |
---|
40 |
eval(evalcom) |
---|
41 |
|
---|
42 |
set(fign,'NumberTitle',numtitle) |
---|
43 |
set(fign,'Name',win_name) |
---|
44 |
|
---|
45 |
|
---|
46 |
% Read /tmp/win.dat to retrieve the Resource Manager's HEX ID |
---|
47 |
% for the passed figure number |
---|
48 |
|
---|
49 |
fid=fopen('/tmp/win.dat','r'); |
---|
50 |
line=fgets(fid); |
---|
51 |
line=fgets(fid); |
---|
52 |
fclose(fid); |
---|
53 |
|
---|
54 |
%parse line to get hex window id |
---|
55 |
colons=findstr(line,':'); |
---|
56 |
subline=line(colons(2)+2:length(line)); |
---|
57 |
spaces=findstr(line,' '); |
---|
58 |
wid=subline(1:spaces(1)); |
---|
59 |
|
---|
60 |
disp(['Current Fig ID = ' wid]) |
---|
61 |
|
---|
62 |
% |
---|
63 |
% Brian O. Blanton |
---|
64 |
% Department of Marine Sciences |
---|
65 |
% Ocean Processes Numerical Modeling Laboratory |
---|
66 |
% 12-7 Venable Hall |
---|
67 |
% CB# 3300 |
---|
68 |
% University of North Carolina |
---|
69 |
% Chapel Hill, NC |
---|
70 |
% 27599-3300 |
---|
71 |
% |
---|
72 |
% 919-962-4466 |
---|
73 |
% blanton@marine.unc.edu |
---|
74 |
% |
---|
75 |
% Spring 1995 |
---|
76 |
% |
---|