diff options
Diffstat (limited to 'Master/texmf-dist/metapost/drv/drv.mp')
-rw-r--r-- | Master/texmf-dist/metapost/drv/drv.mp | 250 |
1 files changed, 163 insertions, 87 deletions
diff --git a/Master/texmf-dist/metapost/drv/drv.mp b/Master/texmf-dist/metapost/drv/drv.mp index 8323b9f00af..09cd16a41d5 100644 --- a/Master/texmf-dist/metapost/drv/drv.mp +++ b/Master/texmf-dist/metapost/drv/drv.mp @@ -1,5 +1,5 @@ -%% drv 0.96 -%% Copyright 2010 Laurent M\'ehats +%% drv 0.97 +%% Copyright 2011 Laurent M\'ehats % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -17,7 +17,7 @@ % This work consists of the file drv.mp newinternal drv_version; -drv_version:=0.96; +drv_version:=0.97; %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -208,18 +208,22 @@ drv_version:=0.96; % % drv_box_mode <id> % <id> status identifier (on or off) -% on -% off % % drv_fraction_mode <id> % <id> status identifier (on or off) -% on -% off % % drv_proof_mode <id> % <id> status identifier (on or off) -% on -% off +% +% drv_labels_mode (<id 1>, <id 2>) +% <id 1> label-type identifier (ilb, plb or dlb) +% ilb inference labels +% dlb delimiter labels +% plb phantom steps labels +% <id 2> status identifier (on or off) +% +% drv_verbatimtex <str> +% <str> LaTeX material % % drv_radial_mode <id> % <id> status identifier (on or off) @@ -463,6 +467,15 @@ vardef drv_tex[] expr tex_str= pct enddef; +vardef drv_verbatimtex expr tex_str= + write char(10)& + "% drv_verbatimtex"&char(10)&char(10)& + "verbatimtex"&char(10)& + tex_str&char(10)& + "etex;" + to delayed_tex_file; +enddef; + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % @@ -584,11 +597,11 @@ vardef drv_font_size expr size_str= min_clr[2]:=1*rul_thk[2]; % Rule 15d. min_clr[3]:=1*rul_thk[3]; % for mth_sty:=0 upto 3: - sp_pct:=drv_tex[mth_sty] "\thinspace"; + sp_pct:=drv_tex[mth_sty] "\,"; % thinspace thn_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\medspace"; + sp_pct:=drv_tex[mth_sty] "\:"; % medspace med_sp[mth_sty]:=width sp_pct; - sp_pct:=drv_tex[mth_sty] "\thickspace"; + sp_pct:=drv_tex[mth_sty] "\;"; % thickspace thk_sp[mth_sty]:=width sp_pct; pdt_pct:=drv_tex[mth_sty] "\ldotp"; pdt_hg[mth_sty]:=height pdt_pct; @@ -750,23 +763,44 @@ vardef text_arc (expr pct, rad) expr tnum= string tok_str; arc_pct:=nullpicture; for tok within pct: - transform tok_trn; - tok_str:=textpart tok; - (0, 0) transformed tok_trn=(0, 0); - (0, 1) transformed tok_trn=(xypart tok, yypart tok); - (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); - tok_ngl:=arc_angle (rad, xpart tok) tnum; - for chr_rnk=0 upto (length tok_str-1): - chr_pct:=substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) - transformed tok_trn; - hlf_wd:=(width chr_pct)/2; - tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; - addto arc_pct also chr_pct - shifted (-hlf_wd, 0) - rotated (tok_ngl+tnum*90) - shifted ((dir tok_ngl) scaled (rad-tnum*(ypart tok))); - tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; - endfor + if textual tok: + transform tok_trn; + tok_str:=textpart tok; + (0, 0) transformed tok_trn=(0, 0); + (0, 1) transformed tok_trn=(xypart tok, yypart tok); + (1, 0) transformed tok_trn=(xxpart tok, yxpart tok); + tok_ngl:=arc_angle (rad, xpart tok) tnum; + for chr_rnk=0 upto (length tok_str-1): + chr_pct:= + substring (chr_rnk, chr_rnk+1) of tok_str infont (fontpart tok) + transformed tok_trn; + hlf_wd:=(width chr_pct)/2; + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + addto arc_pct also chr_pct + shifted (-hlf_wd, 0) + rotated (tok_ngl+tnum*90) + shifted (dir tok_ngl scaled (rad-tnum*(ypart tok))); + tok_ngl:=tok_ngl+arc_angle (rad, hlf_wd) tnum; + endfor + elseif stroked tok: + path pth; + pair src, tgt; + numeric src_ngl, tgt_ngl; + pth:=pathpart tok; + src:=point 0 of pth; + tgt:=point length pth of pth; + src_ngl:=arc_angle (rad, xpart src) tnum; + tgt_ngl:=arc_angle (rad, xpart tgt) tnum; + interim linecap:=butt; + addto arc_pct doublepath + if xpart src<>xpart tgt: % horizontal rule + (circ_path (rad-tnum*(ypart src), tgt_ngl-src_ngl) tnum) + rotated src_ngl + else: % vertical rule + pth shifted -src rotated (src_ngl+tnum*90) + shifted (dir src_ngl scaled (rad-tnum*(ypart src))) + fi withpen penpart tok; + fi endfor arc_pct enddef; @@ -1030,6 +1064,10 @@ string drv_alg_sty; % default junction style numeric drv_iln_sty; % default inference line path-style numeric drv_phm_sty; % default phantom steps path-style +boolean drv_ilb_on; % inference labels on +boolean drv_dlb_on; % delimiter labels on +boolean drv_plb_on; % phantom steps labels on + % % 2. Macros % @@ -1198,13 +1236,24 @@ vardef NFR[] (text PRM) (expr lilb, rilb, ldlb, rdlb) % % lilb, rilb: inference labels % - opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; - opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + if drv_ilb_on: + opt_init[ilb_sty[drv_sty]] l_ilb[@] lilb; + opt_init[ilb_sty[drv_sty]] r_ilb[@] rilb; + fi % % ldlb, rdlb: delimiter labels % - opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; - opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + if drv_dlb_on: + opt_init[dlb_sty[drv_sty]] l_dlb[@] ldlb; + opt_init[dlb_sty[drv_sty]] r_dlb[@] rdlb; + else: + if ldlb<>"": + box_init l_dlb[@] (mth_tex[dlb_sty[drv_sty]] "{}"); + fi + if rdlb<>"": + box_init r_dlb[@] (mth_tex[dlb_sty[drv_sty]] "{}"); + fi + fi % % j_sty, a_sty and i_sty: junction, alignment and inference styles % @@ -1246,8 +1295,10 @@ vardef MVD[] (expr inf_num, lplb, rplb) (suffix a_sty, p_sty)= % % lplb, rplb: phantom steps labels % - opt_init[plb_sty[drv_sty]] l_plb[phm_idx] lplb; - opt_init[plb_sty[drv_sty]] r_plb[phm_idx] rplb; + if drv_plb_on: + opt_init[plb_sty[drv_sty]] l_plb[@] lplb; + opt_init[plb_sty[drv_sty]] r_plb[@] rplb; + fi phm_idx fi enddef; @@ -1872,32 +1923,33 @@ vardef drv_lin_build[]= % phantom steps % if known tgt[@]: - save bot_y, top_y, phm_pct; - numeric bot_y, top_y; + save trg, bot_y, top_y, phm_pct; + numeric trg, bot_y, top_y; picture phm_pct; + trg:=tgt[@]; if bot_jdg[@]: bot_y:=min_y[@]+min_clr_scl*min_clr[drv_sty]/2; - top_y:=min_y[tgt[@]]; + top_y:=min_y[trg]; else: - bot_y:=max_y[tgt[@]]; + bot_y:=max_y[trg]; top_y:=max_y[@]-min_clr_scl*min_clr[drv_sty]/2; fi phm_pct:=((0, (bot_y-top_y)/2)--(0, (top_y-bot_y)/2)) drv_styled phm_sty[@]; - box_init phm[@] (phm_pct shifted ((width phm_pct)/2, 0)); - phm[@].c=(xpart jdg[@].c, (top_y+bot_y)/2); - nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[@].l); - nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[@].r); + box_init phm[trg] (phm_pct shifted ((width phm_pct)/2, 0)); + phm[trg].c=(xpart jdg[@].c, (top_y+bot_y)/2); + nfr_min_x[@]:=min (nfr_min_x[@], xpart phm[trg].l); + nfr_max_x[@]:=max (nfr_max_x[@], xpart phm[trg].r); % % phantom steps labels % - if known l_plb[@]: - l_plb[@].r=phm[@].l shifted (-plb_skp[drv_sty], 0); - nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[@].l); + if known l_plb[trg]: + l_plb[trg].r=phm[trg].l shifted (-plb_skp[drv_sty], 0); + nfr_min_x[@]:=min (nfr_min_x[@], xpart l_plb[trg].l); fi - if known r_plb[@]: - r_plb[@].l=phm[@].r shifted ( plb_skp[drv_sty], 0); - nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[@].r); + if known r_plb[trg]: + r_plb[trg].l=phm[trg].r shifted ( plb_skp[drv_sty], 0); + nfr_max_x[@]:=max (nfr_max_x[@], xpart r_plb[trg].r); fi fi % @@ -2012,22 +2064,23 @@ vardef drv_rad_build[]= % phantom steps % if known tgt[@]: - save src_rad, tgt_rad; - numeric src_rad, tgt_rad; + save trg, src_rad, tgt_rad; + numeric trg, src_rad, tgt_rad; + trg:=tgt[@]; src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; - tgt_rad:=min_rad[tgt[@]]; - phm[@].rad=(src_rad+tgt_rad)/2; - phm[@].org=jdg[@].org; + tgt_rad:=min_rad[trg]; + phm[trg].rad=(src_rad+tgt_rad)/2; + phm[trg].org=jdg[@].org; % % phantom steps labels % - if known l_plb[@]: - l_plb[@].rad=phm[@].rad; - l_plb[@].org=phm[@].org; + if known l_plb[trg]: + l_plb[trg].rad=phm[trg].rad; + l_plb[trg].org=phm[trg].org; fi - if known r_plb[@]: - r_plb[@].rad=phm[@].rad; - r_plb[@].org=phm[@].org; + if known r_plb[trg]: + r_plb[trg].rad=phm[trg].rad; + r_plb[trg].org=phm[trg].org; fi fi % @@ -2201,43 +2254,44 @@ vardef drv_ngl_build[]= % phantom steps % if known tgt[@]: - save phm_pct, src_rad, tgt_rad; + save trg, src_rad, tgt_rad, phm_pct; + numeric trg, src_rad, tgt_rad; picture phm_pct; - numeric src_rad, tgt_rad; + trg:=tgt[@]; src_rad:=min_rad[@]+min_clr_scl*min_clr[drv_sty]/2; - tgt_rad:=min_rad[tgt[@]]; + tgt_rad:=min_rad[trg]; phm_pct:=((0, (src_rad-tgt_rad)/2)--(0, (tgt_rad-src_rad)/2)) drv_styled phm_sty[@]; - arc_init phm[@] ( + arc_init phm[trg] ( phm_pct - rotated (tnum*90+arc_angle (phm[@].rad, (width phm_pct)/2) tnum) - shifted ((dir 0) scaled phm[@].rad), - arc_angle (phm[@].rad, width phm_pct) tnum); - phm[@].cng=jdg[@].cng; + rotated (tnum*90+arc_angle (phm[trg].rad, (width phm_pct)/2) tnum) + shifted ((dir 0) scaled phm[trg].rad), + arc_angle (phm[trg].rad, width phm_pct) tnum); + phm[trg].cng=jdg[@].cng; nfr_lmost_ppt[@]:=lmost_ppt (nfr_lmost_ppt[@], - (phm[@].rad, phm[@].lng)) tnum; + (phm[trg].rad, phm[trg].lng)) tnum; nfr_rmost_ppt[@]:=rmost_ppt (nfr_rmost_ppt[@], - (phm[@].rad, phm[@].rng)) tnum; + (phm[trg].rad, phm[trg].rng)) tnum; % % phantom steps labels % - if known l_plb[@]: - arc_init l_plb[@]( - text_arc (l_plb[@], l_plb[@].rad) tnum, - arc_angle (l_plb[@].rad, width l_plb[@]) tnum); - l_plb[@].rng=phm[@].lng - -arc_angle (l_plb[@].rad, plb_skp[drv_sty]) tnum; + if known l_plb[trg]: + arc_init l_plb[trg]( + text_arc (l_plb[trg], l_plb[trg].rad) tnum, + arc_angle (l_plb[trg].rad, width l_plb[trg]) tnum); + l_plb[trg].rng=phm[trg].lng + -arc_angle (l_plb[trg].rad, plb_skp[drv_sty]) tnum; nfr_lmost_ppt[@]:= - lmost_ppt(nfr_lmost_ppt[@], (l_plb[@].rad, l_plb[@].lng)) tnum; + lmost_ppt(nfr_lmost_ppt[@], (l_plb[trg].rad, l_plb[trg].lng)) tnum; fi - if known r_plb[@]: - arc_init r_plb[@]( - text_arc (r_plb[@], r_plb[@].rad) tnum, - arc_angle (r_plb[@].rad, width r_plb[@]) tnum); - r_plb[@].lng=phm[@].rng - +arc_angle (r_plb[@].rad, plb_skp[drv_sty]) tnum; + if known r_plb[trg]: + arc_init r_plb[trg]( + text_arc (r_plb[trg], r_plb[trg].rad) tnum, + arc_angle (r_plb[trg].rad, width r_plb[trg]) tnum); + r_plb[trg].lng=phm[trg].rng + +arc_angle (r_plb[trg].rad, plb_skp[drv_sty]) tnum; nfr_rmost_ppt[@]:= - rmost_ppt(nfr_rmost_ppt[@], (r_plb[@].rad, r_plb[@].rng)) tnum; + rmost_ppt(nfr_rmost_ppt[@], (r_plb[trg].rad, r_plb[trg].rng)) tnum; fi fi % @@ -2582,7 +2636,7 @@ vardef drv_bbox[]= else: (ngl_part sub_lmost_ppt[@])-arc_angle (rad_part sub_lmost_ppt[@], - jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum fi; r_ngl:= if known r_dlm[@].lng: @@ -2591,7 +2645,7 @@ vardef drv_bbox[]= else: (ngl_part sub_rmost_ppt[@])+arc_angle (rad_part sub_rmost_ppt[@], - jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum + jdg_skp_scl*jdg_skp[jdg_sty[drv_sty]]) tnum fi; (circ_path(max_rad[@], r_ngl-l_ngl) tnum-- reverse circ_path(min_rad[@], r_ngl-l_ngl) tnum-- @@ -2829,7 +2883,7 @@ vardef drv_labels_position_aux (suffix typ_sfx, pos_sfx)= save typ_str, idt_str, pos_str; string typ_str, idt_str, pos_str; typ_str:=str typ_sfx; - if typ_str="ilb": + if typ_str="ilb": drv_left_ilb:=check_position_left (pos_sfx, drv_left_ilb); elseif typ_str="dlb": drv_left_dlb:=check_position_left (pos_sfx, drv_left_dlb); @@ -2894,6 +2948,25 @@ vardef drv_proof_mode suffix status_sfx= drv_proofmode_on:=check_mode_on (status_sfx, drv_proofmode_on); enddef; +vardef drv_labels_mode (suffix typ_sfx, status_sfx)= + save typ_str, idt_str, pos_str; + string typ_str, idt_str, pos_str; + typ_str:=str typ_sfx; + if typ_str="ilb": + drv_ilb_on:=check_mode_on (status_sfx, drv_ilb_on); + elseif typ_str="dlb": + drv_dlb_on:=check_mode_on (status_sfx, drv_dlb_on); + elseif typ_str="plb": + drv_plb_on:=check_mode_on (status_sfx, drv_plb_on); + else: + drv_errhelp "Valid identifiers are"& + " ilb (inference label),"& + " dlb (delimiter label) and"& + " plb (phantom steps label)."; + drv_errmessage (typ_str&" is not a valid label-type identifier"); + fi +enddef; + vardef drv_radial_mode suffix status_sfx= drv_radialmode_on:=check_mode_on (status_sfx, drv_radialmode_on); enddef; @@ -2932,6 +3005,9 @@ drv_right_delimiter "\rbrace"; drv_box_mode off; drv_fraction_mode on; drv_proof_mode off; +drv_labels_mode (ilb, on); +drv_labels_mode (dlb, on); +drv_labels_mode (plb, on); drv_radial_mode off; drv_scale (crv, 1); |