Table of Contents

Core

This section needs a description

addTool

Parameters

  • apiTool
  • tool baseTool

addToolForElement

Parameters

  • element any
  • apiTool
  • tool baseTool

setToolOptions

Set the options object associated with a particular toolType and element

Parameters

  • toolType string Tool type identifier of the target options object
  • element HTMLElement Element of the target options object
  • options Object Options object to store at target

Returns void

setToolOptions

Parameters

setToolOptionsForElement

Parameters

Tool Modes

This section needs a description

setToolActive

Sets all tool's state, with the provided toolName, to 'active'. Active tools are rendered, respond to user input, and can create new data.

Parameters

Returns undefined

setToolActiveForElement

Sets a tool's state, with the provided toolName and element, to 'active'. Active tools are rendered, respond to user input, and can create new data.

Parameters

Examples

Setting a tool 'active' for a specific interaction type.

// Sets length tool to Active
setToolActiveForElement(element, 'Length', {
  mouseButtonMask: 1
}, ['Mouse'])

Setting a tool 'active' for all interaction types.

// Sets length tool to Active
setToolActiveForElement(element, 'Length', {
  mouseButtonMask: 1
})

Returns undefined

setToolPassive

Sets all tool's state, with the provided toolName, to 'passive'. Passive tools are rendered and respond to user input, but do not create new measurements or annotations.

Parameters

Returns undefined

setToolPassiveForElement

Sets a tool's state, with the provided toolName and element, to 'passive'. Passive tools are rendered and respond to user input, but do not create new measurements or annotations.

Parameters

Returns undefined

setToolEnabled

Sets all tool's state, with the provided toolName, to 'enabled'. Enabled tools are rendered, but do not respond to user input

Parameters

Returns undefined

setToolEnabledForElement

Sets a tool's state, with the provided toolName and element, to 'enabled'. Enabled tools are rendered, but do not respond to user input

Parameters

Returns undefined

setToolDisabled

Sets all tool's state, with the provided toolName, to 'disabled'. Disabled tools are not rendered, and do not respond to user input

Parameters

Returns undefined

setToolDisabledForElement

Sets a tool's state, with the provided toolName and element, to 'disabled'. Disabled tools are not rendered, and do not respond to user input

Parameters

Returns undefined

init

Merges the provided configuration with default values and returns a configured CornerstoneTools instance.

Parameters

Returns Object A configured CornerstoneTools instance with top level API members

setRadius

Sets the brush radius, account for global min/max radius

Parameters

  • radius any

setBrushColorMap

TODO: Should this be a init config property? Sets the brush color map to something other than the default

Parameters

  • colors Array An array of 4D [red, green, blue, alpha] arrays.

enabledElementCallback

enabledElementCallback - Element specific initilisation.

Parameters

  • enabledElement Object The element on which the module is
                                 being initialised.
    

onRegisterCallback

onRegisterCallback - Initialise the module when a new element is added.

registerModule

registerModule - register a module to the store.

Parameters

  • newModule Object The module to register.
  • name

removeToolForElement

Removes all tools from the target element with the provided name

Parameters

  • element any
  • toolName
  • tool baseTool

removeTool

Removes all tools from all enabled elements with the provided name

Parameters

  • toolName baseTool

addEnabledElement

Adds an enabledElement to our store.

Parameters

  • elementEnabledEvt Cornerstone#ElementEnabled

Cornerstone#ElementEnabled

Element Enabled event.

Type: Object

Properties

onImageRenderedBrushEventHandler

Used to redraw the brush label map data per render.

Parameters

_drawImageBitmap

Draws the ImageBitmap the canvas.

Parameters

  • evt Object description
  • imageBitmap
  • alwaysVisible

enable

These listeners are emitted in order, and can be cancelled/prevented from bubbling by any previous event.

  • mouseMove: used to update the [un]hover state of a tool (highlighting)
  • mouseDown: check to see if we are close to an existing annotation, grab it
  • mouseDownActivate: createNewMeasurement (usually)
  • mouseDrag: update measurement or apply strategy (wwwc)
  • mouseDoubleClick: usually a one-time apply specialty action
  • onImageRendered: redraw visible tool data

Parameters

  • element any

enable

