Skip to content

Commit

Permalink
feat: Add labels to the toolData for annotation tools
Browse files Browse the repository at this point in the history
  • Loading branch information
sedghi authored and swederik committed Mar 22, 2022
1 parent 4b670cd commit fe7570d
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/cornerstone-tools/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
removeToolStateByToolDataUID,
getDefaultToolStateManager,
getViewportSpecificStateManager,
getToolDataByToolDataUID,
} from './stateManagement'

import { init, destroy } from './init'
Expand Down Expand Up @@ -139,4 +140,5 @@ export {
Cursors,
getDefaultToolStateManager,
getViewportSpecificStateManager,
getToolDataByToolDataUID,
}
2 changes: 2 additions & 0 deletions packages/cornerstone-tools/src/stateManagement/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
removeToolStateByToolDataUID,
getDefaultToolStateManager,
getViewportSpecificStateManager,
getToolDataByToolDataUID,
} from './toolState'

export {
Expand All @@ -33,4 +34,5 @@ export {
removeToolStateByToolDataUID,
getDefaultToolStateManager,
getViewportSpecificStateManager,
getToolDataByToolDataUID,
}
13 changes: 12 additions & 1 deletion packages/cornerstone-tools/src/stateManagement/toolState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function getDefaultToolStateManager() {
}

function getViewportSpecificStateManager(
element: Types.IEnabledElement | HTMLElement
element?: Types.IEnabledElement | HTMLElement
) {
// TODO:
// We may want multiple FrameOfReferenceSpecificStateManagers.
Expand Down Expand Up @@ -145,9 +145,20 @@ function removeToolStateByToolDataUID(
triggerEvent(eventTarget, eventType, eventDetail)
}

function getToolDataByToolDataUID(
toolDataUID: string,
element?: HTMLElement
): ToolSpecificToolData {
const toolStateManager = getViewportSpecificStateManager(element)
const toolData = toolStateManager.getToolStateByToolDataUID(toolDataUID)

return toolData
}

export {
getToolState,
addToolState,
getToolDataByToolDataUID,
removeToolState,
removeToolStateByToolDataUID,
getViewportSpecificStateManager,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ export default class BidirectionalTool extends BaseAnnotationTool {
viewUp: <Point3>[...viewUp],
FrameOfReferenceUID: viewport.getFrameOfReferenceUID(),
toolName: this.name,
label: '',
referencedImageId,
},
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export default class EllipticalRoiTool extends BaseAnnotationTool {
viewUp: <Point3>[...viewUp],
FrameOfReferenceUID: viewport.getFrameOfReferenceUID(),
referencedImageId,
label: '',
toolName: this.name,
},
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ class LengthTool extends BaseAnnotationTool {
viewUp: <Point3>[...viewUp],
FrameOfReferenceUID: viewport.getFrameOfReferenceUID(),
referencedImageId,
label: '',
toolName: this.name,
},
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export default class SUVPeakTool extends EllipticalRoiTool {
viewUp: <Point3>[...viewUp],
FrameOfReferenceUID: viewport.getFrameOfReferenceUID(),
referencedImageId,
label: '',
toolName: this.name,
},
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ export default class ProbeTool extends BaseAnnotationTool {
viewUp: <Point3>[...viewUp],
FrameOfReferenceUID: viewport.getFrameOfReferenceUID(),
referencedImageId,
label: '',
toolName: this.name,
},
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export default class RectangleRoiTool extends BaseAnnotationTool {
viewUp: <Point3>[...viewUp],
FrameOfReferenceUID: viewport.getFrameOfReferenceUID(),
referencedImageId,
label: '',
toolName: this.name,
},
data: {
Expand Down
10 changes: 9 additions & 1 deletion packages/cornerstone-tools/src/types/toolStateTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ type ToolSpecificToolData = {
* The FrameOfReferenceUID
*/
FrameOfReferenceUID: string
/**
* The registered name of the tool
*/
toolName: string
/**
* An optional property used when annotating on a slice in a StackViewport,
* or when annotating in a VolumeViewport on a viewPlane that corresponds to
Expand All @@ -40,7 +44,11 @@ type ToolSpecificToolData = {
/**
* The registered name of the tool
*/
toolName: string
label?: string
/**
* The registered name of the tool
*/
text?: string
/**
* VolumeUID of the volume that the tool was configured to work on.
*/
Expand Down

0 comments on commit fe7570d

Please sign in to comment.