- setContextToDisplayFontSize
- triggerEvent
- convertToVector3
- makeUnselectable
- playClip
- playClip
- stopClip
- stopClip
- getPlayClipTimeouts
- stopClipWithData
- triggerStopEvent
- createNewMeasurement
- pointNearTool
- pointNearHandle
- pointNearHandleAllTools
- mouseDownActivateCallback
- startDrawing
- addPointPencilMode
- addPoint
- endDrawing
- mouseDownActive
- mouseDownCallback
- mouseDownCallback
- mouseDownCallback
- mouseMoveCallback
- mouseMoveActive
- checkInvalidHandleLocation
- checkHandlesPencilMode
- checkHandlesPolygonMode
- invalidHandlePencilMode
- mouseDragCallback
- mouseUpCallback
- mouseUpCallback
- mouseDownPassive
- modifyObject
- modifyTextBox
- modifyHandle
- mouseHover
- keyDownCallback
- keyUpCallback
- getMouseLocation
- numberWithCommas
- onImageRendered
- enable
- disable
- activate
- deactivate
- removeEventListeners
- getConfiguration
- setConfiguration
- dragObject
- dragTextBox
- dragHandle
- dropObject
- dropTextbox
- dropHandle
- toolName
- toolName
- insertOrDelete
- deletePoint
- insertPoint
- getInsertionIndex
- ClickedLineData
- constructor
- findLine
- _nearestHandleToPointAllTools
- _nearestHandleToPoint
- _getCloseLinesInTool
- _findCorrectLine
- _pointProjectsToLineSegment
- _getLineOriginToMouseAsVector
- _distanceOfPointfromLine
- getCanvasPointsFromHandles
- getLineAsVector
- getNextHandleIndex
- freeHandArea
- calculateFreehandStatistics
- getSum
- sumPointIfInFreehand
- pointInFreehand
- isEnclosedY
- isLineRightOfPoint
- lineSegmentAtPoint
- rayFromPointCrosssesLine
- newHandle
- newHandle
- end
- modify
- doesIntersectOtherLines
- doesIntersect
- orientation
- onSegment
- FreehandHandleData
- FreehandHandleData
- dragCallback
- dragCallback
- createMagnificationCanvas
- removeMagnificationCanvas
- calculateMinMaxMean
- applyWWWCRegion
- recordStartPoint
- getToolOptions
- setToolOptions
- clearToolOptions
- clearToolOptionsByToolName
- clearToolOptionsByToolType
- clearToolOptionsByElement
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}
Trigger a CustomEvent
Parameters
el
EventTarget The element or EventTarget to trigger the event upontype
String The event type namedetail
(Object | null) =null The event data to be sent (optional, defaultnull
)
Returns Boolean The return value is false if at least one event listener called preventDefault(). Otherwise it returns true.
Convert an Array to a cornerstoneMath.Vector3
Parameters
arrayOrVector3
(Array | cornerstoneMath.Vector3) Input array or Vector3
Returns cornerstoneMath.Vector3
A helper function to make an element (and its content) being non selectable.
Parameters
element
{HTMLElement} The element to make unselectableignorePointerEvents
{Boolean} true to make this element also ignore events (e.g. mouse click), false otherwise
Returns void
Starts playing a clip of different time series of the same image 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 have time series
Parameters
element
framesPerSecond
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
Stops an already playing clip.
- @param element
Parameters
element
Stops an already playing clip.
- @param element
Parameters
element
[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.
[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
[private] Trigger playClip tool stop event.
Parameters
element
Returns any void
Initialises a new freehand data object
Returns Object measurementData - data object
Returns true if the mouse cursor is near a handle
Parameters
Returns Boolean
Returns a handle of a particular tool if it is close to the mouse cursor
Parameters
Returns (Number | Object | Boolean)
Returns a handle if it is close to the mouse cursor (all tools)
Parameters
eventData
Object data object associated with an event.
Returns Object
Event handler for MOUSE_DOWN_ACTIVATE event, if tool is active and the event is not caught by mouseDownCallback
Parameters
e
Object The event.
Begining of drawing loop when tool is active and a click event happens far from existing handles.
Parameters
eventData
Object data object associated with an event.
If in pencilMode, check the mouse position is farther than the minimum distance between points, then add a point.
Parameters
eventData
Object Data object associated with an event.dataHandles
Object Data object associated with the tool.
Adds a point on mouse click in polygon mode.
Parameters
eventData
Object data object associated with an event.
Ends the active drawing loop and completes the polygon.
Parameters
eventData
Object data object associated with an event.handleNearby
Object the handle nearest to the mouse cursor.
If in pencilMode, check the mouse position is farther than the minimum distance between points, then add a point.
Parameters
e
toolData
currentTool
eventData
Object data object associated with an event.dataHandles
Object data object associated with the tool.
Event handler for MOUSE_DOWN event.
Parameters
e
Object The event.
Draw the magnifying glass on mouseDown, and begin tracking mouse movements
Parameters
e
Records the start point and attaches the drag event handler
Parameters
e
Event handler for MOUSE_MOVE event.
Parameters
e
Object The event.
Event handler called by mouseMoveCallback when the tool is currently active.
Parameters
eventData
Object data object associated with an event.toolData
Object data object associated with the freehand tool.
Returns true if the proposed location of a new handle is invalid.
Parameters
data
Object data object associated with the tool.
Returns Boolean
Returns true if the proposed location of a new handle is invalid (in pencilMode).
Parameters
data
Object data object associated with the tool.
Returns Boolean
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
Returns true if the mouse position is far enough from previous points (in pencilMode).
Parameters
data
Object data object associated with the tool.mousePoint
Object the position of the mouse cursor.
Returns Boolean
Event handler for MOUSE_DRAG event.
Parameters
e
Object The event.
Event handler for MOUSE_UP event.
Parameters
e
Object The event.
Remove the magnifying glass when the mouse event ends
Parameters
e
Event handler called by mouseDownCallback when the tool is currently deactive.
Parameters
e
Object The event.
Event handler called by mouseDownPassive which modifies a tool's data.
Parameters
Event handler called by mouseDownPassive which modifies a tool's textBox.
Parameters
element
Object The element associated with the event.nearby
Object Object containing information about a nearby handle.
Event handler called by mouseDownPassive which modifies a tool's handle.
Parameters
element
Object The element associated with the event.nearby
Object Object containing information about a nearby handle.toolData
Object The data associated with the tool.
Activates a particular tool when the mouseCursor is near one if it's handles or it's textBox.
Parameters
eventData
Object The data assoicated with the event.toolData
Object The data associated with the tool.
Event handler for KEY_DOWN event.
Parameters
e
Object The event.
Event handler for KEY_UP event.
Parameters
e
Object The event.
Gets the current mouse location and stores it in the configuration object.
Parameters
eventData
Object The data assoicated with the event.
Adds commas as thousand seperators to a Number to increase readability.
Parameters
Returns String A string literal representaton of the number with commas seperating the thousands.
Event handler for IMAGE_RENDERED event.
Parameters
e
Object The event.
Attaches event listeners to the element such that is is visible.
Parameters
element
Object The viewport element to attach event listeners to.
Disables the reference line tool for the given element.
Parameters
element
Object The viewport element to attach event listeners to.
Attaches event listeners to the element such that is is visible, modifiable, and new data can be created.
Parameters
element
Object The viewport element to attach event listeners to.mouseButtonMask
Attaches event listeners to the element such that is is visible and modifiable.
Parameters
element
Object The viewport element to attach event listeners to.mouseButtonMask
Removes event listeners from the element.
Parameters
element
Object The viewport element to remove event listeners from.
Get the configuation object for the freehand tool.
Returns Object configuration - The freehand tool's configuration object.
Set the configuation object for the freehand tool.
Parameters
config
Object The configuration object to set the freehand tool's configuration.
Moves a part of the freehand tool whilst it is dragged by the mouse.
Parameters
currentHandle
Object The handle being dragged.data
Object The data associated with the freehand tool being modified.
Parameters
currentHandle
data
Meta
- author: JamesAPetts
Moves a freehand tool's textBox whilst it is dragged by the mouse.
Parameters
currentHandle
Object The handle being dragged.
Moves a handle of the freehand tool whilst it is dragged by the mouse.
Parameters
currentHandle
Object The handle being dragged.data
Object The data associated with the freehand tool being modified.
Places part of the freehand tool when the mouse button is released.
Parameters
Parameters
e
toolData
Meta
- author: JamesAPetts
Places a freehand tool's textBox.
Parameters
eventData
Object Data object associated with the event.toolData
Object The data associated with the freehand tool.
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.toolData
Object The data associated with the freehand tool.
Type: string
Meta
- author: JamesAPetts
Type: string
Meta
- author: JamesAPetts
Inserts or deletes a point from a freehand tool.
Parameters
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.
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.
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.
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.
Constructs a linefinder with the eventdata
Parameters
eventData
Object Data object associated with the event.
Looks for lines near the mouse cursor.
Returns ClickedLineData
Finds the nearest handle to the mouse cursor for all tools.
Returns Object closestHandle - The handle closest to the point.
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.
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.
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.
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
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.
Calculates the perpendicular distance of the mouse cursor from a line segment.
Parameters
handle1
FreehandHandleData The first handle.handle2
FreehandHandleData The first handle.
Returns Number The perpendicular distance of the mouse cursor from the line segment.
Returns the canvas positions from the handle's pixel positions.
Parameters
handle1
FreehandHandleData The first handle.handle2
FreehandHandleData The second handle.element
Object The element on which the handles reside.
Returns Object An array contsining the handle positions in canvas coordinates.
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.
Gets the next handl index from a cyclical array of points.
Parameters
Returns Number The index of the next handle.
Parameters
dataHandles
scaling
Meta
- author: JamesAPetts
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.
Parameters
sp
boundingBox
dataHandles
Meta
- author: JamesAPetts
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.
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.
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
Meta
- author: JamesAPetts
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.
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.
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.
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.
Orientation algoritm to determine if two lines cross. Credit and details: geeksforgeeks.org/check-if-two-given-line-segments-intersect/
Parameters
candidateHandle
dataHandles
Meta
- author: JamesAPetts
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.
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.
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.
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.
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.
Checks the orientation of 3 points.
Parameters
Returns Number 0: Colinear, 1: Clockwise, 2: Anticlockwise
Checks if point q lines on the segment (p,r).
Parameters
Returns Boolean If q lies on line segment (p,r).
Parameters
position
highlight
(optional, defaulttrue
)active
(optional, defaulttrue
)
Meta
- author: JamesAPetts
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.
Drag callback is triggered by both the touch and mouse magnify tools
Parameters
e
Draws the rectangular region while the touch or mouse event drag occurs
Parameters
e
Creates the magnifying glass canvas
Parameters
element
Find the magnifying glass canvas and remove it
Parameters
element
Calculates the minimum, maximum, and mean value in the given pixel array
Parameters
storedPixelLuminanceData
globalMin
globalMax
Calculates the minimum and maximum value in the given pixel array
Parameters
eventData
Records the start point of the click or touch
Parameters
eventData
Retrieve the options object associated with a particular toolName and element
Parameters
toolName
string Tool name identifier of the target options objectelement
HTMLElement Element of the target options object
Returns Object Target options object (empty if not yet set)
Set the options object associated with a particular toolName and element
Parameters
toolName
string Tool name identifier of the target options objectelement
HTMLElement Element of the target options objectoptions
Object Options object to store at target
Returns void
Clear the options object associated with a particular toolName and element
Parameters
toolName
string Tool name identifier of the target options objectelement
HTMLElement Element of the target options object
Returns void
Clear the options objects associated with a particular toolName
Parameters
toolName
string Tool type identifier of the target options objects
Returns void
Clear the options objects associated with a particular toolType Deprecation Notice: This method will be replaced by clearToolOptionsByToolName
Parameters
toolType
string Tool type identifier of the target options objects
Returns void
Clear the options objects associated with a particular element
Parameters
element
HTMLElement Element of the target options objects
Returns void