diff --git a/src/components/draw-app/DrawProperties.vue b/src/components/draw-app/DrawProperties.vue index 34cd70d..1793778 100644 --- a/src/components/draw-app/DrawProperties.vue +++ b/src/components/draw-app/DrawProperties.vue @@ -72,6 +72,9 @@ + @@ -91,6 +94,7 @@ import PlatformProperty from './properties/PlatformProperty.vue'; import StationProperty from './properties/StationProperty.vue'; import StationLineProperty from './properties/StationLineProperty.vue'; import TrainProperty from './properties/TrainProperty.vue'; +import TrainWindowProperty from './properties/TrainWindowProperty.vue'; import IscsFanProperty from './properties/IscsFanProperty.vue'; import SignalProperty from './properties/SignalProperty.vue'; import TurnoutProperty from './properties/TurnoutProperty.vue'; @@ -108,6 +112,7 @@ import { Signal } from 'src/graphics/signal/Signal'; import { Turnout } from 'src/graphics/turnout/Turnout'; import { RunLine } from 'src/graphics/runLine/RunLine'; import { Section } from 'src/graphics/section/Section'; +import { TrainWindow } from 'src/graphics/trainWindow/TrainWindow'; const drawStore = useDrawStore(); diff --git a/src/components/draw-app/properties/StationProperty.vue b/src/components/draw-app/properties/StationProperty.vue index ec403b3..140186c 100644 --- a/src/components/draw-app/properties/StationProperty.vue +++ b/src/components/draw-app/properties/StationProperty.vue @@ -17,6 +17,13 @@ :options="optionsControl" label="是否有控制" /> + @@ -29,6 +36,7 @@ import { onMounted, reactive, ref, watch } from 'vue'; const drawStore = useDrawStore(); const stationModel = reactive(new StationData()); const hasControl = ref('是'); +const concentrationStations = ref('否'); const optionsControl = ['是', '否']; enum showSelect { 是 = 'true', @@ -48,6 +56,9 @@ watch( hasControl.value = (showSelectData as never)[ stationModel.hasControl + '' ]; + concentrationStations.value = (showSelectData as never)[ + stationModel.concentrationStations + '' + ]; } } ); @@ -57,11 +68,17 @@ onMounted(() => { if (station) { stationModel.copyFrom(station.saveData()); hasControl.value = (showSelectData as never)[stationModel.hasControl + '']; + concentrationStations.value = (showSelectData as never)[ + stationModel.concentrationStations + '' + ]; } }); function onUpdate() { stationModel.hasControl = JSON.parse((showSelect as never)[hasControl.value]); + stationModel.concentrationStations = JSON.parse( + (showSelect as never)[concentrationStations.value] + ); const station = drawStore.selectedGraphic as Station; if (station) { drawStore.getDrawApp().updateGraphicAndRecord(station, stationModel); diff --git a/src/components/draw-app/properties/TrainWindowProperty.vue b/src/components/draw-app/properties/TrainWindowProperty.vue new file mode 100644 index 0000000..5febe88 --- /dev/null +++ b/src/components/draw-app/properties/TrainWindowProperty.vue @@ -0,0 +1,56 @@ + + + diff --git a/src/drawApp/graphics/StationInteraction.ts b/src/drawApp/graphics/StationInteraction.ts index 0170926..9f4acd4 100644 --- a/src/drawApp/graphics/StationInteraction.ts +++ b/src/drawApp/graphics/StationInteraction.ts @@ -31,6 +31,12 @@ export class StationData extends GraphicDataBase implements IStationData { set hasControl(v: boolean) { this.data.hasControl = v; } + get concentrationStations(): boolean { + return this.data.concentrationStations; + } + set concentrationStations(v: boolean) { + this.data.concentrationStations = v; + } clone(): StationData { return new StationData(this.data.cloneMessage()); } diff --git a/src/drawApp/graphics/TrainWindowInteraction.ts b/src/drawApp/graphics/TrainWindowInteraction.ts new file mode 100644 index 0000000..842b06b --- /dev/null +++ b/src/drawApp/graphics/TrainWindowInteraction.ts @@ -0,0 +1,43 @@ +import * as pb_1 from 'google-protobuf'; +import { + ITrainWindowData, + TrainWindow, +} from 'src/graphics/trainWindow/TrainWindow'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { GraphicDataBase } from './GraphicDataBase'; + +export class TrainWindowData + extends GraphicDataBase + implements ITrainWindowData +{ + constructor(data?: graphicData.TrainWindow) { + let trainWindow; + if (!data) { + trainWindow = new graphicData.TrainWindow({ + common: GraphicDataBase.defaultCommonInfo(TrainWindow.Type), + }); + } else { + trainWindow = data; + } + super(trainWindow); + } + + public get data(): graphicData.TrainWindow { + return this.getData(); + } + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + clone(): TrainWindowData { + return new TrainWindowData(this.data.cloneMessage()); + } + copyFrom(data: TrainWindowData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: TrainWindowData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 69624b9..f872fc0 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -40,6 +40,9 @@ import { StationLineData } from './graphics/StationLineInteraction'; import { TrainLine } from 'src/graphics/trainLine/TrainLine'; import { TrainLineDraw } from 'src/graphics/trainLine/TrainLineAssistant'; import { TrainLineData } from './graphics/TrainLineInteraction'; +import { TrainWindow } from 'src/graphics/trainWindow/TrainWindow'; +import { TrainWindowDraw } from 'src/graphics/trainWindow/TrainWindowDrawAssistant'; +import { TrainWindowData } from './graphics/TrainWindowInteraction'; import { Turnout } from 'src/graphics/turnout/Turnout'; import { TurnoutDraw } from 'src/graphics/turnout/TurnoutDrawAssistant'; import { TurnoutData } from './graphics/TurnoutInteraction'; @@ -139,6 +142,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { | TrainLineDraw | PolygonDraw | PathLineDraw + | TrainWindowDraw )[] = []; if (draftType === 'Line') { drawAssistants = [ @@ -161,6 +165,9 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { /* new PolygonDraw(app, () => { return new PolygonData(); }), */ + new TrainWindowDraw(app, () => { + return new TrainWindowData(); + }), ]; } else { drawAssistants = [ @@ -180,20 +187,6 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { return new PathLineData(); }), ]; - app.addKeyboardListener( - new KeyListener({ - value: 'KeyO', - onPress: () => { - app.interactionPlugin(StationLine.Type).resume(); - }, - }), - new KeyListener({ - value: 'KeyR', - onPress: () => { - app.interactionPlugin(Rect.Type).resume(); - }, - }) - ); } app.setOptions({ drawAssistants: drawAssistants }); @@ -293,6 +286,9 @@ export function saveDrawDatas(app: JlDrawApp) { } else if (PathLine.Type === g.type) { const pathLineData = (g as PathLine).saveData(); storage.pathLines.push((pathLineData as PathLineData).data); + } else if (TrainWindow.Type === g.type) { + const trainWindowData = (g as TrainWindow).saveData(); + storage.trainWindows.push((trainWindowData as TrainWindowData).data); } }); const base64 = fromUint8Array(storage.serialize()); @@ -357,6 +353,9 @@ export async function loadDrawDatas(app: GraphicApp) { storage.pathLines.forEach((pathLine) => { datas.push(new PathLineData(pathLine)); }); + storage.trainWindows.forEach((trainWindow) => { + datas.push(new TrainWindowData(trainWindow)); + }); app.loadGraphic(datas); } else { app.loadGraphic([]); diff --git a/src/graphics/station/Station.ts b/src/graphics/station/Station.ts index 3be6384..7c2bb28 100644 --- a/src/graphics/station/Station.ts +++ b/src/graphics/station/Station.ts @@ -9,8 +9,10 @@ import { export interface IStationData extends GraphicData { get code(): string; // 编号 set code(v: string); - get hasControl(): boolean; + get hasControl(): boolean; /// 是否有控制 set hasControl(v: boolean); + get concentrationStations(): boolean; ////是否集中站 + set concentrationStations(v: boolean); clone(): IStationData; copyFrom(data: IStationData): void; eq(other: IStationData): boolean; diff --git a/src/graphics/trainWindow/TrainWindow.ts b/src/graphics/trainWindow/TrainWindow.ts new file mode 100644 index 0000000..b5ec73b --- /dev/null +++ b/src/graphics/trainWindow/TrainWindow.ts @@ -0,0 +1,64 @@ +import { Color, Graphics, Rectangle } from 'pixi.js'; +import { + GraphicData, + JlGraphic, + JlGraphicTemplate, + getRectangleCenter, +} from 'src/jl-graphic'; + +export interface ITrainWindowData extends GraphicData { + get code(): string; // 编号 + set code(v: string); + clone(): ITrainWindowData; + copyFrom(data: ITrainWindowData): void; + eq(other: ITrainWindowData): boolean; +} + +export const TrainWindowConsts = { + width: 40, + height: 15, + lineWidth: 2, + lineColor: '0x0fe81f', +}; + +export class TrainWindow extends JlGraphic { + static Type = 'TrainWindow'; + rectGraphic: Graphics = new Graphics(); + constructor() { + super(TrainWindow.Type); + this.addChild(this.rectGraphic); + } + get datas(): ITrainWindowData { + return this.getDatas(); + } + doRepaint(): void { + const rectGraphic = this.rectGraphic; + rectGraphic.clear(); + rectGraphic.lineStyle( + TrainWindowConsts.lineWidth, + new Color(TrainWindowConsts.lineColor) + ); + rectGraphic.drawRect( + 0, + 0, + TrainWindowConsts.width, + TrainWindowConsts.height + ); + const rectP = new Rectangle( + 0, + 0, + TrainWindowConsts.width, + TrainWindowConsts.height + ); + rectGraphic.pivot = getRectangleCenter(rectP); + } +} + +export class TrainWindowTemplate extends JlGraphicTemplate { + constructor() { + super(TrainWindow.Type); + } + new(): TrainWindow { + return new TrainWindow(); + } +} diff --git a/src/graphics/trainWindow/TrainWindowDrawAssistant.ts b/src/graphics/trainWindow/TrainWindowDrawAssistant.ts new file mode 100644 index 0000000..633261b --- /dev/null +++ b/src/graphics/trainWindow/TrainWindowDrawAssistant.ts @@ -0,0 +1,108 @@ +import { FederatedPointerEvent, IHitArea, Point } from 'pixi.js'; +import { + GraphicDrawAssistant, + GraphicInteractionPlugin, + JlDrawApp, + JlGraphic, + linePoint, +} from 'src/jl-graphic'; + +import { + ITrainWindowData, + TrainWindow, + TrainWindowTemplate, + TrainWindowConsts, +} from './TrainWindow'; + +export interface ITrainWindowDrawOptions { + newData: () => ITrainWindowData; +} + +export class TrainWindowDraw extends GraphicDrawAssistant< + TrainWindowTemplate, + ITrainWindowData +> { + trainWindowGraph: TrainWindow; + constructor(app: JlDrawApp, createData: () => ITrainWindowData) { + super( + app, + new TrainWindowTemplate(), + createData, + 'sym_o_square', + '车次窗TrainWindow' + ); + this.trainWindowGraph = this.graphicTemplate.new(); + this.container.addChild(this.trainWindowGraph); + TrainWindowInteraction.init(app); + } + + bind(): void { + super.bind(); + this.trainWindowGraph.loadData(this.createGraphicData()); + this.trainWindowGraph.doRepaint(); + } + + 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: ITrainWindowData): boolean { + data.transform = this.container.saveTransform(); + return true; + } +} + +//碰撞检测 +export class RectGraphicHitArea implements IHitArea { + rect: TrainWindow; + constructor(rect: TrainWindow) { + this.rect = rect; + } + contains(x: number, y: number): boolean { + let contains = false; + const tolerance = TrainWindowConsts.lineWidth; + const p1 = new Point(0, 0); + const p2 = new Point(TrainWindowConsts.width, 0); + const p3 = new Point(TrainWindowConsts.width, TrainWindowConsts.height); + const p4 = new Point(0, TrainWindowConsts.height); + const p = new Point(x, y); + + contains = contains || linePoint(p1, p2, p, tolerance); + contains = contains || linePoint(p2, p3, p, tolerance); + contains = contains || linePoint(p3, p4, p, tolerance); + contains = contains || linePoint(p4, p1, p, tolerance); + return contains; + } +} + +export class TrainWindowInteraction extends GraphicInteractionPlugin { + static Name = 'TrainWindow_transform'; + constructor(app: JlDrawApp) { + super(TrainWindowInteraction.Name, app); + } + static init(app: JlDrawApp) { + return new TrainWindowInteraction(app); + } + filter(...grahpics: JlGraphic[]): TrainWindow[] | undefined { + return grahpics + .filter((g) => g.type === TrainWindow.Type) + .map((g) => g as TrainWindow); + } + bind(g: TrainWindow): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.rotatable = true; + g.rectGraphic.hitArea = new RectGraphicHitArea(g); + } + unbind(g: TrainWindow): void { + g.eventMode = 'none'; + g.scalable = false; + g.rotatable = false; + } +} diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index 9c13250..9321182 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -23,9 +23,10 @@ export namespace graphicData { trainLines?: TrainLine[]; pathLines?: PathLine[]; polygons?: Polygon[]; + trainWindows?: TrainWindow[]; }) { 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 ("polygons" in data && data.polygons != undefined) { this.polygons = data.polygons; } + if ("trainWindows" in data && data.trainWindows != undefined) { + this.trainWindows = data.trainWindows; + } } } get canvas() { @@ -167,6 +171,12 @@ export namespace graphicData { set polygons(value: Polygon[]) { pb_1.Message.setRepeatedWrapperField(this, 15, value); } + get trainWindows() { + return pb_1.Message.getRepeatedWrapperField(this, TrainWindow, 16) as TrainWindow[]; + } + set trainWindows(value: TrainWindow[]) { + pb_1.Message.setRepeatedWrapperField(this, 16, value); + } static fromObject(data: { canvas?: ReturnType; links?: ReturnType[]; @@ -183,6 +193,7 @@ export namespace graphicData { trainLines?: ReturnType[]; pathLines?: ReturnType[]; polygons?: ReturnType[]; + trainWindows?: ReturnType[]; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -230,6 +241,9 @@ export namespace graphicData { if (data.polygons != null) { message.polygons = data.polygons.map(item => Polygon.fromObject(item)); } + if (data.trainWindows != null) { + message.trainWindows = data.trainWindows.map(item => TrainWindow.fromObject(item)); + } return message; } toObject() { @@ -249,6 +263,7 @@ export namespace graphicData { trainLines?: ReturnType[]; pathLines?: ReturnType[]; polygons?: ReturnType[]; + trainWindows?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -295,6 +310,9 @@ export namespace graphicData { if (this.polygons != null) { data.polygons = this.polygons.map((item: Polygon) => item.toObject()); } + if (this.trainWindows != null) { + data.trainWindows = this.trainWindows.map((item: TrainWindow) => item.toObject()); + } return data; } serialize(): Uint8Array; @@ -331,6 +349,8 @@ export namespace graphicData { writer.writeRepeatedMessage(14, this.pathLines, (item: PathLine) => item.serialize(writer)); if (this.polygons.length) writer.writeRepeatedMessage(15, this.polygons, (item: Polygon) => item.serialize(writer)); + if (this.trainWindows.length) + writer.writeRepeatedMessage(16, this.trainWindows, (item: TrainWindow) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -385,6 +405,9 @@ export namespace graphicData { 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; default: reader.skipField(); } } @@ -1752,6 +1775,7 @@ export namespace graphicData { common?: CommonInfo; code?: string; hasControl?: boolean; + concentrationStations?: boolean; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -1765,6 +1789,9 @@ export namespace graphicData { if ("hasControl" in data && data.hasControl != undefined) { this.hasControl = data.hasControl; } + if ("concentrationStations" in data && data.concentrationStations != undefined) { + this.concentrationStations = data.concentrationStations; + } } } get common() { @@ -1788,10 +1815,17 @@ export namespace graphicData { set hasControl(value: boolean) { pb_1.Message.setField(this, 3, value); } + get concentrationStations() { + return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean; + } + set concentrationStations(value: boolean) { + pb_1.Message.setField(this, 4, value); + } static fromObject(data: { common?: ReturnType; code?: string; hasControl?: boolean; + concentrationStations?: boolean; }): Station { const message = new Station({}); if (data.common != null) { @@ -1803,6 +1837,9 @@ export namespace graphicData { if (data.hasControl != null) { message.hasControl = data.hasControl; } + if (data.concentrationStations != null) { + message.concentrationStations = data.concentrationStations; + } return message; } toObject() { @@ -1810,6 +1847,7 @@ export namespace graphicData { common?: ReturnType; code?: string; hasControl?: boolean; + concentrationStations?: boolean; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -1820,6 +1858,9 @@ export namespace graphicData { if (this.hasControl != null) { data.hasControl = this.hasControl; } + if (this.concentrationStations != null) { + data.concentrationStations = this.concentrationStations; + } return data; } serialize(): Uint8Array; @@ -1832,6 +1873,8 @@ export namespace graphicData { writer.writeString(2, this.code); if (this.hasControl != false) writer.writeBool(3, this.hasControl); + if (this.concentrationStations != false) + writer.writeBool(4, this.concentrationStations); if (!w) return writer.getResultBuffer(); } @@ -1850,6 +1893,9 @@ export namespace graphicData { case 3: message.hasControl = reader.readBool(); break; + case 4: + message.concentrationStations = reader.readBool(); + break; default: reader.skipField(); } } @@ -1978,6 +2024,99 @@ export namespace graphicData { return StationLine.deserialize(bytes); } } + export class TrainWindow 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; + }): TrainWindow { + const message = new TrainWindow({}); + 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): TrainWindow { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TrainWindow(); + 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): TrainWindow { + return TrainWindow.deserialize(bytes); + } + } export class Train extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { @@ -2308,12 +2447,13 @@ export namespace graphicData { constructor(data?: any[] | { common?: CommonInfo; code?: string; - pointA?: Point[]; - pointB?: Point[]; - pointC?: Point[]; + pointA?: Point; + pointB?: Point; + pointC?: Point; + labelOffset?: Point; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [6, 7, 8], this.#one_of_decls); + 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; @@ -2330,6 +2470,9 @@ export namespace graphicData { if ("pointC" in data && data.pointC != undefined) { this.pointC = data.pointC; } + if ("labelOffset" in data && data.labelOffset != undefined) { + this.labelOffset = data.labelOffset; + } } } get common() { @@ -2348,29 +2491,48 @@ export namespace graphicData { pb_1.Message.setField(this, 2, value); } get pointA() { - return pb_1.Message.getRepeatedWrapperField(this, Point, 6) as Point[]; + return pb_1.Message.getWrapperField(this, Point, 6) as Point; } - set pointA(value: Point[]) { - pb_1.Message.setRepeatedWrapperField(this, 6, value); + set pointA(value: Point) { + pb_1.Message.setWrapperField(this, 6, value); + } + get has_pointA() { + return pb_1.Message.getField(this, 6) != null; } get pointB() { - return pb_1.Message.getRepeatedWrapperField(this, Point, 7) as Point[]; + return pb_1.Message.getWrapperField(this, Point, 7) as Point; } - set pointB(value: Point[]) { - pb_1.Message.setRepeatedWrapperField(this, 7, value); + set pointB(value: Point) { + pb_1.Message.setWrapperField(this, 7, value); + } + get has_pointB() { + return pb_1.Message.getField(this, 7) != null; } get pointC() { - return pb_1.Message.getRepeatedWrapperField(this, Point, 8) as Point[]; + return pb_1.Message.getWrapperField(this, Point, 8) as Point; } - set pointC(value: Point[]) { - pb_1.Message.setRepeatedWrapperField(this, 8, value); + set pointC(value: Point) { + pb_1.Message.setWrapperField(this, 8, value); + } + get has_pointC() { + return pb_1.Message.getField(this, 8) != null; + } + get labelOffset() { + return pb_1.Message.getWrapperField(this, Point, 9) as Point; + } + set labelOffset(value: Point) { + pb_1.Message.setWrapperField(this, 9, value); + } + get has_labelOffset() { + return pb_1.Message.getField(this, 9) != null; } static fromObject(data: { common?: ReturnType; code?: string; - pointA?: ReturnType[]; - pointB?: ReturnType[]; - pointC?: ReturnType[]; + pointA?: ReturnType; + pointB?: ReturnType; + pointC?: ReturnType; + labelOffset?: ReturnType; }): Turnout { const message = new Turnout({}); if (data.common != null) { @@ -2380,13 +2542,16 @@ export namespace graphicData { message.code = data.code; } if (data.pointA != null) { - message.pointA = data.pointA.map(item => Point.fromObject(item)); + message.pointA = Point.fromObject(data.pointA); } if (data.pointB != null) { - message.pointB = data.pointB.map(item => Point.fromObject(item)); + message.pointB = Point.fromObject(data.pointB); } if (data.pointC != null) { - message.pointC = data.pointC.map(item => Point.fromObject(item)); + message.pointC = Point.fromObject(data.pointC); + } + if (data.labelOffset != null) { + message.labelOffset = Point.fromObject(data.labelOffset); } return message; } @@ -2394,9 +2559,10 @@ export namespace graphicData { const data: { common?: ReturnType; code?: string; - pointA?: ReturnType[]; - pointB?: ReturnType[]; - pointC?: ReturnType[]; + pointA?: ReturnType; + pointB?: ReturnType; + pointC?: ReturnType; + labelOffset?: ReturnType; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -2405,13 +2571,16 @@ export namespace graphicData { data.code = this.code; } if (this.pointA != null) { - data.pointA = this.pointA.map((item: Point) => item.toObject()); + data.pointA = this.pointA.toObject(); } if (this.pointB != null) { - data.pointB = this.pointB.map((item: Point) => item.toObject()); + data.pointB = this.pointB.toObject(); } if (this.pointC != null) { - data.pointC = this.pointC.map((item: Point) => item.toObject()); + data.pointC = this.pointC.toObject(); + } + if (this.labelOffset != null) { + data.labelOffset = this.labelOffset.toObject(); } return data; } @@ -2423,12 +2592,14 @@ export namespace graphicData { writer.writeMessage(1, this.common, () => this.common.serialize(writer)); if (this.code.length) writer.writeString(2, this.code); - if (this.pointA.length) - writer.writeRepeatedMessage(6, this.pointA, (item: Point) => item.serialize(writer)); - if (this.pointB.length) - writer.writeRepeatedMessage(7, this.pointB, (item: Point) => item.serialize(writer)); - if (this.pointC.length) - writer.writeRepeatedMessage(8, this.pointC, (item: Point) => item.serialize(writer)); + if (this.has_pointA) + writer.writeMessage(6, this.pointA, () => this.pointA.serialize(writer)); + if (this.has_pointB) + writer.writeMessage(7, this.pointB, () => this.pointB.serialize(writer)); + if (this.has_pointC) + writer.writeMessage(8, this.pointC, () => this.pointC.serialize(writer)); + if (this.has_labelOffset) + writer.writeMessage(9, this.labelOffset, () => this.labelOffset.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -2445,13 +2616,16 @@ export namespace graphicData { message.code = reader.readString(); break; case 6: - reader.readMessage(message.pointA, () => pb_1.Message.addToRepeatedWrapperField(message, 6, Point.deserialize(reader), Point)); + reader.readMessage(message.pointA, () => message.pointA = Point.deserialize(reader)); break; case 7: - reader.readMessage(message.pointB, () => pb_1.Message.addToRepeatedWrapperField(message, 7, Point.deserialize(reader), Point)); + reader.readMessage(message.pointB, () => message.pointB = Point.deserialize(reader)); break; case 8: - reader.readMessage(message.pointC, () => pb_1.Message.addToRepeatedWrapperField(message, 8, Point.deserialize(reader), Point)); + reader.readMessage(message.pointC, () => message.pointC = Point.deserialize(reader)); + break; + case 9: + reader.readMessage(message.labelOffset, () => message.labelOffset = Point.deserialize(reader)); break; default: reader.skipField(); }