From ec4eb4b25c692d165d2a12f31c5d152eff34e17d Mon Sep 17 00:00:00 2001 From: Yuan Date: Fri, 9 Jun 2023 18:36:09 +0800 Subject: [PATCH 1/8] =?UTF-8?q?=E5=8C=BA=E6=AE=B5=E7=BB=98=E5=88=B6=20&&?= =?UTF-8?q?=20message=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drawApp/graphics/SectionInteraction.ts | 45 ++++ src/drawApp/index.ts | 10 + src/graphics/section/Section.ts | 76 +++++++ src/graphics/section/SectionDrawAssistant.ts | 139 +++++++++++++ src/protos/LineNetTrainOffset.ts | 143 ++++--------- src/protos/device_status.ts | 205 +++++++++++++++++++ src/protos/stationLayoutGraphics.ts | 141 ++++++++++++- xian-ncc-da-message | 2 +- 8 files changed, 653 insertions(+), 108 deletions(-) create mode 100644 src/drawApp/graphics/SectionInteraction.ts create mode 100644 src/graphics/section/Section.ts create mode 100644 src/graphics/section/SectionDrawAssistant.ts diff --git a/src/drawApp/graphics/SectionInteraction.ts b/src/drawApp/graphics/SectionInteraction.ts new file mode 100644 index 0000000..88f898a --- /dev/null +++ b/src/drawApp/graphics/SectionInteraction.ts @@ -0,0 +1,45 @@ +import * as pb_1 from 'google-protobuf'; +import { GraphicDataBase } from './GraphicDataBase'; +import { ISectionData } from 'src/graphics/section/Section'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { IPointData } from 'pixi.js'; + +export class SectionData extends GraphicDataBase implements ISectionData { + constructor(data?: graphicData.Section) { + let section; + if (!data) { + section = new graphicData.Section({ + common: GraphicDataBase.defaultCommonInfo(), + }); + } else { + section = data; + } + super(section); + } + public get data(): graphicData.Section { + 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 }) + ); + } + clone(): SectionData { + return new SectionData(this.data.cloneMessage()); + } + copyFrom(data: SectionData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: SectionData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index df00920..61f06ea 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -38,6 +38,9 @@ import { TurnoutData } from './graphics/TurnoutInteraction'; import { saveDraft, getDraft } from 'src/api/DraftApi'; import { useDrawStore } from 'src/stores/draw-store'; import { successNotify, errorNotify } from '../utils/CommonNotify'; +import { Section } from 'src/graphics/section/Section'; +import { SectionDraw } from 'src/graphics/section/SectionDrawAssistant'; +import { SectionData } from './graphics/SectionInteraction'; export function fromStoragePoint(p: graphicData.Point): Point { return new Point(p.x, p.y); @@ -124,6 +127,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { // new TrainDraw(app, () => { // return new TrainData(); // }), + new SectionDraw(app, () => new SectionData()), ], }); @@ -233,6 +237,9 @@ export function saveDrawDatas(app: JlDrawApp) { } else if (Signal.Type === g.type) { const signalData = (g as Signal).saveData(); storage.signals.push((signalData as SignalData).data); + } else if (Section.Type === g.type) { + const sectionData = (g as Section).saveData(); + storage.section.push((sectionData as SectionData).data); } }); const base64 = fromUint8Array(storage.serialize()); @@ -293,6 +300,9 @@ export async function loadDrawDatas(app: GraphicApp) { storage.signals.forEach((signal) => { datas.push(new SignalData(signal)); }); + storage.section.forEach((section) => { + datas.push(new SectionData(section)); + }); app.loadGraphic(datas); } else { app.loadGraphic([]); diff --git a/src/graphics/section/Section.ts b/src/graphics/section/Section.ts new file mode 100644 index 0000000..8c8bee4 --- /dev/null +++ b/src/graphics/section/Section.ts @@ -0,0 +1,76 @@ +import { Graphics, IPointData } from 'pixi.js'; +import { GraphicData, JlGraphic, JlGraphicTemplate } from 'src/jl-graphic'; +import { ILineGraphic } from 'src/jl-graphic/plugins/GraphicEditPlugin'; +import { Link } from '../link/Link'; + +export interface ISectionData extends GraphicData { + get code(): string; // 编号 + set code(v: string); + get points(): IPointData[]; // 线坐标点 + set points(points: IPointData[]); + clone(): ISectionData; + copyFrom(data: ISectionData): void; + eq(other: ISectionData): boolean; +} +export const SectionConsts = { + lineColor: '#5578b6', + lineWidth: 5, +}; + +export class Section extends JlGraphic implements ILineGraphic { + static Type = 'Section'; + lineGraphic: Graphics; + + constructor() { + super(Section.Type); + this.lineGraphic = new Graphics(); + this.addChild(this.lineGraphic); + } + + doRepaint() { + if (this.datas.points.length < 2) { + throw new Error('Link坐标数据异常'); + } + this.lineGraphic.clear(); + this.lineGraphic.lineStyle( + SectionConsts.lineWidth, + SectionConsts.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); + } + }); + } + + getStartPoint() { + return this.datas.points[0]; + } + getEndPoint(): IPointData { + return this.datas.points[this.datas.points.length - 1]; + } + + get datas(): ISectionData { + 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 SectionTemplate extends JlGraphicTemplate
{ + constructor() { + super(Section.Type); + } + new() { + return new Section(); + } +} diff --git a/src/graphics/section/SectionDrawAssistant.ts b/src/graphics/section/SectionDrawAssistant.ts new file mode 100644 index 0000000..62eea05 --- /dev/null +++ b/src/graphics/section/SectionDrawAssistant.ts @@ -0,0 +1,139 @@ +import { + GraphicApp, + GraphicDrawAssistant, + GraphicInteractionPlugin, + JlDrawApp, + JlGraphic, + linePoint, +} from 'src/jl-graphic'; +import { + ISectionData, + Section, + SectionConsts, + SectionTemplate, +} from './Section'; +import { + DisplayObject, + FederatedMouseEvent, + Graphics, + IHitArea, + Point, +} from 'pixi.js'; +import { PolylineEditPlugin } from 'src/jl-graphic/plugins/GraphicEditPlugin'; + +export class SectionDraw extends GraphicDrawAssistant< + SectionTemplate, + ISectionData +> { + points: Point[] = []; + graphic = new Graphics(); + + constructor(app: JlDrawApp, createData: () => ISectionData) { + super( + app, + new SectionTemplate(), + createData, + 'sym_o_timeline', + '区段Section' + ); + this.container.addChild(this.graphic); + + SectionPointEditPlugin.init(app); + } + + onLeftDown(e: FederatedMouseEvent): void { + const { x, y } = this.toCanvasCoordinates(e.global); + const p = new Point(x, y); + // this.points.pop(); + this.points.push(p); + } + onRightClick(): void { + this.createAndStore(true); + } + + redraw(cp: Point): void { + if (this.points.length < 1) return; + this.graphic.clear(); + this.graphic.lineStyle(SectionConsts.lineWidth, SectionConsts.lineColor); + // this.points.push(cp); + 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); + } + prepareData(data: ISectionData): boolean { + data.points = this.points; + + return true; + } + clearCache(): void { + this.points = []; + this.graphic.clear(); + } +} + +class SectionGraphicHitArea implements IHitArea { + section: Section; + constructor(section: Section) { + 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 }, SectionConsts.lineWidth)) { + return true; + } + } + return false; + } +} + +export class SectionPointEditPlugin extends GraphicInteractionPlugin
{ + static Name = 'SectionPointDrag'; + constructor(app: GraphicApp) { + super(SectionPointEditPlugin.Name, app); + } + static init(app: GraphicApp) { + return new SectionPointEditPlugin(app); + } + filter(...grahpics: JlGraphic[]): Section[] | undefined { + return grahpics.filter((g) => g.type == Section.Type) as Section[]; + } + bind(g: Section): void { + g.lineGraphic.eventMode = 'static'; + g.lineGraphic.cursor = 'pointer'; + g.lineGraphic.hitArea = new SectionGraphicHitArea(g); + g.on('selected', this.onSelected, this); + g.on('unselected', this.onUnselected, this); + } + unbind(g: Section): void { + g.off('selected', this.onSelected, this); + g.off('unselected', this.onUnselected, this); + } + + onSelected(g: DisplayObject): void { + const section = g as Section; + let lep = section.getAssistantAppend( + PolylineEditPlugin.Name + ); + if (!lep) { + lep = new PolylineEditPlugin(section); + section.addAssistantAppend(lep); + } + lep.showAll(); + } + onUnselected(g: DisplayObject): void { + const section = g as Section; + const lep = section.getAssistantAppend( + PolylineEditPlugin.Name + ); + if (lep) { + lep.hideAll(); + } + } +} diff --git a/src/protos/LineNetTrainOffset.ts b/src/protos/LineNetTrainOffset.ts index 09bba80..d1154b6 100644 --- a/src/protos/LineNetTrainOffset.ts +++ b/src/protos/LineNetTrainOffset.ts @@ -10,12 +10,9 @@ export class LineNetTrainOffset extends pb_1.Message { lineId?: number; Group_id?: string; dir?: number; - initType?: boolean; - offset?: number; - destinationId?: number; - backId?: number; show?: boolean; - rate?: number; + windowNo?: number; + windowOffset?: number; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -29,23 +26,14 @@ export class LineNetTrainOffset extends pb_1.Message { if ("dir" in data && data.dir != undefined) { this.dir = data.dir; } - if ("initType" in data && data.initType != undefined) { - this.initType = data.initType; - } - if ("offset" in data && data.offset != undefined) { - this.offset = data.offset; - } - if ("destinationId" in data && data.destinationId != undefined) { - this.destinationId = data.destinationId; - } - if ("backId" in data && data.backId != undefined) { - this.backId = data.backId; - } if ("show" in data && data.show != undefined) { this.show = data.show; } - if ("rate" in data && data.rate != undefined) { - this.rate = data.rate; + if ("windowNo" in data && data.windowNo != undefined) { + this.windowNo = data.windowNo; + } + if ("windowOffset" in data && data.windowOffset != undefined) { + this.windowOffset = data.windowOffset; } } } @@ -67,52 +55,31 @@ export class LineNetTrainOffset extends pb_1.Message { set dir(value: number) { pb_1.Message.setField(this, 3, value); } - get initType() { + get show() { return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean; } - set initType(value: boolean) { + set show(value: boolean) { pb_1.Message.setField(this, 4, value); } - get offset() { + get windowNo() { return pb_1.Message.getFieldWithDefault(this, 5, 0) as number; } - set offset(value: number) { + set windowNo(value: number) { pb_1.Message.setField(this, 5, value); } - get destinationId() { + get windowOffset() { return pb_1.Message.getFieldWithDefault(this, 6, 0) as number; } - set destinationId(value: number) { + set windowOffset(value: number) { pb_1.Message.setField(this, 6, value); } - get backId() { - return pb_1.Message.getFieldWithDefault(this, 7, 0) as number; - } - set backId(value: number) { - pb_1.Message.setField(this, 7, value); - } - get show() { - return pb_1.Message.getFieldWithDefault(this, 8, false) as boolean; - } - set show(value: boolean) { - pb_1.Message.setField(this, 8, value); - } - get rate() { - return pb_1.Message.getFieldWithDefault(this, 9, 0) as number; - } - set rate(value: number) { - pb_1.Message.setField(this, 9, value); - } static fromObject(data: { lineId?: number; Group_id?: string; dir?: number; - initType?: boolean; - offset?: number; - destinationId?: number; - backId?: number; show?: boolean; - rate?: number; + windowNo?: number; + windowOffset?: number; }): LineNetTrainOffset { const message = new LineNetTrainOffset({}); if (data.lineId != null) { @@ -124,23 +91,14 @@ export class LineNetTrainOffset extends pb_1.Message { if (data.dir != null) { message.dir = data.dir; } - if (data.initType != null) { - message.initType = data.initType; - } - if (data.offset != null) { - message.offset = data.offset; - } - if (data.destinationId != null) { - message.destinationId = data.destinationId; - } - if (data.backId != null) { - message.backId = data.backId; - } if (data.show != null) { message.show = data.show; } - if (data.rate != null) { - message.rate = data.rate; + if (data.windowNo != null) { + message.windowNo = data.windowNo; + } + if (data.windowOffset != null) { + message.windowOffset = data.windowOffset; } return message; } @@ -149,12 +107,9 @@ export class LineNetTrainOffset extends pb_1.Message { lineId?: number; Group_id?: string; dir?: number; - initType?: boolean; - offset?: number; - destinationId?: number; - backId?: number; show?: boolean; - rate?: number; + windowNo?: number; + windowOffset?: number; } = {}; if (this.lineId != null) { data.lineId = this.lineId; @@ -165,23 +120,14 @@ export class LineNetTrainOffset extends pb_1.Message { if (this.dir != null) { data.dir = this.dir; } - if (this.initType != null) { - data.initType = this.initType; - } - if (this.offset != null) { - data.offset = this.offset; - } - if (this.destinationId != null) { - data.destinationId = this.destinationId; - } - if (this.backId != null) { - data.backId = this.backId; - } if (this.show != null) { data.show = this.show; } - if (this.rate != null) { - data.rate = this.rate; + if (this.windowNo != null) { + data.windowNo = this.windowNo; + } + if (this.windowOffset != null) { + data.windowOffset = this.windowOffset; } return data; } @@ -195,18 +141,12 @@ export class LineNetTrainOffset extends pb_1.Message { writer.writeString(2, this.Group_id); if (this.dir != 0) writer.writeInt32(3, this.dir); - if (this.initType != false) - writer.writeBool(4, this.initType); - if (this.offset != 0) - writer.writeInt32(5, this.offset); - if (this.destinationId != 0) - writer.writeInt32(6, this.destinationId); - if (this.backId != 0) - writer.writeInt32(7, this.backId); if (this.show != false) - writer.writeBool(8, this.show); - if (this.rate != 0) - writer.writeFloat(9, this.rate); + writer.writeBool(4, this.show); + if (this.windowNo != 0) + writer.writeInt32(5, this.windowNo); + if (this.windowOffset != 0) + writer.writeInt32(6, this.windowOffset); if (!w) return writer.getResultBuffer(); } @@ -226,22 +166,13 @@ export class LineNetTrainOffset extends pb_1.Message { message.dir = reader.readInt32(); break; case 4: - message.initType = reader.readBool(); - break; - case 5: - message.offset = reader.readInt32(); - break; - case 6: - message.destinationId = reader.readInt32(); - break; - case 7: - message.backId = reader.readInt32(); - break; - case 8: message.show = reader.readBool(); break; - case 9: - message.rate = reader.readFloat(); + case 5: + message.windowNo = reader.readInt32(); + break; + case 6: + message.windowOffset = reader.readInt32(); break; default: reader.skipField(); } diff --git a/src/protos/device_status.ts b/src/protos/device_status.ts index 6455e73..49337ea 100644 --- a/src/protos/device_status.ts +++ b/src/protos/device_status.ts @@ -1546,6 +1546,7 @@ export namespace state { ipSingleSwitchStusBlocked2?: boolean; ipSingleSwitchStusLostIndication?: boolean; id?: string; + speedLimit?: number; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -1634,6 +1635,9 @@ export namespace state { if ("id" in data && data.id != undefined) { this.id = data.id; } + if ("speedLimit" in data && data.speedLimit != undefined) { + this.speedLimit = data.speedLimit; + } } } get ipSingleSwitchStusCiOccupied() { @@ -1804,6 +1808,12 @@ export namespace state { set id(value: string) { pb_1.Message.setField(this, 28, value); } + get speedLimit() { + return pb_1.Message.getFieldWithDefault(this, 29, 0) as number; + } + set speedLimit(value: number) { + pb_1.Message.setField(this, 29, value); + } static fromObject(data: { ipSingleSwitchStusCiOccupied?: boolean; ipSingleSwitchStusCbtcOccupied?: boolean; @@ -1833,6 +1843,7 @@ export namespace state { ipSingleSwitchStusBlocked2?: boolean; ipSingleSwitchStusLostIndication?: boolean; id?: string; + speedLimit?: number; }): Switch { const message = new Switch({}); if (data.ipSingleSwitchStusCiOccupied != null) { @@ -1919,6 +1930,9 @@ export namespace state { if (data.id != null) { message.id = data.id; } + if (data.speedLimit != null) { + message.speedLimit = data.speedLimit; + } return message; } toObject() { @@ -1951,6 +1965,7 @@ export namespace state { ipSingleSwitchStusBlocked2?: boolean; ipSingleSwitchStusLostIndication?: boolean; id?: string; + speedLimit?: number; } = {}; if (this.ipSingleSwitchStusCiOccupied != null) { data.ipSingleSwitchStusCiOccupied = this.ipSingleSwitchStusCiOccupied; @@ -2036,6 +2051,9 @@ export namespace state { if (this.id != null) { data.id = this.id; } + if (this.speedLimit != null) { + data.speedLimit = this.speedLimit; + } return data; } serialize(): Uint8Array; @@ -2098,6 +2116,8 @@ export namespace state { writer.writeBool(27, this.ipSingleSwitchStusLostIndication); if (this.id.length) writer.writeString(28, this.id); + if (this.speedLimit != 0) + writer.writeInt32(29, this.speedLimit); if (!w) return writer.getResultBuffer(); } @@ -2191,6 +2211,9 @@ export namespace state { case 28: message.id = reader.readString(); break; + case 29: + message.speedLimit = reader.readInt32(); + break; default: reader.skipField(); } } @@ -2218,6 +2241,8 @@ export namespace state { overlap?: boolean; blocked?: boolean; id?: string; + speedLimit?: number; + limitType?: number; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -2258,6 +2283,12 @@ export namespace state { if ("id" in data && data.id != undefined) { this.id = data.id; } + if ("speedLimit" in data && data.speedLimit != undefined) { + this.speedLimit = data.speedLimit; + } + if ("limitType" in data && data.limitType != undefined) { + this.limitType = data.limitType; + } } } get ciOccupied() { @@ -2332,6 +2363,18 @@ export namespace state { set id(value: string) { pb_1.Message.setField(this, 12, value); } + get speedLimit() { + return pb_1.Message.getFieldWithDefault(this, 13, 0) as number; + } + set speedLimit(value: number) { + pb_1.Message.setField(this, 13, value); + } + get limitType() { + return pb_1.Message.getFieldWithDefault(this, 14, 0) as number; + } + set limitType(value: number) { + pb_1.Message.setField(this, 14, value); + } static fromObject(data: { ciOccupied?: boolean; cbtcOccupied?: boolean; @@ -2345,6 +2388,8 @@ export namespace state { overlap?: boolean; blocked?: boolean; id?: string; + speedLimit?: number; + limitType?: number; }): Track { const message = new Track({}); if (data.ciOccupied != null) { @@ -2383,6 +2428,12 @@ export namespace state { if (data.id != null) { message.id = data.id; } + if (data.speedLimit != null) { + message.speedLimit = data.speedLimit; + } + if (data.limitType != null) { + message.limitType = data.limitType; + } return message; } toObject() { @@ -2399,6 +2450,8 @@ export namespace state { overlap?: boolean; blocked?: boolean; id?: string; + speedLimit?: number; + limitType?: number; } = {}; if (this.ciOccupied != null) { data.ciOccupied = this.ciOccupied; @@ -2436,6 +2489,12 @@ export namespace state { if (this.id != null) { data.id = this.id; } + if (this.speedLimit != null) { + data.speedLimit = this.speedLimit; + } + if (this.limitType != null) { + data.limitType = this.limitType; + } return data; } serialize(): Uint8Array; @@ -2466,6 +2525,10 @@ export namespace state { writer.writeBool(11, this.blocked); if (this.id.length) writer.writeString(12, this.id); + if (this.speedLimit != 0) + writer.writeFloat(13, this.speedLimit); + if (this.limitType != 0) + writer.writeInt32(14, this.limitType); if (!w) return writer.getResultBuffer(); } @@ -2511,6 +2574,12 @@ export namespace state { case 12: message.id = reader.readString(); break; + case 13: + message.speedLimit = reader.readFloat(); + break; + case 14: + message.limitType = reader.readInt32(); + break; default: reader.skipField(); } } @@ -2540,6 +2609,8 @@ export namespace state { upTrainSkipstop?: boolean; downTrainSkipstop?: boolean; id?: string; + nextSectionRunTime?: number; + nextSectionRunLevel?: number; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -2586,6 +2657,12 @@ export namespace state { if ("id" in data && data.id != undefined) { this.id = data.id; } + if ("nextSectionRunTime" in data && data.nextSectionRunTime != undefined) { + this.nextSectionRunTime = data.nextSectionRunTime; + } + if ("nextSectionRunLevel" in data && data.nextSectionRunLevel != undefined) { + this.nextSectionRunLevel = data.nextSectionRunLevel; + } } } get emergstop() { @@ -2672,6 +2749,18 @@ export namespace state { set id(value: string) { pb_1.Message.setField(this, 14, value); } + get nextSectionRunTime() { + return pb_1.Message.getFieldWithDefault(this, 15, 0) as number; + } + set nextSectionRunTime(value: number) { + pb_1.Message.setField(this, 15, value); + } + get nextSectionRunLevel() { + return pb_1.Message.getFieldWithDefault(this, 16, 0) as number; + } + set nextSectionRunLevel(value: number) { + pb_1.Message.setField(this, 16, value); + } static fromObject(data: { emergstop?: boolean; trainberth?: boolean; @@ -2687,6 +2776,8 @@ export namespace state { upTrainSkipstop?: boolean; downTrainSkipstop?: boolean; id?: string; + nextSectionRunTime?: number; + nextSectionRunLevel?: number; }): Platform { const message = new Platform({}); if (data.emergstop != null) { @@ -2731,6 +2822,12 @@ export namespace state { if (data.id != null) { message.id = data.id; } + if (data.nextSectionRunTime != null) { + message.nextSectionRunTime = data.nextSectionRunTime; + } + if (data.nextSectionRunLevel != null) { + message.nextSectionRunLevel = data.nextSectionRunLevel; + } return message; } toObject() { @@ -2749,6 +2846,8 @@ export namespace state { upTrainSkipstop?: boolean; downTrainSkipstop?: boolean; id?: string; + nextSectionRunTime?: number; + nextSectionRunLevel?: number; } = {}; if (this.emergstop != null) { data.emergstop = this.emergstop; @@ -2792,6 +2891,12 @@ export namespace state { if (this.id != null) { data.id = this.id; } + if (this.nextSectionRunTime != null) { + data.nextSectionRunTime = this.nextSectionRunTime; + } + if (this.nextSectionRunLevel != null) { + data.nextSectionRunLevel = this.nextSectionRunLevel; + } return data; } serialize(): Uint8Array; @@ -2826,6 +2931,10 @@ export namespace state { writer.writeBool(13, this.downTrainSkipstop); if (this.id.length) writer.writeString(14, this.id); + if (this.nextSectionRunTime != 0) + writer.writeInt32(15, this.nextSectionRunTime); + if (this.nextSectionRunLevel != 0) + writer.writeInt32(16, this.nextSectionRunLevel); if (!w) return writer.getResultBuffer(); } @@ -2877,6 +2986,12 @@ export namespace state { case 14: message.id = reader.readString(); break; + case 15: + message.nextSectionRunTime = reader.readInt32(); + break; + case 16: + message.nextSectionRunLevel = reader.readInt32(); + break; default: reader.skipField(); } } @@ -4236,4 +4351,94 @@ export namespace state { return TrainMode.deserialize(bytes); } } + export class OccNccFepNetwork extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + id?: string; + active?: 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 ("id" in data && data.id != undefined) { + this.id = data.id; + } + if ("active" in data && data.active != undefined) { + this.active = data.active; + } + } + } + get id() { + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; + } + set id(value: string) { + pb_1.Message.setField(this, 1, value); + } + get active() { + return pb_1.Message.getFieldWithDefault(this, 2, false) as boolean; + } + set active(value: boolean) { + pb_1.Message.setField(this, 2, value); + } + static fromObject(data: { + id?: string; + active?: boolean; + }): OccNccFepNetwork { + const message = new OccNccFepNetwork({}); + if (data.id != null) { + message.id = data.id; + } + if (data.active != null) { + message.active = data.active; + } + return message; + } + toObject() { + const data: { + id?: string; + active?: boolean; + } = {}; + if (this.id != null) { + data.id = this.id; + } + if (this.active != null) { + data.active = this.active; + } + 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.id.length) + writer.writeString(1, this.id); + if (this.active != false) + writer.writeBool(2, this.active); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): OccNccFepNetwork { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new OccNccFepNetwork(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.id = reader.readString(); + break; + case 2: + message.active = reader.readBool(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): OccNccFepNetwork { + return OccNccFepNetwork.deserialize(bytes); + } + } } diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index d5287f8..04ce03e 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -17,9 +17,10 @@ export namespace graphicData { train?: Train[]; signals?: Signal[]; turnouts?: Turnout[]; + section?: Section[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("canvas" in data && data.canvas != undefined) { this.canvas = data.canvas; @@ -48,6 +49,9 @@ export namespace graphicData { if ("turnouts" in data && data.turnouts != undefined) { this.turnouts = data.turnouts; } + if ("section" in data && data.section != undefined) { + this.section = data.section; + } } } get canvas() { @@ -107,6 +111,12 @@ export namespace graphicData { set turnouts(value: Turnout[]) { pb_1.Message.setRepeatedWrapperField(this, 9, value); } + get section() { + return pb_1.Message.getRepeatedWrapperField(this, Section, 10) as Section[]; + } + set section(value: Section[]) { + pb_1.Message.setRepeatedWrapperField(this, 10, value); + } static fromObject(data: { canvas?: ReturnType; links?: ReturnType[]; @@ -117,6 +127,7 @@ export namespace graphicData { train?: ReturnType[]; signals?: ReturnType[]; turnouts?: ReturnType[]; + section?: ReturnType[]; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -146,6 +157,9 @@ export namespace graphicData { if (data.turnouts != null) { message.turnouts = data.turnouts.map(item => Turnout.fromObject(item)); } + if (data.section != null) { + message.section = data.section.map(item => Section.fromObject(item)); + } return message; } toObject() { @@ -159,6 +173,7 @@ export namespace graphicData { train?: ReturnType[]; signals?: ReturnType[]; turnouts?: ReturnType[]; + section?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -187,6 +202,9 @@ export namespace graphicData { if (this.turnouts != null) { data.turnouts = this.turnouts.map((item: Turnout) => item.toObject()); } + if (this.section != null) { + data.section = this.section.map((item: Section) => item.toObject()); + } return data; } serialize(): Uint8Array; @@ -211,6 +229,8 @@ export namespace graphicData { writer.writeRepeatedMessage(8, this.signals, (item: Signal) => item.serialize(writer)); if (this.turnouts.length) 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 (!w) return writer.getResultBuffer(); } @@ -247,6 +267,9 @@ export namespace graphicData { case 9: reader.readMessage(message.turnouts, () => pb_1.Message.addToRepeatedWrapperField(message, 9, Turnout.deserialize(reader), Turnout)); break; + case 10: + reader.readMessage(message.section, () => pb_1.Message.addToRepeatedWrapperField(message, 10, Section.deserialize(reader), Section)); + break; default: reader.skipField(); } } @@ -2061,4 +2084,120 @@ export namespace graphicData { return Signal.deserialize(bytes); } } + export class Section extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + common?: CommonInfo; + code?: string; + points?: Point[]; + }) { + 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; + } + } + } + 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); + } + static fromObject(data: { + common?: ReturnType; + code?: string; + points?: ReturnType[]; + }): Section { + const message = new Section({}); + 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)); + } + return message; + } + toObject() { + const data: { + common?: ReturnType; + code?: string; + points?: 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()); + } + 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 (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Section { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Section(); + 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; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): Section { + return Section.deserialize(bytes); + } + } } diff --git a/xian-ncc-da-message b/xian-ncc-da-message index a8afc44..6c78a70 160000 --- a/xian-ncc-da-message +++ b/xian-ncc-da-message @@ -1 +1 @@ -Subproject commit a8afc44290373cc61ad855327637032102fd10a0 +Subproject commit 6c78a70743779784b1f81ec34cf3eb0156f3a292 From a3e37d0ff862500b7daf0f1aad1078daa1b06dda Mon Sep 17 00:00:00 2001 From: Yuan Date: Mon, 12 Jun 2023 11:04:14 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E9=81=93=E5=B2=94=E5=92=8C=E5=8C=BA?= =?UTF-8?q?=E6=AE=B5=E5=90=B8=E9=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/turnout/Turnout.ts | 4 ++ src/graphics/turnout/TurnoutDrawAssistant.ts | 53 +++++++++++++++++++- 2 files changed, 55 insertions(+), 2 deletions(-) diff --git a/src/graphics/turnout/Turnout.ts b/src/graphics/turnout/Turnout.ts index 5949c5a..3586a84 100644 --- a/src/graphics/turnout/Turnout.ts +++ b/src/graphics/turnout/Turnout.ts @@ -104,6 +104,10 @@ export class Turnout extends JlGraphic { return this.getStates(); } + getPortPoints() { + return [this.datas.pointA, this.datas.pointB, this.datas.pointC]; + } + doRepaint(): void { const { pointA, pointB, pointC } = this.datas; diff --git a/src/graphics/turnout/TurnoutDrawAssistant.ts b/src/graphics/turnout/TurnoutDrawAssistant.ts index 2d6a413..05c8ad6 100644 --- a/src/graphics/turnout/TurnoutDrawAssistant.ts +++ b/src/graphics/turnout/TurnoutDrawAssistant.ts @@ -1,4 +1,5 @@ import { + AbsorbablePosition, DraggablePoint, GraphicApp, GraphicDrawAssistant, @@ -25,6 +26,8 @@ import { } from 'pixi.js'; import { GraphicEditPlugin } from 'src/jl-graphic/plugins/GraphicEditPlugin'; import Vector2 from 'src/jl-graphic/math/Vector2'; +import { Section } from '../section/Section'; +import AbsorbablePoint from 'src/jl-graphic/graphic/AbsorbablePosition'; export class TurnoutDraw extends GraphicDrawAssistant< TurnoutTemplate, @@ -94,6 +97,41 @@ export class TurnoutHitArea implements IHitArea { } } +function buildAbsorbablePositions(turnout: Turnout): AbsorbablePosition[] { + const aps: AbsorbablePosition[] = []; + + const sections = turnout.queryStore.queryByType
(Section.Type); + sections.forEach((section) => { + const ps = new AbsorbablePoint( + section.localToCanvasPoint(section.getStartPoint()) + ); + const pe = new AbsorbablePoint( + section.localToCanvasPoint(section.getEndPoint()) + ); + aps.push(ps, pe); + }); + + const turnouts = turnout.queryStore.queryByType(Turnout.Type); + turnouts.forEach((otherTurnout) => { + if (turnout.id === otherTurnout.id) return; + otherTurnout.getPortPoints().forEach((portPoint) => { + aps.push(new AbsorbablePoint(otherTurnout.localToCanvasPoint(portPoint))); + }); + }); + + return aps; +} + +function onEditPointCreate(turnout: Turnout, dp: DraggablePoint) { + dp.on('transformstart', (e: GraphicTransformEvent) => { + if (e.isShift()) { + turnout.getGraphicApp().setOptions({ + absorbablePositions: buildAbsorbablePositions(turnout), + }); + } + }); +} + export class TurnoutPointsInteractionPlugin extends GraphicInteractionPlugin { static Name = 'TurnoutPointsDrag'; static init(app: JlDrawApp) { @@ -130,7 +168,7 @@ export class TurnoutPointsInteractionPlugin extends GraphicInteractionPlugin void; + +export interface ITurnoutEditOptions { + onEditPointCreate?: onTurnoutEditPointCreate; +} + export class TurnoutEditPlugin extends GraphicEditPlugin { static Name = 'TurnoutEdit'; + options: ITurnoutEditOptions; editPoints: DraggablePoint[] = []; labels: VectorText[] = []; - constructor(graphic: Turnout) { + constructor(graphic: Turnout, options?: ITurnoutEditOptions) { super(graphic); this.name = TurnoutEditPlugin.Name; + this.options = Object.assign({}, options); this.initEditPoints(); } reset(): void { @@ -208,6 +254,9 @@ export class TurnoutEditPlugin extends GraphicEditPlugin { this.graphic.repaint(); }); + if (this.options.onEditPointCreate) { + this.options.onEditPointCreate(this.graphic, dp); + } this.editPoints.push(dp); }); this.addChild(...this.editPoints); From 9a0e93d705506d58ba882bfa1f391582c59525ed Mon Sep 17 00:00:00 2001 From: Yuan Date: Mon, 12 Jun 2023 11:05:01 +0800 Subject: [PATCH 3/8] =?UTF-8?q?message=20=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/protos/device_status.ts | 51 +++++++++++++++++++++++++++++-------- xian-ncc-da-message | 2 +- 2 files changed, 42 insertions(+), 11 deletions(-) diff --git a/src/protos/device_status.ts b/src/protos/device_status.ts index 49337ea..abc6b9d 100644 --- a/src/protos/device_status.ts +++ b/src/protos/device_status.ts @@ -2242,7 +2242,7 @@ export namespace state { blocked?: boolean; id?: string; speedLimit?: number; - limitType?: number; + limitType?: Track.LimitType; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -2370,9 +2370,9 @@ export namespace state { pb_1.Message.setField(this, 13, value); } get limitType() { - return pb_1.Message.getFieldWithDefault(this, 14, 0) as number; + return pb_1.Message.getFieldWithDefault(this, 14, Track.LimitType.Unknown) as Track.LimitType; } - set limitType(value: number) { + set limitType(value: Track.LimitType) { pb_1.Message.setField(this, 14, value); } static fromObject(data: { @@ -2389,7 +2389,7 @@ export namespace state { blocked?: boolean; id?: string; speedLimit?: number; - limitType?: number; + limitType?: Track.LimitType; }): Track { const message = new Track({}); if (data.ciOccupied != null) { @@ -2451,7 +2451,7 @@ export namespace state { blocked?: boolean; id?: string; speedLimit?: number; - limitType?: number; + limitType?: Track.LimitType; } = {}; if (this.ciOccupied != null) { data.ciOccupied = this.ciOccupied; @@ -2526,9 +2526,9 @@ export namespace state { if (this.id.length) writer.writeString(12, this.id); if (this.speedLimit != 0) - writer.writeFloat(13, this.speedLimit); - if (this.limitType != 0) - writer.writeInt32(14, this.limitType); + writer.writeInt32(13, this.speedLimit); + if (this.limitType != Track.LimitType.Unknown) + writer.writeEnum(14, this.limitType); if (!w) return writer.getResultBuffer(); } @@ -2575,10 +2575,10 @@ export namespace state { message.id = reader.readString(); break; case 13: - message.speedLimit = reader.readFloat(); + message.speedLimit = reader.readInt32(); break; case 14: - message.limitType = reader.readInt32(); + message.limitType = reader.readEnum(); break; default: reader.skipField(); } @@ -2592,6 +2592,14 @@ export namespace state { return Track.deserialize(bytes); } } + export namespace Track { + export enum LimitType { + Unknown = 0, + Cbtc = 1, + Interlock = 2, + CbtcInterlock = 4 + } + } export class Platform extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { @@ -2611,6 +2619,7 @@ export namespace state { id?: string; nextSectionRunTime?: number; nextSectionRunLevel?: number; + stopTime?: number; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -2663,6 +2672,9 @@ export namespace state { if ("nextSectionRunLevel" in data && data.nextSectionRunLevel != undefined) { this.nextSectionRunLevel = data.nextSectionRunLevel; } + if ("stopTime" in data && data.stopTime != undefined) { + this.stopTime = data.stopTime; + } } } get emergstop() { @@ -2761,6 +2773,12 @@ export namespace state { set nextSectionRunLevel(value: number) { pb_1.Message.setField(this, 16, value); } + get stopTime() { + return pb_1.Message.getFieldWithDefault(this, 17, 0) as number; + } + set stopTime(value: number) { + pb_1.Message.setField(this, 17, value); + } static fromObject(data: { emergstop?: boolean; trainberth?: boolean; @@ -2778,6 +2796,7 @@ export namespace state { id?: string; nextSectionRunTime?: number; nextSectionRunLevel?: number; + stopTime?: number; }): Platform { const message = new Platform({}); if (data.emergstop != null) { @@ -2828,6 +2847,9 @@ export namespace state { if (data.nextSectionRunLevel != null) { message.nextSectionRunLevel = data.nextSectionRunLevel; } + if (data.stopTime != null) { + message.stopTime = data.stopTime; + } return message; } toObject() { @@ -2848,6 +2870,7 @@ export namespace state { id?: string; nextSectionRunTime?: number; nextSectionRunLevel?: number; + stopTime?: number; } = {}; if (this.emergstop != null) { data.emergstop = this.emergstop; @@ -2897,6 +2920,9 @@ export namespace state { if (this.nextSectionRunLevel != null) { data.nextSectionRunLevel = this.nextSectionRunLevel; } + if (this.stopTime != null) { + data.stopTime = this.stopTime; + } return data; } serialize(): Uint8Array; @@ -2935,6 +2961,8 @@ export namespace state { writer.writeInt32(15, this.nextSectionRunTime); if (this.nextSectionRunLevel != 0) writer.writeInt32(16, this.nextSectionRunLevel); + if (this.stopTime != 0) + writer.writeInt32(17, this.stopTime); if (!w) return writer.getResultBuffer(); } @@ -2992,6 +3020,9 @@ export namespace state { case 16: message.nextSectionRunLevel = reader.readInt32(); break; + case 17: + message.stopTime = reader.readInt32(); + break; default: reader.skipField(); } } diff --git a/xian-ncc-da-message b/xian-ncc-da-message index 6c78a70..d424b94 160000 --- a/xian-ncc-da-message +++ b/xian-ncc-da-message @@ -1 +1 @@ -Subproject commit 6c78a70743779784b1f81ec34cf3eb0156f3a292 +Subproject commit d424b9466a5eeda8b5553a275a495eb7aa1f172a From de866d9250f3c8d8fdddf2900804aafb8a01c788 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 12 Jun 2023 13:25:48 +0800 Subject: [PATCH 4/8] =?UTF-8?q?=E7=BA=BF=E7=BD=91=E8=BD=A6=E7=AB=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/draw-app/DrawProperties.vue | 5 + .../properties/StationLineProperty.vue | 80 ++++++++++ .../graphics/StationLineInteraction.ts | 46 ++++++ src/drawApp/index.ts | 42 ++++-- src/graphics/stationLine/StationLine.ts | 140 +++++++++++++++++ .../stationLine/StationLineDrawAssistant.ts | 100 +++++++++++++ src/protos/stationLayoutGraphics.ts | 141 +++++++++++++++++- 7 files changed, 544 insertions(+), 10 deletions(-) create mode 100644 src/components/draw-app/properties/StationLineProperty.vue create mode 100644 src/drawApp/graphics/StationLineInteraction.ts create mode 100644 src/graphics/stationLine/StationLine.ts create mode 100644 src/graphics/stationLine/StationLineDrawAssistant.ts diff --git a/src/components/draw-app/DrawProperties.vue b/src/components/draw-app/DrawProperties.vue index 942db5d..3806e44 100644 --- a/src/components/draw-app/DrawProperties.vue +++ b/src/components/draw-app/DrawProperties.vue @@ -51,6 +51,9 @@ + @@ -80,6 +83,7 @@ import LinkProperty from './properties/LinkProperty.vue'; import RectProperty from './properties/RectProperty.vue'; 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 IscsFanProperty from './properties/IscsFanProperty.vue'; import SignalProperty from './properties/SignalProperty.vue'; @@ -88,6 +92,7 @@ import { Link } from 'src/graphics/link/Link'; import { Rect } from 'src/graphics/rect/Rect'; import { Platform } from 'src/graphics/platform/Platform'; import { Station } from 'src/graphics/station/Station'; +import { StationLine } from 'src/graphics/stationLine/StationLine'; import { Train } from 'src/graphics/train/Train'; import { useDrawStore } from 'src/stores/draw-store'; import { IscsFan } from 'src/graphics/iscs-fan/IscsFan'; diff --git a/src/components/draw-app/properties/StationLineProperty.vue b/src/components/draw-app/properties/StationLineProperty.vue new file mode 100644 index 0000000..b23ed30 --- /dev/null +++ b/src/components/draw-app/properties/StationLineProperty.vue @@ -0,0 +1,80 @@ + + + diff --git a/src/drawApp/graphics/StationLineInteraction.ts b/src/drawApp/graphics/StationLineInteraction.ts new file mode 100644 index 0000000..03ee132 --- /dev/null +++ b/src/drawApp/graphics/StationLineInteraction.ts @@ -0,0 +1,46 @@ +import * as pb_1 from 'google-protobuf'; +import { IStationLineData } from 'src/graphics/stationLine/StationLine'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { GraphicDataBase } from './GraphicDataBase'; + +export class StationLineData + extends GraphicDataBase + implements IStationLineData +{ + constructor(data?: graphicData.StationLine) { + let stationLine; + if (!data) { + stationLine = new graphicData.StationLine({ + common: GraphicDataBase.defaultCommonInfo(), + }); + } else { + stationLine = data; + } + super(stationLine); + } + + public get data(): graphicData.StationLine { + return this.getData(); + } + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + get hasTransfer(): boolean { + return this.data.hasTransfer; + } + set hasTransfer(v: boolean) { + this.data.hasTransfer = v; + } + clone(): StationLineData { + return new StationLineData(this.data.cloneMessage()); + } + copyFrom(data: StationLineData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: StationLineData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index abd7936..de31501 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -3,13 +3,7 @@ import { IPointData, Point } from 'pixi.js'; import { IscsFan } from 'src/graphics/iscs-fan/IscsFan'; import { Link } from 'src/graphics/link/Link'; import { LinkDraw } from 'src/graphics/link/LinkDrawAssistant'; -import { Rect } from 'src/graphics/rect/Rect'; -import { RectDraw } from 'src/graphics/rect/RectDrawAssistant'; -import { Platform } from 'src/graphics/platform/Platform'; -import { PlatformDraw } from 'src/graphics/platform/PlatformDrawAssistant'; -import { Station } from 'src/graphics/station/Station'; import { Train } from 'src/graphics/train/Train'; -import { StationDraw } from 'src/graphics/station/StationDrawAssistant'; import { TrainDraw } from 'src/graphics/train/TrainDrawAssistant'; import { Signal } from 'src/graphics/signal/Signal'; import { SignalDraw } from 'src/graphics/signal/SignalDrawAssistant'; @@ -25,12 +19,21 @@ import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu'; import { MenuItemOptions } from 'src/jl-graphic/ui/Menu'; import { IscsFanData } from './graphics/IscsFanInteraction'; import { LinkData } from './graphics/LinkInteraction'; -import { RectData } from './graphics/RectInteraction'; -import { PlatformData } from './graphics/PlatformInteraction'; -import { StationData } from './graphics/StationInteraction'; import { TrainData } from './graphics/TrainInteraction'; import { SignalData } from './graphics/SignalInteraction'; import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { Rect } from 'src/graphics/rect/Rect'; +import { RectDraw } from 'src/graphics/rect/RectDrawAssistant'; +import { RectData } from './graphics/RectInteraction'; +import { Platform } from 'src/graphics/platform/Platform'; +import { PlatformData } from './graphics/PlatformInteraction'; +import { PlatformDraw } from 'src/graphics/platform/PlatformDrawAssistant'; +import { Station } from 'src/graphics/station/Station'; +import { StationDraw } from 'src/graphics/station/StationDrawAssistant'; +import { StationData } from './graphics/StationInteraction'; +import { StationLine } from 'src/graphics/stationLine/StationLine'; +import { StationLineDraw } from 'src/graphics/stationLine/StationLineDrawAssistant'; +import { StationLineData } from './graphics/StationLineInteraction'; import { Turnout } from 'src/graphics/turnout/Turnout'; import { TurnoutDraw } from 'src/graphics/turnout/TurnoutDrawAssistant'; import { TurnoutData } from './graphics/TurnoutInteraction'; @@ -117,6 +120,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { | SignalDraw | TurnoutDraw | SectionDraw + | StationLineDraw )[] = []; if (draftType === 'Line') { drawAssistants = [ @@ -137,6 +141,20 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { // }), new SectionDraw(app, () => new SectionData()), ]; + } else { + drawAssistants = [ + new StationLineDraw(app, () => { + return new StationLineData(); + }), + ]; + app.addKeyboardListener( + new KeyListener({ + value: 'KeyI', + onPress: () => { + app.interactionPlugin(StationLine.Type).resume(); + }, + }) + ); } app.setOptions({ drawAssistants: drawAssistants }); @@ -224,6 +242,9 @@ export function saveDrawDatas(app: JlDrawApp) { } else if (Section.Type === g.type) { const sectionData = (g as Section).saveData(); storage.section.push((sectionData as SectionData).data); + } else if (StationLine.Type === g.type) { + const stationLineData = (g as StationLine).saveData(); + storage.stationLines.push((stationLineData as StationLineData).data); } }); const base64 = fromUint8Array(storage.serialize()); @@ -276,6 +297,9 @@ export async function loadDrawDatas(app: GraphicApp) { storage.section.forEach((section) => { datas.push(new SectionData(section)); }); + storage.stationLines.forEach((stationLine) => { + datas.push(new StationLineData(stationLine)); + }); app.loadGraphic(datas); } else { app.loadGraphic([]); diff --git a/src/graphics/stationLine/StationLine.ts b/src/graphics/stationLine/StationLine.ts new file mode 100644 index 0000000..2ce6a13 --- /dev/null +++ b/src/graphics/stationLine/StationLine.ts @@ -0,0 +1,140 @@ +import { Color, Container, Graphics, Point } from 'pixi.js'; +import { + GraphicData, + JlGraphic, + JlGraphicTemplate, + VectorText, +} from 'src/jl-graphic'; + +export interface IStationLineData extends GraphicData { + get code(): string; // 编号 + set code(v: string); + get hasTransfer(): boolean; + set hasTransfer(v: boolean); + clone(): IStationLineData; + copyFrom(data: IStationLineData): void; + eq(other: IStationLineData): boolean; +} + +const stationConsts = { + radius: 5, + borderWidth: 1, + borderColor: '0xff0000', + fillColor: '0xff0000', + circleOffsetY: -20, + transferRadius: 3.5, + transferWidth: 0.2, + transferColor: '0x0fe81f', + codeColor: '0xF48815', + codeFontSize: 22, + lineWidth: 3, +}; +//子元素--圆点 +class circleGraphic extends Container { + circle: Graphics = new Graphics(); + arcUp: Graphics = new Graphics(); + arcDown: Graphics = new Graphics(); + arrowUp: Graphics = new Graphics(); + arrowDown: Graphics = new Graphics(); + constructor() { + super(); + this.addChild(this.circle); + this.addChild(this.arcUp); + this.addChild(this.arcDown); + this.addChild(this.arrowUp); + this.addChild(this.arrowDown); + } + draw(datas: IStationLineData): void { + const circle = this.circle; + circle.clear(); + circle.lineStyle( + stationConsts.borderWidth, + new Color(stationConsts.borderColor) + ); + circle.beginFill(stationConsts.fillColor, 1); + circle.drawCircle(0, 0, stationConsts.radius); + circle.endFill; + circle.position.set(0, stationConsts.circleOffsetY); + const arcGraphicUp = this.arcUp; + const arcGraphicDown = this.arcDown; + const arrowUpGraphic = this.arrowUp; + const arrowDownGraphic = this.arrowDown; + arcGraphicUp.clear(); + arcGraphicDown.clear(); + arrowUpGraphic.clear(); + arrowDownGraphic.clear(); + if (datas.hasTransfer) { + this.drawTransfer(arcGraphicUp, arrowUpGraphic); + this.drawTransfer(arcGraphicDown, arrowDownGraphic); + arcGraphicDown.rotation = Math.PI; + arrowDownGraphic.rotation = Math.PI - (Math.PI * 1) / 25; + arrowDownGraphic.position.set( + stationConsts.transferRadius, + stationConsts.circleOffsetY + ); + } + } + drawTransfer(transferGraphic: Graphics, arrowGraphic: Graphics): void { + transferGraphic.lineStyle( + stationConsts.transferWidth, + new Color(stationConsts.transferColor) + ); + transferGraphic.arc( + 0, + 0, + stationConsts.transferRadius, + Math.PI / 10, + Math.PI, + false + ); + transferGraphic.position.set(0, stationConsts.circleOffsetY); + arrowGraphic.lineStyle( + stationConsts.transferWidth, + new Color(stationConsts.transferColor) + ); + arrowGraphic.moveTo(0, 0); + arrowGraphic.lineTo(1, 1); + arrowGraphic.moveTo(0, 0); + arrowGraphic.lineTo(-1, 1); + arrowGraphic.position.set( + -stationConsts.transferRadius, + stationConsts.circleOffsetY + ); + arrowGraphic.pivot = new Point(0, 0); + arrowGraphic.rotation = -(Math.PI * 1) / 25; + } +} +export class StationLine extends JlGraphic { + static Type = 'stationLine'; + codeGraph: VectorText = new VectorText(''); //车站名 + circleGraphic: circleGraphic = new circleGraphic(); + constructor() { + super(StationLine.Type); + this.addChild(this.codeGraph); + this.addChild(this.circleGraphic); + this.circleGraphic.name = 'circle'; + } + + get datas(): IStationLineData { + return this.getDatas(); + } + doRepaint(): void { + const codeGraph = this.codeGraph; + codeGraph.text = this.datas?.code || '车站StationLine'; + codeGraph.style.fill = stationConsts.codeColor; + codeGraph.setVectorFontSize(stationConsts.codeFontSize); + codeGraph.anchor.set(0.5); + this.circleGraphic.draw(this.datas); + } +} + +export class StationLineTemplate extends JlGraphicTemplate { + hasTransfer: boolean; + constructor() { + super(StationLine.Type); + this.hasTransfer = true; + } + new(): StationLine { + return new StationLine(); + } +} diff --git a/src/graphics/stationLine/StationLineDrawAssistant.ts b/src/graphics/stationLine/StationLineDrawAssistant.ts new file mode 100644 index 0000000..73b7a68 --- /dev/null +++ b/src/graphics/stationLine/StationLineDrawAssistant.ts @@ -0,0 +1,100 @@ +import { FederatedPointerEvent, Point } from 'pixi.js'; +import { + GraphicData, + GraphicDrawAssistant, + GraphicInteractionPlugin, + JlDrawApp, + JlGraphic, +} from 'src/jl-graphic'; + +import { + IStationLineData, + StationLine, + StationLineTemplate, +} from './StationLine'; + +export interface IStationLineDrawOptions { + newData: () => IStationLineData; +} + +export class StationLineDraw extends GraphicDrawAssistant< + StationLineTemplate, + IStationLineData +> { + codeGraph: StationLine; + constructor(app: JlDrawApp, createData: () => IStationLineData) { + super( + app, + new StationLineTemplate(), + createData, + 'svguse:/drawIcon.svg#icon-station', + '车站StationLine' + ); + this.codeGraph = this.graphicTemplate.new(); + this.container.addChild(this.codeGraph); + stationLineInteraction.init(app); + } + + bind(): void { + super.bind(); + const data = { graphicType: 'stationLine' } as GraphicData; + this.codeGraph.loadData(data); + this.codeGraph.doRepaint(); + } + unbind(): void { + super.unbind(); + } + + 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: IStationLineData): boolean { + const template = this.graphicTemplate; + data.transform = this.container.saveTransform(); + data.hasTransfer = template.hasTransfer; + return true; + } +} + +export class stationLineInteraction extends GraphicInteractionPlugin { + static Name = 'stationLine_transform'; + constructor(app: JlDrawApp) { + super(stationLineInteraction.Name, app); + } + static init(app: JlDrawApp) { + return new stationLineInteraction(app); + } + filter(...grahpics: JlGraphic[]): StationLine[] | undefined { + return grahpics + .filter((g) => g.type === StationLine.Type) + .map((g) => g as StationLine); + } + bind(g: StationLine): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.rotatable = true; + g.circleGraphic.eventMode = 'static'; + g.circleGraphic.cursor = 'pointer'; + g.circleGraphic.draggable = true; + g.circleGraphic.selectable = true; + g.circleGraphic.transformSave = true; + } + unbind(g: StationLine): void { + g.eventMode = 'none'; + g.scalable = false; + g.rotatable = false; + g.circleGraphic.eventMode = 'none'; + g.circleGraphic.draggable = false; + g.circleGraphic.selectable = false; + g.circleGraphic.transformSave = false; + } +} diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index 04ce03e..b87dc1e 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -18,9 +18,10 @@ export namespace graphicData { signals?: Signal[]; turnouts?: Turnout[]; section?: Section[]; + stationLines?: StationLine[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10], 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], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("canvas" in data && data.canvas != undefined) { this.canvas = data.canvas; @@ -52,6 +53,9 @@ 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; + } } } get canvas() { @@ -117,6 +121,12 @@ 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); + } static fromObject(data: { canvas?: ReturnType; links?: ReturnType[]; @@ -128,6 +138,7 @@ export namespace graphicData { signals?: ReturnType[]; turnouts?: ReturnType[]; section?: ReturnType[]; + stationLines?: ReturnType[]; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -160,6 +171,9 @@ 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)); + } return message; } toObject() { @@ -174,6 +188,7 @@ export namespace graphicData { signals?: ReturnType[]; turnouts?: ReturnType[]; section?: ReturnType[]; + stationLines?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -205,6 +220,9 @@ 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()); + } return data; } serialize(): Uint8Array; @@ -231,6 +249,8 @@ 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 (!w) return writer.getResultBuffer(); } @@ -270,6 +290,9 @@ export namespace graphicData { case 10: 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)); + break; default: reader.skipField(); } } @@ -1562,6 +1585,122 @@ 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; + }) { + 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; + } + } + } + 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); + } + static fromObject(data: { + common?: ReturnType; + code?: string; + hasTransfer?: 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; + } + return message; + } + toObject() { + const data: { + common?: ReturnType; + code?: string; + hasTransfer?: 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; + } + 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 (!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; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): StationLine { + return StationLine.deserialize(bytes); + } + } export class Train extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { From 7be8b773d9f2b480a9996ac393f266e598762147 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 12 Jun 2023 13:54:43 +0800 Subject: [PATCH 5/8] =?UTF-8?q?=E7=BA=BF=E7=BD=91=E5=8A=A0=E7=9F=A9?= =?UTF-8?q?=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drawApp/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index de31501..ecc0e9a 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -121,6 +121,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { | TurnoutDraw | SectionDraw | StationLineDraw + | RectDraw )[] = []; if (draftType === 'Line') { drawAssistants = [ @@ -146,6 +147,9 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { new StationLineDraw(app, () => { return new StationLineData(); }), + new RectDraw(app, () => { + return new RectData(); + }), ]; app.addKeyboardListener( new KeyListener({ From fe8fc9cf336eab178e3f1d14f3404512ac4bbc6a Mon Sep 17 00:00:00 2001 From: Yuan Date: Mon, 12 Jun 2023 14:39:13 +0800 Subject: [PATCH 6/8] =?UTF-8?q?=E5=8C=BA=E6=AE=B5=E4=B8=8E=E9=81=93?= =?UTF-8?q?=E5=B2=94=E5=90=B8=E9=99=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/section/SectionDrawAssistant.ts | 58 +++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/src/graphics/section/SectionDrawAssistant.ts b/src/graphics/section/SectionDrawAssistant.ts index 62eea05..fc8e3d0 100644 --- a/src/graphics/section/SectionDrawAssistant.ts +++ b/src/graphics/section/SectionDrawAssistant.ts @@ -1,7 +1,9 @@ import { + DraggablePoint, GraphicApp, GraphicDrawAssistant, GraphicInteractionPlugin, + GraphicTransformEvent, JlDrawApp, JlGraphic, linePoint, @@ -19,7 +21,14 @@ import { IHitArea, Point, } from 'pixi.js'; -import { PolylineEditPlugin } from 'src/jl-graphic/plugins/GraphicEditPlugin'; +import { + ILineGraphic, + PolylineEditPlugin, +} from 'src/jl-graphic/plugins/GraphicEditPlugin'; +import AbsorbablePoint, { + AbsorbablePosition, +} from 'src/jl-graphic/graphic/AbsorbablePosition'; +import { Turnout } from '../turnout/Turnout'; export class SectionDraw extends GraphicDrawAssistant< SectionTemplate, @@ -93,6 +102,51 @@ class SectionGraphicHitArea implements IHitArea { } } +function buildAbsorbablePositions(section: Section): AbsorbablePosition[] { + const aps: AbsorbablePosition[] = []; + + const sections = section.queryStore.queryByType
(Section.Type); + sections.forEach((other) => { + if (other.id == section.id) { + return; + } + const apa = new AbsorbablePoint( + other.localToCanvasPoint(other.getStartPoint()) + ); + const apb = new AbsorbablePoint( + other.localToCanvasPoint(other.getEndPoint()) + ); + aps.push(apa, apb); + }); + + const turnouts = section.queryStore.queryByType(Turnout.Type); + turnouts.forEach((turnout) => { + turnout.localToCanvasPoints(...turnout.getPortPoints()).forEach((p) => { + aps.push(new AbsorbablePoint(p)); + }); + }); + + return aps; +} + +function onEditPointCreate( + g: ILineGraphic, + dp: DraggablePoint, + index: number +): void { + const section = g as Section; + if (index === 0 || index == section.datas.points.length - 1) { + // 端点 + dp.on('transformstart', (e: GraphicTransformEvent) => { + if (e.isShift()) { + section.getGraphicApp().setOptions({ + absorbablePositions: buildAbsorbablePositions(section), + }); + } + }); + } +} + export class SectionPointEditPlugin extends GraphicInteractionPlugin
{ static Name = 'SectionPointDrag'; constructor(app: GraphicApp) { @@ -122,7 +176,7 @@ export class SectionPointEditPlugin extends GraphicInteractionPlugin
{ PolylineEditPlugin.Name ); if (!lep) { - lep = new PolylineEditPlugin(section); + lep = new PolylineEditPlugin(section, { onEditPointCreate }); section.addAssistantAppend(lep); } lep.showAll(); From 916d89abf720a7f89fef961c7175be8610dd8aae Mon Sep 17 00:00:00 2001 From: Yuan Date: Mon, 12 Jun 2023 14:39:42 +0800 Subject: [PATCH 7/8] =?UTF-8?q?bugfix=20-=20token=E8=BF=87=E6=9C=9F?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E7=99=BB=E5=BD=95=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/configs/TokenManage.ts | 4 ++++ src/configs/UrlManage.ts | 1 + src/pages/UserLogin.vue | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/configs/TokenManage.ts b/src/configs/TokenManage.ts index 6360618..11dddf9 100644 --- a/src/configs/TokenManage.ts +++ b/src/configs/TokenManage.ts @@ -7,3 +7,7 @@ export function saveJwtToken(token: string) { export function getJwtToken(): string | null { return sessionStorage.getItem(JwtTokenKey); } + +export function clearJwtToken(): void { + sessionStorage.removeItem(JwtTokenKey); +} diff --git a/src/configs/UrlManage.ts b/src/configs/UrlManage.ts index 3e2eb03..f3db1c6 100644 --- a/src/configs/UrlManage.ts +++ b/src/configs/UrlManage.ts @@ -1,5 +1,6 @@ function getHost(): string { // return '192.168.3.7:9081'; + // return '192.168.3.47:9081'; return '192.168.3.233:9081'; } diff --git a/src/pages/UserLogin.vue b/src/pages/UserLogin.vue index e04fed8..1e0c96c 100644 --- a/src/pages/UserLogin.vue +++ b/src/pages/UserLogin.vue @@ -55,7 +55,7 @@ import { useQuasar } from 'quasar'; import { ApiError } from 'src/boot/axios'; import { login } from 'src/api/UserApi'; -import { saveJwtToken } from 'src/configs/TokenManage'; +import { clearJwtToken, saveJwtToken } from 'src/configs/TokenManage'; import { reactive } from 'vue'; import { useRouter } from 'vue-router'; @@ -69,6 +69,7 @@ const loginInfo = reactive({ async function doLogin() { try { + clearJwtToken(); const token = await login(loginInfo); saveJwtToken(token); router.push({ name: 'home' }); From a10fdad76566ee5e6a1a1d4ef99be31b920630a9 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 12 Jun 2023 15:56:19 +0800 Subject: [PATCH 8/8] =?UTF-8?q?=E5=9C=86=E8=A7=92=E7=9F=A9=E5=BD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draw-app/properties/RectProperty.vue | 54 +++-- src/drawApp/graphics/RectInteraction.ts | 10 +- src/drawApp/index.ts | 4 +- src/graphics/rect/Rect.ts | 69 ++++--- src/graphics/rect/RectDrawAssistant.ts | 186 +++--------------- src/protos/stationLayoutGraphics.ts | 126 ++++++------ 6 files changed, 175 insertions(+), 274 deletions(-) diff --git a/src/components/draw-app/properties/RectProperty.vue b/src/components/draw-app/properties/RectProperty.vue index 703c4a7..d1ec7a3 100644 --- a/src/components/draw-app/properties/RectProperty.vue +++ b/src/components/draw-app/properties/RectProperty.vue @@ -1,9 +1,9 @@ + + + @@ -45,30 +72,29 @@ import { useDrawStore } from 'src/stores/draw-store'; import { onMounted, reactive, watch } from 'vue'; const drawStore = useDrawStore(); -const stationModel = reactive(new RectData()); +const rectModel = reactive(new RectData()); drawStore.$subscribe; watch( () => drawStore.selectedGraphic, (val) => { if (val && val.type == Rect.Type) { - stationModel.copyFrom(val.saveData() as RectData); + rectModel.copyFrom(val.saveData() as RectData); } } ); onMounted(() => { - const station = drawStore.selectedGraphic as Rect; - - if (station) { - stationModel.copyFrom(station.saveData()); + const Rect = drawStore.selectedGraphic as Rect; + if (Rect) { + rectModel.copyFrom(Rect.saveData()); } }); function onUpdate() { - const station = drawStore.selectedGraphic as Rect; - if (station) { - drawStore.getDrawApp().updateGraphicAndRecord(station, stationModel); + const Rect = drawStore.selectedGraphic as Rect; + if (Rect) { + drawStore.getDrawApp().updateGraphicAndRecord(Rect, rectModel); } } diff --git a/src/drawApp/graphics/RectInteraction.ts b/src/drawApp/graphics/RectInteraction.ts index 724ddc3..1336a53 100644 --- a/src/drawApp/graphics/RectInteraction.ts +++ b/src/drawApp/graphics/RectInteraction.ts @@ -57,13 +57,11 @@ export class RectData extends GraphicDataBase implements IRectData { set height(v: number) { this.data.height = v; } - get points(): IPointData[] { - return this.data.points; + get radius(): number { + return this.data.radius; } - set points(points: IPointData[]) { - this.data.points = points.map( - (p) => new graphicData.Point({ x: p.x, y: p.y }) - ); + set radius(v: number) { + this.data.radius = v; } clone(): RectData { return new RectData(this.data.cloneMessage()); diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index ecc0e9a..0d11f34 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -224,7 +224,7 @@ export function saveDrawDatas(app: JlDrawApp) { storage.links.push((linkData as LinkData).data); } else if (Rect.Type === g.type) { const rectData = (g as Rect).saveData(); - storage.Rects.push((rectData as RectData).data); + storage.rects.push((rectData as RectData).data); } else if (IscsFan.Type === g.type) { const IscsFanData = (g as IscsFan).saveData(); storage.iscsFans.push((IscsFanData as IscsFanData).data); @@ -277,7 +277,7 @@ export async function loadDrawDatas(app: GraphicApp) { storage.links.forEach((link) => { datas.push(new LinkData(link)); }); - storage.Rects.forEach((rect) => { + storage.rects.forEach((rect) => { datas.push(new RectData(rect)); }); storage.iscsFans.forEach((fan) => { diff --git a/src/graphics/rect/Rect.ts b/src/graphics/rect/Rect.ts index d0b2d31..2e00c36 100644 --- a/src/graphics/rect/Rect.ts +++ b/src/graphics/rect/Rect.ts @@ -1,5 +1,10 @@ -import { Color, Graphics, IPointData, Point } from 'pixi.js'; -import { GraphicData, JlGraphic, JlGraphicTemplate } from 'src/jl-graphic'; +import { Color, Graphics, IPointData, Point, Rectangle } from 'pixi.js'; +import { + GraphicData, + JlGraphic, + JlGraphicTemplate, + getRectangleCenter, +} from 'src/jl-graphic'; export interface IRectData extends GraphicData { get code(): string; // 编号 @@ -14,8 +19,8 @@ export interface IRectData extends GraphicData { set width(v: number); get height(): number; // 高度 set height(v: number); - get points(): IPointData[]; // 线坐标点 - set points(points: IPointData[]); + get radius(): number; // 圆角半径 + set radius(v: number); clone(): IRectData; copyFrom(data: IRectData): void; eq(other: IRectData): boolean; @@ -24,16 +29,13 @@ export interface IRectData extends GraphicData { const rectConsts = { lineWidth: 2, lineColor: '0xff0000', - width: 60, - height: 20, }; export class Rect extends JlGraphic { static Type = 'Rect'; - rectGraphic: Graphics; + rectGraphic: Graphics = new Graphics(); constructor() { super(Rect.Type); - this.rectGraphic = new Graphics(); this.addChild(this.rectGraphic); } @@ -41,44 +43,53 @@ export class Rect extends JlGraphic { return this.getDatas(); } doRepaint(): void { - const width = this.datas.width; - const height = this.datas.height; - if (this.linePoints.length == 0) { - const r1 = new Point(this.datas.point.x, this.datas.point.y); - const r2 = new Point(r1.x + width, r1.y); - const r3 = new Point(r1.x + width, r1.y + height); - const r4 = new Point(r1.x, r1.y + height); - this.datas.points = [r1, r2, r3, r4, r1]; - } const rectGraphic = this.rectGraphic; rectGraphic.clear(); rectGraphic.lineStyle( this.datas.lineWidth, new Color(this.datas.lineColor) ); - rectGraphic.drawPolygon(this.datas.points); + const radius = this.datas?.radius || 0; + rectGraphic.drawRoundedRect( + 0, + 0, + this.datas.width, + this.datas.height, + radius + ); + rectGraphic.pivot = getRectangleCenter( + new Rectangle(0, 0, this.datas.width, this.datas.height) + ); + const transformPos = this.datas.transform.position; + if (transformPos.x == 0 && transformPos.y == 0) { + this.position.set( + this.datas.point.x + this.datas.width / 2, + this.datas.point.y + this.datas.height / 2 + ); + } else { + this.position.set( + this.datas.transform.position.x, + this.datas.transform.position.y + ); + } } - get linePoints(): IPointData[] { - return this.datas.points; - } - set linePoints(points: IPointData[]) { - const old = this.datas.clone(); - old.points = points; - this.updateData(old); + rectPoints(): IPointData[] { + const r1 = new Point(this.datas.point.x, this.datas.point.y); + const r2 = new Point(r1.x + this.datas.width, r1.y); + const r3 = new Point(r1.x + this.datas.width, r1.y + this.datas.height); + const r4 = new Point(r1.x, r1.y + this.datas.height); + const rectPoints = [r1, r2, r3, r4, r1]; + return rectPoints; } } export class RectTemplate extends JlGraphicTemplate { lineWidth: number; lineColor: string; - width: number; - height: number; constructor() { super(Rect.Type); this.lineWidth = rectConsts.lineWidth; this.lineColor = rectConsts.lineColor; - this.width = rectConsts.width; - this.height = rectConsts.height; } new(): Rect { return new Rect(); diff --git a/src/graphics/rect/RectDrawAssistant.ts b/src/graphics/rect/RectDrawAssistant.ts index 638261d..ab5a7ce 100644 --- a/src/graphics/rect/RectDrawAssistant.ts +++ b/src/graphics/rect/RectDrawAssistant.ts @@ -1,38 +1,13 @@ +import { FederatedPointerEvent, Graphics, Point, IHitArea } from 'pixi.js'; import { - FederatedPointerEvent, - Graphics, - Point, - IHitArea, - DisplayObject, - FederatedMouseEvent, -} from 'pixi.js'; -import { - DraggablePoint, - GraphicApp, GraphicDrawAssistant, GraphicInteractionPlugin, - GraphicTransformEvent, JlDrawApp, JlGraphic, linePoint, } from 'src/jl-graphic'; -import AbsorbablePoint, { - AbsorbablePosition, -} from 'src/jl-graphic/graphic/AbsorbablePosition'; -import { - ILineGraphic, - PolylineEditPlugin, - addWaySegmentingConfig, - addPolygonSegmentingPoint, - clearWayPoint, - clearWaypointsConfig, - getWayLineIndex, -} from 'src/jl-graphic/plugins/GraphicEditPlugin'; -import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu'; - import { IRectData, Rect, RectTemplate } from './Rect'; -import { Link } from '../link/Link'; export interface IRectDrawOptions { newData: () => IRectData; @@ -46,7 +21,7 @@ export class RectDraw extends GraphicDrawAssistant { constructor(app: JlDrawApp, createData: () => IRectData) { super(app, new RectTemplate(), createData, 'sym_o_square', '矩形Rect'); this.container.addChild(this.rectGraphic); - RectPointsEditPlugin.init(app); + rectInteraction.init(app); } bind(): void { @@ -90,10 +65,6 @@ export class RectDraw extends GraphicDrawAssistant { return [x, y, w, h]; } prepareData(data: IRectData): boolean { - if (this.point1 == null) { - console.log('Rect绘制因点不够取消绘制'); - return false; - } const p1 = this.point1 as Point; const p2 = this.point2 as Point; const [x, y, width, height] = this.normalize(p1, p2); @@ -115,147 +86,42 @@ export class RectGraphicHitArea implements IHitArea { } contains(x: number, y: number): boolean { let contains = false; + const datas = this.rect.datas; + const tolerance = datas.lineWidth; + const p1 = new Point(0, 0); + const p2 = new Point(p1.x + datas.width, p1.y); + const p3 = new Point(p1.x + datas.width, p1.y + datas.height); + const p4 = new Point(p1.x, p1.y + datas.height); const p = new Point(x, y); - const rectData = this.rect.datas; - //contains = pointPolygon(p, rectData.points, rectData.lineWidth);是否包含多边形内部 - const tolerance = rectData.lineWidth; - for (let i = 0; i < rectData.points.length - 1; i++) { - const p1 = rectData.points[i]; - const p2 = rectData.points[i + 1]; - contains = contains || linePoint(p1, p2, p, tolerance); - if (contains) { - break; - } - } + 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; } } -/** - * 构建吸附位置 - * @param rect - * @returns - */ -function buildAbsorbablePositions(rect: Rect): AbsorbablePosition[] { - const aps: AbsorbablePosition[] = []; - const rects = rect.queryStore.queryByType(Rect.Type); - const links = rect.queryStore.queryByType(Link.Type); - - links.forEach((other) => { - const apa = new AbsorbablePoint( - other.localToCanvasPoint(other.getStartPoint()) - ); - const apb = new AbsorbablePoint( - other.localToCanvasPoint(other.getEndPoint()) - ); - aps.push(apa, apb); - }); - - rects.forEach((other) => { - if (other.id == rect.id) { - return; - } - other.linePoints.forEach((point) => { - const absorbablePoint = new AbsorbablePoint( - other.localToCanvasPoint(point) - ); - aps.push(absorbablePoint); - }); - }); - - return aps; -} - -/** - * 端点拖拽添加吸附位置 - * @param g - * @param dp - * @param index - */ -function onEditPointCreate(g: ILineGraphic, dp: DraggablePoint): void { - const rect = g as Rect; - // 端点 - dp.on('transformstart', (e: GraphicTransformEvent) => { - if (e.isShift()) { - rect.getGraphicApp().setOptions({ - absorbablePositions: buildAbsorbablePositions(rect), - }); - } - }); -} - -const RectEditMenu: ContextMenu = ContextMenu.init({ - name: '矩形编辑菜单', - groups: [ - { - items: [addWaySegmentingConfig, clearWaypointsConfig], - }, - ], -}); - -/** - * rect路径编辑 - */ -export class RectPointsEditPlugin extends GraphicInteractionPlugin { - static Name = 'RectPointsDrag'; - constructor(app: GraphicApp) { - super(RectPointsEditPlugin.Name, app); - app.registerMenu(RectEditMenu); +export class rectInteraction extends GraphicInteractionPlugin { + static Name = 'platform_transform'; + constructor(app: JlDrawApp) { + super(rectInteraction.Name, app); } - static init(app: GraphicApp): RectPointsEditPlugin { - return new RectPointsEditPlugin(app); + static init(app: JlDrawApp) { + return new rectInteraction(app); } filter(...grahpics: JlGraphic[]): Rect[] | undefined { - return grahpics.filter((g) => g.type == Rect.Type) as Rect[]; + return grahpics.filter((g) => g.type === Rect.Type).map((g) => g as Rect); } bind(g: Rect): void { - g.rectGraphic.eventMode = 'static'; - g.rectGraphic.cursor = 'pointer'; + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.rotatable = true; g.rectGraphic.hitArea = new RectGraphicHitArea(g); - g.on('_rightclick', this.onContextMenu, this); - g.on('selected', this.onSelected, this); - g.on('unselected', this.onUnselected, this); } unbind(g: Rect): void { - g.off('_rightclick', this.onContextMenu, this); - g.off('selected', this.onSelected, this); - g.off('unselected', this.onUnselected, this); - } - - onContextMenu(e: FederatedMouseEvent) { - const target = e.target as DisplayObject; - const rect = target.getGraphic() as Rect; - this.app.updateSelected(rect); - addWaySegmentingConfig.handler = () => { - const linePoints = rect.linePoints; - const p = rect.screenToLocalPoint(e.global); - const { start, end } = getWayLineIndex(linePoints, p); - addPolygonSegmentingPoint(rect, start, end); - }; - clearWaypointsConfig.handler = () => { - clearWayPoint(rect, false); - }; - RectEditMenu.open(e.global); - } - - onSelected(g: DisplayObject): void { - const rect = g as Rect; - let lep = rect.getAssistantAppend( - PolylineEditPlugin.Name - ); - if (!lep) { - lep = new PolylineEditPlugin(rect, { onEditPointCreate }); - rect.addAssistantAppend(lep); - } - lep.showAll(); - } - onUnselected(g: DisplayObject): void { - const rect = g as Rect; - const lep = rect.getAssistantAppend( - PolylineEditPlugin.Name - ); - if (lep) { - lep.hideAll(); - } + g.eventMode = 'none'; + g.scalable = false; + g.rotatable = false; } } diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index b87dc1e..b375f2c 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -13,7 +13,7 @@ export namespace graphicData { iscsFans?: IscsFan[]; Platforms?: Platform[]; stations?: Station[]; - Rects?: Rect[]; + rects?: Rect[]; train?: Train[]; signals?: Signal[]; turnouts?: Turnout[]; @@ -38,8 +38,8 @@ export namespace graphicData { if ("stations" in data && data.stations != undefined) { this.stations = data.stations; } - if ("Rects" in data && data.Rects != undefined) { - this.Rects = data.Rects; + if ("rects" in data && data.rects != undefined) { + this.rects = data.rects; } if ("train" in data && data.train != undefined) { this.train = data.train; @@ -91,10 +91,10 @@ export namespace graphicData { set stations(value: Station[]) { pb_1.Message.setRepeatedWrapperField(this, 5, value); } - get Rects() { + get rects() { return pb_1.Message.getRepeatedWrapperField(this, Rect, 6) as Rect[]; } - set Rects(value: Rect[]) { + set rects(value: Rect[]) { pb_1.Message.setRepeatedWrapperField(this, 6, value); } get train() { @@ -133,7 +133,7 @@ export namespace graphicData { iscsFans?: ReturnType[]; Platforms?: ReturnType[]; stations?: ReturnType[]; - Rects?: ReturnType[]; + rects?: ReturnType[]; train?: ReturnType[]; signals?: ReturnType[]; turnouts?: ReturnType[]; @@ -156,8 +156,8 @@ export namespace graphicData { if (data.stations != null) { message.stations = data.stations.map(item => Station.fromObject(item)); } - if (data.Rects != null) { - message.Rects = data.Rects.map(item => Rect.fromObject(item)); + if (data.rects != null) { + message.rects = data.rects.map(item => Rect.fromObject(item)); } if (data.train != null) { message.train = data.train.map(item => Train.fromObject(item)); @@ -183,7 +183,7 @@ export namespace graphicData { iscsFans?: ReturnType[]; Platforms?: ReturnType[]; stations?: ReturnType[]; - Rects?: ReturnType[]; + rects?: ReturnType[]; train?: ReturnType[]; signals?: ReturnType[]; turnouts?: ReturnType[]; @@ -205,8 +205,8 @@ export namespace graphicData { if (this.stations != null) { data.stations = this.stations.map((item: Station) => item.toObject()); } - if (this.Rects != null) { - data.Rects = this.Rects.map((item: Rect) => item.toObject()); + if (this.rects != null) { + data.rects = this.rects.map((item: Rect) => item.toObject()); } if (this.train != null) { data.train = this.train.map((item: Train) => item.toObject()); @@ -239,8 +239,8 @@ export namespace graphicData { writer.writeRepeatedMessage(4, this.Platforms, (item: Platform) => item.serialize(writer)); if (this.stations.length) writer.writeRepeatedMessage(5, this.stations, (item: Station) => item.serialize(writer)); - if (this.Rects.length) - writer.writeRepeatedMessage(6, this.Rects, (item: Rect) => item.serialize(writer)); + if (this.rects.length) + writer.writeRepeatedMessage(6, this.rects, (item: Rect) => item.serialize(writer)); if (this.train.length) writer.writeRepeatedMessage(7, this.train, (item: Train) => item.serialize(writer)); if (this.signals.length) @@ -276,7 +276,7 @@ export namespace graphicData { reader.readMessage(message.stations, () => pb_1.Message.addToRepeatedWrapperField(message, 5, Station.deserialize(reader), Station)); break; case 6: - reader.readMessage(message.Rects, () => pb_1.Message.addToRepeatedWrapperField(message, 6, Rect.deserialize(reader), Rect)); + reader.readMessage(message.rects, () => pb_1.Message.addToRepeatedWrapperField(message, 6, Rect.deserialize(reader), Rect)); break; case 7: reader.readMessage(message.train, () => pb_1.Message.addToRepeatedWrapperField(message, 7, Train.deserialize(reader), Train)); @@ -1126,13 +1126,13 @@ export namespace graphicData { code?: string; lineWidth?: number; lineColor?: string; - point?: Point; width?: number; height?: number; - points?: Point[]; + radius?: number; + point?: Point; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [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; @@ -1146,17 +1146,17 @@ export namespace graphicData { if ("lineColor" in data && data.lineColor != undefined) { this.lineColor = data.lineColor; } - if ("point" in data && data.point != undefined) { - this.point = data.point; - } if ("width" in data && data.width != undefined) { this.width = data.width; } if ("height" in data && data.height != undefined) { this.height = data.height; } - if ("points" in data && data.points != undefined) { - this.points = data.points; + if ("radius" in data && data.radius != undefined) { + this.radius = data.radius; + } + if ("point" in data && data.point != undefined) { + this.point = data.point; } } } @@ -1187,42 +1187,42 @@ export namespace graphicData { set lineColor(value: string) { pb_1.Message.setField(this, 4, value); } - get point() { - return pb_1.Message.getWrapperField(this, Point, 5) as Point; - } - set point(value: Point) { - pb_1.Message.setWrapperField(this, 5, value); - } - get has_point() { - return pb_1.Message.getField(this, 5) != null; - } get width() { - return pb_1.Message.getFieldWithDefault(this, 6, 0) as number; + return pb_1.Message.getFieldWithDefault(this, 5, 0) as number; } set width(value: number) { - pb_1.Message.setField(this, 6, value); + pb_1.Message.setField(this, 5, value); } get height() { - return pb_1.Message.getFieldWithDefault(this, 7, 0) as number; + return pb_1.Message.getFieldWithDefault(this, 6, 0) as number; } set height(value: number) { + pb_1.Message.setField(this, 6, value); + } + get radius() { + return pb_1.Message.getFieldWithDefault(this, 7, 0) as number; + } + set radius(value: number) { pb_1.Message.setField(this, 7, value); } - get points() { - return pb_1.Message.getRepeatedWrapperField(this, Point, 8) as Point[]; + get point() { + return pb_1.Message.getWrapperField(this, Point, 8) as Point; } - set points(value: Point[]) { - pb_1.Message.setRepeatedWrapperField(this, 8, value); + set point(value: Point) { + pb_1.Message.setWrapperField(this, 8, value); + } + get has_point() { + return pb_1.Message.getField(this, 8) != null; } static fromObject(data: { common?: ReturnType; code?: string; lineWidth?: number; lineColor?: string; - point?: ReturnType; width?: number; height?: number; - points?: ReturnType[]; + radius?: number; + point?: ReturnType; }): Rect { const message = new Rect({}); if (data.common != null) { @@ -1237,17 +1237,17 @@ export namespace graphicData { if (data.lineColor != null) { message.lineColor = data.lineColor; } - if (data.point != null) { - message.point = Point.fromObject(data.point); - } if (data.width != null) { message.width = data.width; } if (data.height != null) { message.height = data.height; } - if (data.points != null) { - message.points = data.points.map(item => Point.fromObject(item)); + if (data.radius != null) { + message.radius = data.radius; + } + if (data.point != null) { + message.point = Point.fromObject(data.point); } return message; } @@ -1257,10 +1257,10 @@ export namespace graphicData { code?: string; lineWidth?: number; lineColor?: string; - point?: ReturnType; width?: number; height?: number; - points?: ReturnType[]; + radius?: number; + point?: ReturnType; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -1274,17 +1274,17 @@ export namespace graphicData { if (this.lineColor != null) { data.lineColor = this.lineColor; } - if (this.point != null) { - data.point = this.point.toObject(); - } if (this.width != null) { data.width = this.width; } if (this.height != null) { data.height = this.height; } - if (this.points != null) { - data.points = this.points.map((item: Point) => item.toObject()); + if (this.radius != null) { + data.radius = this.radius; + } + if (this.point != null) { + data.point = this.point.toObject(); } return data; } @@ -1300,14 +1300,14 @@ export namespace graphicData { writer.writeInt32(3, this.lineWidth); if (this.lineColor.length) writer.writeString(4, this.lineColor); - if (this.has_point) - writer.writeMessage(5, this.point, () => this.point.serialize(writer)); if (this.width != 0) - writer.writeFloat(6, this.width); + writer.writeFloat(5, this.width); if (this.height != 0) - writer.writeFloat(7, this.height); - if (this.points.length) - writer.writeRepeatedMessage(8, this.points, (item: Point) => item.serialize(writer)); + writer.writeFloat(6, this.height); + if (this.radius != 0) + writer.writeInt32(7, this.radius); + if (this.has_point) + writer.writeMessage(8, this.point, () => this.point.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -1330,16 +1330,16 @@ export namespace graphicData { message.lineColor = reader.readString(); break; case 5: - reader.readMessage(message.point, () => message.point = Point.deserialize(reader)); - break; - case 6: message.width = reader.readFloat(); break; - case 7: + case 6: message.height = reader.readFloat(); break; + case 7: + message.radius = reader.readInt32(); + break; case 8: - reader.readMessage(message.points, () => pb_1.Message.addToRepeatedWrapperField(message, 8, Point.deserialize(reader), Point)); + reader.readMessage(message.point, () => message.point = Point.deserialize(reader)); break; default: reader.skipField(); }