From c478ad46aea7f90756d41aef1742245535185eb2 Mon Sep 17 00:00:00 2001 From: Xu Zhimeng Date: Mon, 14 Oct 2024 18:04:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=BB=BA=E5=8F=B0=E7=AB=99?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=84=E8=87=AA=E6=8E=A7=E5=88=B6=E5=90=84?= =?UTF-8?q?=E8=87=AAROI=E5=B1=95=E7=A4=BA=E7=8A=B6=E6=80=81=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/spectrumAnalysis/beta-analysis.vue | 4 +- .../components/BetaGammaSpectrum.vue | 110 +++++++++++------- .../components/RoiLimits/RoiLimits.vue | 14 ++- .../RoiLimits/components/RoiLimitItem.vue | 19 ++- 4 files changed, 96 insertions(+), 51 deletions(-) diff --git a/src/views/spectrumAnalysis/beta-analysis.vue b/src/views/spectrumAnalysis/beta-analysis.vue index 8ca042f..9d07754 100644 --- a/src/views/spectrumAnalysis/beta-analysis.vue +++ b/src/views/spectrumAnalysis/beta-analysis.vue @@ -230,6 +230,8 @@ export default { this.getDetailFromFile() } } + + this.$bus.$emit('resetROIRectState') }, immediate: true, deep: true, @@ -626,7 +628,7 @@ export default { const { success, message, result } = await getAction('/selfStation/saveToDB', { fileName, - comment: sampleData.data.comment + comment: sampleData.data.comment, }) if (success) { Object.entries(result).forEach(([k, v]) => { diff --git a/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue b/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue index ab09439..7062485 100644 --- a/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue +++ b/src/views/spectrumAnalysis/components/BetaGammaSpectrum.vue @@ -54,25 +54,33 @@ height: boundaryContainerPosition.height + 'px', }" > -
-
+
@@ -392,7 +400,6 @@ export default { this.buttons = buttons return { - showROI: true, startChannel: null, endChannel: null, boundaryList: [], // 最终生成的框 @@ -417,15 +424,22 @@ export default { }, btnActive: 2, + + showState: [], } }, created() { this.scatterList = [] this.boundary = [] + this.setAllShowState(true) this.$bus.$on('roiLimitItemChange', this.handleLimitItemChange) + this.$bus.$on('toggleROIRect', this.handleToggleROIRect) + this.$bus.$on('resetROIRectState', this.resetROIRectState) }, beforeDestroy() { this.$bus.$off('roiLimitItemChange', this.handleLimitItemChange) + this.$bus.$off('toggleROIRect', this.handleToggleROIRect) + this.$bus.$off('resetROIRectState', this.resetROIRectState) }, mounted() { const newOption = cloneDeep(TwoDOption) @@ -608,27 +622,23 @@ export default { height: containerBottom - containerTop, } - if (this.showROI) { - this.boundaryList = this.boundary.map((item, index) => { - const color = ColorList[index] - const [start, end] = item + this.boundaryList = this.boundary.map((item, index) => { + const color = ColorList[index] + const [start, end] = item - const [left, top] = chart.convertToPixel({ seriesIndex: 0 }, [start, 4096]) // 拿到矩形左上角坐标 - const [right, bottom] = chart.convertToPixel({ seriesIndex: 0 }, [end, 0]) // 拿到矩形右下角坐标 + const [left, top] = chart.convertToPixel({ seriesIndex: 0 }, [start, 4096]) // 拿到矩形左上角坐标 + const [right, bottom] = chart.convertToPixel({ seriesIndex: 0 }, [end, 0]) // 拿到矩形右下角坐标 - // 因为外层容器已经提供了 上/左 边距的定位,把这部分减去 - return { - borderColor: color.borderColor, - backgroundColor: color.bgColor, - top: top - containerTop, - height: bottom - top, - left: left - containerLeft, - width: right - left, - } - }) - } else { - this.boundaryList = [] - } + // 因为外层容器已经提供了 上/左 边距的定位,把这部分减去 + return { + borderColor: color.borderColor, + backgroundColor: color.bgColor, + top: top - containerTop, + height: bottom - top, + left: left - containerLeft, + width: right - left, + } + }) }, handleChartResize() { @@ -781,8 +791,12 @@ export default { // 点击ROI handleROI() { - this.showROI = !this.showROI - this.reDrawRect() + // 如果有某些Rect处于显示状态,则都隐藏 + if (this.showState.some((state) => state)) { + this.setAllShowState(false) + } else { + this.setAllShowState(true) + } }, // 矩形周边点击 @@ -876,6 +890,22 @@ export default { this.currBoundaryItem = null } }, + + setAllShowState(state) { + this.showState = new Array(4).fill(state) + }, + + // 切换显示隐藏状态 + handleToggleROIRect(index) { + this.$set(this.showState, index, !this.showState[index]) + }, + + // 重置显示隐藏状态 + resetROIRectState() { + this.setAllShowState(true) + this.boundary = [] + this.boundaryList = [] + }, }, } diff --git a/src/views/spectrumAnalysis/components/RoiLimits/RoiLimits.vue b/src/views/spectrumAnalysis/components/RoiLimits/RoiLimits.vue index 5102e57..e2bc6c0 100644 --- a/src/views/spectrumAnalysis/components/RoiLimits/RoiLimits.vue +++ b/src/views/spectrumAnalysis/components/RoiLimits/RoiLimits.vue @@ -1,14 +1,15 @@ @@ -16,7 +17,6 @@ diff --git a/src/views/spectrumAnalysis/components/RoiLimits/components/RoiLimitItem.vue b/src/views/spectrumAnalysis/components/RoiLimits/components/RoiLimitItem.vue index 2780ab6..0a048e7 100644 --- a/src/views/spectrumAnalysis/components/RoiLimits/components/RoiLimitItem.vue +++ b/src/views/spectrumAnalysis/components/RoiLimits/components/RoiLimitItem.vue @@ -1,7 +1,9 @@