summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost/mcf2graph
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-11-03 21:17:00 +0000
committerKarl Berry <karl@freefriends.org>2016-11-03 21:17:00 +0000
commitb60ca9e4d571bb8eaf715f6c8e21a0053d59e1a7 (patch)
tree5e661575f5e6bb09aedac88d5decb7dd46e39e37 /Master/texmf-dist/metapost/mcf2graph
parent7115c2809a8f244352ff9f750f30fb0d8335eabb (diff)
mcf2graph (3nov16)
git-svn-id: svn://tug.org/texlive/trunk@42429 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost/mcf2graph')
-rw-r--r--Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf162
1 files changed, 93 insertions, 69 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
index 60b82397391..668964031b3 100644
--- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
+++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
@@ -1,5 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% mcf2graph ver 4.02 Copyright (c) 2013-2016 Akira Yamaji
+% mcf2graph ver 4.03 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,
@@ -30,20 +30,18 @@
% Set output checklist : mpost -s ahlength=2 FILENAME
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tracingstats:=1;
-message " This is mcf2graph ver 4.0 2016.10";
+message " This is mcf2graph ver 4.0 2016.11";
%-------------------------------------------------------------------------------------------------
-newinternal nA,nB,nC,nD,nE,nF,cntA,cntB,cntM,minX,minY,def_num,def_int,tbl_cnt;
-pair posB[],posA[],posM[];
-numeric lineB[],sB[],eB[],angB[],angA[],strA[],str_wd[],lenB[],ang_br[],save_para[],
- tbl_char_wd[],tbl_char_ht[],tbl_char_dp[],tbl_atom[],tbl_subst[][],tbl_atom_wt[],
- comD[][],parD[][],cntD[];
-string info[],tbl_atom_str[],strD[],var[],tag[],mp_log_name,aux_delimiter;
+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;
%-------------------------------------------------------------------------------------------------
-char_num:=str_cnt:=proc_end:=sw_numberA:=sw_numberB:=sw_mol_frame:=sw_auxout:=sw_solid:=0;
-sw_expand:=sw_font_frame:=sw_atom_frame:=sw_checklist:=sw_MOLout:=sw_subst_off:=sw_bond_single:=0;
-sw_auxfix:=sw_clip:=0;
-numberA_start:=numberB_start:=1; numberA_end:=numberB_end:=4095; aux_max:=20;
+char_num:=str_cnt:=proc_end:=0;
+sw_numberA:=sw_numberB:=sw_mol_frame:=sw_auxout:=sw_solid:=sw_expand:=sw_font_frame:=0;
+sw_atom_frame:=sw_checklist:=sw_MOLout:=sw_subst_off:=sw_bond_single:=sw_auxfix:=sw_clip:=0;
+numberA_start:=numberB_start:=1; numberA_end:=numberB_end:=4095; aux_max:=max_inf_num:=20;
aux_delimiter:=";"; var1:="jobname"; tag1:="F"; var2:="char_num"; tag2:="C";
for i=3 upto aux_max: var[i]:=tag[i]:=""; endfor
%=================================================================================================
@@ -81,8 +79,7 @@ ratio_char_bond:=1.5; ratio_bondgap_bond:=0.15; ratio_zebragap_bond:=0.
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#;
-max_inf_num:=12; for i:=1 upto max_inf_num: info[i]:=":"; endfor
+max_bond_length#:=10mm; bond_len#:=8mm#; font_wd#:=30mm#; font_ht#:=20mm#;
%--------------------------------------------------------------------------------------------------
def_emb_start:=500; % 500 => 2499 for embedded definition (max 2000)
def_usr_start:=2500; % 2500 => 2999 for user definition (max 500)
@@ -90,9 +87,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);
+ _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_);
%--------------------------------------------------------------------------------------------------
def parameter_list=
@@ -100,7 +98,7 @@ def parameter_list=
sw_atom_frame,sw_font_frame,sw_subst_off,sw_bond_single,sw_clip,
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,
+ ratio_wedge_bond,ratio_atomgap_atom,ratio_bond_width,font_wd#,font_ht#,
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;
@@ -114,19 +112,31 @@ def restore_par(text t)= nA:=0;
forsuffixes list=t: if list<>save_para[incr nA]: list:=save_para[nA]; fi endfor enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def beginfont(text s)=
- store_par(parameter_list); save_wd#:=font_wd#; save_ht#:=font_ht#;
+ 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;
+ numeric lineB[],sB[],eB[],angB[],angA[],lenB[],ang_br[],numS[];
+ pair posB[],posA[],posM[];
+ 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;
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_auxout=1)or(sw_checklist=1)or(sw_MOLout=1): proc_calc_out; fi
- char_num:=char_num+1; currentpicture:=chem_structure; chem_structure:=nullpicture; endchar;
+ currentpicture:=chem_structure;
+ chem_structure:=nullpicture;
+ endchar;
clearit;
- restore_par(parameter_list); font_wd#:=save_wd#; font_ht#:=save_ht#;
+ endgroup;
+ restore_par(parameter_list);
if proc_end=1: scantokens("bye"); fi
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -171,7 +181,7 @@ def ''(expr k)(text s)=
else:: comD[k][incr cntD[k]]:=_mk_bond; parD[k][cntD[k]]:=list; fi
elseif string list:: strD[incr str_cnt]:=list;
comD[k][incr cntD[k]]:=_set_atom; parD[k][cntD[k]]:=str_cnt;
- if pic_c(0,list)=="{":: str_wd[str_cnt]:=1.6; else:: str_wd[str_cnt]:=1; fi
+ if pic_c(0,list)=="{":: tbl_str_wd[str_cnt]:=1.6; else:: tbl_str_wd[str_cnt]:=1; fi
fi
fi
endfor
@@ -277,7 +287,7 @@ enddef;
%--------------------------------------------------------------------------------------------------
def ext(text s)=
begingroup
- save wd,ht,n,a,p; numeric a[]; pair p[]; wd:=mol_wd; ht:=mol_ht;
+ 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;
endgroup;
@@ -292,19 +302,15 @@ def MCd(expr RW,RH)(expr FW,FH)(text TX)=
glu,sftX,sftY,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;
%-----------------------------------------------------------------------------------------------
- numeric stkB[],stkA[],stkL[],stkM[],f_char[],ps_adr[],ps_com[],colorA[],colorB[],
- op_com[][],op_par[][],op_cnt[];
- %-----------------------------------------------------------------------------------------------
- save ww,ap,am,hpt,pA,pB,pC,pT,Ls,Le,dx,j,u,pairA,pairT;
- pair Ls,Le,pairA,pairT;
- path pA,pB,pC,pT;
- %-----------------------------------------------------------------------------------------------
save PA,PAs,PP,PG;
def PA(expr a,b)= comD[def_int][incr nA]:=a; parD[def_int][nA]:=b; enddef;
def PAs(text t)= for list==t:: PA(xpart(list),ypart(list)) endfor enddef;
def PP(expr a,b)= op_com[cntP][incr op_cnt[cntP]]:=a; op_par[cntP][op_cnt[cntP]]:=b; enddef;
def PG(expr a,b)= comD[0][incr cntD[0]]:=a; parD[0][cntD[0]]:=b; enddef;
%-----------------------------------------------------------------------------------------------
+ numeric stkB[],stkA[],stkL[],stkM[],f_char[],ps_adr[],ps_com[],colorA[],colorB[],
+ op_com[][],op_par[][],op_cnt[];
+ %-----------------------------------------------------------------------------------------------
if (sw_numberA>=1)or(sw_numberB>=1): ratio_atom_bond:=0.25; fi
if (sw_expand=1)or(sw_MOLout=1): expand_set; fi
def_num:=def_usr_start;
@@ -336,8 +342,10 @@ def MCd(expr RW,RH)(expr FW,FH)(text TX)=
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
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 cntA:
if (sw_numberA>=1)and(i>=numberA_start)and(i<=numberA_end):
if sw_numberA=2: nA:=i-numberA_start+1;
@@ -346,15 +354,16 @@ def MCd(expr RW,RH)(expr FW,FH)(text TX)=
if i<10: draw_atom(i,posA[i],0,decimal(nA),1);
else: draw_atom(i,posA[i]+(-.2atom_wd,0),0,decimal(nA),1); fi
elseif sw_numberB>=1:
- else: draw_atom(i,posA[i],ang_br[i],strD[strA[i]],str_wd[strA[i]]); fi
+ 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);
clearit;
- endgroup; % <=added ";"
+ endgroup;
enddef;
%-------------------------------------------------------------------------------------------------
def ps_put(expr n,p)=
@@ -407,9 +416,9 @@ def proc_scaling=
minX:=minY:=4095.999; max_x:=max_y:=-4095.999;
for i=1 upto cntA:
xpos:=xpart(posA[i]); ypos:=ypart(posA[i]);
- if strA[i]<>0: str_len:=nC:=nD:=0;
- for j=0 upto length(strD[strA[i]])-1:
- nA:=ASCII(pic_c(j,strD[strA[i]]));
+ if numS[i]<>0: str_len:=nC:=nD:=0;
+ for j=0 upto length(strD[numS[i]])-1:
+ nA:=ASCII(pic_c(j,strD[numS[i]]));
if (nA=score_u)or(nA=hat)or(nA=par_s)or(nA=par_e):
if (nA=hat)and(nC<.5atom_wd): nC:=.5atom_wd; fi;
if (nA=score_u)and(nD<.5atom_wd): nD:=.5atom_wd; fi;
@@ -430,8 +439,8 @@ enddef;
def char_use_check=
for i=1 upto 128: f_char[i]:=0; endfor
if (sw_numberA>0)or(sw_numberB>0): for j=ASCII("0") upto ASCII("9"): f_char[j]:=1; endfor
- else: for i=1 upto cntA: if strA[i]<>0: for j=0 upto length(strD[strA[i]])-1:
- f_char[ASCII(pic_c(j,strD[strA[i]]))]:=1; endfor fi endfor fi
+ else: for i=1 upto cntA: if numS[i]<>0: for j=0 upto length(strD[numS[i]])-1:
+ f_char[ASCII(pic_c(j,strD[numS[i]]))]:=1; endfor fi endfor fi
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def proc_bond_atom(expr n)=
@@ -457,10 +466,10 @@ def proc_bond_atom(expr n)=
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;
- elseif com=_chg_atom: strA[getA(adrT)]:=parD[par][1];
- elseif com=_N: strA[getA(par)]:=parD[N][1];
- elseif com=_O: strA[getA(par)]:=parD[O][1];
- elseif com=_S: strA[getA(par)]:=parD[S][1];
+ elseif com=_chg_atom: numS[getA(adrT)]:=parD[par][1];
+ elseif com=_N: numS[getA(par)]:=parD[N][1];
+ elseif com=_O: numS[getA(par)]:=parD[O][1];
+ elseif com=_S: numS[getA(par)]:=parD[S][1];
elseif com=_H: ps_put(getA(par),H);
elseif com=_chg_len: if par=_ring_len: bondL:=ringL;
elseif par=0: if lenT<>crR: bondL:=lenT; else: if bondL<0: bondL:=1; fi fi
@@ -491,7 +500,7 @@ enddef;
def add_atom=
lineB[incr cntB]:=lineT; lineT:=si;
if lenT=crR: lenB[cntB]:=bondL; else: lenB[cntB]:=lenT; lenT:=crR; fi
- if f_bra=0: cntA:=cntA+1; sB[cntB]:=cntA; strA[cntA]:=strAT; strAT:=0;
+ if f_bra=0: cntA:=cntA+1; sB[cntB]:=cntA; numS[cntA]:=strAT; strAT:=0;
if f_MP=1: colorA[cntA]:=colorB[cntA]:=0; fi else: f_bra:=0; fi
if f_end=0: eB[cntB]:=cntA+1; f_term:=0; else: eB[cntB]:=f_end; f_end:=0; f_term:=1; fi
enddef;
@@ -551,12 +560,12 @@ vardef getA(expr n)=
vardef getB(expr n)=
if n>=1: stkB[adrS+1]+n elseif n=0: tempB elseif n>=-999: cntB+n+1 else: stkB[adrS]+n+4095 fi
enddef;
-def termA= if f_term=0: if f_bra=0: strA[incr cntA]:=strAT; strAT:=0;
+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 glu_c(expr n)= if strA[n]<>0: nB:=angT mod 180; nC:=.5str_wd[strA[n]]*atom_wd;
+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;
@@ -568,32 +577,45 @@ vardef proc_env(expr n,m,a,b)= r:=(n mod 360);
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def draw_atom(expr n,p,r,s,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
- pairT:=p-(.5atom_wd*dx*WD,.5atom_wd); u:=j:=0;
+ pT:=p-(.5atom_wd*dx*WD,.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;j:=1;forever:exitif pic_c(i+(incr j),s)="}";endfor fi
- if j>0: nB:=ASCII(pic_c(k+(decr j),s)); fi fi
- if nB=score_u: if u=0: u:=-.5; else:u:=0; fi;
- elseif nB=hat: if u=0: u:= .5; else:u:=0; fi;
+ 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
+ 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]; pairA:=pairT+(.5*((dx-1)*nA),u*atom_wd);
- if sw_atom_frame=1: draw_frame(pairA,nA,atom_wd,0.1pt); fi
+ nA:=atom_wd*tbl_char_wd[nB];
+ pA:=pT+(.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 pairA wpcs 0.01pt; fi
+ erase fill unitsquare xscaled nA yscaled atom_wd shifted pA wpcs 0.01pt; fi
addto currentpicture also atom_font[nB]
- shifted (pairA-(0,atom_wd*tbl_char_dp[nB])) Cp(colorA[n]);
- pairT:=pairT+(nA*dx,0);
+ shifted (pA-(0,atom_wd*tbl_char_dp[nB])) Cp(colorA[n]);
+ pT:=pT+(nA*dx,0);
fi
endfor
+ endgroup
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def draw_bond(expr n,BP,EP,ANG,LN)=
+ begingroup
+ save ww,ap,am,hpt,Ls,Le,pA,pB,pC,pT;
+ pair Ls,Le;
+ path pA,pB,pC,pT;
+ %----------------------------------------------------------------------------------------------
nC:=length(posA[EP]-posA[BP]);
if (nC>0)and(LN<>0):
ww:=wedge_wd; hpt:=.5bond_pen_wd; ap:=ANG+90; am:=ANG-90;
if sw_numberB>=1: clipping(0,0,posA[BP],posA[EP],nC);
- else: clipping(strA[BP],strA[EP],posA[BP],posA[EP],nC); fi
+ else: clipping(numS[BP],numS[EP],posA[BP],posA[EP],nC); fi
pickup pencircle scaled bond_pen_wd;
if known colorB[n]: nB:=colorB[n]; fi
%---------------------------------------------------------------------------------------------
@@ -628,6 +650,7 @@ def draw_bond(expr n,BP,EP,ANG,LN)=
else: nB:=n; fi
draw_atom(n,.5[posA[BP],posA[EP]],0,decimal(nB),1); fi
fi
+ endgroup
enddef;
%-------------------------------------------------------------------------------------------------
def draw_wv= nB:=3bond_pen_wd; nA:=nB/length(Le-Ls);
@@ -653,12 +676,12 @@ def cut_off(expr p,w,h,s)=
def clipping(expr SA,SB,PA,PB,LEN)=
pT:=PA--PB; nA:=0.6atom_wd/LEN;
if (SA=0)and(SB=0): Ls:=PA; Le:=PB; pA:=pB:=pT; pC:=0.1[PA,PB]--0.1[PB,PA];
- elseif SA=0: Ls:=PA; Le:=cut_off(pT,atom_wd*str_wd[SB],atom_wd,PB);
+ elseif SA=0: Ls:=PA; Le:=cut_off(pT,atom_wd*tbl_str_wd[SB],atom_wd,PB);
pA:=Ls--Le; pB:=Ls--nA[PB,PA]; pC:=0.1[PA,PB]--Le;
- elseif SB=0: Ls:= cut_off(pT,atom_wd*str_wd[SA],atom_wd,PA); Le:=PB;
+ elseif SB=0: Ls:= cut_off(pT,atom_wd*tbl_str_wd[SA],atom_wd,PA); Le:=PB;
pA:=Ls--Le; pB:=nA[PA,PB]--Le; pC:=Ls--(0.1)[PB,PA];
- else: Ls:=cut_off(pT,atom_wd*str_wd[SA],atom_wd,PA);
- Le:=cut_off(pT,atom_wd*str_wd[SB],atom_wd,PB);
+ else: Ls:=cut_off(pT,atom_wd*tbl_str_wd[SA],atom_wd,PA);
+ Le:=cut_off(pT,atom_wd*tbl_str_wd[SB],atom_wd,PB);
pB:=nA[PA,PB]--nA[PB,PA]; pC:=pA:=Ls--Le; fi
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -695,7 +718,8 @@ CCl3:='(/Cl,/Cl^60,60,Cl);CBr3:='(/Br,/Br^60,60,Br);O_H:='(O,!,H);CO_H:='(//O,!,
CO_OH:='(//O,!,O,!,H); C_N:='(!~tm,N); N_HH:='(N,/H,60,H); N_OO:='(N,//O,60~dm,O);
S_H:='(S,!,H); N_H:='(N,/H); C_HHH:='(/H,/H^60,60,H);
%--------------------------------------------------------------------------------------------------
-def expand_set= save CH,NH,NO,OH,CHO,COOH,CN,SH;
+def expand_set=
+ save CH,NH,NO,OH,CHO,COOH,CN,SH;
CH3:=C_HHH; NH:=N_H; NH2:=N_HH; NO2:=N_OO; OH:=O_H; CHO:=CO_H; COOH:=CO_OH; CN:=C_N; SH:=S_H;
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -835,8 +859,8 @@ 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[strA[s]]=t: if bond_cnt>n:
- warning(fdr(4)(s)&" ["&strD[strA[s]]&"] has "&fdr(3)(bond_cnt)&" bonds"); fi fi
+ if strD[numS[s]]=t: if bond_cnt>n:
+ warning(fdr(4)(s)&" ["&strD[numS[s]]&"] has "&fdr(3)(bond_cnt)&" bonds"); fi fi
enddef;
vardef stripP(expr a)=if length(a)=4: substring (1,3) of a else: a fi enddef;
%==================================================================================================
@@ -896,16 +920,16 @@ def proc_calc_out=
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
Bcnt[i]:=bond_cnt;
- if strD[strA[i]]="": strD[strA[i]]:="C"; fi
- if strD[strA[i]]="C": if bond_cnt<4: hide_H:=hide_H+(4-bond_cnt); fi fi
+ 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);
for j=1 upto tbl_cnt:
- if strD[strA[i]]=tbl_atom_str[j]:
+ if strD[numS[i]]=tbl_atom_str[j]:
if tbl_atom[j]=0: sumA[j]:=sumA[j]+1;
else: for k=1 upto tbl_atom[j]: sumA[tbl_subst[j][k]]:=sumA[tbl_subst[j][k]]+1; endfor fi
knownA:=1; fi endfor
- if knownA=0: warning(" Unknown Str("&strD[strA[i]]&") is used "&decimal(i)); fi
+ if knownA=0: warning(" Unknown Str("&strD[numS[i]]&") is used "&decimal(i)); fi
endfor
sumA[2]:=sumA[2]+hide_H;
for i=1 upto tbl_cnt:
@@ -946,7 +970,7 @@ def proc_checklist_out= nA:=0;
" 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[strA[i]])&" "&fdr(3)(Bcnt[i]);
+ fdr(10)(ypart(posA[i])/bond_len)&" ) "&fixed_l(8)(strD[numS[i]])&" "&fdr(3)(Bcnt[i]);
endfor
message "%Bond list---------------------------------------------------------";
for i=1 upto cntB: if lineB[i]<>0: message "% "&fdr(3)(incr nA)&" "&fdr(3)(sB[i])&
@@ -972,7 +996,7 @@ def proc_MOLfile_out=
printf ""; printf " -MCFtoMOL- "&fixed_l(20)(info[1]); printf "";
printf fdr(3)(cntA)&fdr(3)(cntB)&" 0 0 0 0 0 0 0 0999 V2000";
for i=1 upto cntA: printf fdr(10)(xpart(posA[i])/bond_len)& fdr(10)(ypart(posA[i])/bond_len)&
- fdr(10)(0)&" "&fixed_l(2)(stripP(strD[strA[i]]))&" 0 0 0 0"; endfor
+ fdr(10)(0)&" "&fixed_l(2)(stripP(strD[numS[i]]))&" 0 0 0 0"; endfor
for i=1 upto cntB: if lineB[i]<>0:
if (lineB[i]=dl)or(lineB[i]=dr)or(lineB[i]=dm): nA:=2;
elseif lineB[i]=tm: nA:=3;