diff options
author | Karl Berry <karl@freefriends.org> | 2016-11-15 22:46:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-11-15 22:46:47 +0000 |
commit | 9a85ca320191b3d06008f820b014995ad9dc7d6b (patch) | |
tree | 81ed5bc37494abb060a3f2de495f8817f57b2261 /Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | |
parent | 641d2fe55a65adfc9744dedd88679025c0444b92 (diff) |
mcf2graph (15nov16)
git-svn-id: svn://tug.org/texlive/trunk@42515 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf')
-rw-r--r-- | Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf | 275 |
1 files changed, 166 insertions, 109 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf index 4a110f441a0..01d2d083e29 100644 --- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf +++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -% mcf2graph ver 4.04 Copyright (c) 2013-2016 Akira Yamaji +% mcf2graph ver 4.05 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, @@ -32,7 +32,7 @@ tracingstats:=1; message " This is mcf2graph ver 4.0 2016.11"; %------------------------------------------------------------------------------------------------- -newinternal nA,nB,nC,nD,nE,nF,def_num,def_int,tbl_cnt; +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_char_wd[],tbl_char_ht[],tbl_char_dp[]; string tbl_atom_str[],strD[],var[],tag[],mp_log_name,aux_delimiter; @@ -88,11 +88,10 @@ def_int_start:=3000; % 3000 => 4000 for internal definition (max 1000) %-------------------------------------------------------------------------------------------------- def def_com(expr n)(text tx)= nA:=n; forsuffixes list=tx:: list:=nA; nA:=nA+1; endfor enddef; def_com(-4000)(_term,_jp_atom,_jp_atom_abs,_jp_bond,_cyc,_cyc_sB,_cyc_eB,_set_line,_chg_line, - _dl,_N,_O,_S,_H,_tmp_line,_chg_len,_get_len,_ring_len,_tmp_len,_rot_ang,_set_ang,_adj_ang, - _chg_env,_tmp_env,_set_colorA,_set_colorB,_postA,_postB,_postC,_postD,_postE,_postF,_set_psA, - _stack_reset,_set_clr,_set_adr,_mk_bond,_set_atom,_arg_ang,_chg_atom,_tmp_rot,_fuse,_push, - _pop,_size_a); -def_com(1)(si,dl,dr,dm,tm,wf,wb,bd,bz,zf,zb,dt,no,ar,vf,vb,wv,nl,si_,wf_,wb_,bd_); + _dl,_N,_O,_S,_H,_tmp_line,_chg_len,_get_len,_ring_len,_tmp_len,_rot_ang,_adj_ang,_chg_env, + _tmp_env,_set_colorA,_set_colorB,_postA,_postB,_postC,_postD,_postE,_postF,_set_psA,_stack_reset, + _set_clr,_set_adr,_mk_bond,_set_atom,_arg_ang,_chg_atom,_tmp_rot,_fuse,_push,_pop,_size_a); +def_com(1)(si,dl,dr,dm,tm,wf,wb,bd,bz,zf,zb,dt,wv,nl,vf,vb,si_,wf_,wb_,bd_); %-------------------------------------------------------------------------------------------------- def parameter_list= sw_checklist,sw_numberA,sw_numberB,sw_mol_frame,sw_auxout,sw_solid,sw_expand,sw_MOLout, @@ -115,17 +114,16 @@ 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,sftX,sftY, - posB,posA,posM,lineB,sB,eB,angB,angA,lenB,ang_br,info,pT; + save cntA,cntB,cntM,minX,minY,f_beginchar,numS,sftX,sftY,f_ext, + 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 posB[],posA[],posM[][],pT; + pair posA[],posM[][],pT,posBs,posBe; string info[]; %------------------------------------------------------------------------------------------------ for i:=1 upto max_inf_num: info[i]:=":"; endfor - f_beginchar:=inf_num:=cntM:=0; + f_ext:=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= @@ -151,9 +149,10 @@ def endfont= 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 - for i=0 upto cntM: + for i=1 upto cntM: addto currentpicture also mol_stru[i] shifted posM[0][i]; mol_stru[i]:=nullpicture; endfor + if f_ext=1: addto currentpicture also mol_stru[0]; mol_stru[0]:=nullpicture; fi endchar; clearit; endgroup; @@ -180,9 +179,9 @@ def set_def_MC= def { == (_push,1) enddef; def } == (_pop,1) enddef; def {{ == (_push,0) enddef; def }} == (_pop,0) enddef; def | == {,} enddef; def || == (_stack_reset,0) enddef; - def /secondary n == (_postA,n) enddef; def //secondary n == (_postB,n) enddef; - def */secondary n == (_postC,n) enddef; def /*secondary n == (_postD,n) enddef; - def **secondary n == (_postE,n) enddef; def */*secondary n == (_postF,n) enddef; + def /secondary n == (_postA,n) enddef; def //secondary n == (_postB,n) enddef; + def */secondary n == (_postC,n) enddef; def /*secondary n == (_postD,n) enddef; + def */*secondary n == (_postE,n) enddef; def **secondary n == (_postF,n) enddef; enddef; %================================================================================================= vardef '(text s)= ''(incr def_num)(s); def_num enddef; @@ -274,7 +273,7 @@ vardef @@(text t)(expr s)= for list==t:: if s==N:: PA(_N,list) elseif s==O:: PA(_O,list) elseif s==S:: PA(_S,list) else:: PA(_set_adr,list) PA(_chg_atom,s) fi endfor - elseif s==NH:: for list==t:: if numeric list:: PAs((_N,list),~~no,'`_size_a,(_H,list)) + elseif s==NH:: for list==t:: if numeric list:: PAs((_N,list),~~nl,'`_size_a,(_H,list)) elseif pair list:: PAs(list) fi endfor elseif s==SOO:: for list==t:: PAs((_S,list),(_set_adr,list), ^^35,~~dm,(_set_psA,O),^^-35,~~dm,(_set_psA,O)) endfor @@ -287,7 +286,8 @@ vardef @@(text t)(expr s)= if numeric list:: if nE==_postA:: elseif nE==_postB:: PAs(~~dm) elseif nE==_postC:: PAs(~~wf) elseif nE==_postD:: PAs(~~zf) - elseif nE==_postE:: PAs(~~nl) elseif nE==_postF:: PAs(~~no) fi + elseif nE==_postE:: PAs(~~nl) elseif nE==_postF:: PAs(~~0) + fi PA(_set_adr,list) PA(_set_psA,nF) elseif pair list:: PAs(list) fi endfor @@ -302,8 +302,9 @@ def EXT(text s)= begingroup 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; + 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; f_ext:=1; endgroup; enddef; %-------------------------------------------------------------------------------------------------- @@ -319,10 +320,10 @@ def MCf(text s)= MCd(1,1)(.5,.5)(s) enddef; % MC fill draw %------------------------------------------------------------------------------------------------- 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,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 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,xpos,ypos, + str_len,max_x,max_y,par_s,par_e,score_u,hat,f_char,ps_adr,ps_com,op_com,op_par,op_cnt,crR, + colorA,colorB; %----------------------------------------------------------------------------------------------- save PA,PAs,PP,PG; def PA(expr a,b)= comD[def_int][incr nA]:=a; parD[def_int][nA]:=b; enddef; @@ -386,11 +387,16 @@ enddef; %------------------------------------------------------------------------------------------------- def ps_put(expr n,p)= ps_adr[incr cntP]:=n; ps_com[cntP]:=p; op_cnt[cntP]:=0; - if lineT<>0: PP(_tmp_line,lineT) fi if rotT<>0: PP(_rot_ang,rotT) fi - if lenT<>crR: PP(_chg_len,lenT) fi if envT<>hz: PP(_chg_env,envT) fi - if lineT=nl: PP(_tmp_len,0) elseif lineT=no: PP(_adj_ang,0) fi PP(_mk_bond,0) - if f_lineT=0: lineT:=si; fi if f_lenT=0: lenT:=crR; fi - if f_rotT=0: rotT:=0; fi if f_envT=0: envT:=hz; fi + if lineT<>0: PP(_tmp_line,lineT) fi + if rotT<>0: PP(_rot_ang,rotT) fi + if lenT<>crR: PP(_chg_len,lenT) fi + if envT<>hz: PP(_chg_env,envT) fi + if lineT=nl: PP(_chg_len,_size_a) PP(_adj_ang,0) fi + if lineT<>0: PP(_mk_bond,0) fi + if f_lineT=0: lineT:=si; fi + if f_lenT=0: lenT:=crR; fi + if f_rotT=0: rotT:=0; fi + if f_envT=0: envT:=hz; fi enddef; %------------------------------------------------------------------------------------------------- def ps_get(expr n)= @@ -472,14 +478,16 @@ def proc_bond_atom(expr n)= elseif par=0: temp_len:=bondL; fi elseif com=_pop: if par=1: adrA:=stkA[decr adrS]; adrB:=stkB[adrS]; bondL:=stkL[adrS]; elseif par=0: bondL:=temp_len; fi - elseif com=_mk_bond: if (par=0)and(rotT<>0): rotT:=0; fi add_atom; - elseif com=_set_adr: adrT:=par; - elseif com=_set_atom: strAT:=par; - elseif com=_set_psA: ps_put(getA(adrT),par); - elseif (com>=_postA)and(com<=_postF): - if com=_postA: elseif com=_postB: lineT:=dm; elseif com=_postC: lineT:=wf; - elseif com=_postD: lineT:=zf; elseif com=_postE: lineT:=nl; - elseif com=_postF: lineT:=no; lenT:=_size_a; fi ps_put(cntA+1,par); + elseif com=_mk_bond: if (par=0)and(rotT<>0): rotT:=0; fi add_atom; + elseif com=_set_adr: adrT:=par; + elseif com=_set_atom: strAT:=par; + elseif com=_set_psA: ps_put(getA(adrT),par); + elseif com=_postA: ps_put(cntA+1,par); + elseif com=_postB: lineT:=dm; ps_put(cntA+1,par); + elseif com=_postC: lineT:=wf; ps_put(cntA+1,par); + elseif com=_postD: lineT:=zf; ps_put(cntA+1,par); + elseif com=_postE: lineT:=nl; ps_put(cntA+1,par); + elseif com=_postF: lineT:=0; ps_put(cntA+1,par); elseif com=_jp_bond: tempB:=getB(par); sB[cntB+1]:=sB[tempB]; f_bra:=1; elseif com=0or_jp_atom: termA; sB[cntB+1]:=getA(par); f_bra:=1; elseif com=_jp_atom_abs: sB[cntB+1]:=par; f_bra:=1; temp_cntB:=cntB; @@ -525,28 +533,28 @@ enddef; def proc_skeleton= adrA:=adrB:=cntA:=cntB:=angT:=adrS:=f_end:=f_bra:=rotT:=f_term:=0; envT:=envB:=f_lineT:=f_rotT:=f_lenT:=f_envT:=stkM[0]:=0; lineT:=si; - angA[0]:=angB[0]:=ang_br[0]:=0; posA[0]:=posB[0]:=posB[1]:=(0,0); + angA[0]:=angB[0]:=ang_br[0]:=0; posA[0]:=posBs:=posBe:=(0,0); for i=0 upto 5: stkA[i]:=stkB[i]:=0; endfor %---------------------------------------------------------------------------------------------- for i=1 upto cntD[0]: com:=comD[0][i]; par:=parD[0][i]; - if com=_push: if par=1: stkM[adrS]:=envB; adrS:=adrS+1; stkA[adrS]:=adrA:=cntA; + if com=_push: if par=1: stkM[adrS]:=envB; adrS:=adrS+1; stkA[adrS]:=adrA:=cntA; stkB[adrS]:=adrB:=cntB; elseif par=0: temp_len:=bondL; fi elseif com=_pop: if par=1: adrA:=stkA[decr adrS]; adrB:=stkB[adrS]; envB:=stkM[adrS]; elseif par=0: temp_len:=bondL; fi - elseif com=_jp_bond: tempB:=getB(par); posB[cntB+1]:=posA[sB[tempB]]; - angT:=angB[tempB]-180; f_bra:=1; rotT:=0; - elseif com=0or_jp_atom: termB; adrT:=getA(par); posB[cntB+1]:=posA[adrT]; + elseif com=_jp_bond: tempB:=getB(par); posBs:=posA[sB[tempB]]; + angT:=angB[tempB]-180; f_bra:=1; rotT:=0; + elseif com=0or_jp_atom: termB; adrT:=getA(par); posBs:=posA[adrT]; angT:=ang_br[adrT]; f_bra:=1; rotT:=0; - elseif com=_jp_atom_abs: adrT:=par; posB[cntB+1]:=posA[adrT]; + elseif com=_jp_atom_abs: adrT:=par; posBs:=posA[adrT]; angT:=ang_br[adrT]; f_bra:=1; rotT:=0; temp_cntB:=cntB; - elseif com=_adj_ang: if (angT<40)or(angT>320): angT:=0; elseif angT<140: angT:=90; - elseif angT<220: angT:=180; else: angT:=270; fi - elseif com=_mk_bond: if (par=0)and(rotT<>0):par:=rotT; rotT:=0; fi add_bond(par); - elseif com=_rot_ang: angT:=(angT+par) mod 360; - elseif com=_tmp_rot: rotT:=par; - elseif (com>=_postA)and(com<=_postF): rotT:=0; + elseif com=_adj_ang: if (angT<40)or(angT>320): angT:=0; elseif angT<140: angT:=90; + elseif angT<220: angT:=180; else: angT:=270; fi + elseif com=_mk_bond: if (par=0)and(rotT<>0):par:=rotT; rotT:=0; fi add_bond(par); + elseif com=_rot_ang: angT:=(angT+par) mod 360; + elseif com=_tmp_rot: rotT:=par; + elseif (com>=_postA)and(com<=_postE): rotT:=0; elseif com=_chg_env: envB:=par; elseif com=_tmp_env: envT:=par; elseif com=_set_clr: f_clr:=par; if par=0: lineT:=si; lenT:=crR; rotT:=envT:=0; fi @@ -560,16 +568,24 @@ def proc_skeleton= enddef; %------------------------------------------------------------------------------------------------- def add_bond(expr m)= - cntB:=cntB+1; if m=_arg_ang: nA:=proc_env(angT,envB,60,-60); else: nA:=m; fi - if f_bra=0: adrT:=cntA:=cntA+1; posA[cntA]:=posB[cntB]; angA[cntA]:=angT; - if nA>=0: ang_br[cntA]:=angT+nA/2-90; else: ang_br[cntA]:=angT+nA/2+90; fi - else: f_bra:=0; fi - angB[cntB]:=angT:=(angT+nA) mod 360; - if f_end=0: if lenB[cntB]=_size_a: posB[cntB+1]:=sfB(posB[cntB],atom_wd,angT); - else: nA:=lenB[cntB];glu:=0; if nA<0: nA:=-nA; glu_c(adrT);glu_c(cntA+1); fi - posB[cntB+1]:=sfB(posB[cntB],nA*bond_len+glu,angT); fi - posA[cntA+1]:=posB[cntB+1]; f_term:=0; - else: f_end:=0; f_term:=1; fi + if m=_arg_ang: nA:=proc_env(angT,envB,60,-60); else: nA:=m; fi + if f_bra=0: + adrT:=cntA:=cntA+1; posA[cntA]:=posBs; angA[cntA]:=angT; + if nA>=0: ang_br[cntA]:=angT+nA/2-90; else: ang_br[cntA]:=angT+nA/2+90; fi + else: f_bra:=0; + fi + angB[cntB+1]:=angT:=(angT+nA) mod 360; + if f_end=0: + if lenB[cntB+1]=_size_a: posBe:=sfB(posBs,atom_wd,angT); + else: + nA:=lenB[cntB+1];glu:=0; if nA<0: nA:=-nA; glu_c(adrT); glu_c(cntA+1); fi + posBe:=sfB(posBs,nA*bond_len+glu,angT); + fi + posA[cntA+1]:=posBe; f_term:=0; + else: + f_end:=0; f_term:=1; + fi + cntB:=cntB+1; posBs:=posBe; enddef; %================================================================================================== vardef getA(expr n)= @@ -581,41 +597,41 @@ def termA= if f_term=0: if f_bra=0: numS[incr cntA]:=strAT; strAT:=0; if f_MP=1: colorA[cntA]:=0; fi else: f_bra:=0; fi f_term:=1; fi enddef; def termB= if f_term=0: if f_bra=0: ang_br[incr cntA]:=angT; else: f_bra:=0; fi f_term:=1; fi enddef; -def proc_cyc(expr n)= add_bond(angle(posA[n]-posB[cntB+1])-angT); enddef; +def proc_cyc(expr n)= add_bond(angle(posA[n]-posBs)-angT); enddef; def glu_c(expr n)= if numS[n]<>0: nB:=angT mod 180; nC:=.5tbl_str_wd[numS[n]]*atom_wd; if (nB<45)or(nB>135):glu:=glu+((sind(nB)*nC)++nC); else :glu:=glu+((cosd(nB)*.5atom_wd)++.5atom_wd) fi fi enddef; vardef proc_env(expr n,m,a,b)= r:=(n mod 360); - if m>=def_emb_start: parD[m][cntB-temp_cntB-1] else: + if m>=def_emb_start: parD[m][cntB-temp_cntB] else: if m=hz:if r=0:a elseif r<=90:b elseif r<=180:a elseif r<270:b else:a fi elseif m=vt:if r=0:b elseif r<90:a elseif r<=180:b elseif r<=271:a else:b fi elseif (m>=-180)and(m<=180): m fi fi enddef; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -def draw_atom(expr n,p,r,s,WD)= +def draw_atom(expr NUM,POS,ANG,STR,WD)= begingroup save pA,pT,dx; pair pA,pT; %---------------------------------------------------------------------------------------------- - if ((r mod 360)<=90+1)or((r mod 360)>=270-1): dx:=1; else: dx:=-1; fi - pT:=p-(.5atom_wd*dx*WD,.5atom_wd); + 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); nE:=nC:=0; - for i=0 upto length(s)-1: - nB:=ASCII(pic_c(i,s)); - if dx<0: if nB=par_s:k:=i+1; nC:=1; forever:exitif pic_c(i+(incr nC),s)="}";endfor fi - if nC>0: nB:=ASCII(pic_c(k+(decr nC),s)); fi + for i=0 upto length(STR)-1: + nB:=ASCII(pic_c(i,STR)); + if dx<0: if nB=par_s:k:=i+1; nC:=1; forever:exitif pic_c(i+(incr nC),STR)="}";endfor fi + if nC>0: nB:=ASCII(pic_c(k+(decr nC),STR)); fi fi if nB=score_u: if nE=0: nE:=-.5; else: nE:=0; fi; 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+(.5*((dx-1)*nA),nE*atom_wd); + 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 addto currentpicture also atom_font[nB] - shifted (pA-(0,atom_wd*tbl_char_dp[nB])) Cp(colorA[n]); + shifted (pA-(0,atom_wd*tbl_char_dp[nB])) Cp(colorA[NUM]); pT:=pT+(nA*dx,0); fi endfor @@ -874,10 +890,13 @@ def blank_str:= " " enddef; vardef fixed_r(expr n)(expr s)= (substring(0,n-length(s)) of blank_str)&s enddef; vardef fixed_l(expr n)(expr s)= s&(substring(0,n-length(s)) of blank_str) enddef; vardef fdr(expr n)(expr s)=fixed_r(n)(decimal(s)) enddef; -def warning(expr s)= message "% "&decimal(char_num)&fdr(3)(incr warning_cnt)&")"&s&" !!!"; enddef; -def B_check(expr s)(expr t)(expr n)= - if strD[numS[s]]=t: if bond_cnt>n: - warning(fdr(4)(s)&" ["&strD[numS[s]]&"] has "&fdr(3)(bond_cnt)&" bonds"); fi fi +vardef fdl(expr n)(expr s)=fixed_l(n)(decimal(s)) enddef; +def warning(expr s)= message "% "&decimal(char_num)&fdr(3)(incr warning_cnt)&")"&s; enddef; +def bond_check(expr a)(text s)= + nF:=0; for list=s: if list=bond_cnt: nF:=1; fi endfor + if nF=0: + warning("A"&decimal(a)&" ( "&fixed_l(8)(strD[numS[a]])&") has"&fdr(2)(bond_cnt)&" bonds"); + fi enddef; vardef stripP(expr a)=if length(a)=4: substring (1,3) of a else: a fi enddef; %================================================================================================== @@ -895,12 +914,13 @@ def STb(expr a)(text s)= enddef; %================================================================================================== tbl_cnt:=0; -STa("C",12.0107); STa("H",1.00794); STa("{Al}",26.9815); STa("{As}",74.9236); STa("B",10.811); -STa("{Br}",79.904); STa("{Ca}",40.078); STa("{Cl}",35.453); STa("{Cu}",63.546); STa("D",2.012); -STa("F",18.9984); STa("{Fe}",55.845); STa("{Hg}",200.59); STa("I",126.90447); STa("K",39.0983); -STa("{Li}",6.941); STa("{Mg}",24.305); STa("N",14.0067); STa("{Na}",22.98977); STa("{Ni}",58.693); -STa("O",15.9994); STa("P",30.973761); STa("S",32.065); STa("{Si}",28.0855); STa("{Sn}",118.71); -STa("{Ti}",47.867); STa("{Zn}",65.409); +STa("C" ,12.0107); STa("H" ,1.00794); STa("{Al}",26.9815); STa("{As}",74.9236); +STa("B" ,10.811); STa("{Br}",79.904); STa("{Ca}",40.078); STa("{Cl}",35.453); +STa("{Cu}",63.546); STa("D" ,2.012); STa("F" ,18.9984); STa("{Fe}",55.845); +STa("{Hg}",200.59); STa("I" ,126.90447); STa("K" ,39.0983); STa("{Li}",6.941); +STa("{Mg}",24.305); STa("N" ,14.0067); STa("{Na}",22.98977); STa("{Ni}",58.693); +STa("O" ,15.9994); STa("P" ,30.973761); STa("S" ,32.065); STa("{Si}",28.0855); +STa("{Sn}",118.71); STa("{Ti}",47.867); STa("{Zn}",65.409); %-------------------------------------------------------------------------------------------------- STb("{H_2_}")("H","H"); STb("OH")("O","H"); STb("O{Na}")("O","{Na}"); STb("CN")("C","N"); STb("SH")("S","H"); STb("CHO")("C","H","O"); STb("N{O_2_}")("N","O","O"); @@ -921,26 +941,45 @@ enddef; %================================================================================================== def proc_calc_out= begingroup - save warning_cnt,cal_MW,cal_MWp,knownA,cal_FM,bondC,tmp_wtp,bond_cnt,hide_H, + save warning_cnt,cal_MW,cal_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; - numeric sumA[],bondC[]; + numeric sumA[],bondC[],hideH[]; string cal_FM,cal_MW_str,sumA,s_tag,s_var, inf_NO,inf_EN,inf_JN,inf_FM,inf_CAS,inf_USE,inf_EXA,inf_EXB,inf_MW; inf_NO:=inf_EN:=inf_JN:=inf_FM:=inf_CAS:=inf_USE:=inf_EXA:=inf_EXB:=inf_MW:=""; - cal_MW_str:=cal_FM:=""; hide_H:=warning_cnt:=cal_MW:=cal_MWp:=0; + cal_MW_str:=cal_FM:=""; cnt_hide_H:=warning_cnt:=cal_MW:=cal_MWp:=0; %------------------------------------------------------------------------------------------ proc_get_info; for i=1 upto tbl_cnt: sumA[i]:=0; endfor - for i=1 upto cntA: knownA:=bond_cnt:=0; - for j=1 upto cntB: if (lineB[j]=dl)or(lineB[j]=dr)or(lineB[j]=dm): bondC[j]:=2; - elseif (lineB[j]=tm): bondC[j]:=3; elseif lineB[j]=nl: bondC[j]:=0; - elseif lineB[j]=0: bondC[j]:=0; else: bondC[j]:=1; fi - if (sB[j]=i)or(eB[j]=i): bond_cnt:=bond_cnt+bondC[j]; fi endfor + for i=1 upto cntA: + knownA:=bond_cnt:=0; + for j=1 upto cntB: + if (lineB[j]=dl)or(lineB[j]=dr)or(lineB[j]=dm): bondC[j]:=2; + elseif lineB[j]=tm: bondC[j]:=3; + elseif (lineB[j]=vf)or(lineB[j]=vb): bondC[j]:=0; + else: bondC[j]:=1; + fi + if (sB[j]=i)or(eB[j]=i): bond_cnt:=bond_cnt+bondC[j]; fi + endfor Bcnt[i]:=bond_cnt; if strD[numS[i]]="": strD[numS[i]]:="C"; fi - if strD[numS[i]]="C": if bond_cnt<4: hide_H:=hide_H+(4-bond_cnt); fi fi - B_check(i)("C")(4); B_check(i)("H")(1); B_check(i)("O")(2); - B_check(i)("F")(1); B_check(i)("{Cl}")(1); B_check(i)("Br}")(1); + if (strD[numS[i]]="C")and(bond_cnt<4): + hideH[i]:=4-bond_cnt; cnt_hide_H:=cnt_hide_H+hideH[i]; else: hideH[i]:=0; + fi + if strD[numS[i]]="C": bond_check(i)(1,2,3,4); + elseif strD[numS[i]]="N": bond_check(i)(3,5); + elseif strD[numS[i]]="H": bond_check(i)(1); + elseif strD[numS[i]]="O": bond_check(i)(2); + elseif strD[numS[i]]="S": bond_check(i)(2,4,6); + elseif strD[numS[i]]="P": bond_check(i)(5); + elseif strD[numS[i]]="OH": bond_check(i)(1); + elseif strD[numS[i]]="COOH": bond_check(i)(1); + elseif strD[numS[i]]="CN": bond_check(i)(1); + elseif strD[numS[i]]="N{H_2_}": bond_check(i)(1); + elseif strD[numS[i]]="F": bond_check(i)(1); + elseif strD[numS[i]]="{Cl}": bond_check(i)(1); + elseif strD[numS[i]]="{Br}": bond_check(i)(1); + fi for j=1 upto tbl_cnt: if strD[numS[i]]=tbl_atom_str[j]: if tbl_atom[j]=0: sumA[j]:=sumA[j]+1; @@ -948,12 +987,11 @@ def proc_calc_out= knownA:=1; fi endfor if knownA=0: warning(" Unknown Str("&strD[numS[i]]&") is used "&decimal(i)); fi endfor - sumA[2]:=sumA[2]+hide_H; + sumA[2]:=sumA[2]+cnt_hide_H; for i=1 upto tbl_cnt: if sumA[i]>=1: - tmp_wtp:=(tbl_atom_wt[i]/100)*sumA[i]; - if (tmp_wtp<=40)and(cal_MWp<=40): cal_MW:=cal_MW+(tbl_atom_wt[i]*sumA[i]); - else: cal_MWp:=cal_MWp+tmp_wtp; fi + nA:=tbl_atom_wt[i]/100*sumA[i]; cal_MWp:=cal_MWp+nA; + if (cal_MWp<40)and(nA<40): cal_MW:= cal_MW +tbl_atom_wt[i]*sumA[i]; fi cal_FM:=cal_FM&stripP(tbl_atom_str[i]) if sumA[i]>=2: &decimal(sumA[i]) fi; fi endfor @@ -969,6 +1007,7 @@ def auxtag_out= enddef; %================================================================================================== def proc_auxfile_out= + message "%["&decimal(char_num)&"]:"&inf_EN; for i=1 upto aux_max: exitif tag[i]=""; if i=1: printf "" else: &aux_delimiter fi if sw_auxfix=0: &tag[i]&":" fi & if string scantokens(var[i]): scantokens(var[i]) @@ -977,35 +1016,53 @@ def proc_auxfile_out= if sw_auxfix=0: for i=1 upto inf_num: &aux_delimiter&info[i] endfor; fi enddef; %================================================================================================== -def proc_checklist_out= nA:=0; - message "% Molecular name = "& inf_EN; - message "% warnings = "&fdr(3)(warning_cnt)&" / Expanded command = "&decimal(cntD[0]); - message "% width * height = " & fdr(8)(mol_wd)&" * "&fdr(8)(mol_ht); +vardef round_auto(expr n)= + if (n<4) and(n>-4): round(n*1000)/1000 elseif (n<40) and(n>-40): round(n*100)/100 + elseif (n<400)and(n>-400): round(n*10)/10 else: round(n) fi +enddef; +%-------------------------------------------------------------------------------------------------- +def proc_checklist_out= + message "%------------------------------------------------------------------"; + message "% Molecular name = "& inf_EN; + message "% Warnings = "&fdr(3)(warning_cnt)&" / Expanded command = "&decimal(cntD[0]); + message "% Width * Height = " & fdr(8)(mol_wd)&" * "&fdr(8)(mol_ht); message "% Shift width * height = "& fdr(8)(minX)&" * "&fdr(8)(minY); message "% Bond length = "&fdr(3)(bond_len)&" Atom size = "&fdr(3)(atom_wd); message "% Atom count="&fdr(3)(cntA)&" Bond count="&fdr(3)(cntB)& - " Ring count="&fdr(3)(cntB-cntA+1)&" Hide H ="&fdr(3)(hide_H); - message "%-----------------------------------< atom >< bond >-------"; - for i=1 upto cntA: message "% "&fdr(3)(i)&" ("&fdr(10)(xpart(posA[i])/bond_len)&" ) ("& - fdr(10)(ypart(posA[i])/bond_len)&" ) "&fixed_l(8)(strD[numS[i]])&" "&fdr(3)(Bcnt[i]); + " Ring count="&fdr(3)(cntB-cntA+1)&" Hide H count="&fdr(3)(cnt_hide_H); + message "%------------------------------------------------------------------"; + message "%< NO. >< x axis , y axis >< atom >< bond >< hide_H >"; + for i=1 upto cntA: + message "% A"&fdl(4)(i)&" ("&fdr(7)(round_auto(xpart(posA[i])/bond_len))&" , "& + fdr(7)(round_auto(ypart(posA[i])/bond_len))&" ) "&fixed_l(8)(strD[numS[i]])& + " "&fdr(3)(Bcnt[i]) if hideH[i]>0: &fdr(8)(hideH[i]) fi; endfor - message "%Bond list---------------------------------------------------------"; - for i=1 upto cntB: if lineB[i]<>0: message "% "&fdr(3)(incr nA)&" "&fdr(3)(sB[i])& - " -> "&fdr(3)(eB[i])&" ("&fdr(3)(bondC[i]-si+1)&")"; fi + message "%------------------------------------------------------------------"; + message "%< NO. >< bond (sdt)><angle + ( +- )><length ( pt )>"; + for i=1 upto cntB: + nC:=lenB[i]; if nC=_size_a: nC:=ratio_atom_bond; elseif nC<0: nC:=-nC; fi + if lineB[i]<>0: + nB:=angB[i]; if nB>180: nB:=nB-360; fi + message "% B"&fdl(4)(i)&fdr(3)(sB[i])&" -> "&fdr(3)(eB[i])& + " ("&fdr(3)(bondC[i]-si+1)&")"&fdr(9)(round_auto(angB[i]))& + " ("&fdr(6)(round_auto(nB))&")"&fdr(8)(nC)&" ("&fdr(8)(round_auto(nC*bond_len))&")"; + fi endfor - message "%Fomula / Molecular weight ---------------------------------------"; + message "%------------------------------------------------------------------"; if cal_MWp<=40: cal_MW_str:=fdr(10)(cal_MW); else: cal_MW_str:=fdr(10)(cal_MWp)&" * 100"; fi for i=1 upto tbl_cnt: if sumA[i]>=1: + nA:=tbl_atom_wt[i]/100*sumA[i]; message "% "&fixed_l(4)(stripP(tbl_atom_str[i]))&"("&fdr(9)(tbl_atom_wt[i])& ") * "&fdr(6)(sumA[i])&" = " - if tmp_wtp<=40: &fdr(12)(tbl_atom_wt[i]*sumA[i]); else: &fdr(12)(tmp_wtp)&" * 100"; fi fi + if nA<40: &fdr(12)(tbl_atom_wt[i]*sumA[i]); else: &fdr(12)(nA)&" * 100"; fi + fi endfor message "% Weight Calc: " &cal_MW_str &" / Input: " if inf_MW<>"": &inf_MW &" / weight gap= " &decimal(cal_MW-scantokens(inf_MW)) fi; message "% Fomula Calc: "&cal_FM&" / Input: " if inf_FM<>"": &inf_FM&" / "& if inf_FM=cal_FM: "MACTCH" else: "NOT MACTCH" fi fi; - message "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"; + message "%=================================================================="; enddef; %================================================================================================== def proc_MOLfile_out= |