These listeners are emitted in order, and can be cancelled/prevented from bubbling by any previous event.

  • tap:
  • touchStart: check to see if we are close to an existing annotation, grab it
  • touchDrag:
  • touchStartActive: createNewMeasurement (usually)
  • touchPress:
  • touchRotate:
  • doubleTap: usually a one-time apply specialty action
  • touchPinch:
  • onImageRendered: redraw visible tool data

Parameters

  • element any

mouseDown

MouseDown is called before MouseDownActivate. If MouseDown finds an existing tool to interact with, it can prevent the event from bubbling to MouseDownActivate.

TODO: Set that a tool is active to prevent multiple event fires TODO: Handles should trigger image update when released TODO: Handles should handle deleting out of bound data by setting

Parameters

  • evt any

mouseMove

This is mostly used to update the [un]hover state of a tool.

Parameters

  • evt any

onNewImageBrushEventHandler

Clears the brush imageBitmapCache, invaldates the data and calls for a re-render.

Parameters

removeEnabledElement

Removes an enabledElement from our store, and all associated tools that were added to it.

Parameters

  • elementDisabledEvt Cornerstone#ElementDisabled

Cornerstone#ElementDisabled

Element Disabled event.

Type: Object

Properties

createNewMeasurement

Create the measurement data for this tool with the end handle activated

Parameters

  • evt any

pointNearTool

Parameters

  • element any
  • data any
  • coords any

renderToolData

Parameters

  • evt any

addNewMeasurement

Parameters

  • evt any
  • interactionType any

createNewMeasurement

Create the measurement data for this tool with the end handle activated

Parameters

  • eventData any

pointNearTool

Parameters

  • element any
  • data any
  • coords any

renderToolData

Parameters

  • evt any

createNewMeasurement

Create the measurement data for this tool with the end handle activated

Parameters

  • eventData any

pointNearTool

Parameters

  • element any
  • data any
  • coords any

renderToolData

Parameters

  • evt any

createNewMeasurement

Parameters

  • evt type description

Returns type description

pointNearTool

Parameters

  • element any
  • data any
  • coords any

Returns boolean If the point is near the tool

distanceFromPoint

Parameters

  • element any
  • data any
  • coords any

Returns number the distance in px from the provided coordinates to the closest rendered portion of the annotation. -1 if the distance cannot be calculated.

renderToolData

Parameters

  • evt any

mouseMoveCallback

Event handler for MOUSE_MOVE event.

Parameters

handleSelectedCallback

Custom callback for when a handle is selected.

Parameters

  • evt any
  • handle any The selected handle.
  • data

toolSelectedCallback

Custom callback for when a tool is selected.

Parameters

  • evt any
  • data
  • toolState
  • tool any The selected tool.

defaultStrategy

Default strategy will pick the exactly point of mouse/touch interact and display the probe data.

Parameters

  • evt
  • config

defaultStrategy

The default strategy keeps the target location fixed on the page as we zoom in/out.

Parameters

  • evt any
  • null any { invert, maxScale, minScale }
    • null.invert
    • null.maxScale
    • null.minScale

minimalStrategy

Minimal strategy will position a circle and use the center of the circle to calculate and display probe data.

Parameters

  • evt
  • config

applyActiveStrategy

Parameters

  • evt any

Returns any Any

_applyMixins

Applys the requested mixins to the class.

Parameters

  • mixins
  • mixinArray Array An array of mixin names (strings).

mergeOptions

Merges provided options with existing options

Parameters

  • options

clearOptions

Clears the tools options; preserves internal options, but with undefined values.

internalOptions

Internal options that "MUST" be in the tool's options if certain conditions are met. Method is also good for inspecting options that can be used to change tool behavior.

Example implementation:

postMouseDownCallback(evt) { return false; }

Callback that takes priority if the tool is active, before TOUCH_START events are processed. Does nothing by default.

Parameters

  • evt type

Returns boolean consumedEvent - True if function consumed the event.

Example implementation:

preTouchStartCallback(evt) { return false; }

Callback that is called if the tool is active, after TOUCH_START events are processed. Does nothing by default.

Parameters

  • evt type

Returns boolean consumedEvent - True if function consumed the event.

Example implementation:

