From 2d93b7ff6a98053f8e2cf098b82078d45d823786 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Tue, 10 Oct 2023 15:39:40 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AB=99=E5=8F=B0=E5=A2=9E=E5=8A=A0=E5=85=B3?= =?UTF-8?q?=E8=81=94=E8=BD=A6=E7=AB=99=E5=92=8C=E5=AD=90=E5=B1=8F=E8=94=BD?= =?UTF-8?q?=E9=97=A8=E6=95=B0=E9=87=8F=E5=8F=AF=E5=8F=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dialogs/BatchBuildRelayCabinetOrRelay.vue | 6 +- .../draw-app/properties/PlatformProperty.vue | 50 ++++++++++++---- src/drawApp/graphics/PlatformInteraction.ts | 14 +++-- src/graphics/platform/Platform.ts | 58 +++++++++++++++---- src/graphics/relay/Relay.ts | 2 +- src/protos/stationLayoutGraphics.ts | 57 ++++++++++++------ 6 files changed, 141 insertions(+), 46 deletions(-) diff --git a/src/components/draw-app/dialogs/BatchBuildRelayCabinetOrRelay.vue b/src/components/draw-app/dialogs/BatchBuildRelayCabinetOrRelay.vue index c543382..d9df02d 100644 --- a/src/components/draw-app/dialogs/BatchBuildRelayCabinetOrRelay.vue +++ b/src/components/draw-app/dialogs/BatchBuildRelayCabinetOrRelay.vue @@ -35,7 +35,10 @@ diff --git a/src/drawApp/graphics/PlatformInteraction.ts b/src/drawApp/graphics/PlatformInteraction.ts index 36941e2..b8fed85 100644 --- a/src/drawApp/graphics/PlatformInteraction.ts +++ b/src/drawApp/graphics/PlatformInteraction.ts @@ -58,11 +58,17 @@ export class PlatformData extends GraphicDataBase implements IPlatformData { set index(v: number) { this.data.index = v; } - get refStationIndex(): number { - return this.data.refStationIndex; + get refStation(): string { + return this.data.refStation; } - set refStationIndex(v: number) { - this.data.refStationIndex = v; + set refStation(v: string) { + this.data.refStation = v; + } + get sonDoorAmount(): number { + return this.data.sonDoorAmount; + } + set sonDoorAmount(v: number) { + this.data.sonDoorAmount = v; } clone(): PlatformData { diff --git a/src/graphics/platform/Platform.ts b/src/graphics/platform/Platform.ts index 671f19c..a88626b 100644 --- a/src/graphics/platform/Platform.ts +++ b/src/graphics/platform/Platform.ts @@ -9,6 +9,7 @@ import { calculateMirrorPoint, getRectangleCenter, } from 'src/jl-graphic'; +import { Station } from '../station/Station'; export interface IPlatformData extends GraphicData { get code(): string; // 编号 @@ -19,8 +20,10 @@ export interface IPlatformData extends GraphicData { set direction(v: string); get index(): number; set index(v: number); - get refStationIndex(): number; - set refStationIndex(v: number); + get refStation(): string; // 关联的车站 + set refStation(v: string); + get sonDoorAmount(): number; //子屏蔽门的数量 + set sonDoorAmount(v: number); clone(): IPlatformData; copyFrom(data: IPlatformData): void; eq(other: IPlatformData): boolean; @@ -139,19 +142,23 @@ class smallDoorGraphic extends Container { this.addChild(this.smallDoorGraphic); this.addChild(this.labelGraphic); } - draw(direction: string, stateData: IPlatformState, i: number): void { + draw(data: IPlatformData, stateData: IPlatformState, i: number): void { + const sonDoorAmount = data?.sonDoorAmount || 30; const start = - -platformConsts.smallDoorWidth * 15 + platformConsts.smallDoorWidth * i; + (-platformConsts.smallDoorWidth * sonDoorAmount) / 2 + + platformConsts.smallDoorWidth * i; const smallDoorGraphic = this.smallDoorGraphic; const lineColor = PlatformColorEnum.doorGreen; // if (stateData.psdCut) { // lineColor = PlatformColorEnum.doorRed; // } - smallDoorGraphic.lineStyle(platformConsts.lineWidth, new Color(lineColor)); - smallDoorGraphic.moveTo(start, 0); - smallDoorGraphic.lineTo(start + platformConsts.smallDoorWidth - 3, 0); + const direction = data.direction; + smallDoorGraphic + .lineStyle(platformConsts.lineWidth, new Color(lineColor)) + .moveTo(start, 0) + .lineTo(start + platformConsts.smallDoorWidth - 3, 0); if (direction == 'down') { - this.labelGraphic.text = 30 - i; + this.labelGraphic.text = sonDoorAmount - i; } else { this.labelGraphic.text = i + 1; } @@ -167,10 +174,11 @@ export class doorGraphic extends Container { constructor() { super(); } - draw(direction: string, stateData: IPlatformState): void { - for (let i = 0; i < 30; i++) { + draw(data: IPlatformData, stateData: IPlatformState): void { + const sonDoorAmount = data?.sonDoorAmount || 30; + for (let i = 0; i < sonDoorAmount; i++) { const smallDoor = new smallDoorGraphic(); - smallDoor.draw(direction, stateData, i); + smallDoor.draw(data, stateData, i); this.addChild(smallDoor); } } @@ -423,7 +431,7 @@ export class Platform extends JlGraphic { doRepaint(): void { this.doorGraphic.clear(); if (this.datas.hasdoor) { - this.doorGraphic.draw(this.datas.direction, this.states); + this.doorGraphic.draw(this.datas, this.states); } this.platformGraphic.draw(this.states); this.emergClose.draw(); @@ -453,6 +461,32 @@ export class Platform extends JlGraphic { } // this.changeState(); } + buildRelation() { + const stationas = this.queryStore.queryByType(Station.Type); + for (let i = 0; i < stationas.length; i++) { + const sP = stationas[i].localBoundsToCanvasPoints(); + if (this.x > sP[0].x && this.x < sP[1].x) { + this.relationManage.addRelation(this, stationas[i]); + break; + } + } + } + saveRelations() { + const refStation = this.relationManage + .getRelationsOfGraphicAndOtherType(this, Station.Type) + .map((relation) => relation.getOtherGraphic(this).datas.id); + if (refStation.length) { + this.datas.refStation = refStation[0]; + } + } + loadRelations() { + if (this.datas.refStation) { + this.relationManage.addRelation( + this, + this.queryStore.queryById(this.datas.refStation) + ); + } + } // changeState(): void { // this.doorGraphic.changeState(this.states); // this.emergClose.changeState(this.id, this.states); diff --git a/src/graphics/relay/Relay.ts b/src/graphics/relay/Relay.ts index 6617da7..1cd2ad6 100644 --- a/src/graphics/relay/Relay.ts +++ b/src/graphics/relay/Relay.ts @@ -10,7 +10,7 @@ import { relayCabinetGraphicData } from 'src/protos/relayCabinetLayoutGraphics'; export interface IRelayData extends GraphicData { get code(): string; // 编号 set code(v: string); - get newModel(): relayCabinetGraphicData.Relay.ModelType; // 计轴、区段边界 + get newModel(): relayCabinetGraphicData.Relay.ModelType; // 型号 set newModel(v: relayCabinetGraphicData.Relay.ModelType); clone(): IRelayData; copyFrom(data: IRelayData): void; diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index 5799eb3..4d17b48 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -1271,7 +1271,8 @@ export namespace graphicData { hasdoor?: boolean; direction?: string; index?: number; - refStationIndex?: number; + refStation?: string; + sonDoorAmount?: number; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -1291,8 +1292,11 @@ export namespace graphicData { if ("index" in data && data.index != undefined) { this.index = data.index; } - if ("refStationIndex" in data && data.refStationIndex != undefined) { - this.refStationIndex = data.refStationIndex; + if ("refStation" in data && data.refStation != undefined) { + this.refStation = data.refStation; + } + if ("sonDoorAmount" in data && data.sonDoorAmount != undefined) { + this.sonDoorAmount = data.sonDoorAmount; } } } @@ -1329,11 +1333,17 @@ export namespace graphicData { set index(value: number) { pb_1.Message.setField(this, 5, value); } - get refStationIndex() { - return pb_1.Message.getFieldWithDefault(this, 6, 0) as number; + get refStation() { + return pb_1.Message.getFieldWithDefault(this, 8, "") as string; } - set refStationIndex(value: number) { - pb_1.Message.setField(this, 6, value); + set refStation(value: string) { + pb_1.Message.setField(this, 8, value); + } + get sonDoorAmount() { + return pb_1.Message.getFieldWithDefault(this, 9, 0) as number; + } + set sonDoorAmount(value: number) { + pb_1.Message.setField(this, 9, value); } static fromObject(data: { common?: ReturnType; @@ -1341,7 +1351,8 @@ export namespace graphicData { hasdoor?: boolean; direction?: string; index?: number; - refStationIndex?: number; + refStation?: string; + sonDoorAmount?: number; }): Platform { const message = new Platform({}); if (data.common != null) { @@ -1359,8 +1370,11 @@ export namespace graphicData { if (data.index != null) { message.index = data.index; } - if (data.refStationIndex != null) { - message.refStationIndex = data.refStationIndex; + if (data.refStation != null) { + message.refStation = data.refStation; + } + if (data.sonDoorAmount != null) { + message.sonDoorAmount = data.sonDoorAmount; } return message; } @@ -1371,7 +1385,8 @@ export namespace graphicData { hasdoor?: boolean; direction?: string; index?: number; - refStationIndex?: number; + refStation?: string; + sonDoorAmount?: number; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -1388,8 +1403,11 @@ export namespace graphicData { if (this.index != null) { data.index = this.index; } - if (this.refStationIndex != null) { - data.refStationIndex = this.refStationIndex; + if (this.refStation != null) { + data.refStation = this.refStation; + } + if (this.sonDoorAmount != null) { + data.sonDoorAmount = this.sonDoorAmount; } return data; } @@ -1407,8 +1425,10 @@ export namespace graphicData { writer.writeString(4, this.direction); if (this.index != 0) writer.writeInt32(5, this.index); - if (this.refStationIndex != 0) - writer.writeInt32(6, this.refStationIndex); + if (this.refStation.length) + writer.writeString(8, this.refStation); + if (this.sonDoorAmount != 0) + writer.writeInt32(9, this.sonDoorAmount); if (!w) return writer.getResultBuffer(); } @@ -1433,8 +1453,11 @@ export namespace graphicData { case 5: message.index = reader.readInt32(); break; - case 6: - message.refStationIndex = reader.readInt32(); + case 8: + message.refStation = reader.readString(); + break; + case 9: + message.sonDoorAmount = reader.readInt32(); break; default: reader.skipField(); }