summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/metapost
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2021-05-05 19:35:28 +0000
committerKarl Berry <karl@freefriends.org>2021-05-05 19:35:28 +0000
commit719bdad66e817a3a745d2e86e8d56d75e07fe68b (patch)
treeee74c6ce4a193d72389fdc8e3cae43a70aaee1af /Master/texmf-dist/metapost
parented1e81738530cebab06a7f5f22509a8c30485e02 (diff)
mcf2graph (5may21)
git-svn-id: svn://tug.org/texlive/trunk@59086 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/metapost')
-rw-r--r--Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf122
1 files changed, 75 insertions, 47 deletions
diff --git a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
index 0c935ab56a1..38086f87eb5 100644
--- a/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
+++ b/Master/texmf-dist/metapost/mcf2graph/mcf2graph.mf
@@ -1,5 +1,5 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% mcf2graph ver 4.63 Copyright (c) 2013-2021 Akira Yamaji
+% mcf2graph ver 4.64 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,16 +37,16 @@
% Set to use plain.mp (label,arrow,atom) : mpost -s labeloffset=2 FILENAME
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tracingstats:=1;
-message "* This is mcf2graph ver 4.63 2021.04.18";
+message "* This is mcf2graph ver 4.64 2021.05.05";
%-------------------------------------------------------------------------------------------------
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[],cmm_adr[];
-string save_str[],tbl_atom_str[],strD[],tag[],file_name_output,blank_str,temps,aux_delimiter,
+ lineB[],sB[],eB[],angB[],angA[],lenB[],angX[],numS[],wdM[],htM[],wdA[],dxA[],cmm_adr[],
+ mc_indent[];
+string save_str[],tbl_atom_str[],strD[],tag[],file_name_output,blank_str,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;
pair save_pair[],posA[],posM[][],msize,mposition,fsize,fmargin,save_mposition,posBs,posBe,dum;
@@ -58,10 +58,10 @@ sw_numberA:=sw_numberB:=sw_expand:=sw_fframe:=sw_mframe:=sw_aframe:=sw_trimming:
sw_group_off:=sw_single:=sw_arrow_emu:=sw_output:=0;
numberA_start:=numberB_start:=1; numberA_end:=numberB_end:=4095;
%-------------------------------------------------------------------------------------------------
-aux_max:=max_inf_num:=20; aux_delimiter:=";"; blank_str:= " ";
+aux_max:=max_inf_num:=20; aux_delimiter:=";"; blank_str:= " "; dum:=(-4091,0);
for i=1 upto aux_max: tag[i]:=""; endfor
-dum:=(-4091,0);
-None:=11; Info1:=21; Info2:=22; Report:=31; MOL2k:=41; MOL3k:=42; Mfont:=51;
+None:=11; Info1:=21; Info2:=22; Info_t:=23; Report:=31; MOL2k:=41; MOL3k:=42;
+Mfont:=51; Mcode:=61; Mcode_t:=62; Info_Mcode_t:=63;
%-------------------------------------------------------------------------------------------------
a_prn_s:=ASCII("("); a_prn_e:=ASCII(")"); a_brc_s:=ASCII("{"); a_brc_e:=ASCII("}");
a_brk_s:=ASCII("["); a_brk_e:=ASCII("]"); a_cmm:=ASCII(","); a_equ:=ASCII("=");
@@ -98,20 +98,22 @@ if (known green)and(known ahlength):
mpfont:="uhvr8r";
atomfont:=defaultfont:="";
%--default ahangle=45---------------------------------------------------------------------
- if ahangle=0: outputformat:="eps"; % eps format(.mps)
- elseif ahangle=1: outputformat:="png"; hppp:=vppp:=0.12; % png format(600dpi)
- elseif ahangle=11: outputformat:="png"; hppp:=vppp:=0.06; % png format(1200dpi)
- elseif ahangle=2: outputformat:="svg"; % svg format
- elseif ahangle=3: outputformat:="eps"; % eps format(.eps)
- elseif ahangle=45: outputformat:="eps"; % eps format(.eps)
+ if ahangle=0: outputformat:="eps"; % eps format(.mps)
+ elseif ahangle=1: outputformat:="png"; hppp:=vppp:=0.12; % png format(600dpi)
+ elseif ahangle=11: outputformat:="png"; hppp:=vppp:=0.06; % png format(1200dpi)
+ elseif ahangle=2: outputformat:="svg"; % svg format
+ elseif ahangle=3: outputformat:="eps"; % eps format(.eps)
+ elseif ahangle=45: outputformat:="eps"; % eps format(.mps) *default
fi
%--default ahlength=4---------------------------------------------------------------------
if ahlength=1: sw_output:=Info1; % output aux file
elseif ahlength=2: sw_output:=Info2; % output aux file(fixed mode)
elseif ahlength=3: sw_output:=Report; % output report
+ elseif ahlength=4: sw_output:=0; % *default
elseif ahlength=5: sw_output:=MOL2k; % output MOL(V2000)
elseif ahlength=6: sw_output:=MOL3k; % output MOL(V3000)
- elseif ahlength=7: sw_output:=Mfont; % output Mfont
+ elseif ahlength=7: sw_output:=Mfont; % output aux mf
+ elseif ahlength=8: sw_output:=Mcode; % output aux mc
fi
%-- default bboxmargin=2------------------------------------------------------------------
if bboxmargin=1: proc_end:=1; fi % output first font only
@@ -154,11 +156,12 @@ if f_MP=1:
if bboxmargin=1: message "* output first font only"; fi
message "* jobname="&jobname;
message "* numbersystem="&numbersystem;
- if ahlength=1: message "* output info file";
+ if (ahlength=1)or(ahlength=2):
+ message "* output info file";
message "* file name="&jobname&"-info.aux";
message "* info delimiter="&aux_delimiter;
- ef ahlength=2: message "* output report file";
- message "* file name="jobname&"-report.txt";
+ ef ahlength=3: message "* output report file";
+ message "* file name="&jobname&"-report.txt";
ef ahlength=5: message "* output MOL file(V2000)";
message "* "&jobname&"-nnn-"&"inf_EN"&".mol";
ef ahlength=6: message "* output MOL file(V3000)";
@@ -251,10 +254,10 @@ enddef;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def beginfont(text s)=
begingroup
- save ',f_beginchar,f_ext,blen,ext,add,ang_br,n_fw,n_bw,at_colon,at_semicol,info,mc,temps,
- file_name_input,t_tag,f_close;
+ save ',f_beginchar,f_ext,blen,ext,add,ang_br,n_fw,n_bw,at_colon,at_semicol,temps,t_tag,f_close,
+ mc,info,file_name_input,bond_cnt,warning_cnt,hideH_cnt,bondC;
numeric at_semicol[];
- string info[],mc[],temps,mc,file_name_input,t_tag;
+ string info[],mc[],mc,temps,file_name_input,t_tag;
%------------------------------------------------------------------------------------------------
def ext=ext_to_font enddef;
def add=add_to_molecule enddef;
@@ -296,7 +299,7 @@ def beginfont(text s)=
enddef;
%==================================================================================================
def endfont=
- if (sw_output=0)or(sw_output=None):
+ if ((sw_output=0)or(sw_output=None))and(f_EOF=0):
if cntM>=1:
if sw_ext_all=1: ext_to_font(EXT_ALL); fi
if sw_trimming>=1:
@@ -344,7 +347,18 @@ def endfont=
%% message "* parts_cnt (0)="& decimal(parts_cnt) &" "& decimal(parts_usr-parts_usr_start);
%% message "* parts_int (0)="& decimal(parts_int) &" "& decimal(parts_int-parts_int_start);
%-----------------------------------------------------------------------------------------------
+ ef sw_output=Info1: proc_info_out(1);
+ ef sw_output=Info2: proc_info_out(2);
+ ef sw_output=Info_t: proc_info_out(3);
+ ef sw_output=Mcode: proc_mc_out(1);
+ ef sw_output=Mcode_t: proc_mc_out(2);
+ ef sw_output=Mfont: proc_mf_out(0);
+ ef sw_output=Report: proc_report_out(0);
+ ef sw_output=MOL2k: proc_mol_out(1);
+ ef sw_output=MOL3k: proc_mol_out(2);
+ ef sw_output=Info_Mcode_t: proc_info_out(3); proc_mc_out(2);
fi
+ %-----------------------------------------------------------------------------------------------
restore_par(parameter_list);
if proc_end=1: scantokens("bye"); fi
endgroup;
@@ -937,7 +951,7 @@ def MC(text TXT)=
mol_stru[cntM]:=currentpicture;
clearit;
endgroup;
- if cntM=1: if (sw_output>=None)and(sw_output<=Mfont): proc_output(sw_output); fi fi
+ if sw_output>0: proc_calc(0); fi
enddef;
%-------------------------------------------------------------------------------------------------
def add_group=
@@ -1508,10 +1522,21 @@ vardef erase_brace(expr ATOM)=
else: ATOM
fi
enddef;
+%-------------------------------------------------------------------------------------------------
+vardef erase_space(expr TXT)=
+ save temp_c,temp_s;
+ string temp_c,temp_s;
+ temp_s:="";
+ for i=1 upto length(TXT):
+ temp_c:=subc(i,TXT);
+ if temp_c=" ": temp_s:=temp_s&"_"; else: temp_s:=temp_s&temp_c; fi
+ endfor
+ temp_s
+enddef;
%=================================================================================================
-def proc_output(expr n)=
+def proc_calc(expr n)=
begingroup
- save knownA,bondC,tmp_wtp,bond_cnt,warning_cnt,hideH_cnt;
+ save knownA,tmp_wtp;
num_MW:=num_MI:=cen_MW:=cen_MI:=tbl_atom_max:=warning_cnt:=hideH_cnt:=0;
nE:=parts_emb_start;
for i=1 upto tbl_atom_end: sumA[i]:=0; endfor
@@ -1581,27 +1606,22 @@ def proc_output(expr n)=
if cen_MI<40: cal_MI:=substring (0,10) of decimal(num_MI);
else: num_MI:=cen_MI; cal_MI:=fdr(8)(cen_MI)&"*100"; fi
%-------------------------------------------------------------------------------------
- if n=Report: proc_report_out(0);
- ef n=Info1: proc_auxfile_out(1);
- ef n=Info2: proc_auxfile_out(2);
- ef n=MOL2k: proc_mol_out(1);
- ef n=MOL3k: proc_mol_out(2);
- ef n=Mfont: proc_mf_out(0);
- fi
endgroup
enddef;
%=================================================================================================
-def proc_auxfile_out(expr n)=
+def proc_info_out(expr n)=
message "["&decimal(char_num)&"]:"&inf_EN;
- file_name_output:=jobname&"-info.aux";
+ if n=3: file_name_output:="temp-info.aux";
+ else: file_name_output:=jobname&"-info.aux";
+ fi
%--------------------------------------------------------------------------------------
if (char_num=1)and(n=2):
- printf tag[1] for i=2 upto aux_max: exitif tag[i]=""; &aux_delimiter&tag[i] endfor ;
+ printf tag[1] for i=2 upto aux_max: exitif tag[i]=""; &aux_delimiter&tag[i] endfor% ;
fi
%--------------------------------------------------------------------------------------
for i=1 upto aux_max: exitif tag[i]="";
if i=1: printf "" else: &aux_delimiter fi
- if n=1: &tag[i]&":" fi
+ if (n=1)or(n=3): &tag[i]&":" fi
%-------------------------------------------
if tag[i]="J": & jobname
ef tag[i]="C": & decimal(char_num)
@@ -1627,14 +1647,10 @@ def proc_auxfile_out(expr n)=
ef tag[i]="EXB": & inf_EXB
ef tag[i]="MC": & inf_MC
fi
- endfor
+ endfor ;
+ if n=3: printf EOF; fi
enddef;
%=================================================================================================
-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_report_out(expr n)=
message "["&decimal(char_num)&"]:"&inf_EN;
file_name_output:=jobname&"-report.txt";
@@ -1642,9 +1658,7 @@ def proc_report_out(expr n)=
printf " No."&fdr(4)(char_num)&" / Name = "& inf_EN&" / file = "& file_name_input;
if mc_row>=1:
printf "---------------------------------------------------------------------------";
- for i=1 upto mc_row:
- printf (substring(0,mc_indent[i]) of blank_str)&mc[i];
- endfor
+ for i=1 upto mc_row: printf (substring(0,mc_indent[i]) of blank_str)&mc[i]; endfor
printf "---------------------------------------------------------------------------";
printf " row="&fdr(3)(mc_row)&" / length="&fdr(4)(length(mc))&
" / commands="&fdr(3)(cnt_cmm);
@@ -1698,10 +1712,15 @@ def proc_report_out(expr n)=
if inf_FM<>"-": &inf_FM&" / "& iif(inf_FM=cal_FM,"MACTCH","NOT MACTCH") fi;
printf "===========================================================================";
enddef;
+%-------------------------------------------------------------------------------------------------
+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_mol_out(expr n)=
message "["&decimal(char_num)&"]:"&inf_EN;
- file_name_output:=jobname&"-"&fit_zero(char_num)&"-"&inf_EN&".mol";
+ file_name_output:=jobname&"-"&fit_zero(char_num)&"-"&erase_space(inf_EN)&".mol";
%-V2000---------------------------------------------------------------------------------------
if n=1:
printf ""; printf " -MCFtoMOL- "&fsl(20)(info[1]); printf "";
@@ -1753,7 +1772,16 @@ def proc_mf_out(expr n)=
printf "endfont";
if n=1: printf "%-------------------------------------------------------------------------"; fi
enddef;
-%-------------------------------------------------------------------------------------------------
+%=================================================================================================
+def proc_mc_out(expr n)=
+ message "["&decimal(char_num)&"]:"&inf_EN;
+ if n=2: file_name_output:="temp-mc.aux";
+ else: file_name_output:=jobname&"-"&fit_zero(char_num)&"-"&erase_space(inf_EN)&"-mc.aux";
+ fi
+ for i=1 upto mc_row: printf (substring(0,mc_indent[i]) of blank_str)&mc[i]; endfor
+ printf EOF;
+enddef;
+%=================================================================================================
vardef fit_zero(expr n)=if n<=9: "00" elseif n<=99: "0" else: "" fi &decimal(n) enddef;
%-------------------------------------------------------------------------------------------------
vardef bond_type(expr n)=