Skip to content

Publish a pair of floats as a vec2, the joystick's argument type - #24

Open
Jules-GP wants to merge 1 commit into
mainfrom
feat/vec2-schema
Open

Publish a pair of floats as a vec2, the joystick's argument type#24
Jules-GP wants to merge 1 commit into
mainfrom
feat/vec2-schema

Conversation

@Jules-GP

Copy link
Copy Markdown
Collaborator

Adds vec2 to the schema vocabulary: two numbers set together, because they are
one position rather than two settings.

The client already renders it - a 2D pad plus two spin boxes, with drag, Ctrl
for a finer gesture, wheel and arrow keys - and had nothing producing it. This
is the producing half.

def run(surfaces: Path, output_dir: Path,
        anterior_right: tuple[float, float] = (0.5, 0.0)) -> Path:
# layout.py
LAYOUT = {
    "anterior_right": {"ui": "joystick",
                       "x_range": [0.0, 1.0], "y_range": [-5.0, 5.0],
                       "x_labels": ["mid", "out"], "y_labels": ["POST", "ANT"]},
}

Two decisions, both toward refusing rather than guessing

Only tuple[float, float]. A three-number tuple is a point and would want a
different widget; refusing it costs less than publishing a type nothing renders.

The ranges are validated by the SERVER, not merely respected by the pad.
They are the one layout key that reaches validate(): a request that skips the
panel would otherwise place a patch corner off the arch and be answered with a
success. A mirrored axis is still written by inverting the range
(x_range: [15, -15] puts 15 at the left end), and validation compares against
the min and max rather than the declared order.

Verified end to end

An annotation through describe.py, the generated schema through the server's
_argument_spec, and validate() refusing y = 9 on an axis declared
[-5, 5] - naming the axis and the value.

scripts/tests 72 passed. The server half is a separate branch in
slicer-remote-tool-server (315 passed there); this one is inert without it, and
harmless: a tool declaring a vec2 simply fails to load on an older server, the
way any unknown type does.

Copilot AI lite review requested due to automatic review settings August 20, 2026 12:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants