From 6dad42231d0e1544f2a7dc76799636e213081342 Mon Sep 17 00:00:00 2001 From: fan Date: Thu, 11 Jan 2024 13:23:26 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BA=94=E7=AD=94=E5=99=A8=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/line-app/StateProperties.vue | 5 + .../line-app/states/TransponderState.vue | 209 ++++++++++++++++++ .../graphics/TransponderInteraction.ts | 114 ++-------- 3 files changed, 237 insertions(+), 91 deletions(-) create mode 100644 src/components/line-app/states/TransponderState.vue diff --git a/src/components/line-app/StateProperties.vue b/src/components/line-app/StateProperties.vue index 9ade058..d599309 100644 --- a/src/components/line-app/StateProperties.vue +++ b/src/components/line-app/StateProperties.vue @@ -25,6 +25,9 @@ + @@ -51,6 +54,8 @@ import ScreenDoorState from './states/ScreenDoorState.vue'; import { ScreenDoor } from 'src/graphics/screenDoor/ScreenDoor'; import SpksSwitchState from './states/SpksSwitchState.vue'; import { SpksSwitch } from 'src/graphics/spksSwitch/SpksSwitch'; +import TransponderState from './states/TransponderState.vue'; +import { Transponder } from 'src/graphics/transponder/Transponder'; const lineStore = useLineStore(); diff --git a/src/components/line-app/states/TransponderState.vue b/src/components/line-app/states/TransponderState.vue new file mode 100644 index 0000000..f01d4c6 --- /dev/null +++ b/src/components/line-app/states/TransponderState.vue @@ -0,0 +1,209 @@ + + diff --git a/src/drawApp/graphics/TransponderInteraction.ts b/src/drawApp/graphics/TransponderInteraction.ts index af12209..5789e9b 100644 --- a/src/drawApp/graphics/TransponderInteraction.ts +++ b/src/drawApp/graphics/TransponderInteraction.ts @@ -14,7 +14,6 @@ import { IGraphicScene, JlGraphic, MenuItemOptions, - VectorText, } from 'jl-graphic'; import { FederatedMouseEvent, DisplayObject, Graphics } from 'pixi.js'; import { useLineStore } from 'src/stores/line-store'; @@ -26,7 +25,7 @@ import { updatePositionTransponder, resetPositionTransponder, } from 'src/api/Simulation'; -import { errorNotify, successNotify } from 'src/utils/CommonNotify'; +import { errorNotify } from 'src/utils/CommonNotify'; import { state } from 'src/protos/device_state'; export class TransponderData @@ -133,7 +132,13 @@ export class TransponderState this.states.id = id; } get km(): graphicData.KilometerSystem { - return this.states.km; + return this.states.km + ? this.states.km + : new graphicData.KilometerSystem({ + coordinateSystem: '', + kilometer: 0, + direction: 0, + }); } set km(v: graphicData.KilometerSystem) { this.states.km = new graphicData.KilometerSystem(v); @@ -160,7 +165,6 @@ export class TransponderState export class TransponderOperationPlugin extends GraphicInteractionPlugin { static Name = 'transponder_operate_menu'; - private stayTimer: NodeJS.Timeout | null = null; constructor(app: IGraphicScene) { super(TransponderOperationPlugin.Name, app); app.registerMenu(TransponderOperationMenu); @@ -177,86 +181,19 @@ export class TransponderOperationPlugin extends GraphicInteractionPlugin(); - this.stayTimer = setTimeout(() => { - let type = '固定应答器'; - if (transponder?.datas.type === TransponderTypeEnum.DB) { - type = '休眠唤醒应答器'; - } else if (transponder?.datas.type === TransponderTypeEnum.WB) { - type = '休眠唤醒应答器'; - } else if (transponder?.datas.type === TransponderTypeEnum.VB) { - type = '主信号应答器'; - } else if (transponder?.datas.type === TransponderTypeEnum.IB) { - type = '预告应答器'; - } - let kilometer = ''; - if ( - transponder?.states.km && - transponder?.states.km.direction === - graphicData.KilometerSystem.Direction.LEFT - ) { - kilometer = - 'ZSSK' + - Math.floor(transponder.states.km.kilometer / 1000000) + - '+' + - ((transponder.states.km.kilometer % 1000000) / 1000).toFixed(2); - } else if ( - transponder?.states.km && - transponder?.states.km.direction === - graphicData.KilometerSystem.Direction.RIGHT - ) { - kilometer = - 'YSSK' + - Math.floor(transponder.states.km.kilometer / 1000000) + - '+' + - ((transponder.states.km.kilometer % 1000000) / 1000).toFixed(2); - } - const tipRect = new Graphics(); - const tip = new VectorText( - ` 应答器编号:${transponder?.datas.code};\n 应答器类型:${type};\n 应答器位置:${kilometer};\n 应答器报文:;\n 工作状态:应答器正常;` - ); - tip.setVectorFontSize(16); - tipRect.beginFill('#FFFF00', 1); - tipRect.drawRect(0, 0, tip.getBounds().width, tip.getBounds().height + 2); - tip.style.fill = '#000000'; - tipRect.endFill(); - transponder?.addChild(tipRect); - transponder?.addChild(tip); - if (transponder) { - transponder.zIndex = 99; - } - }, 1000); - } - onMouseLeave(e: FederatedMouseEvent) { - const target = e.target as DisplayObject; - const transponder = target.getGraphic(); - if (this.stayTimer) { - clearTimeout(this.stayTimer); - } - if (transponder && transponder.children.length > 2) { - transponder?.removeChildAt(3); - transponder?.removeChildAt(2); - transponder.zIndex = 0; - } - } + onContextMenu(e: FederatedMouseEvent) { const target = e.target as DisplayObject; const transponder = target.getGraphic(); @@ -271,9 +208,9 @@ export class TransponderOperationPlugin extends GraphicInteractionPlugin successNotify('移动应答器成功!')) - .catch((e) => errorNotify('移动应答器失败!', e)); + }).catch((e) => errorNotify('移动应答器失败!', e)); }); }; recoverPosition.handler = () => { @@ -298,13 +236,9 @@ export class TransponderOperationPlugin extends GraphicInteractionPlugin { - successNotify('复位应答器成功!'); - }) - .catch((e) => { - errorNotify('复位应答器失败!', e); - }); + }).catch((e) => { + errorNotify('复位应答器失败!', e); + }); }; modifyMessage.handler = () => { updateMessageTransponder({ @@ -319,9 +253,7 @@ export class TransponderOperationPlugin extends GraphicInteractionPlugin successNotify('重置应答器报文成功!')) - .catch((e) => errorNotify('重置应答器报文失败!', e)); + }).catch((e) => errorNotify('重置应答器报文失败!', e)); }; } }