diff options
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 89 |
1 files changed, 61 insertions, 28 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index 48c2b301b3a..eee9dfa0525 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 4.25 Copyright (c) 2013-2017 Akira Yamaji +% mcf2graph ver 4.26 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, @@ -31,7 +31,7 @@ % Set to use plain.mp label,arrow : mpost -s ahlength=3 FILENAME %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tracingstats:=1; -message " This is mcf2graph ver 4.2 2017.7"; +message " This is mcf2graph ver 4.2 2017.8"; %------------------------------------------------------------------------------------------------- newinternal nA,nB,nC,nD,nE,nF,char_num,str_cnt,sub_usr,sub_int,tbl_cnt; numeric save_para[],comD[][],parD[][],cntD[],tbl_str_wd[],tbl_atom[],tbl_subst[][],tbl_atom_wt[], @@ -41,7 +41,7 @@ string tbl_atom_str[],strD[],var[],tag[],mp_log_name,aux_delimiter,atomfont, picture mol_stru[]; path arrow_path,arrow_head; %------------------------------------------------------------------------------------------------- -char_num:=str_cnt:=proc_end:=0; +char_num:=str_cnt:=proc_end:=sw_label_emu:=0; sw_numberA:=sw_numberB:=sw_mol_frame:=sw_auxout:=sw_solid:=sw_expand:=sw_font_frame:=sw_clip:=0; sw_atom_frame:=sw_report:=sw_MOLout:=sw_subst_off:=sw_bond_single:=sw_auxfix:=sw_arrow:=0; numberA_start:=numberB_start:=1; numberA_end:=numberB_end:=4095; aux_max:=max_inf_num:=20; @@ -122,7 +122,7 @@ 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_arrow, + sw_atom_frame,sw_font_frame,sw_subst_off,sw_bond_single,sw_clip,sw_arrow,sw_label_emu, margin_left_right,margin_top_bottom,ratio_atom_bond,ratio_thickness_bond,ratio_char_bond, 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, @@ -146,10 +146,13 @@ def beginfont(text s)= save_defaultfont:=defaultfont; begingroup save cntA,cntB,cntM,minX,minY,f_beginchar,numS,sftX,sftY,f_ext, + cal_FM,cal_MW,cal_MW_str,cal_MI,cal_MI_str, + inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW, posBs,posBe,posA,posM,lineB,sB,eB,angB,angA,lenB,ang_br,info,pT; numeric lineB[],sB[],eB[],angB[],angA[],lenB[],ang_br[],numS[]; pair posA[],posM[][],pT,posBs,posBe; - string info[]; + string info[],cal_FM,cal_MW,cal_MW_str,cal_MI,cal_MI_str, + inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW; %------------------------------------------------------------------------------------------------ for i:=1 upto max_inf_num: info[i]:=":"; endfor f_ext:=inf_num:=cntM:=0; @@ -179,7 +182,6 @@ def endfont= 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_report=1)or(sw_MOLout=1))and(f_MP=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 @@ -330,7 +332,7 @@ def ext_setup= dotlabeldiam:=3bp; labeloffset:=3bp; em=defaultscale*defaultsize; - if (defaultfont="draw")or(f_MP=0): + if (defaultfont="draw")or(f_MP=0)or(sw_label_emu=1): save label,dotlabel; def label = label_emu enddef; def dotlabel = dotlabel_emu enddef; @@ -375,27 +377,47 @@ enddef; %================================================================================================== def ext_puts(expr PA)(expr STR)= begingroup - save cp,sA; + save cp,sA,pC; pair cp; string sA; + picture pC; cp:=PA; + nB:=defaultscale*defaultsize; + nC:=0; %------------------------------------------------------------------------------------------------ for i=0 upto length(STR)-1: sA:=pic_c(i,STR); nA:=ASCII(sA); - nB:=defaultscale*defaultsize; - draw_char(sA,cp,nB,0.35*ratio_char_bond*bp,0); - cp:=cp+(nB*tbl_char_wd[nA],0); + if sw_label_emu=1: + if sA="_": if nC=-0.5: nC:=0; else: nC:=-0.5; fi + elseif sA="^": if nC= 0.5: nC:=0; else: nC:= 0.5; fi + else: + if defaultfont="draw": + draw_char(sA,cp+(0,nB*nC),nB,0.35*ratio_char_bond*bp,0); + cp:=cp+(nB*tbl_char_wd[nA],0); + else: + pC:=sA infont defaultfont scaled defaultscale; + addto currentpicture also pC shifted (cp+(0,nB*nC)); + cp:=cp+(lrcorner pC-llcorner pC); + fi + fi + else: draw_char(sA,cp,nB,0.35*ratio_char_bond*bp,0); + cp:=cp+(nB*tbl_char_wd[nA],0); + fi endfor endgroup; enddef; %-------------------------------------------------------------------------------------------------- vardef label_emu@#(expr STR,POS) = %% modified 'thelabel@#(expr s,z)' of plain.mp - save oft,fx,fy,wds; + save oft,fx,fy,wds,sC; pair oft,oft.lft,oft.rt,oft.top,oft.bot,oft.ulft,oft.llft,oft.urt,oft.lrt; + string sC; wds:=0; for i=0 upto length(STR)-1: - wds:=wds+defaultscale*defaultsize*tbl_char_wd[ASCII(pic_c(i,STR))]; + sC:=pic_c(i,STR); + if not((sw_label_emu=1)and((sC="_")or(sC="^"))): + wds:=wds+defaultscale*defaultsize*tbl_char_wd[ASCII(sC)]; + fi endfor oft:= ( 0, 0); fx:=0.5; fy:=0.5; oft.lft:= ( -1, 0); fx.lft:=1; fy.lft:=0.5; @@ -529,6 +551,7 @@ def MCd(expr RW,RH)(expr FW,FH)(text TX)= addto mol_stru[cntM] also currentpicture; clearit; endgroup; + if ((sw_auxout=1)or(sw_report=1)or(sw_MOLout=1))and(f_MP=1): proc_calc_out; fi %----------------------------------------------------------------------------------------------- %%%% message "count of usr ="& decimal(sub_usr) &" "& decimal(sub_usr-sub_usr_start); %%%% message "count of int ="& decimal(sub_int) &" "& decimal(sub_int-sub_int_start); @@ -769,9 +792,10 @@ enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def draw_atom(expr NUM,POS,ANG,STR,WD)= begingroup - save pA,pT,dx; + save pA,pT,dx,pC,nE,nC; string sB; pair pA,pT; + picture pC; %---------------------------------------------------------------------------------------------- if ((ANG mod 360)<=90+1)or((ANG mod 360)>=270-1): dx:=1; else: dx:=-1; fi pT:=POS-(0.5atom_wd*dx*WD,0.5atom_wd); @@ -785,19 +809,30 @@ def draw_atom(expr NUM,POS,ANG,STR,WD)= elseif nB=hat: if nE=0: nE:= .5; else: nE:=0; fi; elseif (nB<>par_s)and(nB<>par_e): nA:=atom_wd*tbl_char_wd[nB]; - pA:=pT+(0.5*((dx-1)*nA),nE*atom_wd); - if sw_atom_frame=1: draw_frame(pA,nA,atom_wd,0.1pt); fi - if (sw_numberA>=1)or(sw_numberB>=1): - erase fill unitsquare xscaled nA yscaled atom_wd shifted pA wpcs 0.01pt; - fi if (atomfont<>"draw")and(f_MP=1): - addto currentpicture also char(nB) infont atomfont - scaled (atom_wd/atomfontsize) shifted pA Cp(colorA[NUM]); + pC:=sB infont atomfont scaled (atom_wd/atomfontsize); + if dx=-1: pA:=pT-(lrcorner pC-llcorner pC)+(0,nE*atom_wd); + else: pA:=pT+(0,nE*atom_wd); + fi + if (sw_numberA>=1)or(sw_numberB>=1): + erase fill (llcorner pC--lrcorner pC--urcorner pC--ulcorner pC--cycle) shifted pA; + fi + addto currentpicture also pC shifted pA Cp(colorA[NUM]); + if sw_atom_frame=1: + draw ((llcorner pC--lrcorner pC--urcorner pC--ulcorner pC--cycle) shifted pA) + withpen pencircle scaled 0.01pt; + fi + pT:=pT+(lrcorner pC-llcorner pC)*dx; else: + if dx=-1: pA:=pT+(-nA,nE*atom_wd); else: pA:=pT+(0,nE*atom_wd); fi + if (sw_numberA>=1)or(sw_numberB>=1): + erase fill unitsquare xscaled nA yscaled atom_wd shifted pA; + fi draw_char(sB,pA,atom_wd,bond_pen_wd*ratio_char_bond,NUM); + if sw_atom_frame=1: draw_frame(pA,nA,atom_wd,0.1pt); fi + pT:=pT+(nA*dx,0); fi - pT:=pT+(nA*dx,0); - fi + fi endfor endgroup enddef; @@ -944,7 +979,7 @@ char_size_set(.7)( 1)(" ()[]0123456789nhj=_bdtfgpq"); char_size_set(.7)(.7)("*"); char_size_set(.5)( 1)("il"); char_size_set(.7)(.8)("acekosuvxzwry"); -char_size_set(.4)( 1)(".,:;'`"); +char_size_set(.4)( 1)(".,:;'`^"); %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% def draw_char(expr c,POS,WD,PEN,NUM)= save Z,aW,aH,fW,fH,hW,hW,hH,fP,hP,pathO,pathOh,ef,pos,ppcs,sbp,dw,dwh,dwv,cdw; @@ -1115,11 +1150,9 @@ STb("C{H_3_}")("C","H","H","H"); STb("C{F_3_}")("C","F","F","F"); %================================================================================================== def proc_calc_out= begingroup - save warning_cnt,cal_MW,MWp,knownA,cal_FM,bondC,tmp_wtp,bond_cnt,cnt_hide_H, - inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW; + save warning_cnt,MWp,knownA,bondC,tmp_wtp,bond_cnt,cnt_hide_H; numeric sumA[],bondC[],hideH[]; - string cal_FM,cal_MW,cal_MW_str,cal_MI,cal_MI_str,sumA,s_tag,s_var, - inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW; + string sumA,s_tag,s_var; inf_NO:=inf_EN:=inf_JN:=inf_FM:=inf_CAS:=inf_USE:=inf_EXA:=inf_EXB:=inf_MW:=""; cal_MW:=cal_MW_str:=cal_FM:=""; cnt_hide_H:=warning_cnt:=MW_num:=MI_num:=MWp:=0; %------------------------------------------------------------------------------------------ |