From 8a0955ab5eeca9a92da85f75749d4180519f2c29 Mon Sep 17 00:00:00 2001 From: Marius Date: Wed, 12 Oct 2011 20:40:14 +0300 Subject: beta 2011.10.12 19:30 --- tex/context/base/anch-pos.mkiv | 4 - tex/context/base/cont-new.mkii | 2 +- tex/context/base/cont-new.mkiv | 2 +- tex/context/base/context-version.pdf | Bin 4095 -> 4095 bytes tex/context/base/context-version.png | Bin 106412 -> 106290 bytes tex/context/base/context.mkii | 2 +- tex/context/base/context.mkiv | 2 +- tex/context/base/m-chart.lua | 619 +++++++++ tex/context/base/m-chart.mkii | 2 +- tex/context/base/m-chart.mkiv | 1328 -------------------- tex/context/base/m-chart.mkvi | 477 +++++++ tex/context/base/m-flow.lua | 619 --------- tex/context/base/m-flow.mkvi | 477 ------- tex/context/base/m-steps.lua | 227 ++++ tex/context/base/m-steps.mkii | 837 ++++++++++++ tex/context/base/m-steps.mkvi | 382 ++++++ tex/context/base/m-steps.tex | 837 ------------ tex/context/base/status-files.pdf | Bin 23931 -> 23918 bytes tex/context/base/status-lua.pdf | Bin 163361 -> 163358 bytes tex/context/base/x-steps.mkiv | 99 -- tex/generic/context/luatex/luatex-fonts-merged.lua | 2 +- 21 files changed, 2548 insertions(+), 3370 deletions(-) create mode 100644 tex/context/base/m-chart.lua delete mode 100644 tex/context/base/m-chart.mkiv create mode 100644 tex/context/base/m-chart.mkvi delete mode 100644 tex/context/base/m-flow.lua delete mode 100644 tex/context/base/m-flow.mkvi create mode 100644 tex/context/base/m-steps.lua create mode 100644 tex/context/base/m-steps.mkii create mode 100644 tex/context/base/m-steps.mkvi delete mode 100644 tex/context/base/m-steps.tex delete mode 100644 tex/context/base/x-steps.mkiv (limited to 'tex') 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 Binary files a/tex/context/base/context-version.pdf and b/tex/context/base/context-version.pdf differ diff --git a/tex/context/base/context-version.png b/tex/context/base/context-version.png index 064aade26..44759631d 100644 Binary files a/tex/context/base/context-version.png and b/tex/context/base/context-version.png 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-chart.lua b/tex/context/base/m-chart.lua new file mode 100644 index 000000000..acb41399e --- /dev/null +++ b/tex/context/base/m-chart.lua @@ -0,0 +1,619 @@ +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.charts = moduledata.charts or { } + +local gsub, match, find, format, lower = string.gsub, string.match, string.find, string.format, string.lower +local lpegmatch = lpeg.match + +local points = number.points +local variables = interfaces.variables + +local defaults = { + chart = { + name = "", + option = "", + backgroundcolor = "", + width = 0, + height = 0, + dx = 0, + dy = 0, + offset = 0, + bodyfont = "", + dot = "", + }, + shape = { -- FLOS + rulethickness = 65436, + default = "", + framecolor = "green", + backgroundcolor = "yellow", + }, + focus = { -- FLOF + rulethickness = 65436, + framecolor = "red", + backgroundcolor = "yellow", + }, + line = { -- FLOL + rulethickness = 65436, + radius = 65436, + color = "blue", + corner = "", + dash = "", + arrow = "", + offset = "", + }, + set = { -- FLOX + }, + split = { + nx = 3, + ny = 3, + command = "", + marking = "", + before = "", + after = "", + } +} + +local validshapes = { + ["node"] = { kind = "shape", number = 0 }, + ["action"] = { kind = "shape", number = 24 }, + ["procedure"] = { kind = "shape", number = 5 }, + ["product"] = { kind = "shape", number = 12 }, + ["decision"] = { kind = "shape", number = 14 }, + ["archive"] = { kind = "shape", number = 19 }, + ["loop"] = { kind = "shape", number = 35 }, + ["wait"] = { kind = "shape", number = 6 }, + ["subprocedure"] = { kind = "shape", number = 20 }, + ["singledocument"] = { kind = "shape", number = 32 }, + ["multidocument"] = { kind = "shape", number = 33 }, + + ["right"] = { kind = "line", number = 66 }, + ["left"] = { kind = "line", number = 67 }, + ["up"] = { kind = "line", number = 68 }, + ["down"] = { kind = "line", number = 69 }, +} + +local validlabellocations = { + l = "l", left = "l", + r = "r", right = "r", + t = "t", top = "t", + b = "b", bottom = "b", +} + +table.setmetatableindex(validshapes,function(t,k) + local l = gsub(lower(k)," ","") + local v = rawget(t,l) + if not v then + local n = tonumber(k) + if n then + v = { kind = "shape", number = n } + else + v = rawget(t,"action") + end + end + t[k] = v + return v +end) + +local charts = { } + +local data, hash, temp, last_x, last_y, name + +function commands.flow_start_chart(chartname) + data = { } + hash = { } + last_x, last_y = 0, 0 + name = chartname +end + +function commands.flow_stop_chart() + charts[name] = { + data = data, + hash = hash, + last_x = last_x, + last_y = last_y, + } + data, hash, temp = nil, nil, nil +end + +function commands.flow_set_current_cell(n) + temp = data[tonumber(n)] or { } +end + +function commands.flow_start_cell(settings) + temp = { + labels = { }, + comments = { }, + exits = { }, + connections = { }, + settings = settings, + } +end + +function commands.flow_stop_cell() + data[#data+1] = temp + hash[temp.name or #data] = temp +end + +function commands.flow_set_name(str) + temp.name = str +end + +function commands.flow_set_shape(str) + temp.shape = str +end + +function commands.flow_set_destination(str) + temp.destination = str +end + +function commands.flow_set_text(align,str) + temp.align = align + temp.text = str +end + +function commands.flow_set_overlay(str) + temp.overlay = str +end + +function commands.flow_set_focus(str) + temp.focus = str +end + +function commands.flow_set_figure(str) + temp.figure = str +end + +function commands.flow_set_label(location,text) + temp.labels[#temp.labels+1] = { + location = location, + text = text, + } +end + +function commands.flow_set_comment(name,str) + temp.comments[#temp.comments+1] = { + location = location, + text = text, + } +end + +function commands.flow_set_exit(location,text) + temp.exits[#temp.exits+1] = { + location = location, + text = text, + } +end + +function commands.flow_set_include(name,x,y,settings) + data[#data+1] = { + include = name, + x = x, + y = y, + -- settings = settings, + } +end + +local function inject(includedata,data,hash) + local subchart = charts[includedata.include] + if not subchart then + return + end + local subdata = subchart.data + if not subdata then + return + end + local xoffset = (includedata.x or 1) - 1 + local yoffset = (includedata.y or 1) - 1 + local settings = includedata.settings + for i=1,#subdata do + local si = subdata[i] + local t = { + x = si.x + xoffset, + y = si.y + yoffset, + settings = settings, + } + table.setmetatableindex(t,si) + data[#data+1] = t + hash[si.name or #data] = t + end +end + +local function expanded(chart) + local expandeddata = { } + local expandedhash = { } + local expandedchart = { + data = expandeddata, + hash = expandedhash, + } + table.setmetatableindex(expandedchart,chart) + local data = chart.data + local hash = chart.hash + for i=1,#data do + local di = data[i] + if di.include then + inject(di,expandeddata,expandedhash) + else + expandeddata[#expandeddata+1] = di + expandedhash[di.name or #expandeddata] = di + end + end + for i=1,#expandeddata do + local cell = expandeddata[i] + local settings = cell.settings + if not settings then + cell.settings = chart.settings + else + table.setmetatableindex(settings,chart.settings) + end + end + return expandedchart +end + + +local splitter = lpeg.splitat(",") + +function commands.flow_set_location(str) -- handle include differently + -- wrong: delay real x,y, only store relative + local x, y = lpegmatch(splitter,str) + if not x or x == "" then + x = last_x + elseif x == "+" then + x = last_x + 1 + elseif x == "-" then + x = last_x - 1 + elseif find(x,"^[%+%-]") then + x = last_x + (tonumber(x) or 0) + else + x = tonumber(x) + end + if not y or y == "" then + y = last_y + elseif y == "+" then + y = last_y + 1 + elseif x == "-" then + y = last_y - 1 + elseif find(y,"^[%+%-]") then + y = last_y + (tonumber(y) or 0) + else + y = tonumber(y) + end + temp.x = x + temp.y = y + last_x = x + last_y = y +end + +function commands.flow_set_connection(location,displacement,name) + local dx, dy = lpegmatch(splitter,displacement) + dx = tonumber(dx) or 1 + dy = tonumber(dy) or 1 + temp.connections[#temp.connections+1] = { + location = location, + dx = dx - 1, + dy = dy - 1, + name = name, + } +end + +local where = { + l = "left", + r = "right", + t = "top", + b = "bottom", +} + +local what = { + ["p"] = 1, + ["m"] = -1, + ["+"] = 1, + ["-"] = -1, +} + +local function visible(chart,cell) + local x, y = cell.x, cell.y + return + x >= chart.from_x and x <= chart.to_x and + y >= chart.from_y and y <= chart.to_y and cell +end + +local function check_cells(chart,xoffset,yoffset,min_x,min_y,max_x,max_y) + local data = chart.data + if not data then + return + end + for i=1,#data do + local cell = data[i] + local x, y = cell.x + xoffset, cell.y + yoffset + if min_x == 0 then + min_x, max_x = x, x + min_y, max_y = y, y + else + if x < min_x then min_x = x end + if y < min_y then min_y = y end + if x > max_x then max_x = x end + if y > max_y then max_y = y end + end + end + return min_x, min_y, max_x, max_y +end + +local function process_cells(chart,xoffset,yoffset) + local data = chart.data + if not data then + return + end + for i=1,#data do + local cell = visible(chart,data[i]) + if cell then + local shape = cell.shape + if not shape or shape == "" then + shape = settings.shape.default or "none" + end + if shape ~= variables.none then + local settings = cell.settings + local shapedata = validshapes[shape] + context("flow_begin_sub_chart ;") + if shapedata.kind == "line" then + local linesettings = settings.line + context("flow_shape_line_color := \\MPcolor{%s} ;", linesettings.color) + context("flow_shape_fill_color := \\MPcolor{%s} ;", linesettings.backgroundcolor) + context("flow_shape_line_width := %s ; ", points(linesettingsrulethickness)) + elseif hasfocus then -- doifcommonelse{FLOWcell,FLOWfocus}@@FLOWfocus + local focussettings = settings.focus + context("flow_shape_line_color := \\MPcolor{%s} ;", focussettings.framecolor) + context("flow_shape_fill_color := \\MPcolor{%s} ;", focussettings.backgroundcolor) + context("flow_shape_line_width := %s ; ", points(focussettings.rulethickness)) + else + local shapesettings = settings.shape + context("flow_shape_line_color := \\MPcolor{%s} ;", shapesettings.framecolor) + context("flow_shape_fill_color := \\MPcolor{%s} ;", shapesettings.backgroundcolor) + context("flow_shape_line_width := %s ; " , points(shapesettings.rulethickness)) + end + context("bodyfontsize := 10pt ;") -- todo + context("flow_peepshape := false ;") -- todo + context("flow_new_shape(%s,%s,%s) ;",cell.x+xoffset,cell.y+yoffset,shapedata.number) + context("flow_end_sub_chart ;") + end + end + end +end + +-- todo : make lpeg for splitter + +local function process_connections(chart,xoffset,yoffset) + local data = chart.data + local hash = chart.hash + if not data then + return + end + local settings = chart.settings + for i=1,#data do + local cell = visible(chart,data[i]) + if cell then + local connections = cell.connections + for j=1,#connections do + local connection = connections[j] + local othername = connection.name + local othercell = hash[othername] + if othercell then + local cellx, celly = cell.x, cell.y + local otherx, othery, location = othercell.x, othercell.y, connection.location + if otherx > 0 and othery > 0 and cellx > 0 and celly > 0 and connection.location then + -- move to setter + local what_cell, where_cell, what_other, where_other = match(location,"([%+%-pm]-)([lrtb]),?([%+%-pm]-)([lrtb])") + local what_cell = what [what_cell] or 0 + local what_other = what [what_other] or 0 + local where_cell = where[where_cell] or "left" + local where_other = where[where_other] or "right" + local linesettings = settings.line + context("flow_smooth := %s ;", linesettings.corner == variables.round and "true" or "false") + context("flow_dashline := %s ;", linesettings.dash == variables.yes and "true" or "false") + context("flow_arrowtip := %s ;", linesettings.arrow == variables.yes and "true" or "false") + context("flow_touchshape := %s ;", linesettings.offset == variables.none and "true" or "false") + context("flow_dsp_x := %s ; flow_dsp_y := %s ;",connection.dx or 0, connection.dy or 0) + context("flow_connection_line_color := \\MPcolor{%s} ;",linesettings.color) + context("flow_connection_line_width := 2pt ;",points(linesettings.rulethickness)) + context("flow_connect_%s_%s(%s,%s,%s) (%s,%s,%s) ;",where_cell,where_other,cellx,celly,what_cell,otherx,othery,what_other) + context("flow_dsp_x := 0 ; flow_dsp_y := 0 ;") + end + end + end + end + end +end + +local texttemplate = "\\setvariables[flowcell:text][x=%s,y=%s,text={%s},align={%s},figure={%s},destination={%s}]" + +local function process_texts(chart,xoffset,yoffset) + local data = chart.data + local hash = chart.hash + if not data then + return + end + for i=1,#data do + local cell = visible(chart,data[i]) + if cell then + local x = cell.x or 1 + local y = cell.y or 1 + local text = cell.text + if text and text ~= "" then + local a = cell.align or "" + local f = cell.figure or "" + local d = cell.destination or "" + context('flow_chart_draw_text(%s,%s,textext("%s")) ;',x,y,format(texttemplate,x,y,text,a,f,d)) + end + local labels = cell.labels + for i=1,#labels do + local label = labels[i] + local text = label.text + local location = validlabellocations[label.location or ""] + if text and location then + context('flow_chart_draw_label_%s(%s,%s,textext("%s")) ;',location,x,y,text) + end + end + local exits = cell.exits + for i=1,#exits do + local exit = exits[i] + local text = exit.text + local location = validlabellocations[exit.location or ""] + if text and location then + -- maybe make autoexit an option + if location == "l" and x == chart.from_x + 1 or + location == "r" and x == chart.to_x - 1 or + location == "t" and y == chart.to_y - 1 or + location == "b" and y == chart.from_y + 1 then + context('flow_chart_draw_exit_%s(%s,%s,textext("%s")) ;',location,x,y,text) + end + end + end + local comments = cell.comments + for i=1,#comments do + -- invisible + end + end + end +end + +local function getchart(settings) + local chartname = settings.chart.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 + chart.settings = settings + table.setmetatableindex(settings,defaults) + chart = expanded(chart) + local _, _, nx, ny = check_cells(chart,0,0,0,0,0,0) + chart.from_x = chart.settings.chart.x or 1 + chart.from_y = chart.settings.chart.y or 1 + chart.to_x = chart.settings.chart.nx or nx + chart.to_y = chart.settings.chart.ny or ny + chart.nx = chart.to_x - chart.from_x + 1 + chart.ny = chart.to_y - chart.from_y + 1 + return chart +end + +local function makechart(chart) + local settings = chart.settings + context.begingroup() + context.forgetall() + -- + local bodyfont = settings.chart.bodyfont + if bodyfont ~= "" then + context.switchtobodyfont { bodyfont } + end + -- + context.startMPcode() + 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 + context("flow_show_con_points := true ;") + context("flow_show_mid_points := true ;") + context("flow_show_all_points := true ;") + elseif settings.chart.dot ~= "" then -- no checking done, private option + context("flow_show_%s_points := true ;",settings.chart.dot) + end + -- + local backgroundcolor = settings.chart.backgroundcolor + if backgroundcolor and backgroundcolor ~= "" then + context("flow_chart_background_color := \\MPcolor{%s} ;",backgroundcolor) + end + -- + local shapewidth = settings.chart.width + local gridwidth = shapewidth + 2*settings.chart.dx + local shapeheight = settings.chart.height + local gridheight = shapeheight + 2*settings.chart.dy + context("flow_grid_width := %s ;", points(gridwidth)) + context("flow_grid_height := %s ;", points(gridheight)) + context("flow_shape_width := %s ;", points(shapewidth)) + context("flow_shape_height := %s ;", points(shapeheight)) + -- + local radius = settings.line.radius + local rulethickness = settings.line.rulethickness + local dx = settings.chart.dx + local dy = settings.chart.dy + if radius < rulethickness then + radius = 2.5*rulethickness + if radius > dx then + radius = dx + end + if radius > dy then + radius = dy + end + end + context("flow_connection_line_width := %s ;", points(rulethickness)) + context("flow_connection_smooth_size := %s ;", points(radius)) + context("flow_connection_arrow_size := %s ;", points(radius)) + context("flow_connection_dash_size := %s ;", points(radius)) + -- + local offset = settings.chart.offset -- todo: pass string + if offset == variables.none or offset == variables.overlay or offset == "" then + offset = -2.5 * radius -- or rulethickness? + elseif offset == variables.standard then + offset = radius -- or rulethickness? + end + context("flow_chart_offset := %s ;",points(offset)) + -- + context("flow_reverse_y := true ;") + process_cells(chart,0,0) + process_connections(chart,0,0) + process_texts(chart,0,0) + -- context("clip_chart(%s,%s,%s,%s) ;",x,y,nx,ny) -- todo: draw lines but not shapes + context("flow_end_chart ;") + context.stopMPcode() + context.endgroup() +end + +function commands.flow_make_chart(settings) + local chart = getchart(settings) + if chart then + local settings = chart.settings + if settings.split.state == variables.start then + local nx = chart.settings.split.nx + local ny = chart.settings.split.ny + local x = 1 + while true do + local y = 1 + while true do + -- FLOTbefore + -- doif @@FLOTmarking on -> cuthbox + -- @@FLOTcommand + chart.from_x = x + chart.from_y = y + chart.to_x = math.min(x + nx - 1,chart.nx) + chart.to_y = math.min(x + ny - 1,chart.ny) + makechart(chart) + -- FLOTafter + y = y + ny + if y > chart.max_y then + break + else + y = y - dy + end + end + x = x + nx + if x > chart.max_x then + break + else + x = x - dx + end + end + else + makechart(chart) + end + end +end 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-chart.mkvi b/tex/context/base/m-chart.mkvi new file mode 100644 index 000000000..dc92259d2 --- /dev/null +++ b/tex/context/base/m-chart.mkvi @@ -0,0 +1,477 @@ +%D \module +%D [ file=m-chart, +%D version=2011.10.1, -- 1998.10.10, +%D title=\CONTEXT\ Modules, +%D subtitle=Flow Charts, +%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. + +% todo (if used): +% autofocus={name,name,name} -> min/max +% flowsets +% autoscaling (bodyfontsteps) +% comment +% overlay +% +% todo: +% \useFLOWchart[name][parent][setting,setting][additional settings] +% \useFLOWchart[name][parent][additional settings] +% setups +% mp instance with less files + +\registerctxluafile{m-chart}{} + +\unprotect + +% todo: figure out a nice way to define the lot: share current and +% support current as name (nb: we need to set parent then) + +\def\??flch{@@flch} % chart +\def\??flln{@@flln} % line +\def\??flsh{@@flsh} % shape +\def\??flfc{@@flfc} % focus +\def\??flst{@@flst} % sets +\def\??flsp{@@flsp} % split + +\installsimplecommandhandler \??flch {FLOWchart} \??flch +\installsimplecommandhandler \??flln {FLOWline} \??flln +\installsimplecommandhandler \??flsh {FLOWshape} \??flsh +\installsimplecommandhandler \??flfc {FLOWfocus} \??flfc +\installsimplecommandhandler \??flst {FLOWsets} \??flst +\installsimplecommandhandler \??flsp {FLOWsplit} \??flsp + +\let\setupFLOWcharts\setupFLOWchart +\let\setupFLOWlines \setupFLOWline +\let\setupFLOWshapes\setupFLOWshape +\let\setupFLOWsets \setupFLOWset + +\setupFLOWcharts + [\c!width=12\bodyfontsize, + \c!height=7\bodyfontsize, + \c!offset=0pt, % \v!standard, % == auto offset + \c!dx=2\bodyfontsize, + \c!dy=2\bodyfontsize, + \c!nx=0, + \c!ny=0, + \c!x=1, + \c!y=1, + % \c!maxwidth=, + % \c!maxheight=, + % \c!option=, + % \c!bodyfont=, + % \c!dot=, % private option + % \c!autofocus=, + % \c!focus=, + % \c!background=, + % \c!framecolor= + % \c!backgroundcolor=, % \s!white + \c!rulethickness=\linewidth, + \c!frame=\v!off] + +\setupFLOWlines + [\c!corner=\v!round, + \c!arrow=\v!yes, + \c!dash=\v!no, + \c!radius=.375\bodyfontsize, + \c!color=FLOWlinecolor, + \c!rulethickness=.15\bodyfontsize, + \c!offset=\v!none] + +\setupFLOWshapes + [\c!default=action, + \c!framecolor=FLOWframecolor, + \c!background=\v!color, + \c!backgroundcolor=FLOWbackgroundcolor, + \c!rulethickness=.15\bodyfontsize, + \c!offset=.5\bodyfontsize] + +\setupFLOWfocus + [\c!framecolor=FLOWfocuscolor, + \c!background=\FLOWshapeparameter\c!background, + \c!backgroundcolor=\FLOWshapeparameter\c!backgroundcolor, + \c!backgroundscreen=\FLOWshapeparameter\c!backgroundscreen, + \c!rulethickness=\FLOWshapeparameter\c!rulethickness, + \c!offset=\FLOWshapeparameter\c!offset] + +\setupFLOWsplit + [\c!state=\v!stop, + \c!marking=\v!on, + % \c!command=, + % \c!before=, + % \c!after=, + \c!nx=3, + \c!ny=3] + +\definecolor [FLOWfocuscolor] [s=.2] +\definecolor [FLOWlinecolor] [s=.5] +\definecolor [FLOWframecolor] [s=.7] +\definecolor [FLOWbackgroundcolor] [s=.9] + +\newtoks\everyFLOWchart + +\unexpanded\def\startFLOWchart + {\startnointerference + \the\everyFLOWchart + \dosingleempty\start_FLOW_chart} + +\unexpanded\def\start_FLOW_chart[#name]% + {\ctxcommand{flow_start_chart("#name")}} + +\unexpanded\def\stopFLOWchart + {\ctxcommand{flow_stop_chart()}% + \stopnointerference} + +\unexpanded\def\defineFLOWchart % for old times sake + {\dodoubleempty\define_FLOW_chart} + +\unexpanded\def\define_FLOW_chart[#name][#settings]#cells% todo: save settings + {\startnointerference + \the\everyFLOWchart + \ctxcommand{flow_start_chart("#name")}% + #cells% + \ctxcommand{flow_stop_chart()}% + \stopnointerference} + +\unexpanded\def\startFLOWcell + {\dodoubleempty\start_FLOW_cell} + +\unexpanded\def\start_FLOW_cell[#1][#2]% + {\begingroup + \iffirstargument + \setupFLOWshape[#1]% + \fi + \ifsecondargument + \setupFLOWline[#2]% + \fi + \ctxcommand{flow_start_cell { + shape = { + rulethickness = \number\dimexpr\FLOWshapeparameter\c!rulethickness, + default = "\FLOWshapeparameter\c!default", + framecolor = "\FLOWshapeparameter\c!framecolor", + backgroundcolor = "\FLOWshapeparameter\c!backgroundcolor", + }, + focus = { + rulethickness = \number\dimexpr\FLOWfocusparameter\c!rulethickness, + framecolor = "\FLOWfocusparameter\c!framecolor", + backgroundcolor = "\FLOWfocusparameter\c!backgroundcolor", + }, + line = { + rulethickness = \number\dimexpr\FLOWlineparameter\c!rulethickness, + radius = \number\dimexpr\FLOWlineparameter\c!radius, + color = "\FLOWlineparameter\c!color", + corner = "\FLOWlineparameter\c!corner", + dash = "\FLOWlineparameter\c!dash", + arrow = "\FLOWlineparameter\c!arrow", + offset = "\FLOWlineparameter\c!offset", + }, + } }% + \endgroup} + +\unexpanded\def\stopFLOWcell + {\ctxcommand{flow_stop_cell()}} + +\unexpanded\def\FLOWchart + {\dodoubleempty\FLOW_chart} + +\def\FLOW_chart[#name][#settings]% + {\vbox\bgroup + \insidefloattrue + \dontcomplain + \setupFLOWchart[#settings]% + \ctxcommand{flow_make_chart { + chart = { + name = "#name", + option = "\FLOWchartparameter\c!option", + backgroundcolor = "\FLOWchartparameter\c!backgroundcolor", + width = \number\dimexpr\FLOWchartparameter\c!width, + height = \number\dimexpr\FLOWchartparameter\c!height, + dx = \number\dimexpr\FLOWchartparameter\c!dx, + dy = \number\dimexpr\FLOWchartparameter\c!dy, + offset = \number\dimexpr\FLOWchartparameter\c!offset, + bodyfont = "\FLOWchartparameter\c!bodyfont", + dot = "\FLOWchartparameter\c!dot", % private option + }, + shape = { + rulethickness = \number\dimexpr\FLOWshapeparameter\c!rulethickness, + default = "\FLOWshapeparameter\c!default", + framecolor = "\FLOWshapeparameter\c!framecolor", + backgroundcolor = "\FLOWshapeparameter\c!backgroundcolor", + }, + focus = { + rulethickness = \number\dimexpr\FLOWfocusparameter\c!rulethickness, + framecolor = "\FLOWfocusparameter\c!framecolor", + backgroundcolor = "\FLOWfocusparameter\c!backgroundcolor", + }, + line = { + rulethickness = \number\dimexpr\FLOWlineparameter\c!rulethickness, + radius = \number\dimexpr\FLOWlineparameter\c!radius, + color = "\FLOWlineparameter\c!color", + corner = "\FLOWlineparameter\c!corner", + dash = "\FLOWlineparameter\c!dash", + arrow = "\FLOWlineparameter\c!arrow", + offset = "\FLOWlineparameter\c!offset", + }, + set = { + }, + split = { + state = "\FLOWsplitparameter\c!state", + nx = \number\FLOWsplitparameter\c!nx, + ny = \number\FLOWsplitparameter\c!ny, + command = "", + marking = "\FLOWsplitparameter\c!marking", + before = "", + after = "", + } + } }% + \egroup} + +\unexpanded\def\FLOWcharts + {\dodoubleempty\FLOW_charts} + +\def\FLOW_charts[#name][#settings] + {\begingroup + \setupFLOWsplit[\c!state=\v!start,#settings]% + \FLOW_chart[#name][]% + \endgroup} + +\appendtoks + \let\name \FLOW_name + \let\shape \FLOW_shape + \let\destination\FLOW_destination + \let\focus \FLOW_focus + \let\overlay \FLOW_overlay + \let\location \FLOW_location + \let\text \FLOW_text + \let\label \FLOW_label + \let\comment \FLOW_comment + \let\exit \FLOW_exit + \let\connection \FLOW_connection + \let\include \FLOW_include + \let\figure \FLOW_figure + % + \let\connect \FLOW_connection + \let\locate \FLOW_location + % + \let\includeFLOWchart\include +\to \everyFLOWchart + +\unexpanded\def\FLOW_name #name{\ctxcommand{flow_set_name("#name")}\ignorespaces} +\unexpanded\def\FLOW_shape #shape{\ctxcommand{flow_set_shape("#shape")}\ignorespaces} +\unexpanded\def\FLOW_destination #destination{\ctxcommand{flow_set_destination("#destination")}\ignorespaces} +\unexpanded\def\FLOW_focus #focus{\ctxcommand{flow_set_focus("#focus")}\ignorespaces} +\unexpanded\def\FLOW_overlay #overlay{\ctxcommand{flow_set_overlay("#overlay")}\ignorespaces} +\unexpanded\def\FLOW_location #location{\ctxcommand{flow_set_location("#location")}\ignorespaces} +\unexpanded\def\FLOW_figure #figure{\ctxcommand{flow_set_figure("#figure")}\ignorespaces} + +\unexpanded\def\FLOW_text {\dosingleempty\do_FLOW_text} +\unexpanded\def\FLOW_label {\dosingleempty\do_FLOW_label} +\unexpanded\def\FLOW_comment {\dosingleempty\do_FLOW_commment} +\unexpanded\def\FLOW_exit {\dosingleempty\do_FLOW_exit} +\unexpanded\def\FLOW_connection {\dodoubleempty\do_FLOW_connection} +\unexpanded\def\FLOW_include {\dodoubleempty\do_FLOW_include} + +\unexpanded\def\do_FLOW_text [#align]#text{\ctxcommand{flow_set_text("#align",\!!bs\detokenize{#text}\!!es)}\ignorespaces} +\unexpanded\def\do_FLOW_label [#location]#text{\ctxcommand{flow_set_label("#location",\!!bs\detokenize{#text}\!!es)}\ignorespaces} +\unexpanded\def\do_FLOW_comment [#location]#text{\ctxcommand{flow_set_comment("#location",\!!bs\detokenize{#text}\!!es)}\ignorespaces} +\unexpanded\def\do_FLOW_exit [#location]#text{\ctxcommand{flow_set_exit("#location",\!!bs\detokenize{#text}\!!es)}\ignorespaces} +\unexpanded\def\do_FLOW_connection[#location][#offset]#name{\ctxcommand{flow_set_connection("#location","#offset","#name")}\ignorespaces} + +\unexpanded\def\do_FLOW_include [#name][#settings]{% + \begingroup + \getparameters[FLOWi][x=1,y=1,#settings]% + \ctxcommand{flow_set_include("#name",\number\FLOWix,\number\FLOWiy,\!!bs\detokenize{#settings}\!!es)}% + \endgroup + \ignorespaces +} + +\setvariables + [flowcell:text] + [x=1, + y=1, + text=, + align=, + set=\setups{flowcell:text:place}] + +% \c!background={\@@FLOWbackground,\FLOWoverlay}, + +\defineoverlay + [flowcell:figure] + [\overlayfigure{\getvariable{flowcell:text}{figure}}] + +\startsetups flowcell:text:place + \begingroup + \iftrialtypesetting + \directsetup{flowcell:text:place:indeed} + \else \iflocation + \doifelsenothing {\getvariable{flowcell:text}{destination}} { + \directsetup{flowcell:text:place:indeed} + } { + % tricky: scaling and moving around is not taken into account + \setupinteraction[\c!color=,\c!contrastcolor=] + \gotobox{\directsetup{flowcell:text:place:indeed}}[\getvariable{flowcell:text}{destination}] + } + \else + \directsetup{flowcell:text:place:indeed} + \fi \fi + \endgroup +\stopsetups + +\startsetups flowcell:text:place:indeed + \begingroup + \directsetup{flowcell:text:user} + \doifelsenothing {\getvariable{flowcell:text}{figure}} { + \doframed + [flowcell:\getvariable{flowcell:text}{align}] + {\getvariable{flowcell:text}{text}} + } { + \doframed + [flowcell:\getvariable{flowcell:text}{align}] + [background=flowcell:figure] + {\getvariable{flowcell:text}{text}} + } + \endgroup +\stopsetups + +\defineframed % to be discussed: shape or global + [flowcell:base] + [\c!offset=\v!overlay, % no strut ? + \c!frame=\FLOWchartparameter\c!frame, + \c!background=\FLOWchartparameter\c!background, + \c!backgroundcolor=\FLOWchartparameter\c!backgroundcolor, + %\c!foregroundcolor=\FLOWshapeparameter\c!foregroundcolor, + \c!align=\v!middle, + \c!bottom=\vfill, + \c!top=\vfill, + \c!width=\FLOWchartparameter\c!width, + \c!height=\FLOWchartparameter\c!height, + % \c!rulethickness=\FLOWchartparameter\c!rulethickness, + \c!rulethickness=\zeropoint, % comment for tracing + \c!framecolor=\FLOWchartparameter\c!framecolor] + +\defineframed[flowcell:] [flowcell:base] +\defineframed[flowcell:l] [flowcell:base][\c!align=\v!flushleft] +\defineframed[flowcell:r] [flowcell:base][\c!align=\v!flushright] +\defineframed[flowcell:m] [flowcell:base][\c!align=\v!middle] +\defineframed[flowcell:c] [flowcell:base][\c!align=\v!middle] + +\defineframed[flowcell:t] [flowcell:base][\c!top=] +\defineframed[flowcell:b] [flowcell:base][\c!bottom=] + +\defineframed[flowcell:lt][flowcell:base][\c!top=,\c!align=\v!flushleft] +\defineframed[flowcell:rt][flowcell:base][\c!top=,\c!align=\v!flushright] +\defineframed[flowcell:mt][flowcell:base][\c!top=,\c!align=\v!middle] +\defineframed[flowcell:ct][flowcell:base][\c!top=,\c!align=\v!middle] + +\defineframed[flowcell:lb][flowcell:base][\c!bottom=,\c!align=\v!flushleft] +\defineframed[flowcell:rb][flowcell:base][\c!bottom=,\c!align=\v!flushright] +\defineframed[flowcell:mb][flowcell:base][\c!bottom=,\c!align=\v!middle] +\defineframed[flowcell:cb][flowcell:base][\c!bottom=,\c!align=\v!middle] + +% todo: each cell its own setup +% +% \startsetups flowcell +% \definelayer +% [flowcell] +% [width=\FLOWshapewidth, +% height=\FLOWshapeheight] +% \setlayerframed +% [flowcell] +% [preset=rightbottom,offset=1ex] +% [frame=off] +% {\tx(\FLOWx,\FLOWy)} +% \stopsetups + +%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 \starttyping +%D \splitfloat +%D {\placefigure{What a big flowchart this is!}} +%D {\FLOWcharts[mybigflow]} +%D \stoptyping + +\protect + +\continueifinputfile{m-chart.mkvi} + +\input chrt-xml.tex + +\usemodule[abr-01] + +\setupFLOWcharts[option=test] +\setupFLOWcharts[frame=on] +\setupinteraction[state=start] + +% \setupFLOWcharts[dx=30pt,dy=30pt] + +\startMPinclusions + predefined_shapes[101] := fullcircle ; +\stopMPinclusions + +\startFLOWchart[demo] + \startFLOWcell[framecolor=darkgray] + \name {start} + \location {1,1} + \shape {action} + \text {start} + \connection [bl] {one} + \stopFLOWcell + \startFLOWcell + \name {one} +% \destination{CloseDocument} + \location {2,2} +% \shape {action} + \shape {101} + \text {first} +% \label [b] {\bfx bottom} + \connection [rt] {two} +% \exit [l] {exit l} +% \exit [r] {exit r} +% \exit [t] {exit t} +% \exit [b] {exit b} + \stopFLOWcell + \setupFLOWshapes[framecolor=darkgray] + \startFLOWcell % [foregroundcolor=white] + \name {two} +% \destination{CloseDocument} + \location {3,3} + \shape {action} + \text {second} + \figure {cow.pdf} +% \label [l] {\bfx left} +% \exit [l] {exit l} +% \exit [r] {exit r} +% \exit [t] {exit t} +% \exit [b] {exit b} + \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.lua b/tex/context/base/m-flow.lua deleted file mode 100644 index 62d31c197..000000000 --- a/tex/context/base/m-flow.lua +++ /dev/null @@ -1,619 +0,0 @@ -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.charts = moduledata.charts or { } - -local gsub, match, find, format, lower = string.gsub, string.match, string.find, string.format, string.lower -local lpegmatch = lpeg.match - -local points = number.points -local variables = interfaces.variables - -local defaults = { - chart = { - name = "", - option = "", - backgroundcolor = "", - width = 0, - height = 0, - dx = 0, - dy = 0, - offset = 0, - bodyfont = "", - dot = "", - }, - shape = { -- FLOS - rulethickness = 65436, - default = "", - framecolor = "green", - backgroundcolor = "yellow", - }, - focus = { -- FLOF - rulethickness = 65436, - framecolor = "red", - backgroundcolor = "yellow", - }, - line = { -- FLOL - rulethickness = 65436, - radius = 65436, - color = "blue", - corner = "", - dash = "", - arrow = "", - offset = "", - }, - set = { -- FLOX - }, - split = { - nx = 3, - ny = 3, - command = "", - marking = "", - before = "", - after = "", - } -} - -local validshapes = { - ["node"] = { kind = "shape", number = 0 }, - ["action"] = { kind = "shape", number = 24 }, - ["procedure"] = { kind = "shape", number = 5 }, - ["product"] = { kind = "shape", number = 12 }, - ["decision"] = { kind = "shape", number = 14 }, - ["archive"] = { kind = "shape", number = 19 }, - ["loop"] = { kind = "shape", number = 35 }, - ["wait"] = { kind = "shape", number = 6 }, - ["subprocedure"] = { kind = "shape", number = 20 }, - ["singledocument"] = { kind = "shape", number = 32 }, - ["multidocument"] = { kind = "shape", number = 33 }, - - ["right"] = { kind = "line", number = 66 }, - ["left"] = { kind = "line", number = 67 }, - ["up"] = { kind = "line", number = 68 }, - ["down"] = { kind = "line", number = 69 }, -} - -local validlabellocations = { - l = "l", left = "l", - r = "r", right = "r", - t = "t", top = "t", - b = "b", bottom = "b", -} - -table.setmetatableindex(validshapes,function(t,k) - local l = gsub(lower(k)," ","") - local v = rawget(t,l) - if not v then - local n = tonumber(k) - if n then - v = { kind = "shape", number = n } - else - v = rawget(t,"action") - end - end - t[k] = v - return v -end) - -local charts = { } - -local data, hash, temp, last_x, last_y, name - -function commands.flow_start_chart(chartname) - data = { } - hash = { } - last_x, last_y = 0, 0 - name = chartname -end - -function commands.flow_stop_chart() - charts[name] = { - data = data, - hash = hash, - last_x = last_x, - last_y = last_y, - } - data, hash, temp = nil, nil, nil -end - -function commands.flow_set_current_cell(n) - temp = data[tonumber(n)] or { } -end - -function commands.flow_start_cell(settings) - temp = { - labels = { }, - comments = { }, - exits = { }, - connections = { }, - settings = settings, - } -end - -function commands.flow_stop_cell() - data[#data+1] = temp - hash[temp.name or #data] = temp -end - -function commands.flow_set_name(str) - temp.name = str -end - -function commands.flow_set_shape(str) - temp.shape = str -end - -function commands.flow_set_destination(str) - temp.destination = str -end - -function commands.flow_set_text(align,str) - temp.align = align - temp.text = str -end - -function commands.flow_set_overlay(str) - temp.overlay = str -end - -function commands.flow_set_focus(str) - temp.focus = str -end - -function commands.flow_set_figure(str) - temp.figure = str -end - -function commands.flow_set_label(location,text) - temp.labels[#temp.labels+1] = { - location = location, - text = text, - } -end - -function commands.flow_set_comment(name,str) - temp.comments[#temp.comments+1] = { - location = location, - text = text, - } -end - -function commands.flow_set_exit(location,text) - temp.exits[#temp.exits+1] = { - location = location, - text = text, - } -end - -function commands.flow_set_include(name,x,y,settings) - data[#data+1] = { - include = name, - x = x, - y = y, - -- settings = settings, - } -end - -local function inject(includedata,data,hash) - local subchart = charts[includedata.include] - if not subchart then - return - end - local subdata = subchart.data - if not subdata then - return - end - local xoffset = (includedata.x or 1) - 1 - local yoffset = (includedata.y or 1) - 1 - local settings = includedata.settings - for i=1,#subdata do - local si = subdata[i] - local t = { - x = si.x + xoffset, - y = si.y + yoffset, - settings = settings, - } - table.setmetatableindex(t,si) - data[#data+1] = t - hash[si.name or #data] = t - end -end - -local function expanded(chart) - local expandeddata = { } - local expandedhash = { } - local expandedchart = { - data = expandeddata, - hash = expandedhash, - } - table.setmetatableindex(expandedchart,chart) - local data = chart.data - local hash = chart.hash - for i=1,#data do - local di = data[i] - if di.include then - inject(di,expandeddata,expandedhash) - else - expandeddata[#expandeddata+1] = di - expandedhash[di.name or #expandeddata] = di - end - end - for i=1,#expandeddata do - local cell = expandeddata[i] - local settings = cell.settings - if not settings then - cell.settings = chart.settings - else - table.setmetatableindex(settings,chart.settings) - end - end - return expandedchart -end - - -local splitter = lpeg.splitat(",") - -function commands.flow_set_location(str) -- handle include differently - -- wrong: delay real x,y, only store relative - local x, y = lpegmatch(splitter,str) - if not x or x == "" then - x = last_x - elseif x == "+" then - x = last_x + 1 - elseif x == "-" then - x = last_x - 1 - elseif find(x,"^[%+%-]") then - x = last_x + (tonumber(x) or 0) - else - x = tonumber(x) - end - if not y or y == "" then - y = last_y - elseif y == "+" then - y = last_y + 1 - elseif x == "-" then - y = last_y - 1 - elseif find(y,"^[%+%-]") then - y = last_y + (tonumber(y) or 0) - else - y = tonumber(y) - end - temp.x = x - temp.y = y - last_x = x - last_y = y -end - -function commands.flow_set_connection(location,displacement,name) - local dx, dy = lpegmatch(splitter,displacement) - dx = tonumber(dx) or 1 - dy = tonumber(dy) or 1 - temp.connections[#temp.connections+1] = { - location = location, - dx = dx - 1, - dy = dy - 1, - name = name, - } -end - -local where = { - l = "left", - r = "right", - t = "top", - b = "bottom", -} - -local what = { - ["p"] = 1, - ["m"] = -1, - ["+"] = 1, - ["-"] = -1, -} - -local function visible(chart,cell) - local x, y = cell.x, cell.y - return - x >= chart.from_x and x <= chart.to_x and - y >= chart.from_y and y <= chart.to_y and cell -end - -local function check_cells(chart,xoffset,yoffset,min_x,min_y,max_x,max_y) - local data = chart.data - if not data then - return - end - for i=1,#data do - local cell = data[i] - local x, y = cell.x + xoffset, cell.y + yoffset - if min_x == 0 then - min_x, max_x = x, x - min_y, max_y = y, y - else - if x < min_x then min_x = x end - if y < min_y then min_y = y end - if x > max_x then max_x = x end - if y > max_y then max_y = y end - end - end - return min_x, min_y, max_x, max_y -end - -local function process_cells(chart,xoffset,yoffset) - local data = chart.data - if not data then - return - end - for i=1,#data do - local cell = visible(chart,data[i]) - if cell then - local shape = cell.shape - if not shape or shape == "" then - shape = settings.shape.default or "none" - end - if shape ~= variables.none then - local settings = cell.settings - local shapedata = validshapes[shape] - context("flow_begin_sub_chart ;") - if shapedata.kind == "line" then - local linesettings = settings.line - context("flow_shape_line_color := \\MPcolor{%s} ;", linesettings.color) - context("flow_shape_fill_color := \\MPcolor{%s} ;", linesettings.backgroundcolor) - context("flow_shape_line_width := %s ; ", points(linesettingsrulethickness)) - elseif hasfocus then -- doifcommonelse{FLOWcell,FLOWfocus}@@FLOWfocus - local focussettings = settings.focus - context("flow_shape_line_color := \\MPcolor{%s} ;", focussettings.framecolor) - context("flow_shape_fill_color := \\MPcolor{%s} ;", focussettings.backgroundcolor) - context("flow_shape_line_width := %s ; ", points(focussettings.rulethickness)) - else - local shapesettings = settings.shape - context("flow_shape_line_color := \\MPcolor{%s} ;", shapesettings.framecolor) - context("flow_shape_fill_color := \\MPcolor{%s} ;", shapesettings.backgroundcolor) - context("flow_shape_line_width := %s ; " , points(shapesettings.rulethickness)) - end - context("bodyfontsize := 10pt ;") -- todo - context("flow_peepshape := false ;") -- todo - context("flow_new_shape(%s,%s,%s) ;",cell.x+xoffset,cell.y+yoffset,shapedata.number) - context("flow_end_sub_chart ;") - end - end - end -end - --- todo : make lpeg for splitter - -local function process_connections(chart,xoffset,yoffset) - local data = chart.data - local hash = chart.hash - if not data then - return - end - local settings = chart.settings - for i=1,#data do - local cell = visible(chart,data[i]) - if cell then - local connections = cell.connections - for j=1,#connections do - local connection = connections[j] - local othername = connection.name - local othercell = hash[othername] - if othercell then - local cellx, celly = cell.x, cell.y - local otherx, othery, location = othercell.x, othercell.y, connection.location - if otherx > 0 and othery > 0 and cellx > 0 and celly > 0 and connection.location then - -- move to setter - local what_cell, where_cell, what_other, where_other = match(location,"([%+%-pm]-)([lrtb]),?([%+%-pm]-)([lrtb])") - local what_cell = what [what_cell] or 0 - local what_other = what [what_other] or 0 - local where_cell = where[where_cell] or "left" - local where_other = where[where_other] or "right" - local linesettings = settings.line - context("flow_smooth := %s ;", linesettings.corner == variables.round and "true" or "false") - context("flow_dashline := %s ;", linesettings.dash == variables.yes and "true" or "false") - context("flow_arrowtip := %s ;", linesettings.arrow == variables.yes and "true" or "false") - context("flow_touchshape := %s ;", linesettings.offset == variables.none and "true" or "false") - context("flow_dsp_x := %s ; flow_dsp_y := %s ;",connection.dx or 0, connection.dy or 0) - context("flow_connection_line_color := \\MPcolor{%s} ;",linesettings.color) - context("flow_connection_line_width := 2pt ;",points(linesettings.rulethickness)) - context("flow_connect_%s_%s(%s,%s,%s) (%s,%s,%s) ;",where_cell,where_other,cellx,celly,what_cell,otherx,othery,what_other) - context("flow_dsp_x := 0 ; flow_dsp_y := 0 ;") - end - end - end - end - end -end - -local texttemplate = "\\setvariables[flowcell:text][x=%s,y=%s,text={%s},align={%s},figure={%s},destination={%s}]" - -local function process_texts(chart,xoffset,yoffset) - local data = chart.data - local hash = chart.hash - if not data then - return - end - for i=1,#data do - local cell = visible(chart,data[i]) - if cell then - local x = cell.x or 1 - local y = cell.y or 1 - local text = cell.text - if text and text ~= "" then - local a = cell.align or "" - local f = cell.figure or "" - local d = cell.destination or "" - context('flow_chart_draw_text(%s,%s,textext("%s")) ;',x,y,format(texttemplate,x,y,text,a,f,d)) - end - local labels = cell.labels - for i=1,#labels do - local label = labels[i] - local text = label.text - local location = validlabellocations[label.location or ""] - if text and location then - context('flow_chart_draw_label_%s(%s,%s,textext("%s")) ;',location,x,y,text) - end - end - local exits = cell.exits - for i=1,#exits do - local exit = exits[i] - local text = exit.text - local location = validlabellocations[exit.location or ""] - if text and location then - -- maybe make autoexit an option - if location == "l" and x == chart.from_x + 1 or - location == "r" and x == chart.to_x - 1 or - location == "t" and y == chart.to_y - 1 or - location == "b" and y == chart.from_y + 1 then - context('flow_chart_draw_exit_%s(%s,%s,textext("%s")) ;',location,x,y,text) - end - end - end - local comments = cell.comments - for i=1,#comments do - -- invisible - end - end - end -end - -local function getchart(settings) - local chartname = settings.chart.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 - chart.settings = settings - table.setmetatableindex(settings,defaults) - chart = expanded(chart) - local _, _, nx, ny = check_cells(chart,0,0,0,0,0,0) - chart.from_x = chart.settings.chart.x or 1 - chart.from_y = chart.settings.chart.y or 1 - chart.to_x = chart.settings.chart.nx or nx - chart.to_y = chart.settings.chart.ny or ny - chart.nx = chart.to_x - chart.from_x + 1 - chart.ny = chart.to_y - chart.from_y + 1 - return chart -end - -local function makechart(chart) - local settings = chart.settings - context.begingroup() - context.forgetall() - -- - local bodyfont = settings.chart.bodyfont - if bodyfont ~= "" then - context.switchtobodyfont { bodyfont } - end - -- - context.startMPcode() - context("if unknown context_flow : input mp-flow.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 - context("flow_show_con_points := true ;") - context("flow_show_mid_points := true ;") - context("flow_show_all_points := true ;") - elseif settings.chart.dot ~= "" then -- no checking done, private option - context("flow_show_%s_points := true ;",settings.chart.dot) - end - -- - local backgroundcolor = settings.chart.backgroundcolor - if backgroundcolor and backgroundcolor ~= "" then - context("flow_chart_background_color := \\MPcolor{%s} ;",backgroundcolor) - end - -- - local shapewidth = settings.chart.width - local gridwidth = shapewidth + 2*settings.chart.dx - local shapeheight = settings.chart.height - local gridheight = shapeheight + 2*settings.chart.dy - context("flow_grid_width := %s ;", points(gridwidth)) - context("flow_grid_height := %s ;", points(gridheight)) - context("flow_shape_width := %s ;", points(shapewidth)) - context("flow_shape_height := %s ;", points(shapeheight)) - -- - local radius = settings.line.radius - local rulethickness = settings.line.rulethickness - local dx = settings.chart.dx - local dy = settings.chart.dy - if radius < rulethickness then - radius = 2.5*rulethickness - if radius > dx then - radius = dx - end - if radius > dy then - radius = dy - end - end - context("flow_connection_line_width := %s ;", points(rulethickness)) - context("flow_connection_smooth_size := %s ;", points(radius)) - context("flow_connection_arrow_size := %s ;", points(radius)) - context("flow_connection_dash_size := %s ;", points(radius)) - -- - local offset = settings.chart.offset -- todo: pass string - if offset == variables.none or offset == variables.overlay or offset == "" then - offset = -2.5 * radius -- or rulethickness? - elseif offset == variables.standard then - offset = radius -- or rulethickness? - end - context("flow_chart_offset := %s ;",points(offset)) - -- - context("flow_reverse_y := true ;") - process_cells(chart,0,0) - process_connections(chart,0,0) - process_texts(chart,0,0) - -- context("clip_chart(%s,%s,%s,%s) ;",x,y,nx,ny) -- todo: draw lines but not shapes - context("flow_end_chart ;") - context.stopMPcode() - context.endgroup() -end - -function commands.flow_make_chart(settings) - local chart = getchart(settings) - if chart then - local settings = chart.settings - if settings.split.state == variables.start then - local nx = chart.settings.split.nx - local ny = chart.settings.split.ny - local x = 1 - while true do - local y = 1 - while true do - -- FLOTbefore - -- doif @@FLOTmarking on -> cuthbox - -- @@FLOTcommand - chart.from_x = x - chart.from_y = y - chart.to_x = math.min(x + nx - 1,chart.nx) - chart.to_y = math.min(x + ny - 1,chart.ny) - makechart(chart) - -- FLOTafter - y = y + ny - if y > chart.max_y then - break - else - y = y - dy - end - end - x = x + nx - if x > chart.max_x then - break - else - x = x - dx - end - end - else - makechart(chart) - end - end -end diff --git a/tex/context/base/m-flow.mkvi b/tex/context/base/m-flow.mkvi deleted file mode 100644 index 425d7e490..000000000 --- a/tex/context/base/m-flow.mkvi +++ /dev/null @@ -1,477 +0,0 @@ -%D \module -%D [ file=m-flow, -- m-chart -%D version=2011.10.1, -- 1998.10.10, -%D title=\CONTEXT\ Modules, -%D subtitle=Flow Charts, -%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. - -% todo (if used): -% autofocus={name,name,name} -> min/max -% flowsets -% autoscaling (bodyfontsteps) -% comment -% overlay -% -% todo: -% \useFLOWchart[name][parent][setting,setting][additional settings] -% \useFLOWchart[name][parent][additional settings] -% setups -% mp instance with less files - -\registerctxluafile{m-flow}{} - -\unprotect - -% todo: figure out a nice way to define the lot: share current and -% support current as name (nb: we need to set parent then) - -\def\??flch{@@flch} % chart -\def\??flln{@@flln} % line -\def\??flsh{@@flsh} % shape -\def\??flfc{@@flfc} % focus -\def\??flst{@@flst} % sets -\def\??flsp{@@flsp} % split - -\installsimplecommandhandler \??flch {FLOWchart} \??flch -\installsimplecommandhandler \??flln {FLOWline} \??flln -\installsimplecommandhandler \??flsh {FLOWshape} \??flsh -\installsimplecommandhandler \??flfc {FLOWfocus} \??flfc -\installsimplecommandhandler \??flst {FLOWsets} \??flst -\installsimplecommandhandler \??flsp {FLOWsplit} \??flsp - -\let\setupFLOWcharts\setupFLOWchart -\let\setupFLOWlines \setupFLOWline -\let\setupFLOWshapes\setupFLOWshape -\let\setupFLOWsets \setupFLOWset - -\setupFLOWcharts - [\c!width=12\bodyfontsize, - \c!height=7\bodyfontsize, - \c!offset=0pt, % \v!standard, % == auto offset - \c!dx=2\bodyfontsize, - \c!dy=2\bodyfontsize, - \c!nx=0, - \c!ny=0, - \c!x=1, - \c!y=1, - % \c!maxwidth=, - % \c!maxheight=, - % \c!option=, - % \c!bodyfont=, - % \c!dot=, % private option - % \c!autofocus=, - % \c!focus=, - % \c!background=, - % \c!framecolor= - % \c!backgroundcolor=, % \s!white - \c!rulethickness=\linewidth, - \c!frame=\v!off] - -\setupFLOWlines - [\c!corner=\v!round, - \c!arrow=\v!yes, - \c!dash=\v!no, - \c!radius=.375\bodyfontsize, - \c!color=FLOWlinecolor, - \c!rulethickness=.15\bodyfontsize, - \c!offset=\v!none] - -\setupFLOWshapes - [\c!default=action, - \c!framecolor=FLOWframecolor, - \c!background=\v!color, - \c!backgroundcolor=FLOWbackgroundcolor, - \c!rulethickness=.15\bodyfontsize, - \c!offset=.5\bodyfontsize] - -\setupFLOWfocus - [\c!framecolor=FLOWfocuscolor, - \c!background=\FLOWshapeparameter\c!background, - \c!backgroundcolor=\FLOWshapeparameter\c!backgroundcolor, - \c!backgroundscreen=\FLOWshapeparameter\c!backgroundscreen, - \c!rulethickness=\FLOWshapeparameter\c!rulethickness, - \c!offset=\FLOWshapeparameter\c!offset] - -\setupFLOWsplit - [\c!state=\v!stop, - \c!marking=\v!on, - % \c!command=, - % \c!before=, - % \c!after=, - \c!nx=3, - \c!ny=3] - -\definecolor [FLOWfocuscolor] [s=.2] -\definecolor [FLOWlinecolor] [s=.5] -\definecolor [FLOWframecolor] [s=.7] -\definecolor [FLOWbackgroundcolor] [s=.9] - -\newtoks\everyFLOWchart - -\unexpanded\def\startFLOWchart - {\startnointerference - \the\everyFLOWchart - \dosingleempty\start_FLOW_chart} - -\unexpanded\def\start_FLOW_chart[#name]% - {\ctxcommand{flow_start_chart("#name")}} - -\unexpanded\def\stopFLOWchart - {\ctxcommand{flow_stop_chart()}% - \stopnointerference} - -\unexpanded\def\defineFLOWchart % for old times sake - {\dodoubleempty\define_FLOW_chart} - -\unexpanded\def\define_FLOW_chart[#name][#settings]#cells% todo: save settings - {\startnointerference - \the\everyFLOWchart - \ctxcommand{flow_start_chart("#name")}% - #cells% - \ctxcommand{flow_stop_chart()}% - \stopnointerference} - -\unexpanded\def\startFLOWcell - {\dodoubleempty\start_FLOW_cell} - -\unexpanded\def\start_FLOW_cell[#1][#2]% - {\begingroup - \iffirstargument - \setupFLOWshape[#1]% - \fi - \ifsecondargument - \setupFLOWline[#2]% - \fi - \ctxcommand{flow_start_cell { - shape = { - rulethickness = \number\dimexpr\FLOWshapeparameter\c!rulethickness, - default = "\FLOWshapeparameter\c!default", - framecolor = "\FLOWshapeparameter\c!framecolor", - backgroundcolor = "\FLOWshapeparameter\c!backgroundcolor", - }, - focus = { - rulethickness = \number\dimexpr\FLOWfocusparameter\c!rulethickness, - framecolor = "\FLOWfocusparameter\c!framecolor", - backgroundcolor = "\FLOWfocusparameter\c!backgroundcolor", - }, - line = { - rulethickness = \number\dimexpr\FLOWlineparameter\c!rulethickness, - radius = \number\dimexpr\FLOWlineparameter\c!radius, - color = "\FLOWlineparameter\c!color", - corner = "\FLOWlineparameter\c!corner", - dash = "\FLOWlineparameter\c!dash", - arrow = "\FLOWlineparameter\c!arrow", - offset = "\FLOWlineparameter\c!offset", - }, - } }% - \endgroup} - -\unexpanded\def\stopFLOWcell - {\ctxcommand{flow_stop_cell()}} - -\unexpanded\def\FLOWchart - {\dodoubleempty\FLOW_chart} - -\def\FLOW_chart[#name][#settings]% - {\vbox\bgroup - \insidefloattrue - \dontcomplain - \setupFLOWchart[#settings]% - \ctxcommand{flow_make_chart { - chart = { - name = "#name", - option = "\FLOWchartparameter\c!option", - backgroundcolor = "\FLOWchartparameter\c!backgroundcolor", - width = \number\dimexpr\FLOWchartparameter\c!width, - height = \number\dimexpr\FLOWchartparameter\c!height, - dx = \number\dimexpr\FLOWchartparameter\c!dx, - dy = \number\dimexpr\FLOWchartparameter\c!dy, - offset = \number\dimexpr\FLOWchartparameter\c!offset, - bodyfont = "\FLOWchartparameter\c!bodyfont", - dot = "\FLOWchartparameter\c!dot", % private option - }, - shape = { - rulethickness = \number\dimexpr\FLOWshapeparameter\c!rulethickness, - default = "\FLOWshapeparameter\c!default", - framecolor = "\FLOWshapeparameter\c!framecolor", - backgroundcolor = "\FLOWshapeparameter\c!backgroundcolor", - }, - focus = { - rulethickness = \number\dimexpr\FLOWfocusparameter\c!rulethickness, - framecolor = "\FLOWfocusparameter\c!framecolor", - backgroundcolor = "\FLOWfocusparameter\c!backgroundcolor", - }, - line = { - rulethickness = \number\dimexpr\FLOWlineparameter\c!rulethickness, - radius = \number\dimexpr\FLOWlineparameter\c!radius, - color = "\FLOWlineparameter\c!color", - corner = "\FLOWlineparameter\c!corner", - dash = "\FLOWlineparameter\c!dash", - arrow = "\FLOWlineparameter\c!arrow", - offset = "\FLOWlineparameter\c!offset", - }, - set = { - }, - split = { - state = "\FLOWsplitparameter\c!state", - nx = \number\FLOWsplitparameter\c!nx, - ny = \number\FLOWsplitparameter\c!ny, - command = "", - marking = "\FLOWsplitparameter\c!marking", - before = "", - after = "", - } - } }% - \egroup} - -\unexpanded\def\FLOWcharts - {\dodoubleempty\FLOW_charts} - -\def\FLOW_charts[#name][#settings] - {\begingroup - \setupFLOWsplit[\c!state=\v!start,#settings]% - \FLOW_chart[#name][]% - \endgroup} - -\appendtoks - \let\name \FLOW_name - \let\shape \FLOW_shape - \let\destination\FLOW_destination - \let\focus \FLOW_focus - \let\overlay \FLOW_overlay - \let\location \FLOW_location - \let\text \FLOW_text - \let\label \FLOW_label - \let\comment \FLOW_comment - \let\exit \FLOW_exit - \let\connection \FLOW_connection - \let\include \FLOW_include - \let\figure \FLOW_figure - % - \let\connect \FLOW_connection - \let\locate \FLOW_location - % - \let\includeFLOWchart\include -\to \everyFLOWchart - -\unexpanded\def\FLOW_name #name{\ctxcommand{flow_set_name("#name")}\ignorespaces} -\unexpanded\def\FLOW_shape #shape{\ctxcommand{flow_set_shape("#shape")}\ignorespaces} -\unexpanded\def\FLOW_destination #destination{\ctxcommand{flow_set_destination("#destination")}\ignorespaces} -\unexpanded\def\FLOW_focus #focus{\ctxcommand{flow_set_focus("#focus")}\ignorespaces} -\unexpanded\def\FLOW_overlay #overlay{\ctxcommand{flow_set_overlay("#overlay")}\ignorespaces} -\unexpanded\def\FLOW_location #location{\ctxcommand{flow_set_location("#location")}\ignorespaces} -\unexpanded\def\FLOW_figure #figure{\ctxcommand{flow_set_figure("#figure")}\ignorespaces} - -\unexpanded\def\FLOW_text {\dosingleempty\do_FLOW_text} -\unexpanded\def\FLOW_label {\dosingleempty\do_FLOW_label} -\unexpanded\def\FLOW_comment {\dosingleempty\do_FLOW_commment} -\unexpanded\def\FLOW_exit {\dosingleempty\do_FLOW_exit} -\unexpanded\def\FLOW_connection {\dodoubleempty\do_FLOW_connection} -\unexpanded\def\FLOW_include {\dodoubleempty\do_FLOW_include} - -\unexpanded\def\do_FLOW_text [#align]#text{\ctxcommand{flow_set_text("#align",\!!bs\detokenize{#text}\!!es)}\ignorespaces} -\unexpanded\def\do_FLOW_label [#location]#text{\ctxcommand{flow_set_label("#location",\!!bs\detokenize{#text}\!!es)}\ignorespaces} -\unexpanded\def\do_FLOW_comment [#location]#text{\ctxcommand{flow_set_comment("#location",\!!bs\detokenize{#text}\!!es)}\ignorespaces} -\unexpanded\def\do_FLOW_exit [#location]#text{\ctxcommand{flow_set_exit("#location",\!!bs\detokenize{#text}\!!es)}\ignorespaces} -\unexpanded\def\do_FLOW_connection[#location][#offset]#name{\ctxcommand{flow_set_connection("#location","#offset","#name")}\ignorespaces} - -\unexpanded\def\do_FLOW_include [#name][#settings]{% - \begingroup - \getparameters[FLOWi][x=1,y=1,#settings]% - \ctxcommand{flow_set_include("#name",\number\FLOWix,\number\FLOWiy,\!!bs\detokenize{#settings}\!!es)}% - \endgroup - \ignorespaces -} - -\setvariables - [flowcell:text] - [x=1, - y=1, - text=, - align=, - set=\setups{flowcell:text:place}] - -% \c!background={\@@FLOWbackground,\FLOWoverlay}, - -\defineoverlay - [flowcell:figure] - [\overlayfigure{\getvariable{flowcell:text}{figure}}] - -\startsetups flowcell:text:place - \begingroup - \iftrialtypesetting - \directsetup{flowcell:text:place:indeed} - \else \iflocation - \doifelsenothing {\getvariable{flowcell:text}{destination}} { - \directsetup{flowcell:text:place:indeed} - } { - % tricky: scaling and moving around is not taken into account - \setupinteraction[\c!color=,\c!contrastcolor=] - \gotobox{\directsetup{flowcell:text:place:indeed}}[\getvariable{flowcell:text}{destination}] - } - \else - \directsetup{flowcell:text:place:indeed} - \fi \fi - \endgroup -\stopsetups - -\startsetups flowcell:text:place:indeed - \begingroup - \directsetup{flowcell:text:user} - \doifelsenothing {\getvariable{flowcell:text}{figure}} { - \doframed - [flowcell:\getvariable{flowcell:text}{align}] - {\getvariable{flowcell:text}{text}} - } { - \doframed - [flowcell:\getvariable{flowcell:text}{align}] - [background=flowcell:figure] - {\getvariable{flowcell:text}{text}} - } - \endgroup -\stopsetups - -\defineframed % to be discussed: shape or global - [flowcell:base] - [\c!offset=\v!overlay, % no strut ? - \c!frame=\FLOWchartparameter\c!frame, - \c!background=\FLOWchartparameter\c!background, - \c!backgroundcolor=\FLOWchartparameter\c!backgroundcolor, - %\c!foregroundcolor=\FLOWshapeparameter\c!foregroundcolor, - \c!align=\v!middle, - \c!bottom=\vfill, - \c!top=\vfill, - \c!width=\FLOWchartparameter\c!width, - \c!height=\FLOWchartparameter\c!height, - % \c!rulethickness=\FLOWchartparameter\c!rulethickness, - \c!rulethickness=\zeropoint, % comment for tracing - \c!framecolor=\FLOWchartparameter\c!framecolor] - -\defineframed[flowcell:] [flowcell:base] -\defineframed[flowcell:l] [flowcell:base][\c!align=\v!flushleft] -\defineframed[flowcell:r] [flowcell:base][\c!align=\v!flushright] -\defineframed[flowcell:m] [flowcell:base][\c!align=\v!middle] -\defineframed[flowcell:c] [flowcell:base][\c!align=\v!middle] - -\defineframed[flowcell:t] [flowcell:base][\c!top=] -\defineframed[flowcell:b] [flowcell:base][\c!bottom=] - -\defineframed[flowcell:lt][flowcell:base][\c!top=,\c!align=\v!flushleft] -\defineframed[flowcell:rt][flowcell:base][\c!top=,\c!align=\v!flushright] -\defineframed[flowcell:mt][flowcell:base][\c!top=,\c!align=\v!middle] -\defineframed[flowcell:ct][flowcell:base][\c!top=,\c!align=\v!middle] - -\defineframed[flowcell:lb][flowcell:base][\c!bottom=,\c!align=\v!flushleft] -\defineframed[flowcell:rb][flowcell:base][\c!bottom=,\c!align=\v!flushright] -\defineframed[flowcell:mb][flowcell:base][\c!bottom=,\c!align=\v!middle] -\defineframed[flowcell:cb][flowcell:base][\c!bottom=,\c!align=\v!middle] - -% todo: each cell its own setup -% -% \startsetups flowcell -% \definelayer -% [flowcell] -% [width=\FLOWshapewidth, -% height=\FLOWshapeheight] -% \setlayerframed -% [flowcell] -% [preset=rightbottom,offset=1ex] -% [frame=off] -% {\tx(\FLOWx,\FLOWy)} -% \stopsetups - -%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 \starttyping -%D \splitfloat -%D {\placefigure{What a big flowchart this is!}} -%D {\FLOWcharts[mybigflow]} -%D \stoptyping - -\protect - -\continueifinputfile{m-flow.mkvi} - -\input chrt-xml.tex - -\usemodule[abr-01] - -\setupFLOWcharts[option=test] -\setupFLOWcharts[frame=on] -\setupinteraction[state=start] - -% \setupFLOWcharts[dx=30pt,dy=30pt] - -\startMPinclusions - predefined_shapes[101] := fullcircle ; -\stopMPinclusions - -\startFLOWchart[demo] - \startFLOWcell[framecolor=darkgray] - \name {start} - \location {1,1} - \shape {action} - \text {start} - \connection [bl] {one} - \stopFLOWcell - \startFLOWcell - \name {one} -% \destination{CloseDocument} - \location {2,2} -% \shape {action} - \shape {101} - \text {first} -% \label [b] {\bfx bottom} - \connection [rt] {two} -% \exit [l] {exit l} -% \exit [r] {exit r} -% \exit [t] {exit t} -% \exit [b] {exit b} - \stopFLOWcell - \setupFLOWshapes[framecolor=darkgray] - \startFLOWcell % [foregroundcolor=white] - \name {two} -% \destination{CloseDocument} - \location {3,3} - \shape {action} - \text {second} - \figure {cow.pdf} -% \label [l] {\bfx left} -% \exit [l] {exit l} -% \exit [r] {exit r} -% \exit [t] {exit t} -% \exit [b] {exit b} - \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-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.mkii b/tex/context/base/m-steps.mkii new file mode 100644 index 000000000..e6bd45548 --- /dev/null +++ b/tex/context/base/m-steps.mkii @@ -0,0 +1,837 @@ +%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 When I need this module, I will reimplement it by using the new +%D sometxt macro. Anyhow, it reflects the state of 2001. + +\unprotect + +% temp hack : + +% \ifx\v!kleinkorps\undefined \let\v!kleinkorps\setsmallbodyfont \fi + +% end of hack + +\definecolor [STEPlinecolor] [s=.5] +\definecolor [STEPframecolor] [s=.7] +\definecolor [STEPbackgroundcolor] [s=.9] + +\def\@@STPF{@@STPF} % frames + +\def\@@STPC{@@STPC} % charts +\def\@@STPT{@@STPT} % tables + +\def\@@STEC{@@STEC} % cells +\def\@@STET{@@STET} % tables +\def\@@STEL{@@STEL} % lines + +\def\setupSTEPcharts{\dodoubleargument\getparameters[\@@STPC]} +\def\setupSTEPtables{\dodoubleargument\getparameters[\@@STPT]} +\def\setupSTEPcells {\dodoubleargument\getparameters[\@@STEC]} +\def\setupSTEPtexts {\dodoubleargument\getparameters[\@@STET]} +\def\setupSTEPlines {\dodoubleargument\getparameters[\@@STEL]} + +\setupSTEPcharts + [\c!before=\blank, + \c!after=\blank, + %\c!distance=.25em, % nvt + \c!hoffset=1em, + \c!voffset=1ex, + \c!method=1, + \c!height=2ex, + \c!offset=.15\bodyfontsize] + +\setupSTEPtables + [\c!before=\blank, + \c!after=\blank, + \c!distance=.25em, + %\c!hoffset=1em, % nvt + \c!voffset=1ex, + \c!method=1, + \c!width=4em, + \c!offset=.15\bodyfontsize] + +\setupSTEPcells + [\c!alternative=24, + \c!background=\v!color, + \c!backgroundcolor=STEPbackgroundcolor, + \c!rulethickness=.1\bodyfontsize, + \c!framecolor=STEPframecolor, + \c!offset=.25\bodyfontsize, + \c!style=, + \c!color=] + +\setupSTEPtexts + [\c!alternative=24, + \c!background=\v!color, + \c!backgroundcolor=STEPbackgroundcolor, + \c!rulethickness=.1\bodyfontsize, + \c!framecolor=STEPframecolor, + \c!offset=.25\bodyfontsize, + \c!style=\v!smallbodyfont, + \c!color=] + +\setupSTEPlines + [\c!alternative=1, + \c!rulethickness=.15\bodyfontsize, + \c!color=STEPlinecolor] + +\def\initializeSTEP + {\initializeSTET \initializeSTEC \initializeSTEL} + +\def\initializeSTPC + {\freezedimenmacro\@@STPCoffset + \startMPdrawing + line_v_offset := \@@STPCoffset ; + line_method := \@@STPCmethod ; % only charts + \stopMPdrawing} + +\def\initializeSTPT + {\freezedimenmacro\@@STPToffset + \startMPdrawing + line_h_offset := \@@STPToffset ; + line_method := \@@STPTmethod ; % only charts + \stopMPdrawing} + +\def\initializeSTET + {\freezedimenmacro\@@STETrulethickness + \freezedimenmacro\@@STEToffset} + +\def\initializeSTEC + {\freezedimenmacro\@@STECrulethickness + \freezedimenmacro\@@STECoffset} + +\def\initializeSTEL + {\freezedimenmacro\@@STELrulethickness} + +%D ... + +\presetlocalframed[\@@STPF] + +\def\@@stepcell#1% + {\doattributes\@@STEC\c!style\c!color + {\localframed + [\@@STPF][\c!offset=\@@STECoffset,\c!frame=\v!off] + {\ignorespaces#1\unskip}}} + +\def\@@stepfake#1% + {\doattributes\@@STEC\c!style\c!color + {\ignorespaces#1\unskip}} + +\def\@@steptext#1% + {\doattributes\@@STET\c!style\c!color + {\localframed + [\@@STPF][\c!offset=\@@STEToffset,\c!frame=\v!off] + {\ignorespaces#1\unskip}}} + +%D The first attempt was purely \METAPOST\ based and spawned +%D the typesetting to the \METAFUN\ handler. This method +%D collects the cells, and directly passes them on to +%D \METAPOST. This method is the cleanest, but has the +%D disadvantage that one cannot embed hyperlinks or document +%D dependent definitions in the cells. The implementation +%D roughly looks as follows: +%D +%D \starttyping +%D \def\startSTEPchart% +%D {\bgroup +%D \startMPdrawing +%D input mp-step.mpii ; begin_step_chart ; +%D \stopMPdrawing +%D \initializeSTEP +%D \let\cells\stepchartcells \def\cell{\cells{}}% +%D \let\texts\stepcharttexts \def\text{\texts{}}} +%D +%D \def\stepchartcells#1#2% +%D {\setMPtext{tdummy}{\strut\ignorespaces#1\unskip}% beter etex/btex +%D \setMPtext{bdummy}{\strut\ignorespaces#2\unskip}% beter etex/btex +%D \startMPdrawing +%D set_step_chart_cells(\MPstring{tdummy},\MPstring{bdummy}) ; +%D \stopMPdrawing} +%D +%D \def\stepcharttexts#1#2% +%D {\setMPtext{tdummy}{\strut\ignorespaces#1\unskip}% beter etex/btex +%D \setMPtext{bdummy}{\strut\ignorespaces#2\unskip}% beter etex/btex +%D \startMPdrawing +%D set_step_chart_texts(\MPstring{tdummy},\MPstring{bdummy}) ; +%D \stopMPdrawing} +%D +%D \def\stopSTEPchart +%D {\startMPdrawing +%D end_step_chart ; +%D \stopMPdrawing +%D \MPdrawingdonetrue +%D \getMPdrawing +%D \resetMPdrawing +%D \egroup} +%D \stoptyping +%D +%D This method has the advantage that it does the job in +%D (virtually) one pass, while the next methods need multiple +%D passes: one to build the table, another to synchronize the +%D positions, and a third one beause the dimensions may have +%D changed. The last pass is a result from the fact that +%D positions are related to the page. +%D +%D The second attempt was based on tabulations and used the +%D build in position tracking mechanism, which uses two +%D position nodes per cell. +%D +%D This method collects the content in token list registers +%D and build a table from them. In the collecting pass, the +%D graphics are build stepwise. We need to collect because the +%D order of definitions is not the same as the order of +%D typesetting. We show this alternative too because it +%D demonstrates how to apply backgrounds to table cells. +%D +%D \starttyping +%D \newtoks\stepsonetop \newtoks\stepstwotop +%D \newtoks\stepsonebot \newtoks\stepstwobot +%D \stoptyping +%D +%D During the collecting phase, we temporarily have to +%D increment the name space counter. +%D +%D \starttyping +%D \def\startSTEPchart% +%D {\bgroup +%D \resetMPdrawing +%D \advance\noftabpositions\plusone % begin of preroll +%D \startMPdrawing +%D input mp-step.mpii ; +%D begin_step_chart ; +%D \stopMPdrawing +%D \initializeSTEP +%D \newcounter\cellcounter +%D \stepsonetop\emptytoks \chardef\somesteponetop=1 +%D \stepsonebot\emptytoks \chardef\somesteponebot=1 +%D \stepstwotop\emptytoks \chardef\somesteptwotop=1 +%D \stepstwobot\emptytoks \chardef\somesteptwobot=1 +%D \let\cells\stepchartcells \def\cell{\cells{}}% +%D \let\texts\stepcharttexts \def\text{\texts{}}} +%D \stoptyping +%D +%D Now we collect the steps and texts, and in the process the +%D graphic is built. Then we continue with building the table. +%D +%D Watch how we anchor the graphic to the main table box. This +%D is needed since the graphic may be larger than the table +%D itself. Actually, these small point took me the most time to +%D digest, even with the right tools (anchors) already in +%D place. +%D +%D \starttyping +%D \def\stopSTEPchart +%D {\splittabulatefalse +%D \insidefloattrue +%D \startMPdrawing +%D nofcells := \cellcounter ; +%D end_step_chart ; +%D anchor_box(\MPpos{\tbPOSprefix origin}) ; +%D \stopMPdrawing +%D \MPdrawingdonetrue +%D \advance\noftabpositions\minusone % end of preroll +%D \setbox0=\vbox +%D {\getMPdrawing} +%D \resetMPdrawing +%D \increment(\cellcounter,\cellcounter)\decrement\cellcounter +%D \setbox2=\vbox +%D {\definetabulate[chart][|*{\cellcounter}{ck0|}] % k0 nills space +%D \startchart +%D \ifcase\somesteptwotop \the\stepstwotop \NC \NR \noalign{\kern2ex} \fi +%D \ifcase\somesteponetop \the\stepsonetop \NC \NR \noalign{\kern2ex} \fi +%D \ifcase\somesteponebot \the\stepsonebot \NC \NR \noalign{\kern2ex} \fi +%D \ifcase\somesteptwobot \the\stepstwobot \NC \NR \noalign{\kern2ex} \fi +%D \noalign{\kern-2ex}% +%D \stopchart} +%D \hbox +%D {\scratchdimen\wd0 +%D \advance\scratchdimen \MPllx bp +%D \raise\MPlly bp\box0 +%D \hskip-\scratchdimen +%D \hpos{\tbPOSprefix origin}{\box2}} +%D \egroup} +%D \stoptyping +%D +%D The steps and texts fill the (at most 4) lines that make up +%D the table. We also feed the (automatically registerd) cell +%D dimensions to the graphic backend. +%D +%D \starttyping +%D \newcounter\cellcounter +%D \newcounter\textcounter +%D +%D \def\stepchartcells#1#2% +%D {\doloop +%D {\ifnum\cellcounter>\textcounter +%D \stepcharttexts{}{}% +%D \else +%D \exitloop +%D \fi}% +%D \increment\cellcounter +%D \doifelsenothing{#1} +%D {\startMPdrawing +%D cells[t][\cellcounter] := origin ; +%D \stopMPdrawing +%D \appendtoks\NC\NC\to\stepsonetop} +%D {\chardef\somesteponetop=0 +%D \edef\stepidentifier{\cellcounter-t-c}% +%D \startMPdrawing +%D initialize_area(\MPpos{b:\tbPOSprefix\stepidentifier}, +%D \MPpos{e:\tbPOSprefix\stepidentifier}) ; +%D cells[t][\cellcounter] := pxy ; +%D \stopMPdrawing +%D \@EA\appendtoks\@EA\stepidentifierposition\@EA{\stepidentifier}#1\NC\to\stepsonetop}% +%D \doifelsenothing{#2} +%D {\startMPdrawing +%D cells[b][\cellcounter] := origin ; +%D \stopMPdrawing +%D \appendtoks\NC\NC\to\stepsonebot} +%D {\chardef\somesteponebot=0 +%D \edef\stepidentifier{\cellcounter-b-c}% +%D \startMPdrawing +%D initialize_area(\MPpos{b:\tbPOSprefix\stepidentifier}, +%D \MPpos{e:\tbPOSprefix\stepidentifier}) ; +%D cells[b][\cellcounter] := pxy ; +%D \stopMPdrawing +%D \@EA\appendtoks\@EA\stepidentifierposition\@EA{\stepidentifier}#2\NC\to\stepsonebot}} +%D +%D \def\stepcharttexts#1#2% \cellcounter = nofcells +%D {\increment\textcounter +%D \doifelsenothing{#1} +%D {\startMPdrawing +%D texts[t][\cellcounter][\textcounter] := origin ; +%D \stopMPdrawing +%D \appendtoks\NC\NC\to\stepstwotop} +%D {\chardef\somesteptwotop=0 +%D \edef\stepidentifier{\cellcounter-\textcounter-t-t}% +%D \startMPdrawing +%D initialize_area(\MPpos{b:\tbPOSprefix\stepidentifier}, +%D \MPpos{e:\tbPOSprefix\stepidentifier}) ; +%D texts[t][\cellcounter][\textcounter] := pxy ; +%D \stopMPdrawing +%D \@EA\appendtoks\@EA\NC\@EA\textcellposition\@EA{\stepidentifier}#1\to\stepstwotop}% +%D \doifelsenothing{#2} +%D {\startMPdrawing +%D texts[b][\cellcounter][\textcounter] := origin ; +%D \stopMPdrawing +%D \appendtoks\NC\NC\to\stepstwobot} +%D {\chardef\somesteptwobot=0 +%D \edef\stepidentifier{\cellcounter-\textcounter-b-t}% +%D \startMPdrawing +%D initialize_area(\MPpos{b:\tbPOSprefix\stepidentifier}, +%D \MPpos{e:\tbPOSprefix\stepidentifier}) ; +%D texts[b][\cellcounter][\textcounter] := pxy ; +%D \stopMPdrawing +%D \@EA\appendtoks\@EA\NC\@EA\textcellposition\@EA{\stepidentifier}#2\to\stepstwobot}} +%D \stoptyping +%D +%D Here are the hooks that take care of calculating the cell +%D dimensions. +%D +%D \starttyping +%D \def\textcellposition#1{\GSC[#1:text]} +%D \def\stepidentifierposition#1{\GSC[#1:step]} +%D \stoptyping +%D +%D We abandoned this method after some testing and went for +%D a third one. It was this third method that evolved into the +%D current mechanism. +%D +%D Since this method was not that efficient, a third one was +%D implemented, which used one position per cell. So, +%D +%D \blank {\bf Here starts the real implementation!} \blank +%D +%D Because we want to build one graphic only we need to store +%D the graphic directives. We also need to collect the cells, +%D which are not defined in the order they show up. This +%D solution uses multiple passes over the definitions. First +%D the cells and texts are processed and the associated +%D graphics are defined in the \METAPOST\ file. Next the +%D lines are flushed. We need to do that in a second pass, +%D because in order to determine the nature of the line, +%D \METAPOST\ needs to know if the start and end cells exist. +%D This need comes from the fact that we store the shapes +%D and lines kind of directly with their associated colors and +%D types, so that we can change the settings in between. So, +%D changing for instance the line color, can take place +%D locally. + +\newbox\stepboxone \newbox\stepboxtwo +\newbox\textboxone \newbox\textboxtwo + +%D We need to define a dedicated name space counter. + +\newcounter\currentstepchart + +\def\stepchartprefix{@sc@-\currentstepchart-} + +%D Next we define the initialization part of the macros. + +\newcounter\cellcounter +\newcounter\textcounter + +\def\startSTEPchart + {\dosingleempty\dostartSTEPchart} + +\long\def\dostartSTEPchart[#1]#2\stopSTEPchart + {\ifinsidefloat + \else + \whitespace + \@@STPCbefore + \startbaselinecorrection + \setlocalhsize + \noindent + \fi + \vbox\bgroup + \setupSTEPcharts[#1]% + \forgetall + \pushMPdrawing + \resetMPdrawing + \doglobal\increment\currentstepchart + \startMPdrawing + input mp-step.mpii ; + begin_step_chart ; + \stopMPdrawing + \initializeSTEP + \initializeSTPC + \global\chardef\somestepboxone\plusone + \global\chardef\sometextboxone\plusone + \global\chardef\somestepboxtwo\somestepboxone + \global\chardef\sometextboxtwo\sometextboxone + \def\startlines{\bgroup\setupSTEPlines}% + \def\stoplines {\egroup}% + \def\cells{\dosingleempty\dostepchartcells} + \def\texts{\dosingleempty\dostepcharttexts} + \def\cell {\dosingleempty\docell}% + \def\text {\dosingleempty\dotext}% + \def\docell[##1]{\dostepchartcells[##1]{}}% + \def\dotext[##1]{\dostepcharttexts[##1]{}} + \doglobal\newcounter\cellcounter + \doglobal\newcounter\textcounter + \let\dostepchartcells\doSTEPchartcellsA + \let\dostepcharttexts\doSTEPcharttextsA + {#2} % pass one: cells and texts {} keeps setting local + \startMPdrawing + nofcells := \cellcounter ; + analyze_step_chart ; + \stopMPdrawing + \doglobal\newcounter\cellcounter + \doglobal\newcounter\textcounter + \let\dostepchartcells\doSTEPchartcellsB + \let\dostepcharttexts\doSTEPcharttextsB + {#2} % pass two: lines + \startMPdrawing + end_step_chart ; + % if box_found(\MPpos{\stepchartprefix origin}) : + % initialize_box(\MPpos{\stepchartprefix origin}) ; + % draw pxy ; + % fi ; + anchor_box(\MPpos{\stepchartprefix origin}) ; + \stopMPdrawing + \MPdrawingdonetrue + \doifelse\@@STPCmethod{0} + {\setbox0\null} + {\setbox0\vbox{\MPstaticgraphictrue\getMPdrawing}}% + \resetMPdrawing + \setbox2\vbox + {\offinterlineskip + \scratchdimen\@@STPCheight + \advance\scratchdimen\@@STPCoffset + \advance\scratchdimen\@@STPCoffset + \ifcase\sometextboxone \box\textboxone \vskip\scratchdimen \fi + \ifcase\somestepboxone \box\stepboxone \vskip\@@STPCvoffset \fi + \ifcase\somestepboxtwo \box\stepboxtwo \vskip\scratchdimen \fi + \ifcase\sometextboxtwo \box\textboxtwo \vskip\@@STPCvoffset \fi + \global\setbox\stepboxone\emptybox \global\setbox\stepboxtwo\emptybox % needed indeed + \global\setbox\textboxone\emptybox \global\setbox\textboxtwo\emptybox % needed indeed + %\kern-\scratchdimen % no, instead: + \vskip-\lastskip} + \hbox + {\scratchdimen\wd0 + \advance\scratchdimen \MPllx bp + \raise\MPlly bp\box0 + \hskip-\scratchdimen + \hpos{\stepchartprefix origin}{\box2}}% + \popMPdrawing + \egroup + \ifinsidefloat \else \stopbaselinecorrection \@@STPCafter \fi} + +%D The next macro looks more complicated than it is. We collect +%D the cells in boxes. Before adding a new step cell, we padd +%D the text rows. After adding the step cells, we flush text +%D cells that are defined but not yet processed. + +\def\doSTEPchartcellsA[#1]#2#3% + {% synchronize texts + \doSTEPchartcellsAB[#1]{#2}{#3}% + % package steps + \setbox0\hbox{\doifsomething{#2}{\@@stepcell{#2}}}% + \setbox2\hbox{\doifsomething{#3}{\@@stepcell{#3}}}% + \ifdim\wd0>\zeropoint \!!doneafalse \else \!!doneatrue \fi + \ifdim\wd2>\zeropoint \!!donebfalse \else \!!donebtrue \fi + \ifdim\wd0>\wd2 + \setbox2\hbox to \wd0{\hss\box2\hss}% + \else + \setbox0\hbox to \wd2{\hss\box0\hss}% + \fi + \if!!donea + \startMPdrawing + cells[t][\cellcounter] := nullpicture ; + \stopMPdrawing + \else + \global\chardef\somestepboxone\zerocount + \edef\stepidentifier{\stepchartprefix\cellcounter-t-c}% + \setbox0\hbox{\hpos{\stepidentifier}{\box0}}% + \bgroup + \iffirstargument\setupSTEPcells[#1]\fi\initializeSTEC + \startMPdrawing + initialize_box(\MPpos{\stepidentifier}) ; + cells[t][\cellcounter] := \MPcellsgraphic ; + \stopMPdrawing + \egroup + \fi + \if!!doneb + \startMPdrawing + cells[b][\cellcounter] := nullpicture ; + \stopMPdrawing + \else + \global\chardef\somestepboxtwo\zerocount + \edef\stepidentifier{\stepchartprefix\cellcounter-b-c}% + \setbox2\hbox{\hpos{\stepidentifier}{\box2}}% + \bgroup + \iffirstargument\setupSTEPcells[#1]\fi\initializeSTEC + \startMPdrawing + initialize_box(\MPpos{\stepidentifier}) ; + cells[b][\cellcounter] := \MPcellsgraphic ; + \stopMPdrawing + \egroup + \fi + \global\setbox\stepboxone\hbox + {\ifdim\wd\stepboxone>\zeropoint + \box\stepboxone\hskip\@@STPChoffset\else + \fi\box0}% + \global\setbox\stepboxtwo\hbox + {\ifdim\wd\stepboxtwo>\zeropoint + \box\stepboxtwo\hskip\@@STPChoffset\else + \fi\box2}% + % flush saved texts + \doSTEPchartcellsBA} + +\def\doSTEPchartcellsB[#1]#2#3% + {\doSTEPchartcellsAB[#1]{#2}{#3}% + \doSTEPchartcellsBA} + +\def\doSTEPchartcellsAB[#1]#2#3% + {\doloop + {\ifnum\cellcounter>\textcounter + \texts{}{}\else\exitloop + \fi}% + \doglobal\increment\cellcounter} + +\def\doSTEPchartcellsBA + {\scratchtoks\stepchartbuffer + \stepchartbuffer\emptytoks + \the\scratchtoks} + +\def\MPcellsgraphic + {image ( drawshape ( + \@@STECalternative, pxy enlarged (-.5*\@@STECoffset), + \@@STECrulethickness, \MPcolor{\@@STECframecolor}, + \MPcolor{\@@STECbackgroundcolor} ) )} + +%D Although each step can have only one associated text, the +%D place where the text is defined determines the starting +%D point of the connecting arrow. Although several methods are +%D possible, we've chosen a funny collector that flushes one +%D step text at a time. + +\newtoks\stepchartbuffer + +\def\doSTEPcharttextsA[#1]% #2 #3 + {\dodoSTEPcharttextsA{\cellcounter}{#1}} + +\def\dodoSTEPcharttextsA#1#2#3#4% #1=number #2=setup + {\dodoSTEPcharttextsAB{#1}{#2}{#3}{#4}\dodoSTEPcharttextsA + \ifnum\textcounter>\cellcounter\relax + \doglobal\decrement\textcounter\relax + \else + \setbox0\hbox{\doifsomething{#3}{\@@steptext{#3}}}% + \setbox2\hbox{\doifsomething{#4}{\@@steptext{#4}}}% + \ifdim\wd0>\zeropoint \!!doneafalse \else \!!doneatrue \fi + \ifdim\wd2>\zeropoint \!!donebfalse \else \!!donebtrue \fi + \if!!donea + \setbox0\hbox to \@@STPChoffset{\hss}% + \startMPdrawing + texts[t][#1][\textcounter] := nullpicture ; + \stopMPdrawing + \else + \global\chardef\sometextboxone\zerocount + \edef\stepidentifier{\stepchartprefix#1-\textcounter-t-t}% + \setbox0\hbox to \@@STPChoffset + {\hss\hpos{\stepidentifier}{\box0}\hss}% + \bgroup + \setupSTEPtexts[#2]\initializeSTET + \startMPdrawing + initialize_box(\MPpos{\stepidentifier}) ; + texts[t][#1][\textcounter] := \MPtextsgraphic ; + \stopMPdrawing + \egroup + \fi + \if!!doneb + \setbox2\hbox to \@@STPChoffset{\hss}% + \startMPdrawing + texts[b][#1][\textcounter] := nullpicture ; + \stopMPdrawing + \else + \global\chardef\sometextboxtwo\zerocount + \edef\stepidentifier{\stepchartprefix#1-\textcounter-b-t}% + \setbox2\hbox to \@@STPChoffset + {\hss\hpos{\stepidentifier}{\box2}\hss}% + \bgroup + \setupSTEPtexts[#2]\initializeSTET + \startMPdrawing + initialize_box(\MPpos{\stepidentifier}) ; + texts[b][#1][\textcounter] := \MPtextsgraphic ; + \stopMPdrawing + \egroup + \fi + \global\setbox\textboxone\hbox + {\hbox to \wd\stepboxone{\box\textboxone\hss}\box0} + \global\setbox\textboxtwo\hbox + {\hbox to \wd\stepboxtwo{\box\textboxtwo\hss}\box2} + \fi} + +\def\doSTEPcharttextsB[#1]% #2 #3 + {\dodoSTEPcharttextsB{\cellcounter}{#1}} + +\def\dodoSTEPcharttextsB#1#2#3#4% #1=number #2=setup + {\dodoSTEPcharttextsAB{#1}{#2}{#3}{#4}\dodoSTEPcharttextsB + \ifnum\textcounter>\cellcounter\relax + \doglobal\decrement\textcounter\relax + \else + \bgroup + \initializeSTEL + \startMPdrawing + lines[t][#1][\textcounter] := \MPcharttoplinesgraphic{#1}\textcounter ; + lines[b][#1][\textcounter] := \MPchartbotlinesgraphic{#1}\textcounter ; + \stopMPdrawing + \egroup + \fi} + +\def\dodoSTEPcharttextsAB#1#2#3#4#5% #1=number #2=setup + {\doglobal\increment\textcounter\relax + \ifnum\textcounter>\cellcounter\relax + \@EA\appendtoks\@EA#5\@EA{#1}{#2}{#3}{#4}\to\stepchartbuffer + \fi} + +\def\MPtextsgraphic + {image(drawshape( + \@@STETalternative, pxy enlarged (-.5*\@@STEToffset), + \@@STETrulethickness, \MPcolor{\@@STETframecolor}, + \MPcolor{\@@STETbackgroundcolor} ) )} + +\def\MPcharttoplinesgraphic#1#2% + {image(drawline( + \@@STELalternative, get_step_chart_top_line(#1,#2), + \@@STELrulethickness, \MPcolor{\@@STELcolor} ) )} + +\def\MPchartbotlinesgraphic#1#2% + {image(drawline( + \@@STELalternative, get_step_chart_bot_line(#1,#2), + \@@STELrulethickness, \MPcolor{\@@STELcolor} ) )} + +%D Step tables are the vertical counterpart of stepcharts. + +\newcounter\currentsteptable + +\def\steptableprefix{@st@-\currentsteptable-} + +\def\startSTEPtable + {\dosingleempty\dostartSTEPtable} + +\def\dostartSTEPtable[#1]#2\stopSTEPtable + {\dostartSTEPaligntable[0][#1]#2\stopSTEPaligntable} + +\def\startSTEPaligntable + {\dodoubleempty\dostartSTEPaligntable[1]} + +\def\dostartSTEPaligntable[#1][#2]#3\stopSTEPaligntable % flag settings data + {\ifinsidefloat + \else + \whitespace + \@@STPTbefore + \startbaselinecorrection + \setlocalhsize + \noindent + \fi + \vbox\bgroup + \setupSTEPtables[#2]% + \forgetall + \pushMPdrawing + \doglobal\increment\currentsteptable + \startMPdrawing + input mp-step.mpii ; + begin_step_table ; + \stopMPdrawing + \initializeSTEP + \initializeSTPT + \def\startlines{\bgroup\setupSTEPlines}% + \def\stoplines {\egroup}% + \def\prep##1{\ignorespaces##1\unskip\enspace\ignorespaces}% + \def\cell {\dosingleempty\docell}% + \def\cells {\dosingleempty\docells}% + \def\text {\dosingleempty\dotext}% + % first graphic pass, also trial pass + \global\dimen1\zeropoint + \global\dimen3\zeropoint + \global\dimen5\zeropoint + \def\docell[##1]% + {\docells[##1]{}{}}% + \def\docells[##1]##2##3##4% + {\doglobal\increment\cellcounter + \bgroup + \iffirstargument\setupSTEPcells[##1]\fi + \initializeSTEC + \startMPdrawing + if box_found(\MPpos{\steptableprefix\cellcounter-c}) : + initialize_box(\MPpos{\steptableprefix\cellcounter-c}) ; + cells[\cellcounter] := \MPcellsgraphic ; + fi ; + \stopMPdrawing + \egroup + \def\do####1####2% + {\setbox\scratchbox\hbox{\@@stepfake{####2}}% + \ifdim\wd\scratchbox>\dimen####1\global\dimen####1=\wd\scratchbox\fi}% + \ifcase#1\else\do1{##2}\do3{##3}\fi\do5{##4}}% + \def\dotext[##1]##2% + {\bgroup + \iffirstargument\setupSTEPtexts[##1]\fi + \initializeSTET + \startMPdrawing + if box_found(\MPpos{\steptableprefix\cellcounter-t}) : + initialize_box(\MPpos{\steptableprefix\cellcounter-t}) ; + texts[\cellcounter] := \MPtextsgraphic ; + fi ; + \stopMPdrawing + \egroup} + \doglobal\newcounter\cellcounter#3 + % second graphic pass pass, drawing lines + \def\docells[##1]##2##3##4% + {\doglobal\increment\cellcounter} + \def\dotext[##1]##2% + {\bgroup + \initializeSTEL + \startMPdrawing + lines[\cellcounter] := \MPtablelinesgraphic ; + \stopMPdrawing + \egroup} + \doglobal\newcounter\cellcounter#3 + % finishing graphic touch + \startMPdrawing + nofcells := \cellcounter ; + end_step_table ; + anchor_box(\MPpos{\steptableprefix origin}) ; + \stopMPdrawing + \MPdrawingdonetrue + \doifelse\@@STPTmethod{0} + {\setbox0\null} + {\setbox0\vbox{\MPstaticgraphictrue\getMPdrawing}}% + \resetMPdrawing + % typesetting pass + \dimen6=\@@STPTdistance \dimen6=2\dimen6 + % cell width + \dimen8=\dimen1 + \advance\dimen8\dimen3 + \advance\dimen8\dimen5 + % offset width + \ifcase#1\else \advance\dimen8 \dimen6 \fi + % arrow width + \advance\dimen8 \@@STPTwidth + \advance\dimen8 \@@STPToffset + \advance\dimen8 \@@STPToffset + \def\docells[##1]##2##3##4% + {\doglobal\increment\cellcounter + \def\do####1####2####3####4% % strut really needed there ! + {\hbox to \dimen####1{####2\@@stepfake{####3}\strut####4}}% + \setbox8\hbox + {\ifcase#1\else + \do1\hss{##2}\relax \hskip\@@STPTdistance + \do3\hss{##3}\hss \hskip\@@STPTdistance + \fi + \do5\relax{##4}\hss}% + \hpos{\steptableprefix\cellcounter-c}{\@@stepcell{\box8}} + \endgraf + \nointerlineskip + \kern\@@STPTvoffset} + \def\dotext[##1]##2% + {\bgroup + \hskip\dimen8 + \advance\hsize-\dimen8 + \advance\hsize-\dimen6 % twice the offset + \setbox0\hbox{\@@steptext{##2}}% +% to do +% \ifdim\wd0>\hsize +% \setbox0=\vbox{\@@steptext{##2}}% +% \fi +% align + \hpos{\steptableprefix\cellcounter-t}{\box0}% + \endgraf + \egroup + \nointerlineskip + \kern\@@STPTvoffset} + \setbox2\vbox + {\doglobal\newcounter\cellcounter + #3\kern-\@@STPTvoffset} + \hbox + {\scratchdimen\wd0 + \advance\scratchdimen \MPllx bp + \raise\MPlly bp\box0 + \hskip-\scratchdimen + \hpos{\steptableprefix origin}{\box2}} + \popMPdrawing + \egroup + \ifinsidefloat \else \stopbaselinecorrection \@@STPTafter \fi} + +\def\MPtablelinesgraphic + {image ( drawline ( + \@@STELalternative, get_step_table_line(\cellcounter), + \@@STELrulethickness, \MPcolor{\@@STELcolor} ) )} + +\protect + +\continueifinputfile{m-steps.tex} + +% A simple paragraph-flow test: + +\starttext + +\startbuffer +\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 +\stopbuffer + +\getbuffer + +\startnarrower \getbuffer \stopnarrower + +\placefigure[left]{}{\getbuffer} + +\stoptext 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 + + some cell + some text + some cell + some text + some cell + +\stopbuffer + +\typebuffer \processxmlbuffer + + +\startbuffer + + some cell + some text + some cell + some text + some cell + +\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 + + some text some text + text text + some text some text + +\stopbuffer + +\processxmlbuffer + +\startbuffer + + some text + text text + some text + +\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/m-steps.tex b/tex/context/base/m-steps.tex deleted file mode 100644 index 7bc92d456..000000000 --- a/tex/context/base/m-steps.tex +++ /dev/null @@ -1,837 +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 When I need this module, I will reimplement it by using the new -%D sometxt macro. Anyhow, it reflects the state of 2001. - -\unprotect - -% temp hack : - -% \ifx\v!kleinkorps\undefined \let\v!kleinkorps\setsmallbodyfont \fi - -% end of hack - -\definecolor [STEPlinecolor] [s=.5] -\definecolor [STEPframecolor] [s=.7] -\definecolor [STEPbackgroundcolor] [s=.9] - -\def\@@STPF{@@STPF} % frames - -\def\@@STPC{@@STPC} % charts -\def\@@STPT{@@STPT} % tables - -\def\@@STEC{@@STEC} % cells -\def\@@STET{@@STET} % tables -\def\@@STEL{@@STEL} % lines - -\def\setupSTEPcharts{\dodoubleargument\getparameters[\@@STPC]} -\def\setupSTEPtables{\dodoubleargument\getparameters[\@@STPT]} -\def\setupSTEPcells {\dodoubleargument\getparameters[\@@STEC]} -\def\setupSTEPtexts {\dodoubleargument\getparameters[\@@STET]} -\def\setupSTEPlines {\dodoubleargument\getparameters[\@@STEL]} - -\setupSTEPcharts - [\c!before=\blank, - \c!after=\blank, - %\c!distance=.25em, % nvt - \c!hoffset=1em, - \c!voffset=1ex, - \c!method=1, - \c!height=2ex, - \c!offset=.15\bodyfontsize] - -\setupSTEPtables - [\c!before=\blank, - \c!after=\blank, - \c!distance=.25em, - %\c!hoffset=1em, % nvt - \c!voffset=1ex, - \c!method=1, - \c!width=4em, - \c!offset=.15\bodyfontsize] - -\setupSTEPcells - [\c!alternative=24, - \c!background=\v!color, - \c!backgroundcolor=STEPbackgroundcolor, - \c!rulethickness=.1\bodyfontsize, - \c!framecolor=STEPframecolor, - \c!offset=.25\bodyfontsize, - \c!style=, - \c!color=] - -\setupSTEPtexts - [\c!alternative=24, - \c!background=\v!color, - \c!backgroundcolor=STEPbackgroundcolor, - \c!rulethickness=.1\bodyfontsize, - \c!framecolor=STEPframecolor, - \c!offset=.25\bodyfontsize, - \c!style=\v!smallbodyfont, - \c!color=] - -\setupSTEPlines - [\c!alternative=1, - \c!rulethickness=.15\bodyfontsize, - \c!color=STEPlinecolor] - -\def\initializeSTEP - {\initializeSTET \initializeSTEC \initializeSTEL} - -\def\initializeSTPC - {\freezedimenmacro\@@STPCoffset - \startMPdrawing - line_v_offset := \@@STPCoffset ; - line_method := \@@STPCmethod ; % only charts - \stopMPdrawing} - -\def\initializeSTPT - {\freezedimenmacro\@@STPToffset - \startMPdrawing - line_h_offset := \@@STPToffset ; - line_method := \@@STPTmethod ; % only charts - \stopMPdrawing} - -\def\initializeSTET - {\freezedimenmacro\@@STETrulethickness - \freezedimenmacro\@@STEToffset} - -\def\initializeSTEC - {\freezedimenmacro\@@STECrulethickness - \freezedimenmacro\@@STECoffset} - -\def\initializeSTEL - {\freezedimenmacro\@@STELrulethickness} - -%D ... - -\presetlocalframed[\@@STPF] - -\def\@@stepcell#1% - {\doattributes\@@STEC\c!style\c!color - {\localframed - [\@@STPF][\c!offset=\@@STECoffset,\c!frame=\v!off] - {\ignorespaces#1\unskip}}} - -\def\@@stepfake#1% - {\doattributes\@@STEC\c!style\c!color - {\ignorespaces#1\unskip}} - -\def\@@steptext#1% - {\doattributes\@@STET\c!style\c!color - {\localframed - [\@@STPF][\c!offset=\@@STEToffset,\c!frame=\v!off] - {\ignorespaces#1\unskip}}} - -%D The first attempt was purely \METAPOST\ based and spawned -%D the typesetting to the \METAFUN\ handler. This method -%D collects the cells, and directly passes them on to -%D \METAPOST. This method is the cleanest, but has the -%D disadvantage that one cannot embed hyperlinks or document -%D dependent definitions in the cells. The implementation -%D roughly looks as follows: -%D -%D \starttyping -%D \def\startSTEPchart% -%D {\bgroup -%D \startMPdrawing -%D input mp-step ; begin_step_chart ; -%D \stopMPdrawing -%D \initializeSTEP -%D \let\cells\stepchartcells \def\cell{\cells{}}% -%D \let\texts\stepcharttexts \def\text{\texts{}}} -%D -%D \def\stepchartcells#1#2% -%D {\setMPtext{tdummy}{\strut\ignorespaces#1\unskip}% beter etex/btex -%D \setMPtext{bdummy}{\strut\ignorespaces#2\unskip}% beter etex/btex -%D \startMPdrawing -%D set_step_chart_cells(\MPstring{tdummy},\MPstring{bdummy}) ; -%D \stopMPdrawing} -%D -%D \def\stepcharttexts#1#2% -%D {\setMPtext{tdummy}{\strut\ignorespaces#1\unskip}% beter etex/btex -%D \setMPtext{bdummy}{\strut\ignorespaces#2\unskip}% beter etex/btex -%D \startMPdrawing -%D set_step_chart_texts(\MPstring{tdummy},\MPstring{bdummy}) ; -%D \stopMPdrawing} -%D -%D \def\stopSTEPchart -%D {\startMPdrawing -%D end_step_chart ; -%D \stopMPdrawing -%D \MPdrawingdonetrue -%D \getMPdrawing -%D \resetMPdrawing -%D \egroup} -%D \stoptyping -%D -%D This method has the advantage that it does the job in -%D (virtually) one pass, while the next methods need multiple -%D passes: one to build the table, another to synchronize the -%D positions, and a third one beause the dimensions may have -%D changed. The last pass is a result from the fact that -%D positions are related to the page. -%D -%D The second attempt was based on tabulations and used the -%D build in position tracking mechanism, which uses two -%D position nodes per cell. -%D -%D This method collects the content in token list registers -%D and build a table from them. In the collecting pass, the -%D graphics are build stepwise. We need to collect because the -%D order of definitions is not the same as the order of -%D typesetting. We show this alternative too because it -%D demonstrates how to apply backgrounds to table cells. -%D -%D \starttyping -%D \newtoks\stepsonetop \newtoks\stepstwotop -%D \newtoks\stepsonebot \newtoks\stepstwobot -%D \stoptyping -%D -%D During the collecting phase, we temporarily have to -%D increment the name space counter. -%D -%D \starttyping -%D \def\startSTEPchart% -%D {\bgroup -%D \resetMPdrawing -%D \advance\noftabpositions\plusone % begin of preroll -%D \startMPdrawing -%D input mp-step ; -%D begin_step_chart ; -%D \stopMPdrawing -%D \initializeSTEP -%D \newcounter\cellcounter -%D \stepsonetop\emptytoks \chardef\somesteponetop=1 -%D \stepsonebot\emptytoks \chardef\somesteponebot=1 -%D \stepstwotop\emptytoks \chardef\somesteptwotop=1 -%D \stepstwobot\emptytoks \chardef\somesteptwobot=1 -%D \let\cells\stepchartcells \def\cell{\cells{}}% -%D \let\texts\stepcharttexts \def\text{\texts{}}} -%D \stoptyping -%D -%D Now we collect the steps and texts, and in the process the -%D graphic is built. Then we continue with building the table. -%D -%D Watch how we anchor the graphic to the main table box. This -%D is needed since the graphic may be larger than the table -%D itself. Actually, these small point took me the most time to -%D digest, even with the right tools (anchors) already in -%D place. -%D -%D \starttyping -%D \def\stopSTEPchart -%D {\splittabulatefalse -%D \insidefloattrue -%D \startMPdrawing -%D nofcells := \cellcounter ; -%D end_step_chart ; -%D anchor_box(\MPpos{\tbPOSprefix origin}) ; -%D \stopMPdrawing -%D \MPdrawingdonetrue -%D \advance\noftabpositions\minusone % end of preroll -%D \setbox0=\vbox -%D {\getMPdrawing} -%D \resetMPdrawing -%D \increment(\cellcounter,\cellcounter)\decrement\cellcounter -%D \setbox2=\vbox -%D {\definetabulate[chart][|*{\cellcounter}{ck0|}] % k0 nills space -%D \startchart -%D \ifcase\somesteptwotop \the\stepstwotop \NC \NR \noalign{\kern2ex} \fi -%D \ifcase\somesteponetop \the\stepsonetop \NC \NR \noalign{\kern2ex} \fi -%D \ifcase\somesteponebot \the\stepsonebot \NC \NR \noalign{\kern2ex} \fi -%D \ifcase\somesteptwobot \the\stepstwobot \NC \NR \noalign{\kern2ex} \fi -%D \noalign{\kern-2ex}% -%D \stopchart} -%D \hbox -%D {\scratchdimen\wd0 -%D \advance\scratchdimen \MPllx bp -%D \raise\MPlly bp\box0 -%D \hskip-\scratchdimen -%D \hpos{\tbPOSprefix origin}{\box2}} -%D \egroup} -%D \stoptyping -%D -%D The steps and texts fill the (at most 4) lines that make up -%D the table. We also feed the (automatically registerd) cell -%D dimensions to the graphic backend. -%D -%D \starttyping -%D \newcounter\cellcounter -%D \newcounter\textcounter -%D -%D \def\stepchartcells#1#2% -%D {\doloop -%D {\ifnum\cellcounter>\textcounter -%D \stepcharttexts{}{}% -%D \else -%D \exitloop -%D \fi}% -%D \increment\cellcounter -%D \doifelsenothing{#1} -%D {\startMPdrawing -%D cells[t][\cellcounter] := origin ; -%D \stopMPdrawing -%D \appendtoks\NC\NC\to\stepsonetop} -%D {\chardef\somesteponetop=0 -%D \edef\stepidentifier{\cellcounter-t-c}% -%D \startMPdrawing -%D initialize_area(\MPpos{b:\tbPOSprefix\stepidentifier}, -%D \MPpos{e:\tbPOSprefix\stepidentifier}) ; -%D cells[t][\cellcounter] := pxy ; -%D \stopMPdrawing -%D \@EA\appendtoks\@EA\stepidentifierposition\@EA{\stepidentifier}#1\NC\to\stepsonetop}% -%D \doifelsenothing{#2} -%D {\startMPdrawing -%D cells[b][\cellcounter] := origin ; -%D \stopMPdrawing -%D \appendtoks\NC\NC\to\stepsonebot} -%D {\chardef\somesteponebot=0 -%D \edef\stepidentifier{\cellcounter-b-c}% -%D \startMPdrawing -%D initialize_area(\MPpos{b:\tbPOSprefix\stepidentifier}, -%D \MPpos{e:\tbPOSprefix\stepidentifier}) ; -%D cells[b][\cellcounter] := pxy ; -%D \stopMPdrawing -%D \@EA\appendtoks\@EA\stepidentifierposition\@EA{\stepidentifier}#2\NC\to\stepsonebot}} -%D -%D \def\stepcharttexts#1#2% \cellcounter = nofcells -%D {\increment\textcounter -%D \doifelsenothing{#1} -%D {\startMPdrawing -%D texts[t][\cellcounter][\textcounter] := origin ; -%D \stopMPdrawing -%D \appendtoks\NC\NC\to\stepstwotop} -%D {\chardef\somesteptwotop=0 -%D \edef\stepidentifier{\cellcounter-\textcounter-t-t}% -%D \startMPdrawing -%D initialize_area(\MPpos{b:\tbPOSprefix\stepidentifier}, -%D \MPpos{e:\tbPOSprefix\stepidentifier}) ; -%D texts[t][\cellcounter][\textcounter] := pxy ; -%D \stopMPdrawing -%D \@EA\appendtoks\@EA\NC\@EA\textcellposition\@EA{\stepidentifier}#1\to\stepstwotop}% -%D \doifelsenothing{#2} -%D {\startMPdrawing -%D texts[b][\cellcounter][\textcounter] := origin ; -%D \stopMPdrawing -%D \appendtoks\NC\NC\to\stepstwobot} -%D {\chardef\somesteptwobot=0 -%D \edef\stepidentifier{\cellcounter-\textcounter-b-t}% -%D \startMPdrawing -%D initialize_area(\MPpos{b:\tbPOSprefix\stepidentifier}, -%D \MPpos{e:\tbPOSprefix\stepidentifier}) ; -%D texts[b][\cellcounter][\textcounter] := pxy ; -%D \stopMPdrawing -%D \@EA\appendtoks\@EA\NC\@EA\textcellposition\@EA{\stepidentifier}#2\to\stepstwobot}} -%D \stoptyping -%D -%D Here are the hooks that take care of calculating the cell -%D dimensions. -%D -%D \starttyping -%D \def\textcellposition#1{\GSC[#1:text]} -%D \def\stepidentifierposition#1{\GSC[#1:step]} -%D \stoptyping -%D -%D We abandoned this method after some testing and went for -%D a third one. It was this third method that evolved into the -%D current mechanism. -%D -%D Since this method was not that efficient, a third one was -%D implemented, which used one position per cell. So, -%D -%D \blank {\bf Here starts the real implementation!} \blank -%D -%D Because we want to build one graphic only we need to store -%D the graphic directives. We also need to collect the cells, -%D which are not defined in the order they show up. This -%D solution uses multiple passes over the definitions. First -%D the cells and texts are processed and the associated -%D graphics are defined in the \METAPOST\ file. Next the -%D lines are flushed. We need to do that in a second pass, -%D because in order to determine the nature of the line, -%D \METAPOST\ needs to know if the start and end cells exist. -%D This need comes from the fact that we store the shapes -%D and lines kind of directly with their associated colors and -%D types, so that we can change the settings in between. So, -%D changing for instance the line color, can take place -%D locally. - -\newbox\stepboxone \newbox\stepboxtwo -\newbox\textboxone \newbox\textboxtwo - -%D We need to define a dedicated name space counter. - -\newcounter\currentstepchart - -\def\stepchartprefix{@sc@-\currentstepchart-} - -%D Next we define the initialization part of the macros. - -\newcounter\cellcounter -\newcounter\textcounter - -\def\startSTEPchart - {\dosingleempty\dostartSTEPchart} - -\long\def\dostartSTEPchart[#1]#2\stopSTEPchart - {\ifinsidefloat - \else - \whitespace - \@@STPCbefore - \startbaselinecorrection - \setlocalhsize - \noindent - \fi - \vbox\bgroup - \setupSTEPcharts[#1]% - \forgetall - \pushMPdrawing - \resetMPdrawing - \doglobal\increment\currentstepchart - \startMPdrawing - input mp-step ; - begin_step_chart ; - \stopMPdrawing - \initializeSTEP - \initializeSTPC - \global\chardef\somestepboxone\plusone - \global\chardef\sometextboxone\plusone - \global\chardef\somestepboxtwo\somestepboxone - \global\chardef\sometextboxtwo\sometextboxone - \def\startlines{\bgroup\setupSTEPlines}% - \def\stoplines {\egroup}% - \def\cells{\dosingleempty\dostepchartcells} - \def\texts{\dosingleempty\dostepcharttexts} - \def\cell {\dosingleempty\docell}% - \def\text {\dosingleempty\dotext}% - \def\docell[##1]{\dostepchartcells[##1]{}}% - \def\dotext[##1]{\dostepcharttexts[##1]{}} - \doglobal\newcounter\cellcounter - \doglobal\newcounter\textcounter - \let\dostepchartcells\doSTEPchartcellsA - \let\dostepcharttexts\doSTEPcharttextsA - {#2} % pass one: cells and texts {} keeps setting local - \startMPdrawing - nofcells := \cellcounter ; - analyze_step_chart ; - \stopMPdrawing - \doglobal\newcounter\cellcounter - \doglobal\newcounter\textcounter - \let\dostepchartcells\doSTEPchartcellsB - \let\dostepcharttexts\doSTEPcharttextsB - {#2} % pass two: lines - \startMPdrawing - end_step_chart ; - % if box_found(\MPpos{\stepchartprefix origin}) : - % initialize_box(\MPpos{\stepchartprefix origin}) ; - % draw pxy ; - % fi ; - anchor_box(\MPpos{\stepchartprefix origin}) ; - \stopMPdrawing - \MPdrawingdonetrue - \doifelse\@@STPCmethod{0} - {\setbox0\null} - {\setbox0\vbox{\MPstaticgraphictrue\getMPdrawing}}% - \resetMPdrawing - \setbox2\vbox - {\offinterlineskip - \scratchdimen\@@STPCheight - \advance\scratchdimen\@@STPCoffset - \advance\scratchdimen\@@STPCoffset - \ifcase\sometextboxone \box\textboxone \vskip\scratchdimen \fi - \ifcase\somestepboxone \box\stepboxone \vskip\@@STPCvoffset \fi - \ifcase\somestepboxtwo \box\stepboxtwo \vskip\scratchdimen \fi - \ifcase\sometextboxtwo \box\textboxtwo \vskip\@@STPCvoffset \fi - \global\setbox\stepboxone\emptybox \global\setbox\stepboxtwo\emptybox % needed indeed - \global\setbox\textboxone\emptybox \global\setbox\textboxtwo\emptybox % needed indeed - %\kern-\scratchdimen % no, instead: - \vskip-\lastskip} - \hbox - {\scratchdimen\wd0 - \advance\scratchdimen \MPllx bp - \raise\MPlly bp\box0 - \hskip-\scratchdimen - \hpos{\stepchartprefix origin}{\box2}}% - \popMPdrawing - \egroup - \ifinsidefloat \else \stopbaselinecorrection \@@STPCafter \fi} - -%D The next macro looks more complicated than it is. We collect -%D the cells in boxes. Before adding a new step cell, we padd -%D the text rows. After adding the step cells, we flush text -%D cells that are defined but not yet processed. - -\def\doSTEPchartcellsA[#1]#2#3% - {% synchronize texts - \doSTEPchartcellsAB[#1]{#2}{#3}% - % package steps - \setbox0\hbox{\doifsomething{#2}{\@@stepcell{#2}}}% - \setbox2\hbox{\doifsomething{#3}{\@@stepcell{#3}}}% - \ifdim\wd0>\zeropoint \!!doneafalse \else \!!doneatrue \fi - \ifdim\wd2>\zeropoint \!!donebfalse \else \!!donebtrue \fi - \ifdim\wd0>\wd2 - \setbox2\hbox to \wd0{\hss\box2\hss}% - \else - \setbox0\hbox to \wd2{\hss\box0\hss}% - \fi - \if!!donea - \startMPdrawing - cells[t][\cellcounter] := nullpicture ; - \stopMPdrawing - \else - \global\chardef\somestepboxone\zerocount - \edef\stepidentifier{\stepchartprefix\cellcounter-t-c}% - \setbox0\hbox{\hpos{\stepidentifier}{\box0}}% - \bgroup - \iffirstargument\setupSTEPcells[#1]\fi\initializeSTEC - \startMPdrawing - initialize_box(\MPpos{\stepidentifier}) ; - cells[t][\cellcounter] := \MPcellsgraphic ; - \stopMPdrawing - \egroup - \fi - \if!!doneb - \startMPdrawing - cells[b][\cellcounter] := nullpicture ; - \stopMPdrawing - \else - \global\chardef\somestepboxtwo\zerocount - \edef\stepidentifier{\stepchartprefix\cellcounter-b-c}% - \setbox2\hbox{\hpos{\stepidentifier}{\box2}}% - \bgroup - \iffirstargument\setupSTEPcells[#1]\fi\initializeSTEC - \startMPdrawing - initialize_box(\MPpos{\stepidentifier}) ; - cells[b][\cellcounter] := \MPcellsgraphic ; - \stopMPdrawing - \egroup - \fi - \global\setbox\stepboxone\hbox - {\ifdim\wd\stepboxone>\zeropoint - \box\stepboxone\hskip\@@STPChoffset\else - \fi\box0}% - \global\setbox\stepboxtwo\hbox - {\ifdim\wd\stepboxtwo>\zeropoint - \box\stepboxtwo\hskip\@@STPChoffset\else - \fi\box2}% - % flush saved texts - \doSTEPchartcellsBA} - -\def\doSTEPchartcellsB[#1]#2#3% - {\doSTEPchartcellsAB[#1]{#2}{#3}% - \doSTEPchartcellsBA} - -\def\doSTEPchartcellsAB[#1]#2#3% - {\doloop - {\ifnum\cellcounter>\textcounter - \texts{}{}\else\exitloop - \fi}% - \doglobal\increment\cellcounter} - -\def\doSTEPchartcellsBA - {\scratchtoks\stepchartbuffer - \stepchartbuffer\emptytoks - \the\scratchtoks} - -\def\MPcellsgraphic - {image ( drawshape ( - \@@STECalternative, pxy enlarged (-.5*\@@STECoffset), - \@@STECrulethickness, \MPcolor{\@@STECframecolor}, - \MPcolor{\@@STECbackgroundcolor} ) )} - -%D Although each step can have only one associated text, the -%D place where the text is defined determines the starting -%D point of the connecting arrow. Although several methods are -%D possible, we've chosen a funny collector that flushes one -%D step text at a time. - -\newtoks\stepchartbuffer - -\def\doSTEPcharttextsA[#1]% #2 #3 - {\dodoSTEPcharttextsA{\cellcounter}{#1}} - -\def\dodoSTEPcharttextsA#1#2#3#4% #1=number #2=setup - {\dodoSTEPcharttextsAB{#1}{#2}{#3}{#4}\dodoSTEPcharttextsA - \ifnum\textcounter>\cellcounter\relax - \doglobal\decrement\textcounter\relax - \else - \setbox0\hbox{\doifsomething{#3}{\@@steptext{#3}}}% - \setbox2\hbox{\doifsomething{#4}{\@@steptext{#4}}}% - \ifdim\wd0>\zeropoint \!!doneafalse \else \!!doneatrue \fi - \ifdim\wd2>\zeropoint \!!donebfalse \else \!!donebtrue \fi - \if!!donea - \setbox0\hbox to \@@STPChoffset{\hss}% - \startMPdrawing - texts[t][#1][\textcounter] := nullpicture ; - \stopMPdrawing - \else - \global\chardef\sometextboxone\zerocount - \edef\stepidentifier{\stepchartprefix#1-\textcounter-t-t}% - \setbox0\hbox to \@@STPChoffset - {\hss\hpos{\stepidentifier}{\box0}\hss}% - \bgroup - \setupSTEPtexts[#2]\initializeSTET - \startMPdrawing - initialize_box(\MPpos{\stepidentifier}) ; - texts[t][#1][\textcounter] := \MPtextsgraphic ; - \stopMPdrawing - \egroup - \fi - \if!!doneb - \setbox2\hbox to \@@STPChoffset{\hss}% - \startMPdrawing - texts[b][#1][\textcounter] := nullpicture ; - \stopMPdrawing - \else - \global\chardef\sometextboxtwo\zerocount - \edef\stepidentifier{\stepchartprefix#1-\textcounter-b-t}% - \setbox2\hbox to \@@STPChoffset - {\hss\hpos{\stepidentifier}{\box2}\hss}% - \bgroup - \setupSTEPtexts[#2]\initializeSTET - \startMPdrawing - initialize_box(\MPpos{\stepidentifier}) ; - texts[b][#1][\textcounter] := \MPtextsgraphic ; - \stopMPdrawing - \egroup - \fi - \global\setbox\textboxone\hbox - {\hbox to \wd\stepboxone{\box\textboxone\hss}\box0} - \global\setbox\textboxtwo\hbox - {\hbox to \wd\stepboxtwo{\box\textboxtwo\hss}\box2} - \fi} - -\def\doSTEPcharttextsB[#1]% #2 #3 - {\dodoSTEPcharttextsB{\cellcounter}{#1}} - -\def\dodoSTEPcharttextsB#1#2#3#4% #1=number #2=setup - {\dodoSTEPcharttextsAB{#1}{#2}{#3}{#4}\dodoSTEPcharttextsB - \ifnum\textcounter>\cellcounter\relax - \doglobal\decrement\textcounter\relax - \else - \bgroup - \initializeSTEL - \startMPdrawing - lines[t][#1][\textcounter] := \MPcharttoplinesgraphic{#1}\textcounter ; - lines[b][#1][\textcounter] := \MPchartbotlinesgraphic{#1}\textcounter ; - \stopMPdrawing - \egroup - \fi} - -\def\dodoSTEPcharttextsAB#1#2#3#4#5% #1=number #2=setup - {\doglobal\increment\textcounter\relax - \ifnum\textcounter>\cellcounter\relax - \@EA\appendtoks\@EA#5\@EA{#1}{#2}{#3}{#4}\to\stepchartbuffer - \fi} - -\def\MPtextsgraphic - {image(drawshape( - \@@STETalternative, pxy enlarged (-.5*\@@STEToffset), - \@@STETrulethickness, \MPcolor{\@@STETframecolor}, - \MPcolor{\@@STETbackgroundcolor} ) )} - -\def\MPcharttoplinesgraphic#1#2% - {image(drawline( - \@@STELalternative, get_step_chart_top_line(#1,#2), - \@@STELrulethickness, \MPcolor{\@@STELcolor} ) )} - -\def\MPchartbotlinesgraphic#1#2% - {image(drawline( - \@@STELalternative, get_step_chart_bot_line(#1,#2), - \@@STELrulethickness, \MPcolor{\@@STELcolor} ) )} - -%D Step tables are the vertical counterpart of stepcharts. - -\newcounter\currentsteptable - -\def\steptableprefix{@st@-\currentsteptable-} - -\def\startSTEPtable - {\dosingleempty\dostartSTEPtable} - -\def\dostartSTEPtable[#1]#2\stopSTEPtable - {\dostartSTEPaligntable[0][#1]#2\stopSTEPaligntable} - -\def\startSTEPaligntable - {\dodoubleempty\dostartSTEPaligntable[1]} - -\def\dostartSTEPaligntable[#1][#2]#3\stopSTEPaligntable % flag settings data - {\ifinsidefloat - \else - \whitespace - \@@STPTbefore - \startbaselinecorrection - \setlocalhsize - \noindent - \fi - \vbox\bgroup - \setupSTEPtables[#2]% - \forgetall - \pushMPdrawing - \doglobal\increment\currentsteptable - \startMPdrawing - input mp-step ; - begin_step_table ; - \stopMPdrawing - \initializeSTEP - \initializeSTPT - \def\startlines{\bgroup\setupSTEPlines}% - \def\stoplines {\egroup}% - \def\prep##1{\ignorespaces##1\unskip\enspace\ignorespaces}% - \def\cell {\dosingleempty\docell}% - \def\cells {\dosingleempty\docells}% - \def\text {\dosingleempty\dotext}% - % first graphic pass, also trial pass - \global\dimen1\zeropoint - \global\dimen3\zeropoint - \global\dimen5\zeropoint - \def\docell[##1]% - {\docells[##1]{}{}}% - \def\docells[##1]##2##3##4% - {\doglobal\increment\cellcounter - \bgroup - \iffirstargument\setupSTEPcells[##1]\fi - \initializeSTEC - \startMPdrawing - if box_found(\MPpos{\steptableprefix\cellcounter-c}) : - initialize_box(\MPpos{\steptableprefix\cellcounter-c}) ; - cells[\cellcounter] := \MPcellsgraphic ; - fi ; - \stopMPdrawing - \egroup - \def\do####1####2% - {\setbox\scratchbox\hbox{\@@stepfake{####2}}% - \ifdim\wd\scratchbox>\dimen####1\global\dimen####1=\wd\scratchbox\fi}% - \ifcase#1\else\do1{##2}\do3{##3}\fi\do5{##4}}% - \def\dotext[##1]##2% - {\bgroup - \iffirstargument\setupSTEPtexts[##1]\fi - \initializeSTET - \startMPdrawing - if box_found(\MPpos{\steptableprefix\cellcounter-t}) : - initialize_box(\MPpos{\steptableprefix\cellcounter-t}) ; - texts[\cellcounter] := \MPtextsgraphic ; - fi ; - \stopMPdrawing - \egroup} - \doglobal\newcounter\cellcounter#3 - % second graphic pass pass, drawing lines - \def\docells[##1]##2##3##4% - {\doglobal\increment\cellcounter} - \def\dotext[##1]##2% - {\bgroup - \initializeSTEL - \startMPdrawing - lines[\cellcounter] := \MPtablelinesgraphic ; - \stopMPdrawing - \egroup} - \doglobal\newcounter\cellcounter#3 - % finishing graphic touch - \startMPdrawing - nofcells := \cellcounter ; - end_step_table ; - anchor_box(\MPpos{\steptableprefix origin}) ; - \stopMPdrawing - \MPdrawingdonetrue - \doifelse\@@STPTmethod{0} - {\setbox0\null} - {\setbox0\vbox{\MPstaticgraphictrue\getMPdrawing}}% - \resetMPdrawing - % typesetting pass - \dimen6=\@@STPTdistance \dimen6=2\dimen6 - % cell width - \dimen8=\dimen1 - \advance\dimen8\dimen3 - \advance\dimen8\dimen5 - % offset width - \ifcase#1\else \advance\dimen8 \dimen6 \fi - % arrow width - \advance\dimen8 \@@STPTwidth - \advance\dimen8 \@@STPToffset - \advance\dimen8 \@@STPToffset - \def\docells[##1]##2##3##4% - {\doglobal\increment\cellcounter - \def\do####1####2####3####4% % strut really needed there ! - {\hbox to \dimen####1{####2\@@stepfake{####3}\strut####4}}% - \setbox8\hbox - {\ifcase#1\else - \do1\hss{##2}\relax \hskip\@@STPTdistance - \do3\hss{##3}\hss \hskip\@@STPTdistance - \fi - \do5\relax{##4}\hss}% - \hpos{\steptableprefix\cellcounter-c}{\@@stepcell{\box8}} - \endgraf - \nointerlineskip - \kern\@@STPTvoffset} - \def\dotext[##1]##2% - {\bgroup - \hskip\dimen8 - \advance\hsize-\dimen8 - \advance\hsize-\dimen6 % twice the offset - \setbox0\hbox{\@@steptext{##2}}% -% to do -% \ifdim\wd0>\hsize -% \setbox0=\vbox{\@@steptext{##2}}% -% \fi -% align - \hpos{\steptableprefix\cellcounter-t}{\box0}% - \endgraf - \egroup - \nointerlineskip - \kern\@@STPTvoffset} - \setbox2\vbox - {\doglobal\newcounter\cellcounter - #3\kern-\@@STPTvoffset} - \hbox - {\scratchdimen\wd0 - \advance\scratchdimen \MPllx bp - \raise\MPlly bp\box0 - \hskip-\scratchdimen - \hpos{\steptableprefix origin}{\box2}} - \popMPdrawing - \egroup - \ifinsidefloat \else \stopbaselinecorrection \@@STPTafter \fi} - -\def\MPtablelinesgraphic - {image ( drawline ( - \@@STELalternative, get_step_table_line(\cellcounter), - \@@STELrulethickness, \MPcolor{\@@STELcolor} ) )} - -\protect - -\continueifinputfile{m-steps.tex} - -% A simple paragraph-flow test: - -\starttext - -\startbuffer -\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 -\stopbuffer - -\getbuffer - -\startnarrower \getbuffer \stopnarrower - -\placefigure[left]{}{\getbuffer} - -\stoptext diff --git a/tex/context/base/status-files.pdf b/tex/context/base/status-files.pdf index 38f7b8132..a4c56c6f8 100644 Binary files a/tex/context/base/status-files.pdf and b/tex/context/base/status-files.pdf differ diff --git a/tex/context/base/status-lua.pdf b/tex/context/base/status-lua.pdf index 10704da13..964cabb11 100644 Binary files a/tex/context/base/status-lua.pdf and b/tex/context/base/status-lua.pdf 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 -- cgit v1.2.3