diff options
author | Karl Berry <karl@freefriends.org> | 2022-10-10 20:21:43 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2022-10-10 20:21:43 +0000 |
commit | 3c2bc083812ac2acc7384696a710e3655a3cdddf (patch) | |
tree | 90ffc3fde9da22871fb0102499b9d4e60ce03d81 /Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp | |
parent | 7ebe67c43f676873decb1e34bfd5223a04db5dd9 (diff) |
mcf2graph (10oct22)
git-svn-id: svn://tug.org/texlive/trunk@64671 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp')
-rw-r--r-- | Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp | 97 |
1 files changed, 52 insertions, 45 deletions
diff --git a/Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp b/Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp index a5c880ed0b2..729be297d03 100644 --- a/Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp +++ b/Master/texmf-dist/doc/metapost/mcf2graph/mcf2graph.mp @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 4.87 Copyright (c) 2013-2022 Akira Yamaji +% mcf2graph ver 4.88 Copyright (c) 2013-2022 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, @@ -33,7 +33,7 @@ % Set output MOL file (V3000) : mpost -s ahlength=6 FILENAME % Set output report : mpost -s ahlength=7 FILENAME %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -message "* This is mcf2graph ver 4.87 2022.08.22"; +message "* This is mcf2graph ver 4.88 2022.10.10"; tracingstats:=1; prologues:=3; warningcheck:=0; %------------------------------------------------------------------------------------------------- newinternal string EN_; @@ -185,13 +185,13 @@ def beginfigm(text s)= save ',mc,f_ext,blen,ext,add,ang_br,fw_n,bw_n,at_colon,info_cnt,group_num,bond_cntA,warning_cnt, hideH,hideH_cnt,filter_s,mc_indent,cntM,cntA,cntB,minX,minY,maxX,maxY,posA,posM,lineB, sB,eB,angB,angA,lenB,angX,numS,sumA,bond_num,wdM,htM,chargeA,addA,add_rot,cal_FM,cal_MW, - cal_MI,inf_Cat,inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW, - mol_pic,sC,sI,sS,sT,sV,color_list,unit_cnt,f_end,semic_cnt,f_match,var_n,tag_a,var_a; - numeric mc_indent[],hideH[],lineB[],sB[],eB[],angB[],angA[],lenB[],angX[],strA[],sumA[], - bond_num[],wdM[],htM[],chargeA[],addA[],add_rot[]; + cal_MI,inf_Cat,inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW,mol_pic, + sC,sI,sS,sT,sV,color_list,unit_cnt,f_end,semic_cnt,f_match,var_n,tag_a,var_a; + numeric mc_indent[],op_indent[],ex_indent[],ad_indent[],hideH[],lineB[],sB[],eB[],angB[],angA[], + lenB[],angX[],strA[],sumA[],bond_num[],wdM[],htM[],chargeA[],addA[],add_rot[]; pair posA[],posM[][]; - string mc[],tag_a[],var_a[],mc,filter_s,cal_FM,cal_MW,cal_MI,inf_Cat,inf_NO,inf_EN,inf_JN, - inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW,sC,sI,sS,sT,sV; + string mc[],ex[],ad[],op[],tag_a[],var_a[],mc,ex,ad,op,filter_s,cal_FM,cal_MW,cal_MI,inf_Cat, + inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW,sC,sI,sS,sT,sV,firstc; picture mol_pic[]; color color_list[]; %------------------------------------------------------------------------------------------------ @@ -200,17 +200,22 @@ def beginfigm(text s)= let ext=ext_to_fig; let add=add_to_molecule; def '=read_ud enddef; %------------------------------------------------------------------------------------------------ inf_NO:=inf_EN:=inf_JN:=inf_MW:=inf_FM:=inf_CAS:=inf_Cat:=inf_EXA:=inf_EXB:="-"; - mc:=temps:=cal_MW:=cal_MI:=cal_FM:=filter_s:=""; file_input:=default_library; + mc:=ex:=ad:=op:=temps:=cal_MW:=cal_MI:=cal_FM:=filter_s:=""; file_input:=default_library; %------------------------------------------------------------------------------------------------ parts_num:=parts_usr_start; parts_int:=parts_int_start; - fig_num:=fig_num+1; f_ext:=cntM:=mc_row:=info_cnt:=f_EOF:=0; + fig_num:=fig_num+1; f_ext:=cntM:=mc_row:=ex_row:=ad_row:=op_row:=info_cnt:=f_EOF:=0; %------------------------------------------------------------------------------------------------ for list=s: - at_colon:=scan_c(":",list); - if at_colon=1: - fw_n:=scan_char(" ",list,1,2); bw_n:=scan_char(" ",list,-1,2); - mc_indent[incr mc_row]:=fw_n-2; - mc[mc_row]:=substring(fw_n-1,bw_n) of list; mc:=mc&mc[mc_row]; + at_colon:=scan_c(":",list); firstc:=subc(1,list); + fw_n:=scan_char(" ",list,1,2); bw_n:=scan_char(" ",list,-1,2); + if firstc=":": mc_indent[incr mc_row]:=fw_n-2; + mc[mc_row]:=substring(fw_n-1,bw_n) of list; mc:=mc&mc[mc_row]; + ef firstc="*": ex_indent[incr ex_row]:=fw_n-2; + ex[ex_row]:=substring(fw_n-1,bw_n) of list; ex:=ex&ex[ex_row]; + ef firstc="+": ad_indent[incr ad_row]:=fw_n-2; + ad[ad_row]:=substring(fw_n-1,bw_n) of list; ad:=ad&ad[ad_row]; + ef firstc="=": op_indent[incr op_row]:=fw_n-2; + op[op_row]:=substring(fw_n-1,bw_n) of list; op:=op&op[op_row]; ef at_colon>=1: info_s[incr info_cnt]:=list; sT:=substring(0,at_colon-1) of list; sV:=substring(at_colon,length(list)) of list; @@ -292,29 +297,31 @@ def pickup_data_unit(expr t,v,f)= f_end:=unit_cnt:=semic_cnt:=f_match:=inf_num:=0; if t="n": var_n:=scantokens(v); fi forever: - sS:=readfrom file_input; if sS=EOF: f_EOF:=1; fi exitif f_EOF=1; - if subc(1,sS)="%": - ef subc(1,sS)="+": + temps:=readfrom file_input; if temps=EOF: f_EOF:=1; fi exitif f_EOF=1; firstc:=subc(1,temps); + if firstc="%": + ef (firstc=":")or(firstc="="): + if firstc=":": nF:=1; ef firstc="=": nF:=2; fi unit_cnt:=unit_cnt+1; if v="*": f_match:=1; ef t="n": if unit_cnt=var_n: f_match:=1; fi fi if f_match=1: forever: - sS:=readfrom file_input; - if sS=EOF: f_EOF:=1; fi exitif f_EOF=1; exitif subc(1,sS)="+"; - if subc(1,sS)<>"%": - fw_n:=scan_char(" ",sS,1,1); mc_indent[incr mc_row]:=fw_n-1; - mc[mc_row]:=substring(fw_n-1,length(sS)) of sS; mc:=mc&mc[mc_row]; fi + sS:=readfrom file_input; firstc:=subc(1,sS); nS:=length(sS); + if sS=EOF: f_EOF:=1; fi exitif f_EOF=1; exitif firstc=";"; + if firstc=":": nF:=1; ef firstc="=": nF:=2; ef firstc="*": nF:=3; ef firstc="+": nF:=4; + else: fw_n:=scan_char(" ",sS,1,1)-1; temps:=substring(fw_n,nS) of sS; + if nF=1: mc_indent[incr mc_row]:=fw_n; mc[mc_row]:=temps; mc:=mc&mc[mc_row]; + ef nF=2: op_indent[incr op_row]:=fw_n; op[op_row]:=temps; op:=op&op[op_row]; + ef nF=3: ex_indent[incr ex_row]:=fw_n; ex[ex_row]:=temps; ex:=ex&ex[ex_row]; + ef nF=4: ad_indent[incr ad_row]:=fw_n; ad[ad_row]:=temps; ad:=ad&ad[ad_row]; fi fi endfor for i=1 upto inf_num: - if known scantokens("inf_"&tag_a[i]): scantokens("inf_"&tag_a[i]):=var_a[i]; fi - endfor + if known scantokens("inf_"&tag_a[i]): scantokens("inf_"&tag_a[i]):=var_a[i]; fi endfor f_end:=1; else: - forever: - sS:=readfrom file_input; if sS=EOF: f_EOF:=1; fi exitif f_EOF=1; exitif subc(1,sS)="+"; - endfor + forever: sS:=readfrom file_input; + if sS=EOF: f_EOF:=1; fi exitif f_EOF=1; exitif subc(1,sS)=";"; endfor fi else: - inf_num:=split_str(sS,";")(arg_s); + inf_num:=split_str(temps,";")(arg_s); for i=1 upto inf_num: get_tag_var(arg_s[i])(tag_a[i],var_a[i]); if t=tag_a[i]: if v=var_a[i]: f_match:=1; fi fi endfor @@ -553,12 +560,12 @@ enddef; %------------------------------------------------------------------------------------------------- def add_to_molecule(text t)= begingroup - save w,h,n,l,p,am,aw,A,B,plus,minus,lonepair,__,**,=>,<<,/*; + save w,h,n,l,p,am,aw,A,B,plus,minus,lonepair,wave_line,__,**,=>,<<,/*; numeric A[]dir,B[]up,A[]ang,B[]ang; pair __,p[],A[],B[]s,B[]e,B[]m,A[]up,A[]left,A[]right,A[]down,B[]up,B[]left,B[]right,B[]down; path B[]; def plus = circled_plus_add enddef; def minus = circled_minus_add enddef; - def lonepair = lone_pair_add enddef; + def lonepair = lone_pair_add enddef; def wave_line = wave_line_add enddef; ext_setup; w:=mol_wd; h:=mol_ht; l:=blen; aw:=atom_wd; p0:=(minX,minY); lonepairdiam:=0.3aw; lonepairspace:=.7aw; circlediam:=.6aw; circlepen:=.2; @@ -595,6 +602,10 @@ vardef circled_minus_add= nA:=circlediam; nB:=circlepen; vardef lone_pair_add expr n= image(draw (0,0) wpcs lonepairdiam; draw ((0,lonepairspace) rotated n) wpcs lonepairdiam;) enddef; +%------------------------------------------------------------------------------------------------- +vardef wave_line_add expr n= + image() +enddef; %================================================================================================= def MCat(expr w,h)(text t)= save_mposition:=mposition; mposition:=(w,h); MC(t) mposition:=save_mposition; enddef; @@ -966,10 +977,9 @@ def draw_bond(expr n)= ef nL=zf: wz_put(Ls,sfrt(Le,ww,ap),sfrt(Le,ww,am)); ef nL=zb: wz_put(Le,sfrt(Ls,ww,am),sfrt(Ls,ww,ap)); ef nL=dt: for i=0 step .75hash_gap/lenL until 1: drawdot i[Ls,Le]; endfor - ef nL=wv: nA:=3bond_pen_wd; nB:=lenL/nA; - draw Le for i=1 upto nB: - ..controls(((i-.5)/nB)[sfrt(Le,nA,iif(odd(i),ap,am)),sfrt(Ls,nA,iif(odd(i),ap,am))]) - ..(i/nB)[Le,Ls] endfor ..Ls; + ef nL=wv: nA:=.4bondgap; nB:=round(lenL/nA); + draw Ls for i=1 upto nB: ..controls(point (i-.5)/nB of sfrt(zA,nA,iif(odd i,ap,am))) + ..point i/nB of zA endfor ef nL=wf_r: filldraw Ls--sfrt(Le,.35ww,am)--sfrt(Le,.35ww,ap)--cycle wpcs .05ww; ef nL=wb_r: filldraw sfrt(Ls,.35ww,am)--Le--sfrt(Ls,.35ww,ap)--cycle wpcs .05ww; ef nL=bd_r: draw zA wpcs .65bondgap; @@ -1013,15 +1023,12 @@ def draw_bond(expr n)= if f_col=1: drawoptions(); fi enddef; %------------------------------------------------------------------------------------------------ -def wz_put(expr a,b,c)= - for i=0 upto lenL/hash_gap: - nA:=hash_gap*i/lenL; nD:=(hash_gap*i+ratio_hash_black*hash_gap)/lenL; - if nD>((lenL-hash_gap)/lenL): nD:=1; fi - fill nA[b,a]--nA[c,a]--nD[c,a]--nD[b,a]--cycle; endfor enddef; +def wz_put(expr a,b,c)= nB:=round(lenL/hash_gap); + for i=1 upto nB: nA:=i/nB; if i=1: nD:=0; else: nD:=(i-ratio_hash_black)/nB; fi + fill nD[a,b]--nD[a,c]--nA[a,c]--nA[a,b]--cycle; endfor enddef; %------------------------------------------------------------------------------------------------ -def bz_put(expr a,b,c,d)= - for i=0 upto lenL/hash_gap: - nA:=hash_gap*i/lenL; nD:=(hash_gap*i+ratio_hash_black*hash_gap)/lenL; +def bz_put(expr a,b,c,d)= nB:=round(lenL/hash_gap); + for i=0 upto nB-1: nA:=i/nB; nD:=nA+ratio_hash_black/nB; fill nA[b,a]--nA[d,c]--nD[d,c]--nD[b,a]--cycle; endfor enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def char_size_set(expr w,h)(expr s)= @@ -1588,7 +1595,7 @@ def mc_query(text s)= temps:=readfrom file_input; exitif temps=EOF; if subc(1,temps)<>"%": line_s[unit_cnt][incr unit_row]:=temps; - if (substring(0,2) of temps)="+-": + if subc(1,temps)=";": row_cnt[unit_cnt]:=unit_row; f_mcf:=unit_row:=0; filter_n:=1; for i=1 upto filter_cnt: filter_p[i]:=0; endfor sort_s:=""; @@ -1609,7 +1616,7 @@ def mc_query(text s)= for i=1 upto filter_cnt: if filter_p[i]=0: filter_n:=0; fi endfor info_cnt:=0; lib_unit_cnt:=lib_unit_cnt+1; if filter_n=1: if key_s<>"": sort_tbl[unit_cnt]:=sort_s; fi unit_cnt:=unit_cnt+1; fi - ef subc(1,temps)="+": f_mcf:=1; mc_row:=1; + ef (subc(1,temps)=":")or(subc(1,temps)="="): f_mcf:=1; mc_row:=1; ef subc(1,temps)<>"%": if f_mcf=1: mc_row:=mc_row+1; else: info_cnt:=split_str(temps,";")(arg_s); fi fi fi |