|
@@ -473,10 +473,6 @@ export function addCustomMark(currentViewportId: string, text: string): void {
|
|
|
|
|
|
|
|
const toolGroup = getToolgroupByViewportId(currentViewportId);
|
|
const toolGroup = getToolgroupByViewportId(currentViewportId);
|
|
|
|
|
|
|
|
- // 激活标签工具
|
|
|
|
|
- toolGroup.setToolActive(LabelTool.toolName, {
|
|
|
|
|
- bindings: [],
|
|
|
|
|
- });
|
|
|
|
|
|
|
|
|
|
// 获取视口元素和位置
|
|
// 获取视口元素和位置
|
|
|
const element = document.getElementById(currentViewportId);
|
|
const element = document.getElementById(currentViewportId);
|
|
@@ -490,22 +486,13 @@ export function addCustomMark(currentViewportId: string, text: string): void {
|
|
|
message.error(`添加注释失败`);
|
|
message.error(`添加注释失败`);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- const viewport = renderingEngine.getViewport(currentViewportId);
|
|
|
|
|
|
|
+
|
|
|
// 计算标记位置(图像中心位置)
|
|
// 计算标记位置(图像中心位置)
|
|
|
// 1️⃣ canvas 坐标(屏幕中心)
|
|
// 1️⃣ canvas 坐标(屏幕中心)
|
|
|
const { width, height } = element.getBoundingClientRect();
|
|
const { width, height } = element.getBoundingClientRect();
|
|
|
const canvasPoint: Types.Point2 = [width / 2, height / 2];
|
|
const canvasPoint: Types.Point2 = [width / 2, height / 2];
|
|
|
|
|
|
|
|
- // 2️⃣ 转为 world 坐标(关键!)
|
|
|
|
|
- const worldPoint = viewport.canvasToWorld(canvasPoint);
|
|
|
|
|
-
|
|
|
|
|
- // 3️⃣ 使用 world 坐标 添加标签
|
|
|
|
|
- LabelTool.hydrate(currentViewportId, worldPoint, text);
|
|
|
|
|
-
|
|
|
|
|
- // 恢复工具状态
|
|
|
|
|
- toolGroup.setToolPassive(LabelTool.toolName, {
|
|
|
|
|
- removeAllBindings: true,
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ TextAnnotationToolManager.activateTextAnnotationTool(currentViewportId, text,canvasPoint);
|
|
|
|
|
|
|
|
console.log(`Custom mark "${text}" added successfully`);
|
|
console.log(`Custom mark "${text}" added successfully`);
|
|
|
}
|
|
}
|