Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
publicAPI.setMeasurementData = (el, toolType, measurementData, newData) =>
cornerstoneTools
.getElementToolStateManager(el)
.setData(el, toolType, measurementData, newData);
<div>
<button disabled="{forceDisable}" checked="{checked}"> this.toggleTool(name)}
>
</button>
</div>
);
});
const measurements = [];
if (view && view.getContainer()) {
const element = view.getContainer();
const stateManager = cornerstoneTools.getElementToolStateManager(element);
if (
stateManager !== cornerstoneTools.globalImageIdSpecificToolStateManager
) {
const getSliceIndex = (imageId) => {
const { params } = parseImageId(imageId);
return params.slice;
};
const toolState = stateManager.getToolState();
Object.values(toolState).forEach((states) => {
Object.keys(states).forEach((toolType) => {
states[toolType].data.forEach((item) =>
measurements.push({
key: item.metadata.measurementId,
type: item.metadata.toolType,
publicAPI.deleteMeasurement = (el, toolType, measurementData) =>
cornerstoneTools
.getElementToolStateManager(el)
.removeData(el, toolType, measurementData);