From 23cd3d2a1aef72188cdf81d605085fd1b9554594 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 5 Nov 2016 21:34:03 +0000 Subject: mcf2graph (5nov16) git-svn-id: svn://tug.org/texlive/trunk@42442 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 77 ++++++++++++++--------- 1 file changed, 47 insertions(+), 30 deletions(-) (limited to 'Master/texmf-dist/metapost') diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index 668964031b3..4a110f441a0 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 4.03 Copyright (c) 2013-2016 Akira Yamaji +% mcf2graph ver 4.04 Copyright (c) 2013-2016 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, @@ -36,7 +36,7 @@ newinternal nA,nB,nC,nD,nE,nF,def_num,def_int,tbl_cnt; numeric save_para[],comD[][],parD[][],cntD[],tbl_str_wd[],tbl_atom[],tbl_subst[][],tbl_atom_wt[], tbl_char_wd[],tbl_char_ht[],tbl_char_dp[]; string tbl_atom_str[],strD[],var[],tag[],mp_log_name,aux_delimiter; -picture atom_font[],chem_structure; +picture atom_font[],mol_stru[]; %------------------------------------------------------------------------------------------------- char_num:=str_cnt:=proc_end:=0; sw_numberA:=sw_numberB:=sw_mol_frame:=sw_auxout:=sw_solid:=sw_expand:=sw_font_frame:=0; @@ -68,7 +68,8 @@ else: f_MP:=0; mode_setup; def printf expr s= message s enddef; fi ahangle:=45; ahlength:=4; -clearit; chem_structure:=currentpicture; +clearit; +for i=0 upto 20: mol_stru[i]:=nullpicture; endfor %-------------------------------------------------------------------------------------------------- let DIV= /; let MUL= *; let LT= <; let GT= >; let AND= &; let :: = : ; let == = =; %-------------------------------------------------------------------------------------------------- @@ -114,25 +115,45 @@ def restore_par(text t)= nA:=0; def beginfont(text s)= store_par(parameter_list); begingroup - save cntA,cntB,cntM,minX,minY,f_beginchar,numS, - posB,posA,posM,lineB,sB,eB,angB,angA,lenB,ang_br,info; + save cntA,cntB,cntM,minX,minY,f_beginchar,numS,sftX,sftY, + posB,posA,posM,lineB,sB,eB,angB,angA,lenB,ang_br,info,pT; numeric lineB[],sB[],eB[],angB[],angA[],lenB[],ang_br[],numS[]; - pair posB[],posA[],posM[]; + pair posB[],posA[],posM[][],pT; string info[]; %------------------------------------------------------------------------------------------------ for i:=1 upto max_inf_num: info[i]:=":"; endfor f_beginchar:=inf_num:=cntM:=0; for list=s: info[incr inf_num]:=list; endfor char_num:=char_num+1; + posM[0][0]:=(0,0); enddef; %================================================================================================== def endfont= - if (sw_font_frame=1)or(sw_font_frame=3): EXT(draw_frame((0,0),w,h,thickness_font_frame);) fi - if (sw_font_frame=2)or(sw_font_frame=3): EXT(draw_frame(p0,wd,ht,thickness_font_frame);) fi - if sw_font_frame=4: EXT(draw_corner(w,h,thickness_font_frame);) fi + if sw_clip>0: + nA:=4095; nB:=-4095; nC:=4095; nD:=-4095; + for i=1 upto cntM: + if xpart(posM[1][i])nB: nB:=xpart(posM[2][i]); fi + if ypart(posM[1][i])nD: nD:=ypart(posM[2][i]); fi + endfor + font_wd#:=font_wd#*((nB-nA+2margin_left_right)/font_wd); + font_ht#:=font_ht#*((nD-nC+2margin_top_bottom)/font_ht); + for i=1 upto cntM: + posM[0][i]:=posM[0][i]+(margin_left_right-nA,margin_top_bottom-nC); + endfor + fi + %----------------------------------------------------------------------------------------------- + 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); + 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 - currentpicture:=chem_structure; - chem_structure:=nullpicture; + for i=0 upto cntM: + addto currentpicture also mol_stru[i] shifted posM[0][i]; mol_stru[i]:=nullpicture; + endfor endchar; clearit; endgroup; @@ -279,9 +300,10 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def EXT(text s)= begingroup - save wd,ht,n,p; pair p[]; wd:=w-2margin_left_right; ht:=h-2margin_top_bottom; - p0:=(margin_left_right,margin_top_bottom); n:=cntM; for i=1 upto n: p[i]:=posM[i]; endfor - s addto chem_structure also currentpicture; clearit; + save w,h,wd,ht,n,p; pair p[]; + w:=font_wd; h:=font_ht; wd:=w-2margin_left_right; ht:=h-2margin_top_bottom; + p0:=(margin_left_right,margin_top_bottom); n:=cntM; for i=1 upto n: p[i]:=posM[1][i]; endfor + s addto mol_stru[0] also currentpicture; clearit; endgroup; enddef; %-------------------------------------------------------------------------------------------------- @@ -289,7 +311,7 @@ def ext(text s)= begingroup save wd,ht,n,a,l,p; numeric a[]; pair p[]; wd:=mol_wd; ht:=mol_ht; l:=bond_len; p0:=(minX,minY); n:=cntA; for i=1 upto n: p[i]:=posA[i]; a[i]:=ang_br[i]; endfor - s addto chem_structure also currentpicture shifted (sftX,sftY); clearit; + s addto mol_stru[cntM] also currentpicture; clearit; endgroup; enddef; %================================================================================================= @@ -299,7 +321,7 @@ def MCd(expr RW,RH)(expr FW,FH)(text TX)= begingroup save com,par,adrA,adrB,f_bra,envT,envB,lenT,lineT,strAT,stkA,stkB,stkL,stkM,cntP, bondL,temp_len,temp_cntB,f_end,f_term,rotT,adrS,f_lineT,f_rotT,f_lenT,f_envT,angT,tempB, - glu,sftX,sftY,xpos,ypos,str_len,max_x,max_y,par_s,par_e,score_u,hat,f_char,lenB, + glu,xpos,ypos,str_len,max_x,max_y,par_s,par_e,score_u,hat,f_char,lenB, ps_adr,ps_com,op_com,op_par,op_cnt,crR,colorA,colorB; %----------------------------------------------------------------------------------------------- save PA,PAs,PP,PG; @@ -337,12 +359,6 @@ def MCd(expr RW,RH)(expr FW,FH)(text TX)= fi proc_char_setup; %----------------------------------------------------------------------------------------------- - if f_beginchar=0: - if sw_clip=1: font_wd#:=font_wd#*((mol_wd+2margin_left_right)/font_wd); - font_ht#:=font_ht#*((mol_ht+2margin_top_bottom)/font_ht); fi - beginchar(char_num,font_wd#,font_ht#,0); f_beginchar:=1; - fi - %----------------------------------------------------------------------------------------------- for i=1 upto cntB: if lineB[i]=si_: draw_bond(i,sB[i],eB[i],angB[i],lineB[i]); fi endfor %----------------------------------------------------------------------------------------------- @@ -357,11 +373,13 @@ def MCd(expr RW,RH)(expr FW,FH)(text TX)= else: draw_atom(i,posA[i],ang_br[i],strD[numS[i]],tbl_str_wd[numS[i]]); fi endfor %----------------------------------------------------------------------------------------------- - sftX:=margin_left_right-minX+(w-mol_wd-2margin_left_right)*FW; - sftY:=margin_top_bottom-minY+(h-mol_ht-2margin_top_bottom)*FH; - posM[incr cntM]:=(minX+sftX,minY+sftY); - if sw_mol_frame=1: ext(draw_frame(p0,wd,ht,0.2pt);) fi - addto chem_structure also currentpicture shifted (sftX,sftY); + sftX:=margin_left_right-minX+(font_wd-mol_wd-2margin_left_right)*FW; + sftY:=margin_top_bottom-minY+(font_ht-mol_ht-2margin_top_bottom)*FH; + posM[0][incr cntM]:=(sftX,sftY); + posM[1][cntM]:=(minX+sftX,minY+sftY); + posM[2][cntM]:=(max_x+sftX,max_y+sftY); + if sw_mol_frame=1: draw_frame((minX,minY),mol_wd,mol_ht,thickness_font_frame) fi + addto mol_stru[cntM] also currentpicture; clearit; endgroup; enddef; @@ -387,12 +405,11 @@ def ps_get(expr n)= enddef; %------------------------------------------------------------------------------------------------- def draw_frame(expr PS,LX,LY,PN)= - draw ((PN/2,PN/2)--(LX-PN/2,PN/2)--(LX-PN/2,LY-PN/2)--(PN/2,LY-PN/2)--cycle) shifted PS wpss PN; + draw ((0,0)--(LX,0)--(LX,LY)--(0,LY)--cycle) shifted PS wpss PN; enddef; %------------------------------------------------------------------------------------------------- def draw_corner(expr LX,LY,PN)= - drawdot (PN/2,PN/2) wpss PN; drawdot (LX-PN/2,PN/2) wpss PN; - drawdot (LX-PN/2,LY-PN/2) wpss PN; drawdot (PN/2,LY-PN/2) wpss PN; + drawdot(0,0) wpss PN; drawdot(LX,0) wpss PN; drawdot(LX,LY) wpss PN; drawdot(0,LY) wpss PN; enddef; %------------------------------------------------------------------------------------------------- def draw_vector(expr POS,ROT,LEN)= -- cgit v1.2.3