%====================================================================              
% Filename: listcode.tex
% Author: Daniel Mueller [d.mueller@qut.edu.au]
%--------------------------------------------------------------------
% Description: 
% Encapulates commands to list source code using the listings package.
% Also loads the [Shading]OpenGL language.
%--------------------------------------------------------------------
% Notes:
% - The listings package does not integrate well with the memoir class...
%	It may be necessary to delete the *.lol (local listing file) if an error
%   occurs during compilation.
%====================================================================              

%--------------------------------------------------------------------
% Define useful colours
\definecolor{listcomment}{rgb}{0.0,0.5,0.0}
\definecolor{listkeyword}{rgb}{0.0,0.0,0.5}
\definecolor{listnumbers}{gray}{0.65}
\definecolor{listlightgray}{gray}{0.955}
\definecolor{listwhite}{gray}{1.0}

%--------------------------------------------------------------------
% Configure C# listings
\newcommand{\listcsharp}
{
\lstset{frame = tb,
        framerule = 0.25pt,
        float,
        fontadjust,
        backgroundcolor={\color{listlightgray}},
        basicstyle = {\ttfamily\footnotesize},
        keywordstyle = {\ttfamily\color{listkeyword}\textbf},
        identifierstyle = {\ttfamily},
        commentstyle = {\ttfamily\color{listcomment}\textit},
        stringstyle = {\ttfamily},
        showstringspaces = false,
        showtabs = false,
        numbers = left,
        numbersep = 6pt,
        numberstyle={\ttfamily\color{listnumbers}},
        tabsize = 2,
        language=[Sharp]C,
        floatplacement=!h
        }
}

%--------------------------------------------------------------------
% Configure C# snippets
\newcommand{\listcsharpsnip}
{
\lstset{frame = none,
        framerule = 0.0pt,
        float,
        fontadjust,
        backgroundcolor={\color{listlightgray}},
        basicstyle = {\ttfamily\footnotesize},
        keywordstyle = {\ttfamily\color{listkeyword}\textbf},
        identifierstyle = {\ttfamily},
        commentstyle = {\ttfamily\color{listcomment}\textit},
        stringstyle = {\ttfamily},
        showstringspaces = false,
        showtabs = false,
        numbers = left,
        numbersep = 6pt,
        numberstyle={\ttfamily\color{listnumbers}},
        tabsize = 2,
        language=[Sharp]C,
        floatplacement=!h
        }
}

%--------------------------------------------------------------------
% Configure console snippets
\newcommand{\listconsolesnip}
{
\lstset{frame = none,
        framerule = 0.0pt,
        float,
        fontadjust,
        backgroundcolor={\color{listlightgray}},
        basicstyle = {\ttfamily\footnotesize},
        keywordstyle = {\ttfamily},
        identifierstyle = {\ttfamily},
        commentstyle = {\ttfamily},
        stringstyle = {\ttfamily},
        showstringspaces = false,
        showtabs = false,
        numbers = none,        
        tabsize = 2,
        floatplacement=!h
        }
}

%--------------------------------------------------------------------
% Configure python listings
\newcommand{\listpython}
{
\lstset{frame = tb,
        framerule = 0.25pt,
        float,
        fontadjust,
        backgroundcolor={\color{listlightgray}},
        basicstyle = {\ttfamily\footnotesize},
        keywordstyle = {\ttfamily\color{listkeyword}\textbf},
        identifierstyle = {\ttfamily},
        commentstyle = {\ttfamily\color{listcomment}\textit},
        stringstyle = {\ttfamily},
        showstringspaces = false,
        showtabs = false,
        numbers = left,
        numbersep = 6pt,
        numberstyle={\ttfamily\color{listnumbers}},
        tabsize = 2,
        language=Python,
        floatplacement=!h
        }
}

\newcommand{\listpythonsmall}
{
\lstset{frame = tb,
        framerule = 0.25pt,
        float,
        fontadjust,
        backgroundcolor={\color{listlightgray}},
        basicstyle = {\ttfamily\scriptsize},
        keywordstyle = {\ttfamily\color{listkeyword}\textbf},
        identifierstyle = {\ttfamily},
        commentstyle = {\ttfamily\color{listcomment}\textit},
        stringstyle = {\ttfamily},
        showstringspaces = false,
        showtabs = false,
        numbers = left,
        numbersep = 6pt,
        numberstyle={\ttfamily\color{listnumbers}},
        tabsize = 2,
        language=Python,
        floatplacement=!h
        }
}

