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

freehand tool doesn't fire MEASUREMENT_MODIFIED event #774

Closed
2 of 3 tasks
Zaid-Safadi opened this issue Jan 27, 2019 · 5 comments
Closed
2 of 3 tasks

freehand tool doesn't fire MEASUREMENT_MODIFIED event #774

Zaid-Safadi opened this issue Jan 27, 2019 · 5 comments
Assignees

Comments

@Zaid-Safadi
Copy link
Contributor

Prerequisites

  • Are you running the latest version?
    Using v2.4.0
  • Are you reporting to the correct repository?
  • Did you perform a cursory search?

For more information, see the CONTRIBUTING guide.

Description

The freehand tool doesn't fire the cornerstonetoolsmeasurementmodified event as the other measurement tools

Not sure if this issue is fixed in vNext.

Steps to Reproduce

  1. Register to the event element.addEventListener("cornerstonetoolsmeasurementmodified", onModified);
  2. draw a freehand
  3. Event is not being called.

Expected behavior:
The event "cornerstonetoolsmeasurementmodified" be fired and the handler is called.

Actual behavior:
Event is not fired.

@Zaid-Safadi
Copy link
Contributor Author

If possible to update this in v2.4.0 I'll submit a PR and if someone can confirmed it exists in vNext I'll update that too.

This can be fixed by firing the event in the addPoint and endDrawing methods:

/**
* Adds a point on mouse click in polygon mode.
*
* @param {Object} eventData - data object associated with an event.
*/
function addPoint (eventData) {
...
// Increment the current handle value
  config.currentHandle += 1;
  fireModified(eventData.element, data);
...
...
}

/**
* Ends the active drawing loop and completes the polygon.
*
* @param {Object} eventData - data object associated with an event.
* @param {Object} handleNearby - the handle nearest to the mouse cursor.
*/
function endDrawing (eventData, handleNearby) {
  ...
  data.canComplete = false;

  fireModified(eventData.element, data);

  external.cornerstone.updateImage(eventData.element);
}

function fireModified (element, data) {
  const eventType = EVENTS.MEASUREMENT_MODIFIED;
  const modifiedEventData = {
    toolType,
    element,
    measurementData: data
  };

  triggerEvent(element, eventType, modifiedEventData);
}

@dannyrb dannyrb self-assigned this Jan 27, 2019
Zaid-Safadi added a commit that referenced this issue Feb 3, 2019
Zaid-Safadi added a commit that referenced this issue Feb 10, 2019
@Zaid-Safadi
Copy link
Contributor Author

This is fixed for v2 in branch v2.4.x.
I will leave it open to apply the fix for v3

@JamesAPetts
Copy link
Member

Hey @Zaid-Safadi , if I get time tomorrow I can do this for v3/master :).

@Zaid-Safadi
Copy link
Contributor Author

That would be really nice @JamesAPetts ! please let me know know if there is anything I can help with. Thank you

dannyrb added a commit to sisobus/cornerstoneTools that referenced this issue Mar 4, 2019
dannyrb added a commit to sisobus/cornerstoneTools that referenced this issue Mar 5, 2019
dannyrb added a commit to sisobus/cornerstoneTools that referenced this issue Mar 6, 2019
JamesAPetts added a commit to sisobus/cornerstoneTools that referenced this issue Mar 6, 2019
JamesAPetts added a commit to sisobus/cornerstoneTools that referenced this issue Mar 7, 2019
JamesAPetts pushed a commit to sisobus/cornerstoneTools that referenced this issue Mar 7, 2019
…NT_MODIFIED on freehand edit.

EVENTS.MEASUREMENT_MODIFIED is now fired when a freehand annotation is modified.

cornerstonejs#774
dannyrb added a commit to sisobus/cornerstoneTools that referenced this issue Mar 14, 2019
dannyrb added a commit to sisobus/cornerstoneTools that referenced this issue Mar 28, 2019
@dannyrb
Copy link
Member

dannyrb commented May 27, 2019

Fixed in 3.10

image

@dannyrb dannyrb closed this as completed May 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants