-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathexport_drawing.m
More file actions
75 lines (66 loc) · 1.91 KB
/
export_drawing.m
File metadata and controls
75 lines (66 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
function coords = export_drawing( filename, output_coords )
% coords = export_drawing( filename, output_coords )
%
% Export drawing to different formats: PostScript, JPEG, PDF, PNG
%
% Inputs:
% filename = name of output image (should end in .eps, .jpg, .pdf, or .png)
% output_coords = [default: 0] Also output tab-separated file with:
%
% x y chain segid resnum name
%
% for each residue/ligand/protein in the drawing.
% Name will be filename.coords.txt.
%
%
% See also: SAVE_DRAWING, EXPORT_COORDINATES
%
% (C) R. Das, Stanford University
if ~exist( 'output_coords','var' ) output_coords = 0; end;
cols = strsplit( filename, '.' );
switch cols{end}
case {'eps','ps','ai'}
opt = '-depsc2';
case 'pdf'
opt = '-dpdf';
case 'jpg','jpeg'
opt = '-djpg';
case 'png'
opt = '-dpng';
case 'svg'
opt = 'SVG';
otherwise
fprintf( 'Unrecognized extension' )
help
return;
end
plot_settings = getappdata( gca, 'plot_settings' );
hide_helix_controls;
hide_domain_controls;
hide_selection_controls;
hide_linker_controls;
if strcmp(opt,'SVG'); set(gcf,'color','none'); end
tic
if strcmp(opt, 'SVG') == 1
% Use library function
plot2svg( filename, gcf );
else
print( filename, opt, '-r300' );
end
fprintf( 'Created: %s\n', filename );
toc
tic
coords = [];
if output_coords
cdata = imread( filename );
s = size(cdata);
coord_filename = [filename, '.coords.txt'];
coords = export_coordinates( coord_filename, s([2 1]) ); % have to switch x <--> y
end
toc
show_helix_controls ( plot_settings.show_helix_controls );
show_domain_controls( plot_settings.show_domain_controls );
show_coax_controls( plot_settings.show_coax_controls );
show_linker_controls( plot_settings.show_linker_controls );
if strcmp(opt,'SVG'); set(gcf,'color','white'); end
if system( 'which open' ) == 0; system( ['open ',filename] ); end;