From 55b650e3493e770fab4c8d5c193d426c042aea34 Mon Sep 17 00:00:00 2001 From: fan Date: Fri, 7 Jul 2023 09:25:37 +0800 Subject: [PATCH 1/6] =?UTF-8?q?message=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/protos/stationLayoutGraphics.ts | 751 +--------------------------- 1 file changed, 17 insertions(+), 734 deletions(-) diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index 5beab30..cf8fb6c 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -18,17 +18,13 @@ export namespace graphicData { signals?: Signal[]; turnouts?: Turnout[]; section?: Section[]; - stationLines?: StationLine[]; - runLines?: RunLine[]; - trainLines?: TrainLine[]; - pathLines?: PathLine[]; polygons?: Polygon[]; trainWindows?: TrainWindow[]; axleCountings?: AxleCounting[]; separators?: Separator[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("canvas" in data && data.canvas != undefined) { this.canvas = data.canvas; @@ -60,18 +56,6 @@ export namespace graphicData { if ("section" in data && data.section != undefined) { this.section = data.section; } - if ("stationLines" in data && data.stationLines != undefined) { - this.stationLines = data.stationLines; - } - if ("runLines" in data && data.runLines != undefined) { - this.runLines = data.runLines; - } - if ("trainLines" in data && data.trainLines != undefined) { - this.trainLines = data.trainLines; - } - if ("pathLines" in data && data.pathLines != undefined) { - this.pathLines = data.pathLines; - } if ("polygons" in data && data.polygons != undefined) { this.polygons = data.polygons; } @@ -149,53 +133,29 @@ export namespace graphicData { set section(value: Section[]) { pb_1.Message.setRepeatedWrapperField(this, 10, value); } - get stationLines() { - return pb_1.Message.getRepeatedWrapperField(this, StationLine, 11) as StationLine[]; - } - set stationLines(value: StationLine[]) { - pb_1.Message.setRepeatedWrapperField(this, 11, value); - } - get runLines() { - return pb_1.Message.getRepeatedWrapperField(this, RunLine, 12) as RunLine[]; - } - set runLines(value: RunLine[]) { - pb_1.Message.setRepeatedWrapperField(this, 12, value); - } - get trainLines() { - return pb_1.Message.getRepeatedWrapperField(this, TrainLine, 13) as TrainLine[]; - } - set trainLines(value: TrainLine[]) { - pb_1.Message.setRepeatedWrapperField(this, 13, value); - } - get pathLines() { - return pb_1.Message.getRepeatedWrapperField(this, PathLine, 14) as PathLine[]; - } - set pathLines(value: PathLine[]) { - pb_1.Message.setRepeatedWrapperField(this, 14, value); - } get polygons() { - return pb_1.Message.getRepeatedWrapperField(this, Polygon, 15) as Polygon[]; + return pb_1.Message.getRepeatedWrapperField(this, Polygon, 11) as Polygon[]; } set polygons(value: Polygon[]) { - pb_1.Message.setRepeatedWrapperField(this, 15, value); + pb_1.Message.setRepeatedWrapperField(this, 11, value); } get trainWindows() { - return pb_1.Message.getRepeatedWrapperField(this, TrainWindow, 16) as TrainWindow[]; + return pb_1.Message.getRepeatedWrapperField(this, TrainWindow, 12) as TrainWindow[]; } set trainWindows(value: TrainWindow[]) { - pb_1.Message.setRepeatedWrapperField(this, 16, value); + pb_1.Message.setRepeatedWrapperField(this, 12, value); } get axleCountings() { - return pb_1.Message.getRepeatedWrapperField(this, AxleCounting, 17) as AxleCounting[]; + return pb_1.Message.getRepeatedWrapperField(this, AxleCounting, 13) as AxleCounting[]; } set axleCountings(value: AxleCounting[]) { - pb_1.Message.setRepeatedWrapperField(this, 17, value); + pb_1.Message.setRepeatedWrapperField(this, 13, value); } get separators() { - return pb_1.Message.getRepeatedWrapperField(this, Separator, 18) as Separator[]; + return pb_1.Message.getRepeatedWrapperField(this, Separator, 14) as Separator[]; } set separators(value: Separator[]) { - pb_1.Message.setRepeatedWrapperField(this, 18, value); + pb_1.Message.setRepeatedWrapperField(this, 14, value); } static fromObject(data: { canvas?: ReturnType; @@ -208,10 +168,6 @@ export namespace graphicData { signals?: ReturnType[]; turnouts?: ReturnType[]; section?: ReturnType[]; - stationLines?: ReturnType[]; - runLines?: ReturnType[]; - trainLines?: ReturnType[]; - pathLines?: ReturnType[]; polygons?: ReturnType[]; trainWindows?: ReturnType[]; axleCountings?: ReturnType[]; @@ -248,18 +204,6 @@ export namespace graphicData { if (data.section != null) { message.section = data.section.map(item => Section.fromObject(item)); } - if (data.stationLines != null) { - message.stationLines = data.stationLines.map(item => StationLine.fromObject(item)); - } - if (data.runLines != null) { - message.runLines = data.runLines.map(item => RunLine.fromObject(item)); - } - if (data.trainLines != null) { - message.trainLines = data.trainLines.map(item => TrainLine.fromObject(item)); - } - if (data.pathLines != null) { - message.pathLines = data.pathLines.map(item => PathLine.fromObject(item)); - } if (data.polygons != null) { message.polygons = data.polygons.map(item => Polygon.fromObject(item)); } @@ -286,10 +230,6 @@ export namespace graphicData { signals?: ReturnType[]; turnouts?: ReturnType[]; section?: ReturnType[]; - stationLines?: ReturnType[]; - runLines?: ReturnType[]; - trainLines?: ReturnType[]; - pathLines?: ReturnType[]; polygons?: ReturnType[]; trainWindows?: ReturnType[]; axleCountings?: ReturnType[]; @@ -325,18 +265,6 @@ export namespace graphicData { if (this.section != null) { data.section = this.section.map((item: Section) => item.toObject()); } - if (this.stationLines != null) { - data.stationLines = this.stationLines.map((item: StationLine) => item.toObject()); - } - if (this.runLines != null) { - data.runLines = this.runLines.map((item: RunLine) => item.toObject()); - } - if (this.trainLines != null) { - data.trainLines = this.trainLines.map((item: TrainLine) => item.toObject()); - } - if (this.pathLines != null) { - data.pathLines = this.pathLines.map((item: PathLine) => item.toObject()); - } if (this.polygons != null) { data.polygons = this.polygons.map((item: Polygon) => item.toObject()); } @@ -375,22 +303,14 @@ export namespace graphicData { writer.writeRepeatedMessage(9, this.turnouts, (item: Turnout) => item.serialize(writer)); if (this.section.length) writer.writeRepeatedMessage(10, this.section, (item: Section) => item.serialize(writer)); - if (this.stationLines.length) - writer.writeRepeatedMessage(11, this.stationLines, (item: StationLine) => item.serialize(writer)); - if (this.runLines.length) - writer.writeRepeatedMessage(12, this.runLines, (item: RunLine) => item.serialize(writer)); - if (this.trainLines.length) - writer.writeRepeatedMessage(13, this.trainLines, (item: TrainLine) => item.serialize(writer)); - if (this.pathLines.length) - writer.writeRepeatedMessage(14, this.pathLines, (item: PathLine) => item.serialize(writer)); if (this.polygons.length) - writer.writeRepeatedMessage(15, this.polygons, (item: Polygon) => item.serialize(writer)); + writer.writeRepeatedMessage(11, this.polygons, (item: Polygon) => item.serialize(writer)); if (this.trainWindows.length) - writer.writeRepeatedMessage(16, this.trainWindows, (item: TrainWindow) => item.serialize(writer)); + writer.writeRepeatedMessage(12, this.trainWindows, (item: TrainWindow) => item.serialize(writer)); if (this.axleCountings.length) - writer.writeRepeatedMessage(17, this.axleCountings, (item: AxleCounting) => item.serialize(writer)); + writer.writeRepeatedMessage(13, this.axleCountings, (item: AxleCounting) => item.serialize(writer)); if (this.separators.length) - writer.writeRepeatedMessage(18, this.separators, (item: Separator) => item.serialize(writer)); + writer.writeRepeatedMessage(14, this.separators, (item: Separator) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -431,28 +351,16 @@ export namespace graphicData { reader.readMessage(message.section, () => pb_1.Message.addToRepeatedWrapperField(message, 10, Section.deserialize(reader), Section)); break; case 11: - reader.readMessage(message.stationLines, () => pb_1.Message.addToRepeatedWrapperField(message, 11, StationLine.deserialize(reader), StationLine)); + reader.readMessage(message.polygons, () => pb_1.Message.addToRepeatedWrapperField(message, 11, Polygon.deserialize(reader), Polygon)); break; case 12: - reader.readMessage(message.runLines, () => pb_1.Message.addToRepeatedWrapperField(message, 12, RunLine.deserialize(reader), RunLine)); + reader.readMessage(message.trainWindows, () => pb_1.Message.addToRepeatedWrapperField(message, 12, TrainWindow.deserialize(reader), TrainWindow)); break; case 13: - reader.readMessage(message.trainLines, () => pb_1.Message.addToRepeatedWrapperField(message, 13, TrainLine.deserialize(reader), TrainLine)); + reader.readMessage(message.axleCountings, () => pb_1.Message.addToRepeatedWrapperField(message, 13, AxleCounting.deserialize(reader), AxleCounting)); break; case 14: - reader.readMessage(message.pathLines, () => pb_1.Message.addToRepeatedWrapperField(message, 14, PathLine.deserialize(reader), PathLine)); - break; - case 15: - reader.readMessage(message.polygons, () => pb_1.Message.addToRepeatedWrapperField(message, 15, Polygon.deserialize(reader), Polygon)); - break; - case 16: - reader.readMessage(message.trainWindows, () => pb_1.Message.addToRepeatedWrapperField(message, 16, TrainWindow.deserialize(reader), TrainWindow)); - break; - case 17: - reader.readMessage(message.axleCountings, () => pb_1.Message.addToRepeatedWrapperField(message, 17, AxleCounting.deserialize(reader), AxleCounting)); - break; - case 18: - reader.readMessage(message.separators, () => pb_1.Message.addToRepeatedWrapperField(message, 18, Separator.deserialize(reader), Separator)); + reader.readMessage(message.separators, () => pb_1.Message.addToRepeatedWrapperField(message, 14, Separator.deserialize(reader), Separator)); break; default: reader.skipField(); } @@ -1980,145 +1888,6 @@ export namespace graphicData { return Station.deserialize(bytes); } } - export class StationLine extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | { - common?: CommonInfo; - code?: string; - hasTransfer?: boolean; - hideName?: boolean; - }) { - super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); - if (!Array.isArray(data) && typeof data == "object") { - if ("common" in data && data.common != undefined) { - this.common = data.common; - } - if ("code" in data && data.code != undefined) { - this.code = data.code; - } - if ("hasTransfer" in data && data.hasTransfer != undefined) { - this.hasTransfer = data.hasTransfer; - } - if ("hideName" in data && data.hideName != undefined) { - this.hideName = data.hideName; - } - } - } - get common() { - return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; - } - set common(value: CommonInfo) { - pb_1.Message.setWrapperField(this, 1, value); - } - get has_common() { - return pb_1.Message.getField(this, 1) != null; - } - get code() { - return pb_1.Message.getFieldWithDefault(this, 2, "") as string; - } - set code(value: string) { - pb_1.Message.setField(this, 2, value); - } - get hasTransfer() { - return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean; - } - set hasTransfer(value: boolean) { - pb_1.Message.setField(this, 3, value); - } - get hideName() { - return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean; - } - set hideName(value: boolean) { - pb_1.Message.setField(this, 4, value); - } - static fromObject(data: { - common?: ReturnType; - code?: string; - hasTransfer?: boolean; - hideName?: boolean; - }): StationLine { - const message = new StationLine({}); - if (data.common != null) { - message.common = CommonInfo.fromObject(data.common); - } - if (data.code != null) { - message.code = data.code; - } - if (data.hasTransfer != null) { - message.hasTransfer = data.hasTransfer; - } - if (data.hideName != null) { - message.hideName = data.hideName; - } - return message; - } - toObject() { - const data: { - common?: ReturnType; - code?: string; - hasTransfer?: boolean; - hideName?: boolean; - } = {}; - if (this.common != null) { - data.common = this.common.toObject(); - } - if (this.code != null) { - data.code = this.code; - } - if (this.hasTransfer != null) { - data.hasTransfer = this.hasTransfer; - } - if (this.hideName != null) { - data.hideName = this.hideName; - } - return data; - } - serialize(): Uint8Array; - serialize(w: pb_1.BinaryWriter): void; - serialize(w?: pb_1.BinaryWriter): Uint8Array | void { - const writer = w || new pb_1.BinaryWriter(); - if (this.has_common) - writer.writeMessage(1, this.common, () => this.common.serialize(writer)); - if (this.code.length) - writer.writeString(2, this.code); - if (this.hasTransfer != false) - writer.writeBool(3, this.hasTransfer); - if (this.hideName != false) - writer.writeBool(4, this.hideName); - if (!w) - return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): StationLine { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new StationLine(); - while (reader.nextField()) { - if (reader.isEndGroup()) - break; - switch (reader.getFieldNumber()) { - case 1: - reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); - break; - case 2: - message.code = reader.readString(); - break; - case 3: - message.hasTransfer = reader.readBool(); - break; - case 4: - message.hideName = reader.readBool(); - break; - default: reader.skipField(); - } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): StationLine { - return StationLine.deserialize(bytes); - } - } export class TrainWindow extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { @@ -2470,99 +2239,6 @@ export namespace graphicData { return Train.deserialize(bytes); } } - export class TrainLine extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | { - common?: CommonInfo; - code?: string; - }) { - super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); - if (!Array.isArray(data) && typeof data == "object") { - if ("common" in data && data.common != undefined) { - this.common = data.common; - } - if ("code" in data && data.code != undefined) { - this.code = data.code; - } - } - } - get common() { - return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; - } - set common(value: CommonInfo) { - pb_1.Message.setWrapperField(this, 1, value); - } - get has_common() { - return pb_1.Message.getField(this, 1) != null; - } - get code() { - return pb_1.Message.getFieldWithDefault(this, 2, "") as string; - } - set code(value: string) { - pb_1.Message.setField(this, 2, value); - } - static fromObject(data: { - common?: ReturnType; - code?: string; - }): TrainLine { - const message = new TrainLine({}); - if (data.common != null) { - message.common = CommonInfo.fromObject(data.common); - } - if (data.code != null) { - message.code = data.code; - } - return message; - } - toObject() { - const data: { - common?: ReturnType; - code?: string; - } = {}; - if (this.common != null) { - data.common = this.common.toObject(); - } - if (this.code != null) { - data.code = this.code; - } - return data; - } - serialize(): Uint8Array; - serialize(w: pb_1.BinaryWriter): void; - serialize(w?: pb_1.BinaryWriter): Uint8Array | void { - const writer = w || new pb_1.BinaryWriter(); - if (this.has_common) - writer.writeMessage(1, this.common, () => this.common.serialize(writer)); - if (this.code.length) - writer.writeString(2, this.code); - if (!w) - return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): TrainLine { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TrainLine(); - while (reader.nextField()) { - if (reader.isEndGroup()) - break; - switch (reader.getFieldNumber()) { - case 1: - reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); - break; - case 2: - message.code = reader.readString(); - break; - default: reader.skipField(); - } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): TrainLine { - return TrainLine.deserialize(bytes); - } - } export class IscsFan extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { @@ -3151,237 +2827,6 @@ export namespace graphicData { return Signal.deserialize(bytes); } } - export class RunLine extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | { - common?: CommonInfo; - code?: string; - points?: Point[]; - nameColor?: string; - nameBgColor?: string; - containSta?: string[]; - linkPathLines?: string[]; - lineId?: string; - }) { - super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 8, 9], this.#one_of_decls); - if (!Array.isArray(data) && typeof data == "object") { - if ("common" in data && data.common != undefined) { - this.common = data.common; - } - if ("code" in data && data.code != undefined) { - this.code = data.code; - } - if ("points" in data && data.points != undefined) { - this.points = data.points; - } - if ("nameColor" in data && data.nameColor != undefined) { - this.nameColor = data.nameColor; - } - if ("nameBgColor" in data && data.nameBgColor != undefined) { - this.nameBgColor = data.nameBgColor; - } - if ("containSta" in data && data.containSta != undefined) { - this.containSta = data.containSta; - } - if ("linkPathLines" in data && data.linkPathLines != undefined) { - this.linkPathLines = data.linkPathLines; - } - if ("lineId" in data && data.lineId != undefined) { - this.lineId = data.lineId; - } - } - } - get common() { - return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; - } - set common(value: CommonInfo) { - pb_1.Message.setWrapperField(this, 1, value); - } - get has_common() { - return pb_1.Message.getField(this, 1) != null; - } - get code() { - return pb_1.Message.getFieldWithDefault(this, 2, "") as string; - } - set code(value: string) { - pb_1.Message.setField(this, 2, value); - } - get points() { - return pb_1.Message.getRepeatedWrapperField(this, Point, 3) as Point[]; - } - set points(value: Point[]) { - pb_1.Message.setRepeatedWrapperField(this, 3, value); - } - get nameColor() { - return pb_1.Message.getFieldWithDefault(this, 4, "") as string; - } - set nameColor(value: string) { - pb_1.Message.setField(this, 4, value); - } - get nameBgColor() { - return pb_1.Message.getFieldWithDefault(this, 5, "") as string; - } - set nameBgColor(value: string) { - pb_1.Message.setField(this, 5, value); - } - get containSta() { - return pb_1.Message.getFieldWithDefault(this, 8, []) as string[]; - } - set containSta(value: string[]) { - pb_1.Message.setField(this, 8, value); - } - get linkPathLines() { - return pb_1.Message.getFieldWithDefault(this, 9, []) as string[]; - } - set linkPathLines(value: string[]) { - pb_1.Message.setField(this, 9, value); - } - get lineId() { - return pb_1.Message.getFieldWithDefault(this, 10, "") as string; - } - set lineId(value: string) { - pb_1.Message.setField(this, 10, value); - } - static fromObject(data: { - common?: ReturnType; - code?: string; - points?: ReturnType[]; - nameColor?: string; - nameBgColor?: string; - containSta?: string[]; - linkPathLines?: string[]; - lineId?: string; - }): RunLine { - const message = new RunLine({}); - if (data.common != null) { - message.common = CommonInfo.fromObject(data.common); - } - if (data.code != null) { - message.code = data.code; - } - if (data.points != null) { - message.points = data.points.map(item => Point.fromObject(item)); - } - if (data.nameColor != null) { - message.nameColor = data.nameColor; - } - if (data.nameBgColor != null) { - message.nameBgColor = data.nameBgColor; - } - if (data.containSta != null) { - message.containSta = data.containSta; - } - if (data.linkPathLines != null) { - message.linkPathLines = data.linkPathLines; - } - if (data.lineId != null) { - message.lineId = data.lineId; - } - return message; - } - toObject() { - const data: { - common?: ReturnType; - code?: string; - points?: ReturnType[]; - nameColor?: string; - nameBgColor?: string; - containSta?: string[]; - linkPathLines?: string[]; - lineId?: string; - } = {}; - if (this.common != null) { - data.common = this.common.toObject(); - } - if (this.code != null) { - data.code = this.code; - } - if (this.points != null) { - data.points = this.points.map((item: Point) => item.toObject()); - } - if (this.nameColor != null) { - data.nameColor = this.nameColor; - } - if (this.nameBgColor != null) { - data.nameBgColor = this.nameBgColor; - } - if (this.containSta != null) { - data.containSta = this.containSta; - } - if (this.linkPathLines != null) { - data.linkPathLines = this.linkPathLines; - } - if (this.lineId != null) { - data.lineId = this.lineId; - } - return data; - } - serialize(): Uint8Array; - serialize(w: pb_1.BinaryWriter): void; - serialize(w?: pb_1.BinaryWriter): Uint8Array | void { - const writer = w || new pb_1.BinaryWriter(); - if (this.has_common) - writer.writeMessage(1, this.common, () => this.common.serialize(writer)); - if (this.code.length) - writer.writeString(2, this.code); - if (this.points.length) - writer.writeRepeatedMessage(3, this.points, (item: Point) => item.serialize(writer)); - if (this.nameColor.length) - writer.writeString(4, this.nameColor); - if (this.nameBgColor.length) - writer.writeString(5, this.nameBgColor); - if (this.containSta.length) - writer.writeRepeatedString(8, this.containSta); - if (this.linkPathLines.length) - writer.writeRepeatedString(9, this.linkPathLines); - if (this.lineId.length) - writer.writeString(10, this.lineId); - if (!w) - return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): RunLine { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new RunLine(); - while (reader.nextField()) { - if (reader.isEndGroup()) - break; - switch (reader.getFieldNumber()) { - case 1: - reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); - break; - case 2: - message.code = reader.readString(); - break; - case 3: - reader.readMessage(message.points, () => pb_1.Message.addToRepeatedWrapperField(message, 3, Point.deserialize(reader), Point)); - break; - case 4: - message.nameColor = reader.readString(); - break; - case 5: - message.nameBgColor = reader.readString(); - break; - case 8: - pb_1.Message.addToRepeatedField(message, 8, reader.readString()); - break; - case 9: - pb_1.Message.addToRepeatedField(message, 9, reader.readString()); - break; - case 10: - message.lineId = reader.readString(); - break; - default: reader.skipField(); - } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): RunLine { - return RunLine.deserialize(bytes); - } - } export class Section extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { @@ -3719,168 +3164,6 @@ export namespace graphicData { return KilometerPoint.deserialize(bytes); } } - export class PathLine extends pb_1.Message { - #one_of_decls: number[][] = []; - constructor(data?: any[] | { - common?: CommonInfo; - code?: string; - points?: Point[]; - isUp?: boolean; - kilometerPoints?: KilometerPoint[]; - }) { - super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 5], this.#one_of_decls); - if (!Array.isArray(data) && typeof data == "object") { - if ("common" in data && data.common != undefined) { - this.common = data.common; - } - if ("code" in data && data.code != undefined) { - this.code = data.code; - } - if ("points" in data && data.points != undefined) { - this.points = data.points; - } - if ("isUp" in data && data.isUp != undefined) { - this.isUp = data.isUp; - } - if ("kilometerPoints" in data && data.kilometerPoints != undefined) { - this.kilometerPoints = data.kilometerPoints; - } - } - } - get common() { - return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; - } - set common(value: CommonInfo) { - pb_1.Message.setWrapperField(this, 1, value); - } - get has_common() { - return pb_1.Message.getField(this, 1) != null; - } - get code() { - return pb_1.Message.getFieldWithDefault(this, 2, "") as string; - } - set code(value: string) { - pb_1.Message.setField(this, 2, value); - } - get points() { - return pb_1.Message.getRepeatedWrapperField(this, Point, 3) as Point[]; - } - set points(value: Point[]) { - pb_1.Message.setRepeatedWrapperField(this, 3, value); - } - get isUp() { - return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean; - } - set isUp(value: boolean) { - pb_1.Message.setField(this, 4, value); - } - get kilometerPoints() { - return pb_1.Message.getRepeatedWrapperField(this, KilometerPoint, 5) as KilometerPoint[]; - } - set kilometerPoints(value: KilometerPoint[]) { - pb_1.Message.setRepeatedWrapperField(this, 5, value); - } - static fromObject(data: { - common?: ReturnType; - code?: string; - points?: ReturnType[]; - isUp?: boolean; - kilometerPoints?: ReturnType[]; - }): PathLine { - const message = new PathLine({}); - if (data.common != null) { - message.common = CommonInfo.fromObject(data.common); - } - if (data.code != null) { - message.code = data.code; - } - if (data.points != null) { - message.points = data.points.map(item => Point.fromObject(item)); - } - if (data.isUp != null) { - message.isUp = data.isUp; - } - if (data.kilometerPoints != null) { - message.kilometerPoints = data.kilometerPoints.map(item => KilometerPoint.fromObject(item)); - } - return message; - } - toObject() { - const data: { - common?: ReturnType; - code?: string; - points?: ReturnType[]; - isUp?: boolean; - kilometerPoints?: ReturnType[]; - } = {}; - if (this.common != null) { - data.common = this.common.toObject(); - } - if (this.code != null) { - data.code = this.code; - } - if (this.points != null) { - data.points = this.points.map((item: Point) => item.toObject()); - } - if (this.isUp != null) { - data.isUp = this.isUp; - } - if (this.kilometerPoints != null) { - data.kilometerPoints = this.kilometerPoints.map((item: KilometerPoint) => item.toObject()); - } - return data; - } - serialize(): Uint8Array; - serialize(w: pb_1.BinaryWriter): void; - serialize(w?: pb_1.BinaryWriter): Uint8Array | void { - const writer = w || new pb_1.BinaryWriter(); - if (this.has_common) - writer.writeMessage(1, this.common, () => this.common.serialize(writer)); - if (this.code.length) - writer.writeString(2, this.code); - if (this.points.length) - writer.writeRepeatedMessage(3, this.points, (item: Point) => item.serialize(writer)); - if (this.isUp != false) - writer.writeBool(4, this.isUp); - if (this.kilometerPoints.length) - writer.writeRepeatedMessage(5, this.kilometerPoints, (item: KilometerPoint) => item.serialize(writer)); - if (!w) - return writer.getResultBuffer(); - } - static deserialize(bytes: Uint8Array | pb_1.BinaryReader): PathLine { - const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new PathLine(); - while (reader.nextField()) { - if (reader.isEndGroup()) - break; - switch (reader.getFieldNumber()) { - case 1: - reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); - break; - case 2: - message.code = reader.readString(); - break; - case 3: - reader.readMessage(message.points, () => pb_1.Message.addToRepeatedWrapperField(message, 3, Point.deserialize(reader), Point)); - break; - case 4: - message.isUp = reader.readBool(); - break; - case 5: - reader.readMessage(message.kilometerPoints, () => pb_1.Message.addToRepeatedWrapperField(message, 5, KilometerPoint.deserialize(reader), KilometerPoint)); - break; - default: reader.skipField(); - } - } - return message; - } - serializeBinary(): Uint8Array { - return this.serialize(); - } - static deserializeBinary(bytes: Uint8Array): PathLine { - return PathLine.deserialize(bytes); - } - } export class RelatedRef extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { From 1aaf0f6da002adb7613e0adca7d67dac5e3265b1 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Fri, 7 Jul 2023 09:27:18 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/boot/axios.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/boot/axios.ts b/src/boot/axios.ts index 3fe93a6..414e620 100644 --- a/src/boot/axios.ts +++ b/src/boot/axios.ts @@ -66,7 +66,7 @@ export class ApiError { // "export default () => {}" function below (which runs individually // for each client) const api = axios.create({ baseURL: getHttpBase() }); - +let isOpenDialog = false; // 认证弹窗是否打开 export default boot(({ app, router }) => { // for use inside Vue files (Options API) through this.$axios and this.$api @@ -86,14 +86,20 @@ export default boot(({ app, router }) => { return response; }, (err) => { - if (err.response && err.response.status === 401) { + if (err.response && err.response.status === 401 && !isOpenDialog) { + isOpenDialog = true; Dialog.create({ title: '认证失败', message: '认证失败或登录超时,请重新登录', persistent: true, - }).onOk(() => { - router.push({ name: 'login' }); - }); + }) + .onOk(() => { + router.push({ name: 'login' }); + isOpenDialog = false; + }) + .onCancel(() => { + isOpenDialog = false; + }); } return Promise.reject(ApiError.from(err)); } From 6e38d31bd2ec0b2365c152097b144180ecc410d3 Mon Sep 17 00:00:00 2001 From: fan Date: Fri, 7 Jul 2023 16:05:17 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=A2=9E=E5=8A=A0link?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- graphic-pixi | 2 +- src/components/draw-app/DrawProperties.vue | 5 + .../properties/SectionLinkProperty.vue | 44 +++++ .../graphics/SectionLinkInteraction.ts | 58 ++++++ src/drawApp/index.ts | 28 +++ src/graphics/sectionLink/SectionLink.ts | 106 ++++++++++ .../sectionLink/SectionLinkDrawAssistant.ts | 183 ++++++++++++++++++ src/layouts/DrawLayout.vue | 12 ++ src/protos/stationLayoutGraphics.ts | 164 +++++++++++++++- 9 files changed, 600 insertions(+), 2 deletions(-) create mode 100644 src/components/draw-app/properties/SectionLinkProperty.vue create mode 100644 src/drawApp/graphics/SectionLinkInteraction.ts create mode 100644 src/graphics/sectionLink/SectionLink.ts create mode 100644 src/graphics/sectionLink/SectionLinkDrawAssistant.ts diff --git a/graphic-pixi b/graphic-pixi index 1f30264..0a0cb0a 160000 --- a/graphic-pixi +++ b/graphic-pixi @@ -1 +1 @@ -Subproject commit 1f302648b5a71a82b798b77fe238c5fc6e3081b4 +Subproject commit 0a0cb0a77afd9783081c2dc6ba19687b0b3aa0f7 diff --git a/src/components/draw-app/DrawProperties.vue b/src/components/draw-app/DrawProperties.vue index 32b0b66..5dd68cb 100644 --- a/src/components/draw-app/DrawProperties.vue +++ b/src/components/draw-app/DrawProperties.vue @@ -72,6 +72,9 @@ + @@ -96,6 +99,7 @@ import SignalProperty from './properties/SignalProperty.vue'; import TurnoutProperty from './properties/TurnoutProperty.vue'; import SectionProperty from './properties/SectionProperty.vue'; import SeparatorProperty from './properties/SeparatorProperty.vue'; +import SectionLinkProperty from './properties/SectionLinkProperty.vue'; import { Link } from 'src/graphics/link/Link'; import { Rect } from 'src/graphics/rect/Rect'; import { Platform } from 'src/graphics/platform/Platform'; @@ -108,6 +112,7 @@ import { Section } from 'src/graphics/section/Section'; import { TrainWindow } from 'src/graphics/trainWindow/TrainWindow'; import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting'; import { Separator } from 'src/graphics/separator/Separator'; +import { SectionLink } from 'src/graphics/sectionLink/SectionLink'; const drawStore = useDrawStore(); diff --git a/src/components/draw-app/properties/SectionLinkProperty.vue b/src/components/draw-app/properties/SectionLinkProperty.vue new file mode 100644 index 0000000..1052c01 --- /dev/null +++ b/src/components/draw-app/properties/SectionLinkProperty.vue @@ -0,0 +1,44 @@ + + + diff --git a/src/drawApp/graphics/SectionLinkInteraction.ts b/src/drawApp/graphics/SectionLinkInteraction.ts new file mode 100644 index 0000000..c7d0d38 --- /dev/null +++ b/src/drawApp/graphics/SectionLinkInteraction.ts @@ -0,0 +1,58 @@ +import * as pb_1 from 'google-protobuf'; +import { GraphicDataBase } from './GraphicDataBase'; +import { + ISectionLinkData, + SectionLink, +} from 'src/graphics/sectionLink/SectionLink'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { IPointData } from 'pixi.js'; + +export class SectionLinkData + extends GraphicDataBase + implements ISectionLinkData +{ + constructor(data?: graphicData.SectionLink) { + let sectionLink; + if (!data) { + sectionLink = new graphicData.SectionLink({ + common: GraphicDataBase.defaultCommonInfo(SectionLink.Type), + }); + } else { + sectionLink = data; + } + super(sectionLink); + } + public get data(): graphicData.SectionLink { + return this.getData(); + } + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + get points(): IPointData[] { + return this.data.points; + } + set points(points: IPointData[]) { + this.data.points = points.map( + (p) => new graphicData.Point({ x: p.x, y: p.y }) + ); + } + get refDevice(): string { + return this.data.refDevice; + } + set refDevice(v: string) { + this.data.refDevice = v; + } + + clone(): SectionLinkData { + return new SectionLinkData(this.data.cloneMessage()); + } + copyFrom(data: SectionLinkData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: SectionLinkData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 686f00c..ae76f16 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -59,6 +59,12 @@ import { toStorageTransform } from './graphics/GraphicDataBase'; import { SeparatorDraw } from 'src/graphics/separator/SeparatorDrawAssistant'; import { Separator, SeparatorTemplate } from 'src/graphics/separator/Separator'; import { SeparatorData } from './graphics/SeparatorInteraction'; +import { + SectionLink, + SectionLinkTemplate, +} from 'src/graphics/sectionLink/SectionLink'; +import { SectionLinkDraw } from 'src/graphics/sectionLink/SectionLinkDrawAssistant'; +import { SectionLinkData } from './graphics/SectionLinkInteraction'; // export function fromStoragePoint(p: graphicData.Point): Point { // return new Point(p.x, p.y); @@ -164,6 +170,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { | OneClickGenerateDraw | AxleCountingDraw | SeparatorDraw + | SectionLinkDraw )[] = []; if (draftType === 'Line') { drawAssistants = [ @@ -189,6 +196,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { new AxleCountingTemplate(new AxleCountingData()) ), new SeparatorDraw(app, new SeparatorTemplate(new SeparatorData())), + new SectionLinkDraw(app, new SectionLinkTemplate(new SectionLinkData())), ]; DrawSignalInteraction.init(app); } @@ -207,6 +215,11 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { const trainWindows = app.queryStore.queryByType( TrainWindow.Type ); + const sections = app.queryStore.queryByType
(Section.Type); + const sectionLinks = app.queryStore.queryByType( + SectionLink.Type + ); + const turnouts = app.queryStore.queryByType(Turnout.Type); UndoOptions.handler = () => { app.opRecord.undo(); }; @@ -220,6 +233,15 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { axleCountings.forEach((axleCounting) => { axleCounting.visible = false; }); + sections.forEach((section) => { + section.visible = false; + }); + sectionLinks.forEach((sectionLink) => { + sectionLink.visible = true; + }); + turnouts.forEach((turnout) => { + turnout.visible = false; + }); }; twoLayerOptions.handler = () => { trainWindows.forEach((trainWindow) => { @@ -308,6 +330,9 @@ export function saveDrawDatas(app: JlDrawApp) { } else if (Separator.Type === g.type) { const separatorData = (g as Separator).saveData(); storage.separators.push((separatorData as SeparatorData).data); + } else if (SectionLink.Type === g.type) { + const sectionLinkData = (g as SectionLink).saveData(); + storage.sectionLinks.push((sectionLinkData as SectionLinkData).data); } }); const base64 = fromUint8Array(storage.serialize()); @@ -366,6 +391,9 @@ export async function loadDrawDatas(app: GraphicApp) { storage.separators.forEach((separator) => { datas.push(new SeparatorData(separator)); }); + storage.sectionLinks.forEach((sectionLink) => { + datas.push(new SectionLinkData(sectionLink)); + }); app.loadGraphic(datas); } else { app.loadGraphic([]); diff --git a/src/graphics/sectionLink/SectionLink.ts b/src/graphics/sectionLink/SectionLink.ts new file mode 100644 index 0000000..5be55ea --- /dev/null +++ b/src/graphics/sectionLink/SectionLink.ts @@ -0,0 +1,106 @@ +import { Graphics, IPointData } from 'pixi.js'; +import { + GraphicData, + JlGraphic, + JlGraphicTemplate, + VectorText, + IChildTransform, +} from 'src/jl-graphic'; +import { ILineGraphic } from 'src/jl-graphic/plugins/GraphicEditPlugin'; + +export interface ISectionLinkData extends GraphicData { + get code(): string; // 编号 + set code(v: string); + get points(): IPointData[]; + set points(points: IPointData[]); + get refDevice(): string; + set refDevice(v: string); + clone(): ISectionLinkData; + copyFrom(data: ISectionLinkData): void; + eq(other: ISectionLinkData): boolean; +} + +export const SectionLinkConsts = { + lineColor: 0x5578b6, + lineWidth: 5, +}; + +export class SectionLink extends JlGraphic implements ILineGraphic { + static Type = 'SectionLink'; + lineGraphic: Graphics; + labelGraphic: VectorText; + + constructor() { + super(SectionLink.Type); + this.lineGraphic = new Graphics(); + this.labelGraphic = new VectorText(); + this.labelGraphic.setVectorFontSize(14); + this.labelGraphic.anchor.set(0.5); + this.labelGraphic.style.fill = '#0f0'; + this.labelGraphic.transformSave = true; + this.labelGraphic.name = 'label'; + this.transformSave = true; + this.addChild(this.lineGraphic); + this.addChild(this.labelGraphic); + } + + doRepaint() { + if (this.datas.points.length < 2) { + throw new Error('SectionLink坐标数据异常'); + } + + this.lineGraphic.clear(); + this.lineGraphic.lineStyle( + SectionLinkConsts.lineWidth, + SectionLinkConsts.lineColor + ); + this.datas.points.forEach((p, i) => { + if (i !== 0) { + this.lineGraphic.lineTo(p.x, p.y); + } else { + this.lineGraphic.moveTo(p.x, p.y); + } + }); + this.labelGraphic.text = this.datas.code; + const labelPosition = this.datas?.childTransforms?.find( + (item: IChildTransform) => item.name === this.labelGraphic.name + )?.transform.position; + if (labelPosition) { + this.labelGraphic.position.set(labelPosition.x, labelPosition.y); + } else { + this.labelGraphic.position.set( + this.datas.points[0].x, + this.datas.points[0].y + 20 + ); + } + } + + getStartPoint() { + return this.datas.points[0]; + } + getEndPoint(): IPointData { + return this.datas.points[this.datas.points.length - 1]; + } + + get datas(): ISectionLinkData { + return this.getDatas(); + } + + get linePoints(): IPointData[] { + return this.datas.points; + } + set linePoints(points: IPointData[]) { + const old = this.datas.clone(); + old.points = points; + this.updateData(old); + } +} + +export class SectionLinkTemplate extends JlGraphicTemplate { + constructor(dataTemplate: ISectionLinkData) { + super(SectionLink.Type, { dataTemplate }); + } + new() { + return new SectionLink(); + } +} diff --git a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts new file mode 100644 index 0000000..8856825 --- /dev/null +++ b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts @@ -0,0 +1,183 @@ +import { + GraphicApp, + GraphicDrawAssistant, + GraphicInteractionPlugin, + JlDrawApp, + JlGraphic, + linePoint, + GraphicIdGenerator, +} from 'src/jl-graphic'; +import { + ISectionLinkData, + SectionLink, + SectionLinkConsts, + SectionLinkTemplate, +} from './SectionLink'; +import { + DisplayObject, + FederatedMouseEvent, + Graphics, + IHitArea, + IPointData, + Point, +} from 'pixi.js'; +import { Section } from '../section/Section'; +import { Turnout } from '../turnout/Turnout'; + +export class SectionLinkDraw extends GraphicDrawAssistant< + SectionLinkTemplate, + ISectionLinkData +> { + points: Point[] = []; + graphic = new Graphics(); + + constructor(app: JlDrawApp, template: SectionLinkTemplate) { + super(app, template, 'sym_o_timeline', '不展示'); + this.container.addChild(this.graphic); + + SectionLinkEditPlugin.init(app, this); + } + + onRightClick(): void { + this.createAndStore(true); + } + + redraw(cp: Point): void { + if (this.points.length < 1) return; + this.graphic.clear(); + this.graphic.lineStyle( + SectionLinkConsts.lineWidth, + SectionLinkConsts.lineColor + ); + this.points.forEach((p, i) => { + if (i !== 0) { + this.graphic.lineTo(p.x, p.y); + } else { + this.graphic.moveTo(p.x, p.y); + } + }); + this.graphic.lineTo(cp.x, cp.y); + console.log(cp, '000'); + } + + prepareData(data: ISectionLinkData): boolean { + console.log(this.points, '000'); + data.points = this.points; + return true; + } + oneGenerates() { + // localToCanvasPoints + const sectionList = this.app.queryStore.queryByType
(Section.Type); + const turnoutList = this.app.queryStore.queryByType(Turnout.Type); + console.log(sectionList.length, turnoutList.length); + sectionList.forEach((section: Section) => { + const sectionLink = new SectionLink(); + sectionLink.loadData(this.graphicTemplate.datas); + sectionLink.id = GraphicIdGenerator.next(); + const points: IPointData[] = []; + section.datas.points.forEach((p) => { + points.push(section.localToCanvasPoint(p)); + }); + sectionLink.datas.points = points; + this.storeGraphic(sectionLink); + }); + turnoutList.forEach((turnout: Turnout) => { + const sectionLinkA = new SectionLink(); + const sectionLinkB = new SectionLink(); + const sectionLinkC = new SectionLink(); + sectionLinkA.loadData(this.graphicTemplate.datas); + sectionLinkB.loadData(this.graphicTemplate.datas); + sectionLinkC.loadData(this.graphicTemplate.datas); + const forkP = new Point(turnout.position.x, turnout.position.y); + const pointA = [forkP]; + const pointB = [forkP]; + const pointC = [forkP]; + turnout.datas.pointA.forEach((p) => { + pointA.push(turnout.localToCanvasPoint(p)); + }); + turnout.datas.pointB.forEach((p) => { + pointB.push(turnout.localToCanvasPoint(p)); + }); + turnout.datas.pointC.forEach((p) => { + pointC.push(turnout.localToCanvasPoint(p)); + }); + sectionLinkA.id = GraphicIdGenerator.next(); + sectionLinkB.id = GraphicIdGenerator.next(); + sectionLinkC.id = GraphicIdGenerator.next(); + sectionLinkA.datas.points = pointA; + sectionLinkB.datas.points = pointB; + sectionLinkC.datas.points = pointC; + this.storeGraphic(sectionLinkA); + this.storeGraphic(sectionLinkB); + this.storeGraphic(sectionLinkC); + }); + } + clearCache(): void { + this.points = []; + this.graphic.clear(); + } +} + +class SectionLinkGraphicHitArea implements IHitArea { + section: SectionLink; + constructor(section: SectionLink) { + this.section = section; + } + contains(x: number, y: number): boolean { + for (let i = 1; i < this.section.datas.points.length; i++) { + const p1 = this.section.datas.points[i - 1]; + const p2 = this.section.datas.points[i]; + if (linePoint(p1, p2, { x, y }, SectionLinkConsts.lineWidth)) { + return true; + } + } + return false; + } +} + +export class SectionLinkEditPlugin extends GraphicInteractionPlugin { + static Name = 'SectionLinkDrag'; + drawAssistant: SectionLinkDraw; + + constructor(app: GraphicApp, da: SectionLinkDraw) { + super(SectionLinkEditPlugin.Name, app); + this.drawAssistant = da; + } + static init(app: GraphicApp, da: SectionLinkDraw) { + return new SectionLinkEditPlugin(app, da); + } + filter(...grahpics: JlGraphic[]): SectionLink[] | undefined { + return grahpics.filter((g) => g.type == SectionLink.Type) as SectionLink[]; + } + bind(g: SectionLink): void { + g.lineGraphic.eventMode = 'static'; + g.lineGraphic.cursor = 'pointer'; + g.lineGraphic.hitArea = new SectionLinkGraphicHitArea(g); + // g.transformSave = true; + // g.labelGraphic.eventMode = 'static'; + // g.labelGraphic.cursor = 'pointer'; + // g.labelGraphic.selectable = true; + // g.labelGraphic.draggable = true; + // g.on('selected', this.onSelected, this); + // g.on('unselected', this.onUnselected, this); + // g.on('_rightclick', this.onContextMenu, this); + } + unbind(g: SectionLink): void { + // g.off('selected', this.onSelected, this); + // g.off('unselected', this.onUnselected, this); + // g.off('_rightclick', this.onContextMenu, this); + } + + // onContextMenu(e: FederatedMouseEvent) { + // const target = e.target as DisplayObject; + // const section = target.getGraphic() as SectionLink; + // this.app.updateSelected(section); + // } + + // onSelected(g: DisplayObject): void { + // const sectionLink = g as SectionLink; + // } + // onUnselected(g: DisplayObject): void { + // const sectionLink = g as SectionLink; + // } +} diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index e6b6726..dcec201 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -24,6 +24,9 @@ 一键生成计轴 + + 一键生成Link + @@ -186,6 +189,8 @@ import { ApiError } from 'src/boot/axios'; import { OneClickGenerate } from 'src/graphics/trainWindow/oneClickDrawAssistant'; import { Separator } from 'src/graphics/separator/Separator'; import { SeparatorDraw } from 'src/graphics/separator/SeparatorDrawAssistant'; +import { SectionLink } from 'src/graphics/sectionLink/SectionLink'; +import { SectionLinkDraw } from 'src/graphics/sectionLink/SectionLinkDrawAssistant'; const route = useRoute(); const router = useRouter(); @@ -328,6 +333,13 @@ function oneClickAxleCounting() { drawStore.oneClickType = 'AxleCounting'; drawStore.getDrawApp().interactionPlugin(OneClickGenerate.Type).resume(); } +function oneClickLink() { + drawStore.oneClickType = 'SectionLink'; + const draw = drawStore + .getDrawApp() + .getDrawAssistant(SectionLink.Type) as SectionLinkDraw; + draw.oneGenerates(); +} function backConfirm() { router.go(-1); diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index cf8fb6c..0787ebe 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -22,9 +22,10 @@ export namespace graphicData { trainWindows?: TrainWindow[]; axleCountings?: AxleCounting[]; separators?: Separator[]; + sectionLinks?: SectionLink[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("canvas" in data && data.canvas != undefined) { this.canvas = data.canvas; @@ -68,6 +69,9 @@ export namespace graphicData { if ("separators" in data && data.separators != undefined) { this.separators = data.separators; } + if ("sectionLinks" in data && data.sectionLinks != undefined) { + this.sectionLinks = data.sectionLinks; + } } } get canvas() { @@ -157,6 +161,12 @@ export namespace graphicData { set separators(value: Separator[]) { pb_1.Message.setRepeatedWrapperField(this, 14, value); } + get sectionLinks() { + return pb_1.Message.getRepeatedWrapperField(this, SectionLink, 15) as SectionLink[]; + } + set sectionLinks(value: SectionLink[]) { + pb_1.Message.setRepeatedWrapperField(this, 15, value); + } static fromObject(data: { canvas?: ReturnType; links?: ReturnType[]; @@ -172,6 +182,7 @@ export namespace graphicData { trainWindows?: ReturnType[]; axleCountings?: ReturnType[]; separators?: ReturnType[]; + sectionLinks?: ReturnType[]; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -216,6 +227,9 @@ export namespace graphicData { if (data.separators != null) { message.separators = data.separators.map(item => Separator.fromObject(item)); } + if (data.sectionLinks != null) { + message.sectionLinks = data.sectionLinks.map(item => SectionLink.fromObject(item)); + } return message; } toObject() { @@ -234,6 +248,7 @@ export namespace graphicData { trainWindows?: ReturnType[]; axleCountings?: ReturnType[]; separators?: ReturnType[]; + sectionLinks?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -277,6 +292,9 @@ export namespace graphicData { if (this.separators != null) { data.separators = this.separators.map((item: Separator) => item.toObject()); } + if (this.sectionLinks != null) { + data.sectionLinks = this.sectionLinks.map((item: SectionLink) => item.toObject()); + } return data; } serialize(): Uint8Array; @@ -311,6 +329,8 @@ export namespace graphicData { writer.writeRepeatedMessage(13, this.axleCountings, (item: AxleCounting) => item.serialize(writer)); if (this.separators.length) writer.writeRepeatedMessage(14, this.separators, (item: Separator) => item.serialize(writer)); + if (this.sectionLinks.length) + writer.writeRepeatedMessage(15, this.sectionLinks, (item: SectionLink) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -362,6 +382,9 @@ export namespace graphicData { case 14: reader.readMessage(message.separators, () => pb_1.Message.addToRepeatedWrapperField(message, 14, Separator.deserialize(reader), Separator)); break; + case 15: + reader.readMessage(message.sectionLinks, () => pb_1.Message.addToRepeatedWrapperField(message, 15, SectionLink.deserialize(reader), SectionLink)); + break; default: reader.skipField(); } } @@ -3406,4 +3429,143 @@ export namespace graphicData { return Separator.deserialize(bytes); } } + export class SectionLink extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + common?: CommonInfo; + code?: string; + points?: Point[]; + refDevice?: string; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("common" in data && data.common != undefined) { + this.common = data.common; + } + if ("code" in data && data.code != undefined) { + this.code = data.code; + } + if ("points" in data && data.points != undefined) { + this.points = data.points; + } + if ("refDevice" in data && data.refDevice != undefined) { + this.refDevice = data.refDevice; + } + } + } + get common() { + return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; + } + set common(value: CommonInfo) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_common() { + return pb_1.Message.getField(this, 1) != null; + } + get code() { + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; + } + set code(value: string) { + pb_1.Message.setField(this, 2, value); + } + get points() { + return pb_1.Message.getRepeatedWrapperField(this, Point, 3) as Point[]; + } + set points(value: Point[]) { + pb_1.Message.setRepeatedWrapperField(this, 3, value); + } + get refDevice() { + return pb_1.Message.getFieldWithDefault(this, 4, "") as string; + } + set refDevice(value: string) { + pb_1.Message.setField(this, 4, value); + } + static fromObject(data: { + common?: ReturnType; + code?: string; + points?: ReturnType[]; + refDevice?: string; + }): SectionLink { + const message = new SectionLink({}); + if (data.common != null) { + message.common = CommonInfo.fromObject(data.common); + } + if (data.code != null) { + message.code = data.code; + } + if (data.points != null) { + message.points = data.points.map(item => Point.fromObject(item)); + } + if (data.refDevice != null) { + message.refDevice = data.refDevice; + } + return message; + } + toObject() { + const data: { + common?: ReturnType; + code?: string; + points?: ReturnType[]; + refDevice?: string; + } = {}; + if (this.common != null) { + data.common = this.common.toObject(); + } + if (this.code != null) { + data.code = this.code; + } + if (this.points != null) { + data.points = this.points.map((item: Point) => item.toObject()); + } + if (this.refDevice != null) { + data.refDevice = this.refDevice; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_common) + writer.writeMessage(1, this.common, () => this.common.serialize(writer)); + if (this.code.length) + writer.writeString(2, this.code); + if (this.points.length) + writer.writeRepeatedMessage(3, this.points, (item: Point) => item.serialize(writer)); + if (this.refDevice.length) + writer.writeString(4, this.refDevice); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): SectionLink { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new SectionLink(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); + break; + case 2: + message.code = reader.readString(); + break; + case 3: + reader.readMessage(message.points, () => pb_1.Message.addToRepeatedWrapperField(message, 3, Point.deserialize(reader), Point)); + break; + case 4: + message.refDevice = reader.readString(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): SectionLink { + return SectionLink.deserialize(bytes); + } + } } From 6d6874a5ac6e3568d80d09740246caa93892bc13 Mon Sep 17 00:00:00 2001 From: fan Date: Fri, 7 Jul 2023 16:42:45 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bj-rtss-message | 1 + 1 file changed, 1 insertion(+) create mode 160000 bj-rtss-message diff --git a/bj-rtss-message b/bj-rtss-message new file mode 160000 index 0000000..f12288d --- /dev/null +++ b/bj-rtss-message @@ -0,0 +1 @@ +Subproject commit f12288dffe11443fbf16c02b9e1f39f3b44ceda2 From 27c48d04d52841a9944888f2a60ce9b8d7c51e06 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Fri, 7 Jul 2023 17:15:53 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E5=88=9D=E6=8F=90=E4=BA=A4--=E5=BE=85=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/draw-app/DrawProperties.vue | 10 + .../AxleCountingSectionProperty.vue | 119 ++++++++ .../AxleCountingSectionInteraction.ts | 63 +++++ src/drawApp/index.ts | 19 ++ .../AxleCountingSection.ts | 122 ++++++++ .../AxleCountingSectionAssistant.ts | 261 ++++++++++++++++++ src/layouts/DrawLayout.vue | 16 ++ src/protos/stationLayoutGraphics.ts | 193 ++++++++++++- 8 files changed, 802 insertions(+), 1 deletion(-) create mode 100644 src/components/draw-app/properties/AxleCountingSectionProperty.vue create mode 100644 src/drawApp/graphics/AxleCountingSectionInteraction.ts create mode 100644 src/graphics/axleCountingSection/AxleCountingSection.ts create mode 100644 src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts diff --git a/src/components/draw-app/DrawProperties.vue b/src/components/draw-app/DrawProperties.vue index 5dd68cb..788d6ee 100644 --- a/src/components/draw-app/DrawProperties.vue +++ b/src/components/draw-app/DrawProperties.vue @@ -22,6 +22,9 @@ + @@ -69,6 +72,11 @@ + @@ -95,6 +103,7 @@ import StationProperty from './properties/StationProperty.vue'; // import TrainProperty from './properties/TrainProperty.vue'; import TrainWindowProperty from './properties/TrainWindowProperty.vue'; import AxleCountingProperty from './properties/AxleCountingProperty.vue'; +import AxleCountingSectionProperty from './properties/AxleCountingSectionProperty.vue'; import SignalProperty from './properties/SignalProperty.vue'; import TurnoutProperty from './properties/TurnoutProperty.vue'; import SectionProperty from './properties/SectionProperty.vue'; @@ -111,6 +120,7 @@ import { Turnout } from 'src/graphics/turnout/Turnout'; import { Section } from 'src/graphics/section/Section'; import { TrainWindow } from 'src/graphics/trainWindow/TrainWindow'; import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting'; +import { AxleCountingSection } from 'src/graphics/axleCountingSection/AxleCountingSection'; import { Separator } from 'src/graphics/separator/Separator'; import { SectionLink } from 'src/graphics/sectionLink/SectionLink'; diff --git a/src/components/draw-app/properties/AxleCountingSectionProperty.vue b/src/components/draw-app/properties/AxleCountingSectionProperty.vue new file mode 100644 index 0000000..9d3cf5c --- /dev/null +++ b/src/components/draw-app/properties/AxleCountingSectionProperty.vue @@ -0,0 +1,119 @@ + + + diff --git a/src/drawApp/graphics/AxleCountingSectionInteraction.ts b/src/drawApp/graphics/AxleCountingSectionInteraction.ts new file mode 100644 index 0000000..72d3770 --- /dev/null +++ b/src/drawApp/graphics/AxleCountingSectionInteraction.ts @@ -0,0 +1,63 @@ +import * as pb_1 from 'google-protobuf'; +import { GraphicDataBase } from './GraphicDataBase'; +import { + IAxleCountingSectionData, + AxleCountingSection, +} from 'src/graphics/axleCountingSection/AxleCountingSection'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { IPointData } from 'pixi.js'; + +export class AxleCountingSectionData + extends GraphicDataBase + implements IAxleCountingSectionData +{ + constructor(data?: graphicData.AxleCountingSection) { + let axleCountingSection; + if (!data) { + axleCountingSection = new graphicData.AxleCountingSection({ + common: GraphicDataBase.defaultCommonInfo(AxleCountingSection.Type), + }); + } else { + axleCountingSection = data; + } + super(axleCountingSection); + } + public get data(): graphicData.AxleCountingSection { + return this.getData(); + } + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + get points(): IPointData[] { + return this.data.points; + } + set points(points: IPointData[]) { + this.data.points = points.map( + (p) => new graphicData.Point({ x: p.x, y: p.y }) + ); + } + get paRef(): graphicData.RelatedRef { + return this.data.paRef; + } + set paRef(ref: graphicData.RelatedRef) { + this.data.paRef = ref; + } + get pbRef(): graphicData.RelatedRef { + return this.data.pbRef; + } + set pbRef(ref: graphicData.RelatedRef) { + this.data.pbRef = ref; + } + clone(): AxleCountingSectionData { + return new AxleCountingSectionData(this.data.cloneMessage()); + } + copyFrom(data: AxleCountingSectionData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: AxleCountingSectionData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index ae76f16..fd0b78d 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -46,6 +46,12 @@ import { } from 'src/graphics/axleCounting/AxleCounting'; import { AxleCountingDraw } from 'src/graphics/axleCounting/AxleCountingDrawAssistant'; import { AxleCountingData } from './graphics/AxleCountingInteraction'; +import { + AxleCountingSection, + AxleCountingSectionTemplate, +} from 'src/graphics/axleCountingSection/AxleCountingSection'; +import { AxleCountingSectionDraw } from 'src/graphics/axleCountingSection/AxleCountingSectionAssistant'; +import { AxleCountingSectionData } from './graphics/AxleCountingSectionInteraction'; import { Turnout, TurnoutTemplate } from 'src/graphics/turnout/Turnout'; import { TurnoutDraw } from 'src/graphics/turnout/TurnoutDrawAssistant'; import { TurnoutData } from './graphics/TurnoutInteraction'; @@ -171,6 +177,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { | AxleCountingDraw | SeparatorDraw | SectionLinkDraw + | AxleCountingSectionDraw )[] = []; if (draftType === 'Line') { drawAssistants = [ @@ -197,6 +204,10 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { ), new SeparatorDraw(app, new SeparatorTemplate(new SeparatorData())), new SectionLinkDraw(app, new SectionLinkTemplate(new SectionLinkData())), + new AxleCountingSectionDraw( + app, + new AxleCountingSectionTemplate(new AxleCountingSectionData()) + ), ]; DrawSignalInteraction.init(app); } @@ -333,6 +344,11 @@ export function saveDrawDatas(app: JlDrawApp) { } else if (SectionLink.Type === g.type) { const sectionLinkData = (g as SectionLink).saveData(); storage.sectionLinks.push((sectionLinkData as SectionLinkData).data); + } else if (AxleCountingSection.Type === g.type) { + const axleCountingSectionData = (g as AxleCountingSection).saveData(); + storage.axleCountingSections.push( + (axleCountingSectionData as AxleCountingSectionData).data + ); } }); const base64 = fromUint8Array(storage.serialize()); @@ -394,6 +410,9 @@ export async function loadDrawDatas(app: GraphicApp) { storage.sectionLinks.forEach((sectionLink) => { datas.push(new SectionLinkData(sectionLink)); }); + storage.axleCountingSections.forEach((axleCountingSection) => { + datas.push(new AxleCountingSectionData(axleCountingSection)); + }); app.loadGraphic(datas); } else { app.loadGraphic([]); diff --git a/src/graphics/axleCountingSection/AxleCountingSection.ts b/src/graphics/axleCountingSection/AxleCountingSection.ts new file mode 100644 index 0000000..3c445b8 --- /dev/null +++ b/src/graphics/axleCountingSection/AxleCountingSection.ts @@ -0,0 +1,122 @@ +import { Graphics, IPointData } from 'pixi.js'; +import { + GraphicData, + GraphicRelationParam, + JlGraphic, + JlGraphicTemplate, + VectorText, +} from 'src/jl-graphic'; +import { IRelatedRefData, protoPort2Data } from '../CommonGraphics'; +import { SectionPort } from '../section/Section'; + +export interface IAxleCountingSectionData extends GraphicData { + get code(): string; // 编号 + set code(v: string); + get points(): IPointData[]; // 线坐标点 + set points(points: IPointData[]); + get paRef(): IRelatedRefData | undefined; + set paRef(ref: IRelatedRefData | undefined); + get pbRef(): IRelatedRefData | undefined; + set pbRef(ref: IRelatedRefData | undefined); + clone(): IAxleCountingSectionData; + copyFrom(data: IAxleCountingSectionData): void; + eq(other: IAxleCountingSectionData): boolean; +} + +export const AxleCountingSectionConsts = { + lineColor: '0xff0000', + lineWidth: 2, +}; + +export class AxleCountingSection extends JlGraphic { + static Type = 'AxleCountingSection'; + lineGraphic: Graphics; + labelGraphic: VectorText; + constructor() { + super(AxleCountingSection.Type); + this.lineGraphic = new Graphics(); + this.labelGraphic = new VectorText(); + this.labelGraphic.setVectorFontSize(14); + this.labelGraphic.anchor.set(0.5); + this.labelGraphic.style.fill = '#0f0'; + this.labelGraphic.transformSave = true; + this.labelGraphic.name = 'label'; + this.transformSave = true; + this.addChild(this.lineGraphic); + this.addChild(this.labelGraphic); + } + + get datas(): IAxleCountingSectionData { + return this.getDatas(); + } + doRepaint(): void { + if (this.datas.points.length < 2) { + throw new Error('AxleCountingSection坐标数据异常'); + } + this.lineGraphic.clear(); + this.lineGraphic.lineStyle( + AxleCountingSectionConsts.lineWidth, + AxleCountingSectionConsts.lineColor + ); + this.datas.points.forEach((p, i) => { + if (i !== 0) { + this.lineGraphic.lineTo(p.x, p.y); + } else { + this.lineGraphic.moveTo(p.x, p.y); + } + }); + this.labelGraphic.text = this.datas.code; + const labelPosition = this.datas.childTransforms?.find( + (t) => t.name === this.labelGraphic.name + )?.transform.position; + if (labelPosition) { + this.labelGraphic.position.set(labelPosition.x, labelPosition.y); + } else { + this.labelGraphic.position.set( + this.datas.points[0].x, + this.datas.points[0].y + 20 + ); + } + } + get linePoints(): IPointData[] { + return this.datas.points; + } + set linePoints(points: IPointData[]) { + const old = this.datas.clone(); + old.points = points; + this.updateData(old); + } + loadRelations() { + if (this.datas?.paRef?.id) { + this.relationManage.addRelation( + new GraphicRelationParam(this, SectionPort.A), + new GraphicRelationParam( + this.queryStore.queryById(this.datas.paRef.id), + protoPort2Data(this.datas.paRef.devicePort) + ) + ); + } + if (this.datas?.pbRef?.id) { + this.relationManage.addRelation( + new GraphicRelationParam(this, SectionPort.B), + new GraphicRelationParam( + this.queryStore.queryById(this.datas.pbRef.id), + protoPort2Data(this.datas.pbRef.devicePort) + ) + ); + } + } +} + +export class AxleCountingSectionTemplate extends JlGraphicTemplate { + constructor(dataTemplate: IAxleCountingSectionData) { + super(AxleCountingSection.Type, { + dataTemplate, + }); + } + new(): AxleCountingSection { + const axleCountingSection = new AxleCountingSection(); + axleCountingSection.loadData(this.datas); + return axleCountingSection; + } +} diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts new file mode 100644 index 0000000..98b75c9 --- /dev/null +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -0,0 +1,261 @@ +import { + FederatedPointerEvent, + IHitArea, + IPoint, + IPointData, + Point, +} from 'pixi.js'; +import { + AbsorbableLine, + AbsorbablePosition, + GraphicDrawAssistant, + GraphicIdGenerator, + GraphicInteractionPlugin, + JlDrawApp, + JlGraphic, + linePoint, +} from 'src/jl-graphic'; + +import { + IAxleCountingSectionData, + AxleCountingSection, + AxleCountingSectionTemplate, + AxleCountingSectionConsts, +} from './AxleCountingSection'; +import { AxleCounting } from '../axleCounting/AxleCounting'; +import { Section } from '../section/Section'; +import { Turnout } from '../turnout/Turnout'; +import { createRelatedRefProto } from '../CommonGraphics'; + +function hasCommonElements(arr1: string[], arr2: string[]): boolean { + for (let i = 0; i < arr1.length; i++) { + if (arr2.includes(arr1[i])) { + return true; + } + } + return false; +} + +function hasSamePosition(point1: IPointData, point2: IPointData): boolean { + if ( + Math.abs(point1.x - point2.x) < 20 && + Math.abs(point1.y - point2.y) < 20 + ) { + return true; + } + return false; +} + +export interface IAxleCountingSectionDrawOptions { + newData: () => IAxleCountingSectionData; +} + +export class AxleCountingSectionDraw extends GraphicDrawAssistant< + AxleCountingSectionTemplate, + IAxleCountingSectionData +> { + codeGraph: AxleCountingSection; + constructor(app: JlDrawApp, template: AxleCountingSectionTemplate) { + super(app, template, 'sym_o_circle', '不展示'); + this.codeGraph = this.graphicTemplate.new(); + this.container.addChild(this.codeGraph); + AxleCountingSectionInteraction.init(app); + } + + bind(): void { + super.bind(); + this.codeGraph.loadData(this.graphicTemplate.datas); + this.codeGraph.doRepaint(); + } + + clearCache(): void { + //this.codeGraph.destroy(); + } + onLeftDown(e: FederatedPointerEvent): void { + this.container.position.copyFrom(this.toCanvasCoordinates(e.global)); + this.createAndStore(true); + } + + redraw(p: Point): void { + this.container.position.copyFrom(p); + } + prepareData(data: IAxleCountingSectionData): boolean { + data.transform = this.container.saveTransform(); + return true; + } + draw(graphics: AxleCounting[]) { + /* const paRefPs = this.app.queryStore.queryById( + graphics[0].datas.axleCountingRef[0].id + ); + const RepbRefPs = this.app.queryStore.queryById( + graphics[1].datas.axleCountingRef[0].id + ); */ + const axleCountingSection = new AxleCountingSection(); + axleCountingSection.loadData(this.graphicTemplate.datas); + axleCountingSection.datas.points = [ + graphics[0].position, + graphics[1].position, + ]; + axleCountingSection.id = GraphicIdGenerator.next(); + const paRef = createRelatedRefProto(graphics[0].type, graphics[0].id); + const pbRef = createRelatedRefProto(graphics[1].type, graphics[1].id); + axleCountingSection.datas.paRef = paRef; + axleCountingSection.datas.pbRef = pbRef; + this.storeGraphic(axleCountingSection); + axleCountingSection.loadRelations(); + } + + oneGenerates() { + const axleCountings = this.app.queryStore.queryByType( + AxleCounting.Type + ); + const hasfourTurnout: AxleCounting[][] = []; + axleCountings.forEach((axleCounting) => { + const refDeviceTarget = axleCounting.datas.axleCountingRef.map( + (ref) => ref.id + ); + for (let i = 0; i < axleCountings.length - 1; i++) { + if (axleCountings[i].id == axleCounting.id) return; + const refDevice = axleCountings[i].datas.axleCountingRef.map( + (ref) => ref.id + ); + if (hasCommonElements(refDeviceTarget, refDevice)) { + this.draw([axleCounting, axleCountings[i]]); + } + if (hasSamePosition(axleCounting, axleCountings[i])) { + hasfourTurnout.push([axleCounting, axleCountings[i]]); + } + } + }); + const fourTurnout: Turnout[] = []; + hasfourTurnout.forEach((axleCountings) => { + const axleCountingRelations = + axleCountings[0].relationManage.getRelationsOfGraphicAndOtherType( + axleCountings[0], + Turnout.Type + ); + axleCountingRelations.forEach((relation) => { + const refDevice = relation.getOtherGraphic
(axleCountings[0]); + fourTurnout; + }); + }); + + /* axleCountings.sort((a, b) => a.x - b.x); + const downAxleCountings = axleCountings.filter((point) => { + return point.y > 350; + }); + for (let i = 0; i < downAxleCountings.length - 1; i++) { + const firstRef = downAxleCountings[i].datas.axleCountingRef.map( + (ref) => ref.id + ); + const nextRef = downAxleCountings[i + 1].datas.axleCountingRef.map( + (ref) => ref.id + ); + let nextNextRef: string[] = []; + if (i + 2 < downAxleCountings.length) { + nextNextRef = downAxleCountings[i + 2].datas.axleCountingRef.map( + (ref) => ref.id + ); + } + if (hasCommonElements(firstRef, nextRef)) { + this.draw([downAxleCountings[i], downAxleCountings[i + 1]]); + } else if ( + hasSamePosition( + downAxleCountings[i + 1].position, + downAxleCountings[i + 2].position + ) && + hasCommonElements(firstRef, nextNextRef) + ) { + this.draw([downAxleCountings[i], downAxleCountings[i + 2]]); + i += 2; + } + } */ + } +} + +function buildAbsorbablePositions( + axleCountingSection: AxleCountingSection +): AbsorbablePosition[] { + const aps: AbsorbablePosition[] = []; + const axleCountingSections = + axleCountingSection.queryStore.queryByType( + AxleCountingSection.Type + ); + const { width } = axleCountingSection.getGraphicApp().canvas; + axleCountingSections.forEach((other) => { + if (other.id == axleCountingSection.id) { + return; + } + const ps = other.datas.transform.position; + const xs = new AbsorbableLine({ x: 0, y: ps.y }, { x: width, y: ps.y }); + aps.push(xs); + }); + return aps; +} + +class AxleCountingSectionGraphicHitArea implements IHitArea { + axleCountingSection: AxleCountingSection; + constructor(axleCountingSection: AxleCountingSection) { + this.axleCountingSection = axleCountingSection; + } + contains(x: number, y: number): boolean { + for (let i = 1; i < this.axleCountingSection.datas.points.length; i++) { + const p1 = this.axleCountingSection.datas.points[i - 1]; + const p2 = this.axleCountingSection.datas.points[i]; + if (linePoint(p1, p2, { x, y }, AxleCountingSectionConsts.lineWidth)) { + return true; + } + } + return false; + } +} + +export class AxleCountingSectionInteraction extends GraphicInteractionPlugin { + static Name = 'AxleCountingSection_transform'; + constructor(app: JlDrawApp) { + super(AxleCountingSectionInteraction.Name, app); + } + static init(app: JlDrawApp) { + return new AxleCountingSectionInteraction(app); + } + filter(...grahpics: JlGraphic[]): AxleCountingSection[] | undefined { + return grahpics + .filter((g) => g.type === AxleCountingSection.Type) + .map((g) => g as AxleCountingSection); + } + bind(g: AxleCountingSection): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.transformSave = true; + g.lineGraphic.eventMode = 'static'; + g.lineGraphic.cursor = 'pointer'; + g.lineGraphic.hitArea = new AxleCountingSectionGraphicHitArea(g); + g.labelGraphic.eventMode = 'static'; + g.labelGraphic.cursor = 'pointer'; + g.labelGraphic.selectable = true; + g.labelGraphic.draggable = true; + g.on('selected', this.onSelected, this); + } + unbind(g: AxleCountingSection): void { + g.eventMode = 'none'; + g.scalable = false; + g.rotatable = false; + g.lineGraphic.eventMode = 'none'; + g.lineGraphic.draggable = false; + g.lineGraphic.selectable = false; + g.lineGraphic.transformSave = false; + g.labelGraphic.eventMode = 'none'; + g.labelGraphic.draggable = false; + g.labelGraphic.selectable = false; + g.labelGraphic.transformSave = false; + g.off('selected', this.onSelected, this); + } + onSelected(): void { + const AxleCountingSection = this.app + .selectedGraphics[0] as AxleCountingSection; + this.app.setOptions({ + absorbablePositions: buildAbsorbablePositions(AxleCountingSection), + }); + } +} diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index dcec201..e00e11f 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -27,6 +27,13 @@ 一键生成Link + + 一键生成计轴区段 + @@ -191,6 +198,8 @@ import { Separator } from 'src/graphics/separator/Separator'; import { SeparatorDraw } from 'src/graphics/separator/SeparatorDrawAssistant'; import { SectionLink } from 'src/graphics/sectionLink/SectionLink'; import { SectionLinkDraw } from 'src/graphics/sectionLink/SectionLinkDrawAssistant'; +import { AxleCountingSection } from 'src/graphics/axleCountingSection/AxleCountingSection'; +import { AxleCountingSectionDraw } from 'src/graphics/axleCountingSection/AxleCountingSectionAssistant'; const route = useRoute(); const router = useRouter(); @@ -333,6 +342,13 @@ function oneClickAxleCounting() { drawStore.oneClickType = 'AxleCounting'; drawStore.getDrawApp().interactionPlugin(OneClickGenerate.Type).resume(); } +function oneClickAxleCountingSection() { + //一键生成计轴区段 + const axleCountingSectionDraw = drawStore + .getDrawApp() + .getDrawAssistant(AxleCountingSection.Type) as AxleCountingSectionDraw; + axleCountingSectionDraw.oneGenerates(); +} function oneClickLink() { drawStore.oneClickType = 'SectionLink'; const draw = drawStore diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index 0787ebe..17a6ae5 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -23,9 +23,10 @@ export namespace graphicData { axleCountings?: AxleCounting[]; separators?: Separator[]; sectionLinks?: SectionLink[]; + axleCountingSections?: AxleCountingSection[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("canvas" in data && data.canvas != undefined) { this.canvas = data.canvas; @@ -72,6 +73,9 @@ export namespace graphicData { if ("sectionLinks" in data && data.sectionLinks != undefined) { this.sectionLinks = data.sectionLinks; } + if ("axleCountingSections" in data && data.axleCountingSections != undefined) { + this.axleCountingSections = data.axleCountingSections; + } } } get canvas() { @@ -167,6 +171,12 @@ export namespace graphicData { set sectionLinks(value: SectionLink[]) { pb_1.Message.setRepeatedWrapperField(this, 15, value); } + get axleCountingSections() { + return pb_1.Message.getRepeatedWrapperField(this, AxleCountingSection, 16) as AxleCountingSection[]; + } + set axleCountingSections(value: AxleCountingSection[]) { + pb_1.Message.setRepeatedWrapperField(this, 16, value); + } static fromObject(data: { canvas?: ReturnType; links?: ReturnType[]; @@ -183,6 +193,7 @@ export namespace graphicData { axleCountings?: ReturnType[]; separators?: ReturnType[]; sectionLinks?: ReturnType[]; + axleCountingSections?: ReturnType[]; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -230,6 +241,9 @@ export namespace graphicData { if (data.sectionLinks != null) { message.sectionLinks = data.sectionLinks.map(item => SectionLink.fromObject(item)); } + if (data.axleCountingSections != null) { + message.axleCountingSections = data.axleCountingSections.map(item => AxleCountingSection.fromObject(item)); + } return message; } toObject() { @@ -249,6 +263,7 @@ export namespace graphicData { axleCountings?: ReturnType[]; separators?: ReturnType[]; sectionLinks?: ReturnType[]; + axleCountingSections?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -295,6 +310,9 @@ export namespace graphicData { if (this.sectionLinks != null) { data.sectionLinks = this.sectionLinks.map((item: SectionLink) => item.toObject()); } + if (this.axleCountingSections != null) { + data.axleCountingSections = this.axleCountingSections.map((item: AxleCountingSection) => item.toObject()); + } return data; } serialize(): Uint8Array; @@ -331,6 +349,8 @@ export namespace graphicData { writer.writeRepeatedMessage(14, this.separators, (item: Separator) => item.serialize(writer)); if (this.sectionLinks.length) writer.writeRepeatedMessage(15, this.sectionLinks, (item: SectionLink) => item.serialize(writer)); + if (this.axleCountingSections.length) + writer.writeRepeatedMessage(16, this.axleCountingSections, (item: AxleCountingSection) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -385,6 +405,9 @@ export namespace graphicData { case 15: reader.readMessage(message.sectionLinks, () => pb_1.Message.addToRepeatedWrapperField(message, 15, SectionLink.deserialize(reader), SectionLink)); break; + case 16: + reader.readMessage(message.axleCountingSections, () => pb_1.Message.addToRepeatedWrapperField(message, 16, AxleCountingSection.deserialize(reader), AxleCountingSection)); + break; default: reader.skipField(); } } @@ -3568,4 +3591,172 @@ export namespace graphicData { return SectionLink.deserialize(bytes); } } + export class AxleCountingSection extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + common?: CommonInfo; + code?: string; + points?: Point[]; + paRef?: RelatedRef; + pbRef?: RelatedRef; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("common" in data && data.common != undefined) { + this.common = data.common; + } + if ("code" in data && data.code != undefined) { + this.code = data.code; + } + if ("points" in data && data.points != undefined) { + this.points = data.points; + } + if ("paRef" in data && data.paRef != undefined) { + this.paRef = data.paRef; + } + if ("pbRef" in data && data.pbRef != undefined) { + this.pbRef = data.pbRef; + } + } + } + get common() { + return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; + } + set common(value: CommonInfo) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_common() { + return pb_1.Message.getField(this, 1) != null; + } + get code() { + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; + } + set code(value: string) { + pb_1.Message.setField(this, 2, value); + } + get points() { + return pb_1.Message.getRepeatedWrapperField(this, Point, 3) as Point[]; + } + set points(value: Point[]) { + pb_1.Message.setRepeatedWrapperField(this, 3, value); + } + get paRef() { + return pb_1.Message.getWrapperField(this, RelatedRef, 4) as RelatedRef; + } + set paRef(value: RelatedRef) { + pb_1.Message.setWrapperField(this, 4, value); + } + get has_paRef() { + return pb_1.Message.getField(this, 4) != null; + } + get pbRef() { + return pb_1.Message.getWrapperField(this, RelatedRef, 5) as RelatedRef; + } + set pbRef(value: RelatedRef) { + pb_1.Message.setWrapperField(this, 5, value); + } + get has_pbRef() { + return pb_1.Message.getField(this, 5) != null; + } + static fromObject(data: { + common?: ReturnType; + code?: string; + points?: ReturnType[]; + paRef?: ReturnType; + pbRef?: ReturnType; + }): AxleCountingSection { + const message = new AxleCountingSection({}); + if (data.common != null) { + message.common = CommonInfo.fromObject(data.common); + } + if (data.code != null) { + message.code = data.code; + } + if (data.points != null) { + message.points = data.points.map(item => Point.fromObject(item)); + } + if (data.paRef != null) { + message.paRef = RelatedRef.fromObject(data.paRef); + } + if (data.pbRef != null) { + message.pbRef = RelatedRef.fromObject(data.pbRef); + } + return message; + } + toObject() { + const data: { + common?: ReturnType; + code?: string; + points?: ReturnType[]; + paRef?: ReturnType; + pbRef?: ReturnType; + } = {}; + if (this.common != null) { + data.common = this.common.toObject(); + } + if (this.code != null) { + data.code = this.code; + } + if (this.points != null) { + data.points = this.points.map((item: Point) => item.toObject()); + } + if (this.paRef != null) { + data.paRef = this.paRef.toObject(); + } + if (this.pbRef != null) { + data.pbRef = this.pbRef.toObject(); + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_common) + writer.writeMessage(1, this.common, () => this.common.serialize(writer)); + if (this.code.length) + writer.writeString(2, this.code); + if (this.points.length) + writer.writeRepeatedMessage(3, this.points, (item: Point) => item.serialize(writer)); + if (this.has_paRef) + writer.writeMessage(4, this.paRef, () => this.paRef.serialize(writer)); + if (this.has_pbRef) + writer.writeMessage(5, this.pbRef, () => this.pbRef.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): AxleCountingSection { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new AxleCountingSection(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); + break; + case 2: + message.code = reader.readString(); + break; + case 3: + reader.readMessage(message.points, () => pb_1.Message.addToRepeatedWrapperField(message, 3, Point.deserialize(reader), Point)); + break; + case 4: + reader.readMessage(message.paRef, () => message.paRef = RelatedRef.deserialize(reader)); + break; + case 5: + reader.readMessage(message.pbRef, () => message.pbRef = RelatedRef.deserialize(reader)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): AxleCountingSection { + return AxleCountingSection.deserialize(bytes); + } + } } From 021d683829c805e550515216200fc2817ecc5dee Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Fri, 7 Jul 2023 17:25:51 +0800 Subject: [PATCH 6/6] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E5=9C=A8=E7=AB=AF=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/axleCounting/AxleCountingDrawAssistant.ts | 10 ++-------- .../AxleCountingSectionAssistant.ts | 5 +++++ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts index b7b38b7..3c62ab5 100644 --- a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts +++ b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts @@ -115,10 +115,7 @@ export class AxleCountingDraw extends GraphicDrawAssistant< if (graphic.type == 'Turnout') { axleCounting.position.set(ps.x, ps.y); } else { - axleCounting.position.set( - ps.x, - ps.y - AxleCountingConsts.offsetSection * direction - ); + axleCounting.position.set(ps.x, ps.y); } axleCounting.id = GraphicIdGenerator.next(); axleCounting.datas.axleCountingRef = [refData2, refData1]; @@ -142,10 +139,7 @@ export class AxleCountingDraw extends GraphicDrawAssistant< if (graphic.type == 'Turnout') { axleCounting.position.set(ps.x, ps.y); } else { - axleCounting.position.set( - ps.x, - ps.y - AxleCountingConsts.offsetSection * direction - ); + axleCounting.position.set(ps.x, ps.y); } axleCounting.id = GraphicIdGenerator.next(); axleCounting.datas.axleCountingRef = [refData]; diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index 98b75c9..a0da3ce 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -106,6 +106,11 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< } oneGenerates() { + const axleCountingSectionAll = + this.app.queryStore.queryByType( + AxleCountingSection.Type + ); + this.app.deleteGraphics(...axleCountingSectionAll); const axleCountings = this.app.queryStore.queryByType( AxleCounting.Type );