# This file was auto generated by Styx.
# Do not edit this file directly.

import typing
import pathlib
from styxdefs import *

SCENE_CAPTURE_IMAGE_METADATA = Metadata(
    id="55af0e180213a5b9c01ff3c05ec7ffefe348871b.boutiques",
    name="scene-capture-image",
    package="workbench",
    container_image_tag="brainlife/connectome_workbench:1.5.0-freesurfer-update",
)


SceneCaptureImageSizeWidthHeightParameters = typing.TypedDict('SceneCaptureImageSizeWidthHeightParameters', {
    "@type": typing.NotRequired[typing.Literal["size_width_height"]],
    "width": float,
    "height": float,
})
SceneCaptureImageSizeWidthHeightParametersTagged = typing.TypedDict('SceneCaptureImageSizeWidthHeightParametersTagged', {
    "@type": typing.Literal["size_width_height"],
    "width": float,
    "height": float,
})


SceneCaptureImageResolutionParameters = typing.TypedDict('SceneCaptureImageResolutionParameters', {
    "@type": typing.NotRequired[typing.Literal["resolution"]],
    "number_of_pixels": float,
    "units_name": str,
})
SceneCaptureImageResolutionParametersTagged = typing.TypedDict('SceneCaptureImageResolutionParametersTagged', {
    "@type": typing.Literal["resolution"],
    "number_of_pixels": float,
    "units_name": str,
})


SceneCaptureImageSetMapYokeParameters = typing.TypedDict('SceneCaptureImageSetMapYokeParameters', {
    "@type": typing.NotRequired[typing.Literal["set_map_yoke"]],
    "map_yoking_roman_numeral": str,
    "map_undex": int,
})
SceneCaptureImageSetMapYokeParametersTagged = typing.TypedDict('SceneCaptureImageSetMapYokeParametersTagged', {
    "@type": typing.Literal["set_map_yoke"],
    "map_yoking_roman_numeral": str,
    "map_undex": int,
})


SceneCaptureImageConnDbLoginParameters = typing.TypedDict('SceneCaptureImageConnDbLoginParameters', {
    "@type": typing.NotRequired[typing.Literal["conn_db_login"]],
    "username": str,
    "password": str,
})
SceneCaptureImageConnDbLoginParametersTagged = typing.TypedDict('SceneCaptureImageConnDbLoginParametersTagged', {
    "@type": typing.Literal["conn_db_login"],
    "username": str,
    "password": str,
})


SceneCaptureImageParameters = typing.TypedDict('SceneCaptureImageParameters', {
    "@type": typing.NotRequired[typing.Literal["workbench/scene-capture-image"]],
    "scene_file": str,
    "scene_name_or_number": str,
    "image_file_name": str,
    "opt_size_window": bool,
    "opt_size_capture": bool,
    "size_width_height": typing.NotRequired[SceneCaptureImageSizeWidthHeightParameters | None],
    "opt_size_width_width": typing.NotRequired[float | None],
    "opt_size_height_height": typing.NotRequired[float | None],
    "opt_units_units": typing.NotRequired[str | None],
    "resolution": typing.NotRequired[SceneCaptureImageResolutionParameters | None],
    "opt_margin_size": typing.NotRequired[int | None],
    "opt_no_scene_colors": bool,
    "set_map_yoke": typing.NotRequired[SceneCaptureImageSetMapYokeParameters | None],
    "conn_db_login": typing.NotRequired[SceneCaptureImageConnDbLoginParameters | None],
    "opt_show_capture_settings": bool,
    "opt_renderer_renderer": typing.NotRequired[str | None],
    "opt_print_image_info": bool,
})
SceneCaptureImageParametersTagged = typing.TypedDict('SceneCaptureImageParametersTagged', {
    "@type": typing.Literal["workbench/scene-capture-image"],
    "scene_file": str,
    "scene_name_or_number": str,
    "image_file_name": str,
    "opt_size_window": bool,
    "opt_size_capture": bool,
    "size_width_height": typing.NotRequired[SceneCaptureImageSizeWidthHeightParameters | None],
    "opt_size_width_width": typing.NotRequired[float | None],
    "opt_size_height_height": typing.NotRequired[float | None],
    "opt_units_units": typing.NotRequired[str | None],
    "resolution": typing.NotRequired[SceneCaptureImageResolutionParameters | None],
    "opt_margin_size": typing.NotRequired[int | None],
    "opt_no_scene_colors": bool,
    "set_map_yoke": typing.NotRequired[SceneCaptureImageSetMapYokeParameters | None],
    "conn_db_login": typing.NotRequired[SceneCaptureImageConnDbLoginParameters | None],
    "opt_show_capture_settings": bool,
    "opt_renderer_renderer": typing.NotRequired[str | None],
    "opt_print_image_info": bool,
})