postTouchStartCallback(evt) { return false; }

Callback that takes priority if the tool is active, before MOUSE_DOWN events are processed. Does nothing by default.

Parameters

  • evt type

Returns boolean consumedEvent - True if function consumed the event.

Example implementation:

preMouseDownCallback(evt) { return false; }

Callback that is called if the tool is active, after MOUSE_DOWN events are processed. Does nothing by default.

Parameters

  • evt type

Returns boolean consumedEvent - True if function consumed the event.

passiveCallback

If one attempts to change mode to 'passive', redirect the tool to 'disabled'.

Parameters

  • element type The element on which the tool resides.

passiveCallback

If one attempts to change mode to 'passive', redirect the tool to 'disabled'.

Parameters

  • element type The element on which the tool resides.

enabledCallback

If one attempts to turn the tool 'enabled', redirect the tool to 'active'.

Parameters

  • element type The element on which the tool resides.

activeCallback

If one attempts to change mode to 'active', redirect the tool to 'enabled'.

Parameters

  • element type The element on which the tool resides.

createNewMeasurement

Create the measurement data for this tool with the end handle activated

Parameters

  • eventData any

pointNearTool

Parameters

  • element any
  • data any
  • coords any

renderToolData

Parameters

  • evt any

createNewMeasurement

Create the measurement data for this tool

Parameters

  • eventData any

pointNearTool

Parameters

  • element any
  • data any
  • coords any

Returns Boolean

distanceFromPoint

Parameters

  • element any
  • data any
  • coords any

Returns number the distance in px from the provided coordinates to the closest rendered portion of the annotation. -1 if the distance cannot be calculated.

distanceFromPointCanvas

Parameters

  • element any
  • data any
  • coords any

Returns number the distance in canvas units from the provided coordinates to the closest rendered portion of the annotation. -1 if the distance cannot be calculated.

renderToolData

Parameters

  • evt any

addNewMeasurement

Event handler for called by the mouseDownActivate event, if tool is active and the event is not caught by mouseDownCallback.

Parameters

  • evt Object The event.
  • interactionType

preMouseDownCallback

Active mouse down callback that takes priority if the user is attempting to insert or delete a handle with ctrl + click.

Parameters

handleSelectedCallback

Custom callback for when a handle is selected.

Parameters

_drawingMouseMoveCallback

Event handler for MOUSE_MOVE during drawing event loop.

Parameters

_drawingMouseDownCallback

Event handler for MOUSE_DOWN during drawing event loop.

Parameters

_editMouseDragCallback

Event handler for MOUSE_DRAG during handle drag event loop.

Parameters

_editMouseUpCallback

Event handler for MOUSE_UP during handle drag event loop.

Parameters

_dropHandle

Places a handle of the freehand tool if the new location is valid. If the new location is invalid the handle snaps back to its previous position.

Parameters

  • eventData Object Data object associated with the event.
  • toolState Object The data associated with the freehand tool.

_checkHandlesPolygonMode

Returns true if the proposed location of a new handle is invalid (in polygon mode).

Parameters

  • data Object data object associated with the tool.

Returns Boolean

insertOrDelete

Inserts or deletes a point from a freehand tool.

Parameters

  • evt
  • nearby Object Object containing information about a nearby handle.
  • e Object The event.

deletePoint

Deletes a point from a freehand tool.

Parameters

  • eventData Object The data object associated with the event.
  • deleteInfo Object Object containing information about which point to delete.

insertPoint

Inserts a new point into a freehand tool.

Parameters

  • eventData Object The data object associated with the event.
  • insertInfo Object Object containing information about where to insert the point.

getInsertionIndex

Gets the handle index of a tool in which to insert the new point.

Parameters

  • insertInfo Object Object containing information about where to insert the point.

constructor

Constructs a linefinder with the eventdata

Parameters

  • eventData Object Data object associated with the event.

findLine

Looks for lines near the mouse cursor.

Returns ClickedLineData

findTool

Looks for tools near the mouse cursor.

Returns ClickedLineData

_nearestHandleToPointAllTools

Finds the nearest handle to the mouse cursor for all tools.

Returns Object closestHandle - The handle closest to the point.

_nearestHandleToPoint