%--------------------------------------------------------------------
% Configure python snippets
\newcommand{\listpythonsnip}
{
\lstset{frame = none,
        framerule = 0pt,
        float,
        fontadjust,
        backgroundcolor={\color{listlightgray}},
        basicstyle = {\ttfamily\footnotesize},
        keywordstyle = {\ttfamily\color{listkeyword}\textbf},
        identifierstyle = {\ttfamily},
        commentstyle = {\ttfamily\color{listcomment}\textit},
        stringstyle = {\ttfamily},
        showstringspaces = false,
        showtabs = false,
        numbers = left,
        numbersep = 6pt,
        numberstyle={\ttfamily\color{listnumbers}},
        tabsize = 2,
        language=Python,
        floatplacement=tb
        }
}

%--------------------------------------------------------------------
% Configure make listings
\newcommand{\listmake}
{
\lstset{frame = tb,
        framerule = 0.25pt,
        float,
        fontadjust,
        backgroundcolor={\color{listlightgray}},
        basicstyle = {\ttfamily\footnotesize},
        keywordstyle = {\ttfamily\color{listkeyword}\textbf},
        identifierstyle = {\ttfamily},
        commentstyle = {\ttfamily\color{listcomment}\textit},
        stringstyle = {\ttfamily},
        showstringspaces = false,
        showtabs = false,
        numbers = left,
        numbersep = 6pt,
        numberstyle={\ttfamily\color{listnumbers}},
        tabsize = 2,
        language=make,
        floatplacement=!h
        }
}

\newcommand{\listmakesmall}
{
\lstset{frame = tb,
        framerule = 0.25pt,
        float,
        fontadjust,
        backgroundcolor={\color{listlightgray}},
        basicstyle = {\ttfamily\scriptsize},
        keywordstyle = {\ttfamily\color{listkeyword}\textbf},
        identifierstyle = {\ttfamily},
        commentstyle = {\ttfamily\color{listcomment}\textit},
        stringstyle = {\ttfamily},
        showstringspaces = false,
        showtabs = false,
        numbers = left,
        numbersep = 6pt,
        numberstyle={\ttfamily\color{listnumbers}},
        tabsize = 2,
        language=make,
        floatplacement=!h
        }
}

%--------------------------------------------------------------------
% Configure GLSL listings
\newcommand{\listglsl}
{
\lstset{frame = tb,
        framerule = 0.25pt,
        float,
        fontadjust,
        backgroundcolor={\color{listlightgray}},
        basicstyle = {\ttfamily\footnotesize},
        keywordstyle = {\ttfamily\color{listkeyword}\textbf},
        identifierstyle = {\ttfamily},
        commentstyle = {\ttfamily\color{listcomment}\textit},
        stringstyle = {\ttfamily},
        showstringspaces = false,
        showtabs = false,
        numbers = left,
        numbersep = 6pt,
        numberstyle={\ttfamily\color{listnumbers}},
        tabsize = 2,
        language=[Shading]OpenGL,
        floatplacement=!h
        }
}

\newcommand{\listglslsmall}
{
\lstset{frame = tb,
        framerule = 0.25pt,
        float,
        fontadjust,
        backgroundcolor={\color{listlightgray}},
        basicstyle = {\ttfamily\scriptsize},
        keywordstyle = {\ttfamily\color{listkeyword}\textbf},
        identifierstyle = {\ttfamily},
        commentstyle = {\ttfamily\color{listcomment}\textit},
        stringstyle = {\ttfamily},
        showstringspaces = false,
        showtabs = false,
        numbers = left,
        numbersep = 6pt,
        numberstyle={\ttfamily\color{listnumbers}},
        tabsize = 2,
        language=[Shading]OpenGL,
        floatplacement=!h
        }
}

