From 0e655938565fe19d231b66a424c5071085ab530d Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Thu, 3 Aug 2023 15:01:51 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E5=9B=BE=E5=B1=82=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=8E=A7=E5=88=B6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draw-app/dialogs/LayerControlDialog.vue | 43 +++-- src/drawApp/index.ts | 167 ++++++------------ src/drawApp/lineApp.ts | 8 +- src/layouts/DrawLayout.vue | 27 +++ src/layouts/LineLayout.vue | 25 ++- src/stores/line-store.ts | 4 +- 6 files changed, 134 insertions(+), 140 deletions(-) diff --git a/src/components/draw-app/dialogs/LayerControlDialog.vue b/src/components/draw-app/dialogs/LayerControlDialog.vue index a8b7425..53bdf16 100644 --- a/src/components/draw-app/dialogs/LayerControlDialog.vue +++ b/src/components/draw-app/dialogs/LayerControlDialog.vue @@ -1,6 +1,6 @@ @@ -237,6 +244,9 @@ import { Section } from 'src/graphics/section/Section'; import { LogicSection } from 'src/graphics/logicSection/LogicSection'; import { LogicSectionDraw } from 'src/graphics/logicSection/LogicSectionDrawAssistant'; import { useQuasar } from 'quasar'; +import LayerControlDialog from 'src/components/draw-app/dialogs/LayerControlDialog.vue'; +import { drawLayerList } from 'src/drawApp/index'; +import { useLineStore } from 'src/stores/line-store'; const $q = useQuasar(); const route = useRoute(); @@ -244,6 +254,7 @@ const router = useRouter(); const searchId = ref(''); const drawStore = useDrawStore(); +const lineStore = useLineStore(); watch( () => drawStore.drawMode, @@ -462,4 +473,20 @@ async function saveAs(name: string) { onUnmounted(() => { drawStore.destroy(); }); + +function setShowLayer(val: string[]) { + lineStore.setShowLayer(val); + const drawApp = drawStore.getDrawApp(); + const alllGraphic = drawApp.queryStore.getAllGraphics(); + alllGraphic.forEach((g) => { + if (val.includes(g.type)) { + g.visible = true; + } else { + g.visible = false; + } + }); +} +function onDialogClose() { + lineStore.setShowLayerDialog(false); +} diff --git a/src/layouts/LineLayout.vue b/src/layouts/LineLayout.vue index 595d7f5..63ab4fa 100644 --- a/src/layouts/LineLayout.vue +++ b/src/layouts/LineLayout.vue @@ -21,7 +21,13 @@
- + @@ -35,6 +41,7 @@ import StateProperties from 'src/components/line-app/StateProperties.vue'; // import { Train } from 'src/graphics/train/Train'; // import { Turnout } from 'src/graphics/turnout/Turnout'; import LayerControlDialog from 'src/components/draw-app/dialogs/LayerControlDialog.vue'; +import { layerList } from 'src/drawApp/lineApp'; const canvasWidth = ref(0); const canvasHeight = ref(0); @@ -103,4 +110,20 @@ watch( } } ); + +function setShowLayer(val: string[]) { + lineStore.setShowLayer(val); + const lineApp = lineStore.getLineApp(); + const alllGraphic = lineApp.queryStore.getAllGraphics(); + alllGraphic.forEach((g) => { + if (val.includes(g.type)) { + g.visible = true; + } else { + g.visible = false; + } + }); +} +function onDialogClose() { + lineStore.setShowLayerDialog(false); +} diff --git a/src/stores/line-store.ts b/src/stores/line-store.ts index 99559de..68079ec 100644 --- a/src/stores/line-store.ts +++ b/src/stores/line-store.ts @@ -10,8 +10,8 @@ export const useLineStore = defineStore('line', { simulationId: null as string | null, socketStates: null as GraphicState[] | null, stateProCount: 0, - showLayer: [] as string[], // 显示的图层 - showLayerDialog: false, // 显示图层控制弹窗 + showLayer: [] as string[], // 显示的图层(草稿和发布图公用) + showLayerDialog: false, // 显示图层控制弹窗(草稿和发布图公用) }), getters: { selectedGraphicType: (state) => { From 474429a8277a822435d9c15bc0095a4738253110 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Thu, 3 Aug 2023 16:42:22 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E5=9D=A1=E5=BA=A6=E5=A4=87=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/draw-app/DrawProperties.vue | 5 + .../draw-app/properties/SlopeProperty.vue | 112 +++++++++ src/drawApp/graphics/SlopeInteraction.ts | 70 ++++++ src/drawApp/index.ts | 12 + src/graphics/slope/Slope.ts | 152 ++++++++++++ src/graphics/slope/SlopeAssistant.ts | 121 +++++++++ src/layouts/DrawLayout.vue | 12 + src/protos/stationLayoutGraphics.ts | 233 +++++++++++++++++- 8 files changed, 716 insertions(+), 1 deletion(-) create mode 100644 src/components/draw-app/properties/SlopeProperty.vue create mode 100644 src/drawApp/graphics/SlopeInteraction.ts create mode 100644 src/graphics/slope/Slope.ts create mode 100644 src/graphics/slope/SlopeAssistant.ts diff --git a/src/components/draw-app/DrawProperties.vue b/src/components/draw-app/DrawProperties.vue index b1b628b..a2c4d50 100644 --- a/src/components/draw-app/DrawProperties.vue +++ b/src/components/draw-app/DrawProperties.vue @@ -96,6 +96,9 @@ + @@ -143,6 +146,8 @@ import GatedBoxProperty from './properties/GatedBoxProperty.vue'; import { GatedBox } from 'src/graphics/gatedBox/GatedBox'; import EsbButtonProperty from './properties/EsbButtonProperty.vue'; import { EsbButton } from 'src/graphics/esbButton/EsbButton'; +import { Slope } from 'src/graphics/slope/Slope'; +import SlopeProperty from './properties/SlopeProperty.vue'; const drawStore = useDrawStore(); diff --git a/src/components/draw-app/properties/SlopeProperty.vue b/src/components/draw-app/properties/SlopeProperty.vue new file mode 100644 index 0000000..f65a275 --- /dev/null +++ b/src/components/draw-app/properties/SlopeProperty.vue @@ -0,0 +1,112 @@ + + + diff --git a/src/drawApp/graphics/SlopeInteraction.ts b/src/drawApp/graphics/SlopeInteraction.ts new file mode 100644 index 0000000..f253f85 --- /dev/null +++ b/src/drawApp/graphics/SlopeInteraction.ts @@ -0,0 +1,70 @@ +import * as pb_1 from 'google-protobuf'; +import { GraphicDataBase } from './GraphicDataBase'; +import { ISlopeData, Slope } from 'src/graphics/slope/Slope'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { IPointData } from 'pixi.js'; + +export class SlopeData extends GraphicDataBase implements ISlopeData { + constructor(data?: graphicData.Slope) { + let slope; + if (!data) { + slope = new graphicData.Slope({ + common: GraphicDataBase.defaultCommonInfo(Slope.Type), + }); + } else { + slope = data; + } + super(slope); + } + public get data(): graphicData.Slope { + return this.getData(); + } + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + get points(): IPointData[] { + return this.data.points; + } + set points(points: IPointData[]) { + this.data.points = points.map( + (p) => new graphicData.Point({ x: p.x, y: p.y }) + ); + } + get slopeNumber(): string { + return this.data.slopeNumber; + } + set slopeNumber(v: string) { + this.data.slopeNumber = v; + } + get slopeDirection(): string { + return this.data.slopeDirection; + } + set slopeDirection(v: string) { + this.data.slopeDirection = v; + } + get slopeLong(): number { + return this.data.slopeLong; + } + set slopeLong(v: number) { + this.data.slopeLong = v; + } + get refDeviceId(): string[] { + return this.data.refDeviceId; + } + set refDeviceId(v: string[]) { + this.data.refDeviceId = v; + } + + clone(): SlopeData { + return new SlopeData(this.data.cloneMessage()); + } + copyFrom(data: SlopeData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: SlopeData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 6d3f110..2254332 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -111,6 +111,9 @@ import { TransponderTemplate, } from 'src/graphics/transponder/Transponder'; import { TransponderData } from './graphics/TransponderInteraction'; +import { SlopeDraw } from 'src/graphics/slope/SlopeAssistant'; +import { SlopeData } from './graphics/SlopeInteraction'; +import { Slope, SlopeTemplate } from 'src/graphics/slope/Slope'; import { useLineStore } from 'src/stores/line-store'; // export function fromStoragePoint(p: graphicData.Point): Point { @@ -199,6 +202,7 @@ const showType = [ EsbButton.Type, Transponder.Type, TrainWindow.Type, + Slope.Type, ]; export const drawLayerList = [ // 图层列表 @@ -244,6 +248,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { | GatedBoxDraw | EsbButtonDraw | TransponderDraw + | SlopeDraw )[] = []; if (draftType === 'Line') { drawAssistants = [ @@ -289,6 +294,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { new SpksSwitchDraw(app, new SpksSwitchTemplate(new SpksSwitchData())), new GatedBoxDraw(app, new GatedBoxTemplate(new GatedBoxData())), new EsbButtonDraw(app, new EsbButtonTemplate(new EsbButtonData())), + new SlopeDraw(app, new SlopeTemplate(new SlopeData())), ]; DrawSignalInteraction.init(app); DrawStopPositionInteraction.init(app); @@ -449,6 +455,9 @@ export function saveDrawDatas(app: JlDrawApp) { } else if (Transponder.Type === g.type) { const transponderData = (g as Transponder).saveData(); storage.transponders.push((transponderData as TransponderData).data); + } else if (Slope.Type === g.type) { + const slopeData = (g as Slope).saveData(); + storage.slopes.push((slopeData as SlopeData).data); } }); const base64 = fromUint8Array(storage.serialize()); @@ -532,6 +541,9 @@ export async function loadDrawDatas(app: GraphicApp) { storage.transponders.forEach((transponder) => { datas.push(new TransponderData(transponder)); }); + storage.slopes.forEach((slope) => { + datas.push(new SlopeData(slope)); + }); await app.loadGraphic(datas); } else { app.loadGraphic([]); diff --git a/src/graphics/slope/Slope.ts b/src/graphics/slope/Slope.ts new file mode 100644 index 0000000..b566dcb --- /dev/null +++ b/src/graphics/slope/Slope.ts @@ -0,0 +1,152 @@ +import { Graphics, IPointData } from 'pixi.js'; +import { + GraphicData, + JlGraphic, + JlGraphicTemplate, + VectorText, + calculateLineMidpoint, +} from 'src/jl-graphic'; + +export interface ITurnoutPosRefData { + get id(): string; //道岔的ID + set id(v: string); + get position(): number; //道岔的正反为,0是正位,1是反位 + set position(v: number); +} + +export interface ISlopeData extends GraphicData { + get code(): string; // 名称 + set code(v: string); + get points(): IPointData[]; // 线坐标点 + set points(points: IPointData[]); + get slopeNumber(): string; // 坡度的值 + set slopeNumber(v: string); + get slopeDirection(): string; //坡度方向 有三种,无坡度--上坡--下坡 + set slopeDirection(v: string); + get slopeLong(): number; //该坡度的长度--两端公里标的差值 + set slopeLong(v: number); + get refDeviceId(): string[]; // 坡度关联的设备id + set refDeviceId(v: string[]); + clone(): ISlopeData; + copyFrom(data: ISlopeData): void; + eq(other: ISlopeData): boolean; +} + +export const SlopeConsts = { + lineColor: '0xffffff', + lineWidth: 2, + height: 40, +}; + +export class Slope extends JlGraphic { + static Type = 'Slope'; + lineGraphic: Graphics; + slopeNumber: VectorText; + slopeLong: VectorText; + constructor() { + super(Slope.Type); + this.lineGraphic = new Graphics(); + this.slopeNumber = new VectorText(); + this.slopeNumber.name = 'slopeNumber'; + this.slopeLong = new VectorText(); + this.slopeLong.name = 'slopeLong'; + const vectorTexts = [this.slopeNumber, this.slopeLong]; + vectorTexts.forEach((vectorText) => { + vectorText.setVectorFontSize(14); + vectorText.anchor.set(0.5); + vectorText.style.fill = '0xffffff'; + vectorText.transformSave = true; + }); + this.transformSave = true; + this.addChild(this.lineGraphic); + this.addChild(this.slopeNumber); + this.addChild(this.slopeLong); + } + + get datas(): ISlopeData { + return this.getDatas(); + } + doRepaint(): void { + if (this.datas.points.length < 2) { + throw new Error('Slope坐标数据异常'); + } + this.lineGraphic.clear(); + this.lineGraphic.lineStyle(SlopeConsts.lineWidth, SlopeConsts.lineColor); + let distanceY = 0; + switch (this.datas.slopeDirection) { + case 'up': + distanceY = -SlopeConsts.height / 2; + break; + case 'down': + distanceY = SlopeConsts.height / 2; + break; + } + this.datas.points.forEach((p, i) => { + if (i !== 0) { + this.lineGraphic.lineTo(p.x, p.y + distanceY); + } else { + this.lineGraphic.moveTo(p.x, p.y - distanceY); + } + }); + //坡度值 + this.slopeNumber.text = this.datas.slopeNumber; + const slopeNumberPosition = this.datas.childTransforms?.find( + (t) => t.name === this.slopeNumber.name + )?.transform.position; + if (slopeNumberPosition) { + this.slopeNumber.position.set( + slopeNumberPosition.x, + slopeNumberPosition.y + ); + } else { + const centerPos = calculateLineMidpoint( + this.datas.points[0], + this.datas.points[this.datas.points.length - 1] + ); + this.slopeNumber.position.set(centerPos.x, centerPos.y - 15); + } + //坡度长度 + this.slopeLong.text = this.datas.slopeLong; + const slopeLongPosition = this.datas.childTransforms?.find( + (t) => t.name === this.slopeLong.name + )?.transform.position; + if (slopeLongPosition) { + this.slopeLong.position.set(slopeLongPosition.x, slopeLongPosition.y); + } else { + const centerPos = calculateLineMidpoint( + this.datas.points[0], + this.datas.points[this.datas.points.length - 1] + ); + this.slopeLong.position.set(centerPos.x, centerPos.y + 15); + } + } + get linePoints(): IPointData[] { + return this.datas.points; + } + set linePoints(points: IPointData[]) { + const old = this.datas.clone(); + old.points = points; + this.updateData(old); + } + loadRelations() { + if (this.datas.refDeviceId.length) { + this.datas.refDeviceId.forEach((id) => { + const section = this.queryStore.queryById(id); + this.relationManage.addRelation(this, section); + }); + } + } +} + +export class SlopeTemplate extends JlGraphicTemplate { + constructor(dataTemplate: ISlopeData) { + super(Slope.Type, { + dataTemplate, + }); + } + new(): Slope { + const slope = new Slope(); + slope.loadData(this.datas); + return slope; + } +} diff --git a/src/graphics/slope/SlopeAssistant.ts b/src/graphics/slope/SlopeAssistant.ts new file mode 100644 index 0000000..bf6a101 --- /dev/null +++ b/src/graphics/slope/SlopeAssistant.ts @@ -0,0 +1,121 @@ +import { FederatedPointerEvent, IHitArea, Point } from 'pixi.js'; +import { + GraphicDrawAssistant, + GraphicIdGenerator, + GraphicInteractionPlugin, + JlDrawApp, + JlGraphic, + linePoint, +} from 'src/jl-graphic'; + +import { ISlopeData, Slope, SlopeTemplate, SlopeConsts } from './Slope'; +import { AxleCounting } from '../axleCounting/AxleCounting'; + +export interface ISlopeDrawOptions { + newData: () => ISlopeData; +} +export class SlopeDraw extends GraphicDrawAssistant { + codeGraph: Slope; + constructor(app: JlDrawApp, template: SlopeTemplate) { + super(app, template, 'sym_o_circle', '不展示'); + this.codeGraph = this.graphicTemplate.new(); + this.container.addChild(this.codeGraph); + SlopeInteraction.init(app); + } + + bind(): void { + super.bind(); + this.codeGraph.loadData(this.graphicTemplate.datas); + this.codeGraph.doRepaint(); + } + + clearCache(): void { + //this.codeGraph.destroy(); + } + onLeftDown(e: FederatedPointerEvent): void { + this.container.position.copyFrom(this.toCanvasCoordinates(e.global)); + this.createAndStore(true); + } + + redraw(p: Point): void { + this.container.position.copyFrom(p); + } + prepareData(data: ISlopeData): boolean { + data.transform = this.container.saveTransform(); + return true; + } + draw(graphics: AxleCounting[], map: Map) { + if ( + map.has(`${graphics[0].id}+${graphics[1].id}`) || + map.has(`${graphics[1].id}+${graphics[0].id}`) + ) + return; + map.set(`${graphics[0].id}+${graphics[1].id}`, 1); + const slope = new Slope(); + slope.loadData(this.graphicTemplate.datas); + slope.datas.points = [graphics[0].position, graphics[1].position]; + slope.id = GraphicIdGenerator.next(); + slope.datas.refDeviceId = [graphics[0].id, graphics[1].id]; + this.storeGraphic(slope); + slope.loadRelations(); + } + oneGenerates() { + const map = new Map(); + const slopes = this.app.queryStore.queryByType(Slope.Type); + slopes.forEach((slope) => { + map.set(`${slope.datas.refDeviceId[0]}+${slope.datas.refDeviceId[1]}`, 1); + }); + const axleCountings = this.app.queryStore.queryByType( + AxleCounting.Type + ); + axleCountings.sort((a, b) => a.position.x - b.position.x); + for (let i = 0; i < axleCountings.length - 1; i++) { + this.draw([axleCountings[i], axleCountings[i + 1]], map); + } + } +} +class SlopeGraphicHitArea implements IHitArea { + slope: Slope; + constructor(slope: Slope) { + this.slope = slope; + } + contains(x: number, y: number): boolean { + for (let i = 1; i < this.slope.datas.points.length; i++) { + const p1 = this.slope.datas.points[i - 1]; + const p2 = this.slope.datas.points[i]; + if (linePoint(p1, p2, { x, y }, SlopeConsts.lineWidth)) { + return true; + } + } + return false; + } +} + +export class SlopeInteraction extends GraphicInteractionPlugin { + static Name = 'Slope_transform'; + constructor(app: JlDrawApp) { + super(SlopeInteraction.Name, app); + } + static init(app: JlDrawApp) { + return new SlopeInteraction(app); + } + filter(...grahpics: JlGraphic[]): Slope[] | undefined { + return grahpics.filter((g) => g.type === Slope.Type).map((g) => g as Slope); + } + bind(g: Slope): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.transformSave = true; + g.lineGraphic.eventMode = 'static'; + g.lineGraphic.cursor = 'pointer'; + g.lineGraphic.hitArea = new SlopeGraphicHitArea(g); + } + unbind(g: Slope): void { + g.eventMode = 'none'; + g.lineGraphic.eventMode = 'none'; + g.lineGraphic.draggable = false; + g.lineGraphic.selectable = false; + g.lineGraphic.transformSave = false; + } +} diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index 6d5fafc..166cedc 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -43,6 +43,9 @@ 一键生成逻辑区段 + + 一键生成坡度 + @@ -243,6 +246,8 @@ import { SectionDraw } from 'src/graphics/section/SectionDrawAssistant'; import { Section } from 'src/graphics/section/Section'; import { LogicSection } from 'src/graphics/logicSection/LogicSection'; import { LogicSectionDraw } from 'src/graphics/logicSection/LogicSectionDrawAssistant'; +import { Slope } from 'src/graphics/slope/Slope'; +import { SlopeDraw } from 'src/graphics/slope/SlopeAssistant'; import { useQuasar } from 'quasar'; import LayerControlDialog from 'src/components/draw-app/dialogs/LayerControlDialog.vue'; import { drawLayerList } from 'src/drawApp/index'; @@ -430,6 +435,13 @@ function oneClickLogicSection() { .getDrawAssistant(LogicSection.Type) as LogicSectionDraw; logicSectionDraw.oneGenerates(); } +function oneClickSlope() { + //一键生成坡度 + const slopeDraw = drawStore + .getDrawApp() + .getDrawAssistant(Slope.Type) as SlopeDraw; + slopeDraw.oneGenerates(); +} function oneClickLink() { drawStore.oneClickType = 'SectionLink'; const draw = drawStore diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index 80411d6..4414b6c 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -25,9 +25,10 @@ export namespace graphicData { esbButtons?: EsbButton[]; gateBoxs?: GatedBox[]; transponders?: Transponder[]; + slopes?: Slope[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4, 5, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4, 5, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("canvas" in data && data.canvas != undefined) { this.canvas = data.canvas; @@ -80,6 +81,9 @@ export namespace graphicData { if ("transponders" in data && data.transponders != undefined) { this.transponders = data.transponders; } + if ("slopes" in data && data.slopes != undefined) { + this.slopes = data.slopes; + } } } get canvas() { @@ -187,6 +191,12 @@ export namespace graphicData { set transponders(value: Transponder[]) { pb_1.Message.setRepeatedWrapperField(this, 22, value); } + get slopes() { + return pb_1.Message.getRepeatedWrapperField(this, Slope, 23) as Slope[]; + } + set slopes(value: Slope[]) { + pb_1.Message.setRepeatedWrapperField(this, 23, value); + } static fromObject(data: { canvas?: ReturnType; Platforms?: ReturnType[]; @@ -205,6 +215,7 @@ export namespace graphicData { esbButtons?: ReturnType[]; gateBoxs?: ReturnType[]; transponders?: ReturnType[]; + slopes?: ReturnType[]; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -258,6 +269,9 @@ export namespace graphicData { if (data.transponders != null) { message.transponders = data.transponders.map(item => Transponder.fromObject(item)); } + if (data.slopes != null) { + message.slopes = data.slopes.map(item => Slope.fromObject(item)); + } return message; } toObject() { @@ -279,6 +293,7 @@ export namespace graphicData { esbButtons?: ReturnType[]; gateBoxs?: ReturnType[]; transponders?: ReturnType[]; + slopes?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -331,6 +346,9 @@ export namespace graphicData { if (this.transponders != null) { data.transponders = this.transponders.map((item: Transponder) => item.toObject()); } + if (this.slopes != null) { + data.slopes = this.slopes.map((item: Slope) => item.toObject()); + } return data; } serialize(): Uint8Array; @@ -371,6 +389,8 @@ export namespace graphicData { writer.writeRepeatedMessage(21, this.gateBoxs, (item: GatedBox) => item.serialize(writer)); if (this.transponders.length) writer.writeRepeatedMessage(22, this.transponders, (item: Transponder) => item.serialize(writer)); + if (this.slopes.length) + writer.writeRepeatedMessage(23, this.slopes, (item: Slope) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -431,6 +451,9 @@ export namespace graphicData { case 22: reader.readMessage(message.transponders, () => pb_1.Message.addToRepeatedWrapperField(message, 22, Transponder.deserialize(reader), Transponder)); break; + case 23: + reader.readMessage(message.slopes, () => pb_1.Message.addToRepeatedWrapperField(message, 23, Slope.deserialize(reader), Slope)); + break; default: reader.skipField(); } } @@ -4426,4 +4449,212 @@ export namespace graphicData { return GatedBox.deserialize(bytes); } } + export class Slope extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + common?: CommonInfo; + code?: string; + points?: Point[]; + slopeNumber?: string; + slopeDirection?: string; + slopeLong?: number; + refDeviceId?: string[]; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 7], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("common" in data && data.common != undefined) { + this.common = data.common; + } + if ("code" in data && data.code != undefined) { + this.code = data.code; + } + if ("points" in data && data.points != undefined) { + this.points = data.points; + } + if ("slopeNumber" in data && data.slopeNumber != undefined) { + this.slopeNumber = data.slopeNumber; + } + if ("slopeDirection" in data && data.slopeDirection != undefined) { + this.slopeDirection = data.slopeDirection; + } + if ("slopeLong" in data && data.slopeLong != undefined) { + this.slopeLong = data.slopeLong; + } + if ("refDeviceId" in data && data.refDeviceId != undefined) { + this.refDeviceId = data.refDeviceId; + } + } + } + get common() { + return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo; + } + set common(value: CommonInfo) { + pb_1.Message.setWrapperField(this, 1, value); + } + get has_common() { + return pb_1.Message.getField(this, 1) != null; + } + get code() { + return pb_1.Message.getFieldWithDefault(this, 2, "") as string; + } + set code(value: string) { + pb_1.Message.setField(this, 2, value); + } + get points() { + return pb_1.Message.getRepeatedWrapperField(this, Point, 3) as Point[]; + } + set points(value: Point[]) { + pb_1.Message.setRepeatedWrapperField(this, 3, value); + } + get slopeNumber() { + return pb_1.Message.getFieldWithDefault(this, 4, "") as string; + } + set slopeNumber(value: string) { + pb_1.Message.setField(this, 4, value); + } + get slopeDirection() { + return pb_1.Message.getFieldWithDefault(this, 5, "") as string; + } + set slopeDirection(value: string) { + pb_1.Message.setField(this, 5, value); + } + get slopeLong() { + return pb_1.Message.getFieldWithDefault(this, 6, 0) as number; + } + set slopeLong(value: number) { + pb_1.Message.setField(this, 6, value); + } + get refDeviceId() { + return pb_1.Message.getFieldWithDefault(this, 7, []) as string[]; + } + set refDeviceId(value: string[]) { + pb_1.Message.setField(this, 7, value); + } + static fromObject(data: { + common?: ReturnType; + code?: string; + points?: ReturnType[]; + slopeNumber?: string; + slopeDirection?: string; + slopeLong?: number; + refDeviceId?: string[]; + }): Slope { + const message = new Slope({}); + if (data.common != null) { + message.common = CommonInfo.fromObject(data.common); + } + if (data.code != null) { + message.code = data.code; + } + if (data.points != null) { + message.points = data.points.map(item => Point.fromObject(item)); + } + if (data.slopeNumber != null) { + message.slopeNumber = data.slopeNumber; + } + if (data.slopeDirection != null) { + message.slopeDirection = data.slopeDirection; + } + if (data.slopeLong != null) { + message.slopeLong = data.slopeLong; + } + if (data.refDeviceId != null) { + message.refDeviceId = data.refDeviceId; + } + return message; + } + toObject() { + const data: { + common?: ReturnType; + code?: string; + points?: ReturnType[]; + slopeNumber?: string; + slopeDirection?: string; + slopeLong?: number; + refDeviceId?: string[]; + } = {}; + if (this.common != null) { + data.common = this.common.toObject(); + } + if (this.code != null) { + data.code = this.code; + } + if (this.points != null) { + data.points = this.points.map((item: Point) => item.toObject()); + } + if (this.slopeNumber != null) { + data.slopeNumber = this.slopeNumber; + } + if (this.slopeDirection != null) { + data.slopeDirection = this.slopeDirection; + } + if (this.slopeLong != null) { + data.slopeLong = this.slopeLong; + } + if (this.refDeviceId != null) { + data.refDeviceId = this.refDeviceId; + } + return data; + } + serialize(): Uint8Array; + serialize(w: pb_1.BinaryWriter): void; + serialize(w?: pb_1.BinaryWriter): Uint8Array | void { + const writer = w || new pb_1.BinaryWriter(); + if (this.has_common) + writer.writeMessage(1, this.common, () => this.common.serialize(writer)); + if (this.code.length) + writer.writeString(2, this.code); + if (this.points.length) + writer.writeRepeatedMessage(3, this.points, (item: Point) => item.serialize(writer)); + if (this.slopeNumber.length) + writer.writeString(4, this.slopeNumber); + if (this.slopeDirection.length) + writer.writeString(5, this.slopeDirection); + if (this.slopeLong != 0) + writer.writeInt64(6, this.slopeLong); + if (this.refDeviceId.length) + writer.writeRepeatedString(7, this.refDeviceId); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Slope { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Slope(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader)); + break; + case 2: + message.code = reader.readString(); + break; + case 3: + reader.readMessage(message.points, () => pb_1.Message.addToRepeatedWrapperField(message, 3, Point.deserialize(reader), Point)); + break; + case 4: + message.slopeNumber = reader.readString(); + break; + case 5: + message.slopeDirection = reader.readString(); + break; + case 6: + message.slopeLong = reader.readInt64(); + break; + case 7: + pb_1.Message.addToRepeatedField(message, 7, reader.readString()); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): Slope { + return Slope.deserialize(bytes); + } + } } From 26627b3d186d60d4da86b392c2b7c5b9b47d6863 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Fri, 4 Aug 2023 11:09:20 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E5=9D=A1=E5=BA=A6=E4=B9=8B=E9=97=B4?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=92=8C=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/slope/SlopeAssistant.ts | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/graphics/slope/SlopeAssistant.ts b/src/graphics/slope/SlopeAssistant.ts index bf6a101..6c46148 100644 --- a/src/graphics/slope/SlopeAssistant.ts +++ b/src/graphics/slope/SlopeAssistant.ts @@ -62,13 +62,26 @@ export class SlopeDraw extends GraphicDrawAssistant { oneGenerates() { const map = new Map(); const slopes = this.app.queryStore.queryByType(Slope.Type); - slopes.forEach((slope) => { - map.set(`${slope.datas.refDeviceId[0]}+${slope.datas.refDeviceId[1]}`, 1); - }); const axleCountings = this.app.queryStore.queryByType( AxleCounting.Type ); axleCountings.sort((a, b) => a.position.x - b.position.x); + const axleCountingsPos = axleCountings.map((g) => g.position.x); + //检验坡度有效性--是否有增加和删除 + slopes.forEach((slope) => { + const pS = slope.datas.points[0].x; + const mapS = axleCountingsPos.findIndex((x) => x == pS); + const pE = slope.datas.points[1].x; + const mapE = axleCountingsPos.findIndex((x) => x == pE); + if (mapS !== -1 && mapE !== -1 && mapE - mapS == 1) { + map.set( + `${slope.datas.refDeviceId[0]}+${slope.datas.refDeviceId[1]}`, + 1 + ); + } else { + this.app.deleteGraphics(slope); + } + }); for (let i = 0; i < axleCountings.length - 1; i++) { this.draw([axleCountings[i], axleCountings[i + 1]], map); } From 13b9356eececafd668b25b313cb783911dc2f99a Mon Sep 17 00:00:00 2001 From: fan Date: Fri, 4 Aug 2023 13:45:49 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E4=BF=A1=E5=8F=B7=E6=9C=BA=E5=81=9C?= =?UTF-8?q?=E8=BD=A6=E7=82=B9=E5=A2=9E=E5=8A=A0=E5=85=B3=E8=81=94=E5=85=B3?= =?UTF-8?q?=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bj-rtss-message | 2 +- .../draw-app/properties/SignalProperty.vue | 122 ++++++- .../properties/StopPositionProperty.vue | 61 +++- src/drawApp/graphics/SignalInteraction.ts | 6 + .../graphics/StopPositionInteraction.ts | 6 + src/graphics/signal/Signal.ts | 5 +- src/graphics/stopPosition/StopPosition.ts | 4 +- src/protos/stationLayoutGraphics.ts | 308 +++++++++++++++++- 8 files changed, 482 insertions(+), 32 deletions(-) diff --git a/bj-rtss-message b/bj-rtss-message index c87d9f5..d537023 160000 --- a/bj-rtss-message +++ b/bj-rtss-message @@ -1 +1 @@ -Subproject commit c87d9f5a4108c8b01ac16aff151d7b1a385156a0 +Subproject commit d537023854a0fa4e3d44dbd752ca18e92fe97178 diff --git a/src/components/draw-app/properties/SignalProperty.vue b/src/components/draw-app/properties/SignalProperty.vue index b28e52b..79b63f6 100644 --- a/src/components/draw-app/properties/SignalProperty.vue +++ b/src/components/draw-app/properties/SignalProperty.vue @@ -32,37 +32,125 @@ @blur="onUpdate" label="公里标(mm):" /> + + + + diff --git a/src/pages/DraftManage.vue b/src/pages/DraftManage.vue index 6bdba87..79e5439 100644 --- a/src/pages/DraftManage.vue +++ b/src/pages/DraftManage.vue @@ -58,30 +58,32 @@ transition-hide="scale" > - - + +
新建草稿图
-
- - - - -
+ + + + + +
@@ -93,11 +95,8 @@ > -
草稿发布
-
- - - + +
草稿发布
- -
+ :rules="[(val) => val.length > 0 || '请输入备注!']" + /> - - - - -
+ + + + + +
@@ -136,10 +132,20 @@ diff --git a/src/pages/PublishManage.vue b/src/pages/PublishManage.vue index 4b462b9..a331839 100644 --- a/src/pages/PublishManage.vue +++ b/src/pages/PublishManage.vue @@ -32,6 +32,11 @@ label="创建仿真" @click="create(props.row)" /> + + + + + +
另存到草稿
+ + + + + + + +
+
+
+
diff --git a/src/router/routes.ts b/src/router/routes.ts index c19f1d2..c803ffd 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -35,9 +35,9 @@ const routes: RouteRecordRaw[] = [ component: () => import('pages/PublishManage.vue'), }, { - path: 'lineInfo', - name: 'lineInfo', - component: () => import('pages/LineInfoManage.vue'), + path: 'categoryInfo', + name: 'categoryInfo', + component: () => import('pages/CategoryManage.vue'), }, ], },