How to use the cornerstone-tools.getElementToolStateManager function in cornerstone-tools

To help you get started, weโ€™ve selected a few cornerstone-tools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github chestrays / cornerstone_widget / js / lib / cs_widget.js View on Github external
activate_tool: function () {
        var tool_name = this.model.get('_selected_tool');
        console.log('switching to tool: ' + tool_name);
        if (tool_name == 'reset') {
            this._disable_all_tools(this.viewer);
            cs.reset(this.viewer);
            var toolStateManager = ctools.getElementToolStateManager(this.viewer);
            // Note that this only works on ImageId-specific tool state managers (for now)
            toolStateManager.clear(this.viewer);
            cs.updateImage(this.viewer);
            this.model.set('_tool_state_in', '');
            this.model.set('_tool_state_out', '');
            this._setup_tools();
        } else {
            this._disable_all_tools(this.viewer);
            if (tool_name == 'zoom') {
                ctools.zoom.activate(this.viewer, 1);
            }
            if (tool_name == 'window') {
                ctools.wwwc.activate(this.viewer, 1);
            }
            if (tool_name == 'pan') {
                ctools.pan.activate(this.viewer, 1);
github Kitware / paraview-glance / Sources / externals / MedicalCornerstone / CornerstoneToolManager.js View on Github external
publicAPI.setMeasurementData = (el, toolType, measurementData, newData) =>
    cornerstoneTools
      .getElementToolStateManager(el)
      .setData(el, toolType, measurementData, newData);
github Kitware / paraview-glance / Sources / externals / MedicalCornerstone / CornerstoneToolControl / index.js View on Github external
<div>
            <button disabled="{forceDisable}" checked="{checked}"> this.toggleTool(name)}
            &gt;
              
            </button>
          </div>
        );
      });

    const measurements = [];
    if (view &amp;&amp; view.getContainer()) {
      const element = view.getContainer();
      const stateManager = cornerstoneTools.getElementToolStateManager(element);

      if (
        stateManager !== cornerstoneTools.globalImageIdSpecificToolStateManager
      ) {
        const getSliceIndex = (imageId) =&gt; {
          const { params } = parseImageId(imageId);
          return params.slice;
        };

        const toolState = stateManager.getToolState();
        Object.values(toolState).forEach((states) =&gt; {
          Object.keys(states).forEach((toolType) =&gt; {
            states[toolType].data.forEach((item) =&gt;
              measurements.push({
                key: item.metadata.measurementId,
                type: item.metadata.toolType,
github Kitware / paraview-glance / Sources / externals / MedicalCornerstone / CornerstoneToolManager.js View on Github external
publicAPI.deleteMeasurement = (el, toolType, measurementData) =>
    cornerstoneTools
      .getElementToolStateManager(el)
      .removeData(el, toolType, measurementData);