%--------------------------------------------------------------------
% Configure GLSL snippets
\newcommand{\listglslsnip}
{
\lstset{frame = none,
        framerule = 0pt,
        float,
        fontadjust,
        backgroundcolor={\color{listlightgray}},
        basicstyle = {\ttfamily\footnotesize},
        keywordstyle = {\ttfamily\color{listkeyword}\textbf},
        identifierstyle = {\ttfamily},
        commentstyle = {\ttfamily\color{listcomment}\textit},
        stringstyle = {\ttfamily},
        showstringspaces = false,
        showtabs = false,
        numbers = left,
        numbersep = 6pt,
        numberstyle={\ttfamily\color{listnumbers}},
        tabsize = 2,
        language=[Shading]OpenGL,
        floatplacement=!h
        }
}


%--------------------------------------------------------------------
% Configure SharpImage snippets
\newcommand{\listsharpimagesnip}
{
\lstset{frame = none,
        framerule = 0pt,
        float,
        fontadjust,
        backgroundcolor={\color{listlightgray}},
        basicstyle = {\ttfamily\footnotesize},
        keywordstyle = {\ttfamily\color{listkeyword}\textbf},
        identifierstyle = {\ttfamily},
        commentstyle = {\ttfamily\color{listcomment}\textit},
        stringstyle = {\ttfamily},
        showstringspaces = false,
        showtabs = false,
        numbers = left,
        numbersep = 6pt,
        numberstyle={\ttfamily\color{listnumbers}},
        tabsize = 2,
        language=SharpImage,
        floatplacement=!h
        }
}
%--------------------------------------------------------------------
% Define the OpenGL Shading language keywords, comments, etc...
\lstdefinelanguage[Shading]{OpenGL}%
{%
    morekeywords=   {%
                    attribute,%
                    const,%
                    uniform,%
                    varying,%
                    break,%
                    continue,%
                    do,%
                    for,%
                    while,%
                    if,%
                    else,%
                    in,%
                    out,%
                    inout,%
                    true,%
                    false,%
                    discard,%
                    return,%
                    float,%
                    int,%
                    void,%
                    bool,%
                    mat2,%
                    mat3,%
                    mat4,%
                    vec2,
                    vec3,%
                    vec4,%
                    ivec2,%
                    ivec3,%
                    ivec4,%
                    bvec2,%
                    bvec3,%
                    bvec4,%
                    sampler1D,%
                    sampler2D,%
                    sampler3D,%
                    samplerCube,%
                    sampler1DShadow,%
                    sampler2DShadow,%
                    struct,%
                    radians,%
                    degrees,%
                    sin,%
                    cos,%
                    tan,%
                    asin,%
                    acos,%
                    atan,%
                    pow,%
                    exp2,%
                    log2,%
                    sqrt,%
                    inversesqrt,%
                    abs,%
                    sign,%
                    floor,%
                    ceil,%
                    fract,%
                    mod,%
                    min,%
                    max,%
                    clamp,%
                    mix,%
                    step,%
                    smoothstep,%
                    length,%
                    distance,%
                    dot,%
                    cross,%
                    normalize,%
                    transform,%
                    faceforward,%
                    reflect,%
                    matrixCompMult,%
                    lessThan,%
                    lessThanEqual,%
                    greaterThan,%
                    greaterThanEqual,%
                    equal,%
                    notEqual,%
                    any,%
                    all,%
                    not,%
                    texture1D,%
                    texture1DProj,%
                    texture1DProjLod,%
                    texture2D,%
                    texture2DProj,%
                    texture2DProjLod,%
                    texture3D,%
                    texture3DProj,%
                    texture3DProjLod,%
                    textureCube,%
                    textureCubeLod,%
                    shadow1D,%
                    shadow1DProj,%
                    shadow1DLod,%
                    shadow1DProjLod,%
                    shadow2D,%
                    shadow2DProj,%
                    shadow2DLod,%
                    shadow2DProjLod,%
                    dFdx,%
                    dFdy,%
                    fwidth,%
                    noise1,%
                    noise2,%
                    noise3,%
                    noise4},%
    morekeywords={%
                    gl_Position,%
                    gl_PointSize,%
                    gl_ClipVertex,%
                    gl_FragCoord,%
                    gl_FrontFacing,%
                    gl_FragColor,%
                    gl_FragDepth,%
                    gl_Color,%
                    gl_SecondaryColor,%
                    gl_Normal,%
                    gl_Vertex,%
                    gl_MultiTexCoord0,%
                    gl_MultiTexCoord1,%
                    gl_MultiTexCoord2,%
                    gl_MultiTexCoord3,%
                    gl_MultiTexCoord4,%
                    gl_MultiTexCoord5,%
                    gl_MultiTexCoord6,%
                    gl_MultiTexCoord7,%
                    gl_FogCoord,%
                    gl_MaxLights,%
                    gl_MaxClipPlanes,%
                    gl_MaxTextureUnits,%
                    gl_MaxTextureCoordsARB,%
                    gl_MaxVertexAttributesGL2,%
                    gl_MaxVertexUniformFloatsGL2,%
                    gl_MaxVaryingFloatsGL2,%
                    gl_MaxVertexTextureUnitsGL2,%
                    gl_MaxFragmentTextureUnitsGL2,%
                    gl_MaxFragmentUniformFloatsGL2,%
                    gl_ModelViewMatrix,%
                    gl_ProjectionMatrix,%
                    gl_ModelViewProjectionMatrix,%
                    gl_NormalMatrix,%
                    gl_TextureMatrix,%
                    gl_NormalScale,%
                    gl_DepthRange,%
                    gl_ClipPlane,%
                    gl_Point,%
                    gl_FrontMaterial,%
                    gl_BackMaterial,%
                    gl_LightSource,%
                    gl_LightModel,%
                    gl_FrontLightModelProduct,%
                    gl_BackLightModelProduct,%
                    gl_FrontLightProduct,%
                    gl_LightProducts,%
                    gl_TextureEnvColor,%
                    gl_EyePlaneS,%
                    gl_EyePlaneT,%
                    gl_EyePlaneR,%
                    gl_EyePlaneQ,%
                    gl_ObjectPlaneS,%
                    gl_ObjectPlaneT,%
                    gl_ObjectPlaneR,%
                    gl_ObjectPlaneQ,%
                    gl_Fog,%
                    gl_FrontColor,%
                    gl_BackColor,%
                    gl_FrontSecondaryColor,%
                    gl_BackSecondaryColor,%
                    gl_TexCoord,%
                    gl_FogFragCoord,%
                    gl_Color,%
                    gl_SecondaryColor,%
                    gl_TexCoord,%
                    gl_FogFragCoord},%                   
    sensitive,%
    morecomment=[s]{/*}{*/},%
    morecomment=[l]//,%
    morestring=[b]"
    }[keywords,comments,strings]%

