分割视图添加直方图
continuous-integration/drone/push Build is passing Details

main
wangxiaoshuang 2026-04-08 14:58:26 +08:00
parent b1de662677
commit 5b4cc097bc
3 changed files with 1035 additions and 82 deletions

View File

@ -313,7 +313,8 @@
@dblclick="toggleFullScreen($event, index)" @click="activeViewport(index)"> @dblclick="toggleFullScreen($event, index)" @click="activeViewport(index)">
<VolumeViewport :ref="`viewport-${index}`" :data-viewport-uid="`viewport-${index}`" <VolumeViewport :ref="`viewport-${index}`" :data-viewport-uid="`viewport-${index}`"
:rendering-engine-id="renderingEngineId" :viewport-id="`viewport-${index}`" :viewport-index="index" :rendering-engine-id="renderingEngineId" :viewport-id="`viewport-${index}`" :viewport-index="index"
@activeViewport="activeViewport" @toggleTaskByViewport="toggleTaskByViewport" @previewCD="previewCD" :histogramVisible="histogramVisible" @activeViewport="activeViewport"
@toggleTaskByViewport="toggleTaskByViewport" @previewCD="previewCD"
@renderAnnotations="renderAnnotations" @contentMouseup="contentMouseup" v-if="readingTool === 3" @renderAnnotations="renderAnnotations" @contentMouseup="contentMouseup" v-if="readingTool === 3"
v-resize="(e) => handleSizeChange(e, `viewport-${index}`)" /> v-resize="(e) => handleSizeChange(e, `viewport-${index}`)" />
<Viewport :ref="`viewport-${index}`" :data-viewport-uid="`viewport-${index}`" <Viewport :ref="`viewport-${index}`" :data-viewport-uid="`viewport-${index}`"
@ -493,6 +494,9 @@
<SegmentForm ref="SegmentForm" v-if="segmentVisible" :visible.sync="segmentVisible" :visitInfo="segmentVisitInfo" <SegmentForm ref="SegmentForm" v-if="segmentVisible" :visible.sync="segmentVisible" :visitInfo="segmentVisitInfo"
@handleSegmentSave="handleSegmentSave" /> @handleSegmentSave="handleSegmentSave" />
</el-dialog> </el-dialog>
<!--直方图-->
<histogram ref="histogram" v-if="readingTool === 3" :visible.sync="histogramVisible" :activeTool.sync="activeTool"
:viewportKey="viewportKey" :rendering-engine-id="renderingEngineId" :activeViewportIndex="activeViewportIndex" />
<upload-dicom-and-nonedicom v-if="uploadImageVisible" :subject-id="uploadSubjectId" <upload-dicom-and-nonedicom v-if="uploadImageVisible" :subject-id="uploadSubjectId"
:subject-code="uploadSubjectCode" :criterion="uploadTrialCriterion" :visible.sync="uploadImageVisible" :subject-code="uploadSubjectCode" :criterion="uploadTrialCriterion" :visible.sync="uploadImageVisible"
:visit-task-id="taskId" :is-reading-task-view-in-order="isReadingTaskViewInOrder" /> :visit-task-id="taskId" :is-reading-task-view-in-order="isReadingTaskViewInOrder" />
@ -500,7 +504,6 @@
:subject-code="uploadSubjectCode" :criterion="uploadTrialCriterion" :task-id="taskId" :subject-code="uploadSubjectCode" :criterion="uploadTrialCriterion" :task-id="taskId"
:visible.sync="downloadImageVisible" /> :visible.sync="downloadImageVisible" />
<readingChart ref="readingChart" /> <readingChart ref="readingChart" />
<histogram ref="histogram" />
</div> </div>
</template> </template>
<script> <script>
@ -773,7 +776,9 @@ export default {
hasFusionUpperInitialized: false, hasFusionUpperInitialized: false,
timer: null, timer: null,
FullTimerOut: null, FullTimerOut: null,
isDelay: false isDelay: false,
histogramVisible: false
} }
}, },
computed: { computed: {
@ -866,7 +871,37 @@ export default {
this.setToolsPassive() this.setToolsPassive()
} }
} }
} },
histogramVisible: {
handler() {
if (this.readingTool !== 3) return false
this.setToolsPassive()
let viewportIds = ['viewport-0', 'viewport-1', 'viewport-2', 'viewport-3']
if (this.isMPR) {
viewportIds = ['viewport-MPR-0', 'viewport-MPR-1', 'viewport-MPR-2']
}
viewportIds.forEach(id => {
const toolGroup = ToolGroupManager.getToolGroup(id)
if (this.histogramVisible) {
toolGroup.setToolEnabled(StackScrollTool.toolName)
} else {
toolGroup.setToolActive(StackScrollTool.toolName, {
bindings: [{ mouseButton: MouseBindings.Wheel }]
})
let annotations = annotation.state.getAllAnnotations().filter(item => item.metadata.toolName.includes('histogram_'));
annotations.forEach(item => {
annotation.state.removeAnnotation(item.annotationUID)
})
for (let i = 0; i < this.cells.length; i++) {
const viewportId = `${this.viewportKey}-${i}`
const viewport = renderingEngine.getViewport(viewportId)
viewport.render()
}
}
})
}
},
}, },
mounted() { mounted() {
this.taskInfo = JSON.parse(sessionStorage.getItem('taskInfo')) this.taskInfo = JSON.parse(sessionStorage.getItem('taskInfo'))
@ -915,8 +950,10 @@ export default {
}, },
methods: { methods: {
async openHistogram() { async openHistogram() {
let res = await this.$refs.histogram.getCurrentSliceValuesFromVoxelManager(renderingEngineId, `${this.viewportKey}-${this.activeViewportIndex}`) this.histogramVisible = true
console.log(res, 'openHistogram') this.setToolsPassive()
this.$refs.histogram.init()
}, },
handleSizeChange(e, viewportId) { handleSizeChange(e, viewportId) {
// console.log('handleSizeChange', e) // console.log('handleSizeChange', e)
@ -1380,6 +1417,18 @@ export default {
toolGroup.addTool(ZoomTool.toolName) toolGroup.addTool(ZoomTool.toolName)
toolGroup.addTool(BrushTool.toolName) toolGroup.addTool(BrushTool.toolName)
if (this.readingTool === 3 || toolGroupId === this.volumeToolGroupId) { if (this.readingTool === 3 || toolGroupId === this.volumeToolGroupId) {
toolGroup.addToolInstance(
'histogram_RectangleROI',
RectangleROITool.toolName,
);
toolGroup.addToolInstance(
'histogram_CircleROI',
CircleROITool.toolName,
);
toolGroup.addToolInstance(
'histogram_PlanarFreehandROI',
PlanarFreehandROITool.toolName,
);
toolGroup.addToolInstance( toolGroup.addToolInstance(
'CircularBrush', 'CircularBrush',
BrushTool.toolName, BrushTool.toolName,
@ -1699,6 +1748,7 @@ export default {
if (this.readingTaskState === 2) return if (this.readingTaskState === 2) return
const { annotation } = e.detail const { annotation } = e.detail
if (!annotation) return if (!annotation) return
if (annotation.metadata.toolName.includes('histogram_')) return this.$refs.histogram.initToolValue(annotation)
if (annotation.metadata.toolName === 'PlanarFreehandROI' && !annotation.data.contour.closed) return if (annotation.metadata.toolName === 'PlanarFreehandROI' && !annotation.data.contour.closed) return
const series = this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].series const series = this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].series
if (series && series.TaskInfo.VisitTaskId && series.TaskInfo.VisitTaskId === this.taskInfo.VisitTaskId) { if (series && series.TaskInfo.VisitTaskId && series.TaskInfo.VisitTaskId === this.taskInfo.VisitTaskId) {
@ -1725,6 +1775,7 @@ export default {
const { annotation } = e.detail const { annotation } = e.detail
if (!annotation.highlighted) return if (!annotation.highlighted) return
if (!annotation) return if (!annotation) return
if (annotation.metadata.toolName.includes('histogram_')) return this.$refs.histogram.initToolValue(annotation)
if (annotation.metadata.toolName === 'PlanarFreehandROI' && !annotation.data.contour.closed) return if (annotation.metadata.toolName === 'PlanarFreehandROI' && !annotation.data.contour.closed) return
const series = this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].series const series = this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].series
if (series && series.TaskInfo.VisitTaskId && series.TaskInfo.VisitTaskId === this.taskInfo.VisitTaskId) { if (series && series.TaskInfo.VisitTaskId && series.TaskInfo.VisitTaskId === this.taskInfo.VisitTaskId) {
@ -1767,6 +1818,7 @@ export default {
if (this.readingTaskState === 2) return if (this.readingTaskState === 2) return
const { annotation } = e.detail const { annotation } = e.detail
if (!annotation) return if (!annotation) return
if (annotation.metadata.toolName.includes('histogram_')) return this.$refs.histogram.initToolValue(annotation)
const i = this.tools.findIndex(i => i.toolName === annotation.metadata.toolName) const i = this.tools.findIndex(i => i.toolName === annotation.metadata.toolName)
if (i === -1) { if (i === -1) {
if (annotation.metadata.toolName !== LabelMapEditWithContourTool.toolName) this.setToolsPassive() if (annotation.metadata.toolName !== LabelMapEditWithContourTool.toolName) this.setToolsPassive()
@ -1855,6 +1907,7 @@ export default {
const { annotation } = e.detail const { annotation } = e.detail
if (!annotation.highlighted) return if (!annotation.highlighted) return
if (!annotation) return if (!annotation) return
if (annotation.metadata.toolName.includes('histogram_')) return this.$refs.histogram.initToolValue(annotation)
const i = this.tools.findIndex(i => i.toolName === annotation.metadata.toolName) const i = this.tools.findIndex(i => i.toolName === annotation.metadata.toolName)
if (i === -1) { if (i === -1) {
if (annotation.metadata.toolName !== LabelMapEditWithContourTool.toolName) this.setToolsPassive() if (annotation.metadata.toolName !== LabelMapEditWithContourTool.toolName) this.setToolsPassive()
@ -2339,6 +2392,7 @@ export default {
}, },
// //
setToolActive(toolName) { setToolActive(toolName) {
if (this.histogramVisible) return false
const toolGroupId = this.isMPR ? this.volumeToolGroupId : `${this.viewportKey}-${this.activeViewportIndex}` const toolGroupId = this.isMPR ? this.volumeToolGroupId : `${this.viewportKey}-${this.activeViewportIndex}`
const toolGroup = ToolGroupManager.getToolGroup(toolGroupId) const toolGroup = ToolGroupManager.getToolGroup(toolGroupId)
if (this.activeTool === toolName) { if (this.activeTool === toolName) {
@ -2365,6 +2419,7 @@ export default {
// //
setAnnotateToolActive(toolName) { setAnnotateToolActive(toolName) {
// if (this.readingTaskState === 2) return // if (this.readingTaskState === 2) return
if (this.histogramVisible) return false
const toolObj = this.tools.find(i => i.toolName === toolName) const toolObj = this.tools.find(i => i.toolName === toolName)
if (!toolObj || toolObj.isDisabled) return if (!toolObj || toolObj.isDisabled) return
const series = this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].series const series = this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].series
@ -2434,6 +2489,7 @@ export default {
}, },
setMoreToolActive(toolName) { setMoreToolActive(toolName) {
// if (this.readingTaskState === 2) return // if (this.readingTaskState === 2) return
if (this.histogramVisible) return false
this.setToolsPassive() this.setToolsPassive()
const series = this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].series const series = this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].series
if (series && series.TaskInfo.VisitTaskId && series.TaskInfo.VisitTaskId === this.taskInfo.VisitTaskId) { if (series && series.TaskInfo.VisitTaskId && series.TaskInfo.VisitTaskId === this.taskInfo.VisitTaskId) {
@ -2706,11 +2762,13 @@ export default {
}, },
// //
scrollPage(type) { scrollPage(type) {
if (this.histogramVisible) return false
this.clipPlaying = false this.clipPlaying = false
this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].scrollPage(type) this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].scrollPage(type)
}, },
// //
toggleClipPlay(isPlay) { toggleClipPlay(isPlay) {
if (this.histogramVisible) return false
this.clipPlaying = !this.clipPlaying this.clipPlaying = !this.clipPlaying
this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].toggleClipPlay(isPlay, this.fps) this.$refs[`${this.viewportKey}-${this.activeViewportIndex}`][0].toggleClipPlay(isPlay, this.fps)
}, },
@ -2986,6 +3044,7 @@ export default {
const confirm = await this.$confirm(this.$t('trials:reading:confirm:changeStack')) const confirm = await this.$confirm(this.$t('trials:reading:confirm:changeStack'))
if (!confirm) return false if (!confirm) return false
} }
if (this.histogramVisible) this.$refs.histogram.close()
this.isFusion = false this.isFusion = false
this.setToolsPassive() this.setToolsPassive()
this.rows = 1 this.rows = 1
@ -3005,6 +3064,7 @@ export default {
}) })
} }
if (this.histogramVisible) this.$refs.histogram.close()
if (!obj.IsDicom) { if (!obj.IsDicom) {
return this.previewNoneDicoms(obj) return this.previewNoneDicoms(obj)
} }

View File

@ -96,6 +96,10 @@ export default {
type: Number, type: Number,
required: true required: true
}, },
histogramVisible: {
type: Boolean,
default: false
}
}, },
data() { data() {
return { return {
@ -183,6 +187,7 @@ export default {
this.element.addEventListener('CORNERSTONE_VOI_MODIFIED', this.voiModified) this.element.addEventListener('CORNERSTONE_VOI_MODIFIED', this.voiModified)
this.element.addEventListener('CORNERSTONE_IMAGE_RENDERED', this.imageRendered) this.element.addEventListener('CORNERSTONE_IMAGE_RENDERED', this.imageRendered)
this.element.addEventListener('wheel', (e) => { this.element.addEventListener('wheel', (e) => {
if (this.histogramVisible) return false
console.log('CORNERSTONE_STACK_VIEWPORT_SCROLL') console.log('CORNERSTONE_STACK_VIEWPORT_SCROLL')
const renderingEngine = getRenderingEngine(this.renderingEngineId) const renderingEngine = getRenderingEngine(this.renderingEngineId)
const viewport = renderingEngine.getViewport(this.viewportId) const viewport = renderingEngine.getViewport(this.viewportId)