Browse Source

实现删除L和R annotation

dengdx 3 weeks ago
parent
commit
92d401f086
1 changed files with 13 additions and 0 deletions
  1. 13 0
      src/pages/view/components/viewers/stack.image.viewer.tsx

+ 13 - 0
src/pages/view/components/viewers/stack.image.viewer.tsx

@@ -194,6 +194,19 @@ const StackViewer = ({ imageIndex }) => {
           break;
         case 'Delete Selected Mark':
           // Implement the logic to delete the selected mark
+          const viewport = cornerstone.getEnabledElementByViewportId(currentViewportId).viewport;
+          const allAnnotations = cornerstoneTools.annotation.state.getAllAnnotations();
+          // const allAnnotations = cornerstoneTools.annotation.state.getAnnotations(LabelTool.toolName, element.element);
+          console.log(`allAnnotations 数量:${allAnnotations.length}`);
+          for (const annotation of allAnnotations) {
+            if (annotation.data.text === 'L' || annotation.data.text === 'R') {
+              console.log(`Deleting annotation with UID: ${annotation.annotationUID}`);
+              cornerstoneTools.annotation.state.removeAnnotation(annotation.annotationUID!);
+            }
+            // cornerstoneTools.annotation.state.removeAnnotation(annotation.annotationUID!);
+          }
+          // 触发视口重新渲染
+          viewport.render();
           console.log('Deleting Selected Mark');
           break;
         case 'Horizontal Flip':