Finds the nearest handle to the mouse cursor for a specific tool.

Parameters

  • toolIndex Number The index of the particular freehand tool.

Returns Object An object containing information about the closest handle.

_getCloseLinesInTool

Finds all the lines close to the mouse point for a particular tool.

Parameters

  • toolIndex Number The index of the particular freehand tool.

Returns Object An array of lines close to the mouse point.

_findCorrectLine

Finds the line the user clicked on from an array of close lines.

Parameters

  • toolIndex Number The index of the particular freehand tool.
  • closeLines Object An array of lines close to the mouse point.

Returns (ClickedLineData | null) An instance of ClickedLineData containing information about the line, or null if no line is correct.

_pointProjectsToLineSegment

Returns true if the mouse point projects onto the line segment.

Parameters

  • toolIndex Number The index of the particular freehand tool.
  • handleIndexArray Object An array of indicies corresponding to the line segment.

Returns Boolean True if the mouse point projects onto the line segment

_getLineOriginToMouseAsVector

Constructs a vector from the direction and magnitude of the line from the the line origin to the mouse cursor.

Parameters

  • p Object An array of two points respresenting the line segment.

Returns Object An array containing the x and y components of the vector.

_distanceOfPointfromLine

Calculates the perpendicular distance of the mouse cursor from a line segment.

Parameters

Returns Number The perpendicular distance of the mouse cursor from the line segment.

getCanvasPointsFromHandles

Returns the canvas positions from the handle's pixel positions.

Parameters

Returns Object An array contsining the handle positions in canvas coordinates.

getLineAsVector

Converts a line segment to a vector.

Parameters

  • p Object An array of two points respresenting the line segment.

Returns Object An array containing the x and y components of the vector, as well as a magnitude property.

getNextHandleIndex

Gets the next handl index from a cyclical array of points.

Parameters

  • currentIndex Number The current index.
  • length Number The number of handles in the polygon.

Returns Number The index of the next handle.

ClickedLineData

Type: Object

Properties

  • toolIndex Number ID of the tool that the line corresponds to.
  • handleIndexArray Object An array of the handle indicies that correspond to the line segment.

freehandArea

Calculates the area of a freehand tool polygon.

Parameters

  • dataHandles Object data object associated with the tool.
  • scaling Object Area scaling of image.

Returns Number The area of the polygon.

calculateFreehandStatistics

Calculates the statistics of all the points within the freehand object.

Parameters

  • sp Object An array of the pixel data.
  • boundingBox Object Rectangular box enclosing the polygon.
  • dataHandles Object Data object associated with the tool.

Returns Object statisticsObj - Object containing the derived statistics.

getSum

Calculates the sum, squared sum and count of all pixels within the polygon.

Parameters

  • sp Object An array of the pixel data.
  • boundingBox Object Rectangular box enclosing the polygon.
  • dataHandles Object Data object associated with the tool.

Returns Object sum - Object containing the sum, squared sum and pixel count.

sumPointIfInFreehand

Adds the pixel to the workingSum if it is within the polygon.

Parameters

  • dataHandles Object Data object associated with the tool.
  • point Object The pixel coordinates.
  • workingSum Object The working sum, squared sum and pixel count.
  • pixelValue Object The pixel value.

pointInFreehand

Calculates if "point" is inside the polygon defined by dataHandles by counting the number of times a ray originating from "point" crosses the edges of the polygon. Odd === inside, Even === outside. The bool "inROI" flips every time the ray originating from location and pointing to the right crosses a linesegment.

Parameters

  • dataHandles
  • location

isEnclosedY

Returns true if the y-position yp is enclosed within y-positions y1 and y2.

Parameters

  • yp Number The y position of point p.
  • y1 Number The y position of point 1.
  • y2 Number The y position of point 2.

Returns Boolean True if the y-position yp is enclosed within y-positions y1 and y2.

isLineRightOfPoint

Returns true if the line segment is to the right of the point.

Parameters

  • point Object The point being queried.
  • lp1 Object The first point of the line segment.
  • lp2 Object The second point of the line segment.

Returns Boolean True if the line is to the right of the point.

lineSegmentAtPoint

Returns the y value of the line segment at the x value of the point.

