Skip to content

feat(CircleROITools) : Added new handles to the CircleROITools - #2122

Merged
sedghi merged 17 commits into
cornerstonejs:mainfrom
Celian-abd:add-new-handles
Jul 2, 2025
Merged

feat(CircleROITools) : Added new handles to the CircleROITools#2122
sedghi merged 17 commits into
cornerstonejs:mainfrom
Celian-abd:add-new-handles

Conversation

@Celian-abd

Copy link
Copy Markdown
Contributor

Context

Added new handles for the CircleROITool and CircleROIStartEndThreshold.
There is now 5 handles (center , top, bottom, left and right).

Changes & Results

Before :
image

After :
image

Testing

Checklist

PR

  • [] My Pull Request title is descriptive, accurate and follows the
    semantic-release format and guidelines.

Code

  • [] My code has been well-documented (function documentation, inline comments,
    etc.)

Public Documentation Updates

  • [] The documentation page has been updated as necessary for any public API
    additions or removals.

Tested Environment

  • [] "OS:
  • [] "Node version:
  • [] "Browser:

@sedghi
sedghi requested a review from Copilot June 5, 2025 00:24

This comment was marked as outdated.

@sedghi sedghi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we have a configuration said simplified: true, and if it is false all of these appear?

@Celian-abd
Celian-abd requested a review from sedghi June 5, 2025 15:05
@Celian-abd

Copy link
Copy Markdown
Contributor Author

I've made the changes, now when the configuration says simplified: true, the tool is the same as before, but if we put simplified: false then our multiple handles appears.

Comment thread packages/tools/src/tools/annotation/CircleROITool.ts Outdated

@rodrigobasilio2022 rodrigobasilio2022 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good to me. Just one minor question related to the duplication of the center information

@salimkanoun

Copy link
Copy Markdown
Contributor

Hi there if this PR is OK can it be merged ?

@sedghi

sedghi commented Jun 30, 2025

Copy link
Copy Markdown
Member

@rodrigobasilio2022 can you try it in local example and then merge?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a configurable simplified mode for both CircleROITool and CircleROIStartEndThresholdTool, toggling between a 2-handle (center + radius) and a 5-handle (center, top, bottom, left, right) representation. Type definitions, drawing/modification callbacks, and rendering routines have been updated to support the new multi-handle scenario.

  • Extended annotation types to support five points when simplified: false.
  • Added a simplified flag and branched logic throughout both tools.
  • Updated rendering, drag, and slice-projection logic to handle five handles.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/tools/src/types/ToolSpecificAnnotationTypes.ts Updated points tuple for circle annotations to five handles
packages/tools/src/tools/segmentation/CircleROIStartEndThresholdTool.ts Introduced simplified config, branched logic for handle arrays
packages/tools/src/tools/annotation/CircleROITool.ts Mirrored simplified changes, updated draw/modify callbacks
packages/tools/examples/.../index.ts Enabled simplified example in segmentation demo
Comments suppressed due to low confidence (2)

packages/tools/src/tools/segmentation/CircleROIStartEndThresholdTool.ts:86

  • There are no tests verifying both simplified modes (2-handle vs 5-handle). Consider adding unit or integration tests to cover drawing, modifying, and rendering behaviors when simplified is false (5-handle mode).
        //Simplified handles, if false (5 handles : center, top, bottom, left, right)

packages/tools/src/tools/annotation/CircleROITool.ts:287

  • The variable canvasCoords is undefined in this scope. It should likely be canvasHandles[1] to match the center-plus-radius usage.
    const radiusPoint = getCanvasCircleRadius([canvasCenter, canvasCoords]);

};
handles: {
points: [Types.Point3, Types.Point3]; // [center, end]
points: Types.Point3[]; // [center, top, bottom, left, right]

Copilot AI Jul 2, 2025

Copy link

Choose a reason for hiding this comment

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

The points type for CircleROIStartEndThresholdAnnotation is a general Types.Point3[], which can lead to inconsistent tuple lengths. Consider defining it as a fixed-length tuple [Types.Point3, Types.Point3, Types.Point3, Types.Point3, Types.Point3] to reflect exactly five handles.

Suggested change
points: Types.Point3[]; // [center, top, bottom, left, right]
points: [Types.Point3, Types.Point3, Types.Point3, Types.Point3, Types.Point3]; // [center, top, bottom, left, right]

Copilot uses AI. Check for mistakes.

@rodrigobasilio2022 rodrigobasilio2022 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for the contribution

@sedghi
sedghi merged commit 2b02464 into cornerstonejs:main Jul 2, 2025
9 checks passed
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.

5 participants