From 779bbf5d736c524f4c66dc13dc5b4d812b164c71 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 3 Sep 2011 23:23:34 +0000 Subject: new context package context-gantt (3sep11) git-svn-id: svn://tug.org/texlive/trunk@23785 c570f23f-e606-0410-a88d-b1316a301751 --- .../metapost/context/third/hatching/mp-hatching.mp | 64 ++++ .../tex/context/third/gantt/gantt-s-mp.tex | 370 +++++++++++++++++++++ .../tex/context/third/gantt/gantt-s-tikz.tex | 312 +++++++++++++++++ .../tex/context/third/gantt/t-gantt.tex | 22 ++ Master/tlpkg/bin/tlpkg-ctan-check | 3 +- Master/tlpkg/tlpsrc/collection-context.tlpsrc | 1 + Master/tlpkg/tlpsrc/context-gantt.tlpsrc | 0 7 files changed, 771 insertions(+), 1 deletion(-) create mode 100644 Master/texmf-dist/doc/latex/context-gantt/metapost/context/third/hatching/mp-hatching.mp create mode 100644 Master/texmf-dist/doc/latex/context-gantt/tex/context/third/gantt/gantt-s-mp.tex create mode 100644 Master/texmf-dist/doc/latex/context-gantt/tex/context/third/gantt/gantt-s-tikz.tex create mode 100644 Master/texmf-dist/doc/latex/context-gantt/tex/context/third/gantt/t-gantt.tex create mode 100644 Master/tlpkg/tlpsrc/context-gantt.tlpsrc diff --git a/Master/texmf-dist/doc/latex/context-gantt/metapost/context/third/hatching/mp-hatching.mp b/Master/texmf-dist/doc/latex/context-gantt/metapost/context/third/hatching/mp-hatching.mp new file mode 100644 index 00000000000..af86e19d2b6 --- /dev/null +++ b/Master/texmf-dist/doc/latex/context-gantt/metapost/context/third/hatching/mp-hatching.mp @@ -0,0 +1,64 @@ +%%% addto clip hatchfill hatchfill_ +%%% numeric color +%%% length withcolor +% This is HATCHING.MP file defining a set of METAPOST macros for +% hatching interior of closed paths. +% +% Made in BOP, Gda\'nsk, Poland +% E-mail contact: B.Jackowski@gust.org.pl +% Public domain software (no copyrights, copylefts, copyups, copydowns, etc.) +% Current version: 11.07.2000 -- ver 0.1 (pre-release) +% Current version: 21.09.2000 -- ver 0.11 (ending semicolon +% added in |extra_beginfig|; |hatchfill_| introduced in order +% to make possible something like |def fill = hatchfill enddef| +def hatchfill_ expr c = addto currentpicture contour c _op_ enddef; + +vardef hatchfill text p = + save c_,p_; path p_; color c_[\\]; c_.num:=0; + save withcolor_; let withcolor_:=withcolor; + def withcolor = ; c_[incr c_.num]:= enddef; + p_:=p; let withcolor:=withcolor_; + for i_:=c_.num downto 1: % find the least ``true'' fill + c_.num':=i_; exitif bluepart(c_[i_])>0; + endfor + if c_.num>0: + for i_:=c_.num' upto c_.num: + if bluepart(c_[i_])<0: draw hatched(p_)c_[i_]; + else: hatchfill_ p_ withcolor c_[i_]; fi + endfor + else: hatchfill_ p_; fi +enddef; + +vardef hatched(expr o) primary c = + save a_, b_, d_, l_, i_, r_, za_, zb_, zc_, zd_; + path b_; picture r_; pair za_, zb_, zc_, zd_; + r_:=image( + a_:=redpart(c) mod 180; l_:=greenpart(c); d_:=-bluepart(c); + b_:=o rotated -a_; + b_:=if a_>=90: (lrcorner b_--llcorner b_--ulcorner b_--urcorner b_--cycle) + else: (llcorner b_--lrcorner b_--urcorner b_--ulcorner b_--cycle) fi + rotated a_; + za_:=point 0 of b_; zb_:=point 1 of b_; + zc_:=point 2 of b_; zd_:=point 3 of b_; + if hatch_match>0: + n_:=round(length(zd_-za_)/l_); if n_<2: n_:=2; fi; l_:=length(zd_-za_)/n_; + else: n_:=length(zd_-za_)/l_; fi + % show (greenpart(c), l_); + for i_:=if hatch_match>0: 1 else: 0 fi upto ceiling n_-1: + draw_hatched_band((i_/n_)[zd_,za_],(i_/n_)[zc_,zb_],a_,l_,d_); + endfor + ); + clip r_ to o; r_ +enddef; + +def draw_hatched_band(expr za,zb,a,l,d) = % normally, |a| and |l| are ignored + draw za--zb withpen pencircle scaled d _hop_; +enddef; + +def hatchoptions(text t) = def _hop_ = t enddef enddef; + +newinternal hatch_match; hatch_match:=1; +hatchoptions(); extra_beginfig:=extra_beginfig & ";hatchoptions();"; + +endinput +%%\end diff --git a/Master/texmf-dist/doc/latex/context-gantt/tex/context/third/gantt/gantt-s-mp.tex b/Master/texmf-dist/doc/latex/context-gantt/tex/context/third/gantt/gantt-s-mp.tex new file mode 100644 index 00000000000..f41f534ec29 --- /dev/null +++ b/Master/texmf-dist/doc/latex/context-gantt/tex/context/third/gantt/gantt-s-mp.tex @@ -0,0 +1,370 @@ +%D \module +%D [ file=t-gantt, +%D version=2011.08.27, +%D title=\CONTEXT\ User Module, +%D subtitle=Drawing gantt diagrams, +%D author={Adam Reviczky}, +%D date=\currentdate, +%D copyright=Adam Reviczky, +%D license=Public Domain] + +%D Some macros for drawing gantt diagrams using MetaPost. +%D +%D Adam Reviczky, 27.08.2011 (Version 3.2) + +\writestatus{loading}{ConTeXt User Module / Drawing gantt diagrams} + +\startmodule[gantt-s-mp] +\unprotect + +\def\????gantt{@@@@gantt} + +\definesystemvariable{gantt} + +\startMPinclusions + % temporary solution for a pattern substitute + input mp-hatching; +\stopMPinclusions + +\newcount\ganttnum +\newcount\gantttitlenum +\newcount\ganttwidth + +\newdimen\ganttlastx \ganttlastx = 0cm +\newdimen\nextganttlastx +\newdimen\titleunitlength \titleunitlength = 1cm +\newdimen\ganttunitlength \ganttunitlength = 1cm + +\newdimen\gantttmpa +\newdimen\gantttmpb + +% workaround for titleelement +\def\!!row{\numexpr\ganttnum*-1\relax} + +\def\setupgantt + {\bgroup + \catcode`\#=\@@other + \dosingleempty + \dosetupgantt} + +\def\dosetupgantt[#1]% + {\egroup + \getparameters[\??gantt][#1]} + +\setupgantt + [sx=1, + sy=1, + xunitlength=1cm, + fontsize=\tf, + titlefontsize=\tfx, + drawledgerline=false] + +\def\setupganttbar + {\bgroup + \catcode`\#=\@@other + \dosingleempty + \dosetupganttbar} + +\def\dosetupganttbar[#1]% + {\egroup + \getparameters[\??gantt][#1]} + +\setupganttbar + [pattern=north east lines, + color=black] + +% The gantt environment draws the canvas of a gantt figure (realized as tikzpicture) +% The usage is \startgantt[...]{no of Tasks to plot}{no of time slots} +% The optional argument [...] can be filled in a key=value syntax, using one or more of the following keys: +% +% xunitlength - length of one time slot (default: 1cm) +% fontsize - fontsize of labels (default: \tf) +% titlefontsize - fontsize of title section (default: \tfx) +% drawledgerline - Switch to enable/disable the drawing of horizontal ledger lines (default value: false) +\long\def\dostartgantt[#1]#2#3% + {\getparameters[\??gantt][#1]% + \gdef\v!sx{\@@ganttsx} + \gdef\v!sy{\@@ganttsy} + \gdef\v!ganttunitlength{\@@ganttxunitlength} + \gdef\v!fontsize{\getvalue{@@ganttfontsize}} + \gdef\v!titlefontsize{\getvalue{@@gantttitlefontsize}} + \gdef\v!drawledgerline{\@@ganttdrawledgerline} + + \bgroup + \newcount\ganttx \ganttx=0 + \newcount\ganttheight + + \def\ganttxstringtop{} + \def\ganttxstringbottom{} + + \global\ganttwidth=#3 + \global\ganttnum=0 + + \ganttheight=#2 + \advance\ganttheight by 1 + + \startMPdrawing + linecap := squared; + linejoin := mitered; + + draw (0,0.5cm)--(0,1.4cm-\the\ganttheight*cm); + draw (\the\ganttwidth*\v!ganttunitlength,0.5cm)--(\the\ganttwidth*\v!ganttunitlength,1.4cm-\the\ganttheight*cm); + % draw x axis + draw (0cm,-#2*cm+0.4cm)--(\the\ganttwidth*\v!ganttunitlength,-#2*cm+0.4cm); + + % draw grid + for t=1 upto \the\ganttwidth: + draw (\v!ganttunitlength*t,-0.5cm)--(\v!ganttunitlength*t,1.4cm-\the\ganttheight*cm) dashed withdots; + endfor + \stopMPdrawing + \egroup + } + +\def\startgantt% + {\dosingleempty\dostartgantt} + +\def\stopgantt% + {\startMPdrawing + % debug + % draw bbox currentpicture withcolor .625red; + \stopMPdrawing + \scale[sx=\v!sx,sy=\v!sy]{\MPdrawingdonetrue\getMPdrawing} + } + +% ganttitle is the environment for drawing the title section +\definestartstop[ganttitle][ + before={ + \ganttlastx = 0cm + }, + after={ + \ganttlastx = 0cm + \doglobal\decrement\ganttnum + } + ] + +% \titleelement draws one element of the title +% usage: \titleelement{label}{length} +\long\def\dotitleelement#1#2% + {\gantttmpa=\dimexpr\v!ganttunitlength*#2\relax + \divide\gantttmpa by 2 + + \startMPdrawing + draw (\the\ganttlastx,0.5cm-\the\!!row*cm)--(\the\ganttlastx+#2*\v!ganttunitlength,0.5cm-\the\!!row*cm)--(\the\ganttlastx+#2*\v!ganttunitlength,0.5cm-0.6cm-\the\!!row*cm)--(\the\ganttlastx,0.5cm-0.6cm-\the\!!row*cm)--cycle; + path diam; diam = (\the\ganttlastx,0.5cm-\the\!!row*cm)--(\the\ganttlastx+#2*\v!ganttunitlength,0.5cm-0.6cm-\the\!!row*cm); + label (btex \getvalue{v!titlefontsize} #1 etex, center diam); + \stopMPdrawing + + \ganttlastx=\dimexpr\ganttlastx+\v!ganttunitlength*#2\relax + } + +\def\titleelement% + {\dotitleelement} + +% \numtitle draws a numbered sequence of title elements +% usage: \numtitle{start number}{increment}{end number}{length of each title element} +\long\def\donumtitle#1#2#3#4% + {\gantttitlenum=#1 + \dostepwiserecurse{#1}{#3}{#2}{ + \titleelement{\the\gantttitlenum}{#4} + \advance\gantttitlenum by #2 + } + } + +\def\numtitle% + {\donumtitle} + +% \ganttbar draws a single, unconnected bar for representing a task +% usage: \ganttbar[pattern=,color=]{label}{start}{length} +% where the optional comma separated arguments are: +% pattern - not implemented with MetaPost yet! (FIXME) +% color - a color of the pattern (e.g. red, green blue gray, dark gray) +\long\def\doganttbar[#1]#2#3#4% + {\bgroup + \getparameters[\??gantt][#1]% + \edef\v!pattern{\@@ganttpattern} + \edef\v!color{\@@ganttcolor} + + \gantttmpa=\dimexpr\v!ganttunitlength*#3\relax + \gantttmpb=\dimexpr\v!ganttunitlength*#4+\gantttmpa\relax + + \doif{\v!drawledgerline}{true}{ + \startMPdrawing + draw (0,\ganttnum*cm-0.2cm)--(\the\ganttwidth*\v!ganttunitlength,\ganttnum*cm-0.2cm) dashed withdots; + \stopMPdrawing + } + \startMPdrawing + path diag; diag = (0,\ganttnum*cm+0.1cm)--(0,\ganttnum*cm+0.5cm); + label.lft (btex \getvalue{v!fontsize} #2 etex, center diag); + path f; f := (\the\gantttmpa,\ganttnum*cm+0.1cm)--(\the\gantttmpb,\ganttnum*cm+0.1cm)--(\the\gantttmpb,\ganttnum*cm+0.5cm)--(\the\gantttmpa,\ganttnum*cm+0.5cm)--cycle; + + hatchoptions(withcolor \v!color); + draw f withcolor black; + % workaround for transparent bug + % hatchfill f withcolor transparent("normal",0,white) withcolor (45,1mm,-0.5bp); + hatchfill f withcolor (45,1mm,-0.5bp); + \stopMPdrawing + + \global\ganttlastx=\gantttmpb + \doglobal\decrement\ganttnum + \egroup + } + +\def\ganttbar + {\dosingleempty\doganttbar} + +% \ganttcon draws an arrow between to bars with specified coordinates +% usage: \ganttcon{startx}{starty}{endx}{endy} +\long\def\doganttcon#1#2#3#4% + {\bgroup + \startMPdrawing + begingroup; + interim linecap := squared; + interim linejoin := rounded; + + drawarrow (#1*\v!ganttunitlength,-#2*cm+0.1cm+0.2cm)--(#1*\v!ganttunitlength+0.4*\v!ganttunitlength,-#2*cm+0.1*cm+0.2*cm)--(#1*\v!ganttunitlength+0.4*\v!ganttunitlength,-#2*cm-0.4*cm+0.2*cm)--(#1*\v!ganttunitlength-0.4*\v!ganttunitlength,-#2*cm-0.4*cm+0.2*cm)--(#1*\v!ganttunitlength-0.4*\v!ganttunitlength,-#4*cm+0.1*cm+0.2*cm)--(#3*\v!ganttunitlength,-#4*cm+0.1*cm+0.2*cm); + endgroup; + \stopMPdrawing + \egroup + } + +\def\ganttcon + {\doganttcon} + +% \ganttbarcon draws a single bar *and* connects the bar with the previous bar for +% consecutive tasks +% usage: \ganttbarcon[pattern=,color=]{label}{start}{length} +% where the optional pattern argument are the same as for \ganttbar +\long\def\doganttbarcon[#1]#2#3#4% + {\bgroup + \getparameters[\??gantt][#1]% + \edef\v!pattern{\@@ganttpattern} + \edef\v!color{\@@ganttcolor} + + \nextganttlastx = \dimexpr\ganttlastx+\ganttunitlength*1\relax + \ifdim\nextganttlastx>\dimexpr\v!ganttunitlength*#3\relax + \startMPdrawing + begingroup; + interim linecap := squared; + interim linejoin := rounded; + + drawarrow (\the\ganttlastx,\ganttnum*cm+1.1*cm+0.2*cm)--(\the\ganttlastx+0.4*\v!ganttunitlength,\ganttnum*cm+1.1*cm+0.2*cm)--(\the\ganttlastx+0.4*\v!ganttunitlength,\ganttnum*cm+0.6*cm+0.2*cm)--(\the\ganttlastx-0.4*\v!ganttunitlength,\ganttnum*cm+0.6*cm+0.2*cm)--(\the\ganttlastx-0.4*\v!ganttunitlength,\ganttnum*cm+0.1*cm+0.2*cm)--(#3*\v!ganttunitlength,\ganttnum*cm+0.1*cm+0.2*cm); + endgroup; + \stopMPdrawing + \else + \startMPdrawing + begingroup; + interim linecap := squared; + interim linejoin := rounded; + + drawarrow (\the\ganttlastx,\ganttnum*cm+1.1*cm+0.2*cm)--(\the\ganttlastx+0.4*\v!ganttunitlength,\ganttnum*cm+1.1*cm+0.2*cm)--(\the\ganttlastx+0.4*\v!ganttunitlength,\ganttnum*cm+0.1*cm+0.2*cm)--(#3*\v!ganttunitlength,\ganttnum*cm+0.1*cm+0.2*cm); + endgroup; + \stopMPdrawing + \fi + + \ganttbar[#1]{#2}{#3}{#4} + \egroup + } + +\def\ganttbarcon + {\dosingleempty\doganttbarcon} + +% \ganttgroup draws a bar to group tasks +% usage: \ganttgroup{label}{start}{length} +\long\def\doganttgroup#1#2#3% + {\bgroup + \gantttmpa=\dimexpr\v!ganttunitlength*#2\relax + \gantttmpb=\dimexpr\v!ganttunitlength*#3+\gantttmpa\relax + + \doif{\v!drawledgerline}{true}{ + \startMPdrawing + draw (0,\ganttnum*cm-0.2cm)--(\the\ganttwidth*\v!ganttunitlength,\ganttnum*cm-0.2cm) dashed withdots; + \stopMPdrawing + } + \startMPdrawing + pen diamond; diamond := makepen fulldiamond; + path diag; diag = (0,\ganttnum*cm+0.1cm)--(0,\ganttnum*cm+0.5cm); + label.lft (btex \getvalue{v!fontsize}\bf #1 etex, center diag); + fill (\the\gantttmpa-0.14*cm,\ganttnum*cm+0.2cm)--(\the\gantttmpb+0.14*cm,\ganttnum*cm+0.2cm)--(\the\gantttmpb+0.14*cm,\ganttnum*cm+0.4cm)--(\the\gantttmpa-0.14*cm,\ganttnum*cm+0.4cm)--cycle withcolor black; + fill fulldiamond scaled 0.3cm shifted (\the\gantttmpa+0.01cm,\ganttnum*cm+0.2cm) withcolor black; + fill fulldiamond scaled 0.3cm shifted (\the\gantttmpb-0.01cm,\ganttnum*cm+0.2cm) withcolor black; + \stopMPdrawing + + \global\ganttlastx=\gantttmpb + \doglobal\decrement\ganttnum + \egroup + } + +\def\ganttgroup + {\doganttgroup} + +% \ganttmilestone, draw a diamond to represent a milestone +% usage: \ganttgroup[color=]{label}{start} +% color - a tikz color of the pattern (e.g. red, green blue gray, dark gray) +% for more information see the tikz documentation + +% Declaring layers to abvoid superposition when you connect a \ganttmileston with a task +\long\def\doganttmilestone[#1]#2#3% + {\bgroup + \getparameters[\??gantt][#1]% + \edef\v!color{\@@ganttcolor} + + \gantttmpa=\dimexpr\v!ganttunitlength*#3\relax + \gantttmpb=\dimexpr\v!ganttunitlength*0+\gantttmpa\relax + + \doif{\v!drawledgerline}{true}{ + \startMPdrawing + draw (0,\ganttnum*cm-0.2cm)--(\the\ganttwidth*\v!ganttunitlength,\ganttnum*cm-0.2cm) dashed withdots; + \stopMPdrawing + } + \startMPdrawing + pen diamond; diamond := makepen fulldiamond; + path diag; diag = (0,\ganttnum*cm+0.1cm)--(0,\ganttnum*cm+0.5cm); + label.lft (btex \getvalue{v!fontsize} #2 etex, center diag); + fill fulldiamond scaled 0.3cm shifted (\the\gantttmpb,\ganttnum*cm+0.3cm) withcolor \v!color; + \stopMPdrawing + + \global\ganttlastx=\gantttmpb + \doglobal\decrement\ganttnum + \egroup + } + +\def\ganttmilestone + {\dosingleempty\doganttmilestone} + +% \ganttmilestonecon draws a single diamond *and* connects the diamond with the previous task +% usage: \ganttmilestonecon[color=]{label}{start}{length} +% where the optional color argument are the same as for \ganttbar and \ganttmilestone +\long\def\doganttmilestonecon[#1]#2#3% + {\bgroup + \getparameters[\??gantt][#1]% + \edef\v!color{\@@ganttcolor} + + \nextganttlastx = \dimexpr\ganttlastx+\ganttunitlength*1\relax + \ifdim\nextganttlastx>\dimexpr\v!ganttunitlength*#3\relax + \startMPdrawing + begingroup; + interim linecap := squared; + interim linejoin := rounded; + + drawarrow (\the\ganttlastx,\ganttnum*cm+1.1*cm+0.2*cm)--(\the\ganttlastx+0.4*\v!ganttunitlength,\ganttnum*cm+1.1*cm+0.2*cm)--(\the\ganttlastx+0.4*\v!ganttunitlength,\ganttnum*cm+0.6*cm+0.2*cm)--(\the\ganttlastx-0.4*\v!ganttunitlength-0.14*cm,\ganttnum*cm+0.6*cm+0.2*cm)--(\the\ganttlastx-0.4*\v!ganttunitlength-0.14*cm,\ganttnum*cm+0.1*cm+0.2*cm)--(#3*\v!ganttunitlength-0.14*cm,\ganttnum*cm+0.1*cm+0.2*cm); + endgroup; + \stopMPdrawing + \else + \startMPdrawing + begingroup; + interim linecap := squared; + interim linejoin := rounded; + + drawarrow (\the\ganttlastx,\ganttnum*cm+1.1*cm+0.2*cm)--(\the\ganttlastx+0.4*\v!ganttunitlength,\ganttnum*cm+1.1*cm+0.2*cm)--(\the\ganttlastx+0.4*\v!ganttunitlength,\ganttnum*cm+0.1*cm+0.2*cm)--(#3*\v!ganttunitlength-0.14*cm,\ganttnum*cm+0.1*cm+0.2*cm); + endgroup; + \stopMPdrawing + \fi + + \ganttmilestone[#1]{#2}{#3} + \egroup + } + +\def\ganttmilestonecon + {\dosingleempty\doganttmilestonecon} + +\protect \stopmodule diff --git a/Master/texmf-dist/doc/latex/context-gantt/tex/context/third/gantt/gantt-s-tikz.tex b/Master/texmf-dist/doc/latex/context-gantt/tex/context/third/gantt/gantt-s-tikz.tex new file mode 100644 index 00000000000..49031499829 --- /dev/null +++ b/Master/texmf-dist/doc/latex/context-gantt/tex/context/third/gantt/gantt-s-tikz.tex @@ -0,0 +1,312 @@ +%D \module +%D [ file=t-gantt-tikz, +%D version=2011.08.27, +%D title=\CONTEXT\ User Module, +%D subtitle=Drawing gantt diagrams, +%D author={Adam Reviczky}, +%D date=\currentdate, +%D copyright=Adam Reviczky, +%D license=GNU GPL 2.0] + +%D Some macros for drawing gantt diagrams using TikZ. +%D +%D Adam Reviczky, 27.08.2011 (Version 2.1) +%D Andrés Silva Marambio, 20.03.2011 (Version 1.3) +%D Alan Munn, Martin Kumm, 14.03.2011 (Version 1.2) + +\writestatus{loading}{ConTeXt User Module / Drawing gantt diagrams} + +\startmodule[gantt-s-tikz] +\unprotect + +\def\????gantt-tikz{@@@@gantt-tikz} + +\usemodule[tikz,pgffor] +\usetikzlibrary[arrows,patterns] + +\definesystemvariable{gantt} + +\newcount\ganttnum +\newcount\gantttitlenum +\newcount\ganttwidth + +\newdimen\ganttlastx \ganttlastx = 0cm +\newdimen\nextganttlastx +\newdimen\titleunitlength \titleunitlength = 1cm +\newdimen\ganttunitlength \ganttunitlength = 1cm + +\newdimen\gantttmpa +\newdimen\gantttmpb + +\def\setupgantt + {\bgroup + \catcode`\#=\@@other + \dosingleempty + \dosetupgantt} + +\def\dosetupgantt[#1]% + {\egroup + \getparameters[\??gantt][#1]} + +\setupgantt + [xunitlength=1cm, + fontsize=\tf, + titlefontsize=\tfx, + drawledgerline=false] + +\def\setupganttbar + {\bgroup + \catcode`\#=\@@other + \dosingleempty + \dosetupganttbar} + +\def\dosetupganttbar[#1]% + {\egroup + \getparameters[\??gantt][#1]} + +\setupganttbar + [pattern=north east lines, + color=black] + +% The gantt environment draws the canvas of a gantt figure (realized as tikzpicture) +% The usage is \startgantt[...]{no of Tasks to plot}{no of time slots} +% The optional argument [...] can be filled in a key=value syntax, using one or more of the following keys: +% +% xunitlength - length of one time slot (default: 1 cm) +% fontsize - fontsize of labels (default: \tf) +% titlefontsize - fontsize of title section (default: \tfx) +% drawledgerline - Switch to enable/disable the drawing of horizontal ledger lines (default value: false) + +\long\def\dostartgantt[#1]#2#3% + {\getparameters[\??gantt][#1]% + \gdef\v!ganttunitlength{\getvalue{@@ganttxunitlength}} + \gdef\v!fontsize{\getvalue{@@ganttfontsize}} + \gdef\v!titlefontsize{\getvalue{@@gantttitlefontsize}} + \gdef\v!drawledgerline{\@@ganttdrawledgerline} + + \bgroup + \tikzstyle{time}=[coordinate] + + \newcount\ganttx \ganttx=0 + \newcount\ganttheight + + \def\ganttxstringtop{} + \def\ganttxstringbottom{} + + \global\ganttwidth=#3 + \global\ganttnum=0 + + \ganttheight=#2 + \advance\ganttheight by 1; + + \draw (0,0.5) node[above] {\ganttxstringtop} -- (0,1.4-\ganttheight) node[below] {\ganttxstringbottom}; + \draw (\ganttwidth*\v!ganttunitlength,0.5) node[above] {\ganttxstringtop} -- (\ganttwidth*\v!ganttunitlength,1.4-\ganttheight) node[below] {\ganttxstringbottom}; + + % draw grid + \foreach \!!t in {1,2,...,\ganttwidth}{ + \draw[dotted] (\v!ganttunitlength*\!!t,-0.5) node[above] {\ganttxstringtop} -- (\v!ganttunitlength*\!!t,1.4-\ganttheight) node[below] {\ganttxstringbottom}; + } + + % draw x axis + \draw[] (0,-#2+0.4) -- (\ganttwidth*\v!ganttunitlength,-#2+0.4); + \egroup + } + +\def\startgantt% + {\starttikzpicture[draw=black,yscale=.7,xscale=1] + \dosingleempty\dostartgantt} + +\def\stopgantt% + {\stoptikzpicture} + +% ganttitle is the environment for drawing the title section +\definestartstop[ganttitle][ + before={ + \ganttlastx = 0cm + }, + after={ + \ganttlastx = 0cm + \doglobal\decrement\ganttnum + } + ] + +% \titleelement draws one element of the title +% usage: \titleelement{label}{length} +\long\def\dotitleelement#1#2% + {\gantttmpa=\dimexpr\v!ganttunitlength*#2\relax + \divide\gantttmpa by 2; + + \def\!!xoffset{1.5} + + \draw (\ganttlastx,\ganttnum) rectangle (\ganttlastx+#2*\v!ganttunitlength,\ganttnum+0.6); + \node [text height=1.5ex,text depth=0.7ex] at (\ganttlastx+\gantttmpa-\!!xoffset,\ganttnum+0.25) {% + \getvalue{v!titlefontsize} #1% + }; + + \ganttlastx=\dimexpr\ganttlastx+\v!ganttunitlength*#2\relax + } + +\def\titleelement% + {\dotitleelement} + +% \numtitle draws a numbered sequence of title elements +% usage: \numtitle{start number}{increment}{end number}{length of each title element} +\long\def\donumtitle#1#2#3#4% + {\gantttitlenum=#1 + \dostepwiserecurse{#1}{#3}{#2}{ + \titleelement{\the\gantttitlenum}{#4} + \advance\gantttitlenum by #2; + } + } + +\def\numtitle% + {\donumtitle} + +% \ganttbar draws a single, unconnected bar for representing a task +% usage: \ganttbar[pattern=,color=]{label}{start}{length} +% where the optional comma separated arguments are: +% pattern - is a tikz pattern (e.g. north east lines (default), north west lines, crosshatch, crosshatch dots, grid, ...) +% color - a tikz color of the pattern (e.g. red, green blue gray, dark gray) +% for more information see the tikz documentation +\long\def\doganttbar[#1]#2#3#4% + {\bgroup + \getparameters[\??gantt][#1]% + \edef\v!pattern{\@@ganttpattern} + \edef\v!color{\@@ganttcolor} + + \gantttmpa=\dimexpr\v!ganttunitlength*#3\relax + \gantttmpb=\dimexpr\v!ganttunitlength*#4+\gantttmpa\relax + + \doif{\v!drawledgerline}{true}{ + \draw[dotted] (0,\ganttnum-0.2) -- (\ganttwidth*\v!ganttunitlength,\ganttnum-0.2); + } + \node at (0,\ganttnum) [anchor=base east] {% + \getvalue{v!fontsize} #2% + }; + \draw[pattern=\v!pattern,pattern color=\v!color] (\gantttmpa,\ganttnum+0.1) rectangle (\gantttmpb,\ganttnum+0.5); + \global\ganttlastx=\gantttmpb + \doglobal\decrement\ganttnum + \egroup + } + +\def\ganttbar + {\dosingleempty\doganttbar} + +% \ganttcon draws an arrow between to bars with specified coordinates +% usage: \ganttcon{startx}{starty}{endx}{endy} +\long\def\doganttcon#1#2#3#4% + {\bgroup + \draw[-latex,rounded corners=1pt] (#1*\v!ganttunitlength,-#2+0.1+0.2) -- (#1*\v!ganttunitlength+0.4*\v!ganttunitlength,-#2+0.1+0.2) -- (#1*\v!ganttunitlength+0.4*\v!ganttunitlength,-#2-0.4+0.2) -- (#1*\v!ganttunitlength-0.4*\v!ganttunitlength,-#2-0.4+0.2) -- (#1*\v!ganttunitlength-0.4*\v!ganttunitlength,-#4+0.1+0.2) -- (#3*\v!ganttunitlength,-#4+0.1+0.2); + \egroup + } + +\def\ganttcon + {\doganttcon} + +% \ganttbarcon draws a single bar *and* connects the bar with the previous bar for +% consecutive tasks +% usage: \ganttbarcon[pattern=,color=]{label}{start}{length} +% where the optional pattern argument are the same as for \ganttbar +\long\def\doganttbarcon[#1]#2#3#4% + {\bgroup + \getparameters[\??gantt][#1]% + \edef\v!pattern{\@@ganttpattern} + \edef\v!color{\@@ganttcolor} + + \nextganttlastx = \dimexpr\ganttlastx+\ganttunitlength*1\relax + \ifdim\nextganttlastx>\dimexpr\v!ganttunitlength*#3\relax + \draw[-latex,rounded corners=1pt] (\ganttlastx,\ganttnum+1.1+0.2) -- (\ganttlastx+0.4*\v!ganttunitlength,\ganttnum+1.1+0.2) -- (\ganttlastx+0.4*\v!ganttunitlength,\ganttnum+0.6+0.2) -- (\ganttlastx-0.4*\v!ganttunitlength,\ganttnum+0.6+0.2) -- (\ganttlastx-0.4*\v!ganttunitlength,\ganttnum+0.1+0.2) -- (#3*\v!ganttunitlength,\ganttnum+0.1+0.2); + \else + \draw[-latex,rounded corners=1pt] (\ganttlastx,\ganttnum+1.1+0.2) -- (\ganttlastx+0.4*\v!ganttunitlength,\ganttnum+1.1+0.2) -- (\ganttlastx+0.4*\v!ganttunitlength,\ganttnum+0.1+0.2) -- (#3*\v!ganttunitlength,\ganttnum+0.1+0.2); + \fi + + %hbox overfull! + \ganttbar[#1]{#2}{#3}{#4} + \egroup + } + +\def\ganttbarcon + {\dosingleempty\doganttbarcon} + +% \ganttgroup draws a bar to group tasks +% usage: \ganttgroup{label}{start}{length} +\long\def\doganttgroup#1#2#3% + {\bgroup + \gantttmpa=\dimexpr\v!ganttunitlength*#2\relax + \gantttmpb=\dimexpr\v!ganttunitlength*#3+\gantttmpa\relax + + \doif{\v!drawledgerline}{true}{ + \draw[dotted] (0,\ganttnum-0.2) -- (\ganttwidth*\v!ganttunitlength,\ganttnum-0.2); + } + \node at (0,\ganttnum) [anchor=base east] {% + \getvalue{v!fontsize}\bf #1% + }; + \fill[black] (\gantttmpa-0.14cm,\ganttnum+0.2) rectangle (\gantttmpb+0.14cm,\ganttnum+0.4); + \draw[diamond-diamond] (\gantttmpa-0.14cm,\ganttnum+0.2) -- (\gantttmpb+0.14cm,\ganttnum+0.2); + + \global\ganttlastx=\gantttmpb + \doglobal\decrement\ganttnum + \egroup + } + +\def\ganttgroup + {\doganttgroup} + +% \ganttmilestone, draw a diamond to represent a milestone +% usage: \ganttmilestone[color=]{label}{start} +% color - a tikz color of the pattern (e.g. red, green blue gray, dark gray) +% for more information see the tikz documentation + +% Declaring layers to abvoid superposition when you connect a \ganttmileston with a task +\pgfdeclarelayer{background} +\pgfdeclarelayer{foreground} +\pgfsetlayers{background,main,foreground} + +\long\def\doganttmilestone[#1]#2#3% + {\bgroup + \getparameters[\??gantt][#1]% + \edef\v!color{\@@ganttcolor} + + \gantttmpa=\dimexpr\v!ganttunitlength*#3\relax + \gantttmpb=\dimexpr\v!ganttunitlength*0+\gantttmpa\relax + + \doif{\v!drawledgerline}{true}{ + \draw[dotted] (0,\ganttnum-0.2) -- (\ganttwidth*\v!ganttunitlength,\ganttnum-0.2); + } + \node at (0,\ganttnum) [anchor=base east] {% + \getvalue{v!fontsize} #2% + }; + \pgfonlayer{foreground} + \draw[diamond-, color=\v!color] (\gantttmpa,\ganttnum+0.1) -- (\gantttmpb,\ganttnum+0.4); + \endpgfonlayer + \global\ganttlastx=\gantttmpb + \doglobal\decrement\ganttnum + \egroup + } + +\def\ganttmilestone + {\dosingleempty\doganttmilestone} + +% \ganttmilestonecon draws a single diamond *and* connects the diamond with the previous task +% usage: \ganttmilestonecon[color=]{label}{start} +% where the optional color argument are the same as for \ganttbar and \ganttmilestone +\long\def\doganttmilestonecon[#1]#2#3% + {\bgroup + \getparameters[\??gantt][#1]% + \edef\v!color{\@@ganttcolor} + + \nextganttlastx = \dimexpr\ganttlastx+\ganttunitlength*1\relax + \ifdim\nextganttlastx>\dimexpr\v!ganttunitlength*#3\relax + \draw[-latex,rounded corners=1pt] (\ganttlastx,\ganttnum+1.1+0.2) -- (\ganttlastx+0.4*\v!ganttunitlength,\ganttnum+1.1+0.2) -- (\ganttlastx+0.4*\v!ganttunitlength,\ganttnum+0.6+0.2) -- (\ganttlastx-0.4*\v!ganttunitlength-1.8,\ganttnum+0.6+0.2) -- (\ganttlastx-0.4*\v!ganttunitlength-1.8,\ganttnum+0.1+0.2) -- (#3*\v!ganttunitlength-1.8,\ganttnum+0.1+0.2); + \else + \draw[-latex,rounded corners=1pt] (\ganttlastx,\ganttnum+1.1+0.2) -- (\ganttlastx+0.4*\v!ganttunitlength,\ganttnum+1.1+0.2) -- (\ganttlastx+0.4*\v!ganttunitlength,\ganttnum+0.1+0.2) -- (#3*\v!ganttunitlength-1.8,\ganttnum+0.1+0.2); + \fi + + \ganttmilestone[#1]{#2}{#3} + \egroup + } + +\def\ganttmilestonecon + {\dosingleempty\doganttmilestonecon} + +\protect \stopmodule diff --git a/Master/texmf-dist/doc/latex/context-gantt/tex/context/third/gantt/t-gantt.tex b/Master/texmf-dist/doc/latex/context-gantt/tex/context/third/gantt/t-gantt.tex new file mode 100644 index 00000000000..ab5a4258d67 --- /dev/null +++ b/Master/texmf-dist/doc/latex/context-gantt/tex/context/third/gantt/t-gantt.tex @@ -0,0 +1,22 @@ +%D \module +%D [ file=t-gantt, +%D version=2011.08.28 +%D title=\CONTEXT\ Module, +%D subtitle=Gantt Module, +%D author=Adam Reviczky, +%D date=\currentdate, +%D copyright=Adam Reviczky] + +\writestatus{loading}{module gantt} + +\startmodule[gantt] + +\unprotect +\setupmodule[style=] + +\doifdefinedelse{\currentmoduleparameter\c!style} + {\usemodule[gantt-s][mp]} + {\usemodule[gantt-s][\currentmoduleparameter\c!style]} + +\protect +\stopmodule diff --git a/Master/tlpkg/bin/tlpkg-ctan-check b/Master/tlpkg/bin/tlpkg-ctan-check index 40461ea60dd..ed15a9e5692 100755 --- a/Master/tlpkg/bin/tlpkg-ctan-check +++ b/Master/tlpkg/bin/tlpkg-ctan-check @@ -98,7 +98,8 @@ my @TLP_working = qw( concmath concmath-fonts concprog confproc constants context-account context-algorithmic context-bnf context-chromato context-construction-plan context-degrade context-filter context-fixme - context-french context-fullpage context-games context-gnuplot + context-french context-fullpage + context-games context-gantt context-gnuplot context-letter context-lettrine context-lilypond context-mathsets context-notes-zh-cn context-rst context-ruby context-simplefonts context-simpleslides diff --git a/Master/tlpkg/tlpsrc/collection-context.tlpsrc b/Master/tlpkg/tlpsrc/collection-context.tlpsrc index 92fbf98997e..2e85947f791 100644 --- a/Master/tlpkg/tlpsrc/collection-context.tlpsrc +++ b/Master/tlpkg/tlpsrc/collection-context.tlpsrc @@ -16,6 +16,7 @@ depend context-fixme depend context-french depend context-fullpage depend context-games +depend context-gantt depend context-gnuplot depend context-letter depend context-lettrine diff --git a/Master/tlpkg/tlpsrc/context-gantt.tlpsrc b/Master/tlpkg/tlpsrc/context-gantt.tlpsrc new file mode 100644 index 00000000000..e69de29bb2d -- cgit v1.2.3