Parameters

  • point Object The point being queried.
  • lp1 Object The first point of the line segment.
  • lp2 Object The second point of the line segment.

Returns Object An object containing the y value as well as the gradient of the line segment.

rayFromPointCrosssesLine

Returns true if a rightwards ray originating from the point crosses the line defined by handleI and handleJ.

Parameters

  • point Object The point being queried.
  • handleI Object The first handle of the line segment.
  • handleJ Object The second handle of the line segment.

Returns Boolean True if a rightwards ray originating from the point crosses the line defined by handleI and handleJ.

newHandle

Orientation algoritm to determine if two lines cross. Credit and details: geeksforgeeks.org/check-if-two-given-line-segments-intersect/

Parameters

  • candidateHandle
  • dataHandles

newHandle

Determines whether a new handle causes an intersection of the lines of the polygon.

Parameters

  • candidateHandle Object The new handle to check.
  • dataHandles Object data object associated with the tool.

Returns Boolean Whether the new line intersects with any other lines of the polygon.

end

Checks if the last line of a polygon will intersect the other lines of the polgyon.

Parameters

  • dataHandles Object data object associated with the tool.

Returns Boolean Whether the last line intersects with any other lines of the polygon.

modify

Checks whether the modification of a handle's position causes intersection of the lines of the polygon

Parameters

  • dataHandles Object data object associated with the tool.
  • modifiedHandleId Number The id of the handle being modified.

Returns Boolean Whether the modfication causes any intersections.

doesIntersectOtherLines

Checks whether the line (p1,q1) intersects any of the other lines in the polygon.

Parameters

  • dataHandles Object data object associated with the tool.
  • p1 Object Coordinates of the start of the line.
  • q1 Object Coordinates of the end of the line.
  • ignoredHandleIds Object Ids of handles to ignore (i.e. lines that share a vertex with the line being tested).

Returns Boolean Whether the line intersects any of the other lines in the polygon.

doesIntersect

Checks whether the line (p1,q1) intersects the line (p2,q2) via an orientation algorithm.

Parameters

  • p1 Object Coordinates of the start of the line 2.
  • q1 Object Coordinates of the end of the line 2.
  • p2
  • q2

Returns Boolean Whether lines (p1,q1) and (p2,q2) intersect.

orientation

Checks the orientation of 3 points.

Parameters

Returns Number 0: Colinear, 1: Clockwise, 2: Anticlockwise

onSegment

Checks if point q lines on the segment (p,r).

Parameters

Returns Boolean If q lies on line segment (p,r).

renderToolData

Event handler for IMAGE_RENDERED event.

Parameters

preMouseDownCallback

Event handler for MOUSE_DOWN.

Parameters

activeMouseDragCallback

Event handler for MOUSE_DRAG during the active loop.

Parameters

activeMouseUpCallback

Event handler for MOUSE_UP during the active loop.

Parameters

newImageCallback

Event handler for NEW_IMAGE event.

Parameters

enabledCallback

Event handler for switching mode to enabled.

Parameters

passiveCallback

Event handler for switching mode to passive.

Parameters

disabledCallback

Event handler for switching mode to disabled.

Parameters

getDefaultFreehandSculpterMouseToolConfiguration

Returns the default freehandSculpterMouseTool configuration.

Returns Object The default configuration object.

FreehandHandleData

Type: Object

Properties

  • x Number The x position.
  • y Number The y position.
  • highlight Boolean Whether the handle should be rendered as the highlighted color.
  • active Boolean Whether the handle is active.
  • lines Object An array of lines associated with the handle.

changeTextCallback

This function is a callback to be overwriten in order to provide the wante feature modal, overlay, popup or any kind of interaction with the user to be able to update the text marker label.

Parameters

  • data
  • eventData
  • doneChangingTextCallback

createNewMeasurement

Create the measurement data for this tool with the end handle activated

Parameters

  • eventData any

pointNearTool

Parameters

  • element any
  • data any
  • coords any

renderToolData

Parameters

  • evt any

_drawZoomedElement

Creates a cornerstone enabled element, and renders the target image at the desired magnification level using it.

Parameters

  • evt any

_removeZoomElement

Removes the canvas and associated enabled element that's used to render the zoomed image.

_createMagnificationCanvas

