diff options
author | Karl Berry <karl@freefriends.org> | 2021-03-07 22:04:32 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-03-07 22:04:32 +0000 |
commit | 7afd3410de5ecc644213fcbab439b023e44253b8 (patch) | |
tree | 27d33527dab6c575ad94f7b8f9c9b69fc7ce7c0a /Master/texmf-dist/metapost | |
parent | 0ce7cbf84226220eaf916f5ed2657fe1981691d0 (diff) |
mcf2graph (7mar21)
git-svn-id: svn://tug.org/texlive/trunk@58197 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 130 |
1 files changed, 67 insertions, 63 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index 9c68e1d84c9..cdffa5932cc 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 4.59 Copyright (c) 2013-2021 Akira Yamaji +% mcf2graph ver 4.60 Copyright (c) 2013-2021 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, @@ -37,14 +37,15 @@ % Set to use plain.mp (label,arrow,atom) : mpost -s labeloffset=2 FILENAME %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% tracingstats:=1; -message "* This is mcf2graph ver 4.59 2021.02.28"; +message "* This is mcf2graph ver 4.60 2021.03.07"; %------------------------------------------------------------------------------------------------- newinternal cntA,cntB,cntM,minX,minY,maxX,maxY,sftX,sftY,com,par,envT,envB,lenT,lineT,angT,rotT, crR,nA,nB,nC,nD,nE,nF,nS,nL,nR,nU,nP,xpos,ypos,markA,markB,saveA,saveB,bondL; numeric save_num[],comD[][],parD[][],adrD[][],cntD[],tbl_atom[],tbl_group[][],f_char[], tbl_atom_wt[],tbl_atom_mi[],tbl_char_wd[],tbl_char_ht[],addA[],add_rot[],chargeA[], com_group[][],par_group[][],cnt_group[],colorA[],colorB[],sumA[],bondC[],hideH[], - lineB[],sB[],eB[],angB[],angA[],lenB[],angX[],numS[],wdM[],htM[],wdA[],dxA[],mc_indent[]; + lineB[],sB[],eB[],angB[],angA[],lenB[],angX[],numS[],wdM[],htM[],wdA[],dxA[], + mc_indent[],cmm_adr[]; string save_str[],tbl_atom_str[],strD[],tag[],out_file_name,out_file_aux, out_file_rep,out_file_mpc,aux_delimiter,atomfont,mpfont,s_tag,s_var,cal_FM,cal_MW,cal_MI, inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW,blank_str; @@ -186,9 +187,9 @@ fi ?3:=?20:=Ph:=Ph1:=Ph2:=hz:=0; vt:=1; ratio_chain_ring:=0.66; ratio_atom_bond:=0.36; ratio_thickness_bond:=0.015; ratio_thickness_char:=0.1; 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.040; -offset_thickness:=0.2bp; offset_bond_gap:=0.3bp; offset_zebra_gap:=0.1bp; +ratio_hashgap_bond:=0.12; ratio_hash_black:=0.4; ratio_wedge_bond:=0.12; +ratio_atomgap_atom:=0.04; +offset_thickness:=0.2bp; offset_bond_gap:=0.3bp; offset_hash_gap:=0.1bp; offset_atom:=0.8pt; offset_wedge:=0.4bp; thickness_fframe:=0.2bp; thickness_mframe:=0.2bp; thickness_aframe:=0.1bp; max_blength:=10mm; blength:=mangle:=0; max_labelsize:=20mm; dottedline_gap:=1.5bp; @@ -214,15 +215,15 @@ def_com(-4090)(_com,_jp_atom,_jp_absA,_jp_bond,_cyc,_cyc_sB,_cyc_eB,_set_line,_t _chg_len,_get_len,_ring_len,_tmp_len,_rot_ang,_adj_ang,_chg_env,_tmp_env,_set_colorA,_set_colorB, _group_si,_set_adr,_mk_bond,_set_atom,_arrange_ang,_chg_atom,_tmp_rot,_fuse,_size_atom,_numeric, _jump_at,_set_add,_chg_add,_nop,_mark,_moff,_term,_len_s,_len_e,_len_ss,_len_ee, - _group_s,_group_e,_rest,_charge,_zero_ang, + _group_s,_group_e,_rest,_charge, si,dl,dl_,dr,dr_,db,dm,dm_,tm,wf,wb,bd,bz,zf,zb,dt,wv,nl,vf,vb,nb,si_,wf_,wb_,zf_,zb_,wv_,bd_); %-------------------------------------------------------------------------------------------------- def parameter_list= sw_rep_out,sw_numberA,sw_numberB,sw_mframe,sw_aux_out,sw_expand,sw_mol_out,sw_calc, sw_single,sw_ext_all,sw_aframe,sw_fframe,sw_group_off,sw_trimming,sw_arrow_emu, ratio_atom_bond,ratio_thickness_bond,ratio_char_bond,ratio_chain_ring,ratio_bondgap_bond, - ratio_zebra_black,ratio_zebragap_bond,ratio_thickness_char,ratio_wedge_bond,ratio_atomgap_atom, - lonepairdiam,lonepairspace,blength,offset_atom,offset_wedge,max_blength,offset_zebra_gap, + ratio_hash_black,ratio_hashgap_bond,ratio_thickness_char,ratio_wedge_bond,ratio_atomgap_atom, + lonepairdiam,lonepairspace,blength,offset_atom,offset_wedge,max_blength,offset_hash_gap, offset_bond_gap,thickness_fframe,thickness_mframe,thickness_aframe,offset_thickness, numberA_start,numberA_end,numberB_start,numberB_end,defaultsize,defaultscale,labeloffset,mangle, fsize,fmargin,msize,mposition,defaultfont,atomfont,dottedline_gap, @@ -323,10 +324,12 @@ def endfont= %---------------------------------------------------------------------------------------- if f_MP=0: beginchar(char_num,font_wd/bp*bp#,font_ht/bp*bp#,0) else: beginfig(char_num) w:=charwd:=font_wd; h:=charht:=font_ht; chardp:=0; + if (sw_fframe<>1)and(sw_fframe<>3): draw_corner((0,0),w,h,0.05bp); fi + fi + if (sw_fframe=1)or(sw_fframe=3): draw_frame((0,0),w,h,thickness_fframe); fi + if (sw_fframe=2)or(sw_fframe=3): + draw_frame((margin_lr,margin_tb),w-2margin_lr,h-2margin_tb,thickness_fframe); fi - if (sw_fframe=1)or(sw_fframe=3): ext(draw_frame((0,0),w,h,thickness_fframe);) fi - if (sw_fframe=2)or(sw_fframe=3): ext(draw_frame(p0,w0,h0,thickness_fframe);) fi - if sw_fframe=4: ext(draw_corner((0,0),w,h,0.2bp);) fi for i=1 upto cntM: addto currentpicture also mol_stru[i] shifted posM[0][i]; mol_stru[i]:=nullpicture; if sw_mframe=1: ext(draw_frame(p[i],w[i],h[i],thickness_mframe)) fi @@ -379,8 +382,7 @@ tertiarydef a op_bq b = if known b:: (_tmp_len,b),a else:: _nop,a fi enddef; def rot_angle primary n = (_rot_ang,n) enddef; def cyc_atom primary n = (_cyc,n) enddef; def jump_atom primary a = - if numeric a:: (_jp_atom,a) - elseif pair a:: (_jp_atom,$1),(_com,_zero_ang),angle(a)~0`length(a),(_com,_zero_ang) fi + if numeric a:: (_jp_atom,a) elseif pair a:: (_jp_atom,$1),<$0,angle(a)~0`length(a),<$0 fi enddef; def chg_length primary n = (_com,_len_s),(_chg_len,n) enddef; def group_si secondary n == if known n:: (_group_si,n) else:: _nop fi enddef; @@ -934,7 +936,7 @@ def proc_size_setup= atom_wd:=.8blen; ratio_chain_ring:= .5; fi wedge_wd:= blen*ratio_wedge_bond+offset_wedge; - zebra_gap:= blen*ratio_zebragap_bond+offset_zebra_gap; + hash_gap:= blen*ratio_hashgap_bond+offset_hash_gap; bondgap:= blen*ratio_bondgap_bond+offset_bond_gap; bond_pen_wd:= blen*ratio_thickness_bond+offset_thickness; enddef; @@ -1051,14 +1053,13 @@ def proc_skeleton(expr a)= ef com=_com: if par=_mark: saveA:=markA; saveB:=markB; markA:=cntA; markB:=cntB; ef par=_rest: markA:=saveA; markB:=saveB; ef par=_moff: markA:=markB:=0; ef par=_term: termB; - ef par=_zero_ang: angT:=0; ef par=_group_e: lineT:=si; lenT:=crR; rotT:=envT:=0; fi ef com=_jp_bond: termB; nA:=getB(par); posBs:=posA[sB[nA]]; angT:=angB[nA]; f_bra:=1; rotT:=0; ef com=_jp_atom: termB; adrT:=getA(par); posBs:=posA[adrT]; angT:=angX[adrT]; f_bra:=1; rotT:=0; ef com=_jp_absA: adrT:=par; posBs:=posA[adrT]; angT:=angX[adrT]; f_bra:=1; rotT:=0; temp_cntB:=cntB; ef com=_adj_ang: angT:=adjust_ang(angT); - ef com=_rot_ang: angT:=(angT+par) mod 360; + ef com=_rot_ang: if par>-3700: angT:=(angT+par) mod 360; else: angT:=(par+4095) mod 360; fi ef com=_tmp_rot: rotT:=par; ef com=_group_si: rotT:=0; ef com=_chg_env: envB:=par; @@ -1078,7 +1079,8 @@ def add_bond(expr ROT,FLG)= angX[cntA]:=(angT+nA/2+iif(nA>=0,-90,90)) mod 360; else: f_bra:=0; fi - cntB:=cntB+1; angB[cntB]:=angT:=(angT+nA) mod 360; + cntB:=cntB+1; + if nA>-3700: angB[cntB]:=angT:=(angT+nA) mod 360; else: angB[cntB]:=angT:=nA+4095; fi if FLG=1: if lenB[cntB]=_size_atom: posBe:=sfrt(posBs,atom_wd,angT); else: @@ -1209,7 +1211,7 @@ def draw_bond(expr NUM)= ef nL=bz: bz_put(sfrt(Ls,ww,ap),sfrt(Le,ww,ap),sfrt(Ls,ww,am),sfrt(Le,ww,am)); 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 .75zebra_gap/len until 1: drawdot i[Ls,Le] Cp(col); endfor + ef nL=dt: for i=0 step .75hash_gap/len until 1: drawdot i[Ls,Le] Cp(col); endfor ef nL=wv: nA:=3bond_pen_wd; nB:=len/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))]) @@ -1245,16 +1247,16 @@ def draw_bond(expr NUM)= enddef; %------------------------------------------------------------------------------------------------ def wz_put(expr PA,PB,PD)= - for i=0 upto len/zebra_gap: - nA:=zebra_gap*i/len; nD:=(zebra_gap*i+ratio_zebra_black*zebra_gap)/len; - if nD>((len-zebra_gap)/len): nD:=1; fi + for i=0 upto len/hash_gap: + nA:=hash_gap*i/len; nD:=(hash_gap*i+ratio_hash_black*hash_gap)/len; + if nD>((len-hash_gap)/len): nD:=1; fi fill nA[PB,PA]--nA[PD,PA]--nD[PD,PA]--nD[PB,PA]--cycle Cp(col); endfor enddef; %------------------------------------------------------------------------------------------------ def bz_put(expr PA,PB,PC,PD)= - for i=0 upto len/zebra_gap: - nA:=zebra_gap*i/len; nD:=(zebra_gap*i+ratio_zebra_black*zebra_gap)/len; + for i=0 upto len/hash_gap: + nA:=hash_gap*i/len; nD:=(hash_gap*i+ratio_hash_black*hash_gap)/len; fill nA[PB,PA]--nA[PD,PC]--nD[PD,PC]--nD[PB,PA]--cycle Cp(col); endfor enddef; @@ -1582,7 +1584,8 @@ def proc_report_out= printf (substring(0,mc_indent[i]) of blank_str)&mc[i]; endfor printf "---------------------------------------------------------------------------"; - printf " mc length="&fdr(4)(length(mc))&" / mc low="&fdr(3)(mc_low); + printf " mc-length="&fdr(4)(length(mc))&" / mc-low="&fdr(3)(mc_low)& + " / mc-commands="&fdr(3)(cmm_cnt); fi printf "---------------------------------------------------------------------------"; printf " Warnings = "&fdr(3)(warning_cnt)&" / Command count= "&decimal(cntD[0]); @@ -1797,46 +1800,46 @@ def expand_set= enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% vardef check_mc(expr s)= - save mc_char,mc_char,temp_c,err_cnt,char_cnt; + save mc_char,mc_char,temp_c,err_cnt,char_cnt,f_depth, + a_prn_s_cnt,a_prn_e_cnt,a_brc_s_cnt,a_brc_e_cnt,a_brk_s_cnt,a_brk_e_cnt; + f_depth:=cmm_cnt:=0;; string temp_c,err_str[],err_type[]; numeric mc_char[],err_adr[],err_code[]; err_cnt:=char_cnt:=code_cnt:=0; - err_type[1]:=" '(' > ')' "; - err_type[2]:=" '(' < ')' "; - err_type[3]:=" '{' > '}' "; - err_type[4]:=" '{' < '}' "; - err_type[5]:=" '[' > ']' "; - err_type[6]:=" '[' < ']' "; - err_type[7]:="missing arg"; - err_type[8]:="extra arg "; + err_type[1]:=" '(' > ')' "; err_type[2]:=" '(' < ')' "; + err_type[3]:=" '{' > '}' "; err_type[4]:=" '{' < '}' "; + err_type[5]:=" '[' > ']' "; err_type[6]:=" '[' < ']' "; + err_type[7]:="missing arg"; err_type[8]:="extra arg "; %----------------------------------------------------------------------------------------------- for i=1 upto length(s): temp_c:=subc(i,s); if temp_c<>" ": char_cnt:=char_cnt+1; mc_char[char_cnt]:=ASCII(temp_c); fi endfor mc_char[0]:=mc_char[char_cnt+1]:=mc_char[char_cnt+2]:=a_cmm; %-- argument missing chkeck -------------------------------------------------------------------- - nA:=1; + a_prn_s_cnt:=a_prn_e_cnt:=a_brc_s_cnt:=a_brc_e_cnt:=a_brk_s_cnt:=a_brk_e_cnt:=0; + nA:=f_depth:=cmm_cnt:=0; forever: - nB:=mc_char[nA-1]; nC:=mc_char[nA]; nD:=mc_char[nA+1]; nE:=mc_char[nA+2]; nF:=mc_char[nA+3]; + nA:=nA+1; nB:=mc_char[nA-1]; nC:=mc_char[nA]; nD:=mc_char[nA+1]; %--------------------------------------------------------------------------------------------- - if nC=a_cmm: - ef (nC=a_ast)and(nD=a_sls)and(nE=a_ast)and(nF=a_cmm): proc_error(7,nA) nA:=nA+3; % */* x - ef (nC=a_sls)and(nD=a_sls)and(nE=a_cmm): proc_error(7,nA) nA:=nA+2; % // x - ef (nC=a_sls)and(nD=a_ast)and(nE=a_cmm): proc_error(7,nA) nA:=nA+2; % /* x - ef (nC=a_ast)and(nD=a_sls)and(nE=a_cmm): proc_error(7,nA) nA:=nA+2; % */ x - ef (nC=a_ast)and(nD=a_ast)and(nE=a_cmm): proc_error(7,nA) nA:=nA+2; % ** x - ef (nC=a_hsh)and(nD=a_hsh): nA:=nA+2; % ## - ef (nC=a_sls)and(nD=a_cmm): proc_error(7,nA) % / x - ef (nC=a_dol)and(nD=a_cmm): proc_error(7,nA) % $ x - %-------------------------------------------------------------------------------------------- + if nC=a_cmm: if f_depth=0: cmm_cnt:=cmm_cnt+1; cmm_adr[cmm_cnt]:=nA; fi + ef nC=a_ast: + if nD=a_sls: + if mc_char[nA+2]=a_ast: if mc_char[nA+3]=a_cmm: proc_error(7,nA) nA:=nA+2; fi % */* x + ef mc_char[nA+2]=a_cmm: proc_error(7,nA) nA:=nA+1; fi % */ x + ef nD=a_ast: if mc_char[nA+2]=a_cmm: proc_error(7,nA) nA:=nA+1; fi fi % ** x + ef nC=a_sls: if nD=a_sls: if mc_char[nA+2]=a_cmm: proc_error(7,nA) nA:=nA+1; fi % // x + ef nD=a_ast: if mc_char[nA+2]=a_cmm: proc_error(7,nA) nA:=nA+1; fi % /* x + ef nD=a_cmm: proc_error(7,nA) fi % / x + ef nC=a_hsh: if nD=a_hsh: nA:=nA+1; % ## + ef nD=a_cmm: proc_error(7,nA) fi % # x + if nB<>a_cmm: proc_error(8,nA) fi % a # + ef nC=a_dol: if nD=a_cmm: proc_error(7,nA) fi % $ x ef nC=a_equ: if nD= a_cmm: proc_error(7,nA) fi % = x if nB= a_cmm: proc_error(7,nA) fi % x = ef nC=a_cln: if nD= a_cmm: proc_error(7,nA) fi % : x if nB= a_cmm: proc_error(7,nA) fi % x : ef nC=a_amk: if nD= a_cmm: proc_error(7,nA) fi % @ x if nB<>a_cmm: proc_error(8,nA) fi % a @ - ef nC=a_hsh: if nD= a_cmm: proc_error(7,nA) fi % # x - if nB<>a_cmm: proc_error(8,nA) fi % a # ef nC=a_and: if nD= a_cmm: proc_error(7,nA) fi % & x if nB<>a_cmm: proc_error(8,nA) fi % a & ef nC=a_gtn: if nD= a_cmm: proc_error(7,nA) fi % < x @@ -1850,32 +1853,33 @@ vardef check_mc(expr s)= ef nC=a_bqt: if nD= a_cmm: proc_error(7,nA) fi % ` x if nB= a_cmm: proc_error(7,nA) fi % x ` %--------------------------------------------------------------------------------- + ef nC=a_prn_s: a_prn_s_cnt:=a_prn_s_cnt+1; f_depth:=1; + ef nC=a_prn_e: a_prn_e_cnt:=a_prn_e_cnt+1; f_depth:=0; + ef nC=a_brc_s: a_brc_s_cnt:=a_brc_s_cnt+1; f_depth:=1; + ef nC=a_brc_e: a_brc_e_cnt:=a_brc_e_cnt+1; f_depth:=0; + ef nC=a_brk_s: a_brk_s_cnt:=a_brk_s_cnt+1; f_depth:=1; + ef nC=a_brk_e: a_brk_e_cnt:=a_brk_e_cnt+1; f_depth:=0; + %--------------------------------------------------------------------------------- fi - nA:=nA+1; - exitif nA>=char_cnt; - endfor - %-- check brackets ----------------------------------------------------------------------------- - nA:=nB:=nC:=nD:=nE:=nF:=0; - for i=1 upto char_cnt: - if mc_char[i]=a_prn_s: nA:=nA+1; ef mc_char[i]=a_prn_e: nB:=nB+1; - ef mc_char[i]=a_brc_s: nC:=nC+1; ef mc_char[i]=a_brc_e: nD:=nD+1; - ef mc_char[i]=a_brk_s: nE:=nE+1; ef mc_char[i]=a_brk_e: nF:=nF+1; - fi + exitif nA>=char_cnt+1; endfor - if nA>nB: proc_error(1,0) ef nA<nB: proc_error(2,0) fi - if nC>nD: proc_error(3,0) ef nC<nD: proc_error(4,0) fi - if nE>nF: proc_error(5,0) ef nE<nF: proc_error(6,0) fi + %-- brackets balance check --------------------------------------------------------------------- + if a_prn_s_cnt>a_prn_e_cnt: proc_error(1,0) ef a_prn_s_cnt<a_prn_e_cnt: proc_error(2,0) fi + if a_brc_s_cnt>a_brc_e_cnt: proc_error(3,0) ef a_brc_s_cnt<a_brc_e_cnt: proc_error(4,0) fi + if a_brk_s_cnt>a_brk_e_cnt: proc_error(5,0) ef a_brk_s_cnt<a_brk_e_cnt: proc_error(6,0) fi %----------------------------------------------------------------------------------------------- for i=1 upto err_cnt: message "*"&fdr(3)(i)&" "&err_type[err_code[i]]&fdr(4)(err_adr[i])&" '"&err_str[i]&"'"; endfor -%%%% readstring; +%%%%%% readstring; err_cnt enddef; %------------------------------------------------------------------------------------------------- def proc_error(expr ERR_CODE,ADR)= err_cnt:=err_cnt+1; err_adr[err_cnt]:=ADR; err_code[err_cnt]:=ERR_CODE; - if ADR=0: err_str[err_cnt]:=" "; else: err_str[err_cnt]:=substring (ADR-3,ADR+2) of mc; fi + if ERR_CODE<=6: err_str[err_cnt]:=" "; + else: err_str[err_cnt]:=substring (ADR-3,ADR+2) of mc; + fi enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |