|
@@ -9,7 +9,7 @@ import { SystemMode } from '@/states/systemModeSlice';
|
|
|
import store from '@/states/store';
|
|
|
import { clearAction } from '@/states/view/functionAreaSlice';
|
|
|
import { useDispatch } from 'react-redux';
|
|
|
-import { SplineROITool } from '@cornerstonejs/tools';
|
|
|
+import { annotation, SplineROITool } from '@cornerstonejs/tools';
|
|
|
import { eventTarget } from '@cornerstonejs/core';
|
|
|
|
|
|
const {
|
|
@@ -256,6 +256,40 @@ function addMask(): void {
|
|
|
bindings: [{ mouseButton: MouseBindings.Primary }],
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+function remoteMask(): void {
|
|
|
+ // 1. 获取所有 annotation
|
|
|
+ const all = annotation.state.getAllAnnotations();
|
|
|
+
|
|
|
+ // 2. 过滤出 LinearSplineROI 产生的
|
|
|
+ const toRemove = all.filter(
|
|
|
+ (a) => a.metadata?.toolName === 'LinearSplineROI'
|
|
|
+ );
|
|
|
+
|
|
|
+ // 3. 逐条删掉
|
|
|
+ toRemove.forEach((a) => {
|
|
|
+ if (a.annotationUID) {
|
|
|
+ annotation.state.removeAnnotation(a.annotationUID);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const viewport = cornerstone.getEnabledElementByViewportId(currentViewportId)
|
|
|
+ .viewport as cornerstone.StackViewport;
|
|
|
+ viewport.render();
|
|
|
+
|
|
|
+ console.log('Deleting Digital Mask');
|
|
|
+
|
|
|
+ const viewportElement = viewport.element;
|
|
|
+ const firstChild = viewportElement.firstChild;
|
|
|
+ if (firstChild) {
|
|
|
+ const canvasElements = Array.from(firstChild.childNodes).filter(
|
|
|
+ (child): child is Element =>
|
|
|
+ child instanceof Element && child.tagName === 'CANVAS'
|
|
|
+ );
|
|
|
+ canvasElements.slice(1).forEach((canvas) => {
|
|
|
+ firstChild.removeChild(canvas);
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
function HorizontalFlip(): void {
|
|
|
const viewport = cornerstone.getEnabledElementByViewportId(currentViewportId)
|
|
|
.viewport as cornerstone.StackViewport;
|
|
@@ -546,8 +580,7 @@ const StackViewer = ({
|
|
|
addMask();
|
|
|
break;
|
|
|
case 'Delete Digital Mask':
|
|
|
- // Implement the logic to delete the digital mask
|
|
|
- console.log('Deleting Digital Mask');
|
|
|
+ remoteMask();
|
|
|
break;
|
|
|
case 'Adjust Brightness and Contrast':
|
|
|
adjustBrightnessAndContrast();
|