刷选联动

This commit is contained in:
Xu Zhimeng 2024-07-24 18:45:12 +08:00
parent b214308e23
commit 221a097dba
4 changed files with 152 additions and 29 deletions

View File

@ -358,7 +358,6 @@ export default {
const { success, result, message } = await putAction('/selfStation/updateROI', formData) const { success, result, message } = await putAction('/selfStation/updateROI', formData)
if (success) { if (success) {
console.log('%c [ ]-353', 'font-size:13px; background:pink; color:#bf2c9f;', result)
const { const {
ROIOneList, ROIOneList,
ROITwoList, ROITwoList,

View File

@ -265,6 +265,9 @@ export default {
isLog: true, // log isLog: true, // log
} }
}, },
created() {
this.$bus.$on('roiLimitItemChange', this.handleLimitItemChange)
},
mounted() { mounted() {
this.opts.notMerge = true this.opts.notMerge = true
this.$nextTick(() => { this.$nextTick(() => {
@ -359,6 +362,20 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.reDrawRect() this.reDrawRect()
}) })
this.$bus.$emit('roiLimitItemUnzoom')
},
//
handleLimitItemChange(x1, x2) {
this.twoDOption.yAxis.min = x1
this.twoDOption.yAxis.max = x2
this.buildScatterList()
this.$nextTick(() => {
this.reDrawRect()
})
}, },
// Log // Log
@ -416,6 +433,8 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.reDrawRect() this.reDrawRect()
}) })
this.$bus.$emit('roiLimitItemChange', y1, y2)
} }
this.clearBrush(chart) this.clearBrush(chart)
@ -562,23 +581,24 @@ export default {
.boundary-item { .boundary-item {
position: absolute; position: absolute;
border: 1px solid transparent; border: 1px solid transparent;
pointer-events: all; overflow: visible;
&-left, &-left,
&-right { &-right {
position: absolute; position: absolute;
top: 0; top: 0;
width: 2px; width: 4px;
bottom: 0; bottom: 0;
cursor: w-resize; cursor: w-resize;
pointer-events: all;
} }
&-left { &-left {
left: 0; left: -2px;
} }
&-right { &-right {
right: 0; right: -2px;
} }
} }
} }

View File

