diff options
author | Karl Berry <karl@freefriends.org> | 2015-08-14 22:37:14 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-08-14 22:37:14 +0000 |
commit | b52c087654644bf3129e35c766b5359e86bd3356 (patch) | |
tree | 10c329604b12727d096a740983039a0e93531a46 /Master/texmf-dist/metapost | |
parent | 4877d5e5d365e505f6ed41141c84481c19087d6c (diff) |
mcf2graph (14aug15)
git-svn-id: svn://tug.org/texlive/trunk@38124 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 77 |
1 files changed, 36 insertions, 41 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index c1862e2cb2b..b7a841c9ca2 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,6 +1,6 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 3.55 Copyright (c) 2013-2015 Akira Yamaji -% +% mcf2graph ver 3.57 Copyright (c) 2013-2015 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, % including without limitation the rights to use, copy, modify, merge, publish, distribute, @@ -44,6 +44,7 @@ picture atom_font[],chem_structure,temp_picture; %------------------------------------------------------------------------------------------------- sw_numberA:=sw_numberB:=sw_frame:=sw_logout:=sw_solid:=sw_expand:=sw_start_vector:=0; sw_atom_frame:=sw_checklist:=sw_MOLfile:=char_num:=str_cnt:=size_changed:=proc_end:=0; +sw_info_file:=sw_info_char:=1; sw_info_lenx:=sw_info_leny:=sw_info_mw:=sw_info_fm:=0; if known green: f_MP:=1; mp_log_name:=jobname&"-info.aux"; if ahlength=1: proc_end:=1; fi % first molecular only @@ -85,27 +86,25 @@ def_com(1)(si,dl,dr,dm,tm,wf,wb,bd,zf,zb,ov,dt,no,ar,vf,vb,wv,nl); def parameter_list= sw_checklist,sw_numberA,sw_numberB,sw_frame,sw_logout,sw_solid,sw_expand, sw_MOLfile,sw_start_vector,sw_atom_frame,lr_margin,tb_margin,ratio_atom_bond,ratio_thickness_bond, ratio_cr,offset_atom,max_bond_width,ratio_pen_wd,ratio_bondgap_bond,ratio_zebra_black, - ratio_zebra_gap,ratio_wedge_bond,font_gap,offset_zebra_gap,offset_gap,offset_thick -enddef; + ratio_zebra_gap,ratio_wedge_bond,font_gap,offset_zebra_gap,offset_gap,offset_thick enddef; %------------------------------------------------------------------------------------------------- nA:=0; for list=parameter_list: st_p[incr nA]:=list; endfor def store_par(text t)= nA:=0; for list=t: if st_p[incr nA]<>list: st_p[nA]:=list; fi endfor enddef; def restore_par(text t)= nA:=0; forsuffixes list=t: if list<>st_p[incr nA]: list:=st_p[nA]; fi endfor enddef; %------------------------------------------------------------------------------------------------- -def beginfont(text s)= mol_name:=""; len_x:=len_y:=cntA:=0; +def beginfont(text s)= mol_name:=""; len_x:=len_y:=cntA:=info_num:=0; store_par(parameter_list); ratio_bond_width:=1mm#/font_wd#; - for i:=1 upto 12: if info[i]<>":": info[i]:=":"; fi endfor - for list=s: cntA:=cntA+1; info[cntA]:=list; - if substring (0,2) of list="EN": - mol_name:=substring (3,length(list)) of list; fi exitif cntA=11; endfor - beginchar(char_num,font_wd#,font_ht#,0); clearit; -enddef; + for list=s: info_num:=info_num+1; info[info_num]:=list; + if substring (0,2) of list="EN": mol_name:=substring (3,length(list)) of list; fi endfor + beginchar(char_num,font_wd#,font_ht#,0); clearit; enddef; %------------------------------------------------------------------------------------------------- def endfont= if sw_frame=1: AUX(draw_frame(len_x,len_y,(min_x,min_y),0.2pt);) fi - if sw_start_vector=1: AUX(start_vector) fi if sw_logout=1: logfile_out; fi - if sw_checklist=1: mol_check; checklist_out; fi if sw_MOLfile=1: mol_check; MOL_out; fi + if sw_start_vector=1: AUX(start_vector) fi + if sw_checklist=1: mol_check; checklist_out; fi + if sw_MOLfile=1: mol_check; MOL_out; fi + if sw_logout=1: logfile_out; fi char_num:=char_num+1; currentpicture:=chem_structure; chem_structure:=nullpicture; restore_par(parameter_list); if size_changed=1: font_wd#:=stock_wd#; font_ht#:=stock_ht#; size_changed:=0; fi @@ -121,8 +120,7 @@ def size_setup= BL# := font_wd#*ratio_bond_width; pen_wd# := ratio_thickness_bond*BL#+offset_thick#; Apen_wd# := ratio_pen_wd*pen_wd#; define_pixels(BL,zebra_gap,wedge_wd,AL,gap,pen_wd,Apen_wd,font_wd,font_ht); - font_size_setup; -enddef; + font_size_setup; enddef; %------------------------------------------------------------------------------------------------- def scaling= min_x:=min_y:= 4095.999; max_x:=max_y:=-4095.999; for i=1 upto cntA: xpos:=xpart(posA[i]); ypos:=ypart(posA[i]); @@ -148,16 +146,14 @@ enddef; def resize(expr WD,HT)= if (len_y/len_x)>(font_ht/font_wd): factor:=(font_ht*HT-2tb_margin)/len_y; else: factor:=(font_wd*WD-2lr_margin)/len_x; fi - ratio_bond_width:=ratio_bond_width*factor; len_x:=len_x*factor; len_y:=len_y*factor; -enddef; + ratio_bond_width:=ratio_bond_width*factor; len_x:=len_x*factor; len_y:=len_y*factor; enddef; %------------------------------------------------------------------------------------------------- for i=1 upto 128: f_FON[i]=0; endfor asc0:=ASCII("0"); asc9:=ASCII("9"); def font_use_check= for i=1 upto 128: if f_FON[i]<>0: f_FON[i]:=0; fi endfor if (sw_numberA=1)or(sw_numberB=1): for j=asc0 upto asc9: f_FON[j]:=1; endfor else: for i=1 upto cntA: if strA[i]<>0: for j=0 upto length(com_str[strA[i]])-1: - f_FON[ASCII(pic_c(j,com_str[strA[i]]))]:=1; endfor fi endfor fi -enddef; + f_FON[ASCII(pic_c(j,com_str[strA[i]]))]:=1; endfor fi endfor fi enddef; %------------------------------------------------------------------------------------------------- vardef '(text s)= ''(incr mc_num)(s); mc_num enddef; def set_def_MC= @@ -198,16 +194,14 @@ enddef; %------------------------------------------------------------------------------------------------- def !?(expr a)(expr b)(expr c) = PB(_jp_bond,a) PB(_get_len,a) PB(_push,c) PB(_chg_len,_ring_len) for i==1 upto b-2:: PB(_mk_bond,360 DIV b) endfor PB(_pop,c) - if a>=1:: PB(_cyc_eB,0) elseif a<=0:: PB(_cyc_eB,a-b+2) else:: PB(_cyc_eB,a) fi -enddef; + if a>=1:: PB(_cyc_eB,0) elseif a<=0:: PB(_cyc_eB,a-b+2) else:: PB(_cyc_eB,a) fi enddef; %------------------------------------------------------------------------------------------------- def !!?(expr a)(expr b)(expr c)(expr n) = PB(_jp_bond,xpart(a)) PB(_push,n) if b==6:: PB(_chg_len,0) for i==1 upto c-1:: PB(_mk_bond,60) endfor elseif b==5:: if c==2:: PB(_chg_len,1.25) PB(_mk_bond,80) elseif c==3:: PB(_chg_len,1.1) PB(_mk_bond,78) PB(_mk_bond,72) fi elseif b==4:: PB(_chg_len,1.225) PB(_mk_bond,105) fi - PB(_pop,n) if ypart(a)<=0:: PB(_cyc_eB,ypart(a)-c+1) else:: PB(_cyc_eB,ypart(a)) fi -enddef; + PB(_pop,n) if ypart(a)<=0:: PB(_cyc_eB,ypart(a)-c+1) else:: PB(_cyc_eB,ypart(a)) fi enddef; %------------------------------------------------------------------------------------------------- def PB(expr b,c)= comMC[ab_num][incr cntBS]:=b; parMC[ab_num][cntBS]:=c; enddef; def $$(text t)(expr e) = begingroup save cntBS; cntBS:=0; ab_num:=ab_num+1; @@ -269,8 +263,7 @@ def ps_get(expr n)= cntC:=cntMC[0]; cntPS:=cntP; for j=1 upto cntMC[ps_com[i]]: PS(comMC[ps_com[i]][j],parMC[ps_com[i]][j]) endfor PS(_pop,1) PS(_term,0) endfor - proc_atom(cntC+1); if cntP>cntPS: ps_get(cntPS+1); fi -enddef; + proc_atom(cntC+1); if cntP>cntPS: ps_get(cntPS+1); fi enddef; %------------------------------------------------------------------------------------------------- def AUX(text s)=s addto chem_structure also currentpicture shifted(sft_X,sft_Y); clearit; enddef; def MCf(text s)= MCd(1,1)(.5,.5)(s); enddef; @@ -302,8 +295,7 @@ def draw_frame(expr LX,LY,PS,PN)= draw unitsquare xscaled LX yscaled LY shifted PS wpcs PN; enddef; def start_vector= draw (posA[1] shifted (-1mm,0))--(posA[1] shifted (-4mm,0)) withpen penrazor rotated 90 scaled .8mm; - fill (posA[1] shifted (-2mm,-1mm))--posA[1]--(posA[1] shifted (-2mm,1mm))--cycle; -enddef; + fill (posA[1] shifted (-2mm,-1mm))--posA[1]--(posA[1] shifted (-2mm,1mm))--cycle; enddef; %------------------------------------------------------------------------------------------------ def proc_atom(expr n)= f_Br:=f_En:=f_T:=rotT:=adrS:=f_lineT:=f_rotT:=f_lenT:=f_envT:=envT:=env:=0; @@ -356,15 +348,13 @@ enddef; def ps_put(expr n,p)= ps_adr[incr cntP]:=n; ps_com[cntP]:=p; ps_len[cntP]:=lenT; ps_line[cntP]:=lineT; ps_rot[cntP]:=rotT; ps_env[cntP]:=envT; if f_lineT=0: lineT:=si; fi if f_lenT=0: lenT:=ratio_cr; fi - if f_rotT=0: rotT:=0; fi if f_envT=0: envT:=hz; fi -enddef; + if f_rotT=0: rotT:=0; fi if f_envT=0: envT:=hz; fi enddef; %------------------------------------------------------------------------------------------------- def add_atom= lineB[incr cntB]:=lineT; lineT:=si; if lenT=ratio_cr: lenB[cntB]:=B_len; else: lenB[cntB]:=lenT; lenT:=ratio_cr; fi if f_Br=0: cntA:=cntA+1; sB[cntB]:=cntA; strA[cntA]:=strAT; strAT:=0; if f_MP=1: colorA[cntA]:=colorB[cntA]:=0; fi else: f_Br:=0; fi - if f_En=0: eB[cntB]:=cntA+1; f_T:=0; else: eB[cntB]:=f_En; f_En:=0; f_T:=1; fi -enddef; + if f_En=0: eB[cntB]:=cntA+1; f_T:=0; else: eB[cntB]:=f_En; f_En:=0; f_T:=1; fi enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def proc_skelton= stkA[1]:=stkB[1]:=1; envT:=env:=f_lineT:=f_rotT:=f_lenT:=f_envT:=0; adrA:=adrB:=cntA:=cntB:=angT:=adrS:=f_En:=f_Br:=rotT:=f_T:=0; @@ -461,8 +451,7 @@ def clipping(expr SA,SB,PA,PB,LEN)= pT:=PA--PB; tn:=0.6AL/LEN; elseif SB=0: Ls:= cut_off(pT,AL*strW[SA],AL,PA); Le:=PB; pA:=Ls--Le; pB:=tn[PA,PB]--Le; pC:=Ls--(0.1)[PB,PA]; else: Ls:=cut_off(pT,AL*strW[SA],AL,PA); Le:=cut_off(pT,AL*strW[SB],AL,PB); - pB:=tn[PA,PB]--tn[PB,PA]; pC:=pA:=Ls--Le; fi -enddef; + pB:=tn[PA,PB]--tn[PB,PA]; pC:=pA:=Ls--Le; fi enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def draw_wv= nB:=3pen_wd; nA:=nB/length(Le-Ls); draw Le for i=1 upto 1/nA: if odd(i): ..controls(((i-.5)*nA)[sfB(Le,nB,ap),sfB(Ls,nB,ap)]) @@ -494,11 +483,15 @@ if (nC>0)and(LN<>0): ww:=wedge_wd; hpt:=.5pen_wd; ap:=ANG+90; am:=ANG-90; enddef; %------------------------------------------------------------------------------------------------- vardef fit_zero(expr n)=if n<=9: "00" elseif n<=99: "0" fi enddef; +def info_c(expr sw,c,cc)= if sw=1: &"{"&c&":"&cc&"}" fi enddef; +def info_n(expr sw,c,n)= if sw=1: &"{"&c&":"&decimal(n)&"}" fi enddef; def logfile_out= - printf "%"; - printf "\MOLinfo" for i=1 upto max_info_num: &"{"&info[i]&"}" endfor &"%"; - printf "\MCFinfo{"&jobname&"}{"&decimal(char_num)&"}{"&mp_filename&"}{"&decimal(len_x) - &"}{"&decimal(len_y)&"}{"&decimal(ratio_bond_width)&"}{"&decimal(cntA)&"}{}{}%"; enddef; + printf "\INFO{" + info_c(sw_info_file,"F",jobname) info_n(sw_info_char,"C",char_num) + info_n(sw_info_lenx,"Lx",len_x) info_n(sw_info_leny,"Ly",len_y) + info_n(sw_info_mw,"Mw",Mol_wt) info_c(sw_info_fm,"Fm",fomula_str) + for i=1 upto info_num: &"{"&info[i]&"}" endfor &"}%"; +enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% mc_num:=first_def_number; lr:='(60 for i==1 upto 10:: ,-60,60 endfor); rl:='(-60,lr); @@ -564,7 +557,7 @@ if f_FON[ASCII(c)]=1: z10=(fW,hH); z12=( 0,fH); z13=(hP,fH); z14=(hW,fH); z16=(aW,fH); z18=(hP,aH); z19=(hW,hP); s; atom_font[ASCII(c)]:=currentpicture shifted (font_gap*AL,font_gap*AL); - clearxy; save x,y; clearit; fi enddef; + clearxy; save x,y; clearit; fi enddef; %------------------------------------------------------------------------------------------------- def font_setup= pickup pencircle scaled Apen_wd; fP:=Apen_wd; hP:=.5Apen_wd; FD(" ")(); @@ -663,7 +656,7 @@ def STa(expr a,b)= tblA[incr tbl_cnt]:=a; tblN[tbl_cnt]:=0; wtA[tbl_cnt]:=b; end def STb(expr a)(text s)= tblA[incr tbl_cnt]:=a; tblN[tbl_cnt]:=0; for list=s: tblN[tbl_cnt]:=tblN[tbl_cnt]+1; for j=1 upto tbl_max: if list=tblA[j]: tblB[tbl_cnt][tblN[tbl_cnt]]:=j; fi endfor - endfor enddef; + endfor enddef; %------------------------------------------------------------------------------------------------- tbl_cnt:=0; STa("C",12.0107); STa("H",1.00794); STa("{Al}",26.9815); STa("{As}",74.9236); STa("B",10.811); @@ -696,7 +689,8 @@ def mol_check= hide_H:=warning_cnt:=0; for i=1 upto tbl_max: sumA[i]:=0; endfor knownA:=1; fi endfor if knownA=0: warning(" Unknown Str("&com_str[strA[i]]&") is used "&decimal(i)); fi endfor - sumA[2]:=sumA[2]+hide_H; enddef; + sumA[2]:=sumA[2]+hide_H; +enddef; %------------------------------------------------------------------------------------------------- def checklist_out= Mol_wt:=Mol_wtp:=nA:=0; fomula_str:=""; message "% There were "&fdr(3)(warning_cnt)&" warnings"; @@ -724,7 +718,8 @@ def checklist_out= Mol_wt:=Mol_wtp:=nA:=0; fomula_str:=""; if Mol_wtp<=40: &fdr(10)(Mol_wt); else: &fdr(10)(Mol_wtp)&" * 100"; fi message "% --------------------------------------"; message "% Molecular Fomula: "&fomula_str; - message "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"; enddef; + message "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"; +enddef; %------------------------------------------------------------------------------------------------ def MOL_out= mp_log_name:=jobname&"-"&fit_zero(char_num)&decimal(char_num)&"-"&mol_name&".mol"; printf ""; printf " -MCFtoMOL- "&fixed_l(20)(info[1]); printf ""; |