View in #cornerstone3d on Slack
@Peter_Newhook: What’s the best way to get new measurements of an annotation after calling calibrateImageSpacing()
? We have so sync annotation measurements with a Redux store, so after calling calibrateImageSpacing()
I call getAnnotation(id)
, but it looks like I’m getting length of a line from before calibration is applied?
![Syed_Pasha_[Ramsoft]] @Syed_Pasha_[Ramsoft]: how about listening to the measurement added event so you get the annotation right after it is created?
@Peter_Newhook: I think that’s my next attempt, presumably Annotation added is just called once at first addition? I need to to draw a line, calibrate, then get the new length of that line. Maybe CORNERSTONE_TOOLS_ANNOTATION_MODIFIED
?
![Syed_Pasha_[Ramsoft]] @Syed_Pasha_[Ramsoft]: yeah the modified event would make more sense in this context.
debounce the event listener if you end up using it
@Peter_Newhook: Looks like CORNERSTONE_TOOLS_ANNOTATION_MODIFIED
isn’t triggered. But there are a lot of CORNERSTONE_TOOLS_ANNOTATION_RENDERED
events fired. Unfortunately those only include the element, viewport ID, and rendering engine ID. Any recommendations on getting all the annotations for a given viewport ID?
![Syed_Pasha_[Ramsoft]] @Syed_Pasha_[Ramsoft]: apart from the mentioned properties, do you need something specific?
i see a lot of useful methods like getAnnotations
getAllAnnotations
inside cornerstoneTools.annotation.state
@Peter_Newhook: Yeah, those require an annotation ID.
![Syed_Pasha_[Ramsoft]] @Syed_Pasha_[Ramsoft]: hm you can capture the annotation uid from the measurement added event and then get the required annotation.
there must be a simple way to do this IMO
hey i just checked, the CORNERSTONE_TOOLS_ANNOTATION_MODIFIED
does get triggered when changing the annotation. and it also has the data of the annotation. i assume you meant it does not trigger after calibration?
@Peter_Newhook: Yeah, I noticed that. But for some reason my event handler for that function isn’t firing.
![Syed_Pasha_[Ramsoft]] @Syed_Pasha_[Ramsoft]: how are you listening to the event?
this is what i did atleast
cornerstone.eventTarget.addEventListener(cornerstoneTools.Enums.Events.ANNOTATION_MODIFIED, (x) => {
console.log(x)
})
@Peter_Newhook: ohhh, I was adding the event to the Viewport HTML element
That’s perfect thank you. It’s fired after the throttled _calculateCachedStats
call, so the new value is correct