Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
renderToolData(evt: any) {
const toolData = cornerstoneTools.getToolState(evt.currentTarget, this.name)
if (!toolData) {
return
}
const eventData = evt.detail
const { image, element } = eventData
const lineWidth = cornerstoneTools.toolStyle.getToolWidth()
const { handleRadius, drawHandlesOnHover } = this.configuration
const context = getNewContext(eventData.canvasContext.canvas)
const { rowPixelSpacing, colPixelSpacing } = getPixelSpacing(image)
// Meta
const seriesModule =
cornerstone.metaData.get('generalSeriesModule', image.imageId) || {}
mouseMoveCallback(e: any) {
const eventData = e.detail
const { element } = eventData
cornerstoneTools.toolCoordinates.setCoords(eventData)
// If we have no tool data for this element, do nothing
const toolData = cornerstoneTools.getToolState(element, this.name)
if (!toolData) {
return
}
// We have tool data, search through all data
// And see if we can activate a handle
let imageNeedsUpdate = false
for (let i = 0; i < toolData.data.length; i++) {
// Get the cursor position in canvas coordinates
const coords = eventData.currentPoints.canvas
const data = toolData.data[i]
if (handleActivator(eventData.element, data.handles, coords) === true) {
}
if (handle) {
handle.moving = false
handle.selected = true
}
setToolCursor(this.element, this.svgCursor)
cornerstone.updateImage(element)
element.addEventListener(EVENTS.MOUSE_MOVE, this.mouseMoveCallback)
element.addEventListener(EVENTS.TOUCH_START, this._moveCallback)
}
const coords = eventData.startPoints.canvas
const toolData = cornerstoneTools.getToolState(e.currentTarget, this.name)
if (!toolData) {
return
}
let i
// Now check to see if there is a handle we can move
for (i = 0; i < toolData.data.length; i++) {
data = toolData.data[i]
const distance = 6
const handle = getHandleNearImagePoint(
element,
data.handles,
coords,
distance,
onPaintEnd = strokeBuffer => {
const element = this.cornerstoneElements[0];
const enabledElement = cornerstone.getEnabledElement(element);
const { getters, setters } = cornerstoneTools.getModule('segmentation');
const labelmap3D = getters.labelmap3D(element);
const stackState = cornerstoneTools.getToolState(element, 'stack');
const { rows, columns } = enabledElement.image;
if (!stackState || !labelmap3D) {
return;
}
const stackData = stackState.data[0];
const numberOfFrames = stackData.imageIds.length;
const segmentIndex = labelmap3D.activeSegmentIndex;
for (let i = 0; i < numberOfFrames; i++) {
let labelmap2D = labelmap3D.labelmaps2D[i];
if (labelmap2D && labelmap2D.segmentsOnLabelmap.includes(segmentIndex)) {
continue;
}
onClickBackButton: () => {
const stackData = csTools.getToolState(activeEnabledElement, 'stack');
if (!stackData || !stackData.data || !stackData.data.length) return;
const { currentImageIdIndex } = stackData.data[0];
if (currentImageIdIndex === 0) return;
scrollToIndex(activeEnabledElement, currentImageIdIndex - 1);
},
onClickSkipToStart: () => {
Object.keys(model.tools).forEach((toolName) => {
const state = cornerstoneTools.getToolState(element, toolName);
measurements[toolName] = (state || {}).data || [];
});
return measurements;
availableToolTypes.forEach(toolType => {
const elementToolData = cornerstoneTools.getToolState(
element,
toolType
);
if (!elementToolData) {
return;
}
elementToolData.data.forEach((toolData, index) => {
let elementToolInstance = cornerstoneTools.getToolForElement(
element,
toolType
);
if (!elementToolInstance) {
elementToolInstance = cornerstoneTools.getToolForElement(