The canvas used to render the zoomed image. It will be displayed and clipped inside the magnifying glass frame/element.

Parameters

  • element any

_destroyMagnificationCanvas

Parameters

  • evt any

createNewMeasurement

Create the measurement data for this tool with the end handle activated

Parameters

  • eventData any

pointNearTool

Parameters

  • element any
  • data any
  • coords any

renderToolData

Parameters

  • evt any

createNewMeasurement

Create the measurement data for this tool with the end handle activated

Parameters

  • eventData any

pointNearTool

Parameters

  • element any
  • data any
  • coords any

renderToolData

Parameters

  • evt any

angleBetweenPoints

Parameters

  • p0
  • p1
  • p2

computeScaleBounds

Computes the max bound for scales on the image

Parameters

  • canvasSize
  • horizontalReduction
  • verticalReduction

drawVerticalScalebarIntervals

Parameters

  • context
  • element
  • imageAttributes

basicLevelingStrategy

Here we normalize the ww/wc adjustments so the same number of on screen pixels adjusts the same percentage of the dynamic range of the image. This is needed to provide consistency for the ww/wc tool regardless of the dynamic range (e.g. an 8 bit image will feel the same as a 16 bit image would)

Parameters

  • evt
  • $1 Object
    • $1.orientation
  • eventData

_startOutliningRegion

Sets the start handle point and claims the eventDispatcher event

Parameters

  • evt any

Returns Boolean True

_setHandlesAndUpdate

This function will update the handles and updateImage to force re-draw

Parameters

  • evt

_applyStrategy

Event handler for MOUSE_UP during handle drag event loop.

Parameters

_resetHandles

Sets the start and end handle points to empty objects

isEmptyObject

Parameters

  • obj any

applyWWWCRegion

Calculates the minimum and maximum value in the given pixel array

Parameters

  • evt any
  • config any

calculateMinMaxMean

Calculates the minimum, maximum, and mean value in the given pixel array

Parameters

  • storedPixelLuminanceData any
  • globalMin any
  • globalMax any

touchPinchCallback

Parameters

  • evt any

mouseWheelCallback

Parameters

  • evt any

convertToVector3

Convert an Array to a cornerstoneMath.Vector3

Parameters

  • arrayOrVector3 (Array | cornerstoneMath.Vector3) Input array or Vector3

Returns cornerstoneMath.Vector3

renderBrush

Called by the event dispatcher to render the image.

Parameters

renderBrush

Helper function for rendering the brush.

Parameters

_paint

Paints the data to the canvas.

Parameters

  • eventData Object The data object associated with the event.

mouseDragCallback

Event handler for MOUSE_DRAG event.

Parameters

preMouseDownCallback

Event handler for MOUSE_DOWN event.

Parameters

_startPainting

Initialise painting with baseBrushTool

Parameters

mouseMoveCallback

Event handler for MOUSE_MOVE event.

Parameters

passiveCallback

Event handler for switching mode to passive;

Parameters

renderToolData

Used to redraw the tool's annotation data per render.

Parameters

_getBrushColor

Get the draw color (segmentation) of the tool.

Parameters

  • drawId Number The id of the color (segmentation) to switch to.

_drawingMouseUpCallback

Event handler for MOUSE_UP during the drawing event loop.

Parameters

_startListeningForMouseUp

Adds modify loop event listeners.

Parameters

  • element Object The viewport element to add event listeners to.

_stopListeningForMouseUp

Adds modify loop event listeners.

Parameters

  • element Object The viewport element to add event listeners to.

nextSegmentation

Switches to the next segmentation color.

previousSegmentation

Switches to the previous segmentation color.

increaseBrushSize

Increases the brush size

decreaseBrushSize

Decreases the brush size

showSegmentationOnElement

Displays a segmentation on the element.

Parameters

  • segIndex Number The index of the segmentation.
  • enabledElement String The enabledElement on which to display.

hideSegmentationOnElement

Hides a segmentation on an element.

Parameters

  • segIndex Number The index of the segmentation.

showAllSegmentationsOnElement

Displays all segmentations on an element.

hideAllSegmentationsOnElement

Hides all segmentations on an element.

getNumberOfColors

Returns the number of colors in the colormap.

