summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r--Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf215
1 files changed, 122 insertions, 93 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
index c7beb8ad15a..2bc472f6efd 100644
--- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
+++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
@@ -1,5 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% mcf2graph ver 3.61 Copyright (c) 2013-2015 Akira Yamaji
+% mcf2graph ver 3.63 Copyright (c) 2013-2015 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,
@@ -46,6 +46,7 @@ sw_numberA:=sw_numberB:=sw_mol_frame:=sw_logout:=sw_solid:=sw_expand:=sw_start_v
sw_font_frame:=sw_atom_frame:=sw_checklist:=sw_MOLfile:=0;
sw_info_file:=sw_info_char:=1; sw_info_lenx:=sw_info_leny:=sw_info_weight:=sw_info_formula:=0;
char_num:=str_cnt:=proc_end:=0;
+numberA_start:=1; numberA_end:=4095; numberB_start:=1; numberB_end:=4095;
if known green: f_MP:=1;
mp_log_name:=jobname&"-info.aux";
if ahlength=1: proc_end:=1; fi % first molecular only
@@ -82,6 +83,7 @@ def def_com(expr n)(text tx)= nA:=n; forsuffixes list=tx:: list:=nA; nA:=nA+1; e
def_com(-4000)(_term,_jp_atom,_jp_atom_abs,_jp_bond,_cyc,_cyc_sB,_cyc_eB,_set_line,_chg_line,
_dl,_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,
+ _skeletonA_end,_skeletonB_end,
_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,zf,zb,ov,dt,no,ar,vf,vb,wv,nl);
%-------------------------------------------------------------------------------------------------
@@ -92,7 +94,7 @@ def parameter_list=
ratio_chain_ring,offset_atom,offset_atom#,max_bond_width,ratio_bondgap_bond,ratio_zebra_black,
ratio_zebragap_bond,ratio_wedge_bond,ratio_atomgap_atom,offset_wedge,offset_wedge#,
offset_zebra_gap,offset_zebra_gap#,offset_bond_gap,offset_bond_gap#,
- offset_thickness,offset_thickness#
+ offset_thickness,offset_thickness#,numberA_start,numberA_end,numberB_start,numberB_end
enddef;
%-------------------------------------------------------------------------------------------------
nA:=0; for list=parameter_list: stock_p[incr nA]:=list; endfor
@@ -126,15 +128,16 @@ def endfont=
if proc_end=1: scantokens("bye"); fi
enddef;
%-------------------------------------------------------------------------------------------------
-def size_setup= BL# := font_wd#*ratio_bond_width;
- wedge_wd# := ratio_wedge_bond*BL#+offset_wedge#;
- zebra_gap# := ratio_zebragap_bond*BL#+offset_zebra_gap#;
- AL# := ratio_atom_bond*BL#+offset_atom#;
- gap# := ratio_bondgap_bond*BL#+offset_bond_gap#;
- bond_pen_wd# := ratio_thickness_bond*BL#+offset_thickness#;
- char_pen_wd# := ratio_char_bond*bond_pen_wd#;
- define_pixels(BL,zebra_gap,wedge_wd,AL,gap,bond_pen_wd,char_pen_wd,font_wd,font_ht);
- font_size_setup;
+def size_setup=
+ BL# := font_wd#*ratio_bond_width;
+ wedge_wd# := ratio_wedge_bond*BL#+offset_wedge#;
+ zebra_gap# := ratio_zebragap_bond*BL#+offset_zebra_gap#;
+ AL# := ratio_atom_bond*BL#+offset_atom#;
+ gap# := ratio_bondgap_bond*BL#+offset_bond_gap#;
+ bond_pen_wd# := ratio_thickness_bond*BL#+offset_thickness#;
+ char_pen_wd# := ratio_char_bond*bond_pen_wd#;
+ define_pixels(BL,zebra_gap,wedge_wd,AL,gap,bond_pen_wd,char_pen_wd,font_wd,font_ht);
+ font_size_setup;
enddef;
%-------------------------------------------------------------------------------------------------
def scaling= min_x:=min_y:= 4095.999; max_x:=max_y:=-4095.999;
@@ -167,7 +170,7 @@ enddef;
for i=1 upto 128: f_FON[i]=0; endfor asc0:=ASCII("0"); asc9:=ASCII("9");
def font_use_check=
for i=1 upto 128: if f_FON[i]<>0: f_FON[i]:=0; fi endfor
- if (sw_numberA=1)or(sw_numberB=1): for j=asc0 upto asc9: f_FON[j]:=1; endfor
+ if (sw_numberA>=1)or(sw_numberB>=1): for j=asc0 upto asc9: f_FON[j]:=1; endfor
else: for i=1 upto cntA: if strA[i]<>0: for j=0 upto length(com_str[strA[i]])-1:
f_FON[ASCII(pic_c(j,com_str[strA[i]]))]:=1; endfor fi endfor fi
enddef;
@@ -243,7 +246,8 @@ def $$(text t)(expr e) = begingroup save cntBS; cntBS:=0; ab_num:=ab_num+1;
enddef;
%-------------------------------------------------------------------------------------------------
def PA(expr b,c)= comMC[ab_num][incr cntAS]:=b; parMC[ab_num][cntAS]:=c; enddef;
-def @@(text t)(expr s)= begingroup save cntAS; cntAS:=0; ab_num:=ab_num+1;
+def @@(text t)(expr s)=
+ begingroup save cntAS; cntAS:=0; ab_num:=ab_num+1;
if known s:: if numeric s::
if (s>=H)and(s<=U):: for list==t:: PA(_set_adr,list) PA(_chg_atom,s) endfor
elseif s==NH:: for list==t::
@@ -277,37 +281,46 @@ def ps_get(expr n)= cntC:=cntMC[0]; cntPS:=cntP;
if ps_rot[i]<>0: PS(_rot_ang,ps_rot[i]) fi
if ps_env[i]<>hz: PS(_chg_env,ps_env[i]) fi
if (ps_line[i]<>0)and(ps_line[i]<>nl): PS(_tmp_line,ps_line[i]) fi
- if ps_len[i]<>chainRT: PS(_tmp_len,ps_len[i]) fi PS(_chg_len,chainRT)
+ if ps_len[i]<>crR: PS(_tmp_len,ps_len[i]) fi PS(_chg_len,crR)
if ps_line[i]<>nl: if ps_line[i]=no: PS(_adj_ang,0) fi PS(_mk_bond,0) fi
for j=1 upto cntMC[ps_com[i]]: PS(comMC[ps_com[i]][j],parMC[ps_com[i]][j]) endfor
PS(_pop,1) PS(_term,0)
endfor
- proc_atom(cntC+1); if cntP>cntPS: ps_get(cntPS+1); fi
+ proc_bond_atom(cntC+1); if cntP>cntPS: ps_get(cntPS+1); fi
enddef;
%-------------------------------------------------------------------------------------------------
def AUX(expr a,b)(text s)=s addto chem_structure also currentpicture shifted(a,b); clearit; enddef;
-def MCf(text s)= MCd(1,1)(.5,.5)(s); enddef;
-%-------------------------------------------------------------------------------------------------
+def MCf(text s)= MCd(1,1)(.5,.5)(s); enddef; % MC fill draw
+%-- MC draw --------------------------------------------------------------------------------------
def MCd(expr RW,RH)(expr FW,FH)(text s)=
if f_beginchar=0: beginchar(char_num,font_wd#,font_ht#,0); clearit; f_beginchar:=1; fi
- mc_num:=user_def_number; ab_num:=ab_def_number; chainRT:=-ratio_chain_ring;
+ mc_num:=user_def_number; ab_num:=ab_def_number; crR:=-ratio_chain_ring;
adrA:=adrB:=cntA:=cntB:=adrS:=cntPS:=angA[0]:=angB[0]:=br_ang[0]:=sB[0]:=cntC:=cntP:=0;
stkA[0]:=stkB[0]:=stkL[0]:=stkM[0]:=strAT:=f_lineT:=f_lenT:=f_envT:=f_rotT:=0;
eB[0]:=1; com_str[0]:=""; lineT:=si; str_cnt:=2000; posA[0]:=posB[0]:=posB[1]:=(0,0);
- if (sw_numberA=1)or(sw_numberB=1):
- ratio_atom_bond:=0.25; ratio_thickness_bond:=0.005; offset_atomn:=0; fi
+ if (sw_numberA>=1)or(sw_numberB>=1): ratio_atom_bond:=0.25; fi
if (sw_expand=1)or(sw_MOLfile=1): expand_set; fi
- ''(0)(s,(_term,0)); proc_atom(1); if cntP>0: ps_get(1); fi font_use_check;
- if sw_solid=1: size_setup; proc_skelton; scaling;
- else: size_setup; proc_skelton; scaling; resize(RW,RH); size_setup;
+ ''(0)(s,(_term,0)); proc_bond_atom(1); cntA_skeleton:=cntA; cntA_skeleton:=cntB;
+ if cntP>0: ps_get(1); fi
+ font_use_check;
+ if sw_solid=1: size_setup; proc_skeleton; scaling;
+ else: size_setup; proc_skeleton; scaling; resize(RW,RH); size_setup;
if ratio_bond_width>max_bond_width:
- ratio_bond_width:=max_bond_width; size_setup; proc_skelton; scaling;
- else: for i=1 upto 4: proc_skelton; scaling; resize(RW,RH); size_setup; endfor fi fi
+ ratio_bond_width:=max_bond_width; size_setup; proc_skeleton; scaling;
+ else: for i=1 upto 4: proc_skeleton; scaling; resize(RW,RH); size_setup; endfor fi fi
font_setup;
- for i=1 upto cntB: put_bond(i,sB[i],eB[i],angB[i],lineB[i]); endfor
+ for i=1 upto cntB: draw_bond(i,sB[i],eB[i],angB[i],lineB[i]); endfor
for i=1 upto cntA:
- if sw_numberA=1: put_string(i,posA[i],0,decimal(i),1); elseif sw_numberB=1:
- else: put_string(i,posA[i],br_ang[i],com_str[strA[i]],strW[strA[i]]); fi endfor
+ if numberA_end=_skeletonA_end: numberA_end:=cntA_skeleton; fi
+ if (sw_numberA>=1)and(i>=numberA_start)and(i<=numberA_end):
+ if sw_numberA=2: nA:=i-numberA_start+1;
+ elseif sw_numberA=3: if numberA_end<cntA: nA:=numberA_end-i+1; else: nA:=cntA-i+1; fi
+ else: nA:=i; fi
+ draw_atom(i,posA[i],0,decimal(nA),1);
+ elseif sw_numberB>=1:
+ else: draw_atom(i,posA[i],br_ang[i],com_str[strA[i]],strW[strA[i]]);
+ fi
+ endfor
sft_X:=-min_x+(font_wd-len_x)*FW; sft_Y:=-min_y+(font_ht-len_y)*FH;
if sw_mol_frame=1: AUX(sft_X,sft_Y)(draw_frame(len_x,len_y,(min_x,min_y),0.2pt);) fi
if sw_start_vector=1: AUX(sft_X,sft_Y)(start_vector) fi
@@ -322,15 +335,15 @@ def start_vector= draw (posA[1] shifted (-1mm,0))--(posA[1] shifted (-4mm,0))
fill (posA[1] shifted (-2mm,-1mm))--posA[1]--(posA[1] shifted (-2mm,1mm))--cycle;
enddef;
%------------------------------------------------------------------------------------------------
-def proc_atom(expr n)=
- f_Br:=f_En:=f_T:=rotT:=adrS:=f_lineT:=f_rotT:=f_lenT:=f_envT:=envT:=env:=0;
- stkL[0]:=B_len:=chainRT; lenT:=chainRT; stkA[1]:=stkB[1]:=1;
+def proc_bond_atom(expr n)=
+ f_bra:=f_end:=f_term:=rotT:=adrS:=f_lineT:=f_rotT:=f_lenT:=f_envT:=envT:=env:=0;
+ stkL[0]:=bondL:=crR; lenT:=crR; stkA[1]:=stkB[1]:=1;
for i=n upto cntMC[0]: com:= comMC[0][i]; par:=parMC[0][i];
if com=_push:
- if par=1: stkL[adrS]:=B_len; stkA[incr adrS]:=adrA:=cntA; stkB[adrS]:=adrB:=cntB;
- elseif par=0: temp_len:=B_len; fi
- elseif com=_pop: if par=1: adrA:=stkA[decr adrS]; adrB:=stkB[adrS]; B_len:=stkL[adrS];
- elseif par=0: B_len:=temp_len; fi
+ if par=1: stkL[adrS]:=bondL; stkA[incr 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]; 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;
@@ -339,30 +352,28 @@ def proc_atom(expr n)=
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=_jp_bond: tempB:=getB(par); sB[cntB+1]:=sB[tempB]; f_Br:=1;
- elseif com=0or_jp_atom: termA; sB[cntB+1]:=getA(par); f_Br:=1;
- elseif com=_jp_atom_abs: sB[cntB+1]:=par; f_Br:=1; temp_cntB:=cntB;
+ 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)]:=parMC[par][1];
- elseif com=_chg_len: if par=_ring_len: B_len:=ring_len;
- elseif par=0:
- if lenT<>chainRT: B_len:=lenT; else: if B_len<0: B_len:=1; fi fi
- else: B_len:=par; fi
- elseif com=_get_len: if par=0: if B_len=chainRT: B_len:=lenT; fi
- else: ring_len:=lenB[getB(par)]; fi
- elseif com=_tmp_len: lenT:=par;
+ 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
+ else: bondL:=par; fi
+ elseif com=_get_len: if par=0: if bondL=crR: bondL:=lenT; fi else: ringL:=lenB[getB(par)]; fi
+ elseif com=_tmp_len: lenT:=par;
elseif com=_set_line: lineB[getB(adrT)]:=par;
elseif com=_dl: lineB[getB(par)]:=dl;
elseif (com=_chg_line)or(com=_tmp_line): lineT:=par;
elseif com=_tmp_rot: rotT:=par;
- elseif com=_cyc: f_En:=getA(par); add_atom;
- elseif com=_cyc_eB: f_En:=eB[getB(par)]; add_atom;
- elseif com=_cyc_sB: f_En:=sB[getB(par)]; add_atom;
+ elseif com=_cyc: f_end:=getA(par); add_atom;
+ elseif com=_cyc_eB: f_end:=eB[getB(par)]; add_atom;
+ elseif com=_cyc_sB: f_end:=sB[getB(par)]; add_atom;
elseif com=_chg_env: env:=par;
elseif com=_tmp_env: envT:=par;
elseif com=_set_clr:
if par=1: if lineT<>si: f_lineT:=1; fi if rotT<>0: f_rotT:=1; fi
- if lenT<>chainRT: f_lenT:=1; fi if envT<>hz: f_envT:=1; fi fi
- if par=0: f_lineT:=f_rotT:=f_lenT:=f_envT:=rotT:=envT:=0; lineT:=si; lenT:=chainRT; fi
+ if lenT<>crR: f_lenT:=1; fi if envT<>hz: f_envT:=1; fi fi
+ if par=0: f_lineT:=f_rotT:=f_lenT:=f_envT:=rotT:=envT:=0; lineT:=si; lenT:=crR; fi
elseif com=_term: termA;
elseif com=_set_colorA: colorA[getA(adrT)]:=par;
elseif com=_set_colorB: colorB[getB(adrT)]:=par;
@@ -370,45 +381,48 @@ def proc_atom(expr n)=
endfor
enddef;
%-------------------------------------------------------------------------------------------------
-def ps_put(expr n,p)= ps_adr[incr cntP]:=n; ps_com[cntP]:=p; ps_len[cntP]:=lenT;
+def ps_put(expr n,p)=
+ ps_adr[incr cntP]:=n; ps_com[cntP]:=p; ps_len[cntP]:=lenT;
ps_line[cntP]:=lineT; ps_rot[cntP]:=rotT; ps_env[cntP]:=envT;
- if f_lineT=0: lineT:=si; fi if f_lenT=0: lenT:=chainRT; 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 add_atom= lineB[incr cntB]:=lineT; lineT:=si;
- if lenT=chainRT: lenB[cntB]:=B_len; else: lenB[cntB]:=lenT; lenT:=chainRT; fi
- if f_Br=0: cntA:=cntA+1; sB[cntB]:=cntA; strA[cntA]:=strAT; strAT:=0;
- if f_MP=1: colorA[cntA]:=colorB[cntA]:=0; fi else: f_Br:=0; fi
- if f_En=0: eB[cntB]:=cntA+1; f_T:=0; else: eB[cntB]:=f_En; f_En:=0; f_T:=1; fi
+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_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;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-def proc_skelton= stkA[1]:=stkB[1]:=1; envT:=env:=f_lineT:=f_rotT:=f_lenT:=f_envT:=0;
- adrA:=adrB:=cntA:=cntB:=angT:=adrS:=f_En:=f_Br:=rotT:=f_T:=0;
+def proc_skeleton=
+ stkA[1]:=stkB[1]:=1; envT:=env:=f_lineT:=f_rotT:=f_lenT:=f_envT:=0;
+ adrA:=adrB:=cntA:=cntB:=angT:=adrS:=f_end:=f_bra:=rotT:=f_term:=0;
for i=1 upto cntMC[0]: com:=comMC[0][i]; par:=parMC[0][i];
if com=_push: if par=1: stkM[adrS]:=env; adrS:=adrS+1; stkA[adrS]:=adrA:=cntA;
stkB[adrS]:=adrB:=cntB;
- elseif par=0: temp_len:=B_len; fi
+ elseif par=0: temp_len:=bondL; fi
elseif com=_pop: if par=1: adrA:=stkA[decr adrS]; adrB:=stkB[adrS]; env:=stkM[adrS];
- elseif par=0: temp_len:=B_len; fi
+ 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_Br:=1; rotT:=0;
+ angT:=angB[tempB]-180; f_bra:=1; rotT:=0;
elseif com=0or_jp_atom: termB; adrT:=getA(par); posB[cntB+1]:=posA[adrT];
- angT:=br_ang[adrT]; f_Br:=1; rotT:=0;
+ angT:=br_ang[adrT]; f_bra:=1; rotT:=0;
elseif com=_jp_atom_abs: adrT:=par; posB[cntB+1]:=posA[adrT];
- angT:=br_ang[adrT]; f_Br:=1; rotT:=0; temp_cntB:=cntB;
+ angT:=br_ang[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_B(par);
+ 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=_chg_env: env:=par;
elseif com=_tmp_env: envT:=par;
- elseif com=_set_clr: f_clr:=par; if par=0: lineT:=si; lenT:=chainRT; rotT:=envT:=0; fi
- elseif com=_cyc: f_En:=1; proc_cyc(getA(par));
- elseif com=_cyc_sB: f_En:=1; proc_cyc(sB[getB(par)]);
- elseif com=_cyc_eB: f_En:=1; proc_cyc(eB[getB(par)]);
+ elseif com=_set_clr: f_clr:=par; if par=0: lineT:=si; lenT:=crR; rotT:=envT:=0; fi
+ elseif com=_cyc: f_end:=1; proc_cyc(getA(par));
+ elseif com=_cyc_sB: f_end:=1; proc_cyc(sB[getB(par)]);
+ elseif com=_cyc_eB: f_end:=1; proc_cyc(eB[getB(par)]);
elseif com=_term: termB;
fi
endfor
@@ -418,29 +432,31 @@ vardef getA(expr n)= if n>=1: stkA[adrS+1]+n elseif n<=-1: cntA+n+1
elseif n>0: stkA[adrS]+2048n elseif n<0: -2048n fi enddef;
vardef getB(expr n)= if n>=1: stkB[adrS+1]+n elseif n<=-1: cntB+n+1 elseif n=0: tempB
elseif n>0: stkB[adrS]+2048n elseif n<0: -2048n fi enddef;
-def termA= if f_T=0: if f_Br=0: strA[incr cntA]:=strAT; strAT:=0;
- if f_MP=1: colorA[cntA]:=0; fi else: f_Br:=0; fi f_T:=1; fi enddef;
-def termB= if f_T=0: if f_Br=0: br_ang[incr cntA]:=angT; else: f_Br:=0; fi f_T:=1; fi enddef;
-def proc_cyc(expr n)= add_B(angle(posA[n]-posB[cntB+1])-angT); enddef;
+def termA= if f_term=0: if f_bra=0: strA[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: br_ang[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:=.5strW[strA[n]]*AL;
if (nB<45)or(nB>135):glu:=glu+((sind(nB)*nC)++nC);
else :glu:=glu+((cosd(nB)*.5AL)++.5AL) fi fi
enddef;
%-------------------------------------------------------------------------------------------------
-def add_B(expr m)=
+def add_bond(expr m)=
cntB:=cntB+1; if m=_arg_ang: tn:=proc_env(angT,env,60,-60); else: tn:=m; fi
- if f_Br=0: adrT:=cntA:=cntA+1; posA[cntA]:=posB[cntB]; angA[cntA]:=angT;
+ if f_bra=0: adrT:=cntA:=cntA+1; posA[cntA]:=posB[cntB]; angA[cntA]:=angT;
if tn>=0: br_ang[cntA]:=angT+tn/2-90; else: br_ang[cntA]:=angT+tn/2+90; fi
- else: f_Br:=0; fi
+ else: f_bra:=0; fi
angB[cntB]:=angT:=(angT+tn) mod 360;
- if f_En=0: if lenB[cntB]=_size_a: posB[cntB+1]:=sfB(posB[cntB],AL,angT);
+ if f_end=0: if lenB[cntB]=_size_a: posB[cntB+1]:=sfB(posB[cntB],AL,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*BL+glu,angT); fi
- posA[cntA+1]:=posB[cntB+1]; f_T:=0;
- else: f_En:=0; f_T:=1; fi
+ posA[cntA+1]:=posB[cntB+1]; f_term:=0;
+ else: f_end:=0; f_term:=1; fi
enddef;
%-------------------------------------------------------------------------------------------------
-vardef proc_env(expr n,m,a,b)= r:=(n mod 360);
+vardef proc_env(expr n,m,a,b)=
+ r:=(n mod 360);
if m>=first_def_number: parMC[m][cntB-temp_cntB-1] 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
@@ -448,7 +464,7 @@ vardef proc_env(expr n,m,a,b)= r:=(n mod 360);
enddef;
%-------------------------------------------------------------------------------------------------
def pic_c(expr i,s)= substring(i,i+1) of s enddef;
-def put_string(expr n,p,r,s,w)=
+def draw_atom(expr n,p,r,s,w)=
if ((r mod 360)<=90+1)or((r mod 360)>=270-1): dx:=1; else: dx:=-1; fi
pairT:=p-(.5AL*w*dx,.5AL); u:=j:=0;
for i=0 upto length(s)-1: nB:=ASCII(pic_c(i,s));
@@ -458,7 +474,7 @@ def put_string(expr n,p,r,s,w)=
elseif nB=hat: if u=0: u:= .5; else:u:=0; fi;
elseif (nB<>par_s)and(nB<>par_e): nA:=atom_w[nB]; pairA:=pairT+(.5*((dx-1)*nA),u*AL);
if sw_atom_frame=1: draw_frame(nA,AL,pairA,0.01pt); fi
- if (sw_numberA=1)or(sw_numberB=1):
+ if (sw_numberA>=1)or(sw_numberB>=1):
erase fill unitsquare xscaled nA yscaled AL shifted pairA wpcs 0.01pt; fi
addto currentpicture also atom_font[nB] shifted (pairA-(0,atom_d[nB])) Cp(colorA[n]);
pairT:=pairT+(nA*dx,0); fi endfor
@@ -474,7 +490,8 @@ def z_put(expr PA,PB,PD,CL)= save nA,nC,nD; nC:=length(Le-Ls);
fill nA[PB,PA]--nA[PD,PA]--nD[PD,PA]--nD[PB,PA]--cycle Cp(CL); endfor enddef;
def cut_off(expr p,w,h,s)=
p intersectionpoint sqr(1.1w,1.1h) shifted (s-(.5(1.1w),.5(1.1h))); enddef;
-def clipping(expr SA,SB,PA,PB,LEN)= pT:=PA--PB; tn:=0.6AL/LEN;
+def clipping(expr SA,SB,PA,PB,LEN)=
+ pT:=PA--PB; tn:=0.6AL/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,AL*strW[SB],AL,PB);
pA:=Ls--Le; pB:=Ls--tn[PB,PA]; pC:=0.1[PA,PB]--Le;
@@ -484,14 +501,17 @@ def clipping(expr SA,SB,PA,PB,LEN)= pT:=PA--PB; tn:=0.6AL/LEN;
pB:=tn[PA,PB]--tn[PB,PA]; pC:=pA:=Ls--Le; fi
enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-def draw_wv= nB:=3bond_pen_wd; nA:=nB/length(Le-Ls);
+def draw_wv=
+ nB:=3bond_pen_wd; nA:=nB/length(Le-Ls);
draw Le for i=1 upto 1/nA: if odd(i): ..controls(((i-.5)*nA)[sfB(Le,nB,ap),sfB(Ls,nB,ap)])
else: ..controls(((i-.5)*nA)[sfB(Le,nB,am),sfB(Ls,nB,am)]) fi ..(i*nA)[Le,Ls] endfor ..Ls;
enddef;
%-------------------------------------------------------------------------------------------------
-def put_bond(expr n,BP,EP,ANG,LN)= 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);
+def draw_bond(expr n,BP,EP,ANG,LN)=
+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
pickup pencircle scaled bond_pen_wd;
if known colorB[n]: nB:=colorB[n]; fi
@@ -510,7 +530,12 @@ if (nC>0)and(LN<>0): ww:=wedge_wd; hpt:=.5bond_pen_wd; ap:=ANG+90; am:=ANG-90;
elseif LN=ov:erase draw 0.15[Ls,Le]--0.85[Ls,Le] wpcs gap; draw pA Cp(nB);
elseif LN=vf:draw pA Cp(nB);draw sfB(Le,gap,ANG-150)--Le--sfB(Le,gap,ANG+150) Cp(nB);
elseif LN=vb:draw pA Cp(nB);draw sfB(Ls,gap,ANG-30)--Ls--sfB(Ls,gap,ANG+30) Cp(nB); fi
- if sw_numberB=1: put_string(n,.5[posA[BP],posA[EP]],0,decimal(n),1); fi fi
+ if (sw_numberB>=1)and(n>=numberB_start)and(n<=numberB_end):
+ if sw_numberB=2: nB:=n-numberB_start+1;
+ elseif sw_numberB=3: if numberB_end<cntB: nB:=numberB_end-n+1; else: nB:=cntB-n+1; fi
+ else: nB:=n; fi
+ draw_atom(n,.5[posA[BP],posA[EP]],0,decimal(nB),1); fi
+fi
enddef;
%-------------------------------------------------------------------------------------------------
vardef fit_zero(expr n)=if n<=9: "00" elseif n<=99: "0" fi enddef;
@@ -563,7 +588,7 @@ 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;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-def font_size_set(expr m)(expr n)(expr o)(expr s)=%
+def font_size_set(expr m)(expr n)(expr o)(expr s)=
for j=0 upto length(s)-1: num_a:=ASCII(pic_c(j,s));
if f_FON[num_a]=1: atom_w[num_a]:=m*AL; atom_h[num_a]:=n*AL; atom_d[num_a]:=o*AL; fi
endfor
@@ -593,7 +618,8 @@ if f_FON[ASCII(c)]=1:
clearxy; save x,y; clearit; fi
enddef;
%-------------------------------------------------------------------------------------------------
-def font_setup= pickup pencircle scaled char_pen_wd; fP:=char_pen_wd; hP:=.5char_pen_wd;
+def font_setup=
+pickup pencircle scaled char_pen_wd; fP:=char_pen_wd; hP:=.5char_pen_wd;
FD(" ")();
FD(".")(drawdot z19 wpcs fP);
FD(",")(drawdot z19 wpcs fP; draw (hW+.5fP,hP)..(hW+.3fP,-fP)..(hW-.5fP,hP-2fP));
@@ -707,7 +733,8 @@ STb("CHO")("C","H","O"); STb("N{O_2_}")("N","O","O"); STb("N{H_2_}")("N","H","H
STb("S{O_3_}")("S","O","O","O"); STb("COOH")("C","O","O","H");
STb("C{H_3_}")("C","H","H","H"); STb("C{F_3_}")("C","F","F","F");
%-------------------------------------------------------------------------------------------------
-def mol_check= hide_H:=warning_cnt:=calc_weight:=calc_weightp:=0; calc_formula:="";
+def mol_check=
+ hide_H:=warning_cnt:=calc_weight:=calc_weightp:=0; calc_formula:="";
for i=1 upto tbl_max: sumA[i]:=0; endfor
for i=1 upto cntA: knownA:=nA:=0;
for j=1 upto cntB: if (lineB[j]=dl)or(lineB[j]=dr)or(lineB[j]=dm): nB:=2;
@@ -737,7 +764,8 @@ def mol_check= hide_H:=warning_cnt:=calc_weight:=calc_weightp:=0; calc_formula
endfor
enddef;
%-------------------------------------------------------------------------------------------------
-def checklist_out= nA:=0; calc_weight_str:="";
+def checklist_out=
+ nA:=0; calc_weight_str:="";
message "% Molecular name = "& mol_name;
message "% There were "&fdr(3)(warning_cnt)&" warnings";
message "% width * height = " & fdr(8)(max_x-min_x)&" * "&fdr(8)(max_y-min_y);
@@ -767,7 +795,8 @@ def checklist_out= nA:=0; calc_weight_str:="";
message "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%";
enddef;
%------------------------------------------------------------------------------------------------
-def MOL_out= mp_log_name:=jobname&"-"&fit_zero(char_num)&decimal(char_num)&"-"&mol_name&".mol";
+def MOL_out=
+ mp_log_name:=jobname&"-"&fit_zero(char_num)&decimal(char_num)&"-"&mol_name&".mol";
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])/BL)& fdr(10)(ypart(posA[i])/BL)&