def scene_capture_image_size_width_height_params(
    width: float,
    height: float,
) -> SceneCaptureImageSizeWidthHeightParametersTagged:
    """
    Build parameters.
    
    Args:
        width: Width for output image.
        height: Height for output image.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "size_width_height",
        "width": width,
        "height": height,
    }
    return params


def scene_capture_image_size_width_height_cargs(
    params: SceneCaptureImageSizeWidthHeightParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("-size-width-height")
    cargs.append(str(params.get("width", None)))
    cargs.append(str(params.get("height", None)))
    return cargs


def scene_capture_image_resolution_params(
    number_of_pixels: float,
    units_name: str,
) -> SceneCaptureImageResolutionParametersTagged:
    """
    Build parameters.
    
    Args:
        number_of_pixels: number of pixels.
        units_name: Name of resolution units. Valid resolution unit names are:\
            PIXELS_PER_INCH\
            PIXELS_PER_CENTIMETER\
            PIXELS_PER_METER\
            PIXELS_PER_MILLIMETER.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "resolution",
        "number_of_pixels": number_of_pixels,
        "units_name": units_name,
    }
    return params


def scene_capture_image_resolution_cargs(
    params: SceneCaptureImageResolutionParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("-resolution")
    cargs.append(str(params.get("number_of_pixels", None)))
    cargs.append(params.get("units_name", None))
    return cargs


def scene_capture_image_set_map_yoke_params(
    map_yoking_roman_numeral: str,
    map_undex: int,
) -> SceneCaptureImageSetMapYokeParametersTagged:
    """
    Build parameters.
    
    Args:
        map_yoking_roman_numeral: Roman numeral identifying the map yoking\
            group (I, II, III, IV, V, VI, VII, VIII, IX, X).
        map_undex: Map index for yoking group. Indices start at 1 (one).
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "set_map_yoke",
        "map_yoking_roman_numeral": map_yoking_roman_numeral,
        "map_undex": map_undex,
    }
    return params


def scene_capture_image_set_map_yoke_cargs(
    params: SceneCaptureImageSetMapYokeParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("-set-map-yoke")
    cargs.append(params.get("map_yoking_roman_numeral", None))
    cargs.append(str(params.get("map_undex", None)))
    return cargs


def scene_capture_image_conn_db_login_params(
    username: str,
    password: str,
) -> SceneCaptureImageConnDbLoginParametersTagged:
    """
    Build parameters.
    
    Args:
        username: Connectome DB Username.
        password: Connectome DB Password.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "conn_db_login",
        "username": username,
        "password": password,
    }
    return params


