From b241682fa9fb99d940cfdc7e8c20279037b8e962 Mon Sep 17 00:00:00 2001 From: caiyiling <1321909229@qq.com> Date: Wed, 17 Jun 2026 13:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E5=AE=9A=E5=9C=86=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E6=A0=87=E6=B3=A8=E5=A4=8D=E5=88=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dicoms3D/components/PetCtViewport.vue | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/views/trials/trials-panel/reading/dicoms3D/components/PetCtViewport.vue b/src/views/trials/trials-panel/reading/dicoms3D/components/PetCtViewport.vue index 1f77aabc..527d9103 100644 --- a/src/views/trials/trials-panel/reading/dicoms3D/components/PetCtViewport.vue +++ b/src/views/trials/trials-panel/reading/dicoms3D/components/PetCtViewport.vue @@ -302,36 +302,46 @@ export default { y: Math.min(Math.max(e.clientY - rect.top, padding), maxY), } }, + getInstanceInfo(imageId) { + const params = {} + if (imageId) { + const searchParams = new URLSearchParams(imageId.split('?')[1]) + for (const [key, value] of searchParams.entries()) { + params[key] = value + } + if (isNaN(params.frame)) { + params.frame = null + } + } + return params + }, getCircleAnnotationFromContextMenuEvent(e) { const viewport = this.getViewportInstance() if (!viewport || !this.element) return null const rect = this.element.getBoundingClientRect() const canvasPoint = [e.clientX - rect.left, e.clientY - rect.top] - const currentVisitTaskId = this.series?.TaskInfo?.VisitTaskId - const toolNames = ['CircleROI'] //FixedRadiusCircleROI看后期是不是要补充 - const candidates = [] - - toolNames.forEach((toolName) => { + const currentImageId = viewport.getCurrentImageId?.() + const currentInstanceId = this.getInstanceInfo(currentImageId).instanceId + const toolNames = ['CircleROI', 'FixedRadiusCircleROI'] + for (const toolName of toolNames) { const annotations = cornerstoneTools.annotation.state.getAnnotations(toolName, this.element) || [] - annotations.forEach((annotation) => { - if (!annotation?.data?.handles?.points?.length) return - if (currentVisitTaskId && annotation.visitTaskId && annotation.visitTaskId !== currentVisitTaskId) return + const selectedAnnotation = annotations.find((annotation) => { + if (!annotation?.highlighted) return false + if (!annotation?.data?.handles?.points?.length) return false + const annotationInstanceId = annotation.instanceId || this.getInstanceInfo(annotation.metadata?.referencedImageId).instanceId + if (currentInstanceId && annotationInstanceId && annotationInstanceId !== currentInstanceId) return false const hitInfo = this.getCircleAnnotationHitInfo(annotation, canvasPoint, viewport) - if (!hitInfo.hit || hitInfo.score === null) return - - candidates.push({ - annotation, - score: hitInfo.score, - }) + return hitInfo.hit }) - }) - if (!candidates.length) return null + if (selectedAnnotation) { + return selectedAnnotation + } + } - candidates.sort((a, b) => a.score - b.score) - return candidates[0].annotation + return null }, getCircleAnnotationHitInfo(annotation, canvasPoint, viewport) { const points = annotation?.data?.handles?.points || []