Ver código fonte

feat (1.45.0 -> 1.46.0): 实现任意角度旋转工具的状态管理

- 在functionAreaSlice中将'Rotate Any Angle'添加到互斥鼠标左键绑定工具列表
- 在stack.image.viewer中添加activateRotateAnyAngle和deactivateRotateAnyAngle函数
- 在ViewerContainer中实现Activate/Deactivate/DeactivateAll action的处理逻辑
- 确保'Rotate Any Angle'工具与其他状态工具互斥,并支持状态持久化

改动文件:
- src/states/view/functionAreaSlice.ts
- src/pages/view/components/viewers/stack.image.viewer.tsx
- src/pages/view/components/ViewerContainer.tsx
- src/pages/view/components/FunctionArea.tsx
dengdx 1 semana atrás
pai
commit
cb5e29dc94

+ 16 - 0
CHANGELOG.md

@@ -2,6 +2,22 @@
 
 本项目的所有重要变更都将记录在此文件中。
 
+## [1.46.0] - 2026-01-03 18:26
+
+### 新增 (Added)
+
+- **实现任意角度旋转工具的状态管理** - 将"Rotate Any Angle"工具加入状态管理按钮系统
+  - 在functionAreaSlice中将"Rotate Any Angle"添加到互斥工具列表
+  - 在stack.image.viewer中添加activateRotateAnyAngle和deactivateRotateAnyAngle函数
+  - 在ViewerContainer中添加工具激活/停用处理逻辑
+  - 在FunctionArea中已包含"Rotate Any Angle"在状态按钮列表中
+
+**改动文件:**
+- src/states/view/functionAreaSlice.ts
+- src/pages/view/components/viewers/stack.image.viewer.tsx
+- src/pages/view/components/ViewerContainer.tsx
+- src/pages/view/components/FunctionArea.tsx
+
 ## [1.45.0] - 2026-01-03 17:57
 
 ### 新增 (Added)

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "zsis",
-  "version": "1.45.0",
+  "version": "1.46.0",
   "private": true,
   "description": "医学成像系统",
   "main": "main.js",

+ 1 - 0
src/pages/view/components/FunctionArea.tsx

@@ -18,6 +18,7 @@ const STATEFUL_BUTTON_ACTIONS = new Set([
   'Magnifier',
   'Zoom Image',
   'Pan',
+  'Rotate Any Angle'
 ]);
 
 const FunctionButton = ({

+ 11 - 1
src/pages/view/components/ViewerContainer.tsx

@@ -4,6 +4,7 @@ import StackViewer, {
   activateMagnifier,
   activatePan,
   activateZoom,
+  activateRotateAnyAngle,
   addLMark,
   addMark,
   addRLabel,
@@ -49,6 +50,7 @@ import StackViewer, {
   deactivatePan,
   deactivateZoom,
   deactivateWindowLevel,
+  deactivateRotateAnyAngle,
 } from './viewers/stack.image.viewer';
 import { useSelector, useDispatch } from 'react-redux';
 import { getDcmImageUrl } from '@/API/bodyPosition';
@@ -350,12 +352,13 @@ const ViewerContainer: React.FC<ViewerContainerProps> = ({ imageUrls }) => {
       if (action.startsWith('Activate:')) {
         const toolName = action.substring('Activate:'.length);
         console.log(`[ViewerContainer] 激活工具: ${toolName}`);
-        //先停用所有4个状态工具
+        //先停用所有5个状态工具
         selectedViewportIds.forEach((viewportId) => {
           deactivateMagnifier(viewportId);
           deactivatePan(viewportId);
           deactivateWindowLevel(viewportId);
           deactivateZoom(viewportId);
+          deactivateRotateAnyAngle(viewportId);
         });
         selectedViewportIds.forEach((viewportId) => {
           switch (toolName) {
@@ -371,6 +374,9 @@ const ViewerContainer: React.FC<ViewerContainerProps> = ({ imageUrls }) => {
             case 'Zoom Image':
               activateZoom(viewportId);
               break;
+            case 'Rotate Any Angle':
+              activateRotateAnyAngle(viewportId);
+              break;
           }
         });
         dispatch(clearAction());
@@ -395,6 +401,9 @@ const ViewerContainer: React.FC<ViewerContainerProps> = ({ imageUrls }) => {
             case 'Zoom Image':
               deactivateZoom(viewportId);
               break;
+            case 'Rotate Any Angle':
+              deactivateRotateAnyAngle(viewportId);
+              break;
           }
         });
         dispatch(clearAction());
@@ -415,6 +424,7 @@ const ViewerContainer: React.FC<ViewerContainerProps> = ({ imageUrls }) => {
         deactivateMagnifier(viewportId);
         deactivatePan(viewportId);
         deactivateZoom(viewportId);
+        deactivateRotateAnyAngle(viewportId);
       });
       // 预处理带参数的 action
       // 处理预定义标记 (AddPredefinedMark:标记文本)

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

@@ -848,6 +848,28 @@ export function activateZoom(currentViewportId: string) {
     ],
   });
 }
+/** 激活 PlanarRotate 工具
+ */
+export function activateRotateAnyAngle(currentViewportId: string) {
+  console.log('Activating PlanarRotate Tool');
+  const toolGroup = getToolgroupByViewportId(currentViewportId);
+  toolGroup.setToolActive(PlanarRotateTool.toolName, {
+    bindings: [
+      {
+        mouseButton: MouseBindings.Primary, // Left Click
+      },
+    ],
+  });
+}
+/** 停用 PlanarRotate 工具
+ */
+export function deactivateRotateAnyAngle(currentViewportId: string) {
+  console.log('Deactivating PlanarRotate Tool');
+  const toolGroup = getToolgroupByViewportId(currentViewportId);
+  toolGroup.setToolPassive(PlanarRotateTool.toolName, {
+    removeAllBindings: true,
+  });
+}
 
 export function invertContrast(currentViewportId: string) {
   const viewport =

+ 2 - 1
src/states/view/functionAreaSlice.ts

@@ -17,7 +17,8 @@ const MOUSE_BINDING_TOOLS = [
   'Adjust Brightness and Contrast',
   'Magnifier',
   'Zoom Image',
-  'Pan'
+  'Pan',
+  'Rotate Any Angle'
 ] as const;
 
 const functionAreaSlice = createSlice({