Skip to content
Chris Hafey edited this page Apr 7, 2014 · 4 revisions

Cornerstone tools are in one of the following states for each enabled element

  • Disabled - In this state the tool is not connected to the enabled element at all. This is the default for every tool must be changed into one of the other states for the image to provide any interactivity through the tool.
  • Enabled - In this state the tool is connected to the enabled element. Tools in this state will receive the CornerstoneImageRendered event so they can draw themselves but will not respond to any input. This is useful for read-only scenarios where tool data may have been previously created and the user wants to view it but should not be able to modify it.
  • Active - In this state the tool will actively respond to user input. For example, a length measurement tool in this state would create a new length measurement in response to a left click drag with the mouse. Typically a single tool will be active for a given input mechanism (e.g. left mouse click, touch pan gesture, keypress of the spacebar on the keyboard.
  • Passive - In this state the tool will passively respond to user input. For example, moving the mouse over a length measurement handle will update the image to highlight the handle. The user could move the position of the handle by left click dragging but left clicking outside of the handle would not create a new measurement tool.

Click here for to see an example of changing the tool state for the cornerstone pixel probe tool

Developers are responsible for transitioning the tool state of cornerstone tools based on the needs of their application. Each tool exposes an object that includes the following functions:


function enable(element)

Parameters:

  • element - the DOM node for an enabled element to transition the tool into the enabled state.

Returns: nothing


function disable(element)

Parameters:

  • element - the DOM node for an enabled element to transition the tool into the disabled state.

Returns: nothing


function activate(element, mouseButtonMask)

Parameters:

  • element - the DOM node for an enabled element to transition the tool into the activate state
  • mouseButtonMask - a bit field indicating which mouse buttons to capture. Defaults to 1 if no value is provided.
    • 1 = left mouse button
    • 2 = middle mouse button
    • 4 = right mouse button

Returns: nothing


function deactivate(element)

Parameters:

  • element - the DOM node for an enabled element to transition the tool into the passive state

Returns: nothing

NOTE: deactivate isn't the best name for changing to the passive state but pacify doesn't seem quite right either. Inactive doesn't seem quite right as a state name either though, need to find a good name here.


TODO:

  1. Add support for touch gestures
  2. Figure out how to support different input mechanisms while in the inactive state (currently hard coded to use the left mouse button)

Clone this wiki locally