%%
%% This is file `pgfgantt.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pgfgantt.dtx  (with options: `pgfgantt')
%% 
%% Copyright (C) 2011 by Wolfgang Skala
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%% 
\ProvidesPackage{pgfgantt}[2011/11/10 v2.1 Draw Gantt diagrams with TikZ]
\NeedsTeXFormat{LaTeX2e}[1999/12/01]

\RequirePackage{tikz}
  \usetikzlibrary{arrows,backgrounds,calc,patterns,positioning}

\newcounter{gtt@width}
\newcounter{gtt@currentline}
\newcounter{gtt@lasttitleline}
\newcounter{gtt@lasttitleslot}
\newcounter{gtt@elementid}
\newcounter{gtt@currgrid}
\def\gtt@lastelement{}
\def\gtt@currentelement{}
\newif\ifgtt@intitle

\def\ganttset#1{\pgfqkeys{/pgfgantt}{#1}}

\def\@gtt@keydef#1{%
  \pgfkeysdef{/pgfgantt/#1}{%
    \expandafter\def\csname gtt@#1\endcsname{##1}%
  }%
}
\def\@gtt@get#1{\csname gtt@#1\endcsname}
\def\@gtt@stylekeydef#1{%
  \pgfkeysdef{/pgfgantt/#1}{%
    \pgfkeys{/pgfgantt/#1@style/.style={##1}}%
  }%
}
\def\@gtt@linkkeydef#1#2#3#4{%
  \pgfkeysdef{/pgfgantt/link type/#1}{%
    \def\gtt@link@type{#1}%
    \def\gtt@link@startanchor{#3}%
    \def\gtt@link@endanchor{#4}%
  }%
  \ganttset{link label={#1}{#2}}%
}

\@gtt@stylekeydef{hgrid style}
\newif\ifgtt@hgrid
\pgfkeysdef{/pgfgantt/hgrid}{%
  \def\@tempa{#1}%
  \def\@tempb{false}%
  \ifx\@tempa\@tempb%
    \gtt@hgridfalse%
  \else%
    \gtt@hgridtrue%
    \def\@tempb{true}%
    \ifx\@tempa\@tempb%
      \def\gtt@hgridstyle{dotted}%
    \else%
      \def\gtt@hgridstyle{#1}%
    \fi%
  \fi%
}
\pgfkeys{/pgfgantt/hgrid/.default=dotted}

\newif\ifgtt@vgrid
\pgfkeysdef{/pgfgantt/vgrid}{%
  \def\@tempa{#1}%
  \def\@tempb{false}%
  \ifx\@tempa\@tempb%
    \gtt@vgridfalse%
  \else%
    \gtt@vgridtrue%
    \def\@tempb{true}%
    \ifx\@tempa\@tempb%
      \def\gtt@vgridstyle{dotted}%
    \else%
      \def\gtt@vgridstyle{#1}%
    \fi%
  \fi%
}
\pgfkeys{/pgfgantt/vgrid/.default=dotted}


\@gtt@keydef{x unit}
\@gtt@keydef{y unit title}
\@gtt@keydef{y unit chart}

\@gtt@stylekeydef{canvas}
\@gtt@keydef{today}
\@gtt@stylekeydef{today rule}
\@gtt@keydef{today label}

\@gtt@stylekeydef{title}
\@gtt@keydef{title label font}
\@gtt@stylekeydef{title label anchor}
\pgfkeysdef{/pgfgantt/title list options}{%
  \def\gtt@titlelistoptions{[#1]}%
}
\@gtt@keydef{title left shift}
\@gtt@keydef{title right shift}
\@gtt@keydef{title top shift}
\@gtt@keydef{title height}

\newif\ifgtt@includetitle
\pgfkeys{/pgfgantt/include title in canvas/.is if=gtt@includetitle}

\@gtt@keydef{name}
\@gtt@keydef{time slot modifier}
\newif\ifgtt@inline
\pgfkeys{/pgfgantt/inline/.is if=gtt@inline}

\@gtt@stylekeydef{bar}
\pgfkeysdef{/pgfgantt/bar label text}{%
  \def\gtt@barlabeltext##1{#1}%
}
\@gtt@keydef{bar label font}
\@gtt@stylekeydef{bar label anchor}
\@gtt@stylekeydef{bar label inline anchor}
\@gtt@keydef{bar left shift}
\@gtt@keydef{bar right shift}
\@gtt@keydef{bar top shift}
\@gtt@keydef{bar height}

\@gtt@stylekeydef{group}
\pgfkeysdef{/pgfgantt/group label text}{%
  \def\gtt@grouplabeltext##1{#1}%
}
\@gtt@keydef{group label font}
\@gtt@stylekeydef{group label anchor}
\@gtt@stylekeydef{group label inline anchor}
\@gtt@keydef{group left shift}
\@gtt@keydef{group right shift}
\@gtt@keydef{group top shift}
\@gtt@keydef{group height}
\pgfkeysdefnargs{/pgfgantt/group left peak}{3}{%
  \def\@tempa{#1}%
  \ifx\@tempa\@empty\else\def\gtt@groupleftpeakmidx{#1}\fi%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else\def\gtt@groupleftpeakinnerx{#2}\fi%
  \def\@tempa{#3}%
  \ifx\@tempa\@empty\else\def\gtt@groupleftpeaky{#3}\fi%
}
\pgfkeysdefnargs{/pgfgantt/group right peak}{3}{%
  \def\@tempa{#1}%
  \def\@tempb{-}%
  \ifx\@tempa\@empty\else%
    \ifx\@tempa\@tempb\else\def\gtt@grouprightpeakmidx{#1}\fi%
  \fi%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else%
    \ifx\@tempa\@tempb\else\def\gtt@grouprightpeakinnerx{#2}\fi%
  \fi%
  \def\@tempa{#3}%
  \ifx\@tempa\@empty\else\def\gtt@grouprightpeaky{#3}\fi%
}
\pgfkeysdefnargs{/pgfgantt/group peaks}{3}{%
  \ganttset{group left peak={#1}{#2}{#3}, group right peak={-#1}{-#2}{#3}}%
}

\@gtt@keydef{progress}
\@gtt@stylekeydef{bar incomplete}
\@gtt@stylekeydef{group incomplete}
\pgfkeysdef{/pgfgantt/incomplete}{%
  \ganttset{bar incomplete={#1}, group incomplete={#1}}%
}
\pgfkeysdef{/pgfgantt/progress label text}{%
  \def\gtt@progresslabeltext##1{#1}%
}
\@gtt@keydef{progress label font}
\@gtt@stylekeydef{progress label anchor}

\@gtt@stylekeydef{milestone}
\pgfkeysdef{/pgfgantt/milestone label text}{%
  \def\gtt@milestonelabeltext##1{#1}%
}
\@gtt@keydef{milestone label font}
\@gtt@stylekeydef{milestone label anchor}
\@gtt@stylekeydef{milestone label inline anchor}
\@gtt@keydef{milestone width}
\@gtt@keydef{milestone height}
\@gtt@keydef{milestone xshift}
\@gtt@keydef{milestone yshift}

\@gtt@stylekeydef{link}
\pgfkeysdefnargs{/pgfgantt/link label}{2}{%
  \expandafter\def\csname gtt@link@#1@labeltext\endcsname{#2}%
}
\pgfkeys{/pgfgantt/link type/.is choice}
\@gtt@linkkeydef{arrow}{\relax}{}{}
\@gtt@linkkeydef{s-s}{start-to-start}{lower left}{upper left}
\@gtt@linkkeydef{s-f}{start-to-finish}{lower left}{upper right}
\@gtt@linkkeydef{f-s}{finish-to-start}{lower right}{upper left}
\@gtt@linkkeydef{f-f}{finish-to-finish}{lower right}{upper right}

\@gtt@keydef{link label font}
\@gtt@stylekeydef{link label anchor}
\@gtt@keydef{link mid}
\@gtt@keydef{link bulge}
\@gtt@keydef{link tolerance}

\ganttset{
  canvas={fill=white},
  x unit=.5cm,
  y unit title=1cm,
  y unit chart=1cm,
  hgrid style=dotted,
  today=none,
  today rule={dashed, line width=1pt},
  today label=TODAY,
  title={fill=white},
  title label font=\small,
  title label anchor={anchor=mid},
  title left shift=0,
  title right shift=0,
  title top shift=0,
  title height=.6,
  title list options={var=\x, evaluate=\x},
  include title in canvas,
  name={},
  time slot modifier=-1,
  inline=false,
  bar={fill=white},
  bar label text={\strut#1},
  bar label font=\normalsize,
  bar label anchor={anchor=east},
  bar label inline anchor={anchor=center},
  bar left shift=0,
  bar right shift=0,
  bar top shift=.3,
  bar height=.4,
  group={fill=black},
  group label text={\strut#1},
  group label font=\normalsize\bfseries,
  group label anchor={anchor=east},
  group label inline anchor={anchor=south},
  group left shift=-.1,
  group right shift=.1,
  group top shift=.4,
  group height=.2,
  group peaks={.2}{.4}{.1},
  progress=none,
  incomplete={fill=black!25},
  progress label text={#1\% complete},
  progress label font=\scriptsize,
  progress label anchor={anchor=west},
  milestone={fill=black},
  milestone label text={\strut#1},
  milestone label font=\normalsize\itshape,
  milestone label anchor={anchor=east},
  milestone label inline anchor={anchor=south},
  milestone width=.8,
  milestone height=.4,
  milestone xshift=0,
  milestone yshift=.5,
  link={-latex, rounded corners=1pt},
  link type=arrow,
  link label font=\scriptsize\itshape\normalcolor,
  link label anchor={anchor=west},
  link mid=.5,
  link bulge=.4,
  link tolerance=0.6
}

\def\gtt@vgrid@do#1,{%
  \ifx\relax#1\else%
    \ifnum\value{gtt@currgrid}>\value{gtt@width}\else%
      \gtt@vgrid@analyze#1\relax%
      \expandafter\expandafter\expandafter\gtt@vgrid@do%
    \expandafter\fi%
  \fi%
}

\def\gtt@vgrid@analyze{%
  \@ifstar{\gtt@vgrid@draw}{\gtt@vgrid@draw1}%
}

\def\gtt@vgrid@draw#1#2\relax{%
  \foreach \i in {1,...,#1} {%
    \draw[#2] (\value{gtt@currgrid} * \@gtt@get{x unit}, \y@upper pt) --%
      (\value{gtt@currgrid} * \@gtt@get{x unit}, \y@lower pt);%
    \stepcounter{gtt@currgrid}%
    \ifnum\value{gtt@currgrid}>\value{gtt@width}\breakforeach\fi%
  }%
}

\def\gtt@hgrid@do#1,{%
  \ifx\relax#1\else
    \ifnum\value{gtt@currgrid}<\value{gtt@currentline}\else%
      \gtt@hgrid@analyze#1\relax%
      \expandafter\expandafter\expandafter\gtt@hgrid@do%
    \expandafter\fi%
  \fi%
}

\def\gtt@hgrid@analyze{%
  \@ifstar{\gtt@hgrid@draw}{\gtt@hgrid@draw1}%
}

\def\gtt@hgrid@draw#1#2\relax{%
  \foreach \i in {1,...,#1} {%
    \pgfmathsetmacro\y@upper{%
      \value{gtt@lasttitleline} * \@gtt@get{y unit title} +%
      (\value{gtt@currgrid} - \value{gtt@lasttitleline})%
      * \@gtt@get{y unit chart}%
    }%
    \draw[#2] (0pt, \y@upper pt) --
      (\value{gtt@width} * \@gtt@get{x unit}, \y@upper pt);%
    \addtocounter{gtt@currgrid}{-1}%
    \ifnum\value{gtt@currgrid}<\value{gtt@currentline}\breakforeach\fi%
  }%
}

\newif\ifgtt@tikzpicture

\newenvironment{ganttchart}[2][]{%
  \@ifundefined{useasboundingbox}%
    {\gtt@tikzpicturefalse\begin{tikzpicture}}%
    {\gtt@tikzpicturetrue}%
  \ganttset{#1}%
  \setcounter{gtt@width}{#2}%
  \setcounter{gtt@currentline}{0}%
  \setcounter{gtt@lasttitleline}{0}%
  \setcounter{gtt@elementid}{0}%
  \setcounter{gtt@currgrid}{1}%
  \gtt@intitletrue%
  \let\\\ganttnewline%
}{%
  \begin{scope}[on background layer]%
    \ifgtt@includetitle%
      \def\y@upper{0}%
    \else%
      \pgfmathsetmacro\y@upper{%
        \value{gtt@lasttitleline} * \@gtt@get{y unit title}%
      }%
    \fi%
    \pgfmathsetmacro\y@lower{%
      \value{gtt@lasttitleline} * \@gtt@get{y unit title}%
      + (\value{gtt@currentline} - \value{gtt@lasttitleline} - 1)%
      * \@gtt@get{y unit chart}%
    }%
    \draw[/pgfgantt/canvas@style]
      (0pt, \y@upper pt) rectangle
      (\value{gtt@width} * \@gtt@get{x unit}, \y@lower pt);%
    \pgfmathsetmacro\y@upper{%
      \value{gtt@lasttitleline} * \@gtt@get{y unit title}%
    }%
    \ifgtt@vgrid
      \addtocounter{gtt@width}{-1}%
      \foreach \x in {1,...,\value{gtt@width}} {%
        \expandafter\gtt@vgrid@do\gtt@vgridstyle,\relax,%
        \ifnum\value{gtt@currgrid}>\value{gtt@width}\breakforeach\fi%
      }%
      \stepcounter{gtt@width}%
    \fi%
    \ifgtt@hgrid%
      \ifgtt@includetitle%
        \setcounter{gtt@currgrid}{\value{gtt@lasttitleline}}%
      \else%
        \pgfmathsetcounter{gtt@currgrid}{\value{gtt@lasttitleline}-1}%
      \fi%
      \edef\hgrid@upper{\thegtt@currgrid}%
      \foreach \t in {\hgrid@upper,...,\value{gtt@currentline}} {%
        \expandafter\gtt@hgrid@do\gtt@hgridstyle,\relax,%
        \ifnum\value{gtt@currgrid}<\value{gtt@currentline}\breakforeach\fi%
      }%
    \fi%
    \def\@tempa{none}%
    \ifx\gtt@today\@tempa\else%
      \draw[/pgfgantt/today rule@style]
        (\@gtt@get{today} * \@gtt@get{x unit}, \y@upper pt) --
        (\@gtt@get{today} * \@gtt@get{x unit}, \y@lower pt);%
      \node at (\@gtt@get{today} * \@gtt@get{x unit}, \y@lower pt)
        [anchor=north] {\@gtt@get{today label}};%
    \fi%
  \end{scope}%
  \ifgtt@tikzpicture\else\end{tikzpicture}\fi%
}

\newcommand\ganttnewline[1][]{%
  \def\@tempa{#1}%
  \def\@tempb{grid}%
  \ifx\@tempa\@empty\else
    \ifx\@tempa\@tempb%
      \def\@tempa{/pgfgantt/hgrid style@style}%
    \fi%
    \pgfmathsetmacro\y@upper{%
      \value{gtt@lasttitleline} * \@gtt@get{y unit title}%
      + (\value{gtt@currentline} - \value{gtt@lasttitleline} - 1)%
      * \@gtt@get{y unit chart}%
    }
    \expandafter\draw\expandafter[\@tempa]
      (0pt, \y@upper pt) --
      (\value{gtt@width} * \@gtt@get{x unit}, \y@upper pt);%
  \fi%
  \addtocounter{gtt@currentline}{-1}%
  \ifgtt@intitle\addtocounter{gtt@lasttitleline}{-1}\fi%
  \setcounter{gtt@lasttitleslot}{0}%
}

\newcommand\gantttitle[3][]{%
  \begingroup%
  \ganttset{#1}%
  \pgfmathsetmacro\x@left{%
    (\value{gtt@lasttitleslot} + \@gtt@get{title left shift})%
    * \@gtt@get{x unit}%
  }%
  \pgfmathsetmacro\x@right{%
    (\value{gtt@lasttitleslot} + #3 + \@gtt@get{title right shift})%
    * \@gtt@get{x unit}%
  }%
  \pgfmathsetmacro\y@upper{%
    (\value{gtt@currentline} - \@gtt@get{title top shift})%
    * \@gtt@get{y unit title}%
  }%
  \pgfmathsetmacro\y@lower{%
    (\value{gtt@currentline} - \@gtt@get{title top shift}%
    - \@gtt@get{title height}) * \@gtt@get{y unit title}%
  }%
  \draw[/pgfgantt/title@style]
    (\x@left pt, \y@upper pt) rectangle
    (\x@right pt, \y@lower pt);%
  \@gtt@get{title label font}%
  \node at ($(\x@left pt,\y@upper pt)!.5!(\x@right pt,\y@lower pt)$)
    [/pgfgantt/title label anchor@style] {#2};%
  \addtocounter{gtt@lasttitleslot}{#3}%
  \endgroup%
}

\newcommand\gantttitlelist[3][]{%
  \begingroup%
  \ganttset{#1}%
  \expandafter\foreach\gtt@titlelistoptions in {#2} {\gantttitle{\x}{#3}}%
  \endgroup%
}

\pgfdeclareshape{chart element}{%
  \savedanchor\lowerleft{%
    \pgfpoint{\x@left pt}{\y@lower pt}%
  }%
  \savedanchor\leftcenter{%
    \pgfpoint{\x@left pt}{\y@upper pt / 2 + \y@lower pt / 2}%
  }%
  \savedanchor\upperleft{%
    \pgfpoint{\x@left pt}{\y@upper pt}%
  }%
  \savedanchor\lowerright{%
    \pgfpoint{\x@right pt}{\y@lower pt}%
  }%
  \savedanchor\rightcenter{%
    \pgfpoint{\x@right pt}{\y@upper pt / 2 + \y@lower pt / 2}%
  }%
  \savedanchor\upperright{%
    \pgfpoint{\x@right pt}{\y@upper pt}%
  }%
  \savedanchor\centerpoint{%
    \pgfpoint{\x@right pt / 2 + \x@left pt / 2}%
      {\y@upper pt / 2 + \y@lower pt / 2}%
  }%
  \anchor{lower left}{\lowerleft}%
  \anchor{left}{\leftcenter}%
  \anchor{upper left}{\upperleft}%
  \anchor{lower right}{\lowerright}%
  \anchor{right}{\rightcenter}%
  \anchor{upper right}{\upperright}%
  \anchor{center}{\centerpoint}%
}

\newcommand\ganttbar[4][]{%
  \begingroup%
  \ganttset{#1}%
  \pgfmathsetmacro\x@left{%
    (#3 + \@gtt@get{time slot modifier} + \@gtt@get{bar left shift})%
    * \@gtt@get{x unit}%
  }%
  \pgfmathsetmacro\x@right{%
    (#4 + \@gtt@get{bar right shift}) * \@gtt@get{x unit}%
  }%
  \pgfmathsetmacro\y@upper{%
    \value{gtt@lasttitleline} * \@gtt@get{y unit title}
    + (\value{gtt@currentline} - \value{gtt@lasttitleline}
    - \@gtt@get{bar top shift}) * \@gtt@get{y unit chart}%
  }%
  \pgfmathsetmacro\y@lower{%
    \y@upper - \@gtt@get{bar height} * \@gtt@get{y unit chart}%
  }%
  \ifx\gtt@name\@empty\edef\gtt@name{elem\thegtt@elementid}\fi%
  \node[shape=chart element] (\@gtt@get{name})
    at ($(\x@left pt, \y@upper pt)!.5!(\x@right pt, \y@lower pt)$) {};
  \def\@tempa{none}%
  \ifx\gtt@progress\@tempa%
    \def\gtt@progress{100}%
    \let\gtt@pl@draw\relax%
  \else
    \expandafter\ifx\gtt@progresslabeltext\relax\relax%
      \let\gtt@pl@draw\relax%
    \else%
      \def\gtt@pl@draw{%
        \node at ($(\x@right pt, \y@upper pt)!.5!
          (\x@right pt, \y@lower pt)$)
          [/pgfgantt/progress label anchor@style] {%
            \@gtt@get{progress label font}{%
              \@gtt@get{progresslabeltext}{\@gtt@get{progress}}%
            }%
          };%
      }%
    \fi%
  \fi%
  \begin{scope}%
    \clip (\x@left pt, \y@upper pt) rectangle
      ($(\x@left pt, \y@lower pt)!\gtt@progress/100!
        (\x@right pt, \y@lower pt)$);%
    \draw[/pgfgantt/bar@style, draw=none] (\x@left pt, \y@upper pt)
      rectangle (\x@right pt, \y@lower pt);%
  \end{scope}%
  \begin{scope}%
    \clip ($(\x@left pt, \y@upper pt)!\gtt@progress/100!
      (\x@right pt, \y@upper pt)$)
      rectangle (\x@right pt, \y@lower pt);%
    \draw[/pgfgantt/bar incomplete@style, draw=none]
      (\x@left pt, \y@upper pt) rectangle (\x@right pt, \y@lower pt);%
  \end{scope}%
  \draw[/pgfgantt/bar@style, fill=none]
    (\x@left pt, \y@upper pt) rectangle (\x@right pt, \y@lower pt);%
  \gtt@pl@draw%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else%
    \ifgtt@inline%
      \node at (\@gtt@get{name}.center)
        [/pgfgantt/bar label inline anchor@style]
        {\@gtt@get{bar label font}{\gtt@barlabeltext{#2}}};%
    \else%
      \node at ($(0pt, \y@upper pt)!.5!(0pt, \y@lower pt)$)
        [/pgfgantt/bar label anchor@style]
        {\@gtt@get{bar label font}{\gtt@barlabeltext{#2}}};%
    \fi%
  \fi%
  \xdef\gtt@lastelement{\gtt@currentelement}%
  \xdef\gtt@currentelement{\@gtt@get{name}}%
  \stepcounter{gtt@elementid}%
  \global\gtt@intitlefalse%
  \endgroup%
}

\newcommand\ganttlinkedbar[4][]{%
  \begingroup%
  \ganttset{#1}%
  \ganttbar{#2}{#3}{#4}%
  \ganttlink{\gtt@lastelement}{\gtt@currentelement}
  \endgroup%
}

\newcommand\ganttlink[3][]{%
  \begingroup%
  \ganttset{#1}%
  \pgfpointanchor{#2}{right}
  \edef\x@left{\the\pgf@x}
  \edef\y@upper{\the\pgf@y}
  \pgfpointanchor{#3}{left}
  \edef\x@right{\the\pgf@x}
  \edef\y@lower{\the\pgf@y}
  \def\@tempa{arrow}
  \ifx\@tempa\gtt@link@type%
    \pgfmathparse{abs(\y@upper - \y@lower) <= 1}
    \ifcase\pgfmathresult%
      \pgfmathparse{%
        (\x@right - \x@left)
        >= \@gtt@get{link tolerance} * \@gtt@get{x unit}%
      }%
      \ifcase\pgfmathresult%
        \draw[/pgfgantt/link@style]
          (#2.right) --
          (\x@left + \@gtt@get{link bulge} * \@gtt@get{x unit},
            \y@upper) --
          ($(\x@left + \@gtt@get{link bulge} * \@gtt@get{x unit},
            \y@upper)!%
            \@gtt@get{link mid}!%
            (\x@left + \@gtt@get{link bulge} * \@gtt@get{x unit},
            \y@lower)$) --
          ($(\x@right - \@gtt@get{link bulge} * \@gtt@get{x unit},
            \y@upper)!%
            \@gtt@get{link mid}!%
            (\x@right - \@gtt@get{link bulge} * \@gtt@get{x unit},
            \y@lower)$) --
          (\x@right - \@gtt@get{link bulge} * \@gtt@get{x unit},
            \y@lower) --
          (#3.left);%
      \else%
        \draw[/pgfgantt/link@style]
          (#2.right) --
          ($(\x@left, \y@upper)!\@gtt@get{link mid}!
            (\x@right, \y@upper)$) --
          ($(\x@left, \y@lower)!\@gtt@get{link mid}!
            (\x@right, \y@lower)$) --
          (#3.left);%
      \fi%
    \else
      \draw[/pgfgantt/link@style] (#2.right) -- (#3.left);
    \fi
  \else%
    \draw[/pgfgantt/link@style]
      (#2.\gtt@link@startanchor) -- (#3.\gtt@link@endanchor)
      node [pos=.5, /pgfgantt/link label anchor@style] {%
        \@gtt@get{link label font}{%
          \csname gtt@link@\gtt@link@type @labeltext\endcsname%
        }%
      };%
  \fi%
  \endgroup%
}

\newcommand\ganttgroup[4][]{%
  \begingroup%
  \ganttset{#1}%
  \pgfmathsetmacro\x@left{%
    (#3 + \@gtt@get{time slot modifier} + \@gtt@get{group left shift})%
    * \@gtt@get{x unit}%
  }%
  \pgfmathsetmacro\x@right{%
    (#4 + \@gtt@get{group right shift}) * \@gtt@get{x unit}%
  }%
  \pgfmathsetmacro\y@upper{%
    \value{gtt@lasttitleline} * \@gtt@get{y unit title}
    + (\value{gtt@currentline} - \value{gtt@lasttitleline}
    - \@gtt@get{group top shift}) * \@gtt@get{y unit chart}%
  }%
  \pgfmathsetmacro\y@lower{%
    \y@upper - \@gtt@get{group height} * \@gtt@get{y unit chart}%
  }%
  \ifx\gtt@name\@empty\edef\gtt@name{elem\thegtt@elementid}\fi%
  \node[shape=chart element] (\@gtt@get{name})
    at ($(\x@left pt, \y@upper pt)!.5!(\x@right pt, \y@lower pt)$) {};
  \def\@tempa{none}%
  \ifx\gtt@progress\@tempa%
    \def\gtt@progress{100}%
    \let\gtt@pl@draw\relax%
  \else
    \expandafter\ifx\gtt@progresslabeltext\relax\relax%
      \let\gtt@pl@draw\relax%
    \else%
      \def\gtt@pl@draw{%
        \node at ($(\x@right pt, \y@upper pt)!.5!
          (\x@right pt, \y@lower pt)$)
          [/pgfgantt/progress label anchor@style] {%
            \@gtt@get{progress label font}{%
              \@gtt@get{progresslabeltext}{\@gtt@get{progress}}%
            }%
          };%
      }%
    \fi%
  \fi%
  \pgfmathsetmacro\@maxpeak{%
    \gtt@grouprightpeaky > \gtt@groupleftpeaky ?%
    \gtt@grouprightpeaky * \@gtt@get{y unit chart} :%
    \gtt@groupleftpeaky * \@gtt@get{y unit chart}%
  }%
  \begin{scope}%
    \clip (\x@left pt, \y@upper pt) rectangle
      ($(\x@left pt, \y@lower pt - \@maxpeak pt)!%
        \gtt@progress/100!%
        (\x@right pt, \y@lower pt - \@maxpeak pt)$);%
    \path[/pgfgantt/group@style,draw=none]
      (\x@left pt, \y@upper pt) --
      (\x@right pt, \y@upper pt) --
      (\x@right pt, \y@lower pt) --
      (\x@right pt + \gtt@grouprightpeakmidx * \@gtt@get{x unit},
        \y@lower pt - \gtt@grouprightpeaky * \@gtt@get{y unit chart}) --
      (\x@right pt + \gtt@grouprightpeakinnerx * \@gtt@get{x unit},
        \y@lower pt) --
      (\x@left pt + \gtt@groupleftpeakinnerx * \@gtt@get{x unit},
        \y@lower pt) --
      (\x@left pt + \gtt@groupleftpeakmidx * \@gtt@get{x unit},
        \y@lower pt - \gtt@groupleftpeaky * \@gtt@get{y unit chart}) --
      (\x@left pt, \y@lower pt) --
      cycle;%
  \end{scope}%
  \begin{scope}%
    \clip ($(\x@left pt, \y@upper pt)!%
        \gtt@progress/100!%
        (\x@right pt, \y@upper pt)$)
      rectangle (\x@right pt, \y@lower pt - \@maxpeak pt);
    \path[/pgfgantt/group incomplete@style]
      (\x@left pt, \y@upper pt) --
      (\x@right pt, \y@upper pt) --
      (\x@right pt, \y@lower pt) --
      (\x@right pt + \gtt@grouprightpeakmidx * \@gtt@get{x unit},
        \y@lower pt - \gtt@grouprightpeaky * \@gtt@get{y unit chart}) --
      (\x@right pt + \gtt@grouprightpeakinnerx * \@gtt@get{x unit},
        \y@lower pt) --
      (\x@left pt + \gtt@groupleftpeakinnerx * \@gtt@get{x unit},
        \y@lower pt) --
      (\x@left pt + \gtt@groupleftpeakmidx * \@gtt@get{x unit},
        \y@lower pt - \gtt@groupleftpeaky * \@gtt@get{y unit chart}) --
      (\x@left pt, \y@lower pt) --
      cycle;%
  \end{scope}%
  \path[/pgfgantt/group@style,fill=none]
    (\x@left pt, \y@upper pt) --
    (\x@right pt, \y@upper pt) --
    (\x@right pt, \y@lower pt) --
    (\x@right pt + \gtt@grouprightpeakmidx * \@gtt@get{x unit},
      \y@lower pt - \gtt@grouprightpeaky * \@gtt@get{y unit chart}) --
    (\x@right pt + \gtt@grouprightpeakinnerx * \@gtt@get{x unit},
      \y@lower pt) --
    (\x@left pt + \gtt@groupleftpeakinnerx * \@gtt@get{x unit},
      \y@lower pt) --
    (\x@left pt + \gtt@groupleftpeakmidx * \@gtt@get{x unit},
      \y@lower pt - \gtt@groupleftpeaky * \@gtt@get{y unit chart}) --
    (\x@left pt, \y@lower pt) --
    cycle;%
  \gtt@pl@draw%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else%
    \ifgtt@inline%
      \node at (\@gtt@get{name}.center)
        [/pgfgantt/group label inline anchor@style]
        {\@gtt@get{group label font}{\gtt@grouplabeltext{#2}}};%
    \else%
      \node at ($(0pt, \y@upper pt)!.5!(0pt, \y@lower pt)$)
        [/pgfgantt/group label anchor@style]
        {\@gtt@get{group label font}{\gtt@grouplabeltext{#2}}};%
    \fi%
  \fi%
  \xdef\gtt@lastelement{\gtt@currentelement}%
  \xdef\gtt@currentelement{\@gtt@get{name}}%
  \stepcounter{gtt@elementid}%
  \global\gtt@intitlefalse%
  \endgroup%
}

\newcommand\ganttlinkedgroup[4][]{%
  \begingroup%
  \ganttset{#1}%
  \ganttgroup{#2}{#3}{#4}%
  \ganttlink{\gtt@lastelement}{\gtt@currentelement}
  \endgroup%
}

\newcommand\ganttmilestone[3][]{%
  \begingroup%
  \ganttset{#1}%
  \pgfmathsetmacro\x@mid{%
    (#3 + \@gtt@get{milestone xshift}) * \@gtt@get{x unit}%
  }%
  \pgfmathsetmacro\x@left{%
    \x@mid - \@gtt@get{milestone width} / 2 * \@gtt@get{x unit}%
  }
  \pgfmathsetmacro\x@right{%
    \x@mid + \@gtt@get{milestone width} / 2 * \@gtt@get{x unit}%
  }
  \pgfmathsetmacro\y@mid{%
    \value{gtt@lasttitleline} * \@gtt@get{y unit title}%
    + (\value{gtt@currentline} - \value{gtt@lasttitleline}%
    - \@gtt@get{milestone yshift}) * \@gtt@get{y unit chart}%
  }%
  \pgfmathsetmacro\y@upper{%
    \y@mid + \@gtt@get{milestone height} / 2 * \@gtt@get{y unit chart}%
  }%
  \pgfmathsetmacro\y@lower{%
    \y@mid - \@gtt@get{milestone height} / 2 * \@gtt@get{y unit chart}%
  }%
  \ifx\gtt@name\@empty\edef\gtt@name{elem\thegtt@elementid}\fi%
  \node[shape=chart element] (\@gtt@get{name})
    at ($(\x@left pt, \y@upper pt)!.5!(\x@right pt, \y@lower pt)$) {};
  \path[/pgfgantt/milestone@style]
    (\x@left pt, \y@mid pt) --
    (\x@mid pt, \y@lower pt) --
    (\x@right pt, \y@mid pt) --
    (\x@mid pt, \y@upper pt) --
    cycle;%
  \def\@tempa{#2}%
  \ifx\@tempa\@empty\else%
    \ifgtt@inline%
      \node at (\@gtt@get{name}.center)
        [/pgfgantt/milestone label inline anchor@style]
        {\@gtt@get{milestone label font}{\gtt@milestonelabeltext{#2}}};%
    \else%
      \node at (0pt, \y@mid pt)
        [/pgfgantt/milestone label anchor@style]
        {\@gtt@get{milestone label font}{\gtt@milestonelabeltext{#2}}};%
    \fi%
  \fi%
  \xdef\gtt@lastelement{\gtt@currentelement}%
  \xdef\gtt@currentelement{\@gtt@get{name}}%
  \stepcounter{gtt@elementid}%
  \global\gtt@intitlefalse%
  \endgroup%
}

\newcommand\ganttlinkedmilestone[3][]{%
  \begingroup%
  \ganttset{#1}%
  \ganttmilestone{#2}{#3}%
  \ganttlink{\gtt@lastelement}{\gtt@currentelement}
  \endgroup%
}
\endinput
%%
%% End of file `pgfgantt.sty'.
