summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--metapost/context/base/metafun.mpii4
-rw-r--r--metapost/context/base/metafun.mpiv4
-rw-r--r--metapost/context/base/mp-char.mp1019
-rw-r--r--metapost/context/base/mp-flow.mpiv1020
-rw-r--r--metapost/context/base/mp-step.mpii (renamed from metapost/context/base/mp-step.mp)0
-rw-r--r--metapost/context/base/mp-step.mpiv375
-rw-r--r--tex/context/base/anch-pos.mkiv4
-rw-r--r--tex/context/base/cont-new.mkii2
-rw-r--r--tex/context/base/cont-new.mkiv2
-rw-r--r--tex/context/base/context-version.pdfbin4095 -> 4095 bytes
-rw-r--r--tex/context/base/context-version.pngbin106412 -> 106290 bytes
-rw-r--r--tex/context/base/context.mkii2
-rw-r--r--tex/context/base/context.mkiv2
-rw-r--r--tex/context/base/m-chart.lua (renamed from tex/context/base/m-flow.lua)2
-rw-r--r--tex/context/base/m-chart.mkii2
-rw-r--r--tex/context/base/m-chart.mkiv1328
-rw-r--r--tex/context/base/m-chart.mkvi (renamed from tex/context/base/m-flow.mkvi)6
-rw-r--r--tex/context/base/m-steps.lua227
-rw-r--r--tex/context/base/m-steps.mkii (renamed from tex/context/base/m-steps.tex)8
-rw-r--r--tex/context/base/m-steps.mkvi382
-rw-r--r--tex/context/base/status-files.pdfbin23931 -> 23918 bytes
-rw-r--r--tex/context/base/status-lua.pdfbin163361 -> 163358 bytes
-rw-r--r--tex/context/base/x-steps.mkiv99
-rw-r--r--tex/generic/context/luatex/luatex-fonts-merged.lua2
24 files changed, 1002 insertions, 3488 deletions
diff --git a/metapost/context/base/metafun.mpii b/metapost/context/base/metafun.mpii
index 705900a18..65d7b87f8 100644
--- a/metapost/context/base/metafun.mpii
+++ b/metapost/context/base/metafun.mpii
@@ -37,8 +37,8 @@ input mp-text.mp ;
input mp-txts.mp ;
input mp-shap.mp ;
input mp-butt.mp ;
-input mp-char.mp ;
-input mp-step.mp ;
+input mp-char.mpii ;
+input mp-step.mpii ;
input mp-grph.mp ;
input mp-figs.mp ;
input mp-grid.mp ;
diff --git a/metapost/context/base/metafun.mpiv b/metapost/context/base/metafun.mpiv
index 80cfcd423..b32e301a7 100644
--- a/metapost/context/base/metafun.mpiv
+++ b/metapost/context/base/metafun.mpiv
@@ -24,8 +24,8 @@ input mp-text.mp ;
input mp-txts.mp ;
input mp-butt.mp ;
input mp-shap.mp ;
-% mp-char.mp ; % there no need to always load this
-% mp-step.mp ; % there no need to always load this
+% mp-char.mpiv ; % there no need to always load this
+% mp-step.mpiv ; % there no need to always load this
input mp-grph.mp ;
input mp-figs.mp ;
input mp-mlib.mpiv ;
diff --git a/metapost/context/base/mp-char.mp b/metapost/context/base/mp-char.mp
deleted file mode 100644
index 3a7a1d939..000000000
--- a/metapost/context/base/mp-char.mp
+++ /dev/null
@@ -1,1019 +0,0 @@
-% to be cleaned up, namespace needed ! ! ! ! !
-
-%D \module
-%D [ file=mp-char.mp,
-%D version=1998.10.10,
-%D title=\CONTEXT\ \METAPOST\ graphics,
-%D subtitle=charts,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
-%C details.
-
-if unknown context_tool : input mp-tool ; fi ;
-if unknown context_shap : input mp-shap ; fi ;
-if known context_char : endinput ; fi ;
-
-boolean context_char ; context_char := true ;
-
-% kan naar elders
-
-current_position := 0 ;
-
-def save_text_position (expr p) = % beware: clip shift needed
- current_position := current_position + 1 ;
- savedata
- "\MPposition{" & decimal current_position & "}{"
- & decimal xpart p & "}{"
- & decimal ypart p & "}%" ;
-enddef ;
-
-%D settings
-
-grid_width := 60pt ; grid_height := 40pt ;
-shape_width := 45pt ; shape_height := 30pt ;
-
-chart_offset := 2pt ;
-color chart_background_color ; chart_background_color := white ;
-
-%D test mode
-
-boolean show_mid_points ; show_mid_points := false ;
-boolean show_con_points ; show_con_points := false ;
-boolean show_all_points ; show_all_points := false ;
-
-%D shapes
-
-color shape_line_color, shape_fill_color ;
-
-shape_line_width := 2pt ;
-shape_line_color := .5white ;
-shape_fill_color := .9white ;
-
-shape_node := 0 ;
-shape_action := 24 ;
-shape_procedure := 5 ;
-shape_product := 12 ;
-shape_decision := 14 ;
-shape_archive := 19 ;
-shape_loop := 35 ;
-shape_wait := 6 ;
-shape_subprocedure := 20 ; shape_sub_procedure := 20 ;
-shape_singledocument := 32 ; shape_single_document := 32 ;
-shape_multidocument := 33 ; shape_multi_document := 33 ;
-shape_right := 66 ;
-shape_left := 67 ;
-shape_up := 68 ;
-shape_down := 69 ;
-
-% vardef some_shape_path (expr type) == imported from mp-shap
-
-def show_shapes (expr n) =
-
- begin_chart(n,8,10) ;
- show_con_points := true ;
- for i=0 upto 7 :
- for j=0 upto 9 :
- new_shape(i+1,j+1,i*10+j);
- endfor ;
- endfor ;
- end_chart ;
-
-enddef ;
-
-%D connections
-
-def new_chart =
-
- color connection_line_color ;
-
- connection_line_width := shape_line_width ;
- connection_line_color := .8white ;
- connection_smooth_size := 5pt ;
- connection_arrow_size := 4pt ;
- connection_dash_size := 3pt ;
-
- max_x := 6 ;
- max_y := 4 ;
-
- numeric xypoint ; xypoint := 0 ;
-
- pair xypoints [] ;
-
- boolean xyfree [][] ;
- path xypath [][] ;
- numeric xysx [][] ;
- numeric xysy [][] ;
- color xyfill [][] ;
- color xydraw [][] ;
- numeric xyline [][] ;
- boolean xypeep [][] ;
- picture xypicture[][] ;
-
- numeric cpath ; cpath := 0 ;
- path cpaths [] ;
- numeric cline [] ;
- color ccolor [] ;
- boolean carrow [] ;
- boolean cdash [] ;
- boolean ccross [] ;
-
- boolean smooth ; smooth := true ;
- boolean peepshape ; peepshape := false ;
- boolean arrowtip ; arrowtip := true ;
- boolean dashline ; dashline := false ;
- boolean forcevalid ; forcevalid := false ;
- boolean touchshape ; touchshape := false ;
- boolean showcrossing ; showcrossing := false ;
-
- picture dash_pattern ;
-
- boolean reverse_y ; reverse_y := true ;
-
-enddef ;
-
-new_chart ;
-
-def y_pos (expr y) =
- if reverse_y : max_y + 1 - y else : y fi
-enddef ;
-
-def initialize_grid (expr maxx, maxy) =
- begingroup ;
- save i, j ;
- max_x := maxx ;
- max_y := maxy ;
- dsp_x := 0 ;
- dsp_y := 0 ;
- for x=1 upto max_x :
- for y=1 upto max_y :
- xyfree [x][y] := true ;
- xyfill [x][y] := shape_fill_color ;
- xydraw [x][y] := shape_line_color ;
- xyline [x][y] := shape_line_width ;
- endfor ;
- endfor ;
- endgroup ;
-enddef ;
-
-def scaled_to_grid =
- xscaled grid_width yscaled grid_height
-enddef ;
-
-def xy_offset (expr x, y) =
- (x+.5,y+.5)
-enddef ;
-
-def draw_shape (expr x, yy, p, sx, sy) =
- begingroup ;
- save y ;
- y := y_pos(yy) ;
- xypath [x][y] := (p xscaled sx yscaled sy) shifted xy_offset(x,y) ;
- xyfree [x][y] := false ;
- xysx [x][y] := sx ;
- xysy [x][y] := sy ;
- xyfill [x][y] := shape_fill_color ;
- xydraw [x][y] := shape_line_color ;
- xyline [x][y] := shape_line_width ;
- xypeep [x][y] := peepshape ;
- endgroup ;
-enddef ;
-
-vardef i_point (expr x, y, p, t) =
- begingroup ;
- save q, ok ;
- pair q ;
- boolean ok ;
- q := xypath[x][y] intersection_point ((p) shifted xy_offset(x,y)) ;
- ok := true ;
-% if xpart q < -.5 : ok := false ; q := (-.45,ypart q) fi ;
-% if xpart q > .5 : ok := false ; q := ( .45,ypart q) fi ;
-% if ypart q < -.5 : ok := false ; q := (xpart q,-.45) fi ;
-% if ypart q > .5 : ok := false ; q := (xpart q, .45) fi ;
- if not ok :
- message (t & " of shape (" & decimal x & "," & decimal y & ") limited") ;
- fi ;
- q
- endgroup
-enddef ;
-
-vardef trimmed (expr x, y, z, t) =
- if touchshape and t : xyline[x][y]/z else : epsilon fi
-enddef ;
-
-zfactor := 1/3 ;
-
-vardef xy_bottom (expr x, y, z, t) =
- i_point (x, y, ((0,0)--(0,-2)) shifted (zfactor*z*xysx[x][y],0), "bottom")
- shifted(0,-trimmed(x,y,grid_height,t))
-enddef ;
-
-vardef xy_top (expr x, y, z, t) =
- i_point (x, y, ((0,0)--(0,2)) shifted (zfactor*z*xysx[x][y],0), "top")
- shifted(0,trimmed(x,y,grid_height,t))
-enddef ;
-
-vardef xy_left (expr x, y, z, t) =
- i_point (x, y, ((0,0)--(-2,0)) shifted (0,zfactor*z*xysy[x][y]), "left")
- shifted(-trimmed(x,y,grid_width,t),0)
-enddef ;
-
-vardef xy_right (expr x, y, z, t) =
- i_point (x, y, ((0,0)--(2,0)) shifted (0,zfactor*z*xysy[x][y]), "right")
- shifted(trimmed(x,y,grid_width,t),0)
-enddef ;
-
-def flush_shapes =
- for x=1 upto max_x :
- for y=1 upto max_y :
- flush_shape (x, y) ;
- endfor ;
- endfor ;
-enddef ;
-
-def flush_pictures =
- for x=1 upto max_x :
- for y=1 upto max_y :
- flush_picture (x, y) ;
- endfor ;
- endfor ;
-enddef ;
-
-
-def draw_connection_point (expr x, y, z) =
- pickup pencircle scaled if (z=0): 2 fi xyline[x][y] ;
- drawdot xy_bottom(x,y,z,false) scaled_to_grid withcolor (1,0,0) ;
- drawdot xy_top (x,y,z,false) scaled_to_grid withcolor (0,1,0) ;
- drawdot xy_left (x,y,z,false) scaled_to_grid withcolor (0,0,1) ;
- drawdot xy_right (x,y,z,false) scaled_to_grid withcolor (1,1,0) ;
-enddef ;
-
-def flush_shape (expr x, yy) =
- begingroup ;
- save y ;
- y := y_pos(yy) ;
- if not xyfree[x][y] :
- pickup pencircle scaled xyline[x][y] ;
- if xypeep[x][y] :
- fill (xypath[x][y] peepholed (unitsquare shifted (x,y)))
- scaled_to_grid withpen pencircle scaled 0
- withcolor chart_background_color ;
- else :
- fill xypath[x][y] scaled_to_grid withcolor xyfill[x][y] ;
- fi ;
- draw xypath[x][y] scaled_to_grid withcolor xydraw[x][y] ;
- if show_con_points or show_all_points :
- draw_connection_point (x, y, 0) ;
- fi ;
- if show_all_points :
- for i=-1 upto 1 :
- draw_connection_point (x, y, i) ;
- endfor ;
- fi ;
- fi ;
- endgroup ;
-enddef ;
-
-vardef points_initialized (expr xfrom, yfrom, xto, yto, n) =
- if not xyfree[xfrom][yfrom] and not xyfree[xto][yto] :
- xypoint := n ; true
- else :
- xypoint := 0 ; false
- fi
-enddef ;
-
-def collapse_points = % this is now an mp-tool macro
- % remove redundant points
- n := 1 ;
- for i=2 upto xypoint:
- if not (xypoints[i]=xypoints[n]) :
- n := n + 1 ;
- xypoints[n] := xypoints[i]
- fi ;
- endfor ;
- xypoint := n ;
- % make straight lines
- if xypoints[2]=xypoints[xypoint-1] :
- xypoints[3] := xypoints[xypoint] ;
- xypoint := 3 ;
- fi ;
-enddef ;
-
-vardef smooth_connection (expr a,b) =
- sx := connection_smooth_size/grid_width ;
- sy := connection_smooth_size/grid_height ;
- if ypart a = ypart b :
- a shifted (if xpart a >= xpart b : - fi sx,0)
-% a shifted (sx*xpart unitvector(b-a),0)
- else :
- a shifted (0,if ypart a >= ypart b : - fi sy)
-% a shifted (0,sy*ypart unitvector(b-a))
- fi
-enddef ;
-
-vardef trim_points =
- begingroup
- save p, a, b, d, i ; path p ; pair d ;
- p := for i=1 upto xypoint-1 : xypoints[i]-- endfor xypoints[xypoint] ;
- if touchshape :
- a := shape_line_width/grid_width ;
- b := shape_line_width/grid_height ;
- else :
- a := epsilon ;
- b := epsilon ;
- fi ;
- d := direction infinity of p ;
- xypoints[xypoint] := xypoints[xypoint] shifted
- if xpart d < 0 : (+a,0) ;
- elseif xpart d > 0 : (-a,0) ;
- elseif ypart d < 0 : (0,+b) ;
- elseif ypart d > 0 : (0,-b) ;
- else : origin ;
- fi ;
- d := direction 0 of p ;
- xypoints[1] := xypoints[1] shifted
- if xpart d < 0 : (-a,0) ;
- elseif xpart d > 0 : (+a,0) ;
- elseif ypart d < 0 : (0,-b) ;
- elseif ypart d > 0 : (0,+b) ;
- else : origin ;
- fi ;
- endgroup
-enddef ;
-
-vardef trim_points = enddef ;
-
-vardef connection_path =
- if reverse_connection : reverse fi (xypoints[1]--
- for i=2 upto xypoint-1 :
- if smooth :
- smooth_connection(xypoints[i],xypoints[i-1]) ..
- controls xypoints[i] and xypoints[i] ..
- smooth_connection(xypoints[i],xypoints[i+1]) --
- else :
- xypoints[i]--
- fi
- endfor
- xypoints[xypoint])
-enddef ;
-
-% vardef connection_path =
-% sx := connection_smooth_size/grid_width ;
-% sy := connection_smooth_size/grid_height ;
-% if reverse_connection : reverse fi
-% (for i=1 upto xypoint-1 : xypoints[i] -- endfor xypoints[xypoint])
-% if smooth : cornered max(sx,sy) fi
-% enddef ;
-%
-% primarydef p cornered c =
-% if cycle p :
-% ((point 0 of p) shifted (c*(unitvector(point 1 of p - point 0 of p))) --
-% for i=1 upto length(p) :
-% (point i-1 of p) shifted (c*(unitvector(point i of p - point i-1 of p))) --
-% (point i of p) shifted (c*(unitvector(point i-1 of p - point i of p))) ..
-% controls point i of p ..
-% endfor cycle)
-% else :
-% ((point 0 of p) --
-% for i=1 upto length(p)-1 :
-% (point i-1 of p) shifted (c*(unitvector(point i of p - point i-1 of p))) --
-% (point i of p) shifted (c*(unitvector(point i-1 of p - point i of p))) ..
-% controls point i of p ..
-% endfor
-% (point length(p) of p))
-% fi
-% enddef ;
-
-def draw_connection =
- if xypoint>0 :
- collapse_points ;
- trim_points ;
- cpath := cpath + 1 ;
- cpaths[cpath] := connection_path scaled_to_grid ;
- cline[cpath] := connection_line_width ;
- ccolor[cpath] := connection_line_color ;
- carrow[cpath] := arrowtip ;
- cdash[cpath] := dashline ;
- ccross[cpath] := showcrossing ;
- else :
- message("no connection defined") ;
- fi ;
- reverse_connection := false ;
-enddef ;
-
-def flush_connections =
- pair ip ;
- boolean crossing ;
- ahlength := connection_arrow_size ;
- dash_pattern := dashpattern(on connection_dash_size off connection_dash_size ) ;
- for i=1 upto cpath :
- if ccross[i] :
- crossing := false ;
- for j=1 upto i :
- %if not ((point infinity of cpaths[i] = point infinity of cpaths[j]) or
- % (point 0 of cpaths[i] = point 0 of cpaths[j])) :
- if not (point infinity of cpaths[i] = point infinity of cpaths[j]) :
- ip := cpaths[i] intersection_point cpaths[j] ;
- if intersection_found : crossing := true fi ;
- fi ;
- endfor ;
- if crossing :
- pickup pencircle scaled 2cline[i] ;
- %draw cpaths[i] withcolor chart_background_color ;
- path cp ; cp := cpaths[i] ;
- cp := cp cutbefore point .05 length cp of cp ;
- cp := cp cutafter point .95 length cp of cp ;
- draw cp withcolor chart_background_color ;
- fi ;
- fi ;
- pickup pencircle scaled cline[i] ;
- if carrow[i] :
- if cdash[i] :
- drawarrow cpaths[i] withcolor ccolor[i] dashed dash_pattern ;
- else :
- drawarrow cpaths[i] withcolor ccolor[i] ;
- fi ;
- else :
- if cdash[i] :
- draw cpaths[i] withcolor ccolor[i] dashed dash_pattern ;
- else :
- draw cpaths[i] withcolor ccolor[i] ;
- fi ;
- fi ;
- draw_midpoint (i) ;
- endfor ;
-enddef ;
-
-def draw_midpoint (expr n) =
- begingroup
- save p ;
- pair p ;
- p := point .5*length(cpaths[n]) of cpaths[n];
- pickup pencircle scaled 2cline[n] ;
- save_text_position (p) ;
- if show_mid_points :
- drawdot p withcolor .7white ;
- fi ;
- endgroup ;
-enddef ;
-
-def flush_picture(expr x, y) =
- if known xypicture[x][y]:
- draw xypicture[x][y] shifted xy_offset((x+0.5)*grid_width,(max_y-y+1.5)*grid_height) ;
- fi ;
-enddef ;
-
-def chart_draw_picture(expr x, y, p) =
- xypicture[x][y] := p ;
-enddef ;
-
-boolean reverse_connection ; reverse_connection := false ;
-
-vardef up_on_grid (expr n) =
- (xpart xypoints[n],(ypart xypoints[n]+1) div 1)
-enddef ;
-
-vardef down_on_grid (expr n) =
- (xpart xypoints[n],(ypart xypoints[n]) div 1)
-enddef ;
-
-vardef left_on_grid (expr n) =
- ((xpart xypoints[n]) div 1, ypart xypoints[n])
-enddef ;
-
-vardef right_on_grid (expr n) =
- ((xpart xypoints[n]+1) div 1, ypart xypoints[n])
-enddef ;
-
-vardef x_on_grid (expr n, xfrom, xto, zfrom) =
- if (xfrom=xto) and not (zfrom=0) :
- if (zfrom=1) : right_on_grid(2) else : left_on_grid(2) fi
- elseif xpart xypoints[1] < xpart xypoints[6] :
- right_on_grid(n)
- else :
- left_on_grid(n)
- fi
-enddef ;
-
-vardef y_on_grid (expr n, yfrom, yto, zfrom) =
- if (yfrom=yto) and not (zfrom=0) :
- if (zfrom=1) : up_on_grid(2) else : down_on_grid(2) fi
- elseif ypart xypoints[1] < ypart xypoints[6] :
- up_on_grid(n)
- else :
- down_on_grid(n)
- fi
-enddef ;
-
-vardef xy_on_grid (expr n, m) =
- (xpart xypoints[n], ypart xypoints[m])
-enddef ;
-
-vardef down_to_grid (expr a,b) =
- (xpart xypoints[a],
- ypart xypoints[if ypart xypoints[a]<ypart xypoints[b]:a else:b fi])
-enddef ;
-
-vardef up_to_grid (expr a,b) =
- (xpart xypoints[a],
- ypart xypoints[if ypart xypoints[a]>ypart xypoints[b]:a else:b fi])
-enddef ;
-
-vardef left_to_grid (expr a,b) =
- (xpart xypoints[if xpart xypoints[a]<xpart xypoints[b]:a else:b fi],
- ypart xypoints[a])
-enddef ;
-
-vardef right_to_grid (expr a,b) =
- (xpart xypoints[if xpart xypoints[a]>xpart xypoints[b]:a else:b fi],
- ypart xypoints[a])
-enddef ;
-
-% vardef boundingboxfraction(expr p, f) =
-% ((boundingbox p) enlarged (-f*bbwidth(p),-f*bbheight(p)))
-% enddef ;
-
-vardef valid_connection (expr xfrom, yfrom, xto, yto) =
- begingroup ;
- save ok, vc, pp ;
- boolean ok ;
- % check for slanted lines
- ok := true ;
- for i=1 upto xypoint-1 :
- if not ((xpart xypoints[i]=xpart xypoints[i+1]) or
- (ypart xypoints[i]=ypart xypoints[i+1])) : ok := false ;
- fi ;
- endfor ;
- if not ok :
- %message("slanted");
- false
- elseif forcevalid :
- %message("force");
- true
- elseif (xfrom=xto) and (yfrom=yto) :
- %message("self");
- false
- else :
- % check for crossing shapes
- pair vc ;
- path pp ;
-
- pair xyfirst, xylast ;
- xyfirst := xypoints[1] ;
- xylast := xypoints[xypoint] ;
- trim_points ;
- pp := for i=1 upto xypoint-1 : xypoints[i]-- endfor xypoints[xypoint] ;
- xypoints[1] := xyfirst ;
- xypoints[xypoint] := xylast ;
-
- for i=1 upto max_x :
- for j=1 upto max_y : % was bug: xfrom,yto
- if not ( ( (i,j)=(xfrom,yfrom) ) or ( (i,j)=(xto,yto) ) ) :
- if not xyfree[i][j] :
- vc := pp intersection_point xypath[i][j] ;
- if intersection_found : ok := false fi ;
- fi ;
- fi ;
- endfor ;
- endfor ;
- %if not ok: message("crossing") ; fi ;
- ok
- fi
- endgroup
-enddef ;
-
-def connect_top_bottom (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := y_pos(yyfrom) ; yto := y_pos(yyto) ;
- if points_initialized(xfrom,yfrom,xto,yto,6) :
- xypoints[1] := xy_top(xfrom,yfrom,zfrom,true) ;
- xypoints[6] := xy_bottom(xto,yto,zto,true) ;
- xypoints[2] := up_on_grid(1) ;
- xypoints[5] := down_on_grid(6) ;
- xypoints[3] := up_to_grid(2,5) ;
- xypoints[4] := up_to_grid(2,5) ;
- if not valid_connection(xfrom,yfrom,xto,yto) :
- xypoints[3] := x_on_grid(2,xfrom,xto,zfrom) ;
- xypoints[4] := xy_on_grid(3,5) ;
- fi ;
- %%%% begin experiment
- xypoints[3] := xypoints[3] shifted (dsp_x,0) ;
- xypoints[4] := xypoints[4] shifted (dsp_x,0) ;
- if dsp_y>0 :
- xypoints[2] := xypoints[2] shifted (0,dsp_y) ;
- xypoints[3] := xypoints[3] shifted (0,dsp_y) ;
- elseif dsp_y<0 :
- xypoints[4] := xypoints[4] shifted (0,dsp_y) ;
- xypoints[5] := xypoints[5] shifted (0,dsp_y) ;
- fi
- %%%% end experiment
- draw_connection ;
- fi ;
-enddef ;
-
-def connect_left_right (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := y_pos(yyfrom) ; yto := y_pos(yyto) ;
- if points_initialized(xfrom,yfrom,xto,yto,6) :
- xypoints[1] := xy_left(xfrom,yfrom,zfrom,true) ;
- xypoints[6] := xy_right(xto,yto,zto,true) ;
- xypoints[2] := left_on_grid(1) ;
- xypoints[5] := right_on_grid(6) ;
- xypoints[3] := left_to_grid(2,5) ;
- xypoints[4] := left_to_grid(2,5) ;
- if not valid_connection(xfrom,yfrom,xto,yto) :
- xypoints[3] := y_on_grid(2,yfrom,yto,zfrom) ;
- xypoints[4] := xy_on_grid(5,3) ;
- fi ;
- draw_connection ;
- fi ;
-enddef ;
-
-def connect_left_top (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := y_pos(yyfrom) ; yto := y_pos(yyto) ;
- if points_initialized(xfrom,yfrom,xto,yto,5) :
- xypoints[1] := xy_left(xfrom,yfrom,zfrom,true) ;
- xypoints[5] := xy_top(xto,yto,zto,true) ;
- xypoints[2] := left_on_grid(1) ;
- xypoints[4] := up_on_grid(5) ;
- xypoints[3] := left_to_grid(2,5) ;
- if not valid_connection(xfrom,yfrom,xto,yto) :
- xypoints[3] := xy_on_grid(2,4) ;
- fi ;
- draw_connection ;
- fi ;
-enddef ;
-
-def connect_left_bottom (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := y_pos(yyfrom) ; yto := y_pos(yyto) ;
- if points_initialized(xfrom,yfrom,xto,yto,5) :
- xypoints[1] := xy_left(xfrom,yfrom,zfrom,true) ;
- xypoints[5] := xy_bottom(xto,yto,zto,true) ;
- xypoints[2] := left_on_grid(1) ;
- xypoints[4] := down_on_grid(5) ;
- xypoints[3] := left_to_grid(2,5) ;
- if not valid_connection(xfrom,yfrom,xto,yto) :
- xypoints[3] := xy_on_grid(2,4) ;
- fi ;
- draw_connection ;
- fi ;
-enddef ;
-
-def connect_right_top (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := y_pos(yyfrom) ; yto := y_pos(yyto) ;
- if points_initialized(xfrom,yfrom,xto,yto,5) :
- xypoints[1] := xy_right(xfrom,yfrom,zfrom,true) ;
- xypoints[5] := xy_top(xto,yto,zto,true) ;
- xypoints[2] := right_on_grid(1) ;
- xypoints[4] := up_on_grid(5) ;
- xypoints[3] := right_to_grid(2,5) ;
- if not valid_connection(xfrom,yfrom,xto,yto) :
- xypoints[3] := xy_on_grid(2,4) ;
- fi ;
- draw_connection ;
- fi ;
-enddef ;
-
-def connect_right_bottom (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := y_pos(yyfrom) ; yto := y_pos(yyto) ;
- if points_initialized(xfrom,yfrom,xto,yto,5) :
- xypoints[1] := xy_right(xfrom,yfrom,zfrom,true) ;
- xypoints[5] := xy_bottom(xto,yto,zto,true) ;
- xypoints[2] := right_on_grid(1) ;
- xypoints[4] := down_on_grid(5) ;
- xypoints[3] := right_to_grid(2,5) ;
- if not valid_connection(xfrom,yfrom,xto,yto) :
- xypoints[3] := xy_on_grid(2,4) ;
- fi ;
- %%%% begin experiment
- xypoints[2] := xypoints[2] shifted (dsp_x,0) ;
- xypoints[3] := xypoints[3] shifted (dsp_x,0) ;
- if dsp_y>0 :
- xypoints[3] := xypoints[3] shifted (0,-dsp_y) ;
- xypoints[4] := xypoints[4] shifted (0,-dsp_y) ;
- elseif dsp_y<0 :
- xypoints[3] := xypoints[3] shifted (0,dsp_y) ;
- xypoints[4] := xypoints[4] shifted (0,dsp_y) ;
- fi
- %%%% end experiment
- draw_connection ;
- fi ;
-enddef ;
-
-def connect_left_left (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := y_pos(yyfrom) ; yto := y_pos(yyto) ;
- if points_initialized(xfrom,yfrom,xto,yto,6) :
- xypoints[1] := xy_left(xfrom,yfrom,zfrom,true) ;
- xypoints[6] := xy_left(xto,yto,zto,true) ;
- xypoints[2] := left_on_grid(1) ;
- xypoints[5] := left_on_grid(6) ;
- xypoints[3] := left_to_grid(2,5) ;
- xypoints[4] := left_to_grid(5,2) ;
- if not valid_connection(xfrom,yfrom,xto,yto) :
- xypoints[3] := y_on_grid(2,yfrom,yto,zfrom) ;
- xypoints[4] := xy_on_grid(5,3) ;
- fi ;
- draw_connection ;
- fi ;
-enddef ;
-
-def connect_right_right (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := y_pos(yyfrom) ; yto := y_pos(yyto) ;
- if points_initialized(xfrom,yfrom,xto,yto,6) :
- xypoints[1] := xy_right(xfrom,yfrom,zfrom,true) ;
- xypoints[6] := xy_right(xto,yto,zto,true) ;
- xypoints[2] := right_on_grid(1) ;
- xypoints[5] := right_on_grid(6) ;
- xypoints[3] := right_to_grid(2,5) ;
- xypoints[4] := right_to_grid(5,2) ;
- if not valid_connection(xfrom,yfrom,xto,yto) :
- xypoints[3] := y_on_grid(2,yfrom,yto,zfrom) ;
- xypoints[4] := xy_on_grid(5,3) ;
- fi ;
- draw_connection ;
- fi ;
-enddef ;
-
-def connect_top_top (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := y_pos(yyfrom) ; yto := y_pos(yyto) ;
- if points_initialized(xfrom,yfrom,xto,yto,6) :
- xypoints[1] := xy_top(xfrom,yfrom,zfrom,true) ;
- xypoints[6] := xy_top(xto,yto,zto,true) ;
- xypoints[2] := up_on_grid(1) ;
- xypoints[5] := up_on_grid(6) ;
- xypoints[3] := up_to_grid(2,5) ;
- xypoints[4] := up_to_grid(5,2) ;
- if not valid_connection(xfrom,yfrom,xto,yto) :
- xypoints[3] := x_on_grid(2,xfrom,xto,zfrom) ;
- xypoints[4] := xy_on_grid(3,5) ;
- fi ;
- draw_connection ;
- fi ;
-enddef ;
-
-def connect_bottom_bottom (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := y_pos(yyfrom) ; yto := y_pos(yyto) ;
- if points_initialized(xfrom,yfrom,xto,yto,6) :
- xypoints[1] := xy_bottom(xfrom,yfrom,zfrom,true) ;
- xypoints[6] := xy_bottom(xto,yto,zto,true) ;
- xypoints[2] := down_on_grid(1) ;
- xypoints[5] := down_on_grid(6) ;
- xypoints[3] := down_to_grid(2,5) ;
- xypoints[4] := down_to_grid(5,2) ;
- if not valid_connection(xfrom,yfrom,xto,yto) :
- xypoints[3] := x_on_grid(2,xfrom,xto,zfrom) ;
- xypoints[4] := xy_on_grid(3,5) ;
- fi ;
- %%%% begin experiment
- xypoints[3] := xypoints[3] shifted (dsp_x,0) ;
- xypoints[4] := xypoints[4] shifted (dsp_x,0) ;
- if dsp_y<0 :
- xypoints[2] := xypoints[2] shifted (0,-dsp_y) ;
- xypoints[3] := xypoints[3] shifted (0,-dsp_y) ;
- elseif dsp_y>0 :
- xypoints[4] := xypoints[4] shifted (0,dsp_y) ;
- xypoints[5] := xypoints[5] shifted (0,dsp_y) ;
- fi
- %%%% end experiment
- draw_connection ;
- fi ;
-enddef ;
-
-def connect_bottom_top (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
- reverse_connection := true ;
- connect_top_bottom (xto,yto,zto) (xfrom,yfrom,zfrom) ;
-enddef ;
-
-def connect_right_left (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
- reverse_connection := true ;
- connect_left_right (xto,yto,zto) (xfrom,yfrom,zfrom) ;
-enddef ;
-
-def connect_top_left (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
- reverse_connection := true ;
- connect_left_top (xto,yto,zto) (xfrom,yfrom,zfrom) ;
-enddef ;
-
-def connect_bottom_left (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
- reverse_connection := true ;
- connect_left_bottom (xto,yto,zto) (xfrom,yfrom,zfrom) ;
-enddef ;
-
-def connect_top_right (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
- reverse_connection := true ;
- connect_right_top (xto,yto,zto) (xfrom,yfrom,zfrom) ;
-enddef ;
-
-def connect_bottom_right (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
- reverse_connection := true ;
- connect_right_bottom (xto,yto,zto) (xfrom,yfrom,zfrom) ;
-enddef ;
-
-def draw_test_shape (expr x, y) =
- draw_shape(x,y,fullcircle, .7, .7) ;
-enddef ;
-
-def draw_test_shapes =
- for i=1 upto max_x :
- for j=1 upto max_y :
- draw_test_shape(i,j) ;
- endfor ;
- endfor ;
-enddef;
-
-def draw_test_area =
- pickup pencircle scaled .5shape_line_width ;
- draw (unitsquare xscaled max_x yscaled max_y shifted (1,1))
- scaled_to_grid withcolor blue ;
-enddef ;
-
-def show_connection (expr n, m) =
-
- begin_chart(100+n,6,6) ;
-
- draw_test_area ;
-
- smooth := true ;
- arrowtip := true ;
- dashline := true ;
-
- draw_test_shape(2,2) ; draw_test_shape(4,5) ;
- draw_test_shape(3,3) ; draw_test_shape(5,1) ;
- draw_test_shape(2,5) ; draw_test_shape(1,3) ;
- draw_test_shape(6,2) ; draw_test_shape(4,6) ;
-
- if (m=1) :
- connect_top_bottom (2,2,0) (4,5,0) ;
- connect_top_bottom (3,3,0) (5,1,0) ;
- connect_top_bottom (2,5,0) (1,3,0) ;
- connect_top_bottom (6,2,0) (4,6,0) ;
- elseif (m=2) :
- connect_top_top (2,2,0) (4,5,0) ;
- connect_top_top (3,3,0) (5,1,0) ;
- connect_top_top (2,5,0) (1,3,0) ;
- connect_top_top (6,2,0) (4,6,0) ;
- elseif (m=3) :
- connect_bottom_bottom (2,2,0) (4,5,0) ;
- connect_bottom_bottom (3,3,0) (5,1,0) ;
- connect_bottom_bottom (2,5,0) (1,3,0) ;
- connect_bottom_bottom (6,2,0) (4,6,0) ;
- elseif (m=4) :
- connect_left_right (2,2,0) (4,5,0) ;
- connect_left_right (3,3,0) (5,1,0) ;
- connect_left_right (2,5,0) (1,3,0) ;
- connect_left_right (6,2,0) (4,6,0) ;
- elseif (m=5) :
- connect_left_left (2,2,0) (4,5,0) ;
- connect_left_left (3,3,0) (5,1,0) ;
- connect_left_left (2,5,0) (1,3,0) ;
- connect_left_left (6,2,0) (4,6,0) ;
- elseif (m=6) :
- connect_right_right (2,2,0) (4,5,0) ;
- connect_right_right (3,3,0) (5,1,0) ;
- connect_right_right (2,5,0) (1,3,0) ;
- connect_right_right (6,2,0) (4,6,0) ;
- elseif (m=7) :
- connect_left_top (2,2,0) (4,5,0) ;
- connect_left_top (3,3,0) (5,1,0) ;
- connect_left_top (2,5,0) (1,3,0) ;
- connect_left_top (6,2,0) (4,6,0) ;
- elseif (m=8) :
- connect_left_bottom (2,2,0) (4,5,0) ;
- connect_left_bottom (3,3,0) (5,1,0) ;
- connect_left_bottom (2,5,0) (1,3,0) ;
- connect_left_bottom (6,2,0) (4,6,0) ;
- elseif (m=9) :
- connect_right_top (2,2,0) (4,5,0) ;
- connect_right_top (3,3,0) (5,1,0) ;
- connect_right_top (2,5,0) (1,3,0) ;
- connect_right_top (6,2,0) (4,6,0) ;
- else :
- connect_right_bottom (2,2,0) (4,5,0) ;
- connect_right_bottom (3,3,0) (5,1,0) ;
- connect_right_bottom (2,5,0) (1,3,0) ;
- connect_right_bottom (6,2,0) (4,6,0) ;
- fi ;
-
- end_chart ;
-
-enddef ;
-
-def show_connections =
- for f=1 upto 10 :
- show_connection(f,f) ;
- endfor ;
-enddef ;
-
-%D charts
-
-def clip_chart (expr minx, miny, maxx, maxy) =
- cmin_x := minx ;
- cmax_x := maxx ;
- cmin_y := miny ;
- cmax_y := maxy ;
-enddef ;
-
-def begin_chart (expr n, maxx, maxy) =
- new_chart ;
- chart_figure := n ;
- chart_scale := 1 ;
- if chart_figure>0: beginfig(chart_figure) ; fi ;
- startsavingdata ;
- initialize_grid (maxx, maxy) ;
- bboxmargin := 0 ;
- cmin_x := 1 ;
- cmax_x := maxx ;
- cmin_y := 1 ;
- cmax_y := maxy ;
-enddef ;
-
-def end_chart =
- flush_shapes ;
- flush_connections ;
- flush_pictures ;
- cmin_x := cmin_x ;
- cmax_x := cmin_x+cmax_x ;
- cmin_y := cmin_y-1 ;
- cmax_y := cmin_y+cmax_y ;
- if reverse_y :
- cmin_y := y_pos(cmin_y) ;
- cmax_y := y_pos(cmax_y) ;
- fi ;
- path p ;
- p := (((cmin_x,cmin_y)--(cmax_x,cmin_y)--
- (cmax_x,cmax_y)--(cmin_x,cmax_y)--cycle))
- scaled_to_grid ;
- %draw p withcolor red ;
- p := p enlarged chart_offset ;
- clip currentpicture to p ;
- setbounds currentpicture to p ;
- savedata
- "\MPclippath{" &
- decimal xpart llcorner p & "}{" &
- decimal ypart llcorner p & "}{" &
- decimal xpart urcorner p & "}{" &
- decimal ypart urcorner p & "}%" ;
- savedata
- "\MPareapath{" &
- decimal (xpart llcorner p + 2chart_offset) & "}{" &
- decimal (ypart llcorner p + 2chart_offset) & "}{" &
- decimal (xpart urcorner p - 2chart_offset) & "}{" &
- decimal (ypart urcorner p - 2chart_offset) & "}%" ;
- currentpicture := currentpicture scaled chart_scale ;
- stopsavingdata ;
- if chart_figure>0: endfig ; fi ;
-enddef ;
-
-def new_shape (expr x, y, n) =
- if known n :
- if (x>0) and (x<=max_x) and (y>0) and (y<=max_y) :
- sx := shape_width/grid_width ;
- sy := shape_height/grid_height ;
- draw_shape(x,y,some_shape_path(n), sx, sy) ;
- else :
- message ("shape outside grid ignored") ;
- fi ;
- else
- message ("shape not known" ) ;
- fi ;
-enddef ;
-
-def begin_sub_chart =
- begingroup ;
- save shape_line_width , connection_line_width ;
- save shape_line_color, shape_fill_color, connection_line_color ;
- color shape_line_color, shape_fill_color, connection_line_color ;
- save smooth, arrowtip, dashline, peepshape ;
- boolean smooth, arrowtip, dashline, peepshape ;
-enddef ;
-
-def end_sub_chart =
- endgroup ;
-enddef ;
-
-%D done
-
-endinput ;
-
-%D testing
-
-show_shapes(100) ;
-
-end
-
-%D more testing
-
-show_connections ;
-
-begin_chart (1,4,5) ;
- %clip_chart(1,1,1,2) ;
- new_shape (1,1,31) ;
- new_shape (1,2,3) ;
- new_shape (4,4,5) ;
- connect_top_left (1,1,0) (4,4,0) ;
- connect_bottom_top (1,2,0) (4,4,0) ;
- connect_left_right (1,2,0) (1,1,0) ;
-end_chart ;
-
-end
diff --git a/metapost/context/base/mp-flow.mpiv b/metapost/context/base/mp-flow.mpiv
deleted file mode 100644
index 4cf4af0f9..000000000
--- a/metapost/context/base/mp-flow.mpiv
+++ /dev/null
@@ -1,1020 +0,0 @@
-%D \module
-%D [ file=mp-char.mp,
-%D version=2011.10.1, % 1998.10.10,
-%D title=\CONTEXT\ \METAPOST\ graphics,
-%D subtitle=charts,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
-%C details.
-
-%D This is ancient code .. but I see no need to rewrite it.
-
-if unknown context_tool : input mp-tool ; fi ;
-if unknown context_shap : input mp-shap ; fi ;
-if known context_flow : endinput ; fi ;
-
-boolean context_flow ; context_flow := true ;
-
-%D settings
-
-numeric flow_grid_width ; flow_grid_width := 60pt ;
-numeric flow_shape_width ; flow_shape_width := 45pt ;
-numeric flow_grid_height ; flow_grid_height := 40pt ;
-numeric flow_shape_height ; flow_shape_height := 30pt ;
-numeric flow_chart_offset ; flow_chart_offset := 2pt ;
-color flow_chart_background_color ; flow_chart_background_color := white ;
-boolean flow_show_mid_points ; flow_show_mid_points := false ;
-boolean flow_show_con_points ; flow_show_con_points := false ;
-boolean flow_show_all_points ; flow_show_all_points := false ;
-numeric flow_shape_line_width ; flow_shape_line_width := 2pt ;
-color flow_shape_line_color ; flow_shape_line_color := .5white ;
-color flow_shape_fill_color ; flow_shape_fill_color := .9white ;
-color flow_connection_line_color ; flow_connection_line_color := .2white ;
-
-numeric flow_connection_line_width ; flow_connection_line_width := flow_shape_line_width ;
-
-numeric flow_connection_smooth_size ; flow_connection_smooth_size := 5pt ;
-numeric flow_connection_arrow_size ; flow_connection_arrow_size := 4pt ;
-numeric flow_connection_dash_size ; flow_connection_dash_size := 3pt ;
-
-numeric flow_max_x ; flow_max_x := 6 ;
-numeric flow_max_y ; flow_max_y := 4 ;
-
-boolean flow_smooth ; flow_smooth := true ;
-boolean flow_peepshape ; flow_peepshape := false ;
-boolean flow_arrowtip ; flow_arrowtip := true ;
-boolean flow_dashline ; flow_dashline := false ;
-boolean flow_forcevalid ; flow_forcevalid := false ;
-boolean flow_touchshape ; flow_touchshape := false ;
-boolean flow_showcrossing ; flow_showcrossing := false ;
-boolean flow_reverse_y ; flow_reverse_y := true ;
-
-picture flow_dash_pattern ; flow_dash_pattern := nullpicture ;
-
-numeric flow_shape_node ; flow_shape_node := 0 ;
-numeric flow_shape_action ; flow_shape_action := 24 ;
-numeric flow_shape_procedure ; flow_shape_procedure := 5 ;
-numeric flow_shape_product ; flow_shape_product := 12 ;
-numeric flow_shape_decision ; flow_shape_decision := 14 ;
-numeric flow_shape_archive ; flow_shape_archive := 19 ;
-numeric flow_shape_loop ; flow_shape_loop := 35 ;
-numeric flow_shape_wait ; flow_shape_wait := 6 ;
-numeric flow_shape_subprocedure ; flow_shape_subprocedure := 20 ;
-numeric flow_shape_singledocument ; flow_shape_singledocument := 32 ;
-numeric flow_shape_multidocument ; flow_shape_multidocument := 33 ;
-numeric flow_shape_right ; flow_shape_right := 66 ;
-numeric flow_shape_left ; flow_shape_left := 67 ;
-numeric flow_shape_up ; flow_shape_up := 68 ;
-numeric flow_shape_down ; flow_shape_down := 69 ;
-
-% vardef some_shape_path (expr type) == imported from mp-shap
-
-def flow_show_shapes(expr n) =
- flow_begin_chart(n,8,10) ;
- flow_show_con_points := true ;
- for i=0 upto 7 :
- for j=0 upto 9 :
- flow_new_shape(i+1,j+1,i*10+j);
- endfor ;
- endfor ;
- flow_end_chart ;
-enddef ;
-
-%D connections
-
-def flow_new_chart =
-
- flow_grid_width := 60pt ;
- flow_shape_width := 45pt ;
- flow_grid_height := 40pt ;
- flow_shape_height := 30pt ;
- flow_chart_offset := 2pt ;
- flow_chart_background_color := white ;
- flow_show_mid_points := false ;
- flow_show_con_points := false ;
- flow_show_all_points := false ;
- flow_shape_line_width := 2pt ;
- flow_shape_line_color := .5white ;
- flow_shape_fill_color := .9white ;
- flow_connection_line_color := .2white ;
- flow_connection_line_width := flow_shape_line_width ;
- flow_connection_smooth_size := 5pt ;
- flow_connection_arrow_size := 4pt ;
- flow_connection_dash_size := 3pt ;
-
- flow_max_x := 6 ;
- flow_max_y := 4 ;
-
- flow_smooth := true ;
- flow_peepshape := false ;
- flow_arrowtip := true ;
- flow_dashline := false ;
- flow_forcevalid := false ;
- flow_touchshape := false ;
- flow_showcrossing := false ;
- flow_reverse_y := true ;
-
- flow_dash_pattern := nullpicture ;
-
- numeric flow_xypoint ; flow_xypoint := 0 ;
- numeric flow_cpath ; flow_cpath := 0 ;
-
- pair flow_xypoints [] ;
- boolean flow_xyfree [][] ;
- path flow_xypath [][] ;
- numeric flow_xysx [][] ;
- numeric flow_xysy [][] ;
- color flow_xyfill [][] ;
- color flow_xydraw [][] ;
- numeric flow_xyline [][] ;
- boolean flow_xypeep [][] ;
- picture flow_xytext [][] ;
- picture flow_xylabel_l[][] ;
- picture flow_xylabel_r[][] ;
- picture flow_xylabel_t[][] ;
- picture flow_xylabel_b[][] ;
- picture flow_xyexit_l [][] ;
- picture flow_xyexit_r [][] ;
- picture flow_xyexit_t [][] ;
- picture flow_xyexit_b [][] ;
- path flow_cpaths [] ;
- numeric flow_cline [] ;
- color flow_ccolor [] ;
- boolean flow_carrow [] ;
- boolean flow_cdash [] ;
- boolean flow_ccross [] ;
-
- picture flow_tpicture[][] ;
- picture flow_bpicture[][] ;
- picture flow_lpicture[][] ;
- picture flow_rpicture[][] ;
-
- predefined_shapes[61] := (fullcircle scaled (1.5*predefined_shapes_yradius) xscaled (flow_grid_height/flow_grid_width)) ;
- predefined_shapes[62] := (fullcircle scaled (2.0*predefined_shapes_yradius) xscaled (flow_grid_height/flow_grid_width)) ;
-
-enddef ;
-
-flow_new_chart ;
-
-def flow_y_pos(expr y) =
- if flow_reverse_y :
- flow_max_y + 1 - y
- else :
- y
- fi
-enddef ;
-
-def flow_initialize_grid(expr maxx, maxy) =
- flow_max_x := maxx ;
- flow_max_y := maxy ;
- flow_dsp_x := 0 ;
- flow_dsp_y := 0 ;
- for x=1 upto flow_max_x :
- for y=1 upto flow_max_y :
- flow_xyfree[x][y] := true ;
- flow_xyfill[x][y] := flow_shape_fill_color ;
- flow_xydraw[x][y] := flow_shape_line_color ;
- flow_xyline[x][y] := flow_shape_line_width ;
- endfor ;
- endfor ;
-enddef ;
-
-def flow_scaled_to_grid =
- xscaled flow_grid_width yscaled flow_grid_height
-enddef ;
-
-def flow_xy_offset(expr x, y) =
- (x+.5,y+.5)
-enddef ;
-
-def flow_draw_shape(expr x, yy, p, sx, sy) =
- begingroup ;
- save y ; numeric y ;
- y := flow_y_pos(yy) ;
- flow_xypath [x][y] := (p xscaled sx yscaled sy) shifted flow_xy_offset(x,y) ;
- flow_xyfree [x][y] := false ;
- flow_xysx [x][y] := sx ;
- flow_xysy [x][y] := sy ;
- flow_xyfill [x][y] := flow_shape_fill_color ;
- flow_xydraw [x][y] := flow_shape_line_color ;
- flow_xyline [x][y] := flow_shape_line_width ;
- flow_xypeep [x][y] := flow_peepshape ;
- endgroup ;
-enddef ;
-
-vardef flow_i_point (expr x, y, p, t) =
- begingroup ;
- save q, ok ; pair q ; boolean ok ;
- q := flow_xypath[x][y] intersection_point ((p) shifted flow_xy_offset(x,y)) ;
- ok := true ;
- if not ok :
- message (t & " of shape (" & decimal x & "," & decimal y & ") limited") ;
- fi ;
- q
- endgroup
-enddef ;
-
-vardef flow_trimmed (expr x, y, z, t) =
- if flow_touchshape and t :
- flow_xyline[x][y]/z
- else :
- epsilon
- fi
-enddef ;
-
-numeric flow_zfactor ; flow_zfactor := 1/3 ;
-
-vardef flow_xy_bottom (expr x, y, z, t) =
- flow_i_point(x, y, ((0,0)--(0,-2)) shifted (flow_zfactor*z*flow_xysx[x][y],0), "bottom")
- shifted(0,-flow_trimmed(x,y,flow_grid_height,t))
-enddef ;
-
-vardef flow_xy_top (expr x, y, z, t) =
- flow_i_point (x, y, ((0,0)--(0,2)) shifted (flow_zfactor*z*flow_xysx[x][y],0), "top")
- shifted(0,flow_trimmed(x,y,flow_grid_height,t))
-enddef ;
-
-vardef flow_xy_left (expr x, y, z, t) =
- flow_i_point (x, y, ((0,0)--(-2,0)) shifted (0,flow_zfactor*z*flow_xysy[x][y]), "left")
- shifted(-flow_trimmed(x,y,flow_grid_width,t),0)
-enddef ;
-
-vardef flow_xy_right (expr x, y, z, t) =
- flow_i_point (x, y, ((0,0)--(2,0)) shifted (0,flow_zfactor*z*flow_xysy[x][y]), "right")
- shifted(flow_trimmed(x,y,flow_grid_width,t),0)
-enddef ;
-
-def flow_flush_shapes =
- for x=1 upto flow_max_x :
- for y=1 upto flow_max_y :
- flow_flush_shape(x, y) ;
- endfor ;
- endfor ;
-enddef ;
-
-def flow_flush_pictures =
- for x=1 upto flow_max_x :
- for y=1 upto flow_max_y :
- flow_flush_picture(x, y) ;
- endfor ;
- endfor ;
-enddef ;
-
-def flow_draw_connection_point(expr x, y, z) =
- pickup pencircle scaled if (z=0): 2 fi flow_xyline[x][y] ;
- drawdot flow_xy_bottom(x,y,z,false) flow_scaled_to_grid withcolor (1,0,0) ;
- drawdot flow_xy_top (x,y,z,false) flow_scaled_to_grid withcolor (0,1,0) ;
- drawdot flow_xy_left (x,y,z,false) flow_scaled_to_grid withcolor (0,0,1) ;
- drawdot flow_xy_right (x,y,z,false) flow_scaled_to_grid withcolor (1,1,0) ;
-enddef ;
-
-def flow_flush_shape(expr x, yy) =
- begingroup ;
- save y ; numeric y ;
- y := flow_y_pos(yy) ;
- if not flow_xyfree[x][y] :
- pickup pencircle scaled flow_xyline[x][y] ;
- if flow_xypeep[x][y] :
- fill (flow_xypath[x][y] peepholed (unitsquare shifted (x,y)))
- flow_scaled_to_grid withpen pencircle scaled 0
- withcolor flow_chart_background_color ;
- else :
- fill flow_xypath[x][y] flow_scaled_to_grid withcolor flow_xyfill[x][y] ;
- fi ;
- draw flow_xypath[x][y] flow_scaled_to_grid withcolor flow_xydraw[x][y] ;
- if flow_show_con_points or flow_show_all_points :
- flow_draw_connection_point(x, y, 0) ;
- fi ;
- if flow_show_all_points :
- for i=-1 upto 1 :
- flow_draw_connection_point(x, y, i) ;
- endfor ;
- fi ;
- fi ;
- endgroup ;
-enddef ;
-
-vardef flow_points_initialized(expr xfrom, yfrom, xto, yto, n) =
- if not flow_xyfree[xfrom][yfrom] and not flow_xyfree[xto][yto] :
- flow_xypoint := n ; true
- else :
- flow_xypoint := 0 ; false
- fi
-enddef ;
-
-def flow_collapse_points = % this is now an mp-tool macro
- begingroup ;
- % remove redundant points
- save n ; numeric n ;
- n := 1 ;
- for i=2 upto flow_xypoint :
- if not (flow_xypoints[i] = flow_xypoints[n]) :
- n := n + 1 ;
- flow_xypoints[n] := flow_xypoints[i]
- fi ;
- endfor ;
- flow_xypoint := n ;
- % make straight lines
- if flow_xypoints[2] = flow_xypoints[flow_xypoint-1] :
- flow_xypoints[3] := flow_xypoints[flow_xypoint] ;
- flow_xypoint := 3 ;
- fi ;
- endgroup ;
-enddef ;
-
-vardef flow_smooth_connection(expr a,b) =
- if ypart a = ypart b :
- a shifted ( if xpart a >= xpart b : - fi (flow_connection_smooth_size/flow_grid_width ),0)
- else :
- a shifted (0,if ypart a >= ypart b : - fi (flow_connection_smooth_size/flow_grid_height) )
- fi
-enddef ;
-
-vardef flow_trim_points =
- begingroup
- save p, a, b, d, i ; numeric a, b ; path p ; pair d ;
- p := for i=1 upto flow_xypoint-1 : flow_xypoints[i]-- endfor flow_xypoints[flow_xypoint] ;
- if flow_touchshape :
- a := flow_shape_line_width/flow_grid_width ;
- b := flow_shape_line_width/flow_grid_height ;
- else :
- a := epsilon ;
- b := epsilon ;
- fi ;
- d := direction infinity of p ;
- flow_xypoints[flow_xypoint] := flow_xypoints[flow_xypoint] shifted
- if xpart d < 0 : (+a,0) ;
- elseif xpart d > 0 : (-a,0) ;
- elseif ypart d < 0 : (0,+b) ;
- elseif ypart d > 0 : (0,-b) ;
- else : origin ;
- fi ;
- d := direction 0 of p ;
- flow_xypoints[1] := flow_xypoints[1] shifted
- if xpart d < 0 : (-a,0) ;
- elseif xpart d > 0 : (+a,0) ;
- elseif ypart d < 0 : (0,-b) ;
- elseif ypart d > 0 : (0,+b) ;
- else : origin ;
- fi ;
- endgroup
-enddef ;
-
-vardef flow_trim_points = enddef ;
-
-vardef flow_connection_path =
- if flow_reverse_connection : reverse fi (flow_xypoints[1] --
- for i=2 upto flow_xypoint-1 :
- if flow_smooth :
- flow_smooth_connection(flow_xypoints[i],flow_xypoints[i-1]) ..
- controls flow_xypoints[i] and flow_xypoints[i] ..
- flow_smooth_connection(flow_xypoints[i],flow_xypoints[i+1]) --
- else :
- flow_xypoints[i] --
- fi
- endfor
- flow_xypoints[flow_xypoint])
-enddef ;
-
-def flow_draw_connection =
- if flow_xypoint > 0 :
- flow_collapse_points ;
- flow_trim_points ;
- flow_cpath := flow_cpath + 1 ;
- flow_cpaths[flow_cpath] := flow_connection_path flow_scaled_to_grid ;
- flow_cline[flow_cpath] := flow_connection_line_width ;
- flow_ccolor[flow_cpath] := flow_connection_line_color ;
- flow_carrow[flow_cpath] := flow_arrowtip ;
- flow_cdash[flow_cpath] := flow_dashline ;
- flow_ccross[flow_cpath] := flow_showcrossing ;
- else :
- message("no connection defined") ;
- fi ;
- flow_reverse_connection := false ;
-enddef ;
-
-def flow_flush_connections = % protect locals
- begingroup ;
- save ip, crossing, cp ; numeric ip ; boolean crossing ; path cp ;
- ahlength := flow_connection_arrow_size ;
- flow_dash_pattern := dashpattern(on flow_connection_dash_size off flow_connection_dash_size) ;
- for i=1 upto flow_cpath :
- if flow_ccross[i] :
- crossing := false ;
- for j=1 upto i :
- if not (point infinity of flow_cpaths[i] = point infinity of flow_cpaths[j]) :
- ip := flow_cpaths[i] intersection_point flow_cpaths[j] ;
- if intersection_found : crossing := true fi ;
- fi ;
- endfor ;
- if crossing :
- pickup pencircle scaled 2flow_cline[i] ;
- cp := flow_cpaths[i] ;
- cp := cp cutbefore point .05 length cp of cp ;
- cp := cp cutafter point .95 length cp of cp ;
- draw cp withcolor flow_chart_background_color ;
- fi ;
- fi ;
- pickup pencircle scaled flow_cline[i] ;
- if flow_carrow[i] :
- if flow_cdash[i] :
- drawarrow flow_cpaths[i] withcolor flow_ccolor[i] dashed flow_dash_pattern ;
- else :
- drawarrow flow_cpaths[i] withcolor flow_ccolor[i] ;
- fi ;
- else :
- if flow_cdash[i] :
- draw flow_cpaths[i] withcolor flow_ccolor[i] dashed flow_dash_pattern ;
- else :
- draw flow_cpaths[i] withcolor flow_ccolor[i] ;
- fi ;
- fi ;
- flow_draw_midpoint(i) ;
- endfor ;
- endgroup ;
-enddef ;
-
-def flow_draw_midpoint (expr n) =
- begingroup
- save p ; pair p ;
- p := point .5*length(flow_cpaths[n]) of flow_cpaths[n];
- pickup pencircle scaled 2flow_cline[n] ;
- if flow_show_mid_points :
- drawdot p withcolor .7white ;
- fi ;
- endgroup ;
-enddef ;
-
-def flow_flush_picture(expr x, yy) =
- begingroup ; save y ; numeric y ;
- y := flow_y_pos(yy) ;
- if known flow_xytext[x][y] :
- begingroup ;
- % flow_xypath[x][y]
- save p, offset ; path p ; pair offset ;
- offset := flow_xy_offset((x+0.5)*flow_grid_width,(flow_max_y-y+1.5)*flow_grid_height) ;
- offset := offset shifted (-flow_xyline[x][y]/4,-flow_xyline[x][y]/4) ; % terrible hack (some compensation)
- p := fullsquare
- xscaled flow_grid_width
- yscaled flow_grid_height
- shifted offset ;
- if known flow_xytext[x][y]:
- draw flow_xytext[x][y] shifted offset ;
- fi ;
- if known flow_xylabel_t[x][y] :
- label.urt(flow_xylabel_t[x][y],0.5[ulcorner p,urcorner p]) ;
- fi ;
- if known flow_xylabel_b[x][y] :
- label.lrt(flow_xylabel_b[x][y],0.5[llcorner p,lrcorner p]) ;
- fi ;
- if known flow_xylabel_l[x][y] :
- label.ulft(flow_xylabel_l[x][y],0.5[ulcorner p,llcorner p]) ;
- fi ;
- if known flow_xylabel_r[x][y] :
- label.urt (flow_xylabel_r[x][y],0.5[urcorner p,lrcorner p]) ;
- fi ;
- if known flow_xyexit_t[x][y] :
- label.top(flow_xyexit_t[x][y],0.5[ulcorner p,urcorner p] shifted (0, flow_grid_height/2)) ;
- fi ;
- if known flow_xyexit_b[x][y] :
- label.bot(flow_xyexit_b[x][y],0.5[llcorner p,lrcorner p] shifted (0,-flow_grid_height/2)) ;
- fi ;
- if known flow_xyexit_l[x][y] :
- label.lft(flow_xyexit_l[x][y],0.5[ulcorner p,llcorner p] shifted (-flow_grid_width/2,0)) ;
- fi ;
- if known flow_xyexit_r[x][y] :
- label.rt (flow_xyexit_r[x][y],0.5[urcorner p,lrcorner p] shifted ( flow_grid_width/2,0)) ;
- fi ;
- endgroup ;
- fi ;
- endgroup ;
-enddef ;
-
-def flow_chart_draw_text(expr x, y, p) =
- flow_xytext[x][y] := p ;
-enddef ;
-
-def flow_chart_draw_label_t(expr x, y, p) = flow_xylabel_t[x][y] := p ; enddef ;
-def flow_chart_draw_label_b(expr x, y, p) = flow_xylabel_b[x][y] := p ; enddef ;
-def flow_chart_draw_label_l(expr x, y, p) = flow_xylabel_l[x][y] := p ; enddef ;
-def flow_chart_draw_label_r(expr x, y, p) = flow_xylabel_r[x][y] := p ; enddef ;
-
-def flow_chart_draw_exit_t (expr x, y, p) = flow_xyexit_t [x][y] := p ; enddef ;
-def flow_chart_draw_exit_b (expr x, y, p) = flow_xyexit_b [x][y] := p ; enddef ;
-def flow_chart_draw_exit_l (expr x, y, p) = flow_xyexit_l [x][y] := p ; enddef ;
-def flow_chart_draw_exit_r (expr x, y, p) = flow_xyexit_r [x][y] := p ; enddef ;
-
-boolean flow_reverse_connection ; flow_reverse_connection := false ;
-
-vardef flow_up_on_grid (expr n) =
- (xpart flow_xypoints[n],(ypart flow_xypoints[n]+1) div 1)
-enddef ;
-
-vardef flow_down_on_grid (expr n) =
- (xpart flow_xypoints[n],(ypart flow_xypoints[n]) div 1)
-enddef ;
-
-vardef flow_left_on_grid (expr n) =
- ((xpart flow_xypoints[n]) div 1, ypart flow_xypoints[n])
-enddef ;
-
-vardef flow_right_on_grid (expr n) =
- ((xpart flow_xypoints[n]+1) div 1, ypart flow_xypoints[n])
-enddef ;
-
-vardef flow_x_on_grid (expr n, xfrom, xto, zfrom) =
- if (xfrom = xto) and not (zfrom = 0) :
- if (zfrom=1) : flow_right_on_grid(2) else : flow_left_on_grid(2) fi
- elseif xpart flow_xypoints[1] < xpart flow_xypoints[6] :
- flow_right_on_grid(n)
- else :
- flow_left_on_grid(n)
- fi
-enddef ;
-
-vardef flow_y_on_grid (expr n, yfrom, yto, zfrom) =
- if (yfrom = yto) and not (zfrom = 0) :
- if (zfrom = 1) : flow_up_on_grid(2) else : flow_down_on_grid(2) fi
- elseif ypart flow_xypoints[1] < ypart flow_xypoints[6] :
- flow_up_on_grid(n)
- else :
- flow_down_on_grid(n)
- fi
-enddef ;
-
-vardef flow_xy_on_grid (expr n, m) =
- (xpart flow_xypoints[n], ypart flow_xypoints[m])
-enddef ;
-
-vardef flow_down_to_grid (expr a,b) =
- (xpart flow_xypoints[a], ypart flow_xypoints[if ypart flow_xypoints[a]<ypart flow_xypoints[b] : a else : b fi])
-enddef ;
-
-vardef flow_up_to_grid (expr a,b) =
- (xpart flow_xypoints[a], ypart flow_xypoints[if ypart flow_xypoints[a]>ypart flow_xypoints[b] : a else : b fi])
-enddef ;
-
-vardef flow_left_to_grid (expr a,b) =
- (xpart flow_xypoints[if xpart flow_xypoints[a]<xpart flow_xypoints[b] : a else : b fi], ypart flow_xypoints[a])
-enddef ;
-
-vardef flow_right_to_grid (expr a,b) =
- (xpart flow_xypoints[if xpart flow_xypoints[a]>xpart flow_xypoints[b] : a else : b fi], ypart flow_xypoints[a])
-enddef ;
-
-vardef flow_valid_connection (expr xfrom, yfrom, xto, yto) =
- begingroup ;
- save ok, vc, pp ; boolean ok ; pair vc ; path pp ;
- save flow_xyfirst, flow_xylast ; pair flow_xyfirst, flow_xylast ;
- % check for slanted lines
- ok := true ;
- for i=1 upto flow_xypoint-1 :
- if not ((xpart flow_xypoints[i]=xpart flow_xypoints[i+1]) or (ypart flow_xypoints[i]=ypart flow_xypoints[i+1])) :
- ok := false ;
- fi ;
- endfor ;
- if not ok :
- % message("slanted");
- false
- elseif flow_forcevalid :
- % message("force");
- true
- elseif (xfrom=xto) and (yfrom=yto) :
- % message("self");
- false
- else :
- % check for crossing shapes
- flow_xyfirst := flow_xypoints[1] ;
- flow_xylast := flow_xypoints[flow_xypoint] ;
- flow_trim_points ;
- pp := for i=1 upto flow_xypoint-1 : flow_xypoints[i]-- endfor flow_xypoints[flow_xypoint] ;
- flow_xypoints[1] := flow_xyfirst ;
- flow_xypoints[flow_xypoint] := flow_xylast ;
- for i=1 upto flow_max_x :
- for j=1 upto flow_max_y : % was bug: xfrom,yto
- if not ( ( (i,j)=(xfrom,yfrom) ) or ( (i,j)=(xto,yto) ) ) :
- if not flow_xyfree[i][j] :
- vc := pp intersection_point flow_xypath[i][j] ;
- if intersection_found :
- ok := false
- fi ;
- fi ;
- fi ;
- endfor ;
- endfor ;
- % if not ok: message("crossing") ; fi ;
- ok
- fi
- endgroup
-enddef ;
-
-def flow_connect_top_bottom (expr xfrom, yyfrom, zfrom) (expr xto, yyto, zto) =
- yfrom := flow_y_pos(yyfrom) ;
- yto := flow_y_pos(yyto) ;
- if flow_points_initialized(xfrom,yfrom,xto,yto,6) :
- flow_xypoints[1] := flow_xy_top(xfrom,yfrom,zfrom,true) ;
- flow_xypoints[6] := flow_xy_bottom(xto,yto,zto,true) ;
- flow_xypoints[2] := flow_up_on_grid(1) ;
- flow_xypoints[5] := flow_down_on_grid(6) ;
- flow_xypoints[3] := flow_up_to_grid(2,5) ;
- flow_xypoints[4] := flow_up_to_grid(2,5) ;
- if not flow_valid_connection(xfrom,yfrom,xto,yto) :
- flow_xypoints[3] := flow_x_on_grid(2,xfrom,xto,zfrom) ;
- flow_xypoints[4] := flow_xy_on_grid(3,5) ;
- fi ;
- %%%% begin experiment
- flow_xypoints[3] := flow_xypoints[3] shifted (flow_dsp_x,0) ;
- flow_xypoints[4] := flow_xypoints[4] shifted (flow_dsp_x,0) ;
- if flow_dsp_y>0 :
- flow_xypoints[2] := flow_xypoints[2] shifted (0,flow_dsp_y) ;
- flow_xypoints[3] := flow_xypoints[3] shifted (0,flow_dsp_y) ;
- elseif flow_dsp_y<0 :
- flow_xypoints[4] := flow_xypoints[4] shifted (0,flow_dsp_y) ;
- flow_xypoints[5] := flow_xypoints[5] shifted (0,flow_dsp_y) ;
- fi
- %%%% end experiment
- flow_draw_connection ;
- fi ;
-enddef ;
-
-def flow_connect_left_right (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := flow_y_pos(yyfrom) ;
- yto := flow_y_pos(yyto) ;
- if flow_points_initialized(xfrom,yfrom,xto,yto,6) :
- flow_xypoints[1] := flow_xy_left(xfrom,yfrom,zfrom,true) ;
- flow_xypoints[6] := flow_xy_right(xto,yto,zto,true) ;
- flow_xypoints[2] := flow_left_on_grid(1) ;
- flow_xypoints[5] := flow_right_on_grid(6) ;
- flow_xypoints[3] := flow_left_to_grid(2,5) ;
- flow_xypoints[4] := flow_left_to_grid(2,5) ;
- if not flow_valid_connection(xfrom,yfrom,xto,yto) :
- flow_xypoints[3] := flow_y_on_grid(2,yfrom,yto,zfrom) ;
- flow_xypoints[4] := flow_xy_on_grid(5,3) ;
- fi ;
- flow_draw_connection ;
- fi ;
-enddef ;
-
-def flow_connect_left_top (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := flow_y_pos(yyfrom) ;
- yto := flow_y_pos(yyto) ;
- if flow_points_initialized(xfrom,yfrom,xto,yto,5) :
- flow_xypoints[1] := flow_xy_left(xfrom,yfrom,zfrom,true) ;
- flow_xypoints[5] := flow_xy_top(xto,yto,zto,true) ;
- flow_xypoints[2] := flow_left_on_grid(1) ;
- flow_xypoints[4] := flow_up_on_grid(5) ;
- flow_xypoints[3] := flow_left_to_grid(2,5) ;
- if not flow_valid_connection(xfrom,yfrom,xto,yto) :
- flow_xypoints[3] := flow_xy_on_grid(2,4) ;
- fi ;
- flow_draw_connection ;
- fi ;
-enddef ;
-
-def flow_connect_left_bottom (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := flow_y_pos(yyfrom) ;
- yto := flow_y_pos(yyto) ;
- if flow_points_initialized(xfrom,yfrom,xto,yto,5) :
- flow_xypoints[1] := flow_xy_left(xfrom,yfrom,zfrom,true) ;
- flow_xypoints[5] := flow_xy_bottom(xto,yto,zto,true) ;
- flow_xypoints[2] := flow_left_on_grid(1) ;
- flow_xypoints[4] := flow_down_on_grid(5) ;
- flow_xypoints[3] := flow_left_to_grid(2,5) ;
- if not flow_valid_connection(xfrom,yfrom,xto,yto) :
- flow_xypoints[3] := flow_xy_on_grid(2,4) ;
- fi ;
- flow_draw_connection ;
- fi ;
-enddef ;
-
-def flow_connect_right_top (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := flow_y_pos(yyfrom) ;
- yto := flow_y_pos(yyto) ;
- if flow_points_initialized(xfrom,yfrom,xto,yto,5) :
- flow_xypoints[1] := flow_xy_right(xfrom,yfrom,zfrom,true) ;
- flow_xypoints[5] := flow_xy_top(xto,yto,zto,true) ;
- flow_xypoints[2] := flow_right_on_grid(1) ;
- flow_xypoints[4] := flow_up_on_grid(5) ;
- flow_xypoints[3] := flow_right_to_grid(2,5) ;
- if not flow_valid_connection(xfrom,yfrom,xto,yto) :
- flow_xypoints[3] := flow_xy_on_grid(2,4) ;
- fi ;
- flow_draw_connection ;
- fi ;
-enddef ;
-
-def flow_connect_right_bottom (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := flow_y_pos(yyfrom) ;
- yto := flow_y_pos(yyto) ;
- if flow_points_initialized(xfrom,yfrom,xto,yto,5) :
- flow_xypoints[1] := flow_xy_right(xfrom,yfrom,zfrom,true) ;
- flow_xypoints[5] := flow_xy_bottom(xto,yto,zto,true) ;
- flow_xypoints[2] := flow_right_on_grid(1) ;
- flow_xypoints[4] := flow_down_on_grid(5) ;
- flow_xypoints[3] := flow_right_to_grid(2,5) ;
- if not flow_valid_connection(xfrom,yfrom,xto,yto) :
- flow_xypoints[3] := flow_xy_on_grid(2,4) ;
- fi ;
- %%%% begin experiment
- flow_xypoints[2] := flow_xypoints[2] shifted (flow_dsp_x,0) ;
- flow_xypoints[3] := flow_xypoints[3] shifted (flow_dsp_x,0) ;
- if flow_dsp_y>0 :
- flow_xypoints[3] := flow_xypoints[3] shifted (0,-flow_dsp_y) ;
- flow_xypoints[4] := flow_xypoints[4] shifted (0,-flow_dsp_y) ;
- elseif flow_dsp_y<0 :
- flow_xypoints[3] := flow_xypoints[3] shifted (0,flow_dsp_y) ;
- flow_xypoints[4] := flow_xypoints[4] shifted (0,flow_dsp_y) ;
- fi
- %%%% end experiment
- flow_draw_connection ;
- fi ;
-enddef ;
-
-def flow_connect_left_left (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := flow_y_pos(yyfrom) ;
- yto := flow_y_pos(yyto) ;
- if flow_points_initialized(xfrom,yfrom,xto,yto,6) :
- flow_xypoints[1] := flow_xy_left(xfrom,yfrom,zfrom,true) ;
- flow_xypoints[6] := flow_xy_left(xto,yto,zto,true) ;
- flow_xypoints[2] := flow_left_on_grid(1) ;
- flow_xypoints[5] := flow_left_on_grid(6) ;
- flow_xypoints[3] := flow_left_to_grid(2,5) ;
- flow_xypoints[4] := flow_left_to_grid(5,2) ;
- if not flow_valid_connection(xfrom,yfrom,xto,yto) :
- flow_xypoints[3] := flow_y_on_grid(2,yfrom,yto,zfrom) ;
- flow_xypoints[4] := flow_xy_on_grid(5,3) ;
- fi ;
- flow_draw_connection ;
- fi ;
-enddef ;
-
-def flow_connect_right_right (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := flow_y_pos(yyfrom) ;
- yto := flow_y_pos(yyto) ;
- if flow_points_initialized(xfrom,yfrom,xto,yto,6) :
- flow_xypoints[1] := flow_xy_right(xfrom,yfrom,zfrom,true) ;
- flow_xypoints[6] := flow_xy_right(xto,yto,zto,true) ;
- flow_xypoints[2] := flow_right_on_grid(1) ;
- flow_xypoints[5] := flow_right_on_grid(6) ;
- flow_xypoints[3] := flow_right_to_grid(2,5) ;
- flow_xypoints[4] := flow_right_to_grid(5,2) ;
- if not flow_valid_connection(xfrom,yfrom,xto,yto) :
- flow_xypoints[3] := flow_y_on_grid(2,yfrom,yto,zfrom) ;
- flow_xypoints[4] := flow_xy_on_grid(5,3) ;
- fi ;
- flow_draw_connection ;
- fi ;
-enddef ;
-
-def flow_connect_top_top (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := flow_y_pos(yyfrom) ;
- yto := flow_y_pos(yyto) ;
- if flow_points_initialized(xfrom,yfrom,xto,yto,6) :
- flow_xypoints[1] := flow_xy_top(xfrom,yfrom,zfrom,true) ;
- flow_xypoints[6] := flow_xy_top(xto,yto,zto,true) ;
- flow_xypoints[2] := flow_up_on_grid(1) ;
- flow_xypoints[5] := flow_up_on_grid(6) ;
- flow_xypoints[3] := flow_up_to_grid(2,5) ;
- flow_xypoints[4] := flow_up_to_grid(5,2) ;
- if not flow_valid_connection(xfrom,yfrom,xto,yto) :
- flow_xypoints[3] := flow_x_on_grid(2,xfrom,xto,zfrom) ;
- flow_xypoints[4] := flow_xy_on_grid(3,5) ;
- fi ;
- flow_draw_connection ;
- fi ;
-enddef ;
-
-def flow_connect_bottom_bottom (expr xfrom,yyfrom,zfrom) (expr xto,yyto,zto) =
- yfrom := flow_y_pos(yyfrom) ;
- yto := flow_y_pos(yyto) ;
- if flow_points_initialized(xfrom,yfrom,xto,yto,6) :
- flow_xypoints[1] := flow_xy_bottom(xfrom,yfrom,zfrom,true) ;
- flow_xypoints[6] := flow_xy_bottom(xto,yto,zto,true) ;
- flow_xypoints[2] := flow_down_on_grid(1) ;
- flow_xypoints[5] := flow_down_on_grid(6) ;
- flow_xypoints[3] := flow_down_to_grid(2,5) ;
- flow_xypoints[4] := flow_down_to_grid(5,2) ;
- if not flow_valid_connection(xfrom,yfrom,xto,yto) :
- flow_xypoints[3] := flow_x_on_grid(2,xfrom,xto,zfrom) ;
- flow_xypoints[4] := flow_xy_on_grid(3,5) ;
- fi ;
- %%%% begin experiment
- flow_xypoints[3] := flow_xypoints[3] shifted (flow_dsp_x,0) ;
- flow_xypoints[4] := flow_xypoints[4] shifted (flow_dsp_x,0) ;
- if flow_dsp_y<0 :
- flow_xypoints[2] := flow_xypoints[2] shifted (0,-flow_dsp_y) ;
- flow_xypoints[3] := flow_xypoints[3] shifted (0,-flow_dsp_y) ;
- elseif flow_dsp_y>0 :
- flow_xypoints[4] := flow_xypoints[4] shifted (0,flow_dsp_y) ;
- flow_xypoints[5] := flow_xypoints[5] shifted (0,flow_dsp_y) ;
- fi
- %%%% end experiment
- flow_draw_connection ;
- fi ;
-enddef ;
-
-def flow_connect_bottom_top (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
- flow_reverse_connection := true ;
- flow_connect_top_bottom (xto,yto,zto) (xfrom,yfrom,zfrom) ;
-enddef ;
-
-def flow_connect_right_left (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
- flow_reverse_connection := true ;
- flow_connect_left_right (xto,yto,zto) (xfrom,yfrom,zfrom) ;
-enddef ;
-
-def flow_connect_top_left (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
- flow_reverse_connection := true ;
- flow_connect_left_top(xto,yto,zto) (xfrom,yfrom,zfrom) ;
-enddef ;
-
-def flow_connect_bottom_left (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
- flow_reverse_connection := true ;
- flow_connect_left_bottom (xto,yto,zto) (xfrom,yfrom,zfrom) ;
-enddef ;
-
-def flow_connect_top_right (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
- flow_reverse_connection := true ;
- flow_connect_right_top (xto,yto,zto) (xfrom,yfrom,zfrom) ;
-enddef ;
-
-def flow_connect_bottom_right (expr xfrom,yfrom,zfrom) (expr xto,yto,zto) =
- flow_reverse_connection := true ;
- flow_connect_right_bottom (xto,yto,zto) (xfrom,yfrom,zfrom) ;
-enddef ;
-
-def flow_draw_test_shape(expr x, y) =
- flow_draw_shape(x,y,fullcircle, .7, .7) ;
-enddef ;
-
-def flow_draw_test_shapes =
- for i=1 upto flow_max_x :
- for j=1 upto flow_max_y :
- flow_draw_test_shape(i,j) ;
- endfor ;
- endfor ;
-enddef;
-
-def flow_draw_test_area =
- pickup pencircle scaled .5flow_shape_line_width ;
- draw (unitsquare xscaled flow_max_x yscaled flow_max_y shifted (1,1)) flow_scaled_to_grid withcolor blue ;
-enddef ;
-
-def flow_show_connection(expr n, m) =
-
- flow_begin_chart(100+n,6,6) ;
-
- flow_draw_test_area ;
-
- flow_smooth := true ;
- flow_arrowtip := true ;
- flow_dashline := true ;
-
- flow_draw_test_shape(2,2) ; flow_draw_test_shape(4,5) ;
- flow_draw_test_shape(3,3) ; flow_draw_test_shape(5,1) ;
- flow_draw_test_shape(2,5) ; flow_draw_test_shape(1,3) ;
- flow_draw_test_shape(6,2) ; flow_draw_test_shape(4,6) ;
-
- if (m=1) :
- flow_connect_top_bottom (2,2,0) (4,5,0) ;
- flow_connect_top_bottom (3,3,0) (5,1,0) ;
- flow_connect_top_bottom (2,5,0) (1,3,0) ;
- flow_connect_top_bottom (6,2,0) (4,6,0) ;
- elseif (m=2) :
- flow_connect_top_top (2,2,0) (4,5,0) ;
- flow_connect_top_top (3,3,0) (5,1,0) ;
- flow_connect_top_top (2,5,0) (1,3,0) ;
- flow_connect_top_top (6,2,0) (4,6,0) ;
- elseif (m=3) :
- flow_connect_bottom_bottom (2,2,0) (4,5,0) ;
- flow_connect_bottom_bottom (3,3,0) (5,1,0) ;
- flow_connect_bottom_bottom (2,5,0) (1,3,0) ;
- flow_connect_bottom_bottom (6,2,0) (4,6,0) ;
- elseif (m=4) :
- flow_connect_left_right (2,2,0) (4,5,0) ;
- flow_connect_left_right (3,3,0) (5,1,0) ;
- flow_connect_left_right (2,5,0) (1,3,0) ;
- flow_connect_left_right (6,2,0) (4,6,0) ;
- elseif (m=5) :
- flow_connect_left_left (2,2,0) (4,5,0) ;
- flow_connect_left_left (3,3,0) (5,1,0) ;
- flow_connect_left_left (2,5,0) (1,3,0) ;
- flow_connect_left_left (6,2,0) (4,6,0) ;
- elseif (m=6) :
- flow_connect_right_right (2,2,0) (4,5,0) ;
- flow_connect_right_right (3,3,0) (5,1,0) ;
- flow_connect_right_right (2,5,0) (1,3,0) ;
- flow_connect_right_right (6,2,0) (4,6,0) ;
- elseif (m=7) :
- flow_connect_left_top (2,2,0) (4,5,0) ;
- flow_connect_left_top (3,3,0) (5,1,0) ;
- flow_connect_left_top (2,5,0) (1,3,0) ;
- flow_connect_left_top (6,2,0) (4,6,0) ;
- elseif (m=8) :
- flow_connect_left_bottom (2,2,0) (4,5,0) ;
- flow_connect_left_bottom (3,3,0) (5,1,0) ;
- flow_connect_left_bottom (2,5,0) (1,3,0) ;
- flow_connect_left_bottom (6,2,0) (4,6,0) ;
- elseif (m=9) :
- flow_connect_right_top (2,2,0) (4,5,0) ;
- flow_connect_right_top (3,3,0) (5,1,0) ;
- flow_connect_right_top (2,5,0) (1,3,0) ;
- flow_connect_right_top (6,2,0) (4,6,0) ;
- else :
- flow_connect_right_bottom (2,2,0) (4,5,0) ;
- flow_connect_right_bottom (3,3,0) (5,1,0) ;
- flow_connect_right_bottom (2,5,0) (1,3,0) ;
- flow_connect_right_bottom (6,2,0) (4,6,0) ;
- fi ;
-
- flow_end_chart ;
-
-enddef ;
-
-def flow_show_connections =
- for f=1 upto 10 :
- flow_show_connection(f,f) ;
- endfor ;
-enddef ;
-
-%D charts
-
-def flow_clip_chart(expr minx, miny, maxx, maxy) =
- flow_cmin_x := minx ;
- flow_cmax_x := maxx ;
- flow_cmin_y := miny ;
- flow_cmax_y := maxy ;
-enddef ;
-
-def flow_begin_chart(expr n, maxx, maxy) =
- flow_new_chart ;
- flow_chart_figure := n ;
- flow_chart_scale := 1 ;
- if flow_chart_figure>0:
- beginfig(flow_chart_figure) ;
- fi ;
- flow_initialize_grid (maxx, maxy) ;
- bboxmargin := 0 ;
- flow_cmin_x := 1 ;
- flow_cmax_x := maxx ;
- flow_cmin_y := 1 ;
- flow_cmax_y := maxy ;
-enddef ;
-
-def flow_end_chart =
- begingroup ;
- save p ; path p ;
- flow_flush_shapes ;
- flow_flush_connections ;
- flow_flush_pictures ;
- flow_cmin_x := flow_cmin_x ;
- flow_cmax_x := flow_cmin_x+flow_cmax_x ;
- flow_cmin_y := flow_cmin_y-1 ;
- flow_cmax_y := flow_cmin_y+flow_cmax_y ;
- if flow_reverse_y :
- flow_cmin_y := flow_y_pos(flow_cmin_y) ;
- flow_cmax_y := flow_y_pos(flow_cmax_y) ;
- fi ;
- p := (((flow_cmin_x,flow_cmin_y)--(flow_cmax_x,flow_cmin_y)--
- (flow_cmax_x,flow_cmax_y)--(flow_cmin_x,flow_cmax_y)--cycle))
- flow_scaled_to_grid ;
- %draw p withcolor red ;
- p := p enlarged flow_chart_offset ;
- clip currentpicture to p ;
- setbounds currentpicture to p ;
- endgroup ;
- currentpicture := currentpicture scaled flow_chart_scale ;
- if flow_chart_figure>0:
- endfig ;
- fi ;
-enddef ;
-
-def flow_new_shape(expr x, y, n) =
- if known n :
- if (x>0) and (x<=flow_max_x) and (y>0) and (y<=flow_max_y) :
- flow_draw_shape(x,y,some_shape_path(n), flow_shape_width/flow_grid_width, flow_shape_height/flow_grid_height) ;
- else :
- message ("shape outside grid ignored") ;
- fi ;
- else :
- message ("shape not known" ) ;
- fi ;
-enddef ;
-
-def flow_begin_sub_chart =
- begingroup ;
- save flow_shape_line_width, flow_connection_line_width ;
- save flow_shape_line_color, flow_shape_fill_color, flow_connection_line_color ;
- color flow_shape_line_color, flow_shape_fill_color, flow_connection_line_color ;
- save flow_smooth, flow_arrowtip, flow_dashline, flow_peepshape ;
- boolean flow_smooth, flow_arrowtip, flow_dashline, flow_peepshape ;
-enddef ;
-
-def flow_end_sub_chart =
- endgroup ;
-enddef ;
-
diff --git a/metapost/context/base/mp-step.mp b/metapost/context/base/mp-step.mpii
index d602f7014..d602f7014 100644
--- a/metapost/context/base/mp-step.mp
+++ b/metapost/context/base/mp-step.mpii
diff --git a/metapost/context/base/mp-step.mpiv b/metapost/context/base/mp-step.mpiv
new file mode 100644
index 000000000..dbbc38231
--- /dev/null
+++ b/metapost/context/base/mp-step.mpiv
@@ -0,0 +1,375 @@
+%D \module
+%D [ file=mp-cell.mpiv, % mp-step.mp,
+%D version=2010.10.07, % 2001.05.22,
+%D title=\CONTEXT\ \METAPOST\ graphics,
+%D subtitle=steps,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See licen-en.pdf for
+%C details.
+
+if unknown context_tool : input mp-tool ; fi ;
+if known context_cell : endinput ; fi ;
+
+boolean context_cell ; context_cell := true ;
+
+def initialize_step_variables =
+ save
+ text_fill_color, text_line_color, text_line_width, text_offset,
+ cell_fill_color, cell_line_color, cell_line_width, cell_offset,
+ line_line_color, line_line_width, line_alternative,
+ line_distance, cell_distance_y, cell_distance_x,
+ nofcells, chart_vertical ;
+
+ color text_line_color ; text_line_color := red ;
+ color cell_line_color ; cell_line_color := blue ;
+ color line_line_color ; line_line_color := green ;
+
+ color text_fill_color ; text_fill_color := white ;
+ color cell_fill_color ; cell_fill_color := white ;
+
+ numeric text_line_width ; text_line_width := 2pt ;
+ numeric cell_line_width ; cell_line_width := 2pt ;
+ numeric line_line_width ; line_line_width := 2pt ;
+
+ numeric text_offset ; text_offset := 4pt ;
+ numeric cell_offset ; cell_offset := 4pt ;
+
+ numeric line_distance ; line_distance := 10pt ; % between line and text
+ numeric line_offset ; line_offset := 4pt ; % between center and start of line
+ numeric line_height ; line_height := 20pt ;
+
+ numeric cell_distance_y ; cell_distance_y := 20pt ;
+ numeric cell_distance_x ; cell_distance_x := 20pt ;
+
+ numeric text_distance_set ; text_distance_set := 4pt ;
+
+ boolean chart_vertical ; chart_vertical := false ;
+
+ numeric nofcells ; nofcells := 0 ;
+
+enddef ;
+
+def step_cells (expr t, b) =
+ nofcells := nofcells + 1 ;
+ cells_t[nofcells] := textext.d(t) ;
+ cells_b[nofcells] := textext.d(b) ;
+ texts_t[nofcells] := nullpicture ;
+ texts_m[nofcells] := nullpicture ;
+ texts_b[nofcells] := nullpicture ;
+enddef ;
+
+def step_texts (expr t, b) =
+ texts_t[nofcells] := textext.d(t) ;
+ texts_m[nofcells] := textext.d(m) ;
+ texts_b[nofcells] := textext.d(b) ;
+enddef ;
+
+def step_begin_cell =
+ nofcells := nofcells + 1 ;
+ cells_t[nofcells] := nullpicture ;
+ cells_b[nofcells] := nullpicture ;
+ texts_t[nofcells] := nullpicture ;
+ texts_m[nofcells] := nullpicture ;
+ texts_b[nofcells] := nullpicture ;
+enddef ;
+
+def step_end_cell =
+enddef ;
+
+def step_cell_top (expr t) = cells_t[nofcells] := textext.d(t) ; enddef ;
+def step_cell_bot (expr b) = cells_b[nofcells] := textext.d(b) ; enddef ;
+def step_text_top (expr t) = texts_t[nofcells] := textext.d(t) ; enddef ;
+def step_text_mid (expr m) = texts_m[nofcells] := textext.d(m) ; enddef ;
+def step_text_bot (expr b) = texts_b[nofcells] := textext.d(b) ; enddef ;
+
+def step_begin_chart =
+ begingroup ;
+ initialize_step_variables ;
+ save nofcells ; numeric nofcells ; nofcells := 0 ;
+ save cells_t, cells_m, cells_b ; picture cells_t[], cells_m[], cells_b[] ;
+ save texts_t, texts_m, texts_b ; picture texts_t[], texts_m[], texts_b[] ;
+enddef ;
+
+def step_end_chart =
+ % we could combine some loops but this is cleaner
+ save dx, delta ; numeric dx, delta ;
+ save p ; path p ;
+ save one_row_only ; boolean one_row_only ;
+ save cell_t, next_t, text_t ; picture cell_t, next_t, text_t ;
+ save cell_m, next_m, text_m ; picture cell_m, next_m, text_m ;
+ save cell_b, next_b, text_b ; picture cell_b, next_b, text_b ;
+ save height_t, width_t, max_height_t, max_width_t ; numeric height_t, width_t, max_height_t, max_width_t ;
+ save height_m, width_m, max_height_m, max_width_m ; numeric height_m, width_m, max_height_m, max_width_m ;
+ save height_b, width_b, max_height_b, max_width_b ; numeric height_b, width_b, max_height_b, max_width_b ;
+ % check rows
+ one_row_only := true ;
+ for i=1 upto nofcells :
+ if bbwidth(cells_b[i]) > 0 :
+ one_row_only := false ;
+ fi ;
+ endfor ;
+ % swap and rotate
+ if chart_vertical :
+ if one_row_only :
+ % deal with mid_texts
+ max_width_t := max_width_m := max_width_b := 0 ;
+ for i=1 upto nofcells :
+ width_t := bbwidth(texts_t[i]) ;
+ width_m := bbwidth(texts_m[i]) ;
+ width_b := bbwidth(texts_b[i]) ;
+ if width_t > max_width_t : max_width_t := width_t fi ;
+ if width_m > max_width_m : max_width_m := width_m fi ;
+ if width_b > max_width_b : max_width_b := width_b fi ;
+ endfor ;
+ if max_width_m > 0 :
+ for i=1 upto nofcells :
+ text_t := texts_t[i] ; width_t := bbwidth(text_t) ;
+ text_m := texts_m[i] ; width_m := bbwidth(text_m) ;
+ text_b := texts_b[i] ; width_b := bbwidth(text_b) ;
+ if width_t < max_width_t :
+ setbounds text_t to boundingbox text_t leftenlarged (max_width_t - width_t) ;
+ fi ;
+ if width_m < max_width_m :
+ setbounds text_m to boundingbox text_m leftenlarged ((max_width_m - width_m)/2) ;
+ setbounds text_m to boundingbox text_m rightenlarged ((max_width_m - width_m)/2) ;
+ fi ;
+ if width_b < max_width_b :
+ setbounds text_b to boundingbox text_b rightenlarged (max_width_b - width_b) ;
+ fi ;
+ text_t := text_t shifted (- xpart llcorner text_t, 0) ;
+ text_m := text_m shifted (- xpart llcorner text_m, 0) ;
+ text_b := text_b shifted (- xpart llcorner text_b, 0) ;
+ texts_t[i] := image (
+ draw text_t ;
+ draw text_m shifted (max_width_t + text_distance_set,0) ;
+ draw text_b shifted (max_width_t + max_width_m + 2*text_distance_set,0) ;
+ ) rotated 90 ;
+ texts_m[i] := texts_b[i] := nullpicture ;
+ cells_t[i] := cells_t[i] rotated 90 ;
+ endfor ;
+ else :
+ for i=1 upto nofcells :
+ cells_t[i] := cells_t[i] rotated 90 ;
+ texts_t[i] := texts_t[i] rotated 90 ;
+ texts_b[i] := texts_b[i] rotated 90 ;
+ endfor ;
+ fi ;
+ else :
+ for i=1 upto nofcells :
+ cell_t := cells_t[i] ;
+ cell_b := cells_b[i] ;
+ cells_t[i] := cell_b rotated 90 ;
+ cells_b[i] := cell_t rotated 90 ;
+ text_t := texts_t[i] ;
+ text_b := texts_b[i] ;
+ texts_t[i] := text_b rotated 90 ;
+ texts_b[i] := text_t rotated 90 ;
+ endfor ;
+ fi ;
+ fi ;
+ % align horizontal
+ for i=1 upto nofcells :
+ cell_t := cells_t[i] ;
+ cell_b := cells_b[i] ;
+ width_t := bbwidth(cell_t) ;
+ width_b := bbwidth(cell_b) ;
+ if (width_t = 0) and (width_b = 0) :
+ % skip
+ elseif (width_t > 0) and (width_t < width_b) :
+ delta := (width_b-width_t)/2 ;
+ setbounds cell_t to boundingbox cell_t leftenlarged delta rightenlarged delta ;
+ cells_t[i] := cell_t ;
+ elseif (width_b > 0) and (width_t > width_b) :
+ delta := (width_t-width_b)/2 ;
+ setbounds cell_b to boundingbox cell_b leftenlarged delta rightenlarged delta ;
+ cells_b[i] := cell_b ;
+ fi ;
+ endfor ;
+ % analyze vertical
+ max_height_t := 0 ;
+ max_height_b := 0 ;
+ for i=1 upto nofcells :
+ cell_t := cells_t[i] ;
+ cell_b := cells_b[i] ;
+ height_t := bbheight(cell_t) ;
+ height_b := bbheight(cell_b) ;
+ if height_t > 0 :
+ setbounds cell_t to boundingbox cell_t enlarged cell_offset ;
+ height_t := height_t + 2 * cell_offset ;
+ cells_t[i] := cell_t ;
+ fi ;
+ if height_b > 0 :
+ setbounds cell_b to boundingbox cell_b enlarged cell_offset ;
+ height_b := height_b + 2 * cell_offset ;
+ cells_b[i] := cell_b ;
+ fi ;
+ if height_t > max_height_t :
+ max_height_t := height_t ;
+ fi
+ if height_b > max_height_b :
+ max_height_b := height_b ;
+ fi ;
+ endfor ;
+ % align vertical
+ for i=1 upto nofcells :
+ cell_t := cells_t[i] ;
+ cell_b := cells_b[i] ;
+ height_t := bbheight(cell_t) ;
+ height_b := bbheight(cell_b) ;
+ if height_t > 0 :
+ delta := (max_height_t-height_t)/2 ;
+ setbounds cell_t to boundingbox cell_t topenlarged delta bottomenlarged delta ;
+ fi ;
+ if height_b > 0 :
+ delta := (max_height_b-height_b)/2 ;
+ setbounds cell_b to boundingbox cell_b topenlarged delta bottomenlarged delta ;
+ fi ;
+ cells_t[i] := cell_t ;
+ cells_b[i] := cell_b ;
+ endfor ;
+ % position
+ dx := 0 ;
+ for i=1 upto nofcells :
+ cell_t := cells_t[i] ;
+ cell_b := cells_b[i] ;
+ cell_t := cell_t shifted -llcorner cell_t ;
+ cell_b := cell_b shifted -llcorner cell_b ;
+ cell_t := cell_t shifted (dx, 0) ;
+ cell_b := cell_b shifted (dx,-cell_distance_y-max_height_b) ;
+ cells_t[i] := cell_t ;
+ cells_b[i] := cell_b ;
+ width_t := bbwidth(cell_t) ;
+ width_b := bbwidth(cell_b) ;
+ if width_t > 0 :
+ dx := dx + cell_distance_x + width_t ;
+ elseif width_b > 0 :
+ dx := dx + cell_distance_x + width_b ;
+ fi ;
+ endfor ;
+ % flush
+ for i=1 upto nofcells :
+ cell_t := cells_t[i] ;
+ cell_b := cells_b[i] ;
+ width_t := bbwidth(cell_t) ;
+ width_b := bbwidth(cell_b) ;
+ if width_t > 0 :
+ fill boundingbox cell_t withcolor cell_fill_color ;
+ draw boundingbox cell_t withpen pencircle scaled cell_line_width withcolor cell_line_color ;
+ draw cell_t ;
+ fi ;
+ if width_b > 0 :
+ fill boundingbox cell_b withcolor cell_fill_color ;
+ draw boundingbox cell_b withpen pencircle scaled cell_line_width withcolor cell_line_color ;
+ draw cell_b ;
+ fi ;
+ endfor ;
+ %
+ def midtopboundary expr p = 0.5[ulcorner boundingbox p, urcorner boundingbox p] enddef ;
+ def midbottomboundary expr p = 0.5[llcorner boundingbox p, lrcorner boundingbox p] enddef ;
+ % draw top and bottom text boxes
+ for i=1 upto nofcells-1 :
+ text_t := texts_t[i] ;
+ text_b := texts_b[i] ;
+ if bbwidth(text_t) > 0 :
+ setbounds text_t to boundingbox text_t enlarged text_offset ;
+ texts_t[i] := text_t ;
+ fi ;
+ if bbwidth(text_b) > 0 :
+ setbounds text_b to boundingbox text_b enlarged text_offset ;
+ texts_b[i] := text_b ;
+ fi ;
+ endfor ;
+ % arrows
+ for i=1 upto nofcells-1 :
+ cell_t := cells_t[i] ;
+ cell_b := cells_b[i] ;
+ next_t := cells_t[i+1] ;
+ next_b := cells_b[i+1] ;
+ pair t_a, t_b, t_c, b_a, b_b, b_c ;
+ t_a := midtopboundary cell_t ;
+ t_b := midtopboundary next_t ;
+ t_c := (xpart 0.5[t_a,t_b], ypart t_a+line_height+line_distance) ;
+ if one_row_only :
+ b_a := midbottomboundary cell_t ;
+ b_b := midbottomboundary next_t ;
+ else :
+ b_a := midbottomboundary cell_b ;
+ b_b := midbottomboundary next_b ;
+ fi ;
+ b_c := (xpart 0.5[b_a,b_b], ypart b_a-line_height-line_distance) ;
+ texts_t[i] := thelabel.top(texts_t[i],t_c) ;
+ texts_b[i] := thelabel.bot(texts_b[i],b_c) ;
+ endfor ;
+ %
+ for i=1 upto nofcells-1 : % todo arrows when empty text
+ cell_t := cells_t[i] ;
+ cell_b := cells_b[i] ;
+ next_t := cells_t[i+1] ;
+ next_b := cells_b[i+1] ;
+ text_t := texts_t[i] ;
+ text_b := texts_b[i] ;
+ if bbwidth(text_t) > 0 :
+ if bbwidth(cell_t) > 0 :
+ drawarrow midtopboundary cell_t
+ shifted (if i > 1 : line_offset else : 0 fi, cell_line_width) {up} ..
+ midbottomboundary text_t shifted (0,-line_distance) ..
+ {down} midtopboundary next_t shifted(if i < nofcells - 1 : -line_offset else : 0 fi,cell_line_width)
+ withpen pencircle scaled line_line_width
+ withcolor line_line_color ;
+ else :
+ fi ;
+ fi ;
+ if bbwidth(text_b) > 0 :
+ if one_row_only :
+ cell_b := cell_t ;
+ next_b := next_t ;
+ fi ;
+ if bbwidth(cell_b) > 0 :
+ drawarrow midbottomboundary cell_b
+ shifted (if i > 1 : line_offset else : 0 fi, -cell_line_width) {down} ..
+ midtopboundary text_b shifted (0, line_distance) ..
+ {up} midbottomboundary next_b shifted (if i < nofcells - 1 : -line_offset else : 0 fi,-cell_line_width)
+ withpen pencircle scaled line_line_width
+ withcolor line_line_color ;
+ else :
+ fi ;
+ fi ;
+ endfor ;
+ % draw top and bottom text boxes
+ for i=1 upto nofcells-1 :
+ text_t := texts_t[i] ;
+ text_b := texts_b[i] ;
+ if bbwidth(text_t) > 0 :
+ fill boundingbox text_t withcolor text_fill_color ;
+ draw boundingbox text_t withpen pencircle scaled text_line_width withcolor text_line_color ;
+ draw text_t ;
+ fi ;
+ if bbwidth(text_b) > 0 :
+ fill boundingbox text_b withcolor text_fill_color ;
+ draw boundingbox text_b withpen pencircle scaled text_line_width withcolor text_line_color ;
+ draw text_b ;
+ fi ;
+ endfor ;
+ if chart_vertical :
+ % rotate back
+ currentpicture := currentpicture rotated -90 ;
+ fi ;
+ endgroup ;
+enddef ;
+
+% start_begin_step ;
+% step_cells ("\strut test 0", "\strut test 0") ;
+% step_cells ("\strut test 1", "\vbox{\hsize3cm \strut oeps 1\crlf oeps 1}") ;
+% step_texts ("\strut 1", "\strut 1") ;
+% step_cells ("\strut test 2", "\strut oeps 2 oeps 2") ;
+% step_cells ("\strut test X", "\strut test X") ;
+% step_texts ("\strut 2", "\strut 2") ;
+% step_cells ("\strut test 3", "\strut oeps 3 oeps 3") ;
+% step_texts ("\strut 3", "\strut 3") ;
+% step_cells ("\strut test 4", "\strut oeps 4 oeps 4") ;
+% step_texts ("\strut 4", "\strut 4") ;
+% stop_end_chart ;
diff --git a/tex/context/base/anch-pos.mkiv b/tex/context/base/anch-pos.mkiv
index bf7575ee3..d7a4b4d07 100644
--- a/tex/context/base/anch-pos.mkiv
+++ b/tex/context/base/anch-pos.mkiv
@@ -149,10 +149,6 @@
\def\POSprefix{POS::}
-\let\setpospx \gobblefourarguments % suppress errors with mkii tuo file
-\let\setpospxywhd \gobblesevenarguments % suppress errors with mkii tuo file
-\let\setpospxyplus\gobbleeightarguments % suppress errors with mkii tuo file
-
%D This is real tricky! The page anchor is applied to the
%D page box and therefore flushed first. So, when present, it
%D is applied to all positions except itself.
diff --git a/tex/context/base/cont-new.mkii b/tex/context/base/cont-new.mkii
index 8e57d876f..7d7f950fa 100644
--- a/tex/context/base/cont-new.mkii
+++ b/tex/context/base/cont-new.mkii
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.10.12 16:42}
+\newcontextversion{2011.10.12 19:30}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/cont-new.mkiv b/tex/context/base/cont-new.mkiv
index ad5702458..ae1b3d2bd 100644
--- a/tex/context/base/cont-new.mkiv
+++ b/tex/context/base/cont-new.mkiv
@@ -11,7 +11,7 @@
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
-\newcontextversion{2011.10.12 16:42}
+\newcontextversion{2011.10.12 19:30}
%D This file is loaded at runtime, thereby providing an
%D excellent place for hacks, patches, extensions and new
diff --git a/tex/context/base/context-version.pdf b/tex/context/base/context-version.pdf
index 0bc4592ce..ff55f5454 100644
--- a/tex/context/base/context-version.pdf
+++ b/tex/context/base/context-version.pdf
Binary files differ
diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png
index 064aade26..44759631d 100644
--- a/tex/context/base/context-version.png
+++ b/tex/context/base/context-version.png
Binary files differ
diff --git a/tex/context/base/context.mkii b/tex/context/base/context.mkii
index ceb106492..e5991b974 100644
--- a/tex/context/base/context.mkii
+++ b/tex/context/base/context.mkii
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.10.12 16:42}
+\edef\contextversion{2011.10.12 19:30}
%D For those who want to use this:
diff --git a/tex/context/base/context.mkiv b/tex/context/base/context.mkiv
index 5a21958fe..a451b056b 100644
--- a/tex/context/base/context.mkiv
+++ b/tex/context/base/context.mkiv
@@ -20,7 +20,7 @@
%D your styles an modules.
\edef\contextformat {\jobname}
-\edef\contextversion{2011.10.12 16:42}
+\edef\contextversion{2011.10.12 19:30}
%D For those who want to use this:
diff --git a/tex/context/base/m-flow.lua b/tex/context/base/m-chart.lua
index 62d31c197..acb41399e 100644
--- a/tex/context/base/m-flow.lua
+++ b/tex/context/base/m-chart.lua
@@ -517,7 +517,7 @@ local function makechart(chart)
end
--
context.startMPcode()
- context("if unknown context_flow : input mp-flow.mpiv ; fi ;")
+ context("if unknown context_flow : input mp-char.mpiv ; fi ;")
context("flow_begin_chart(0,%s,%s);",chart.nx,chart.ny)
--
if settings.chart.option == variables.test or settings.chart.dot == variables.yes then
diff --git a/tex/context/base/m-chart.mkii b/tex/context/base/m-chart.mkii
index 9b44a2ce1..13403966b 100644
--- a/tex/context/base/m-chart.mkii
+++ b/tex/context/base/m-chart.mkii
@@ -478,7 +478,7 @@
\resetMPdrawing
\doglobal\newcounter\FLOWcomment
\startMPdrawing
- if unknown context_char : input mp-char.mp ; fi ;
+ if unknown context_char : input mp-char.mpii ; fi ;
grid_width := \FLOWgridwidth ;
grid_height := \FLOWgridheight ;
shape_width := \FLOWshapewidth ;
diff --git a/tex/context/base/m-chart.mkiv b/tex/context/base/m-chart.mkiv
deleted file mode 100644
index 165cb1720..000000000
--- a/tex/context/base/m-chart.mkiv
+++ /dev/null
@@ -1,1328 +0,0 @@
-%D \module
-%D [ file=m-chart,
-%D version=1998.10.10,
-%D title=\CONTEXT\ Modules,
-%D subtitle=Flow Charts,
-%D author={Hans Hagen \& Ton Otten},
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D This module will be reimplemented as it can be done much more
-%D simple now in mkiv,.
-
-% todo: \localpushmacro/\localpopmacro (dohandleflowchart etc)
-% todo: make mkiv variant
-% todo: use dimexpr/numspr
-
-% will be redone with layers and dimexpr or even better, by just using
-% textext .. a nice example of old code
-
-%D This is an experimental module. Pieces of code will be moved
-%D to other modules. More features are possible but will be
-%D interfaces later.
-%D
-%D When finished this module will be documented. The main macro
-%D is still a rather big one and there is some redundant and
-%D slow code that needs a clean up.
-
-% arrow, dash
-% crossing
-% \goto -> \normalgoto
-% class -> class:name (ref prefix)
-% c, automatisch geen overlap zoeken
-% eind eerder chart connecties
-% relateren aan korps
-% check op bestaan naam, bestaan shape
-% auto als extern figuur
-% subchart
-% pijlen
-% focus
-% ook nog \MPmessage
-% areapath -> krappe vlak
-% clippath -> gehele vlak
-%
-% offset : clip offset
-% breedte : breedte cel
-% hoogte : hoogte cel
-% dx : halve afstand in breedte (grid breedte = breedte + 2dx)
-% dy : halve afstand in hoogte (grid hoogte = hoogte + 2dy)
-% x : x offset (clipping)
-% y : y offset (clipping)
-% nx : minimaal aantal cellen horizontaal
-% ny : minimaal aantal cellen vertikaal
-%
-% shape none en geen equivalent maken
-%
-% kaderkleur achtergrondkleur
-% lijnkleur lijndikte
-% focus focuskaderkleur focusachtergrondkleur
-% richting
-%
-% focus koppelen aan kleur
-
-\unprotect
-
-\definesorting [flowchart] [flowcharts] [\v!none] % no access
-\setupsorting [flowchart] [\c!state=\v!stop] % off by default
-
-\def\@FLOW@{@FLOW@}
-\def\@FLOC@{@FLOC@}
-\def\@FLOX@{@FLOX@}
-
-\def\@@FLOW{@@FLOW}
-\def\@@FLOL{@@FLOL}
-\def\@@FLOS{@@FLOS}
-\def\@@FLOF{@@FLOF}
-\def\@@FLOT{@@FLOT}
-\def\@@FLOX{@@FLOX}
-
-\def\@@MPx {@@MPx}
-\def\@@MPy {@@MPy}
-
-\def\FLOWbufferprefix{flw-}
-
-\def\processFLOWbuffer#1{\getbuffer[\FLOWbufferprefix#1]}
-\def\typeFLOWbuffer #1{\typebuffer[\FLOWbufferprefix#1]}
-
-\def\setFLOWname#1#2% funny hack that makes sure that we get
- {\bgroup % names that are acceptable for METAPOST
- \lccode`0=`a\lccode`1=`b\lccode`2=`c\lccode`3=`d\lccode`4=`e%
- \lccode`5=`f\lccode`6=`g\lccode`7=`h\lccode`8=`i\lccode`9=`j%
- \lccode` =`\_\lccode`-=`\_\lccode`_=`\_%
- \lowercase{\gdef#1{#2}}%
- \egroup}
-
-% een gobble als default is sneller, en dan alleen setten als
-% nodig
-
-\def\resetFLOWcell
- {% variables
- \global\let\FLOWname \empty
- \global\let\FLOWalign \empty
- \global\let\FLOWshape \empty
- \global\let\FLOWlocation \empty
- \global\let\FLOWtext \empty
- \global\let\FLOWhelp \empty
- \global\let\FLOWdestination\empty
- \global\let\FLOWoverlay \empty
- \global\let\FLOWfocus \empty
- \global\let\tFLOWlabel \empty
- \global\let\bFLOWlabel \empty
- \global\let\lFLOWlabel \empty
- \global\let\rFLOWlabel \empty
- \global\let\bcFLOWlabel \empty
- \global\let\tcFLOWlabel \empty
- \global\let\lcFLOWlabel \empty
- \global\let\rcFLOWlabel \empty
- \global\let\tFLOWexit \empty
- \global\let\bFLOWexit \empty
- \global\let\lFLOWexit \empty
- \global\let\rFLOWexit \empty
- % commands
- \let\name \doFLOWname
- \let\shape \doFLOWshape
- \let\destination\doFLOWdestination
- \let\location \doFLOWlocation
- \let\focus \doFLOWfocus
- \let\overlay \doFLOWoverlay
- \let\figure \doFLOWfigure
- \let\text \doFLOWtext
- \let\comment \doFLOWcomment
- \let\label \doFLOWlabel
- \let\help \doFLOWhelp
- \let\connection \doFLOWconnection
- \let\exit \doFLOWexit
- % convenience commands
- \let\locate \doFLOWlocate
- \let\connect \doFLOWconnect}
-
-\let\FLOWcell \s!unknown
-\let\FLOWshape \s!unknown
-\let\FLOWdestination\s!unknown
-\let\FLOWfocus \s!unknown
-\let\FLOWoverlay \empty
-\let\FLOWtext \empty
-
-\def\doFLOWname#1%
- {\def\FLOWcell{#1}\setFLOWname\FLOWname{name_#1}\ignorespaces}
-
-\def\doFLOWshape#1%
- {\gdef\FLOWshape{#1}\ignorespaces}
-
-\def\doFLOWdestination#1%
- {\gdef\FLOWdestination{#1}\ignorespaces}
-
-\def\doFLOWlocation#1%
- {\setFLOWlocation#1\end\ignorespaces}
-
-\def\doFLOWfocus#1%
- {\gdef\FLOWfocus{#1}\ignorespaces}
-
-\def\doFLOWoverlay#1%
- {\gdef\FLOWoverlay{#1}\ignorespaces}
-
-\def\doFLOWfigure#1%
- {\defineoverlay[\s!dummy][\overlayfigure{#1}]%
- \overlay\s!dummy}
-
-\def\doFLOWtext
- {\dosingleempty\dodoFLOWtext}
-
-\def\dodoFLOWtext[#1]% % #2%
- {\gdef\FLOWalign{#1}\gdef\FLOWtext}% {#2}}
-
-\def\doFLOWcomment[#1]#2%
- {\ignorespaces\dogobblesingleempty}
-
-\def\doFLOWlabel[#1]#2% wordt dit gebruikt ?
- {\setgvalue{#1FLOWlabel}{#2}\ignorespaces}
-
-\def\doFLOWhelp#1%
- {\gdef\FLOWhelp{#1}\ignorespaces}
-
-\def\doFLOWconnection
- {\dodoubleempty\dodoFLOWconnection}
-
-\def\dodoFLOWconnection[#1][#2]#3%
- {\ignorespaces}
-
-\def\doFLOWconnect
- {\connection}
-
-\def\doFLOWlocate
- {\location}
-
-\def\doFLOWexit[#1]#2%
- {\setgvalue{#1FLOWexit}{#2}\ignorespaces}
-
-\def\startFLOWchart
- {\bgroup
- \let\stopFLOWchart\egroup
- \obeylines % lelijk, buffers nog eens fatsoeneren
- \dodoubleempty\dostartFLOWchart}
-
-\def\dostartFLOWchart[#1][#2]%
- {\preparenextFLOWchart{#1}{#2}%
- \dostartbuffer[\FLOWbufferprefix\nofFLOWcharts][startFLOWchart][stopFLOWchart]}
-
-\def\defineFLOWchart%
- {\dodoubleempty\dodefineFLOWchart}
-
-\long\def\dodefineFLOWchart[#1][#2]#3%
- {\preparenextFLOWchart{#1}{#2}%
- \setbuffer[\FLOWbufferprefix\nofFLOWcharts]#3\endbuffer}
-
-\def\preparenextFLOWchart#1#2%
- {\doglobal\increment\nofFLOWcharts
- \flowchart{#1}%
- \setxvalue{\@FLOW@-#1}{\noexpand\dohandleflowchart[\nofFLOWcharts][#2]}}
-
-\def\setupFLOWcharts{\dodoubleargument\getparameters[\@@FLOW]}
-\def\setupFLOWlines {\dodoubleargument\getparameters[\@@FLOL]}
-\def\setupFLOWshapes{\dodoubleargument\getparameters[\@@FLOS]}
-\def\setupFLOWfocus {\dodoubleargument\getparameters[\@@FLOF]}
-\def\setupFLOWsets {\dodoubleargument\getparameters[\@@FLOX]}
-
-\setupFLOWcharts
- [\c!option=,
- \c!bodyfont=,
- \c!dot=, % private option
- \c!width=12\bodyfontsize,
- \c!height=7\bodyfontsize,
- \c!maxwidth=,
- \c!maxheight=,
- \c!offset=\v!standard, % == auto offset
- \c!dx=2\bodyfontsize,
- \c!dy=2\bodyfontsize,
- \c!nx=0, % 1,
- \c!ny=0, % 1,
- \c!x=1,
- \c!y=1,
- \c!autofocus=,
- \c!focus=,
- \c!background=, % \v!color,
- \c!backgroundcolor=\s!white,
- \c!rulethickness=\linewidth,
- \c!frame=\v!off,
- \c!framecolor=]
-
-\setupFLOWlines
- [\c!corner=\v!round,
- \c!arrow=\v!yes,
- \c!dash=\v!no,
- \c!radius=.375\bodyfontsize, % 2.5\c!rulethickness
- \c!color=FLOWlinecolor,
- \c!rulethickness=.15\bodyfontsize, % 2pt,
- \c!offset=\v!none]
-
-\setupFLOWshapes
- [\c!default=action,
- \c!framecolor=FLOWframecolor,
- \c!background=\v!color,
- \c!backgroundcolor=FLOWbackgroundcolor,
- \c!backgroundscreen=\@@rsscreen,
- \c!rulethickness=.15\bodyfontsize, % 2pt,
- \c!offset=.5\bodyfontsize]
-
-\setupFLOWfocus
- [\c!framecolor=FLOWfocuscolor,
- \c!background=\@@FLOSbackground,
- \c!backgroundcolor=\@@FLOSbackgroundcolor,
- \c!backgroundscreen=\@@FLOSbackgroundscreen,
- \c!rulethickness=\@@FLOSrulethickness,
- \c!offset=\@@FLOSoffset]
-
-\definecolor [FLOWfocuscolor] [s=.2]
-\definecolor [FLOWlinecolor] [s=.5]
-\definecolor [FLOWframecolor] [s=.7]
-\definecolor [FLOWbackgroundcolor] [s=.9]
-
-\newcounter\includeFLOWx
-\newcounter\includeFLOWy
-
-\def\includeFLOWchart
- {\dodoubleempty\doincludeFLOWchart}
-
-\def\doincludeFLOWchart[#1][#2]%
- {\pushmacro\includeFLOWx
- \pushmacro\includeFLOWy
- \getparameters[FLOWi][x=1,y=1,#2]%
- \increment(\includeFLOWx,0\FLOWix)\decrement\includeFLOWx
- \increment(\includeFLOWy,0\FLOWiy)\decrement\includeFLOWy
- \def\dodoincludeFLOWchart##1%
- {\doifdefined{\@FLOW@-##1}
- {\globalpushmacro\dohandleflowchart % was local
- \gdef\dohandleflowchart[####1][####2]%
- {\globalpopmacro\dohandleflowchart % was local
- \resetFLOWlocation
- \processFLOWbuffer{####1}}%
- \getvalue{\@FLOW@-##1}}}%
- \processcommalist[#1]\dodoincludeFLOWchart
- \popmacro\includeFLOWx
- \popmacro\includeFLOWy}
-
-\def\resetFLOWlocation
- {\globallet\lastFLOWx\!!zerocount
- \globallet\lastFLOWy\!!zerocount}
-
-\def\dosetFLOWlocation[#1#2]#3#4%
- {\processaction
- [#1#2]
- [ +=>\scratchcounter\numexpr#4+ 1+#3\relax,
- -=>\scratchcounter\numexpr#4- 1+#3\relax,
- +#2=>\scratchcounter\numexpr#4+#2+#3\relax,
- -#2=>\scratchcounter\numexpr#4-#2+#3\relax,
- \s!default=>\scratchcounter\numexpr#4 +#3\relax,
- \s!unknown=>\scratchcounter\numexpr0#1#2+#3\relax]%
- \xdef#4{\the\scratchcounter}}
-
-\def\setFLOWlocation#1,#2\end
- {\dosetFLOWlocation[#1\empty]\includeFLOWx\lastFLOWx
- \dosetFLOWlocation[#2\empty]\includeFLOWy\lastFLOWy
- \xdef\FLOWlocation{\lastFLOWx,\lastFLOWy}}
-
-\def\FLOWshapes
- {node, action, procedure, product, decision, archive,
- loop, wait, subprocedure, singledocument, multidocument,
- sub procedure, single document, multi document, up, down,
- left, right}
-
-\def\FLOWlines
- {up, down, left, right}
-
-\def\FLOWsetconnect#1%
- {\donefalse
- \let\cFLOWfrom\empty
- \let\cFLOWto\empty
- \let\zFLOWfrom\!!zerocount
- \let\zFLOWto\!!zerocount
- \handletokens#1\with\doFLOWsetconnect
- \ifx\cFLOWto\empty\let\cFLOWfrom\empty\fi}
-
-\def\doFLOWsetconnect#1%
- {\ifx #1p%
- \ifdone\def\zFLOWto{+1}\else\def\zFLOWfrom{+1}\fi
- \else\ifx#1+%
- \ifdone\def\zFLOWto{+1}\else\def\zFLOWfrom{+1}\fi
- \else\ifx#1n%
- \ifdone\def\zFLOWto{-1}\else\def\zFLOWfrom{-1}\fi
- \else\ifx#1-%
- \ifdone\def\zFLOWto{-1}\else\def\zFLOWfrom{-1}\fi
- \else\ifdone
- \edef\cFLOWto{\FLOWconnector#1}%
- \else
- \edef\cFLOWfrom{\FLOWconnector#1}%
- \donetrue
- \fi\fi\fi\fi\fi}
-
-\def\FLOWconnector#1%
- {\if#1bbottom\else\if#1ttop\else\if#1lleft\else\if#1rright\fi\fi\fi\fi}
-
-\newif\ifFLOWscaling \FLOWscalingtrue
-
-\def\@@FLOW@@offset{\@@FLOWoffset}
-
-\def\getFLOWchart
- {\dodoubleempty\dogetFLOWchart}
-
-\def\dogetFLOWchart[#1][#2]%
- {\doifundefinedelse{\@FLOW@-#1}
- {\writestatus{FLOW}{unknown chart #1}%
- \framed
- [\c!width=12\bodyfontsize,\c!height=8\bodyfontsize]
- {\tttf [chart #1]}}
- {\dodogetFLOWchart[#1][#2]}}
-
-\def\dodogetFLOWchart[#1][#2]% to be split a bit more
- {\vbox\bgroup
- \insidefloattrue
- \forgetall
- \dontcomplain
- % \offinterlineskip % we now explicitly use \nointerlineskip later on
- \def\dohandleflowchart[##1][##2]%
- {\def\currentFLOWnumber{##1}%
- \getparameters[\@@FLOW][##2]}%
- \getvalue{\@FLOW@-#1}%
- \getparameters[\@@FLOW][#2]% dubbelop ?
- \doifsomething{\@@FLOWautofocus}
- {\checkFLOWautofocus}%
- %\message{AUTOSHAPE 3: (\@@FLOWx,\@@FLOWy)->(\@@FLOWnx,\@@FLOWny)}\wait
- \global\let\FLOWwidth \@@FLOWnx
- \global\let\FLOWheight\@@FLOWny
- \let\startFLOWcell\startFLOWcellA
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber
- \ifcase\@@FLOWnx\relax \let\@@FLOWnx\FLOWwidth \fi
- \ifcase\@@FLOWny\relax \let\@@FLOWny\FLOWheight \fi
- \doifnothing{\@@FLOWmaxwidth\@@FLOWmaxheight}{\FLOWscalingfalse}%
- \ifFLOWscaling
- \doifnothing{\@@FLOWmaxwidth }{\let\@@FLOWmaxwidth \maxdimen}%
- \doifnothing{\@@FLOWmaxheight}{\let\@@FLOWmaxheight\maxdimen}%
- \scratchcounter\bodyfontpoints
- \doloop % NOG FONTSWITCH OM EX EN EM TE LATEN WERKEN
- {\ifnum\scratchcounter>1 % NU DIMENSIONS IN TERMS OF BODYFONTSIZE
- \bodyfontsize=\the\scratchcounter pt
- \dimen0=\@@FLOWmaxwidth
- \dimen2=\@@FLOWwidth
- \dimen4=\@@FLOWdx
- \advance\dimen2 2\dimen4
- \dimen2=\@@FLOWnx\dimen2
- \advance\dimen2 2\dimen4
- \ifdim\dimen2>\dimen0
- \advance\scratchcounter \minusone
- \else
- \dimen0=\@@FLOWmaxheight
- \dimen2=\@@FLOWheight
- \dimen4=\@@FLOWdy
- \advance\dimen2 2\dimen4
- \dimen2=\@@FLOWny\dimen2
- \advance\dimen2 2\dimen4
- \ifdim\dimen2>\dimen0
- \advance\scratchcounter \minusone
- \else
- \exitloop
- \fi
- \fi
- \else
- \exitloop
- \fi}%
- \expanded{\switchtobodyfont[\the\scratchcounter pt]}%
- \forgetall
- % \offinterlineskip % needed ?
- \else\ifx\@@FLOWbodyfont\empty\else
- \expanded{\switchtobodyfont[\@@FLOWbodyfont]}% \expanded ?
- \fi\fi
- \global\let\FLOWcells\empty
- \dimen0=\@@FLOWwidth
- \edef\FLOWshapewidth{\the\dimen0}%
- \dimen2=\@@FLOWdx
- \advance\dimen0 2\dimen2
- \edef\FLOWgridwidth{\the\dimen0}%
- \dimen0=\@@FLOWheight
- \edef\FLOWshapeheight{\the\dimen0}%
- \dimen2=\@@FLOWdy
- \advance\dimen0 2\dimen2
- \edef\FLOWgridheight{\the\dimen0}%
- \scratchdimen=\@@FLOSrulethickness
- \edef\@@FLOSrulethickness{\the\scratchdimen}%
- \scratchdimen=\@@FLOFrulethickness
- \edef\@@FLOFrulethickness{\the\scratchdimen}%
- \scratchdimen=\@@FLOLrulethickness
- \edef\@@FLOLrulethickness{\the\scratchdimen}%
- \ifdim\@@FLOLradius<2.5\scratchdimen
- \scratchdimen=2.5\scratchdimen
- \edef\@@FLOLradius{\the\scratchdimen}%
- \ifdim\@@FLOLradius>\@@FLOWdx
- \scratchdimen=\@@FLOWdx
- \edef\@@FLOLradius{\the\scratchdimen}%
- \fi
- \ifdim\@@FLOLradius>\@@FLOWdy
- \scratchdimen=\@@FLOWdy
- \edef\@@FLOLradius{\the\scratchdimen}%
- \fi
- \else
- \scratchdimen=\@@FLOLradius
- \edef\@@FLOLradius{\the\scratchdimen}%
- \fi
- \processaction % magic 2.5
- [\@@FLOWoffset]
- [ \v!none=>\scratchdimen=-2.5\scratchdimen,
- \v!overlay=>\scratchdimen=-2.5\scratchdimen,
- \v!standard=>\scratchdimen=\scratchdimen,
- \s!unknown=>\scratchdimen=\@@FLOWoffset,
- \s!default=>\scratchdimen=-2.5\scratchdimen]%
- \edef\@@FLOW@@offset{\the\scratchdimen}%
- \forgetall
- \offinterlineskip
- \resetMPdrawing
- \doglobal\newcounter\FLOWcomment
- \startMPdrawing
- if unknown context_char : input mp-char.mp ; fi ;
- grid_width := \FLOWgridwidth ;
- grid_height := \FLOWgridheight ;
- shape_width := \FLOWshapewidth ;
- shape_height := \FLOWshapeheight ;
- connection_line_width := \@@FLOLrulethickness ;
- connection_smooth_size := \@@FLOLradius ;
- connection_arrow_size := \@@FLOLradius ;
- connection_dash_size := \@@FLOLradius ;
- currentpicture := nullpicture ;
- begin_chart(0,\FLOWwidth,\FLOWheight);
- reverse_y := true ;
- chart_offset := \@@FLOW@@offset ;
- \stopMPdrawing
- \doifelsenothing\@@FLOWbackgroundcolor
- {\startMPdrawing
- chart_background_color := white ;
- \stopMPdrawing}
- {\startMPdrawing
- chart_background_color := \MPcolor{\@@FLOWbackgroundcolor} ;
- \stopMPdrawing}%
- \doif\@@FLOWoption\v!test
- {\startMPdrawing
- show_con_points := true ;
- show_mid_points := true ;
- show_all_points := true ;
- \stopMPdrawing}%
- \processaction % private
- [\@@FLOWdot]
- [ \v!yes=>\startMPdrawing
- show_con_points := true ;
- show_mid_points := true ;
- show_all_points := true ;
- \stopMPdrawing,
- \s!unknown=>\startMPdrawing
- show_\@@FLOWdot _points := true ;
- \stopMPdrawing]%
- \doglobal\newcounter\FLOWcomment
- \let\startFLOWcell\startFLOWcellB
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber
- \doglobal\newcounter\FLOWcomment
- \let\startFLOWcell\startFLOWcellC
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber
- \startMPdrawing
- clip_chart(\@@FLOWx,\@@FLOWy,\@@FLOWnx,\@@FLOWny) ;
- end_chart ;
- \stopMPdrawing
- \MPdrawingdonetrue
- \setbox0\hbox
- {\MPstaticgraphictrue
- \MPshiftdrawingfalse
- \getMPdrawing}%
- \def\MPmessage##1%
- {\writestatus{MP charts}{##1}}%
- \def\MPposition##1##2##3%
- {\setvalue{\@@MPx##1}{##2}\setvalue{\@@MPy##1}{##3}}%
- \def\MPclippath##1##2##3##4%
- {\def\clipMPllx{##1bp}\def\clipMPlly{##2bp}%
- \def\clipMPurx{##3bp}\def\clipMPury{##4bp}}%
- \def\MPareapath##1##2##3##4%
- {\def\areaMPllx{##1bp}\def\areaMPlly{##2bp}%
- \def\areaMPurx{##3bp}\def\areaMPury{##4bp}}%
- \getMPdata
- \doglobal\newcounter\FLOWcomment
- \let\startFLOWcell\startFLOWcellD
- \setbox2\vbox to \ht0
- {\forgetall % \offinterlineskip
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber\vss}%
- \setbox2\hbox
- {\hskip\@@FLOW@@offset\lower\@@FLOW@@offset\box2}%
- \wd2\wd0\ht2\ht0\dp2\dp0
- \let\startFLOWcell\startFLOWcellE
- \setbox4\vbox to \ht0
- {\forgetall % \offinterlineskip
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber\vss}%
- \setbox4\hbox
- {\hskip\@@FLOW@@offset\lower\@@FLOW@@offset\box4}%
- \wd4\wd0\ht4\ht0\dp4\dp0
- \doifelse\@@FLOWoption\v!test
- {\setbox6\vbox
- {\forgetall
- \vskip\@@FLOW@@offset
- \hskip\@@FLOW@@offset
- \basegrid
- [\c!x=\@@FLOWx,\c!nx=\@@FLOWnx,\c!dx=\withoutpt\FLOWgridwidth,
- \c!y=\@@FLOWy,\c!ny=\@@FLOWny,\c!dy=\withoutpt\FLOWgridheight,
- \c!xstep=1,\c!ystep=1,
- \c!unit=pt,\c!location=\v!middle]}%
- \wd6\wd0\ht6\ht0\dp6\dp0
- \setbox8\vbox
- {\forgetall
- \offinterlineskip
- \vskip\@@FLOW@@offset
- \dostepwiserecurse\@@FLOWy\@@FLOWny\plusone
- {\vbox to \FLOWgridheight
- {\vfill
- \hskip\@@FLOW@@offset
- \hbox
- {\dostepwiserecurse\@@FLOWx\@@FLOWnx\plusone
- {\hbox to \FLOWgridwidth
- {\hfill
- \framed
- [\c!framecolor=red,
- \c!width=\FLOWshapewidth,
- \c!height=\FLOWshapeheight]
- {}%
- \hfill}}}
- \vfill}}}%
- \wd8\wd0\ht8\ht0\dp8\dp0
- \framed
- [\c!offset=\v!overlay,\c!framecolor=green]
- {\hbox{\box4\hskip-\wd0\box0\hskip-\wd2\box2\hskip-\wd6\box6\hskip-\wd8\box8}}}
- {\framed
- [\c!offset=\v!overlay,
- \c!frame=\@@FLOWframe,
- \c!rulethickness=\@@FLOWrulethickness,
- \c!framecolor=\@@FLOWframecolor,
- \c!background=\@@FLOWbackground,
- \c!backgroundcolor=\@@FLOWbackgroundcolor]
- {\hbox{\box4\hskip-\wd0\box0\hskip-\wd2\box2}}}%
- %\message{[\FLOWcells]}\wait
- \egroup}
-
-% Pass A
-
-\long\def\startFLOWcellA#1\stopFLOWcell%
- {\resetFLOWcell
- \ignorespaces#1\unskip
- \expandafter\getFLOWlocationA\FLOWlocation\end
- \ignorespaces}
-
-\def\getFLOWlocationA#1,#2\end
- {\ifnum0#1>\FLOWwidth \xdef\FLOWwidth {#1}\fi
- \ifnum0#2>\FLOWheight\xdef\FLOWheight{#2}\fi}
-
-% Pass B
-%
-% beware: the - after \@FLOC@ is needed since name can be
-% empty and we don't want to redefine \@FLOC@ itself by
-% mistake
-
-\long\def\startFLOWcellB#1\stopFLOWcell
- {\resetFLOWcell\ignorespaces#1\unskip
- \setxvalue{\@FLOC@-\FLOWname}{\FLOWlocation}% kost veel cs's
- \ifx\FLOWshape\empty
- \global\let\FLOWshape\@@FLOSdefault
- \fi
- \doifnot\FLOWshape{none} % {\v!none}
- {\doifinsetelse\FLOWshape\FLOWshapes
- {\edef\FLOWshapetag{shape_\FLOWshape}% beter \expanded
- \@EA\setFLOWname\@EA\FLOWshapetag\@EA{\FLOWshapetag}}
- {\doifnumberelse\FLOWshape
- {\let\FLOWshapetag\FLOWshape}
- {\let\FLOWshapetag\empty}}%
- \ifx\FLOWshapetag\empty \else
- \doifinsetelse\FLOWshape\FLOWlines
- {\chardef\FLOWstate0 }
- {\doifcommonelse{\FLOWcell,\FLOWfocus}\@@FLOWfocus
- {\chardef\FLOWstate1 }
- {\chardef\FLOWstate2 }}%
- \startMPdrawing
- begin_sub_chart ;
- \ifcase\FLOWstate
- shape_line_color := \MPcolor{\@@FLOLcolor} ;
- shape_fill_color := \MPcolor{\@@FLOLcolor} ;
- shape_line_width := \@@FLOLrulethickness ;
- \or
- shape_line_color := \MPcolor{\@@FLOFframecolor} ;
- shape_fill_color := \MPcolor{\@@FLOFbackgroundcolor} ;
- shape_line_width := \@@FLOFrulethickness ;
- \or
- shape_line_color := \MPcolor{\@@FLOSframecolor} ;
- shape_fill_color := \MPcolor{\@@FLOSbackgroundcolor} ;
- shape_line_width := \@@FLOSrulethickness ;
- \fi
- %\ifx\FLOWoverlay\empty
- % peepshape := false ;
- %\else
- % peepshape := true ;
- %\fi
- peepshape := \ifx\FLOWoverlay\empty false \else true \fi ;
- new_shape(\FLOWlocation,\FLOWshapetag) ;
- end_sub_chart ;
- \stopMPdrawing
- \fi}%
- \ignorespaces}
-
-% Pass C
-
-\long\def\startFLOWcellC#1\stopFLOWcell%
- {\resetFLOWcell
-\pushmacro\lastFLOWx
-\pushmacro\lastFLOWy
- \ignorespaces#1\unskip % makes sure that vars are set
-\popmacro\lastFLOWy
-\popmacro\lastFLOWx
- \let\connection\doFLOWconnectionC
- \ignorespaces#1\unskip}
-
-\def\FLOWorigin{0,0}
-
-\def\doFLOWdisplace[#1,#2,#3]% experiment
- {dsp_x := #1 ; dsp_y := #2 ;}
-
-\def\doFLOWconnectionC
- {\dodoubleempty\dodoFLOWconnectionC}
-
-\def\dodoFLOWconnectionC[#1][#2]#3%
- {\doglobal\increment\FLOWcomment
- \setFLOWname\otherFLOWname{name_#3}%
- \doifdefinedelse{\@FLOC@-\FLOWname}
- {\edef\FLOWfrom{\getvalue{\@FLOC@-\FLOWname}}}
- {\let \FLOWfrom \FLOWorigin}%
- \ifx\FLOWfrom\FLOWorigin \else
- \doifdefinedelse{\@FLOC@-\otherFLOWname}
- {\edef\FLOWto {\getvalue{\@FLOC@-\otherFLOWname}}}
- {\let \FLOWto \FLOWorigin}%
- \ifx\FLOWto\FLOWorigin \else
- \FLOWsetconnect{#1}%
- \ifx\cFLOWfrom\empty \else
- \doifelse\@@FLOLcorner\v!round
- {\startMPdrawing smooth := true ; \stopMPdrawing}
- {\startMPdrawing smooth := false ; \stopMPdrawing}%
- \doifelse\@@FLOLdash\v!yes
- {\startMPdrawing dashline := true ; \stopMPdrawing}
- {\startMPdrawing dashline := false ; \stopMPdrawing}%
- \doifelse\@@FLOLarrow\v!yes
- {\startMPdrawing arrowtip := true ; \stopMPdrawing}
- {\startMPdrawing arrowtip := false ; \stopMPdrawing}%
- \doifelse\@@FLOLoffset\v!none
- {\startMPdrawing touchshape := true ; \stopMPdrawing}
- {\startMPdrawing touchshape := false ; \stopMPdrawing}%
-%\doifsomething{#2}
-% {\startMPdrawing
-% \doFLOWdisplace[0#2,0,0]%
-% \stopMPdrawing}%
- \startMPdrawing
-\doFLOWdisplace[0#2,0,0]%
- connection_line_color := \MPcolor{\@@FLOLcolor} ;
- connection_line_width := \@@FLOLrulethickness ;
- connect_\cFLOWfrom _\cFLOWto (\FLOWfrom,\zFLOWfrom) (\FLOWto,\zFLOWto) ;
-\doFLOWdisplace[0,0,0]%
- \stopMPdrawing
- \fi
- \fi
- \fi
- \ignorespaces}
-
-% Pass D
-
-\long\def\startFLOWcellD#1\stopFLOWcell
- {\resetFLOWcell
- \pushmacro\lastFLOWx
- \pushmacro\lastFLOWy
- \ignorespaces#1\unskip % presets vars
- \popmacro\lastFLOWy
- \popmacro\lastFLOWx
- \let\doprocessFLOWcell\doprocessFLOWcellD
- \expandafter\doprocessFLOWcellD\FLOWlocation\end
- \let\connection\doFLOWconnectionD
- \let\comment\doFLOWcommentD
- \ignorespaces#1\unskip\ignorespaces}
-
-\def\doFLOWconnectionD
- {\dodoubleempty\dodoFLOWconnectionD}
-
-\def\dodoFLOWconnectionD[#1][#2]#3%
- {\doglobal\increment\FLOWcomment
- \ignorespaces}
-
-\def\doFLOWcommentD[#1]#2%
- {\bgroup
- \let\FLOW \middlebox
- \let\FLOWb \bottombox
- \let\FLOWbl\bottomleftbox
- \let\FLOWbr\bottomrightbox
- \let\FLOWt \topbox
- \let\FLOWtl\topleftbox
- \let\FLOWtr\toprightbox
- \let\FLOWl \leftbox
- \let\FLOWlt\lefttopbox
- \let\FLOWlb\leftbottombox
- \let\FLOWr \rightbox
- \let\FLOWrt\righttopbox
- \let\FLOWrb\rightbottombox
- \let\FLOWc \middlebox
-%\ifdefined{FLOW#1}%
- \ifcase0\getvalue{\@@MPx\FLOWcomment}\getvalue{\@@MPy\FLOWcomment}\relax
- \else
- \ifdim\getvalue{\@@MPx\FLOWcomment}\s!bp<\areaMPllx\relax\else
- \ifdim\getvalue{\@@MPx\FLOWcomment}\s!bp>\areaMPurx\relax\else
- \ifdim\getvalue{\@@MPy\FLOWcomment}\s!bp<\areaMPlly\relax\else
- \ifdim\getvalue{\@@MPy\FLOWcomment}\s!bp>\areaMPury\relax\else
- \dimen0=\getvalue{\@@MPx\FLOWcomment}\s!bp
- \advance\dimen0 -\@@FLOW@@offset
- \advance\dimen0 -\clipMPllx
- \dimen2=\clipMPury
- \advance\dimen2 -\@@FLOW@@offset
- \advance\dimen2 -\getvalue{\@@MPy\FLOWcomment}\s!bp
- \setbox\scratchbox\hbox{\strut#2}%
- \boxoffset.5\bodyfontsize
- \setbox\scratchbox\hbox{\hskip\dimen0\lower\dimen2\getvalue{FLOW#1}{\box\scratchbox}}%
- \smashbox\scratchbox
- \box\scratchbox
- \boxoffset\zeropoint
- \nointerlineskip % really needed
- \fi
- \fi
- \fi
- \fi
- \fi
-%\fi
- \egroup
- \ignorespaces}
-
-% pass D
-
-\def\dophaseoneFLOWcellX#1#2%
- {\!!counta#1\relax
- \!!countb#2\relax
- \!!countc\@@FLOWx
- \!!countd\@@FLOWy
- \advance\!!countc \@@FLOWnx
- \advance\!!countd \@@FLOWny
- \advance\!!countc \minusone
- \advance\!!countd \minusone
- \ifnum\!!counta<\@@FLOWx\relax \donefalse
- \else\ifnum\!!counta>\!!countc \donefalse
- \else\ifnum\!!countb<\@@FLOWy\relax \donefalse
- \else\ifnum\!!countb>\!!countd \donefalse
- \else \donetrue
- \fi\fi\fi\fi}
-
-\def\dophasetwoFLOWcellX
- {\advance\!!counta -\@@FLOWx
- \advance\!!counta \plusone
- \advance\!!countb -\@@FLOWy
- \advance\!!countb \plusone
- \dimen0=\FLOWgridwidth
- \dimen0=\!!counta\dimen0
- \advance\dimen0 -\FLOWgridwidth
- \dimen4=\FLOWgridwidth
- \advance\dimen4 -\FLOWshapewidth
- \advance\dimen0 .5\dimen4
- \dimen2=\FLOWgridheight
- \dimen2=\!!countb\dimen2
- \dimen4=\FLOWgridheight
- \advance\dimen4 -\FLOWshapeheight
- \advance\dimen2 -.5\dimen4
- \edef\FLOWdx{\the\dimen0}%
- \edef\FLOWdy{\the\dimen2}}
-
-\def\positionFLOWzero% assumes \FLOWdx and \FLOWdy are set
- {\setbox0\hbox{\hskip\FLOWdx\lower\FLOWdy\box0}%
- \smashbox0\box0
- \nointerlineskip} % new, needed since we somehow reset that
-
-\def\doFLOWtlabel#1#2#3%
- {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdy\fi
- \setbox0\hbox{\hskip\dimen2\raise\scratchdimen
- \hbox{\raise\dimen4\hbox{#1{\strut#3}}}}%
- \positionFLOWzero}%
-
-\def\doFLOWblabel#1#2#3%
- {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdy\fi
- \setbox0\hbox{\hskip\dimen2\raise-\scratchdimen
- \hbox{#1{\strut#3}}}%
- \positionFLOWzero}%
-
-\def\doFLOWllabel#1#2#3%
- {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdx\fi
- \setbox0\hbox{\hskip-\scratchdimen\raise\dimen6
- \hbox{#1{\strut#3}}}%
- \positionFLOWzero}%
-
-\def\doFLOWrlabel#1#2#3%
- {\scratchdimen\ifcase#2 \zeropoint\else\@@FLOWdx\fi
- \setbox0\hbox{\hskip\dimen0\hskip\scratchdimen
- \hbox{\raise\dimen6\hbox{#1{\strut#3}}}}%
- \positionFLOWzero}
-
-\def\doprocessFLOWcellD#1,#2\end
- {\dophaseoneFLOWcellX{#1}{#2}%
- \ifdone
- \dophasetwoFLOWcellX
- \doglobal\addtocommalist\FLOWcell\FLOWcells
- \def\FLOWx{#1}%
- \def\FLOWy{#2}%
- \directsetup{flowcell}%
- \setbox0\hbox
- {\ifx\FLOWalign\empty\else
- \setupframed
- [\c!align=\v!normal,\c!bottom=\vfill,\c!top=\vfill]%
- \@EA\processallactionsinset\@EA
- [\FLOWalign]
- [t=>{\setupframed[\c!bottom=\vfill,\c!top=]},
- b=>{\setupframed[\c!bottom=,\c!top=\vfill]},
- l=>{\setupframed[\c!align=\v!right]},
- r=>{\setupframed[\c!align=\v!left]},
- m=>{\setupframed[\c!align=\v!middle]},
- c=>{\setupframed[\c!align=\v!middle]}]%
- \fi
- \doifelse\FLOWshape{none} % {\v!none}
- {\setupframed[\c!offset=\v!overlay]}
- {\setupframed[\c!offset=\@@FLOSoffset]}%
- \framed
- [\c!frame=\v!off,\c!background=flowcell,
- \c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
- {\FLOWtext}}%
- %\showFLOWhelp0
- \ifx\FLOWdestination\empty\else
- \setbox0\hbox
- {\setupinteraction[\c!color=,\c!contrastcolor=]%
- \gotobox{\box0}[\FLOWdestination]}%
- \fi
- \positionFLOWzero
- \dimen0=\FLOWshapewidth \dimen2=.5\dimen0
- \dimen4=\FLOWshapeheight\dimen6=.5\dimen4
- \boxoffset.5\bodyfontsize
- \doFLOWtlabel \righttopbox0\tFLOWlabel
- \doFLOWblabel\rightbottombox0\bFLOWlabel
- \doFLOWllabel \lefttopbox0\lFLOWlabel
- \doFLOWrlabel \righttopbox0\rFLOWlabel
- \doFLOWtlabel \topbox0\tcFLOWlabel % for me only
- \doFLOWblabel \bottombox0\bcFLOWlabel % for me only
- \doFLOWllabel \leftbox0\lcFLOWlabel % for me only
- \doFLOWrlabel \rightbox0\rcFLOWlabel % for me only
- \relax\ifnum#1=\@@FLOWx \relax \doFLOWllabel \leftbox1\lFLOWexit \fi
- \relax\ifnum#1=\!!countc\relax \doFLOWrlabel \rightbox1\rFLOWexit \fi
- \relax\ifnum#2=\@@FLOWy \relax \doFLOWtlabel \topbox1\tFLOWexit \fi
- \relax\ifnum#2=\!!countd\relax \doFLOWblabel\bottombox1\bFLOWexit \fi
- \boxoffset\zeropoint
- \fi}
-
-% For Willy Egger:
-%
-% \startsetups flowcell
-% \definelayer
-% [flowcell]
-% [width=\FLOWshapewidth,
-% height=\FLOWshapeheight]
-% \setlayerframed
-% [flowcell]
-% [preset=rightbottom,offset=1ex]
-% [frame=off]
-% {\tx(\FLOWx,\FLOWy)}
-% \stopsetups
-
-% Pass E
-
-\long\def\startFLOWcellE#1\stopFLOWcell
- {\resetFLOWcell
- \ignorespaces#1\unskip
- \let\doprocessFLOWcell\doprocessFLOWcellE
- \expandafter\doprocessFLOWcell\FLOWlocation\end}
-
-\def\doprocessFLOWcellE#1,#2\end % redundant
- {\ifx\FLOWoverlay\empty \else
- \dophaseoneFLOWcellX{#1}{#2}%
- \ifdone
- \dophasetwoFLOWcellX
- \edef\FLOWdx{\the\dimen0}%
- \edef\FLOWdy{\the\dimen2}%
- \setbox0\hbox
- {\framed
- [%\c!frame=\v!off,
- \c!background={\@@FLOWbackground,\FLOWoverlay},
- \c!backgroundcolor=\@@FLOSbackgroundcolor,
- \c!width=\FLOWshapewidth,\c!height=\FLOWshapeheight]
- {}}%
- \positionFLOWzero
- \fi
- \fi}
-
-% Pass F
-
-\def\checkFLOWautofocus
- {\def\@@FLOWminx{100}\let\@@FLOWminy\@@FLOWminx
- \def\@@FLOWmaxx {0}\let\@@FLOWmaxy\@@FLOWmaxx
- \def\@@FLOWabsx {0}\let\@@FLOWabsy\@@FLOWabsx
- \let\startFLOWcell\startFLOWcellF
- \resetFLOWlocation
- \processFLOWbuffer\currentFLOWnumber
- %\message{AUTOSHAPE 1: (\@@FLOWminx,\@@FLOWminy)->(\@@FLOWmaxx,\@@FLOWmaxy)}%
- \ifnum\@@FLOWabsx<\@@FLOWmaxx\let\@@FLOWmaxx\@@FLOWabsx\fi
- \ifnum\@@FLOWabsy<\@@FLOWmaxy\let\@@FLOWmaxy\@@FLOWabsy\fi
- %\message{AUTOSHAPE 2: (\@@FLOWminx,\@@FLOWminy)->(\@@FLOWmaxx,\@@FLOWmaxy)}%
- \donetrue
- \ifnum\@@FLOWminx=100 \donefalse\fi
- \ifnum\@@FLOWminy=100 \donefalse\fi
- \ifnum\@@FLOWmaxx=0 \donefalse\fi
- \ifnum\@@FLOWmaxy=0 \donefalse\fi
- \doFLOWcheckF\@@FLOWx\@@FLOWminx\@@FLOWmaxx\@@FLOWnx
- \doFLOWcheckF\@@FLOWy\@@FLOWminy\@@FLOWmaxy\@@FLOWny}
-
-\def\startFLOWcellF#1\stopFLOWcell%
- {\resetFLOWcell
- \ignorespaces#1\unskip
- \expandafter\doFLOWlocationF\FLOWlocation\end}%
-
-\def\doFLOWlocationF#1,#2\end%
- {\ifnum#1>\@@FLOWabsx\def\@@FLOWabsx{#1}\fi
- \ifnum#2>\@@FLOWabsy\def\@@FLOWabsy{#2}\fi
- \doifinset\FLOWcell\@@FLOWautofocus
- {\dodoFLOWlocationF{#1}<-\@@FLOWminx
- \dodoFLOWlocationF{#1}>+\@@FLOWmaxx
- \dodoFLOWlocationF{#2}<-\@@FLOWminy
- \dodoFLOWlocationF{#2}>+\@@FLOWmaxy}}
-
-\def\dodoFLOWlocationF#1#2#3#4%
- {\ifnum#1#2#4\relax
- \!!counta=#1\advance\!!counta #31\relax
- \edef#4{\ifnum\!!counta<1 1\else\the\!!counta\fi}%
- \fi}
-
-\def\doFLOWcheckF#1#2#3#4%
- {\ifdone
- \let#1=#2%
- \!!counta=#3%
- \advance\!!counta \plusone\advance\!!counta -#2\relax
- \ifnum\!!counta<1 \!!counta=1 \fi
- \edef#4{\the\!!counta}%
- \else
- \let#1\!!plusone
- \let#4\!!zerocount % no {1}
- \fi}
-
-% \useFLOWchart[name][parent][setting,setting][additional settings]
-% \useFLOWchart[name][parent][additional settings]
-
-\let\currentFLOWchart\empty
-
-\def\useFLOWchart
- {\doquadrupleempty\douseFLOWchart}
-
-\def\douseFLOWchart[#1][#2][#3][#4]% name parent sets mainsettings
- {\iffourthargument
- \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][#3][#4,##1]}%
- \else
- \checkparameters[#3]%
- \ifparameters
- \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][][#3,##1]}%
- \else
- \setvalue{\@FLOW@--#1}[##1]{\setgetFLOWchart[#2][#3][##1]}%
- \fi
- \fi}
-
-\def\setgetFLOWchart[#1][#2][#3]%
- {\def\docommand##1{}% cell line focus ?
- \processcommalist[#2]\docommand
- \getFLOWchart[#1][#3]}
-
-\def\doFLOWchart[#1][#2]%
- {\hbox\bgroup\vbox\bgroup % vmode suppresses spaces
-\def\currentFLOWchart{#1}%
- \doifundefinedelse{\@FLOW@--#1}
- {\getFLOWchart[#1][#2]}
- {\getvalue{\@FLOW@--#1}[#2]}%
- \egroup\egroup}
-
-\def\FLOWchart%
- {\dodoubleempty\doFLOWchart}
-
-%D The next section is dedicated to splitting up charts.
-
-\def\getFLOWsize[#1]%
- {\bgroup\let\dodogetFLOWchart\dogetFLOWsize\FLOWchart[#1]\egroup}
-
-\def\dogetFLOWsize[#1][#2]%
- {\setbox\scratchbox=\vbox
- {\globallet\FLOWmaxwidth \!!zerocount
- \globallet\FLOWmaxheight\!!zerocount
- \def\getFLOWlocation##1,##2\end
- {\ifnum0##1>\FLOWmaxwidth \xdef\FLOWmaxwidth {##1}\fi
- \ifnum0##2>\FLOWmaxheight\xdef\FLOWmaxheight{##2}\fi}%
- \resetFLOWcell
- \long\def\startFLOWcell##1\stopFLOWcell
- {{##1\expandafter\getFLOWlocation\FLOWlocation\end}}%
- \def\dohandleflowchart[##1][##2]%
- {\resetFLOWlocation
- \processFLOWbuffer{##1}}%
- \getvalue{\@FLOW@-#1}}}
-
-\def\setupFLOWsplit
- {\dodoubleargument\getparameters[\@@FLOT]}
-
-\setupFLOWsplit
- [\c!nx=3,\c!ny=3,
- \c!dx=1,\c!dy=1,
- \c!command=,
- \c!marking=\v!on,
- \c!before=,\c!after=]
-
-\def\FLOWsplitx {1}
-\def\FLOWsplity {1}
-\def\FLOWsplitnx{1}
-\def\FLOWsplitny{1}
-
-\def\FLOWcharts%
- {\dodoubleempty\doFLOWcharts}
-
-%D While splitting, the following variables are available:
-%D
-%D \starttyping
-%D \FLOWsplitnx \FLOWsplitny \FLOWsplitx \FLOWsplity
-%D \stoptyping
-
-\def\doFLOWcharts[#1][#2]%
- {\bgroup
- \getFLOWsize[#1]%
- \dodoFLOWcharts\relax
- \global\let\FLOWsplitnx\FLOWsplitx
- \global\let\FLOWsplitny\FLOWsplity
- \dodoFLOWcharts{\dododoFLOWcharts[#1][#2]}%
- \egroup}
-
-\def\dodoFLOWcharts#1%
- {\def\@@FLOTx{1}%
- \global\let\FLOWsplitx\@@FLOTx
- \doloop
- {\def\@@FLOTy{1}%
- \global\let\FLOWsplity\@@FLOTy
- \doloop
- {\bgroup
- \scratchcounter\FLOWmaxwidth
- \advance\scratchcounter -\@@FLOTx
- \advance\scratchcounter \plusone
- \ifnum\scratchcounter<\@@FLOTnx\edef\@@FLOTnx{\the\scratchcounter}\fi
- \scratchcounter\FLOWmaxheight
- \advance\scratchcounter -\@@FLOTy
- \advance\scratchcounter \plusone
- \ifnum\scratchcounter<\@@FLOTny\edef\@@FLOTny{\the\scratchcounter}\fi
- #1% does something with the float, or not
- \egroup
- \increment(\@@FLOTy,\@@FLOTny)%
- \ifnum\@@FLOTy>\FLOWmaxheight
- \exitloop
- \else
- \doglobal\increment\FLOWsplity
- \decrement(\@@FLOTy,\@@FLOTdy)%
- \fi}%
- \increment(\@@FLOTx,\@@FLOTnx)%
- \ifnum\@@FLOTx>\FLOWmaxwidth
- \exitloop
- \else
- \doglobal\increment\FLOWsplitx
- \decrement(\@@FLOTx,\@@FLOTdx)%
- \fi}}
-
-\def\dododoFLOWcharts[#1][#2]%
- {\bgroup
- \@@FLOTbefore
- \doifnot\@@FLOTmarking\v!on{\let\cuthbox\hbox}%
- \cuthbox
- {\@@FLOTcommand
- {\FLOWchart[#1][#2,
- \c!x=\@@FLOTx,\c!nx=\@@FLOTnx,
- \c!y=\@@FLOTy,\c!ny=\@@FLOTny]}}%
- \@@FLOTafter
- \egroup}
-
-%D An example of splitting is given below:
-%D
-%D \starttyping
-%D \setupFLOWsplit
-%D [nx=5,ny=10,
-%D dx=0,dy=0,
-%D before=,
-%D after=\page]
-%D
-%D \FLOWcharts[mybigflow]
-%D \stoptyping
-%D
-%D Or, one can say:
-%D
-%D \starttyping
-%D \splitfloat
-%D {\placefigure{What a big flowchart this is!}}
-%D {\FLOWcharts[mybigflow]}
-%D \stoptyping
-
-%D \macros
-%D {typeFLOWchart}
-%D
-%D For documentation purposes the following macro is
-%D provided. Watch the use of the first and last line hooks,
-%D which is needed because the start and stop commands are
-%D not part of the buffer.
-
-\def\typeFLOWchart[#1]%
- {\bgroup
- \def\dohandleflowchart[##1][##2]{\typeFLOWbuffer{##1}}%
- \defconvertedargument\firstverbatimfileline{\startFLOWchart[#1]}%
- \defconvertedargument\lastverbatimfileline {\stopFLOWchart}%
- \getvalue{\@FLOW@-#1}
- \egroup}
-
-%D New:
-%D
-%D \starttyping
-%D \setupFLOWcharts[command=\Whow]
-%D
-%D \startFLOWset[convert-en] % [tag][convert-en]
-%D \subFLOWchart[a][x=1,y=1,nx=3,ny=3]
-%D \subFLOWchart[b][x=1,y=2,nx=3,ny=3]
-%D \subFLOWchart[c][x=2,y=1,nx=3,ny=3]
-%D \stopFLOWset
-%D
-%D \def\Whow#1%
-%D {\ifnum\currentFLOWset=1 \framed{Some Chart}\fi}
-%D
-%D \FLOWset[convert-en] % [tag]
-%D
-%D \def\Whow#1%
-%D {\setuphead[state=high]
-%D \startstandardmakeup
-%D \centerbox{#1}
-%D \stopstandardmakeup}
-%D
-%D \FLOWset[convert-en] % [tag]
-%D \stoptyping
-
-\def\startFLOWset
- {\dodoubleempty\dostartFLOWset}
-
-\def\dostartFLOWset[#1][#2]#3\stopFLOWset % tag name data
- {\ifsecondargument
- \long\setvalue{\@FLOX@#1}{\dohandleFLOWset{#1}{#2}{#3}}%
- \else
- \long\setvalue{\@FLOX@#1}{\dohandleFLOWset{#1}{#1}{#3}}%
- \fi}
-
-\long\def\dohandleFLOWset#1#2#3% tag name data
- {\bgroup
- \def\subFLOWchart
- {\dodoubleempty\dosubFLOWchart}%
- \def\dosubFLOWchart[##1][##2]% subtag settings
- {\ifsecondargument
- \dodohandleFLOWset{#1}{##1}{#2}{##2}%
- \else
- \subFLOWchart[][##1]%
- \fi}%
- #3%
- \egroup}
-
-\def\dodohandleFLOWset#1#2#3#4% tag subtag name settings
- {\increment\currentFLOWset
- \bgroup
- \@@FLOXcommand
- {\ifnum\currentFLOWset=1 \pagereference[#1]\fi
- \doifsomething{#2}
- {\setupreferencing[\c!prefix=]%
- \pagereference[#1:#2]% -:#1:#2
- \setupreferencing[\c!prefix=#1:#2]}%
- \FLOWchart[#3][#4]}%
- \egroup}
-
-\def\FLOWset[#1]%
- {\newcounter\currentFLOWset
- \doifdefinedelse{\@FLOX@#1}
- {\getvalue{\@FLOX@#1}}
- {\dodohandleFLOWset{#1}{}{#1}{}}}
-
-\newcounter\currentFLOWset
-
-\setupFLOWsets
- [\c!command=]
-
-%D This will be an option:
-
-% \def\startFLOWchart%
-% {\dodoubleempty\dostartFLOWchart}
-%
-% \long\def\dostartFLOWchart[#1][#2]#3\stopFLOWchart
-% {\preparenextFLOWchart{#1}{#2}%
-% \long\setgvalue{\FLOWbufferprefix\nofFLOWcharts}{#3}}
-%
-% \long\def\dodefineFLOWchart[#1][#2]#3%
-% {\preparenextFLOWchart{#1}{#2}%
-% \long\setgvalue{\FLOWbufferprefix\nofFLOWcharts}{#3}}
-%
-% \def\processFLOWbuffer#1{\getvalue{\FLOWbufferprefix#1}}
-% \def\typeFLOWbuffer #1{[Sorry, no verbatim chart #1 available.]}
-
-\writestatus\m!system{The chart mkiv xml interface is not yet defined!}
-
-\protect
-
-\continueifinputfile{m-chart.mkiv}
-
-\input chrt-xml.tex
-
-\usemodule[abr-01]
-
-% \setupFLOWcharts[option=test]
-\setupinteraction[state=start]
-% \setupFLOWcharts[dx=30pt,dy=30pt]
-
-\startFLOWchart[demo]
- \startFLOWcell
- \name {one}
-% \destination{CloseDocument}
- \location {2,2}
-% \shape {action}
-% \text {first}
-% \label [b] {\bfx bottom}
-% \exit [l] {exit l}
-% \exit [r] {exit r}
-% \exit [t] {exit t}
-% \exit [b] {exit b}
-\comment[t]{comment t}
-\comment[b]{comment t}
- \connection [rt] {two}
- \stopFLOWcell
- \startFLOWcell
- \name {two}
- \destination{CloseDocument}
- \location {3,3}
- \shape {action}
- \text {second}
- \figure {cow.pdf}
-% \label [l] {\bfx left}
- \stopFLOWcell
-\stopFLOWchart
-
-\starttext
-
-\startTEXpage
-% \FLOWchart[convert-en]
-% \FLOWchart[conversion 1]
-% \FLOWchart[conversion 7]
-% \FLOWchart[conversion 9]
-% \FLOWchart[conversion 10]
- \FLOWchart[demo]
-\stopTEXpage
-
-\startTEXpage
- \FLOWchart[conversion 10]
-\stopTEXpage
-
-\stoptext
diff --git a/tex/context/base/m-flow.mkvi b/tex/context/base/m-chart.mkvi
index 425d7e490..dc92259d2 100644
--- a/tex/context/base/m-flow.mkvi
+++ b/tex/context/base/m-chart.mkvi
@@ -1,5 +1,5 @@
%D \module
-%D [ file=m-flow, -- m-chart
+%D [ file=m-chart,
%D version=2011.10.1, -- 1998.10.10,
%D title=\CONTEXT\ Modules,
%D subtitle=Flow Charts,
@@ -24,7 +24,7 @@
% setups
% mp instance with less files
-\registerctxluafile{m-flow}{}
+\registerctxluafile{m-chart}{}
\unprotect
@@ -404,7 +404,7 @@
\protect
-\continueifinputfile{m-flow.mkvi}
+\continueifinputfile{m-chart.mkvi}
\input chrt-xml.tex
diff --git a/tex/context/base/m-steps.lua b/tex/context/base/m-steps.lua
new file mode 100644
index 000000000..97759b799
--- /dev/null
+++ b/tex/context/base/m-steps.lua
@@ -0,0 +1,227 @@
+if not modules then modules = { } end modules ['x-flow'] = {
+ version = 1.001,
+ comment = "companion to m-flow.mkvi",
+ author = "Hans Hagen, PRAGMA-ADE, Hasselt NL",
+ copyright = "PRAGMA ADE / ConTeXt Development Team",
+ license = "see context related readme files"
+}
+
+-- when we can resolve mpcolor at the lua end we will use metapost.graphic(....) directly
+
+moduledata.steps = moduledata.steps or { }
+
+local points = number.points -- number.pt
+local variables = interfaces.variables
+
+local trace_charts = false
+
+local defaults = {
+ chart = {
+ dx = 10*65436,
+ dy = 10*65436,
+ },
+ cell = {
+ alternative = 1,
+ offset = 2*65436,
+ rulethickness = 65436,
+ framecolor = "blue",
+ backgroundcolor = "gray",
+ },
+ text = {
+ alternative = 1,
+ offset = 2*65436,
+ distance = 4*65436,
+ rulethickness = 65436,
+ framecolor = "red",
+ backgroundcolor = "gray",
+ },
+ line = {
+ alternative = 1,
+ rulethickness = 65436,
+ height = 30*65436,
+ distance = 10*65436,
+ offset = 5*65436,
+ color = "green",
+ },
+}
+
+-- todo : name (no name then direct)
+-- maybe: includes
+-- maybe: flush ranges
+
+local charts = { }
+local steps = { }
+
+function commands.step_start_chart(name)
+ name = name or ""
+ steps = { }
+ charts[name] = {
+ steps = steps,
+ }
+end
+
+function commands.step_stop_chart()
+end
+
+function commands.step_make_chart(settings)
+ local chartsettings = settings.chart
+ if not chartsettings then
+ print("no chart")
+ return
+ end
+ local chartname = chartsettings.name
+ if not chartname then
+ print("no name given")
+ return
+ end
+ local chart = charts[chartname]
+ if not chart then
+ print("no such chart",chartname)
+ return
+ end
+ local steps = chart.steps or { }
+ --
+ table.setmetatableindex(settings,defaults)
+ --
+ if trace_charts then
+ inspect(steps)
+ end
+ --
+ local textsettings = settings.text
+ local cellsettings = settings.cell
+ local linesettings = settings.line
+ --
+ context.startMPcode()
+ context("if unknown context_cell : input mp-step.mpiv ; fi ;")
+ context("step_begin_chart ;")
+ --
+ if chartsettings.alternative == variables.vertical then
+ context("chart_vertical := true ;")
+ end
+ --
+ context("text_line_color := \\MPcolor{%s} ;", textsettings.framecolor)
+ context("text_line_width := %s ;", points(textsettings.rulethickness))
+ context("text_fill_color := \\MPcolor{%s} ;", textsettings.backgroundcolor)
+ context("text_offset := %s ;", points(textsettings.offset))
+ context("text_distance_set := %s ;", points(textsettings.distance))
+ --
+ context("cell_line_color := \\MPcolor{%s} ;", cellsettings.framecolor)
+ context("cell_line_width := %s ;", points(cellsettings.rulethickness))
+ context("cell_fill_color := \\MPcolor{%s} ;", cellsettings.backgroundcolor)
+ context("cell_offset := %s ;", points(cellsettings.offset))
+ context("cell_distance_x := %s ;", points(cellsettings.dx))
+ context("cell_distance_y := %s ;", points(cellsettings.dy))
+ --
+ context("line_line_color := \\MPcolor{%s} ;", linesettings.color)
+ context("line_line_width := %s ;", points(linesettings.rulethickness))
+ context("line_distance := %s ;", points(linesettings.distance))
+ context("line_offset := %s ;", points(linesettings.offset))
+ --
+ for i=1,#steps do
+ local step = steps[i]
+ context("step_begin_cell ;")
+ if step.cell_top ~= "" then
+ context('step_cell_top("%s") ;',string.strip(step.cell_top))
+ end
+ if step.cell_bot ~= "" then
+ context('step_cell_bot("%s") ;',string.strip(step.cell_bot))
+ end
+ if step.text_top ~= "" then
+ context('step_text_top("%s") ;',string.strip(step.text_top))
+ end
+ if step.text_mid ~= "" then
+ context('step_text_mid("%s") ;',string.strip(step.text_mid))
+ end
+ if step.text_bot ~= "" then
+ context('step_text_bot("%s") ;',string.strip(step.text_bot))
+ end
+ context("step_end_cell ;")
+ end
+ --
+ context("step_end_chart ;")
+ context.stopMPcode()
+end
+
+function commands.step_cells(top,bot)
+ steps[#steps+1] = {
+ cell_top = top or "",
+ cell_bot = bot or "",
+ text_top = "",
+ text_mid = "",
+ text_bot = "",
+ }
+end
+
+function commands.step_texts(top,bot)
+ if #steps > 0 then
+ steps[#steps].text_top = top or ""
+ steps[#steps].text_bot = bot or ""
+ end
+end
+
+function commands.step_cell(top)
+ steps[#steps+1] = {
+ cell_top = top or "",
+ cell_bot = "",
+ text_top = "",
+ text_mid = "",
+ text_bot = "",
+ }
+end
+
+function commands.step_text(top)
+ if #steps > 0 then
+ steps[#steps].text_top = top or ""
+ end
+end
+
+function commands.step_textset(left,middle,right)
+ if #steps > 0 then
+ steps[#steps].text_top = left or ""
+ steps[#steps].text_mid = middle or ""
+ steps[#steps].text_bot = right or ""
+ end
+end
+
+function commands.step_start_cell()
+ steps[#steps+1] = {
+ cell_top = "",
+ cell_bot = "",
+ text_top = "",
+ text_mid = "",
+ text_bot = "",
+ }
+end
+
+function commands.step_stop_cell()
+end
+
+function commands.step_text_top(str)
+ if #steps > 0 then
+ steps[#steps].text_top = str or ""
+ end
+end
+
+function commands.step_text_mid(str)
+ if #steps > 0 then
+ steps[#steps].text_mid = str or ""
+ end
+end
+
+function commands.step_text_bot(str)
+ if #steps > 0 then
+ steps[#steps].text_bot = str or ""
+ end
+end
+
+function commands.step_cell_top(str)
+ if #steps > 0 then
+ steps[#steps].cell_top = str or ""
+ end
+end
+
+function commands.step_cell_bot(str)
+ if #steps > 0 then
+ steps[#steps].cell_bot = str or ""
+ end
+end
diff --git a/tex/context/base/m-steps.tex b/tex/context/base/m-steps.mkii
index 7bc92d456..e6bd45548 100644
--- a/tex/context/base/m-steps.tex
+++ b/tex/context/base/m-steps.mkii
@@ -146,7 +146,7 @@
%D \def\startSTEPchart%
%D {\bgroup
%D \startMPdrawing
-%D input mp-step ; begin_step_chart ;
+%D input mp-step.mpii ; begin_step_chart ;
%D \stopMPdrawing
%D \initializeSTEP
%D \let\cells\stepchartcells \def\cell{\cells{}}%
@@ -208,7 +208,7 @@
%D \resetMPdrawing
%D \advance\noftabpositions\plusone % begin of preroll
%D \startMPdrawing
-%D input mp-step ;
+%D input mp-step.mpii ;
%D begin_step_chart ;
%D \stopMPdrawing
%D \initializeSTEP
@@ -401,7 +401,7 @@
\resetMPdrawing
\doglobal\increment\currentstepchart
\startMPdrawing
- input mp-step ;
+ input mp-step.mpii ;
begin_step_chart ;
\stopMPdrawing
\initializeSTEP
@@ -682,7 +682,7 @@
\pushMPdrawing
\doglobal\increment\currentsteptable
\startMPdrawing
- input mp-step ;
+ input mp-step.mpii ;
begin_step_table ;
\stopMPdrawing
\initializeSTEP
diff --git a/tex/context/base/m-steps.mkvi b/tex/context/base/m-steps.mkvi
new file mode 100644
index 000000000..1a4406bab
--- /dev/null
+++ b/tex/context/base/m-steps.mkvi
@@ -0,0 +1,382 @@
+%D \module
+%D [ file=m-steps,
+%D version=2011.10.07, % 2001.05.28,
+%D title=\CONTEXT\ Modules,
+%D subtitle=Step Charts \& Tables,
+%D author=Hans Hagen,
+%D date=\currentdate,
+%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
+%C
+%C This module is part of the \CONTEXT\ macro||package and is
+%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
+%C details.
+
+% multiple texts?
+
+\registerctxluafile{m-steps}{}
+
+\unprotect
+
+\def\??stpc{@@stpc} % charts
+\def\??stpt{@@stpt} % tables
+\def\??stec{@@stec} % cells
+\def\??stet{@@stet} % texts
+\def\??stel{@@stel} % lines
+
+\installsimplecommandhandler \??stpc {STEPchart} \??stpc
+\installsimplecommandhandler \??stpt {STEPtable} \??stpt
+\installsimplecommandhandler \??stec {STEPcell} \??stec
+\installsimplecommandhandler \??stet {STEPtext} \??stet
+\installsimplecommandhandler \??stel {STEPline} \??stel
+
+\let\setupSTEPcharts\setupSTEPchart
+\let\setupSTEPtables\setupSTEPtable
+\let\setupSTEPcells \setupSTEPcell
+\let\setupSTEPtexts \setupSTEPtext
+\let\setupSTEPlines \setupSTEPline
+
+% numeric text_text_distance ; text_text_distance := 20pt ;
+% numeric step_distance ; step_distance := 20pt ;
+
+\setupSTEPcharts
+ [\c!alternative=\v!horizontal,
+ \c!before=\blank,
+ \c!after=\blank]
+% \c!offset=.15\bodyfontsize
+% \c!height=2ex
+
+% \setupSTEPtables
+% [\c!before=\blank,
+% \c!after=\blank,
+% \c!distance=.25em,
+% \c!voffset=1ex,
+% \c!method=1,
+% \c!width=4em,
+% \c!offset=.15\bodyfontsize]
+
+\setupSTEPcells
+ [\c!alternative=1, % TODO
+% \c!style=,
+% \c!color=,
+ \c!dx=\bodyfontsize,
+ \c!dy=\bodyfontsize,
+ \c!background=\v!color,
+ \c!backgroundcolor=STEPbackgroundcolor,
+ \c!rulethickness=.1\bodyfontsize,
+ \c!framecolor=STEPframecolor,
+ \c!offset=.25\bodyfontsize]
+
+\setupSTEPtexts
+ [\c!alternative=1, % TODO
+% \c!style=\v!smallbodyfont,
+% \c!color=,
+ \c!background=\v!color,
+ \c!backgroundcolor=STEPbackgroundcolor,
+ \c!rulethickness=.1\bodyfontsize,
+ \c!framecolor=STEPframecolor,
+ \c!distance=.5\bodyfontsize,
+ \c!offset=.25\bodyfontsize]
+
+\setupSTEPlines
+ [\c!alternative=1, % TODO
+ \c!rulethickness=.15\bodyfontsize,
+ \c!height=3\bodyfontsize,
+ \c!distance=.5\bodyfontsize,
+ \c!offset=.25\bodyfontsize,
+ \c!color=STEPlinecolor]
+
+\definecolor [STEPlinecolor] [s=.5]
+\definecolor [STEPframecolor] [s=.7]
+\definecolor [STEPbackgroundcolor] [s=.9]
+
+\newtoks\everySTEPchart
+
+\unexpanded\def\startSTEPchart
+ {\begingroup
+ \dodoubleempty\start_STEP_chart}
+
+\def\start_STEP_chart[#name][#settings]%
+ {\startnointerference
+ \iffirstargument
+ \doifassignmentelse{#name}
+ {\let\currentSTEPchart\empty
+ \xdef\flush_STEP_chart{\STEP_chart[][#name]}}
+ {\edef\currentSTEPchart{#name}%
+ \glet\flush_STEP_chart\relax}% settings are not stored
+ \else
+ \let\currentSTEPchart\empty
+ \gdef\flush_STEP_chart{\STEP_chart[][]}%
+ \fi
+ \the\everySTEPchart
+ \ctxcommand{step_start_chart("\currentSTEPchart")}}
+
+\unexpanded\def\stopSTEPchart
+ {\ctxcommand{step_stop_chart()}%
+ \stopnointerference
+ \flush_STEP_chart
+ \endgroup}
+
+\unexpanded\def\startSTEPtable
+ {\begingroup
+ \setupSTEPchart[\c!alternative=\v!vertical]%
+ \dodoubleempty\start_STEP_chart}
+
+\let\stopSTEPtable\stopSTEPchart
+
+\let\flush_STEP_chart\relax
+
+\unexpanded\def\STEPchart
+ {\dodoubleempty\STEP_chart}
+
+\unexpanded\def\STEP_chart[#name][#settings]%
+ {\begingroup
+ \setupSTEPchart[#settings]%
+ \ifinsidefloat
+ \makeSTEPchart[#name]%
+ \else
+ \STEPchartparameter\c!before
+ \startbaselinecorrection
+ \setlocalhsize
+ \makeSTEPchart[#name]%
+ \stopbaselinecorrection
+ \STEPchartparameter\c!after
+ \fi
+ \endgroup}
+
+\unexpanded\def\makeSTEPchart[#name]%
+ {\ctxcommand{step_make_chart {
+ chart = {
+ name = "#name",
+ alternative = "\STEPchartparameter\c!alternative",
+ },
+ cell = {
+ alternative = "\STEPcellparameter\c!alternative", % TODO: shapes
+ offset = \number\dimexpr\STEPcellparameter\c!offset,
+ rulethickness = \number\dimexpr\STEPcellparameter\c!rulethickness,
+ framecolor = "\STEPcellparameter\c!framecolor",
+ backgroundcolor = "\STEPcellparameter\c!backgroundcolor",
+ dx = \number\dimexpr\STEPcellparameter\c!dx,
+ dy = \number\dimexpr\STEPcellparameter\c!dy,
+ },
+ text = {
+ alternative = "\STEPtextparameter\c!alternative", % TODO: shapes
+ offset = \number\dimexpr\STEPtextparameter\c!offset,
+ distance = \number\dimexpr\STEPtextparameter\c!distance,
+ rulethickness = \number\dimexpr\STEPtextparameter\c!rulethickness,
+ framecolor = "\STEPtextparameter\c!framecolor",
+ backgroundcolor = "\STEPtextparameter\c!backgroundcolor",
+ },
+ line = {
+ alternative = "\STEPlineparameter\c!alternative", % TODO: dash, arrow
+ rulethickness = \number\dimexpr\STEPlineparameter\c!rulethickness,
+ height = \number\dimexpr\STEPlineparameter\c!height,
+ distance = \number\dimexpr\STEPlineparameter\c!distance,
+ offset = \number\dimexpr\STEPlineparameter\c!offset,
+ color = "\STEPlineparameter\c!color",
+ },
+ }}}
+
+\unexpanded\def\startSTEPcell
+ {\ctxcommand{step_start_cell()}}
+
+\unexpanded\def\stopSTEPcell
+ {\ctxcommand{step_stop_cell()}}
+
+\unexpanded\def\step_cells#top#bot%
+ {\ctxcommand{step_cells(\!!bs\detokenize{#top}\!!es,\!!bs\detokenize{#bot}\!!es)}}
+
+\unexpanded\def\step_texts#top#bot%
+ {\ctxcommand{step_texts(\!!bs\detokenize{#top}\!!es,\!!bs\detokenize{#bot}\!!es)}}
+
+\unexpanded\def\step_cell#str%
+ {\ctxcommand{step_cell(\!!bs\detokenize{#str}\!!es)}}
+
+\unexpanded\def\step_text#str%
+ {\ctxcommand{step_text(\!!bs\detokenize{#str}\!!es)}}
+
+\unexpanded\def\step_textset#left#middle#right%
+ {\ctxcommand{step_textset(\!!bs\detokenize{#left}\!!es,\!!bs\detokenize{#middle}\!!es,\!!bs\detokenize{#right}\!!es)}}
+
+\unexpanded\def\step_toptext#top%
+ {\ctxcommand{step_text_top(\!!bs\detokenize{#top}\!!es)}}
+
+\unexpanded\def\step_bottext#bot%
+ {\ctxcommand{step_text_bot(\!!bs\detokenize{#bot}\!!es)}}
+
+\unexpanded\def\step_topcell#top%
+ {\ctxcommand{step_cell_top(\!!bs\detokenize{#top}\!!es)}}
+
+\unexpanded\def\step_botcell#bot%
+ {\ctxcommand{step_cell_bot(\!!bs\detokenize{#bot}\!!es)}}
+
+\appendtoks
+ \let\cells \step_cells
+ \let\texts \step_texts
+ \let\cell \step_cell
+ \let\text \step_text
+ \let\textset\step_textset
+ \let\toptext\step_toptext
+ \let\bottext\step_bottext
+ \let\topcell\step_topcell
+ \let\botcell\step_botcell
+\to \everySTEPchart
+
+% todo: mapping can be done in lua
+
+\startxmlsetups xml:step:define
+ \xmlsetsetup{#1} {stepchart|steptable} {xml:step:*}
+\stopxmlsetups
+
+\xmlregistersetup{xml:step:define}
+
+\startxmlsetups xml:step:stepchart
+ \startSTEPchart
+ \xmlfilter{#1}{/(cells|texts|stepcell|cell|text)/command(xml:step:*)}
+ \stopSTEPchart
+\stopxmlsetups
+
+\startxmlsetups xml:step:steptable
+ \startSTEPtable
+ \xmlfilter{#1}{/(cells|texts|stepcell|cell|text)/command(xml:step:*)}
+ \stopSTEPtable
+\stopxmlsetups
+
+\startxmlsetups xml:step:cells
+ \cells {\xmltext{#1}{/top}} {\xmltext{#1}{/bot}}
+\stopxmlsetups
+
+\startxmlsetups xml:step:texts
+ \texts {\xmltext{#1}{/top}} {\xmltext{#1}{/bot}}
+\stopxmlsetups
+
+\startxmlsetups xml:step:stepcell
+ \cells {\xmltext{#1}{/topcell}} {\xmltext{#1}{/botcell}}
+ \texts {\xmltext{#1}{/toptext}} {\xmltext{#1}{/bottext}}
+\stopxmlsetups
+
+\startxmlsetups xml:step:cell
+ \cell {\xmlflush{#1}}
+\stopxmlsetups
+
+\startxmlsetups xml:step:text
+ \text {\xmlflush{#1}}
+\stopxmlsetups
+
+\protect
+
+\continueifinputfile{m-steps.mkvi}
+
+\starttext
+
+\startbuffer
+<stepchart>
+ <cell> some cell </cell>
+ <text> some text </text>
+ <cell> some cell </cell>
+ <text> some text </text>
+ <cell> some cell </cell>
+</stepchart>
+\stopbuffer
+
+\typebuffer \processxmlbuffer
+
+
+\startbuffer
+<steptable>
+ <cell> some cell </cell>
+ <text> some text </text>
+ <cell> some cell </cell>
+ <text> some text </text>
+ <cell> some cell </cell>
+</steptable>
+\stopbuffer
+
+\typebuffer \processxmlbuffer
+
+\page
+
+\startSTEPchart
+ \cells {A} {B}
+ \cells {one} {five} \texts{$+2$}{$-2$}
+ \cells {two} {four} \texts{$+3$}{$-3$}
+ \cells {three} {three} \texts{$+4$}{$-4$}
+ \cells {four} {two} \texts{$+5$}{$-5$}
+ \cells {five} {one}
+\stopSTEPchart
+
+\startSTEPtable
+ \cell {one} \textset{$x$} {=}{$a+b+c$}
+ \cell {two} \textset{$c+d$}{=}{$y$}
+ \cell {three}
+\stopSTEPtable
+
+
+\page
+
+\startbuffer
+<stepchart>
+ <cells> <top> some text </top> <bot> some text </bot> </cells>
+ <texts> <top> text </top> <bot> text </bot> </texts>
+ <cells> <top> some text </top> <bot> some text </bot> </cells>
+</stepchart>
+\stopbuffer
+
+\processxmlbuffer
+
+\startbuffer
+<stepchart>
+ <cell> some text </cell>
+ <texts> <top> text </top> <bot> text </bot> </texts>
+ <cell> some text </cell>
+</stepchart>
+\stopbuffer
+
+\processxmlbuffer
+
+\page
+
+\startSTEPchart[second]
+ \startSTEPcell
+ \topcell {A}
+ \botcell {B}
+ \startSTEPcell
+ \topcell {one}
+ \botcell {five}
+ \toptext {$+2$}
+ \bottext {$-2$}
+ \stopSTEPcell
+ \startSTEPcell
+ \topcell {two}
+ \botcell {four}
+ \toptext {$+3$}
+ \bottext {$-3$}
+ \stopSTEPcell
+ \startSTEPcell
+ \topcell {three}
+ \botcell {three}
+ \toptext {$+4$}
+ \bottext {$-4$}
+ \stopSTEPcell
+ \startSTEPcell
+ \topcell {four}
+ \botcell {two}
+ \toptext {$+5$}
+ \bottext {$-5$}
+ \stopSTEPcell
+ \startSTEPcell
+ \topcell {five}
+ \botcell {one}
+ \stopSTEPcell
+\stopSTEPchart
+
+\STEPchart[first][alternative=horizontal]
+\STEPchart[first][alternative=vertical]
+
+\page
+
+\STEPchart[second][alternative=horizontal]
+\STEPchart[second][alternative=vertical]
+
+\page
+
+\stoptext
diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf
index 38f7b8132..a4c56c6f8 100644
--- a/tex/context/base/status-files.pdf
+++ b/tex/context/base/status-files.pdf
Binary files differ
diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf
index 10704da13..964cabb11 100644
--- a/tex/context/base/status-lua.pdf
+++ b/tex/context/base/status-lua.pdf
Binary files differ
diff --git a/tex/context/base/x-steps.mkiv b/tex/context/base/x-steps.mkiv
deleted file mode 100644
index d60524338..000000000
--- a/tex/context/base/x-steps.mkiv
+++ /dev/null
@@ -1,99 +0,0 @@
-%D \module
-%D [ file=m-steps,
-%D version=2001.05.28,
-%D title=\CONTEXT\ Modules,
-%D subtitle=Step Charts \& Tables,
-%D author=Hans Hagen,
-%D date=\currentdate,
-%D copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
-%C
-%C This module is part of the \CONTEXT\ macro||package and is
-%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
-%C details.
-
-%D The \XML\ interface. This module can be made way more efficient
-%D in \MKIV\ using textext but it makes only sense to do this when
-%D I really need it in a demanding application. Probably half of the
-%D code in m-steps.tex can go.
-
-\usemodule[m][steps]
-
-\unprotect
-
-\def\xmlstepchartdirective#1{\executeifdefined{@@stepchart@@#1}\gobbletwoarguments} % {#2}{#3}
-\def\xmlsteptabledirective#1{\executeifdefined{@@steptable@@#1}\gobbletwoarguments} % {#2}{#3}
-
-\setvalue{@@stepchart@@charts}{\setsomevalue\@@STPC}
-\setvalue{@@stepchart@@cells}{\setsomevalue\@@STEC}
-\setvalue{@@stepchart@@texts}{\setsomevalue\@@STET}
-\setvalue{@@stepchart@@lines}{\setsomevalue\@@STEL}
-
-\setvalue{@@steptable@@tables}{\setsomevalue\@@STPT}
-\setvalue{@@steptable@@cells}{\setsomevalue\@@STEC}
-\setvalue{@@steptable@@texts}{\setsomevalue\@@STET}
-\setvalue{@@steptable@@lines}{\setsomevalue\@@STEL}
-
-\startxmlsetups xml:ct:define
- \xmlsetsetup {#1} {ct:*} {xml:ct:*}
- \xmlsetsetup {#1} {ct:stepaligntable/cells} {xml:ct:stepaligntable:cells}
- \xmlsetsetup {#1} {ct:stepaligntable/lines} {xml:ct:stepaligntable:lines}
-\stopxmlsetups
-
-\xmlregisterns{ct}{stepcharts}
-
-\xmlregistersetup{xml:ct:define}
-
-\startxmlsetups xml:ct:prep
- \expanded{\prep[\xmltoparameters{#1}]}{\xmlflush{#1}}
-\stopxmlsetups
-
-\startxmlsetups xml:ct:text
- \expanded{\text[\xmltoparameters{#1}]}{\xmlflush{#1}}
-\stopxmlsetups
-
-\startxmlsetups xml:ct:texts
- \expanded{\texts[\xmltoparameters{#1}]}{\xmltext{#1}{/top}} {\xmltext{#1}{/bot}}
-\stopxmlsetups
-
-\startxmlsetups xml:ct:cell
- \expanded{\cell[\xmltoparameters{#1}]}{\xmlflush{#1}}
-\stopxmlsetups
-
-\startxmlsetups xml:ct:cells
- \expanded{\cells[\xmltoparameters{#1}]}{\xmltext{#1}{/top}} {\xmltext{#1}{/bot}}
-\stopxmlsetups
-
-\startxmlsetups xml:ct:lines
- \expanded{\startlines[\xmltoparameters{#1}]}
- \xmlflush{#1}
- \stoplines
-\stopxmlsetups
-
-\startxmlsetups xml:ct:steptable
- \expanded{\startSTEPtable[\xmltoparameters{#1}]}
- \xmlflush{#1}
- \stopSTEPtable
-\stopxmlsetups
-
-\startxmlsetups xml:ct:stepchart
- \expanded{\startSTEPchart[\xmltoparameters{#1}]}
- \xmlflush{#1}
- \stopSTEPchart
-\stopxmlsetups
-
-\startxmlsetups xml:ct:stepaligntable
- \expanded{\startSTEPaligntable[\xmltoparameters{#1}]}
- \xmlflush{#1}
- \stopSTEPaligntable
-\stopxmlsetups
-
-\startxmlsetups xml:ct:stepaligntable:cells
- \expanded{\cells[\xmltoparameters{#1}]} {\xmltext{#1}{/ct:c1}} {\xmltext{#1}{/ct:c2}} {\xmltext{#1}{/ct:c3}}
-\stopxmlsetups
-
-\startxmlsetups xml:ct:stepaligntable:lines
- \expanded{\setupSTEPlines[\xmltoparameters{#1}]}
- \xmlflush{#1}
-\stopxmlsetups
-
-\protect \endinput
diff --git a/tex/generic/context/luatex/luatex-fonts-merged.lua b/tex/generic/context/luatex/luatex-fonts-merged.lua
index c97bfabf2..9bb0b012a 100644
--- a/tex/generic/context/luatex/luatex-fonts-merged.lua
+++ b/tex/generic/context/luatex/luatex-fonts-merged.lua
@@ -1,6 +1,6 @@
-- merged file : luatex-fonts-merged.lua
-- parent file : luatex-fonts.lua
--- merge date : 10/12/11 16:42:20
+-- merge date : 10/12/11 19:30:11
do -- begin closure to overcome local limits and interference