0001 function print_jd(opt,savename,savedir,fignum,res)
0002
0003
0004
0005
0006
0007 if nargin < 5
0008 res = 600;
0009 end
0010 if nargin < 4
0011 fignum = NaN;
0012 end
0013 if nargin < 3
0014 savedir = NaN;
0015 end
0016 if nargin < 2
0017 savename = NaN;
0018 end
0019 if nargin < 1
0020 opt = 1;
0021 end
0022
0023 if isnan(savedir),
0024 savedir = 'figures/';
0025 elseif isempty(savedir),
0026 savedir = './';
0027 elseif ~strcmp(savedir(end),filesep),
0028 savedir = [savedir,filesep];
0029 end
0030 if ishandle(fignum),
0031
0032 else
0033 fignum = get(0,'currentfigure');
0034 end
0035 if isnan(savename)
0036 savename = ['fig_',num2str(fignum)];
0037 end
0038
0039
0040
0041 set(gcf,'PaperPositionMode','auto');
0042 set(gca, 'XTickMode','manual');
0043 set(gca, 'YTickMode','manual');
0044 set(gca, 'ZTickMode','manual');
0045
0046 if opt >= 0 && opt <= 1,
0047 print
0048 end
0049
0050 if opt >= 1,
0051 if opt == 3,
0052 keyboard
0053 end
0054 if opt == -1,
0055 return
0056 end
0057 if exist(savedir,'dir') ~= 7
0058 mkdir(savedir)
0059 end
0060
0061
0062
0063 print(fignum,'-depsc2','-loose',['-r',num2str(res)],[savedir,savename,'.eps']);
0064
0065 saveas(fignum,[savedir,savename,'.fig'],'fig')
0066 if strcmp(computer,'PCWIN'),
0067
0068 print(fignum,'-dmeta',['-r',num2str(res)],[savedir,savename,'.emf']);
0069 else
0070
0071 print(fignum,'-dpng',['-r',num2str(res)],[savedir,savename,'.png']);
0072
0073 end
0074
0075
0076
0077
0078 if strcmp(computer,'MAC'),
0079 eval(['!/Applications/Edition/TeX/macghostview/bin/eps2eps ''',savedir,savename,'.eps'' ''temp_',savedir,savename,'.eps'''])
0080 eval(['!/Applications/Edition/TeX/macghostview/bin/eps2eps ''temp_',savedir,savename,'.eps'' ''',savedir,savename,'.eps'''])
0081 eval(['delete ''temp_',savedir,savename,'.eps'''])
0082 end
0083
0084
0085 end
0086