diff options
author | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-06-25 15:40:51 +0200 |
---|---|---|
committer | Context Git Mirror Bot <phg42.2a@gmail.com> | 2016-06-25 15:40:51 +0200 |
commit | b2a2304cbb0c65040d7b118ac9b857d304e333e6 (patch) | |
tree | ed5212e37a91ec78c12d9f72ca1186a59c139b40 /metapost | |
parent | b2276ae7a04a9f9c35403e508670049d8c3e4b3e (diff) | |
download | context-b2a2304cbb0c65040d7b118ac9b857d304e333e6.tar.gz |
2016-06-25 14:42:00
Diffstat (limited to 'metapost')
-rw-r--r-- | metapost/context/base/mpiv/mp-mlib.mpiv | 39 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-shap.mpiv | 12 | ||||
-rw-r--r-- | metapost/context/base/mpiv/mp-step.mpiv | 364 |
3 files changed, 303 insertions, 112 deletions
diff --git a/metapost/context/base/mpiv/mp-mlib.mpiv b/metapost/context/base/mpiv/mp-mlib.mpiv index ad2338bd0..cac84a6fd 100644 --- a/metapost/context/base/mpiv/mp-mlib.mpiv +++ b/metapost/context/base/mpiv/mp-mlib.mpiv @@ -240,6 +240,32 @@ vardef rawtextext(expr s) = % todo: avoid currentpicture fi enddef ; +vardef validtexbox(expr category, name) = + if category == "" : + false + elseif string name : + name <> "" + elseif numeric name : + name > 0 + else : + true + fi +enddef ; + +vardef rawtexbox(expr category, name) = + mfun_tt_c := nullpicture ; + if validtexbox(category,name) : + mfun_tt_b := lua.mp.tb_dimensions(category, name) ; + addto mfun_tt_c doublepath unitsquare + xscaled redpart mfun_tt_b + yscaled (greenpart mfun_tt_b + bluepart mfun_tt_b) + shifted (0,- bluepart mfun_tt_b) + withprescript "bx_category=" & if numeric category : decimal fi category + withprescript "bx_name=" & if numeric name : decimal fi name ; + fi + mfun_tt_c +enddef ; + % More text defaultfont := "Mono" ; @@ -403,6 +429,19 @@ vardef onetimetextext@#(expr p) = % no draw here thetextext@#(p,origin) enddef ; +vardef thetexbox@#(expr category, name, z) = + save p ; picture p ; p := rawtexbox(category,name) ; + p + if (mfun_labtype@# >= 10) : + shifted (0,ypart center p) + fi + shifted (z + textextoffset*mfun_laboff@# - (mfun_labxf@#*lrcorner p + mfun_labyf@#*ulcorner p + (1-mfun_labxf@#-mfun_labyf@#)*llcorner p)) +enddef ; + +vardef texbox@#(expr category, name) = % no draw here + thetexbox@#(category,name,origin) +enddef ; + vardef thelabel@#(expr p,z) = if string p : thelabel@#(rawtextext("\definedfont[" & defaultfont & "]" & p) scaled defaultscale,z) diff --git a/metapost/context/base/mpiv/mp-shap.mpiv b/metapost/context/base/mpiv/mp-shap.mpiv index 713656510..3e885e585 100644 --- a/metapost/context/base/mpiv/mp-shap.mpiv +++ b/metapost/context/base/mpiv/mp-shap.mpiv @@ -74,6 +74,8 @@ def stop_predefined_shape_definition = enddef ; +% this can be delayed + start_predefined_shape_definition ; predefined_shapes[ 0] := (origin--cycle) ; @@ -143,7 +145,7 @@ start_predefined_shape_definition ; stop_predefined_shape_definition ; vardef some_shape_path (expr type) = - if known predefined_shapes[type] : predefined_shapes[type] else : predefined_shapes[0] fi + if known predefined_shapes[type] : predefined_shapes[type] else : predefined_shapes[24] fi enddef ; def some_shape (expr shape_type, shape_width, shape_height, shape_linewidth, shape_linecolor, shape_fillcolor) = @@ -156,6 +158,14 @@ def some_shape (expr shape_type, shape_width, shape_height, shape_linewidth, sha endgroup ; enddef ; +% maybe: +% +% if t>1 : % normal shape +% path pp ; pp := some_shape_path(t) xyscaled(bbwidth(p), bbheight(p)) ; +% pp := pp shifted - center pp shifted center p ; +% fill pp withcolor fc ; +% draw pp withpen pencircle scaled lw withcolor lc ; + vardef drawpredefinedshape (expr t, p, lw, lc, fc) = save pp ; if t>1 : % normal shape diff --git a/metapost/context/base/mpiv/mp-step.mpiv b/metapost/context/base/mpiv/mp-step.mpiv index f7a7ba5de..27bcffcdc 100644 --- a/metapost/context/base/mpiv/mp-step.mpiv +++ b/metapost/context/base/mpiv/mp-step.mpiv @@ -23,7 +23,9 @@ def initialize_step_variables = 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 ; + nofcells, chart_vertical, chart_align, chart_category ; + + string chart_category ; chart_category := "" ; color text_line_color ; text_line_color := red ; color cell_line_color ; cell_line_color := blue ; @@ -49,6 +51,7 @@ def initialize_step_variables = numeric text_distance_set ; text_distance_set := 4pt ; boolean chart_vertical ; chart_vertical := false ; + boolean chart_align ; chart_align := false ; numeric nofcells ; nofcells := 0 ; @@ -56,17 +59,17 @@ enddef ; def step_cells (expr t, b) = nofcells := nofcells + 1 ; - cells_t[nofcells] := textext.d(t) ; - cells_b[nofcells] := textext.d(b) ; + cells_t[nofcells] := texbox.d(chart_category,t) ; + cells_b[nofcells] := texbox.d(chart_category,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) ; +def step_texts (expr t, m, b) = + texts_t[nofcells] := texbox.d(chart_category,t) ; + texts_m[nofcells] := texbox.d(chart_category,m) ; + texts_b[nofcells] := texbox.d(chart_category,b) ; enddef ; def step_begin_cell = @@ -81,11 +84,66 @@ 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 ; +% maybe: texbox.d + +def step_cell_top (expr t, c, f, l, s) = + cells_t[nofcells] := texbox.d(chart_category,t) ; + cell_top_colors[nofcells] := c ; + cell_top_fills [nofcells] := f ; + cell_top_lines [nofcells] := l ; + cell_top_shapes[nofcells] := s ; +enddef ; + +def step_cell_bot (expr b, c, f, l, s) = + cells_b[nofcells] := texbox.d(chart_category,b) ; + cell_bot_colors[nofcells] := c ; + cell_bot_fills [nofcells] := f ; + cell_bot_lines [nofcells] := l ; + cell_bot_shapes[nofcells] := s ; +enddef ; + +def step_cell_ali (expr ca, cb, cc, c, f, l, s) = + cells_a[nofcells][1] := texbox.d(chart_category,ca) ; + cells_a[nofcells][2] := texbox.d(chart_category,cb) ; + cells_a[nofcells][3] := texbox.d(chart_category,cc) ; + cell_top_colors[nofcells] := c ; + cell_top_fills [nofcells] := f ; + cell_top_lines [nofcells] := l ; + cell_top_shapes[nofcells] := s ; +enddef ; + +def step_text_top (expr t, tc, tf, tl, ts, lc, ll, ls) = + texts_t[nofcells] := texbox.d(chart_category,t) ; + text_top_colors[nofcells] := tc ; + text_top_fills [nofcells] := tf ; + text_top_lines [nofcells] := tl ; + text_top_shapes[nofcells] := ts ; + line_top_colors[nofcells] := lc ; + line_top_lines [nofcells] := ll ; + line_top_shapes[nofcells] := ls ; +enddef ; + +def step_text_mid (expr m, tc, tf, tl, ts, lc, ll, ls) = + texts_m[nofcells] := texbox.d(chart_category,m) ; + text_mid_colors[nofcells] := tc ; + text_mid_fills [nofcells] := tf ; + text_mid_lines [nofcells] := tl ; + text_mid_shapes[nofcells] := ts ; + line_mid_colors[nofcells] := lc ; + line_mid_lines [nofcells] := ll ; + line_mid_shapes[nofcells] := ls ; +enddef ; + +def step_text_bot (expr b, tc, tf, tl, ts, lc, ll, ls) = + texts_b[nofcells] := texbox.d(chart_category,b) ; + text_bot_colors[nofcells] := tc ; + text_bot_fills [nofcells] := tf ; + text_bot_lines [nofcells] := tl ; + text_bot_shapes[nofcells] := ts ; + line_bot_colors[nofcells] := lc ; + line_bot_lines [nofcells] := ll ; + line_bot_shapes[nofcells] := ls ; +enddef ; def step_begin_chart = begingroup ; @@ -93,6 +151,44 @@ def step_begin_chart = 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[] ; + save start_t, start_m, start_b ; numeric start_t[], start_m[], start_b[] ; + save cells_a ; picture cells_a[][] ; + + save cell_top_colors ; color cell_top_colors[] ; + save cell_bot_colors ; color cell_bot_colors[] ; + save text_top_colors ; color text_top_colors[] ; + save text_mid_colors ; color text_mid_colors[] ; + save text_bot_colors ; color text_bot_colors[] ; + + save cell_top_fills ; color cell_top_fills[] ; + save cell_bot_fills ; color cell_bot_fills[] ; + save text_top_fills ; color text_top_fills[] ; + save text_mid_fills ; color text_mid_fills[] ; + save text_bot_fills ; color text_bot_fills[] ; + + save cell_top_lines ; numeric cell_top_lines[] ; + save cell_bot_lines ; numeric cell_bot_lines[] ; + save text_top_lines ; numeric text_top_lines[] ; + save text_mid_lines ; numeric text_mid_lines[] ; + save text_bot_lines ; numeric text_bot_lines[] ; + + save cell_top_shapes ; numeric cell_top_shapes[] ; + save cell_bot_shapes ; numeric cell_bot_shapes[] ; + save text_top_shapes ; numeric text_top_shapes[] ; + save text_mid_shapes ; numeric text_mid_shapes[] ; + save text_bot_shapes ; numeric text_bot_shapes[] ; + + save line_top_lines ; numeric line_top_lines[] ; + save line_mid_lines ; numeric line_mid_lines[] ; + save line_bot_lines ; numeric line_bot_lines[] ; + + save line_top_colors ; color line_top_colors[] ; + save line_mid_colors ; color line_mid_colors[] ; + save line_bot_colors ; color line_bot_colors[] ; + + save line_top_shapes ; numeric line_top_shapes[] ; + save line_mid_shapes ; numeric line_mid_shapes[] ; + save line_bot_shapes ; numeric line_bot_shapes[] ; enddef ; def step_end_chart = @@ -106,6 +202,7 @@ def step_end_chart = 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 ; + save alternative ; numeric alternative ; % check rows one_row_only := true ; for i=1 upto nofcells : @@ -113,18 +210,43 @@ def step_end_chart = one_row_only := false ; fi ; endfor ; + % + if chart_align : + save size, delta, width ; numeric size[], delta[], width[] ; + for i=1 upto 3: + size[i] = 0 ; + for c=1 upto nofcells : + size[i] := max(size[i],bbwidth(cells_a[c][i])) ; + endfor ; + endfor ; + for c=1 upto nofcells : + cells_t[c] := image ( + for i=1 upto 3: + width[i] := bbwidth(cells_a[c][i]); + delta[i] := size[i] - width[i] ; + endfor; + setbounds cells_a[c][1] to boundingbox(cells_a[c][1]) leftenlarged (delta[1]) ; + setbounds cells_a[c][2] to boundingbox(cells_a[c][2]) leftenlarged (delta[2]/2) + rightenlarged(delta[2]/2) ; + setbounds cells_a[c][3] to boundingbox(cells_a[c][3]) rightenlarged(delta[3]) ; + cells_a[c][1] := cells_a[c][1] shifted (- width[1]/2 - size[2]/2 - text_distance_set,0) ; + cells_a[c][3] := cells_a[c][3] shifted ( width[3]/2 + size[2]/2 + text_distance_set,0) ; + for i=1 upto 3: + draw cells_a[c][i] ; + % draw boundingbox cells_a[c][i] ; + endfor ; + ) ; + endfor ; + fi ; % 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 ; + max_width_t := max(max_width_t,bbwidth(texts_t[i])); + max_width_m := max(max_width_m,bbwidth(texts_m[i])); + max_width_b := max(max_width_b,bbwidth(texts_b[i])); endfor ; if max_width_m > 0 : for i=1 upto nofcells : @@ -132,14 +254,17 @@ def step_end_chart = 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) ; + 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) ; + setbounds text_m to boundingbox text_m + leftenlarged ((max_width_m - width_m)/2) + 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) ; + 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) ; @@ -161,6 +286,7 @@ def step_end_chart = fi ; else : for i=1 upto nofcells : + % swaps so we need a scratch variable cell_t := cells_t[i] ; cell_b := cells_b[i] ; cells_t[i] := cell_b rotated 90 ; @@ -174,39 +300,31 @@ def step_end_chart = 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) ; + width_t := bbwidth(cells_t[i]) ; + width_b := bbwidth(cells_b[i]) ; 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 ; + setbounds cells_t[i] to boundingbox cells_t[i] leftenlarged delta rightenlarged delta ; 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 ; + setbounds cells_b[i] to boundingbox cells_b[i] leftenlarged delta rightenlarged delta ; 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) ; + height_t := bbheight(cells_t[i]) ; + height_b := bbheight(cells_b[i]) ; if height_t > 0 : - setbounds cell_t to boundingbox cell_t enlarged cell_offset ; + setbounds cells_t[i] to boundingbox cells_t[i] 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 ; + setbounds cells_b[i] to boundingbox cells_b[i] 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 ; @@ -217,34 +335,24 @@ def step_end_chart = 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) ; + height_t := bbheight(cells_t[i]) ; + height_b := bbheight(cells_b[i]) ; if height_t > 0 : delta := (max_height_t-height_t)/2 ; - setbounds cell_t to boundingbox cell_t topenlarged delta bottomenlarged delta ; + setbounds cells_t[i] to boundingbox cells_t[i] 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 ; + setbounds cells_b[i] to boundingbox cells_b[i] 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) ; + cells_t[i] := cells_t[i] shifted -llcorner cells_t[i] shifted (dx, 0) ; + cells_b[i] := cells_b[i] shifted -llcorner cells_b[i] shifted (dx,-cell_distance_y-max_height_b) ; + width_t := bbwidth(cells_t[i]) ; + width_b := bbwidth(cells_b[i]) ; if width_t > 0 : dx := dx + cell_distance_x + width_t ; elseif width_b > 0 : @@ -253,19 +361,27 @@ def step_end_chart = 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) ; + width_t := bbwidth(cells_t[i]) ; + width_b := bbwidth(cells_b[i]) ; 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 ; + drawpredefinedshape ( + if known cell_top_shapes[i] : cell_top_shapes[i] else : 24 fi, + cells_t[i], + if known cell_top_lines [i] : cell_top_lines [i] else : cell_line_width fi, + if known cell_top_colors[i] : cell_top_colors[i] else : cell_line_color fi, + if known cell_top_fills [i] : cell_top_fills [i] else : cell_fill_color fi + ) ; + draw cells_t[i] ; 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 ; + drawpredefinedshape ( + if known cell_bot_shapes[i] : cell_bot_shapes[i] else : 24 fi, + cells_b[i], + if known cell_bot_lines [i] : cell_bot_lines [i] else : cell_line_width fi, + if known cell_bot_colors[i] : cell_bot_colors[i] else : cell_line_color fi, + if known cell_bot_fills [i] : cell_bot_fills [i] else : cell_fill_color fi + ) ; + draw cells_b[i] ; fi ; endfor ; % @@ -273,54 +389,58 @@ def step_end_chart = 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 ; + if bbwidth(texts_t[i]) > 0 : + setbounds texts_t[i] to boundingbox texts_t[i] enlarged text_offset ; fi ; - if bbwidth(text_b) > 0 : - setbounds text_b to boundingbox text_b enlarged text_offset ; - texts_b[i] := text_b ; + if bbwidth(texts_b[i]) > 0 : + setbounds texts_b[i] to boundingbox texts_b[i] enlarged text_offset ; 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) ; + t_a := midtopboundary cells_t[i] ; + t_b := midtopboundary cells_t[i+1] ; if one_row_only : - b_a := midbottomboundary cell_t ; - b_b := midbottomboundary next_t ; + b_a := midbottomboundary cells_t[i] ; + b_b := midbottomboundary cells_t[i+1] ; else : - b_a := midbottomboundary cell_b ; - b_b := midbottomboundary next_b ; + b_a := midbottomboundary cells_b[i] ; + b_b := midbottomboundary cells_b[i+1] ; fi ; + t_c := (xpart 0.5[t_a,t_b], ypart t_a+line_height+line_distance) ; 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] ; + cell_t := cells_t[start_t[i]] ; + cell_b := cells_b[start_b[i]] ; + next_t := cells_t[i+1] ; + next_b := cells_b[i+1] ; 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 ; + alternative := if known line_top_shapes[i] : line_top_shapes[i] else : 1 fi ; + if (alternative = 1) or (alternative = 2) : drawarrow else : draw fi + 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) + if (alternative = 2) or (alternative = 4) : + dashed evenly scaled ( + if known line_top_lines [i] : line_top_lines [i] else : line_line_width fi + ) + fi + withpen pencircle scaled + if known line_top_lines [i] : line_top_lines [i] else : line_line_width fi + withcolor + if known line_top_colors[i] : line_top_colors[i] else : line_line_color fi + ; else : fi ; fi ; @@ -330,29 +450,49 @@ def step_end_chart = 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 ; + alternative := if known line_bot_shapes[i] : line_bot_shapes[i] else : 1 fi ; + if (alternative = 1) or (alternative = 2) : drawarrow else : draw fi + 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) + if (alternative = 2) or (alternative = 4) : + dashed evenly scaled ( + if known line_top_lines [i] : line_top_lines [i] else : line_line_width fi + ) + fi + withpen pencircle scaled + if known line_bot_lines [i] : line_bot_lines [i] else : line_line_width fi + withcolor + if known line_bot_colors[i] : line_bot_colors[i] else : line_line_color fi + ; 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 ; + if bbwidth(texts_t[i]) > 0 : + drawpredefinedshape ( + if known text_top_shapes[i] : text_top_shapes[i] else : 24 fi, + texts_t[i], + if known text_top_lines [i] : text_top_lines [i] else : text_line_width fi, + if known text_top_colors[i] : text_top_colors[i] else : text_line_color fi, + if known text_top_fills [i] : text_top_fills [i] else : text_fill_color fi + ) ; + draw texts_t[i] ; 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 ; + if bbwidth(texts_b[i]) > 0 : + drawpredefinedshape ( + if known text_bot_shapes[i] : text_bot_shapes[i] else : 24 fi, + texts_b[i], + if known text_bot_lines [i] : text_bot_lines [i] else : text_line_width fi, + if known text_bot_colors[i] : text_bot_colors[i] else : text_line_color fi, + if known text_bot_fills [i] : text_bot_fills [i] else : text_fill_color fi + ) ; + draw texts_b[i] ; fi ; endfor ; if chart_vertical : @@ -362,6 +502,8 @@ def step_end_chart = endgroup ; enddef ; +% no longer working .. will do someday +% % start_begin_step ; % step_cells ("\strut test 0", "\strut test 0") ; % step_cells ("\strut test 1", "\vbox{\hsize3cm \strut oeps 1\crlf oeps 1}") ; |