Returns Number The number of colors in the color map.

getReferencedToolDataName

Returns the toolData type assoicated with this type of tool.

Returns String The number of colors in the color map.

setContextToDisplayFontSize

Sets the canvas context transformation matrix so it is scaled to show text more cleanly even if the image is scaled up. See https://github.com/cornerstonejs/cornerstoneTools/wiki/DrawingText for more information

Parameters

  • enabledElement
  • context
  • fontSize

Returns {fontSize: number, lineHeight: number, fontScale: number}

triggerEvent

Trigger a CustomEvent

Parameters

  • el EventTarget The element or EventTarget to trigger the event upon
  • type String The event type name
  • detail (Object | null) =null The event data to be sent (optional, default null)

Returns Boolean The return value is false if at least one event listener called preventDefault(). Otherwise it returns true.

makeUnselectable

A helper function to make an element (and its content) being non selectable.

Parameters

  • element {HTMLElement} The element to make unselectable
  • ignorePointerEvents {Boolean} true to make this element also ignore events (e.g. mouse click), false otherwise

Returns void

Meta

  • deprecated: Use drawing.js:drawEllipse()

drawCircle

Parameters

  • context
  • start
  • color
  • lineWidth

Meta

  • deprecated: Use drawing.js:drawCircle()

drawCircle

Draw a circle with given center and radius.

Parameters

  • context CanvasRenderingContext2D
  • element HTMLElement The DOM Element to draw on
  • center Object { x, y } in either pixel or canvas coordinates.
  • radius number The circle's radius in canvas units.
  • options Object See path
  • coordSystem String Can be "pixel" (default) or "canvas". The coordinate
    system of the points passed in to the function. If "pixel" then cornerstone.pixelToCanvas
    is used to transform the points from pixel to canvas coordinates. (optional, default `'pixel'`)
    

getPlayClipTimeouts

[private] Turns a Frame Time Vector (0018,1065) array into a normalized array of timeouts. Each element ... of the resulting array represents the amount of time each frame will remain on the screen.

Parameters

  • vector Array A Frame Time Vector (0018,1065) as specified in section C.7.6.5.1.2 of DICOM standard.
  • speed Number A speed factor which will be applied to each element of the resulting array.

Returns Array An array with timeouts for each animation frame.

stopClipWithData

[private] Performs the heavy lifting of stopping an ongoing animation.

Parameters

  • playClipData Object The data from playClip that needs to be stopped.

Returns any void

triggerStopEvent

[private] Trigger playClip tool stop event.

Parameters

  • element

Returns any void

playClip

Starts playing a clip or adjusts the frame rate of an already playing clip. framesPerSecond is optional and defaults to 30 if not specified. A negative framesPerSecond will play the clip in reverse. The element must be a stack of images

Parameters

  • element
  • framesPerSecond

stopClip

Stops an already playing clip.

  • @param element

Parameters

  • element

getToolOptions

Retrieve the options object associated with a particular toolType and element

Parameters

  • toolType string Tool type identifier of the target options object
  • element HTMLElement Element of the target options object

Returns Object Target options object (empty if not yet set)

clearToolOptions

Clear the options object associated with a particular toolType and element

Parameters

  • toolType string Tool type identifier of the target options object
  • element HTMLElement Element of the target options object

Returns void

clearToolOptionsByToolType

Clear the options objects associated with a particular toolType

Parameters

  • toolType string Tool type identifier of the target options objects

Returns void

clearToolOptionsByElement

Clear the options objects associated with a particular element

Parameters

  • element HTMLElement Element of the target options objects

Returns void

getNewContext

Create a new context object for the given canvas and set the transform to the identity transform.

Parameters

Returns CanvasRenderingContext2D

FillStyle

A color, gradient or pattern to use inside shapes.

Type: (String | CanvasGradient | CanvasPattern)

StrokeStyle

A color, gradient or pattern to use for the lines around shapes.

Type: (String | CanvasGradient | CanvasPattern)

ContextFn

Type: Function

Parameters

draw

This function manages the save/restore pattern for working in a new context state stack. The parameter fn is passed the context and can execute any API calls in a clean stack.

Parameters

path

This function manages the beginPath/stroke pattern for working with path objects.

