补充定圆工具标注复制功能
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
cb16658190
commit
b241682fa9
|
|
@ -302,36 +302,46 @@ export default {
|
||||||
y: Math.min(Math.max(e.clientY - rect.top, padding), maxY),
|
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) {
|
getCircleAnnotationFromContextMenuEvent(e) {
|
||||||
const viewport = this.getViewportInstance()
|
const viewport = this.getViewportInstance()
|
||||||
if (!viewport || !this.element) return null
|
if (!viewport || !this.element) return null
|
||||||
|
|
||||||
const rect = this.element.getBoundingClientRect()
|
const rect = this.element.getBoundingClientRect()
|
||||||
const canvasPoint = [e.clientX - rect.left, e.clientY - rect.top]
|
const canvasPoint = [e.clientX - rect.left, e.clientY - rect.top]
|
||||||
const currentVisitTaskId = this.series?.TaskInfo?.VisitTaskId
|
const currentImageId = viewport.getCurrentImageId?.()
|
||||||
const toolNames = ['CircleROI'] //FixedRadiusCircleROI看后期是不是要补充
|
const currentInstanceId = this.getInstanceInfo(currentImageId).instanceId
|
||||||
const candidates = []
|
const toolNames = ['CircleROI', 'FixedRadiusCircleROI']
|
||||||
|
for (const toolName of toolNames) {
|
||||||
toolNames.forEach((toolName) => {
|
|
||||||
const annotations = cornerstoneTools.annotation.state.getAnnotations(toolName, this.element) || []
|
const annotations = cornerstoneTools.annotation.state.getAnnotations(toolName, this.element) || []
|
||||||
annotations.forEach((annotation) => {
|
const selectedAnnotation = annotations.find((annotation) => {
|
||||||
if (!annotation?.data?.handles?.points?.length) return
|
if (!annotation?.highlighted) return false
|
||||||
if (currentVisitTaskId && annotation.visitTaskId && annotation.visitTaskId !== currentVisitTaskId) return
|
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)
|
const hitInfo = this.getCircleAnnotationHitInfo(annotation, canvasPoint, viewport)
|
||||||
if (!hitInfo.hit || hitInfo.score === null) return
|
return hitInfo.hit
|
||||||
|
|
||||||
candidates.push({
|
|
||||||
annotation,
|
|
||||||
score: hitInfo.score,
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
if (!candidates.length) return null
|
if (selectedAnnotation) {
|
||||||
|
return selectedAnnotation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
candidates.sort((a, b) => a.score - b.score)
|
return null
|
||||||
return candidates[0].annotation
|
|
||||||
},
|
},
|
||||||
getCircleAnnotationHitInfo(annotation, canvasPoint, viewport) {
|
getCircleAnnotationHitInfo(annotation, canvasPoint, viewport) {
|
||||||
const points = annotation?.data?.handles?.points || []
|
const points = annotation?.data?.handles?.points || []
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue