summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-01-29 22:31:38 +0000
committerKarl Berry <karl@freefriends.org>2017-01-29 22:31:38 +0000
commitb637e30bd75f158479a9b3d56468f3c405a2d9ae (patch)
tree090c31d4b7390b879032dce87fc7893b2c0b1fb6 /Master/texmf-dist/metapost
parent0a15fbc2acd454966261b5cb52c8ae35a36b62a6 (diff)
mcf2graph (29jan17)
git-svn-id: svn://tug.org/texlive/trunk@43081 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r--Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf110
1 files changed, 69 insertions, 41 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
index 86aed79aff3..7fa4db15f74 100644
--- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
+++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
@@ -1,5 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% mcf2graph ver 4.08 Copyright (c) 2013-2017 Akira Yamaji
+% mcf2graph ver 4.09 Copyright (c) 2013-2017 Akira Yamaji
%
% Permission is hereby granted, free of charge, to any person obtaining a copy of this software
% and associated documentation files (the "Software"), to deal in the Software without restriction,
@@ -27,7 +27,7 @@
% Set outputformat to "svg" : mpost -s ahangle=2 FILENAME
% Set outputformat to MDL Molfile : mpost -s ahangle=3 FILENAME
% Set first font only (for test) : mpost -s ahlength=1 FILENAME
-% Set output checklist : mpost -s ahlength=2 FILENAME
+% Set output report : mpost -s ahlength=2 FILENAME
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tracingstats:=1;
message " This is mcf2graph ver 4.0 2017.1";
@@ -36,11 +36,11 @@ newinternal nA,nB,nC,nD,nE,nF,char_num,str_cnt,def_num,def_int,tbl_cnt;
numeric save_para[],comD[][],parD[][],cntD[],tbl_str_wd[],tbl_atom[],tbl_subst[][],tbl_atom_wt[],
tbl_atom_mi[],tbl_char_wd[],tbl_char_ht[],tbl_char_dp[];
string tbl_atom_str[],strD[],var[],tag[],mp_log_name,aux_delimiter;
-picture atom_font[],mol_stru[];
+picture atom_font[],str_font[],mol_stru[],save_pict;
%-------------------------------------------------------------------------------------------------
char_num:=str_cnt:=proc_end:=0;
sw_numberA:=sw_numberB:=sw_mol_frame:=sw_auxout:=sw_solid:=sw_expand:=sw_font_frame:=0;
-sw_atom_frame:=sw_checklist:=sw_MOLout:=sw_subst_off:=sw_bond_single:=sw_auxfix:=sw_clip:=0;
+sw_atom_frame:=sw_report:=sw_MOLout:=sw_subst_off:=sw_bond_single:=sw_auxfix:=sw_clip:=0;
numberA_start:=numberB_start:=1; numberA_end:=numberB_end:=4095; aux_max:=max_inf_num:=20;
aux_delimiter:=";"; var1:="jobname"; tag1:="F"; var2:="char_num"; tag2:="C";
for i=3 upto aux_max: var[i]:=tag[i]:=""; endfor
@@ -50,7 +50,7 @@ if (known green)and(known ahlength):
color color_list[];
mp_log_name:=jobname&"-info.aux";
if ahlength=1: proc_end:=1; fi % first molecular only
- if ahlength=2: sw_checklist:=1; def shipit = enddef; fi % checklist on
+ if ahlength=2: sw_report:=1; def shipit = enddef; fi % report on
if ahangle=0: def shipit = enddef; % No image file
elseif ahangle=1: outputformat:="png"; hppp:=vppp:=0.1; % PNG format
elseif ahangle=2: outputformat:="svg"; % SVG format
@@ -94,7 +94,7 @@ def_com(-4000)(_term,_jp_atom,_jp_atom_abs,_jp_bond,_cyc,_cyc_sB,_cyc_eB,_set_li
def_com(1)(si,dl,dr,db,dm,tm,wf,wb,bd,bz,zf,zb,dt,wv,nl,vf,vb,si_,wf_,wb_,bd_);
%--------------------------------------------------------------------------------------------------
def parameter_list=
- sw_checklist,sw_numberA,sw_numberB,sw_mol_frame,sw_auxout,sw_solid,sw_expand,sw_MOLout,
+ sw_report,sw_numberA,sw_numberB,sw_mol_frame,sw_auxout,sw_solid,sw_expand,sw_MOLout,
sw_atom_frame,sw_font_frame,sw_subst_off,sw_bond_single,sw_clip,
margin_left_right,margin_top_bottom,ratio_atom_bond,ratio_thickness_bond,ratio_char_bond,
ratio_chain_ring,max_bond_width,ratio_bondgap_bond,ratio_zebra_black,ratio_zebragap_bond,
@@ -112,6 +112,7 @@ def restore_par(text t)= nA:=0;
forsuffixes list=t: if list<>save_para[incr nA]: list:=save_para[nA]; fi endfor enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def beginfont(text s)=
+ char_num:=char_num+1;
store_par(parameter_list);
begingroup
save cntA,cntB,cntM,minX,minY,f_beginchar,numS,sftX,sftY,f_ext,
@@ -123,7 +124,6 @@ def beginfont(text s)=
for i:=1 upto max_inf_num: info[i]:=":"; endfor
f_ext:=inf_num:=cntM:=0;
for list=s: info[incr inf_num]:=list; endfor
- char_num:=char_num+1;
enddef;
%==================================================================================================
def endfont=
@@ -145,10 +145,11 @@ def endfont=
beginchar(char_num,font_wd#,font_ht#,0)
if (sw_font_frame=1)or(sw_font_frame=3): draw_frame((0,0),w,h,thickness_font_frame); fi
if (sw_font_frame=2)or(sw_font_frame=3):
- nA:=w-2margin_left_right; nB:=h-2margin_top_bottom; pT:=(margin_left_right,margin_top_bottom);
+ nA:=w-2margin_left_right; nB:=h-2margin_top_bottom;
+ pT:=(margin_left_right,margin_top_bottom);
draw_frame(pT,nA,nB,thickness_font_frame); fi
if sw_font_frame=4: draw_corner(w,h,thickness_font_frame); fi
- if (sw_auxout=1)or(sw_checklist=1)or(sw_MOLout=1): proc_calc_out; fi
+ if (sw_auxout=1)or(sw_report=1)or(sw_MOLout=1): proc_calc_out; fi
for i=1 upto cntM:
addto currentpicture also mol_stru[i] shifted posM[0][i]; mol_stru[i]:=nullpicture;
endfor
@@ -316,6 +317,27 @@ def ext(text s)=
s addto mol_stru[cntM] also currentpicture; clearit;
endgroup;
enddef;
+%--------------------------------------------------------------------------------------------------
+def use_font(expr WD)=
+ save_pict:=currentpicture;
+ for i=1 upto 128: f_char[i]:=1; endfor
+ proc_char_setup(str_font)(WD);
+ str_wd#:=WD;
+ define_pixels(str_wd);
+ currentpicture:=save_pict;
+enddef;
+%--------------------------------------------------------------------------------------------------
+def puts(expr PA)(expr STR)=
+ begingroup
+ save cp; pair cp;
+ cp:=PA;
+ for i=0 upto length(STR)-1:
+ nA:=ASCII(pic_c(i,STR));
+ addto currentpicture also str_font[nA] shifted (cp-(0,str_wd*tbl_char_dp[nA]));
+ cp:=cp+(str_wd*tbl_char_wd[nA],0);
+ endfor
+ endgroup;
+enddef;
%=================================================================================================
def MCf(text s)= MCd(1,1)(.5,.5)(s) enddef; % MC fill draw
%-------------------------------------------------------------------------------------------------
@@ -359,7 +381,7 @@ def MCd(expr RW,RH)(expr FW,FH)(text TX)=
if bond_len#>max_bond_length#:
bond_len#:=max_bond_length#; proc_size_setup; proc_skeleton; proc_scaling; fi
fi
- proc_char_setup;
+ proc_char_setup(atom_font)(atom_wd#);
%-----------------------------------------------------------------------------------------------
for i=1 upto cntB: if lineB[i]<si_ : draw_bond(i,sB[i],eB[i],angB[i],lineB[i]); fi endfor
for i=1 upto cntB: if lineB[i]>=si_: draw_bond(i,sB[i],eB[i],angB[i],lineB[i]); fi endfor
@@ -462,9 +484,15 @@ enddef;
%-------------------------------------------------------------------------------------------------
def char_use_check=
for i=1 upto 128: f_char[i]:=0; endfor
- if (sw_numberA>0)or(sw_numberB>0): for j=ASCII("0") upto ASCII("9"): f_char[j]:=1; endfor
- else: for i=1 upto cntA: if numS[i]<>0: for j=0 upto length(strD[numS[i]])-1:
- f_char[ASCII(pic_c(j,strD[numS[i]]))]:=1; endfor fi endfor fi
+ if (sw_numberA<>0)or(sw_numberB<>0):
+ for j=ASCII("0") upto ASCII("9"): f_char[j]:=1; endfor
+ else:
+ for i=1 upto cntA:
+ if numS[i]<>0:
+ for j=0 upto length(strD[numS[i]])-1: f_char[ASCII(pic_c(j,strD[numS[i]]))]:=1; endfor
+ fi
+ endfor
+ fi
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def proc_bond_atom(expr n)=
@@ -747,7 +775,7 @@ CH3:='("C{H_3_}"); CN:='("CN"); NH2:='("N{H_2_}"); NO2:='("N{O_2_}"); SH:='("SH"
SO3:='("S{O_3_}"); NMe:=N!:='(N,/Me); iPr:=Me!:='(60,-2\); tBu:='(60,-2\,-3*,60);
OMe:=O!:='(O,!); OEt:=O!2:='(O,!2); OPr:=O!3:='(O,!3); OiPr:=OMe!:='(O,!,iPr);
SMe:=S!:='(S,!); SEt:=S!2:='(S,!2); SPr:=S!3:='(S,!3); SiPr:=SMe!:='(S,!,iPr);
-COOMe:=COO!:='(//O,!,O,!); COMe:=CO!:='(//O,!);
+COOMe:=COO!:='(//O,!,O,!); COMe:=CO!:='(//O,!); COEt:=CO!2:='(//O,!2);
OCOMe:=OCO!:='(O,!,//O,!); COOEt:=COO!2:='(//O,!,O,!2);
COOiPr:=COOMe!:='(//O,!,O,!,iPr); COOPr:=COO!3:='(//O,!,O,!3);
COOtBu:='(//O,!,O,!,tBu); NMeMe:=NMe!:='(N,/Me,!); NHCOMe:=NHCO!:='(NH,!,//O,!);
@@ -780,15 +808,15 @@ char_size_set(.7)( 1)(.15)("pqg");
char_size_set(.7)(.8)( 0)("acekosuvxzwry");
char_size_set(.4)( 1)( 0)(".,:;'`");
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-def proc_char_setup=
+def proc_char_setup(suffix FONT)(expr SIZE)=
begingroup
save Z,aW,aH,fW,hW,hW,hH,fP,hP,vL,hL,PO,POh,sH,FD;
pair Z[];
%---------------------------------------------------------------
def FD(expr c)(text s)=
if f_char[ASCII(c)]=1:
- aW#:=atom_wd#*tbl_char_wd[ASCII(c)]*(1-ratio_atomgap_atom*2);
- aH#:=atom_wd#*tbl_char_ht[ASCII(c)]*(1-ratio_atomgap_atom*2);
+ aW#:=SIZE*tbl_char_wd[ASCII(c)]*(1-ratio_atomgap_atom*2);
+ aH#:=SIZE*tbl_char_ht[ASCII(c)]*(1-ratio_atomgap_atom*2);
define_pixels(aW,aH);
fW:=aW-hP; hW:=.5aW; fH:=aH-hP; hH:=.5aH;
Z01:=( 0,hP); Z02:=(hP, 0); Z03:=(hP,hP); Z04:=(aW,hP); Z05:=(fW, 0); Z08:=( 0,hH);
@@ -796,7 +824,7 @@ def FD(expr c)(text s)=
Z18:=(hP,aH); Z19:=(hW,hP); Z20:=(hW,hH); Z06:=(hW,aH); Z07:=(hW, 0); Z11:=(hW,aW);
Z15:=(fW,aH); Z17:=(aW,hH);
s;
- atom_font[ASCII(c)]:=
+ FONT[ASCII(c)]:=
currentpicture shifted (ratio_atomgap_atom*atom_wd,ratio_atomgap_atom*atom_wd);
clearit;
fi
@@ -926,21 +954,21 @@ def STb(expr a)(text s)=
enddef;
%==================================================================================================
tbl_cnt:=0;
-STa("C" ,12.0107, 12.0000000); STa("H" , 1.00794, 1.00782503223);
-STa("{Al}",26.9815, 26.98153853); STa("{As}",74.9216, 74.92159457);
-STa("B" ,10.811, 11.00930536); STa("{Br}",79.904, 78.9183376);
-STa("{Ca}",40.078, 39.962590863); STa("{Cl}",35.453, 34.968852);
-STa("{Co}",58.933194, 58.93319429); STa("{Cr}",51.9961, 51.94050623);
-STa("{Cu}",63.546, 62.92959772); STa("D" ,2.012, 2.01410177812);
-STa("F" ,18.9984, 18.99840316273); STa("{Fe}",55.845, 55.93493633);
-STa("{Hg}",200.59, 201.97064340); STa("I" ,126.90447, 126.9044719);
-STa("K" ,39.0983, 38.9637064864); STa("{Li}",6.941, 7.0160034366);
-STa("{Mg}",24.305, 23.985041697); STa("{Mn}",54.938044, 54.93804391);
-STa("N" ,14.0067, 14.00307400443); STa("{Na}",22.98977, 22.9897692820);
-STa("{Ni}",58.693, 57.93534241); STa("O" ,15.9994, 15.99491461957);
-STa("P" ,30.973762, 30.97376199842); STa("S" ,32.065, 31.9720711744);
-STa("{Se}",78.971, 79.9165218); STa("{Si}",28.0855, 27.97692653465);
-STa("{Sn}",118.71, 119.90220163); STa("{Ti}",47.867, 47.94794198);
+STa("C" ,12.0107, 12.0000000); STa("H" , 1.00794, 1.00782503223);
+STa("{Al}",26.9815, 26.98153853); STa("{As}",74.9216, 74.92159457);
+STa("B" ,10.811, 11.00930536); STa("{Br}",79.904, 78.9183376);
+STa("{Ca}",40.078, 39.962590863); STa("{Cl}",35.453, 34.968852);
+STa("{Co}",58.933194, 58.93319429); STa("{Cr}",51.9961, 51.94050623);
+STa("{Cu}",63.546, 62.92959772); STa("D" ,2.012, 2.01410177812);
+STa("F" ,18.9984, 18.99840316273); STa("{Fe}",55.845, 55.93493633);
+STa("{Hg}",200.59, 201.97064340); STa("I" ,126.90447,126.9044719);
+STa("K" ,39.0983, 38.9637064864); STa("{Li}",6.941, 7.0160034366);
+STa("{Mg}",24.305, 23.985041697); STa("{Mn}",54.938044, 54.93804391);
+STa("N" ,14.0067, 14.00307400443); STa("{Na}",22.98977, 22.9897692820);
+STa("{Ni}",58.693, 57.93534241); STa("O" ,15.9994, 15.99491461957);
+STa("P" ,30.973762, 30.97376199842); STa("S" ,32.065, 31.9720711744);
+STa("{Se}",78.971, 79.9165218); STa("{Si}",28.0855, 27.97692653465);
+STa("{Sn}",118.71, 119.90220163); STa("{Ti}",47.867, 47.94794198);
STa("{Zn}",65.409, 63.92914201);
%--------------------------------------------------------------------------------------------------
STb("{H_2_}")("H","H"); STb("OH")("O","H"); STb("O{Na}")("O","{Na}"); STb("CN")("C","N");
@@ -1020,7 +1048,7 @@ def proc_calc_out=
cal_MI:=substring (0,10) of decimal(MI_num);
cal_MW:=substring (0,8) of decimal(MW_num);
if sw_auxout=1: proc_auxfile_out; fi
- if sw_checklist=1: proc_checklist_out; fi
+ if sw_report=1: proc_report_out; fi
if sw_MOLout=1: proc_MOLfile_out; fi
endgroup
enddef;
@@ -1045,20 +1073,20 @@ vardef round_auto(expr n)=
elseif (n<400)and(n>-400): round(n*10)/10 else: round(n) fi
enddef;
%--------------------------------------------------------------------------------------------------
-def proc_checklist_out=
+def proc_report_out=
message "%------------------------------------------------------------------";
message "% Molecular name = "& inf_EN;
message "% Warnings = "&fdr(3)(warning_cnt)&" / Expanded command = "&decimal(cntD[0]);
- message "% Width * Height = " & fdr(8)(mol_wd)&" * "&fdr(8)(mol_ht);
- message "% Shift width * height = "& fdr(8)(minX)&" * "&fdr(8)(minY);
+ message "% Width * Height = " & fdr(10)(mol_wd)&" * "&fdr(10)(mol_ht);
+ message "% Shift width * height = "& fdr(10)(minX)&" * "&fdr(10)(minY);
message "% Bond length = "&fdr(3)(bond_len)&" Atom size = "&fdr(3)(atom_wd);
message "% Atom count="&fdr(3)(cntA)&" Bond count="&fdr(3)(cntB)&
" Ring count="&fdr(3)(cntB-cntA+1)&" Hide H count="&fdr(3)(cnt_hide_H);
message "%------------------------------------------------------------------";
- message "%< NO. >< x axis , y axis >< atom >< bond >< hide_H >";
+ message "%< NO. >( x axis , y axis )< atom >< bond >< hide_H >";
for i=1 upto cntA:
- message "% A"&fdl(4)(i)&" ("&fdr(7)(round_auto(xpart(posA[i])/bond_len))&" , "&
- fdr(7)(round_auto(ypart(posA[i])/bond_len))&" ) "&fixed_l(8)(strD[numS[i]])&
+ message "% A"&fdl(4)(i)&" ("&fdr(10)(round_auto(xpart(posA[i])/bond_len))&" , "&
+ fdr(10)(round_auto(ypart(posA[i])/bond_len))&" ) "&fixed_l(8)(strD[numS[i]])&
" "&fdr(3)(Bcnt[i]) if hideH[i]>0: &fdr(8)(hideH[i]) fi;
endfor
message "%------------------------------------------------------------------";
@@ -1084,7 +1112,7 @@ def proc_checklist_out=
if nA<40: &fdr(12)(tbl_atom_wt[i]*sumA[i]); else: &fdr(12)(nA)&" * 100"; fi
fi
endfor
- message "% Mono isotopic:" &cal_MI_str;
+ message "% Monoisotopic mass: "&cal_MI_str;
message "% Weight Calc: " &cal_MW_str &" / Input: "
if inf_MW<>"": &inf_MW &" / weight gap= " &decimal(MW_num-scantokens(inf_MW)) fi;
message "% Fomula Calc: "&cal_FM&" / Input: "