feat: 🎸 Configuration so viewer tools can nix handles (#1304)
* feat: 🎸 Configuration so viewer tools can nix handles Adds a key to cornerstone configuration that allows to toggle on/off handle rendering Closes: #1223 * Update extension docs * Update doc * docs: include hideHandles configuration in our configuration docs * chore: default to hiding handles for annotations * chore: switch to drawHandlesOnHover to mimic legacy viewer functionality * Flip logic for drawHandlesOnHover; reverse of hideHandles * Don't hide the handles of ellipse or rectangle roi * invert check Co-authored-by: Danny Brown <danny.ri.brown@gmail.com>
This commit is contained in:
parent
6c160f517f
commit
63594d36b0
@ -1,6 +1,9 @@
|
|||||||
# Viewer: Configuration
|
# Viewer: Configuration
|
||||||
|
|
||||||
We maintain a number of common viewer application configurations at [`<root>/platform/viewer/public/configs`][config-dir]. How these values are passed to the viewer depend on how it's deployed, but the two most common paths are:
|
We maintain a number of common viewer application configurations at
|
||||||
|
[`<root>/platform/viewer/public/configs`][config-dir]. How these values are
|
||||||
|
passed to the viewer depend on how it's deployed, but the two most common paths
|
||||||
|
are:
|
||||||
|
|
||||||
- `index.html` looks for `https://your-website.com/app-config.js` OR
|
- `index.html` looks for `https://your-website.com/app-config.js` OR
|
||||||
- `index.html` passes the values to `OHIF.installViewer()`
|
- `index.html` passes the values to `OHIF.installViewer()`
|
||||||
@ -42,8 +45,16 @@ window.config = {
|
|||||||
keys: ['v'],
|
keys: ['v'],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
// Config to pass to the bundled cornerstone extension
|
/* Configuration passed to the bundled cornerstone extension
|
||||||
cornerstoneExtensionConfig: {},
|
*
|
||||||
|
* The cornerstone extension is currently tightly coupled to the platform.
|
||||||
|
* Until we're able to decouple it, this key will serve as a workaround to
|
||||||
|
* pass it configuration.
|
||||||
|
*/
|
||||||
|
cornerstoneExtensionConfig: {
|
||||||
|
/* Whether to show/hide annotation "handles" */
|
||||||
|
hideHandles: true,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -85,6 +85,20 @@ Tools can be configured through extension configuration using the tools key:
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Annotate Tools Configuration
|
||||||
|
|
||||||
|
*We currently support one property for annotation tools.*
|
||||||
|
|
||||||
|
### Hide handles
|
||||||
|
This extension configuration allows you to toggle on/off handle rendering for all annotate tools:
|
||||||
|
|
||||||
|
```js
|
||||||
|
...
|
||||||
|
cornerstoneExtensionConfig: {
|
||||||
|
hideHandles: true,
|
||||||
|
},
|
||||||
|
...
|
||||||
|
|
||||||
## Resources
|
## Resources
|
||||||
|
|
||||||
### Repositories
|
### Repositories
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
"@ohif/ui": "^0.50.0",
|
"@ohif/ui": "^0.50.0",
|
||||||
"cornerstone-core": "^2.2.8",
|
"cornerstone-core": "^2.2.8",
|
||||||
"cornerstone-math": "^0.1.8",
|
"cornerstone-math": "^0.1.8",
|
||||||
"cornerstone-tools": "^4.8.0",
|
"cornerstone-tools": "^4.9.0",
|
||||||
"cornerstone-wado-image-loader": "^3.0.0",
|
"cornerstone-wado-image-loader": "^3.0.0",
|
||||||
"dcmjs": "^0.8.2",
|
"dcmjs": "^0.8.2",
|
||||||
"dicom-parser": "^1.8.3",
|
"dicom-parser": "^1.8.3",
|
||||||
|
|||||||
@ -76,19 +76,9 @@ export default function init({ servicesManager, configuration }) {
|
|||||||
|
|
||||||
initCornerstoneTools(defaultCsToolsConfig);
|
initCornerstoneTools(defaultCsToolsConfig);
|
||||||
|
|
||||||
// ~~ Toooools 🙌
|
const toolsGroupedByType = {
|
||||||
const tools = [
|
touch: [csTools.PanMultiTouchTool, csTools.ZoomTouchPinchTool],
|
||||||
csTools.PanTool,
|
annotations: [
|
||||||
csTools.ZoomTool,
|
|
||||||
csTools.WwwcTool,
|
|
||||||
csTools.WwwcRegionTool,
|
|
||||||
csTools.MagnifyTool,
|
|
||||||
csTools.StackScrollTool,
|
|
||||||
csTools.StackScrollMouseWheelTool,
|
|
||||||
// Touch
|
|
||||||
csTools.PanMultiTouchTool,
|
|
||||||
csTools.ZoomTouchPinchTool,
|
|
||||||
// Annotations
|
|
||||||
csTools.ArrowAnnotateTool,
|
csTools.ArrowAnnotateTool,
|
||||||
csTools.EraserTool,
|
csTools.EraserTool,
|
||||||
csTools.BidirectionalTool,
|
csTools.BidirectionalTool,
|
||||||
@ -98,9 +88,23 @@ export default function init({ servicesManager, configuration }) {
|
|||||||
csTools.EllipticalRoiTool,
|
csTools.EllipticalRoiTool,
|
||||||
csTools.DragProbeTool,
|
csTools.DragProbeTool,
|
||||||
csTools.RectangleRoiTool,
|
csTools.RectangleRoiTool,
|
||||||
// Segmentation
|
],
|
||||||
csTools.BrushTool,
|
segmentation: [csTools.BrushTool],
|
||||||
];
|
other: [
|
||||||
|
csTools.PanTool,
|
||||||
|
csTools.ZoomTool,
|
||||||
|
csTools.WwwcTool,
|
||||||
|
csTools.WwwcRegionTool,
|
||||||
|
csTools.MagnifyTool,
|
||||||
|
csTools.StackScrollTool,
|
||||||
|
csTools.StackScrollMouseWheelTool,
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
let tools = [];
|
||||||
|
Object.keys(toolsGroupedByType).forEach(toolsGroup =>
|
||||||
|
tools.push(...toolsGroupedByType[toolsGroup])
|
||||||
|
);
|
||||||
|
|
||||||
/* Add extension tools configuration here. */
|
/* Add extension tools configuration here. */
|
||||||
const internalToolsConfig = {
|
const internalToolsConfig = {
|
||||||
@ -114,13 +118,48 @@ export default function init({ servicesManager, configuration }) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Abstract tools configuration using extension configuration. */
|
||||||
|
const parseToolProps = (props, tool) => {
|
||||||
|
const { annotations } = toolsGroupedByType;
|
||||||
|
// An alternative approach would be to remove the `drawHandlesOnHover` config
|
||||||
|
// from the supported configuration properties in `cornerstone-tools`
|
||||||
|
const toolsWithHideableHandles = annotations.filter(
|
||||||
|
tool => !['RectangleRoiTool', 'EllipticalRoiTool'].includes(tool.name)
|
||||||
|
);
|
||||||
|
|
||||||
|
let parsedProps = { ...props };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* drawHandles - Never/Always show handles
|
||||||
|
* drawHandlesOnHover - Only show handles on handle hover (pointNearHandle)
|
||||||
|
*
|
||||||
|
* Does not apply to tools where handles aren't placed in predictable
|
||||||
|
* locations.
|
||||||
|
*/
|
||||||
|
if (
|
||||||
|
configuration.hideHandles !== false &&
|
||||||
|
toolsWithHideableHandles.includes(tool)
|
||||||
|
) {
|
||||||
|
if (props.configuration) {
|
||||||
|
parsedProps.configuration.drawHandlesOnHover = true;
|
||||||
|
} else {
|
||||||
|
parsedProps.configuration = { drawHandlesOnHover: true };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsedProps;
|
||||||
|
};
|
||||||
|
|
||||||
/* Add tools with its custom props through extension configuration. */
|
/* Add tools with its custom props through extension configuration. */
|
||||||
tools.forEach(tool => {
|
tools.forEach(tool => {
|
||||||
const toolName = tool.name.replace('Tool', '');
|
const toolName = tool.name.replace('Tool', '');
|
||||||
const externalToolsConfig = configuration.tools || {};
|
const externalToolsConfig = configuration.tools || {};
|
||||||
const externalToolProps = externalToolsConfig[toolName] || {};
|
const externalToolProps = externalToolsConfig[toolName] || {};
|
||||||
const internalToolProps = internalToolsConfig[toolName] || {};
|
const internalToolProps = internalToolsConfig[toolName] || {};
|
||||||
const props = merge(internalToolProps, externalToolProps);
|
const props = merge(
|
||||||
|
internalToolProps,
|
||||||
|
parseToolProps(externalToolProps, tool)
|
||||||
|
);
|
||||||
csTools.addTool(tool, props);
|
csTools.addTool(tool, props);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@ohif/core": "^2.2.1",
|
"@ohif/core": "^2.2.1",
|
||||||
"@ohif/ui": "^1.1.5",
|
"@ohif/ui": "^1.1.5",
|
||||||
"cornerstone-tools": "^4.8.0",
|
"cornerstone-tools": "^4.9.0",
|
||||||
"cornerstone-wado-image-loader": "^3.0.0",
|
"cornerstone-wado-image-loader": "^3.0.0",
|
||||||
"dicom-parser": "^1.8.3",
|
"dicom-parser": "^1.8.3",
|
||||||
"gh-pages": "^2.0.1",
|
"gh-pages": "^2.0.1",
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"cornerstone-core": "^2.2.8",
|
"cornerstone-core": "^2.2.8",
|
||||||
"cornerstone-tools": "^4.8.0",
|
"cornerstone-tools": "^4.9.0",
|
||||||
"cornerstone-wado-image-loader": "^3.0.0",
|
"cornerstone-wado-image-loader": "^3.0.0",
|
||||||
"dicom-parser": "^1.8.3"
|
"dicom-parser": "^1.8.3"
|
||||||
},
|
},
|
||||||
|
|||||||
@ -58,7 +58,7 @@
|
|||||||
"core-js": "^3.2.1",
|
"core-js": "^3.2.1",
|
||||||
"cornerstone-core": "^2.2.8",
|
"cornerstone-core": "^2.2.8",
|
||||||
"cornerstone-math": "^0.1.8",
|
"cornerstone-math": "^0.1.8",
|
||||||
"cornerstone-tools": "^4.8.0",
|
"cornerstone-tools": "^4.9.0",
|
||||||
"cornerstone-wado-image-loader": "^3.0.0",
|
"cornerstone-wado-image-loader": "^3.0.0",
|
||||||
"dcmjs": "^0.8.2",
|
"dcmjs": "^0.8.2",
|
||||||
"dicom-parser": "^1.8.3",
|
"dicom-parser": "^1.8.3",
|
||||||
|
|||||||
@ -5962,10 +5962,10 @@ cornerstone-math@^0.1.8:
|
|||||||
resolved "https://registry.yarnpkg.com/cornerstone-math/-/cornerstone-math-0.1.8.tgz#68ab1f9e4fdcd7c5cb23a0d2eb4263f9f894f1c5"
|
resolved "https://registry.yarnpkg.com/cornerstone-math/-/cornerstone-math-0.1.8.tgz#68ab1f9e4fdcd7c5cb23a0d2eb4263f9f894f1c5"
|
||||||
integrity sha512-x7NEQHBtVG7j1yeyj/aRoKTpXv1Vh2/H9zNLMyqYJDtJkNng8C4Q8M3CgZ1qer0Yr7eVq2x+Ynmj6kfOm5jXKw==
|
integrity sha512-x7NEQHBtVG7j1yeyj/aRoKTpXv1Vh2/H9zNLMyqYJDtJkNng8C4Q8M3CgZ1qer0Yr7eVq2x+Ynmj6kfOm5jXKw==
|
||||||
|
|
||||||
cornerstone-tools@^4.8.0:
|
cornerstone-tools@^4.9.0:
|
||||||
version "4.8.0"
|
version "4.9.0"
|
||||||
resolved "https://registry.yarnpkg.com/cornerstone-tools/-/cornerstone-tools-4.8.0.tgz#1972546e13e9a09b8aa25a3541ffc345283eec01"
|
resolved "https://registry.yarnpkg.com/cornerstone-tools/-/cornerstone-tools-4.9.0.tgz#8b68603c32aceb84baf860f4dd0d36ac176e8b75"
|
||||||
integrity sha512-PO7/jYbVwc+ddF9JW/o/JXqNPFZV7y1PUTzlRATC9FeXLXNKIkSFBCF5SA1EGJoyjzRYGDBgTZuTYhfm96AlAA==
|
integrity sha512-6yHzXm4qn7VuHMRiaV/oS3khdMidtTho6P1OIYICqZ2pmorsH8jN8LvNgqz+Ky9Nf+wvrvi7ul8ZzcD1sJTkWA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime" "7.1.2"
|
"@babel/runtime" "7.1.2"
|
||||||
cornerstone-math "0.1.7"
|
cornerstone-math "0.1.7"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user