|
@@ -379,37 +379,36 @@ export default class LineGrayscaleMeasurementTool extends AnnotationTool {
|
|
|
const customAnn = ann as LineGrayscaleAnnotation;
|
|
const customAnn = ann as LineGrayscaleAnnotation;
|
|
|
|
|
|
|
|
// 1. 检查是否点击在文本框上
|
|
// 1. 检查是否点击在文本框上
|
|
|
- if (customAnn.data.textBox) {
|
|
|
|
|
- const textBoxCanvas = customAnn.data.textBox;
|
|
|
|
|
- if (this._isPointNearTextBox(canvasCoords, textBoxCanvas)) {
|
|
|
|
|
- const viewportIdsToRender =
|
|
|
|
|
- utilities.viewportFilters.getViewportIdsWithToolToRender(
|
|
|
|
|
- element,
|
|
|
|
|
- this.getToolName()
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- this.editData = {
|
|
|
|
|
- annotation: customAnn,
|
|
|
|
|
- viewportIdsToRender,
|
|
|
|
|
- textBoxBeingMoved: true,
|
|
|
|
|
- textBoxOffset: [
|
|
|
|
|
- canvasCoords[0] - textBoxCanvas[0],
|
|
|
|
|
- canvasCoords[1] - textBoxCanvas[1],
|
|
|
|
|
- ],
|
|
|
|
|
- hasMoved: false,
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- customAnn.isSelected = true;
|
|
|
|
|
- customAnn.highlighted = true;
|
|
|
|
|
-
|
|
|
|
|
- utilities.triggerAnnotationRenderForViewportIds(
|
|
|
|
|
- viewportIdsToRender
|
|
|
|
|
|
|
+ // 使用默认位置(第二个端点)如果 textBox 未定义
|
|
|
|
|
+ const textBoxCanvas = customAnn.data.textBox || viewport.worldToCanvas(customAnn.data.handles.points[1]);
|
|
|
|
|
+ if (this._isPointNearTextBox(canvasCoords, textBoxCanvas)) {
|
|
|
|
|
+ const viewportIdsToRender =
|
|
|
|
|
+ utilities.viewportFilters.getViewportIdsWithToolToRender(
|
|
|
|
|
+ element,
|
|
|
|
|
+ this.getToolName()
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
- evt.preventDefault();
|
|
|
|
|
- evt.stopPropagation();
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ this.editData = {
|
|
|
|
|
+ annotation: customAnn,
|
|
|
|
|
+ viewportIdsToRender,
|
|
|
|
|
+ textBoxBeingMoved: true,
|
|
|
|
|
+ textBoxOffset: [
|
|
|
|
|
+ canvasCoords[0] - textBoxCanvas[0],
|
|
|
|
|
+ canvasCoords[1] - textBoxCanvas[1],
|
|
|
|
|
+ ],
|
|
|
|
|
+ hasMoved: false,
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
|
|
+ customAnn.isSelected = true;
|
|
|
|
|
+ customAnn.highlighted = true;
|
|
|
|
|
+
|
|
|
|
|
+ utilities.triggerAnnotationRenderForViewportIds(
|
|
|
|
|
+ viewportIdsToRender
|
|
|
|
|
+ );
|
|
|
|
|
+
|
|
|
|
|
+ evt.preventDefault();
|
|
|
|
|
+ evt.stopPropagation();
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 2. 检查是否点击在手柄上
|
|
// 2. 检查是否点击在手柄上
|
|
@@ -671,15 +670,14 @@ export default class LineGrayscaleMeasurementTool extends AnnotationTool {
|
|
|
const customAnn = ann as LineGrayscaleAnnotation;
|
|
const customAnn = ann as LineGrayscaleAnnotation;
|
|
|
|
|
|
|
|
// 1. 检查是否悬停在文本框上
|
|
// 1. 检查是否悬停在文本框上
|
|
|
- if (customAnn.data.textBox) {
|
|
|
|
|
- const textBoxCanvas = customAnn.data.textBox;
|
|
|
|
|
- if (this._isPointNearTextBox(canvasCoords, textBoxCanvas)) {
|
|
|
|
|
- element.style.cursor = 'pointer';
|
|
|
|
|
- customAnn.highlighted = true;
|
|
|
|
|
- isHovering = true;
|
|
|
|
|
- cursorSet = true;
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // 使用默认位置(第二个端点)如果 textBox 未定义
|
|
|
|
|
+ const textBoxCanvas = customAnn.data.textBox || viewport.worldToCanvas(customAnn.data.handles.points[1]);
|
|
|
|
|
+ if (this._isPointNearTextBox(canvasCoords, textBoxCanvas)) {
|
|
|
|
|
+ element.style.cursor = 'pointer';
|
|
|
|
|
+ customAnn.highlighted = true;
|
|
|
|
|
+ isHovering = true;
|
|
|
|
|
+ cursorSet = true;
|
|
|
|
|
+ break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 2. 检查是否靠近手柄
|
|
// 2. 检查是否靠近手柄
|
|
@@ -828,7 +826,7 @@ export default class LineGrayscaleMeasurementTool extends AnnotationTool {
|
|
|
private _isPointNearTextBox(
|
|
private _isPointNearTextBox(
|
|
|
point: CoreTypes.Point2,
|
|
point: CoreTypes.Point2,
|
|
|
textBoxPosition: CoreTypes.Point2,
|
|
textBoxPosition: CoreTypes.Point2,
|
|
|
- padding: number = 50
|
|
|
|
|
|
|
+ padding: number = 10
|
|
|
): boolean {
|
|
): boolean {
|
|
|
// 简单的矩形碰撞检测,假设文本框大小约为 150x80
|
|
// 简单的矩形碰撞检测,假设文本框大小约为 150x80
|
|
|
const textBoxWidth = 150;
|
|
const textBoxWidth = 150;
|