def scene_capture_image_conn_db_login_cargs(
    params: SceneCaptureImageConnDbLoginParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("-conn-db-login")
    cargs.append(params.get("username", None))
    cargs.append(params.get("password", None))
    return cargs


class SceneCaptureImageOutputs(typing.NamedTuple):
    """
    Output object returned when calling `SceneCaptureImageParameters(...)`.
    """
    root: OutputPathType
    """Output root folder. This is the root folder for all outputs."""


def scene_capture_image_params(
    scene_file: str,
    scene_name_or_number: str,
    image_file_name: str,
    opt_size_window: bool = False,
    opt_size_capture: bool = False,
    size_width_height: SceneCaptureImageSizeWidthHeightParameters | None = None,
    opt_size_width_width: float | None = None,
    opt_size_height_height: float | None = None,
    opt_units_units: str | None = None,
    resolution: SceneCaptureImageResolutionParameters | None = None,
    opt_margin_size: int | None = None,
    opt_no_scene_colors: bool = False,
    set_map_yoke: SceneCaptureImageSetMapYokeParameters | None = None,
    conn_db_login: SceneCaptureImageConnDbLoginParameters | None = None,
    opt_show_capture_settings: bool = False,
    opt_renderer_renderer: str | None = None,
    opt_print_image_info: bool = False,
) -> SceneCaptureImageParametersTagged:
    """
    Build parameters.
    
    Args:
        scene_file: scene file.
        scene_name_or_number: name or number (starting at one) of the scene in\
            the scene file.
        image_file_name: output - image file name\
            The file name must end with a valid extension that identifies the\
            image file format. Valid extensions on this system are: (.bmp .jpeg\
            .jpg .png .ppm).\
            \
            If there is more than one window in the scene, multiple image files\
            are output with the window's number inserted into the name of the\
            image file immediately before the image file's extension.
        opt_size_window: Output image is size of window's graphics region from\
            when scene was created.
        opt_size_capture: Output image uses size from Capture Dialog when scene\
            was created.
        size_width_height: Width and height for output image.
        opt_size_width_width: Width for output image. Height is computed using\
            the aspect ratio from the window's width and height saved in the\
            scene.: Width for output image.
        opt_size_height_height: Height for output image. Width is computed\
            using the aspect ratio from the window's width and height saved in the\
            scene.: Height for output image.
        opt_units_units: Units for image width/height\
            Default is PIXELS: Name of units for image width/height. Valid\
            units are:\
            INCHES\
            CENTIMETERS\
            MILLIMETERS\
            METERS\
            PIXELS.
        resolution: Image resolution (number pixels per size unit)\
            Default is 300 PIXELS_PER_INCH.
        opt_margin_size: Add a margin to sides of the image using the window's\
            background color.: size of margin, in pixels, added to all sides of\
            output image.
        opt_no_scene_colors: Do not use background and foreground colors in\
            scene.
        set_map_yoke: Override selected map index for a map yoking group.
        conn_db_login: Login for scenes with files in Connectome Database. If\
            this option is not specified, the login and password stored in the\
            user's preferences is used.
        opt_show_capture_settings: Print settings from Capture Dialog only, DO\
            NOT create image file(s).
        opt_renderer_renderer: Select renderer for drawing image: Name of\
            renderer to use for drawing image.
        opt_print_image_info: Print the size and other information about output\
            images only and DO NOT create any output images.
    Returns:
        Parameter dictionary
    """
    params = {
        "@type": "workbench/scene-capture-image",
        "scene_file": scene_file,
        "scene_name_or_number": scene_name_or_number,
        "image_file_name": image_file_name,
        "opt_size_window": opt_size_window,
        "opt_size_capture": opt_size_capture,
        "opt_no_scene_colors": opt_no_scene_colors,
        "opt_show_capture_settings": opt_show_capture_settings,
        "opt_print_image_info": opt_print_image_info,
    }
    if size_width_height is not None:
        params["size_width_height"] = size_width_height
    if opt_size_width_width is not None:
        params["opt_size_width_width"] = opt_size_width_width
    if opt_size_height_height is not None:
        params["opt_size_height_height"] = opt_size_height_height
    if opt_units_units is not None:
        params["opt_units_units"] = opt_units_units
    if resolution is not None:
        params["resolution"] = resolution
    if opt_margin_size is not None:
        params["opt_margin_size"] = opt_margin_size
    if set_map_yoke is not None:
        params["set_map_yoke"] = set_map_yoke
    if conn_db_login is not None:
        params["conn_db_login"] = conn_db_login
    if opt_renderer_renderer is not None:
        params["opt_renderer_renderer"] = opt_renderer_renderer
    return params


def scene_capture_image_cargs(
    params: SceneCaptureImageParameters,
    execution: Execution,
) -> list[str]:
    """
    Build command-line arguments from parameters.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Command-line arguments.
    """
    cargs = []
    cargs.append("wb_command")
    cargs.append("-scene-capture-image")
    cargs.append(params.get("scene_file", None))
    cargs.append(params.get("scene_name_or_number", None))
    cargs.append(params.get("image_file_name", None))
    if params.get("opt_size_window", False):
        cargs.append("-size-window")
    if params.get("opt_size_capture", False):
        cargs.append("-size-capture")
    if params.get("size_width_height", None) is not None:
        cargs.extend(scene_capture_image_size_width_height_cargs(params.get("size_width_height", None), execution))
    if params.get("opt_size_width_width", None) is not None:
        cargs.extend([
            "-size-width",
            str(params.get("opt_size_width_width", None))
        ])
    if params.get("opt_size_height_height", None) is not None:
        cargs.extend([
            "-size-height",
            str(params.get("opt_size_height_height", None))
        ])
    if params.get("opt_units_units", None) is not None:
        cargs.extend([
            "-units",
            params.get("opt_units_units", None)
        ])
    if params.get("resolution", None) is not None:
        cargs.extend(scene_capture_image_resolution_cargs(params.get("resolution", None), execution))
    if params.get("opt_margin_size", None) is not None:
        cargs.extend([
            "-margin",
            str(params.get("opt_margin_size", None))
        ])
    if params.get("opt_no_scene_colors", False):
        cargs.append("-no-scene-colors")
    if params.get("set_map_yoke", None) is not None:
        cargs.extend(scene_capture_image_set_map_yoke_cargs(params.get("set_map_yoke", None), execution))
    if params.get("conn_db_login", None) is not None:
        cargs.extend(scene_capture_image_conn_db_login_cargs(params.get("conn_db_login", None), execution))
    if params.get("opt_show_capture_settings", False):
        cargs.append("-show-capture-settings")
    if params.get("opt_renderer_renderer", None) is not None:
        cargs.extend([
            "-renderer",
            params.get("opt_renderer_renderer", None)
        ])
    if params.get("opt_print_image_info", False):
        cargs.append("-print-image-info")
    return cargs


def scene_capture_image_outputs(
    params: SceneCaptureImageParameters,
    execution: Execution,
) -> SceneCaptureImageOutputs:
    """
    Build outputs object containing output file paths and possibly stdout/stderr.
    
    Args:
        params: The parameters.
        execution: The execution object for resolving input paths.
    Returns:
        Outputs object.
    """
    ret = SceneCaptureImageOutputs(
        root=execution.output_file("."),
    )
    return ret


def scene_capture_image_execute(
    params: SceneCaptureImageParameters,
    runner: Runner | None = None,
) -> SceneCaptureImageOutputs:
    """
    scene-capture-image
    
    Offscreen rendering of scene to an image file.
    
    ----------------------------------------------------------------------
    
    Render content of browser windows displayed in a scene into image file(s).
    
    If none of the "-size" options are specified, the default is "-size-window"
    (Output image is size of the window that was saved in the scene).
    
    For the "-size" options that accept a width and/or height, the values
    default to number of pixels. To express the width and/or height in physical
    units (inches, centimeters, etc.), use the "-units" option. When physical
    units are used, the pixel width and height are derived using the physical
    width/height and the image resolution (see the "-resolution" option).
    
    Note that scenes created prior to version 1.2 (May 2016) do not contain
    information about the size of the window. Therefore, one must use the
    "-size-width-height" option.
    
    Examples:
    
    Generate an image of the second scene. Width and height of image is width
    and height of window saved in the scene.
    wb_command -scene-capture-image myscene.scene 2 image2.jpg
    
    Generate an image of the second scene with a margin around sides of the
    image. Width and height of image is width and height of window saved in the
    scene.
    wb_command -scene-capture-image myscene.scene 2 image2.jpg -margin 10
    
    Generate an image of the second scene that is 6 inches width with 300 pixels
    per inch. The resulting width is 1800 pixels. The resulting height of the
    image is a function of the width and the aspect ratio (height divided by
    width) of the window size saved in the scene.
    wb_command -scene-capture-image myscene.scene 2 image21.jpg \\
    -size-width 6 -units INCHES -resolution 300 PIXELS_PER_INCH
    
    Print information about the size of the output image for the second scene
    (no image file is created) using a width of 4.5 centimeters.
    wb_command -scene-capture-image myscene.scene 2 test.jpg \\
    -size-width 4.5 -units CENTIMETERS -print-image-info
    
    
    
    
    NO OFF SCREEN RENDERERS AVAILABLE ON THIS SYSTEM. COMMAND WILL FAIL !!!!
    
    
    ERROR: -scene-capture-image is not available !
    A required library for this command, Mesa3D (software version of OpenGL),
    was not available when this software was created. This command is not
    available for the Windows version of this software but should always be
    available in the Linux and MacOS versions.
    .
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        params: The parameters.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SceneCaptureImageOutputs`).
    """
    runner = runner or get_global_runner()
    execution = runner.start_execution(SCENE_CAPTURE_IMAGE_METADATA)
    params = execution.params(params)
    cargs = scene_capture_image_cargs(params, execution)
    ret = scene_capture_image_outputs(params, execution)
    execution.run(cargs)
    return ret


def scene_capture_image(
    scene_file: str,
    scene_name_or_number: str,
    image_file_name: str,
    opt_size_window: bool = False,
    opt_size_capture: bool = False,
    size_width_height: SceneCaptureImageSizeWidthHeightParameters | None = None,
    opt_size_width_width: float | None = None,
    opt_size_height_height: float | None = None,
    opt_units_units: str | None = None,
    resolution: SceneCaptureImageResolutionParameters | None = None,
    opt_margin_size: int | None = None,
    opt_no_scene_colors: bool = False,
    set_map_yoke: SceneCaptureImageSetMapYokeParameters | None = None,
    conn_db_login: SceneCaptureImageConnDbLoginParameters | None = None,
    opt_show_capture_settings: bool = False,
    opt_renderer_renderer: str | None = None,
    opt_print_image_info: bool = False,
    runner: Runner | None = None,
) -> SceneCaptureImageOutputs:
    """
    scene-capture-image
    
    Offscreen rendering of scene to an image file.
    
    ----------------------------------------------------------------------
    
    Render content of browser windows displayed in a scene into image file(s).
    
    If none of the "-size" options are specified, the default is "-size-window"
    (Output image is size of the window that was saved in the scene).
    
    For the "-size" options that accept a width and/or height, the values
    default to number of pixels. To express the width and/or height in physical
    units (inches, centimeters, etc.), use the "-units" option. When physical
    units are used, the pixel width and height are derived using the physical
    width/height and the image resolution (see the "-resolution" option).
    
    Note that scenes created prior to version 1.2 (May 2016) do not contain
    information about the size of the window. Therefore, one must use the
    "-size-width-height" option.
    
    Examples:
    
    Generate an image of the second scene. Width and height of image is width
    and height of window saved in the scene.
    wb_command -scene-capture-image myscene.scene 2 image2.jpg
    
    Generate an image of the second scene with a margin around sides of the
    image. Width and height of image is width and height of window saved in the
    scene.
    wb_command -scene-capture-image myscene.scene 2 image2.jpg -margin 10
    
    Generate an image of the second scene that is 6 inches width with 300 pixels
    per inch. The resulting width is 1800 pixels. The resulting height of the
    image is a function of the width and the aspect ratio (height divided by
    width) of the window size saved in the scene.
    wb_command -scene-capture-image myscene.scene 2 image21.jpg \\
    -size-width 6 -units INCHES -resolution 300 PIXELS_PER_INCH
    
    Print information about the size of the output image for the second scene
    (no image file is created) using a width of 4.5 centimeters.
    wb_command -scene-capture-image myscene.scene 2 test.jpg \\
    -size-width 4.5 -units CENTIMETERS -print-image-info
    
    
    
    
    NO OFF SCREEN RENDERERS AVAILABLE ON THIS SYSTEM. COMMAND WILL FAIL !!!!
    
    
    ERROR: -scene-capture-image is not available !
    A required library for this command, Mesa3D (software version of OpenGL),
    was not available when this software was created. This command is not
    available for the Windows version of this software but should always be
    available in the Linux and MacOS versions.
    .
    
    Author: Connectome Workbench Developers
    
    URL: https://github.com/Washington-University/workbench
    
    Args:
        scene_file: scene file.
        scene_name_or_number: name or number (starting at one) of the scene in\
            the scene file.
        image_file_name: output - image file name\
            The file name must end with a valid extension that identifies the\
            image file format. Valid extensions on this system are: (.bmp .jpeg\
            .jpg .png .ppm).\
            \
            If there is more than one window in the scene, multiple image files\
            are output with the window's number inserted into the name of the\
            image file immediately before the image file's extension.
        opt_size_window: Output image is size of window's graphics region from\
            when scene was created.
        opt_size_capture: Output image uses size from Capture Dialog when scene\
            was created.
        size_width_height: Width and height for output image.
        opt_size_width_width: Width for output image. Height is computed using\
            the aspect ratio from the window's width and height saved in the\
            scene.: Width for output image.
        opt_size_height_height: Height for output image. Width is computed\
            using the aspect ratio from the window's width and height saved in the\
            scene.: Height for output image.
        opt_units_units: Units for image width/height\
            Default is PIXELS: Name of units for image width/height. Valid\
            units are:\
            INCHES\
            CENTIMETERS\
            MILLIMETERS\
            METERS\
            PIXELS.
        resolution: Image resolution (number pixels per size unit)\
            Default is 300 PIXELS_PER_INCH.
        opt_margin_size: Add a margin to sides of the image using the window's\
            background color.: size of margin, in pixels, added to all sides of\
            output image.
        opt_no_scene_colors: Do not use background and foreground colors in\
            scene.
        set_map_yoke: Override selected map index for a map yoking group.
        conn_db_login: Login for scenes with files in Connectome Database. If\
            this option is not specified, the login and password stored in the\
            user's preferences is used.
        opt_show_capture_settings: Print settings from Capture Dialog only, DO\
            NOT create image file(s).
        opt_renderer_renderer: Select renderer for drawing image: Name of\
            renderer to use for drawing image.
        opt_print_image_info: Print the size and other information about output\
            images only and DO NOT create any output images.
        runner: Command runner.
    Returns:
        NamedTuple of outputs (described in `SceneCaptureImageOutputs`).
    """
    params = scene_capture_image_params(
        scene_file=scene_file,
        scene_name_or_number=scene_name_or_number,
        image_file_name=image_file_name,
        opt_size_window=opt_size_window,
        opt_size_capture=opt_size_capture,
        size_width_height=size_width_height,
        opt_size_width_width=opt_size_width_width,
        opt_size_height_height=opt_size_height_height,
        opt_units_units=opt_units_units,
        resolution=resolution,
        opt_margin_size=opt_margin_size,
        opt_no_scene_colors=opt_no_scene_colors,
        set_map_yoke=set_map_yoke,
        conn_db_login=conn_db_login,
        opt_show_capture_settings=opt_show_capture_settings,
        opt_renderer_renderer=opt_renderer_renderer,
        opt_print_image_info=opt_print_image_info,
    )
    return scene_capture_image_execute(params, runner)


__all__ = [
    "SCENE_CAPTURE_IMAGE_METADATA",
    "SceneCaptureImageOutputs",
    "scene_capture_image",
    "scene_capture_image_conn_db_login_params",
    "scene_capture_image_execute",
    "scene_capture_image_params",
    "scene_capture_image_resolution_params",
    "scene_capture_image_set_map_yoke_params",
    "scene_capture_image_size_width_height_params",
]