@ -92,14 +92,16 @@
</template> </template>
</a-table> </a-table>
<!-- 表格结束 --> <!-- 表格结束 -->
</div>
</div>
<div class="figure"> <div class="figure">
<p class="title">Figure of Beta Detector Calibration</p> <p class="title">Figure of Beta Detector Calibration</p>
<div class="content"> <div class="content">
<div class="figure-chart"> <div class="figure-chart">
<custom-chart ref="figureChartRef" :option="figureChartOption" /> <custom-chart ref="figureChartRef" :option="figureChartOption" />
<a-button type="primary" size="small" @click="handleSnapshot($refs.figureChartRef)">Snapshot</a-button> <a-button type="primary" size="small" @click="handleSnapshot($refs.figureChartRef)"
>Snapshot</a-button
>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -238,8 +240,8 @@ const initialBetaGammaChartOption = {
show: false, show: false,
}, },
min: 0, min: 0,
max: 256, max: 512,
interval: 64, interval: 128,
}, },
yAxis: { yAxis: {
name: 'Gamma Channel', name: 'Gamma Channel',
@ -268,8 +270,8 @@ const initialBetaGammaChartOption = {
show: false, show: false,
}, },
min: 0, min: 0,
max: 256, max: 4096,
interval: 64, interval: 1024,
}, },
series: { series: {
type: 'scatterGL', type: 'scatterGL',
@ -585,7 +587,7 @@ export default {
gammaEnergy: [], gammaEnergy: [],
gammaGatedBetaSpectrum: [], gammaGatedBetaSpectrum: [],
gammaChannelWidth: 5, // Gamma Channel Width gammaChannelWidth: 90, // Gamma Channel Width
betaGammaInfo: {}, // channelenergy betaGammaInfo: {}, // channelenergy
markLineVisible: false, markLineVisible: false,
@ -734,8 +736,8 @@ export default {
this.currEnergy = this.gammaEnergy[yAxis][0].toPrecision(6) // Energy this.currEnergy = this.gammaEnergy[yAxis][0].toPrecision(6) // Energy
this.channelAndEnergyModel = { this.channelAndEnergyModel = {
channel: undefined, channel: yAxis,
energy: undefined, energy: this.currEnergy,
} }
this.getGammaGated(yAxis) this.getGammaGated(yAxis)
@ -754,7 +756,7 @@ export default {
result: { data }, result: { data },
message, message,
} = await getAction( } = await getAction(
'/spectrumAnalysis/getGammaGated', '/selfStation/getGammaGated',
{ {
gammaChannel, gammaChannel,
sampleId, sampleId,
@ -939,7 +941,7 @@ export default {
// reset 20231211xiao // reset 20231211xiao
const res = await postAction( const res = await postAction(
'/spectrumAnalysis/resetButton?tabName=beta&sampleFileName=' + this.newSampleData.inputFileName, '/selfStation/resetButton?tabName=beta&sampleFileName=' + this.newSampleData.inputFileName,
{} {}
) )
@ -958,7 +960,7 @@ export default {
return return
} }
try { try {
const { success, result, message } = await postAction('/spectrumAnalysis/fitting', { const { success, result, message } = await postAction('/selfStation/fitting', {
...(this.list.length <= 0 ? this.newCalibrationFuncModel : []), // list C to E 20231101xiao ...(this.list.length <= 0 ? this.newCalibrationFuncModel : []), // list C to E 20231101xiao
sampleFileName: this.newSampleData.inputFileName, sampleFileName: this.newSampleData.inputFileName,
tabName: 'beta', tabName: 'beta',
@ -1089,7 +1091,7 @@ export default {
rectHeight() { rectHeight() {
const { top, bottom } = initialBetaGammaChartOption.grid const { top, bottom } = initialBetaGammaChartOption.grid
const totalHeight = 427 - top - bottom const totalHeight = 427 - top - bottom
return (totalHeight / 256) * this.gammaChannelWidth return (totalHeight / 4096) * this.gammaChannelWidth
}, },
}, },
} }
@ -1137,7 +1139,7 @@ p {
} }
.beta-gamma-chart { .beta-gamma-chart {
height: 353px; height: 608px;
position: relative; position: relative;
.markline { .markline {

View File

@ -12,7 +12,14 @@
</div> </div>
</div> </div>
<div class="roi-limit-item-content"> <div class="roi-limit-item-content">
<custom-chart :option="option" autoresize /> <custom-chart
ref="chartRef"
:option="option"
autoresize
@zr:mousedown="handleMouseDown"
@zr:mouseup="handleMouseUp"
@brushEnd="handleBrushEnd"
/>
</div> </div>
</div> </div>
</template> </template>
@ -29,7 +36,7 @@ import {
scacLineSeries, scacLineSeries,
spectrumSeries, spectrumSeries,
} from '@/views/spectrumAnalysis/seriesBuilder' } from '@/views/spectrumAnalysis/seriesBuilder'
import { buildLineSeries, findSeriesByName } from '@/utils/chartHelper' import { buildLineSeries, findSeriesByName, getAxisMax, rangeNumber } from '@/utils/chartHelper'
const option = { const option = {
grid: { grid: {
@ -73,8 +80,9 @@ const option = {
fontSize: 12, fontSize: 12,
color: '#ade6ee', color: '#ade6ee',
}, },
min: 1, min: 0,
max: 'dataMax', max: 4096,
interval: 1024,
}, },
yAxis: { yAxis: {
type: 'log', type: 'log',
@ -109,6 +117,7 @@ const option = {
max: 'dataMax', max: 'dataMax',
}, },
series: [spectrumSeries, baseLineSeries, lcLineSeries, scacLineSeries, baseLineCtrlPoint], series: [spectrumSeries, baseLineSeries, lcLineSeries, scacLineSeries, baseLineCtrlPoint],
brush: {},
} }
export default { export default {
@ -160,10 +169,15 @@ export default {
created() { created() {
this.option.tooltip.formatter = this.handleTooltipFormat this.option.tooltip.formatter = this.handleTooltipFormat
this.option.series[0].itemStyle.color = 'yellow' this.option.series[0].itemStyle.color = 'yellow'
this.option.brush = { toolbox: [] }
this.$bus.$on('changeROILimitsYAxisType', this.changeYAxisType) this.$bus.$on('changeROILimitsYAxisType', this.changeYAxisType)
this.$bus.$on('roiLimitItemUnzoom', this.handleUnZoom)
this.$bus.$on('roiLimitItemChange', this.handleLimitItemChange)
}, },
beforeDestroy() { beforeDestroy() {
this.$bus.$off('changeROILimitsYAxisType', this.changeYAxisType) this.$bus.$off('changeROILimitsYAxisType', this.changeYAxisType)
this.$bus.$off('roiLimitItemUnzoom', this.handleUnZoom)
this.$bus.$off('roiLimitItemChange', this.handleLimitItemChange)
}, },
methods: { methods: {
handleTooltipFormat(params) { handleTooltipFormat(params) {
@ -321,6 +335,94 @@ export default {
changeYAxisType(isLog) { changeYAxisType(isLog) {
this.option.yAxis.type = isLog ? 'log' : 'value' this.option.yAxis.type = isLog ? 'log' : 'value'
}, },
getChart() {
return this.$refs.chartRef.getChartInstance()
},
//
handleMouseDown() {
this.getChart().dispatchAction({
type: 'takeGlobalCursor',
//
key: 'brush',
brushOption: {
// brush brushType false
brushType: 'rect',
},
})
},
handleMouseUp() {
this.$nextTick(() => {
this.clearBrush()
})
},
clearBrush() {
const chart = this.getChart()
//
chart.dispatchAction({
type: 'brush',
areas: [],
})
//
chart.dispatchAction({
type: 'takeGlobalCursor',
})
},
//
handleBrushEnd(param) {
const chart = this.getChart()
const areas = param.areas[0]
if (areas) {
const range = areas.range
const [[minX, maxX], [minY, maxY]] = range
const point1 = chart.convertFromPixel({ seriesIndex: 0 }, [minX, minY]).map((num) => parseInt(num.toFixed()))
const point2 = chart.convertFromPixel({ seriesIndex: 0 }, [maxX, maxY]).map((num) => parseInt(num.toFixed()))
//
const xAxisMax = getAxisMax(chart, 'xAxis')
const yAxisMax = getAxisMax(chart, 'yAxis')
//
const xAxisMin = this.option.xAxis.min
const yAxisMin = this.option.yAxis.min
let [x1, y2, x2, y1] = [...point1, ...point2] //
const xAxisLimit = rangeNumber(xAxisMin, xAxisMax)
const yAxisLimit = rangeNumber(yAxisMin, yAxisMax)
x1 = xAxisLimit(x1)
x2 = xAxisLimit(x2)
y1 = yAxisLimit(y1)
y2 = yAxisLimit(y2)
this.option.xAxis.min = x1
this.option.xAxis.max = x2
this.option.yAxis.min = y1
this.option.yAxis.max = y2
this.$bus.$emit('roiLimitItemChange', x1, x2)
}
},
handleUnZoom() {
this.option.xAxis.min = 0
this.option.xAxis.max = 4096
this.option.yAxis.min = 1
this.option.yAxis.max = 'dataMax'
},
handleLimitItemChange(x1, x2) {
this.option.xAxis.min = x1
this.option.xAxis.max = x2
},
}, },
watch: { watch: {
roiList: { roiList: {