%--------------------------------------------------------------------
% Load [Shading]OpenGL for use with the listings package 
\lstloadlanguages{[Shading]OpenGL}

%--------------------------------------------------------------------
% Define the SharpImage language keywords, comments, etc...
\lstdefinelanguage{SharpImage}%
{%
    morekeywords=   {%
                    Open,%
                    Close,%
                    Save,%
                    Select,%
                    Properties,%
                    Rename,%
                    Orient,%
                    Resize,%
                    CurvatureFlow,%
                    BinaryThreshold,%
                    Threshold,%
                    ConnectedThreshold,%
                    BinaryPixelMath,%
                    LevelSetSpeed,%
                    Cast,%
                    CastToUC,%
                    CastToSS,%
                    CastToF,%
                    RescaleIntensity,%
                    RescaleIntensityToUC,%
                    RescaleIntensityToSS,%
                    RescaleIntensityToF,%
                    GenerateMask,%
                    GenerateMaskFromFile,%
                    MorphologicalOpen,%
                    MorphologicalErode,%
                    MorphologicalClose,%
                    MorphologicalDilate,%
                    FastMarching,%
                    BinaryThresholdAsLabel,%
                    GradientMagnitude,%
                    Gradient,%
                    MorphologicalGradientMagnitude,%
                    ValueEdgeHistogram,%
                    Vesselness,%
                    ShiftScale,%
                    VolumeRender,%
                    ImageRange,%
                    none},%
    morekeywords={%
                    %itkPoint,%
                    %itkSize,%
                    %itkIndex,%
                    %itkImageRegion,%
                    %itkPixelType,%
                    none},%                   
    sensitive,%
    morecomment=[s]{/*}{*/},%
    morecomment=[l]//,%
    morestring=[b]"
    }[keywords,comments,strings]%

%--------------------------------------------------------------------
% Load [Shading]OpenGL for use with the listings package 
\lstloadlanguages{SharpImage}
