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 || []