|
@@ -285,69 +285,9 @@ function ApplyColormap(): void {
|
|
|
function RotateCounterclockwise90(): void {
|
|
|
const viewport = cornerstone.getEnabledElementByViewportId(currentViewportId)
|
|
|
.viewport as cornerstone.StackViewport;
|
|
|
- // let { rotation } = viewport.getViewPresentation();
|
|
|
- // const currentRotataion = viewport.getRotation();
|
|
|
- // viewport.rotation(22)
|
|
|
- // console.log(`rotation:${rotation}`)
|
|
|
- // if(!!rotation){
|
|
|
- // rotation=0;
|
|
|
- // }
|
|
|
- // viewport.setViewPresentation({ rotation: rotation ?? 0 + 30 });
|
|
|
- // // // Implement the logic to rotate the image counterclockwise
|
|
|
- // // viewport.setCamera({ rotation: -90 });
|
|
|
- // viewport.render();
|
|
|
-
|
|
|
- // // 1. 获取当前的视图表现状态(一个完整的对象)
|
|
|
- // const currentViewPresentation = viewport.getViewPresentation();
|
|
|
-
|
|
|
- // // 2. 创建一个新的对象,基于当前状态,只更新你需要修改的属性
|
|
|
- // // 使用展开运算符 (...) 来复制所有现有属性
|
|
|
- // const newViewPresentation = {
|
|
|
- // ...currentViewPresentation, // 保留所有原有属性,如 scale, translation, flip 等
|
|
|
- // rotation: currentViewPresentation.rotation ?? + 30, // 只覆盖 rotation 属性
|
|
|
- // };
|
|
|
-
|
|
|
- // // 3. 将完整的新状态对象设置回 viewport
|
|
|
- // viewport.setViewPresentation(newViewPresentation);
|
|
|
- // viewport.render();
|
|
|
-
|
|
|
- //----------------------------------------
|
|
|
- // // 获取当前的完整视图状态
|
|
|
- // const currentViewState = viewport.getViewPresentation();
|
|
|
-
|
|
|
- // // 创建新的视图状态对象,保持所有其他属性不变
|
|
|
- // const newViewState = {
|
|
|
- // ...currentViewState, // 保留所有现有属性
|
|
|
- // rotation: (currentViewState.rotation ?? 0 + 30) % 360 // 只修改rotation
|
|
|
- // };
|
|
|
-
|
|
|
- // // 设置新的视图状态
|
|
|
- // viewport.setViewPresentation(newViewState);
|
|
|
- // viewport.render();
|
|
|
- //-----------------------------------------
|
|
|
// 获取当前相机
|
|
|
const camera = viewport.getCamera();
|
|
|
|
|
|
- // // 计算新的旋转角度(当前角度 + 90度)
|
|
|
- // const newRotation = (camera.rotation ?? 0) + 90;
|
|
|
-
|
|
|
- // // 转换为弧度
|
|
|
- // const radians = newRotation * Math.PI / 180;
|
|
|
-
|
|
|
- // // 计算新的viewUp向量(顺时针旋转90度)
|
|
|
- // const newViewUp:[number, number, number] = [
|
|
|
- // Math.cos(radians), // X分量
|
|
|
- // Math.sin(radians), // Y分量
|
|
|
- // 0 // Z分量
|
|
|
- // ];
|
|
|
-
|
|
|
- // // 设置新的相机参数
|
|
|
- // viewport.setCamera({
|
|
|
- // ...camera, // 保持其他相机参数不变
|
|
|
- // viewUp: newViewUp, // 更新向上向量
|
|
|
- // rotation: newRotation // 更新旋转角度(可选,但推荐)
|
|
|
- // });
|
|
|
-
|
|
|
// 计算新的旋转角度(当前角度 + 90度)
|
|
|
const newRotation = (camera.rotation ?? 0) + 90;
|
|
|
|