Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Tools): add Eraser Tool #806

Merged
merged 19 commits into from
Feb 15, 2024
Merged

Conversation

ramonemiliani93
Copy link
Contributor

Context

Creates an eraser tool that allows the deletion of annotations.

Changes & Results

  • Add new tool

What are the effects of this change?

  • New tool available to delete annotations

Testing

  • There is an EraserTool_test file to run tests on the tool.

Checklist

PR

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

Code

Public Documentation Updates

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

Tested Environment

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

@netlify
Copy link

netlify bot commented Oct 3, 2023

Deploy Preview for cornerstone-3d-docs ready!

Name Link
🔨 Latest commit cbca833
🔍 Latest deploy log https://app.netlify.com/sites/cornerstone-3d-docs/deploys/65ce2651426d4d0008f5c40c
😎 Deploy Preview https://deploy-preview-806--cornerstone-3d-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@ramonemiliani93 ramonemiliani93 marked this pull request as draft October 3, 2023 14:40
@sedghi sedghi requested a review from jbocce October 14, 2023 00:20
@jbocce
Copy link
Collaborator

jbocce commented Oct 18, 2023

Thank you so much for this PR. It is a nice feature to get in.

A few overall things for this PR...

continue;
}

const annotations = state.getAnnotations(toolName, viewportId);
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think here we need element instead of viewportId

const vp = this.renderingEngine.getViewport(viewportId);

const addEventListenerForAnnotationRemoved = () => {
element.addEventListener(csToolsEvents.ANNOTATION_REMOVED, () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think here instead of adding the listener to element, eventTarget should be used.

@jbocce
Copy link
Collaborator

jbocce commented Oct 18, 2023

@ramonemiliani93 it looks good so far. Perhaps make the suggested changes, push and then we can take this out of draft and go from there. Thanks.

@ramonemiliani93 ramonemiliani93 changed the base branch from main to beta November 2, 2023 14:12
@ramonemiliani93 ramonemiliani93 changed the base branch from beta to main November 2, 2023 14:12
@ramonemiliani93
Copy link
Contributor Author

Changes done @jbocce 👌 Let me know If I need to add/update something 💪

@jbocce
Copy link
Collaborator

jbocce commented Nov 3, 2023

Changes done @jbocce 👌 Let me know If I need to add/update something 💪

@ramonemiliani93 thank you for the updates. However the unit test you added is not passing. Does it pass for you?

Also I was hoping you would have added the eraser tool to the stack annotation tools example as I had requested.

Without these two items it is difficult to test your code and complete the PR. If you could please update accordingly then that would be very much appreciated.

@ramonemiliani93
Copy link
Contributor Author

Sorry, @jbocce! It seems like I did not push the changes for the stack annotation tools example. Regarding the test, I have yet to figure out why it is not capturing the event (partly the reason why I opened the PR in draft). If you could point me in the right direction on how to figure out why the ANNOTATION_REMOVED event is not being caught, I will fix it as soon as possible.

this.DOMElements = [];

this.stackToolGroup = ToolGroupManager.createToolGroup('stack');
this.stackToolGroup.addTool(EraserTool.toolName, {});
Copy link
Collaborator

Choose a reason for hiding this comment

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

We need to add the length tool to the tool group for the stack viewport so that it is picked up in the EraserTool code. So below this line add...

this.stackToolGroup.addTool(LengthTool.toolName, {});

});

addEventListenerForAnnotationRemoved();
document.dispatchEvent(evt);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Dispatch the event on the viewport element itself. (i.e. element.dispatchEvent(evt))

Copy link
Collaborator

Choose a reason for hiding this comment

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

The only two changes I needed to have the test pass are suggested below. Please give them a try.

@@ -118,6 +119,7 @@ const toolsNames = [
CobbAngleTool.toolName,
ArrowAnnotateTool.toolName,
PlanarFreehandROITool.toolName,
EraserTool.toolName,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for adding the eraser tool to the example. I tried it and was able to delete every annotation type except the probe. Could you please have a look at why this might be? Thanks.

Copy link
Collaborator

@jbocce jbocce left a comment

Choose a reason for hiding this comment

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

Please update the unit test and if it passes push your changes and remove the draft status of the PR so that we can move forward. Also be sure to determine why the probe tool cannot be erased. Thanks.

@sedghi sedghi marked this pull request as ready for review February 15, 2024 16:26
@sedghi sedghi merged commit 9cd1381 into cornerstonejs:main Feb 15, 2024
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.

3 participants