补充定圆工具标注复制功能
continuous-integration/drone/push Build is passing Details

main
caiyiling 2026-06-17 13:31:00 +08:00
parent cb16658190
commit b241682fa9
1 changed files with 28 additions and 18 deletions

View File

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