Browse Source

fix: 修复删除标记功能无法删除自定义和预定义标记的问题

- 修改 deleteSelectedMark 函数逻辑,从硬编码只删除 'L'/'R' 标记改为删除所有 LabelTool 创建的标记
- 现在可以正确删除预定义标记(拉姿、仰卧等12种)、自定义标记和时间戳标记
- 使用 annotation.metadata?.toolName 判断而非 annotation.data.text 判断

改动文件:
- src/pages/view/components/viewers/stack.image.viewer.tsx
dengdx 1 month ago
parent
commit
1c704b9af8
1 changed files with 4 additions and 1 deletions
  1. 4 1
      src/pages/view/components/viewers/stack.image.viewer.tsx

+ 4 - 1
src/pages/view/components/viewers/stack.image.viewer.tsx

@@ -320,13 +320,16 @@ export function deleteSelectedMark(currentViewportId: string): void {
   const viewport =
     cornerstone.getEnabledElementByViewportId(currentViewportId).viewport;
   const allAnnotations = cornerstoneTools.annotation.state.getAllAnnotations();
+  
+  // 删除所有 LabelTool 创建的标记(包括 L/R 标记、预定义标记、自定义标记、时间戳标记)
   for (const annotation of allAnnotations) {
-    if (annotation.data.text === 'L' || annotation.data.text === 'R') {
+    if (annotation.metadata?.toolName === LabelTool.toolName ) {
       cornerstoneTools.annotation.state.removeAnnotation(
         annotation.annotationUID!
       );
     }
   }
+  
   viewport.render();
 }