diff options
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 199 |
1 files changed, 121 insertions, 78 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index 4fea2752498..3228dc57951 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 4.11 Copyright (c) 2013-2017 Akira Yamaji +% mcf2graph ver 4.20 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, @@ -28,16 +28,18 @@ % Set outputformat to MDL Molfile : mpost -s ahangle=3 FILENAME % Set make first font only : mpost -s ahlength=1 FILENAME % Set output report : mpost -s ahlength=2 FILENAME -% Set 'label' to use Metapost : mpost -s ahlength=3 FILENAME +% Set to use metapost label,arrow : mpost -s ahlength=3 FILENAME %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tracingstats:=1; -message " This is mcf2graph ver 4.1 2017.3"; +message " This is mcf2graph ver 4.2 2017.3"; %------------------------------------------------------------------------------------------------- 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[],str_font[],mol_stru[],save_pict; +pen save_pen; +path arrow_path,arrow_head; %------------------------------------------------------------------------------------------------- char_num:=str_cnt:=proc_end:=0; sw_numberA:=sw_numberB:=sw_mol_frame:=sw_auxout:=sw_solid:=sw_expand:=sw_font_frame:=sw_clip:=0; @@ -52,7 +54,7 @@ if (known green)and(known ahlength): mp_log_name:=jobname&"-info.aux"; if ahlength=1: proc_end:=1; fi % first molecular only if ahlength=2: sw_report:=1; def shipit = enddef; fi % report on - if ahlength=3: sw_label:=1; fi % use metapost label + if ahlength=3: sw_label:=1; sw_arrow:=1; fi % use metapost label 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 @@ -64,19 +66,20 @@ if (known green)and(known ahlength): def printf expr s= write s to mp_log_name enddef; def # = enddef; def Cp(expr s) = if known s: if s<>0: withcolor color_list[s] fi fi enddef; - def define_pixels(text s) = enddef; if unknown sw_label: sw_label:=0; fi + if unknown sw_arrow: sw_arrow:=0; fi else: f_MP:=0; string defaultfont; - sw_label:=0; + dotlabeldiam:=3bp; def Cp(expr s) = enddef; def color = transform enddef; def printf expr s= message s enddef; - sw_label:=0; - def label = label_mf enddef; + %----------------------------------------------------------------------- + sw_label:=sw_arrow:=0; + dotlabeldiam:=3bp; + %----------------------------------------------------------------------- mode_setup; fi -ahangle:=45; ahlength:=4; clearit; for i=0 upto 20: mol_stru[i]:=nullpicture; endfor %-------------------------------------------------------------------------------------------------- @@ -87,19 +90,21 @@ margin_left_right:=margin_top_bottom:=0.4mm; ratio_bond_width:=0.1; ratio_chain_ring:= 0.66; ratio_atom_bond:=0.36; ratio_thickness_bond:=0.015; ratio_char_bond:=1.5; ratio_bondgap_bond:=0.15; ratio_zebragap_bond:=0.12; ratio_zebra_black:=0.4; ratio_wedge_bond:=0.12; ratio_atomgap_atom:=0.050; -offset_thickness#:=0.2pt#; offset_bond_gap#:=0.3pt#; offset_zebra_gap#:=0.1pt#; -offset_atom#:=0.8pt#; offset_wedge#:=0.4pt#; thickness_font_frame#:=0.2pt#; -max_bond_length#:=10mm; bond_len#:=8mm#; -font_wd#:=30mm#; font_ht#:=20mm#; +offset_thickness:=0.2pt; offset_bond_gap:=0.3pt; offset_zebra_gap:=0.1pt; +offset_atom:=0.8pt; offset_wedge:=0.4pt; thickness_font_frame:=0.2pt; +max_bond_length:=10mm; bond_len:=8mm; +font_wd:=30mm; font_ht:=20mm; %================================================================================================== defaultfont:="uhvr8r"; % Helvetica %%%%defaultfont:="ucrr8r"; % Courier %%%%defaultfont:="ucrb8r"; % Courier bold %%%%defaultfont:="utmr8r"; % Times -defaultsize#:=8pt#; -ext_defaultscale:=1; +ahangle:=45; +ahlength:=4bp; +defaultsize:=8bp; +ext_defaultline:=0.5bp; +ext_defaultscale:=defaultscale:=1; labeloffset:=3bp; -define_pixels(defaultsize); %================================================================================================== def_emb_start:=500; % 500 => 2499 for embedded definition (max 2000) def_usr_start:=2500; % 2500 => 2999 for user definition (max 500) @@ -114,12 +119,12 @@ 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_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,sw_label, + sw_atom_frame,sw_font_frame,sw_subst_off,sw_bond_single,sw_clip,sw_label,sw_arrow, 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, - ratio_wedge_bond,ratio_atomgap_atom,ratio_bond_width,font_wd#,font_ht#,labeloffset, - bond_len#,offset_atom#,offset_wedge#,max_bond_length#,offset_zebra_gap#,offset_bond_gap#, - thickness_font_frame#,offset_thickness#,numberA_start,numberA_end,numberB_start,numberB_end + ratio_chain_ring,ratio_bondgap_bond,ratio_zebra_black,ratio_zebragap_bond, + ratio_wedge_bond,ratio_atomgap_atom,ratio_bond_width,font_wd,font_ht,labeloffset, + bond_len,offset_atom,offset_wedge,max_bond_length,offset_zebra_gap,offset_bond_gap, + thickness_font_frame,offset_thickness,numberA_start,numberA_end,numberB_start,numberB_end enddef; %-------------------------------------------------------------------------------------------------- vardef pic_c(expr i,s)= substring(i,i+1) of s enddef; @@ -154,14 +159,14 @@ def endfont= if ypart(posM[1][i])<nC: nC:=ypart(posM[1][i]); fi if ypart(posM[2][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); + font_wd:=nB-nA+2margin_left_right; + font_ht:=nD-nC+2margin_top_bottom; 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) + beginchar(char_num,font_wd/bp*bp#,font_ht/bp*bp#,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; @@ -321,17 +326,28 @@ vardef @@(text t)(expr s)= def_int %------- Retern value ------- enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -def EXT(text s)= - begingroup - save w,h,wd,ht,n,p,am,em,currentscale; - pair p[]; +def ext_setup= + pickup pencircle scaled ext_defaultline; + dotlabeldiam:=3bp; + labeloffset:=3bp; em=defaultscale*defaultsize; - %----------------------------------------------------------------------------------------------- currentscale:=defaultscale:=ext_defaultscale; if sw_label=0: - def label = label_mf enddef; - use_font(defaultscale*defaultsize#)(0.12defaultscale*defaultsize#); + def label = label_emu enddef; + def dotlabel = dotlabel_emu enddef; + ext_use_font(defaultscale*defaultsize)(0.12defaultscale*defaultsize); fi + if sw_arrow=0: + def drawarrow = drawarrow_emu enddef; + def drawdblarrow = drawdblarrow_emu enddef; + fi +enddef; +%-------------------------------------------------------------------------------------------------- +def EXT(text s)= + begingroup + save w,h,wd,ht,n,p,am,em,aw,currentscale; + pair p[]; + ext_setup; w:=font_wd; h:=font_ht; wd:=w-2margin_left_right; @@ -346,17 +362,10 @@ enddef; %-------------------------------------------------------------------------------------------------- def ext(text s)= begingroup - save wd,ht,n,l,p,sp,ep,am,em,A,B,currentscale; + save wd,ht,n,l,p,sp,ep,am,em,aw,A,B,currentscale; numeric A[]bra,B[]ang; pair p[],A[],B[],sp,ep; - em=defaultscale*defaultsize; - %--------------------------------------------------------------------- - currentscale:=defaultscale:=ext_defaultscale; - if sw_label=0: - def label = label_mf enddef; - use_font(defaultscale*defaultsize#)(0.12defaultscale*defaultsize#); - fi - %--------------------------------------------------------------------- + ext_setup; wd:=mol_wd; ht:=mol_ht; l:=bond_len; @@ -369,15 +378,17 @@ def ext(text s)= s addto mol_stru[cntM] also currentpicture; clearit; endgroup; enddef; -%-------------------------------------------------------------------------------------------------- -def use_font(expr WD)(expr PEN)= +%================================================================================================== +def ext_use_font(expr WD)(expr PEN)= save_pict:=currentpicture; clearit; + save_pen:=currentpen; for i=1 upto 128: f_char[i]:=1; endfor proc_char_setup(str_font)(WD)(PEN); currentpicture:=save_pict; + currentpen:=save_pen; enddef; %-------------------------------------------------------------------------------------------------- -def puts(expr PA)(expr STR)= +def ext_puts(expr PA)(expr STR)= begingroup save cp; pair cp; @@ -389,22 +400,25 @@ def puts(expr PA)(expr STR)= if nA=ASCII("_"): if nB=0: nB:=-.5; else: nB:=0; fi elseif nA=ASCII("^"): if nB=0: nB:= .5; else: nB:=0; fi else: - addto currentpicture also str_font[nA] shifted (cp+(0,em*(nB-tbl_char_dp[nA]))); - cp:=cp+(em*tbl_char_wd[nA],0); + addto currentpicture also str_font[nA] + shifted (cp+(0,defaultscale*defaultsize*(nB-tbl_char_dp[nA]))); + cp:=cp+(defaultscale*defaultsize*tbl_char_wd[nA],0); fi endfor endgroup; enddef; %-------------------------------------------------------------------------------------------------- -vardef label_mf@#(expr STR,POS) = +vardef label_emu@#(expr STR,POS) = %% modified 'thelabel@#(expr s,z)' of plain.mp save oft,fx,fy,wds; pair oft,oft.lft,oft.rt,oft.top,oft.bot,oft.ulft,oft.llft,oft.urt,oft.lrt; wds:=0; if currentscale<>defaultscale: - use_font(defaultscale*defaultsize#)(0.12defaultscale*defaultsize#); - currentscale:=defaultscale; + ext_use_font(defaultscale*defaultsize)(0.12defaultscale*defaultsize); + currentscale:=defaultscale; fi - for i=0 upto length(STR)-1: wds:=wds+em*tbl_char_wd[ASCII(pic_c(i,STR))]; endfor + for i=0 upto length(STR)-1: + wds:=wds+defaultscale*defaultsize*tbl_char_wd[ASCII(pic_c(i,STR))]; + endfor oft:= ( 0, 0); fx:=0.5; fy:=0.5; oft.lft:= ( -1, 0); fx.lft:=1; fy.lft:=0.5; oft.rt := ( 1, 0); fx.rt :=0; fy.rt :=0.5; @@ -414,15 +428,41 @@ vardef label_mf@#(expr STR,POS) = oft.urt:= ( .7, .7); fx.urt:=0; fy.urt:=0; oft.llft:=(-.7,-.7); fx.llft:=1; fy.llft:=1; oft.lrt:= ( .7,-.7); fx.lrt:=0; fy.lrt:=1; - puts(POS+(labeloffset*oft@#)-(wds*fx@#,em*fy@#))(STR); + ext_puts(POS+(labeloffset*oft@#)-(wds*fx@#,defaultscale*defaultsize*fy@#))(STR); enddef; %------------------------------------------------------------------------------------------------- -def draw_vector(expr POS,ROT,THICK,LEN)= - fill (-2mm,-(.5THICK+.4mm))--(0,0)--(-2mm,.5THICK+.4mm)--(-2mm,.5THICK)--(-LEN,.5THICK)-- - (-LEN,-.5THICK)--(-2mm,-.5THICK)--cycle rotated ROT shifted POS; +vardef dotlabel_emu@#(expr STR,POS)= + label_emu@#(STR,POS); + draw POS withpen pencircle scaled dotlabeldiam; +enddef; +%================================================================================================== +def drawarrow_emu expr PAT = arrow_path:=PAT; draw_arrow enddef; +%------------------------------------------------------------------------------------------------- +def draw_arrow text t = %% modified 'drawarrow' of plain.mp + filldraw arrow_head rotated ahead_angle(reverse arrow_path) + shifted point infinity of arrow_path t; + draw arrow_path t +enddef; +%------------------------------------------------------------------------------------------------- +def drawdblarrow_emu expr PAT = arrow_path:=PAT; draw_dblarrow enddef; +%------------------------------------------------------------------------------------------------- +def draw_dblarrow text t = + filldraw arrow_head rotated ahead_angle(arrow_path) shifted point 0 of arrow_path t; + filldraw arrow_head rotated ahead_angle(reverse arrow_path) + shifted point infinity of arrow_path t; + draw arrow_path t +enddef; +%------------------------------------------------------------------------------------------------- +arrow_head:=(ahlength,-(sind 0.5ahangle)*ahlength)--(0,0)-- + (ahlength, (sind 0.5ahangle)*ahlength)--cycle; +%------------------------------------------------------------------------------------------------- +def ahead_angle(expr p) = + angle direction .5ahlength/length(point 1 of p - point 0 of p) of p enddef; %================================================================================================= -def MCf(text s)= MCd(1,1)(.5,.5)(s) enddef; % MC fill draw +def MCa(expr FW,FH)(text s)= MCd(1,1)(FW,FH)(s) enddef; +def MCc(expr RW,RH)(text s)= MCd(RW,RH)(0.5,0.5)(s) enddef; +def MCf(text s)= MCd(1,1)(0.5,0.5)(s) enddef; %------------------------------------------------------------------------------------------------- def MCd(expr RW,RH)(expr FW,FH)(text TX)= begingroup @@ -450,23 +490,22 @@ def MCd(expr RW,RH)(expr FW,FH)(text TX)= ''(0)(TX,(_term,0)); proc_bond_atom(1); if (cntP>0)and(sw_subst_off=0): ps_get(1); fi - define_pixels(font_wd,font_ht,thickness_font_frame); char_use_check; - if sw_solid=1: bond_len#:=font_wd#*ratio_bond_width; + if sw_solid=1: bond_len:=font_wd*ratio_bond_width; proc_size_setup; proc_skeleton; proc_scaling; elseif sw_solid=2: proc_size_setup; proc_skeleton; proc_scaling; else: - bond_len#:=3mm#; proc_size_setup; + bond_len:=3mm; proc_size_setup; for i=1 upto 6: proc_skeleton; proc_scaling; if (mol_ht/mol_wd)>(font_ht/font_wd): factor:=(font_ht*RH-2margin_top_bottom)/mol_ht; else: factor:=(font_wd*RW-2margin_left_right)/mol_wd; fi exitif factor=1; - bond_len#:=bond_len#*factor; proc_size_setup; + bond_len:=bond_len*factor; proc_size_setup; endfor - if bond_len#>max_bond_length#: - bond_len#:=max_bond_length#; proc_size_setup; proc_skeleton; proc_scaling; fi + if bond_len>max_bond_length: + bond_len:=max_bond_length; proc_size_setup; proc_skeleton; proc_scaling; fi fi - proc_char_setup(atom_font)(atom_wd#)(bond_pen_wd#*ratio_char_bond); + proc_char_setup(atom_font)(atom_wd)(bond_pen_wd*ratio_char_bond); %----------------------------------------------------------------------------------------------- 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 @@ -528,14 +567,13 @@ def draw_corner(expr LX,LY,PN)= enddef; %------------------------------------------------------------------------------------------------- def proc_size_setup= - if (bond_len#*ratio_atom_bond+offset_atom#)<.8bond_len#: - atom_wd#:=bond_len#*ratio_atom_bond+offset_atom#; - else: atom_wd#:=.8bond_len#; ratio_chain_ring:= .5; fi - wedge_wd#:= bond_len#*ratio_wedge_bond+offset_wedge#; - zebra_gap#:= bond_len#*ratio_zebragap_bond+offset_zebra_gap#; - bondgap#:= bond_len#*ratio_bondgap_bond+offset_bond_gap#; - bond_pen_wd#:= bond_len#*ratio_thickness_bond+offset_thickness#; - define_pixels(bond_len,zebra_gap,wedge_wd,atom_wd,bondgap,bond_pen_wd); + if (bond_len*ratio_atom_bond+offset_atom)<.8bond_len: + atom_wd:=bond_len*ratio_atom_bond+offset_atom; + else: atom_wd:=.8bond_len; ratio_chain_ring:= .5; fi + wedge_wd:= bond_len*ratio_wedge_bond+offset_wedge; + zebra_gap:= bond_len*ratio_zebragap_bond+offset_zebra_gap; + bondgap:= bond_len*ratio_bondgap_bond+offset_bond_gap; + bond_pen_wd:= bond_len*ratio_thickness_bond+offset_thickness; enddef; %------------------------------------------------------------------------------------------------- def proc_scaling= @@ -839,10 +877,15 @@ lr:='(60 for i==1 upto 10:: ,-60,60 endfor); rl:='(-60,lr); def ring expr n= <((-180 DIV n)-90),(_chg_len,0), for i==2 upto n:: ,(360 DIV n) endfor,(_cyc_sB,1-n) enddef; for i=3 upto 20: ?[i]:='({{,ring i,}}); endfor -Ph:=Ph1:='(?6,(_dl,-2),(_dl,-4),(_dl,-6)); Ph2:='(?6,(_dl,-1),(_dl,-3),(_dl,-5)); -!:='((_mk_bond,_arg_ang)); !0:='(<180,180); -!!:='(!,(_mb,db)); !!!:='(!,(_mb,tm)); -for i=1 upto 20: ![i]:='({{,(_get_len,0),! for j==2 upto i::,! endfor,}}); endfor +Ph:=Ph1:='(?6,(_dl,-2),(_dl,-4),(_dl,-6)); +Ph2:='(?6,(_dl,-1),(_dl,-3),(_dl,-5)); +!:=!1:='((_mk_bond,_arg_ang)); +for i=2 upto 20: + ![i]:='({{,(_get_len,0),! for j==2 upto i::,! endfor,}}); +endfor +!!:='(!,(_mb,db)); +!!!:='(!,(_mb,tm)); +!0:='(<180,180); Me:='(); Et:=!; Pr:=!2; Bu:=!3; for i=4,5,6: for j=2 upto i-2: ?[i][j]:='((_fuse,i),(j,0)); endfor endfor for i=5,6,7,8: for j=11 upto 15: ?[i][j]:='((_fuse,i),(j,0)); endfor endfor @@ -902,11 +945,10 @@ pair Z[]; %--------------------------------------------------------------- def FD(expr c)(text s)= if f_char[ASCII(c)]=1: - fP#:=PEN_WD; - hP#:=0.5PEN_WD; - 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(fP,hP,aW,aH); + fP:=PEN_WD; + hP:=0.5PEN_WD; + aW:=SIZE*tbl_char_wd[ASCII(c)]*(1-ratio_atomgap_atom*2); + aH:=SIZE*tbl_char_ht[ASCII(c)]*(1-ratio_atomgap_atom*2); 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); Z09:=(hP,hH); Z10:=(fW,hH); Z12:=( 0,fH); Z13:=(hP,fH); Z14:=(hW,fH); Z16:=(aW,fH); @@ -1225,3 +1267,4 @@ enddef; %------------------------------------------------------------------------------------------------- vardef fit_zero(expr n)=if n<=9: "00" elseif n<=99: "0" fi enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% |