From 8c1e6c206846743b850c0bd5fb77ba3138a9ffff Mon Sep 17 00:00:00 2001 From: dmy Date: Wed, 4 Mar 2026 10:34:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E7=BB=9D=E7=BC=98?= =?UTF-8?q?=E5=AD=90=E4=B8=B2=E9=95=BF=E8=AE=A1=E7=AE=97=E4=B8=8E=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webui/src/components/Geometry.vue | 54 +++++++++++++++++++++++--- webui/src/components/ParameterForm.vue | 2 + 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/webui/src/components/Geometry.vue b/webui/src/components/Geometry.vue index 39fe898..4afac47 100644 --- a/webui/src/components/Geometry.vue +++ b/webui/src/components/Geometry.vue @@ -46,6 +46,8 @@ const props = defineProps<{ gcX: number[] // 导、地线水平坐标 [地线, 导线1, ...] hCSag: number // 导线弧垂 hGSag: number // 地线弧垂 + stringCLen: number // 导线串长 + stringGLen: number // 地线串长 groundAngels: number[] // 地面倾角 }>() @@ -61,13 +63,36 @@ const margin = { top: 40, right: 40, bottom: 60, left: 60 } const plotWidth = canvasWidth - margin.left - margin.right const plotHeight = canvasHeight - margin.top - margin.bottom +// 计算实际导地线高度(考虑弧垂和串长) +const calculateActualHeights = () => { + const hArmNums = props.hArm.map(v => Number(v)) + const hGSagNum = Number(props.hGSag) + const hCSagNum = Number(props.hCSag) + const stringGLenNum = Number(props.stringGLen) + const stringCLenNum = Number(props.stringCLen) + + // 地线实际高度 = 挂点高度 - 地线串长 - 地线弧垂 * 2/3 + // 导线实际高度 = 挂点高度 - 导线串长 - 导线弧垂 * 2/3 + return hArmNums.map((h, index) => { + if (index === 0) { + // 地线 + return h - stringGLenNum - hGSagNum * 2 / 3 + } else { + // 导线 + return h - stringCLenNum - hCSagNum * 2 / 3 + } + }) +} + // 计算坐标范围 const calculateRange = () => { // 确保将字符串转换为数字 const hArmNums = props.hArm.map(v => Number(v)) const gcXNums = props.gcX.map(v => Number(v)) + const actualHeights = calculateActualHeights() - const allHeights = [...hArmNums, 0] // 包含地面 + // 包含挂点高度和实际高度 + const allHeights = [...hArmNums, ...actualHeights, 0] const allX = [...gcXNums, -gcXNums[0] * 0.5, gcXNums[0] * 1.5] // 扩展水平范围 const yMin = 0 @@ -191,20 +216,37 @@ const draw = () => { const drawWirePoints = (range: ReturnType) => { if (!ctx) return const c = ctx + const actualHeights = calculateActualHeights() props.hArm.forEach((height, index) => { // 确保将字符串转换为数字 const heightNum = Number(height) + const actualHeight = actualHeights[index] const wireX = Number(props.gcX[index]) || 0 const isGroundWire = index === 0 const canvasX = toCanvasX(wireX, range) const canvasY = toCanvasY(heightNum, range) + const actualCanvasY = toCanvasY(actualHeight, range) - // 绘制挂点标记 + // 绘制从挂点到实际位置的虚线(绝缘子串 + 弧垂) + c.strokeStyle = isGroundWire ? '#4CAF50' : '#FF9800' + c.lineWidth = 2 + c.setLineDash([4, 4]) + c.beginPath() + c.moveTo(canvasX, canvasY) + c.lineTo(canvasX, actualCanvasY) + c.stroke() + c.setLineDash([]) + + // 绘制挂点标记(方形,表示杆塔挂点) + c.fillStyle = '#666' + c.fillRect(canvasX - 5, canvasY - 5, 10, 10) + + // 绘制实际导地线位置(圆形) c.fillStyle = isGroundWire ? '#4CAF50' : '#FF9800' c.beginPath() - c.arc(canvasX, canvasY, 8, 0, Math.PI * 2) + c.arc(canvasX, actualCanvasY, 8, 0, Math.PI * 2) c.fill() // 标注信息 @@ -213,10 +255,10 @@ const drawWirePoints = (range: ReturnType) => { c.textAlign = 'left' const labelX = canvasX + 12 - const labelY = canvasY - 8 + const labelY = actualCanvasY - 8 const wireName = isGroundWire ? '地线' : `导线${index}` - const heightLabel = `H=${heightNum}m` + const heightLabel = `H=${actualHeight.toFixed(1)}m` const xLabel = `X=${wireX}m` c.fillText(wireName, labelX, labelY) @@ -265,7 +307,7 @@ const drawGround = (range: ReturnType) => { // 监听参数变化 watch( - () => [props.hArm, props.gcX, props.hCSag, props.hGSag, props.groundAngels], + () => [props.hArm, props.gcX, props.hCSag, props.hGSag, props.stringCLen, props.stringGLen, props.groundAngels], () => { draw() }, diff --git a/webui/src/components/ParameterForm.vue b/webui/src/components/ParameterForm.vue index 158e884..a81fb30 100644 --- a/webui/src/components/ParameterForm.vue +++ b/webui/src/components/ParameterForm.vue @@ -210,6 +210,8 @@ :gc-x="params.parameter.gc_x" :h-c-sag="params.parameter.h_c_sag" :h-g-sag="params.parameter.h_g_sag" + :string-c-len="params.parameter.string_c_len" + :string-g-len="params.parameter.string_g_len" :ground-angels="params.parameter.ground_angels" />