Parameters

  • context CanvasRenderingContext2D
  • options Object
    • options.color StrokeStyle The stroke style of the path.
    • options.lineWidth Number The width of lines in the path. If null, no line width is set.
      If undefined then toolStyle.getToolWidth() is set.
      
    • options.fillStyle FillStyle The style to fill the path with. If undefined then no filling is done.
    • options.lineDash Array<Number> The dash pattern
      to use on the lines.
      
  • fn ContextFn A drawing function to execute with the provided stroke pattern.

setShadow

Set the shadow properties of the context. Each property is set on the context object if defined, otherwise a default value is set.

Parameters

drawLine

Draw a line between start and end.

Parameters

  • context CanvasRenderingContext2D
  • element HTMLElement The DOM Element to draw on
  • start Object `{ x, y } in either pixel or canvas coordinates.
  • end Object { x, y } in either pixel or canvas coordinates.
  • options Object See path
  • coordSystem String Can be "pixel" (default) or "canvas". The coordinate
    system of the points passed in to the function. If "pixel" then cornerstone.pixelToCanvas
    is used to transform the points from pixel to canvas coordinates. (optional, default `'pixel'`)
    

drawLines

Draw multiple lines.

Parameters

  • context CanvasRenderingContext2D
  • element HTMLElement The DOM Element to draw on
  • lines Array<Object> [{ start: {x, y}, end: { x, y }] An array of start, end pairs.
    Each point is `{ x, y }` in either pixel or canvas coordinates.
    
  • options Object See path
  • coordSystem String Can be "pixel" (default) or "canvas". The coordinate
    system of the points passed in to the function. If "pixel" then cornerstone.pixelToCanvas
    is used to transform the points from pixel to canvas coordinates. (optional, default `'pixel'`)
    

drawJoinedLines

Draw a series of joined lines, starting at start and then going to each point in points.

Parameters

  • context CanvasRenderingContext2D
  • element HTMLElement The DOM Element to draw on
  • start Object { x, y } in either pixel or canvas coordinates.
  • points Array<Object> [{ x, y }] An array of points in either pixel or canvas coordinates.
  • options Object See path
  • coordSystem String Can be "pixel" (default) or "canvas". The coordinate
    system of the points passed in to the function. If "pixel" then cornerstone.pixelToCanvas
    is used to transform the points from pixel to canvas coordinates. (optional, default `'pixel'`)
    

drawEllipse

Draw an ellipse within the bounding box defined by corner1 and corner2.

Parameters

  • context CanvasRenderingContext2D
  • element HTMLElement The DOM Element to draw on
  • corner1 Object { x, y } in either pixel or canvas coordinates.
  • corner2 Object { x, y } in either pixel or canvas coordinates.
  • options Object See path
  • coordSystem String Can be "pixel" (default) or "canvas". The coordinate
    system of the points passed in to the function. If "pixel" then cornerstone.pixelToCanvas
    is used to transform the points from pixel to canvas coordinates. (optional, default `'pixel'`)
    

drawRect

Draw a rectangle defined by corner1 and corner2.

Parameters

  • context CanvasRenderingContext2D
  • element HTMLElement The DOM Element to draw on
  • corner1 Object { x, y } in either pixel or canvas coordinates.
  • corner2 Object { x, y } in either pixel or canvas coordinates.
  • options Object See path
  • coordSystem String Can be "pixel" (default) or "canvas". The coordinate
    system of the points passed in to the function. If "pixel" then cornerstone.pixelToCanvas
    is used to transform the points from pixel to canvas coordinates. (optional, default `'pixel'`)
    

fillBox

Draw a filled rectangle defined by boundingBox using the style defined by fillStyle.

Parameters

fillTextLines

Draw multiple lines of text within a bounding box.

Parameters

  • context CanvasRenderingContext2D
  • boundingBox Object { left, top } in canvas coordinates. Only the top-left corner is specified, as the text will take up as much space as it needs.
  • textLines Array<String> The text to be displayed.
  • fillStyle FillStyle The fillStyle to apply to the text.
  • padding Number The amount of padding above/below each line in canvas units. Note this gives an inter-line spacing of 2*padding.

results matching ""

    No results matching ""