From 47005eb430570da68e4ee08188e6256c3a8e0b3f Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Thu, 29 Jun 2023 16:29:48 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=86=E9=9A=94?= =?UTF-8?q?=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/draw-app/DrawProperties.vue | 7 +- .../draw-app/properties/SeparatorProperty.vue | 55 +++++ src/drawApp/graphics/SeparatorInteraction.ts | 43 ++++ src/drawApp/graphics/TrainInteraction.ts | 92 +++++++ src/drawApp/index.ts | 11 + src/graphics/separator/Separator.ts | 90 +++++++ .../separator/SeparatorDrawAssistant.ts | 227 ++++++++++++++++++ src/layouts/DrawLayout.vue | 6 + src/protos/stationLayoutGraphics.ts | 141 ++++++++++- 9 files changed, 670 insertions(+), 2 deletions(-) create mode 100644 src/components/draw-app/properties/SeparatorProperty.vue create mode 100644 src/drawApp/graphics/SeparatorInteraction.ts create mode 100644 src/graphics/separator/Separator.ts create mode 100644 src/graphics/separator/SeparatorDrawAssistant.ts diff --git a/src/components/draw-app/DrawProperties.vue b/src/components/draw-app/DrawProperties.vue index 61d68b7..31f4a2b 100644 --- a/src/components/draw-app/DrawProperties.vue +++ b/src/components/draw-app/DrawProperties.vue @@ -81,6 +81,9 @@ + @@ -108,12 +111,13 @@ import TurnoutProperty from './properties/TurnoutProperty.vue'; import SectionProperty from './properties/SectionProperty.vue'; import RunLineProperty from './properties/RunLineProperty.vue'; import PathLineProperty from './properties/PathLineProperty.vue'; +import SeparatorProperty from './properties/SeparatorProperty.vue'; 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 { Train } from 'src/graphics/train/Train'; import { useDrawStore } from 'src/stores/draw-store'; import { IscsFan } from 'src/graphics/iscs-fan/IscsFan'; import { Signal } from 'src/graphics/signal/Signal'; @@ -123,6 +127,7 @@ import { Section } from 'src/graphics/section/Section'; import { TrainWindow } from 'src/graphics/trainWindow/TrainWindow'; import { PathLine } from 'src/graphics/pathLine/PathLine'; import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting'; +import { Separator } from 'src/graphics/separator/Separator'; const drawStore = useDrawStore(); diff --git a/src/components/draw-app/properties/SeparatorProperty.vue b/src/components/draw-app/properties/SeparatorProperty.vue new file mode 100644 index 0000000..5785cc1 --- /dev/null +++ b/src/components/draw-app/properties/SeparatorProperty.vue @@ -0,0 +1,55 @@ + + + diff --git a/src/drawApp/graphics/SeparatorInteraction.ts b/src/drawApp/graphics/SeparatorInteraction.ts new file mode 100644 index 0000000..303ca13 --- /dev/null +++ b/src/drawApp/graphics/SeparatorInteraction.ts @@ -0,0 +1,43 @@ +import * as pb_1 from 'google-protobuf'; +import { ISeparatorData, Separator } from 'src/graphics/separator/Separator'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { GraphicDataBase } from './GraphicDataBase'; + +export class SeparatorData extends GraphicDataBase implements ISeparatorData { + constructor(data?: graphicData.Separator) { + let separator; + if (!data) { + separator = new graphicData.Separator({ + common: GraphicDataBase.defaultCommonInfo(Separator.Type), + }); + } else { + separator = data; + } + super(separator); + } + + public get data(): graphicData.Separator { + return this.getData(); + } + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + get separatorType(): string { + return this.data.separatorType; + } + set separatorType(v: string) { + this.data.separatorType = v; + } + clone(): SeparatorData { + return new SeparatorData(this.data.cloneMessage()); + } + copyFrom(data: SeparatorData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: SeparatorData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/graphics/TrainInteraction.ts b/src/drawApp/graphics/TrainInteraction.ts index 83d5a1e..95d7f42 100644 --- a/src/drawApp/graphics/TrainInteraction.ts +++ b/src/drawApp/graphics/TrainInteraction.ts @@ -4,6 +4,14 @@ import { graphicData } from 'src/protos/stationLayoutGraphics'; import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase'; import { state } from 'src/protos/device_status'; import { train } from 'src/protos/train'; +import { MenuItemOptions } from 'src/jl-graphic/ui/Menu'; +import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu'; +import { + GraphicApp, + GraphicInteractionPlugin, + JlGraphic, +} from 'src/jl-graphic'; +import { DisplayObject, FederatedMouseEvent } from 'pixi.js'; export class TrainData extends GraphicDataBase implements ITrainData { constructor(data?: graphicData.Train) { @@ -202,3 +210,87 @@ class StateTrain extends train.TrainInfo { } } } + +const negativeDirectionConfig: MenuItemOptions = { + name: '反方向运行', +}; +const HoldTrainConfig: MenuItemOptions = { + name: '扣车', +}; +const openDoorConfig: MenuItemOptions = { + name: '开门', +}; +const editGroupConfig: MenuItemOptions = { + name: '修改车组号', +}; +const TrainOperateMenu: ContextMenu = ContextMenu.init({ + name: '列车操作菜单', + groups: [ + { + items: [ + negativeDirectionConfig, + HoldTrainConfig, + openDoorConfig, + editGroupConfig, + ], + }, + ], +}); + +export class TrainOperateInteraction extends GraphicInteractionPlugin { + static Name = 'train_operate_menu'; + constructor(app: GraphicApp) { + super(TrainOperateInteraction.Name, app); + app.registerMenu(TrainOperateMenu); + } + static init(app: GraphicApp) { + return new TrainOperateInteraction(app); + } + filter(...grahpics: JlGraphic[]): Train[] | undefined { + return grahpics.filter((g) => g.type === Train.Type).map((g) => g as Train); + } + bind(g: Train): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.selectable = true; + g.on('_rightclick', this.onContextMenu, this); + } + + unbind(g: Train): void { + g.selectable = false; + g.eventMode = 'none'; + g.off('_rightclick', this.onContextMenu, this); + } + + onContextMenu(e: FederatedMouseEvent) { + const target = e.target as DisplayObject; + const train = target.getGraphic() as Train; + this.app.updateSelected(train); + negativeDirectionConfig.handler = () => { + const mode = train.states.mode; + if (!train.states.mode.ipModeTrainDirUp) { + mode.ipModeTrainDirUp = true; + mode.ipModeTrainDirDown = false; + } else if (!train.states.mode.ipModeTrainDirDown) { + mode.ipModeTrainDirUp = false; + mode.ipModeTrainDirDown = true; + } + train.chagneDirection(); + }; + HoldTrainConfig.handler = () => { + train.states.mode.ipModeTrainHolded = + !train.states.mode.ipModeTrainHolded; + train.chagneState(); + }; + openDoorConfig.handler = () => { + train.states.mode.ipModeTrainDoorOpen = + !train.states.mode.ipModeTrainDoorOpen; + train.chagneState(); + }; + editGroupConfig.handler = () => { + train.states.trainId = '022'; + train.doRepaint(); + }; + TrainOperateMenu.open(e.global); + } +} diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 76733af..b45f48e 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -79,6 +79,9 @@ import { PathLine, PathLineTemplate } from 'src/graphics/pathLine/PathLine'; import { PathLineDraw } from 'src/graphics/pathLine/PathLineDrawAssistant'; import { PathLineData } from './graphics/PathLineInteraction'; import { toStorageTransform } from './graphics/GraphicDataBase'; +import { SeparatorDraw } from 'src/graphics/separator/SeparatorDrawAssistant'; +import { Separator, SeparatorTemplate } from 'src/graphics/separator/Separator'; +import { SeparatorData } from './graphics/SeparatorInteraction'; // export function fromStoragePoint(p: graphicData.Point): Point { // return new Point(p.x, p.y); @@ -165,6 +168,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { | TrainDraw | OneClickGenerateDraw | AxleCountingDraw + | SeparatorDraw )[] = []; if (draftType === 'Line') { drawAssistants = [ @@ -189,6 +193,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { app, new AxleCountingTemplate(new AxleCountingData()) ), + new SeparatorDraw(app, new SeparatorTemplate(new SeparatorData())), ]; DrawSignalInteraction.init(app); } else { @@ -305,6 +310,9 @@ export function saveDrawDatas(app: JlDrawApp) { } else if (AxleCounting.Type === g.type) { const axleCountingData = (g as AxleCounting).saveData(); storage.axleCountings.push((axleCountingData as AxleCountingData).data); + } else if (Separator.Type === g.type) { + const separatorData = (g as Separator).saveData(); + storage.separators.push((separatorData as SeparatorData).data); } }); const base64 = fromUint8Array(storage.serialize()); @@ -375,6 +383,9 @@ export async function loadDrawDatas(app: GraphicApp) { storage.axleCountings.forEach((axleCounting) => { datas.push(new AxleCountingData(axleCounting)); }); + storage.separators.forEach((separator) => { + datas.push(new SeparatorData(separator)); + }); app.loadGraphic(datas); } else { app.loadGraphic([]); diff --git a/src/graphics/separator/Separator.ts b/src/graphics/separator/Separator.ts new file mode 100644 index 0000000..5a7e27d --- /dev/null +++ b/src/graphics/separator/Separator.ts @@ -0,0 +1,90 @@ +import { Color, Graphics } from 'pixi.js'; +import { GraphicData, JlGraphic, JlGraphicTemplate } from 'src/jl-graphic'; + +export interface ISeparatorData extends GraphicData { + get code(): string; // 编号 + set code(v: string); + get separatorType(): string; // 类型 + set separatorType(v: string); + clone(): ISeparatorData; + copyFrom(data: ISeparatorData): void; + eq(other: ISeparatorData): boolean; +} + +export enum separatorTypeEnum { + turnout = 'turnout', // 道岔分隔符 + endA = 'endA', // A端尽头分隔符 + endB = 'endB', // B端尽头分隔符 + section = 'section', // 区段分隔符 +} + +export const SeparatorConsts = { + height: 15, + lineWidth: 2, + lineColor: '0x617799', + circleColor: '0xEF0200', + radius: 5, +}; + +export class Separator extends JlGraphic { + static Type = 'Separator'; + rectGraphic: Graphics = new Graphics(); + circleGraphic: Graphics = new Graphics(); + constructor() { + super(Separator.Type); + this.addChild(this.rectGraphic); + this.addChild(this.circleGraphic); + } + get datas(): ISeparatorData { + return this.getDatas(); + } + doRepaint(): void { + const rectGraphic = this.rectGraphic; + rectGraphic.clear(); + if (!this.datas.separatorType) { + this.datas.separatorType = separatorTypeEnum.endA; + } + const typeArr = ['section', 'turnout']; + if (typeArr.includes(this.datas.separatorType)) { + rectGraphic.lineStyle( + SeparatorConsts.lineWidth, + new Color(SeparatorConsts.lineColor) + ); + rectGraphic.moveTo(0, -SeparatorConsts.height / 2); + rectGraphic.lineTo(0, SeparatorConsts.height / 2); + if (this.datas.separatorType == 'turnout') { + this.circleGraphic.lineStyle(1, SeparatorConsts.circleColor); + this.circleGraphic.drawCircle(0, 0, SeparatorConsts.radius); + } + } + const endTypeArr = ['endA', 'endB']; + if (endTypeArr.includes(this.datas.separatorType)) { + let d = SeparatorConsts.radius; + if (this.datas.separatorType == 'endB') { + d = -d; + } + rectGraphic.lineStyle( + SeparatorConsts.lineWidth, + new Color(SeparatorConsts.lineColor) + ); + rectGraphic.moveTo(0, 0); + rectGraphic.lineTo(-d, 0); + rectGraphic.lineTo(-d, -d); + rectGraphic.lineTo(-d * 3, -d); + rectGraphic.moveTo(-d, 0); + rectGraphic.lineTo(-d, d); + rectGraphic.lineTo(-d * 3, d); + } + } +} + +export class SeparatorTemplate extends JlGraphicTemplate { + constructor(dataTemplate: ISeparatorData) { + super(Separator.Type, { + dataTemplate, + }); + } + new(): Separator { + return new Separator(); + } +} diff --git a/src/graphics/separator/SeparatorDrawAssistant.ts b/src/graphics/separator/SeparatorDrawAssistant.ts new file mode 100644 index 0000000..a315d21 --- /dev/null +++ b/src/graphics/separator/SeparatorDrawAssistant.ts @@ -0,0 +1,227 @@ +import { FederatedPointerEvent, IHitArea, IPointData, Point } from 'pixi.js'; +import { + GraphicDrawAssistant, + GraphicIdGenerator, + GraphicInteractionPlugin, + GraphicRelation, + GraphicRelationParam, + GraphicStore, + JlDrawApp, + JlGraphic, + distance2, + linePoint, +} from 'src/jl-graphic'; +import { Section } from '../section/Section'; +import { + ISeparatorData, + Separator, + SeparatorConsts, + SeparatorTemplate, + separatorTypeEnum, +} from './Separator'; +import { SeparatorData } from 'src/drawApp/graphics/SeparatorInteraction'; +import { Turnout } from '../turnout/Turnout'; + +export class SeparatorDraw extends GraphicDrawAssistant< + SeparatorTemplate, + ISeparatorData +> { + SeparatorGraph: Separator; + constructor(app: JlDrawApp, template: SeparatorTemplate) { + super(app, template, 'sym_o_square', '不展示1'); + this.SeparatorGraph = this.graphicTemplate.new(); + this.container.addChild(this.SeparatorGraph); + SeparatorInteraction.init(app); + } + + bind(): void { + super.bind(); + this.SeparatorGraph.loadData(this.graphicTemplate.datas); + this.SeparatorGraph.doRepaint(); + } + + onLeftDown(e: FederatedPointerEvent): void { + this.container.position.copyFrom(this.toCanvasCoordinates(e.global)); + this.createAndStore(true); + } + + redraw(p: Point): void { + this.container.position.copyFrom(p); + } + + prepareData(data: ISeparatorData): boolean { + data.transform = this.container.saveTransform(); + return true; + } + oneGenerates() { + const SeparatorAll = this.app.queryStore.queryByType( + Separator.Type + ); + this.app.deleteGraphics(...SeparatorAll); + const rMap = new Map(); + const sections = this.app.queryStore.queryByType
(Section.Type); + const turnouts = this.app.queryStore.queryByType(Turnout.Type); + function setKey(gr: GraphicRelationParam): string { + let key = ''; + key = `${gr.g.id}_${gr.param}`; + return key; + } + sections.forEach((section) => { + const allR = section.relationManage.getRelationsOfGraphic(section); + const port: string[] = []; + allR.forEach((relation, index) => { + const r = relation.getRelationParam(section); + port.push(r.param); + const other = relation.getOtherRelationParam(section); + if (!rMap.has(setKey(r))) { + rMap.set(setKey(r), { ...r }); + } + if (!rMap.has(setKey(other))) { + rMap.set(setKey(other), { ...other, repetition: true }); + } + if (index == allR.length - 1) { + if (!port.includes('A')) { + rMap.set(`${section.id}_A`, { + g: section, + param: 'A', + separatorType: separatorTypeEnum.endA, + }); + } + if (!port.includes('B')) { + rMap.set(`${section.id}_B`, { + g: section, + param: 'B', + separatorType: separatorTypeEnum.endB, + }); + } + } + }); + }); + turnouts.forEach((turnout) => { + const allR = turnout.relationManage.getRelationsOfGraphic(turnout); + const port: string[] = []; + allR.forEach((relation, index) => { + const r = relation.getRelationParam(turnout); + port.push(r.param); + const other = relation.getOtherRelationParam(turnout); + if (!rMap.has(setKey(r)) && r.param == 'C') { + rMap.set(setKey(r), { + ...r, + separatorType: separatorTypeEnum.turnout, + }); + } + if (!rMap.has(setKey(other)) && other.param == 'C') { + rMap.set(setKey(other), { + ...other, + separatorType: separatorTypeEnum.turnout, + repetition: true, + }); + } + if (index == allR.length - 1) { + if (!port.includes('A')) { + rMap.set(`${turnout.id}_A`, { + g: turnout, + param: 'A', + separatorType: separatorTypeEnum.endB, + }); + } + if (!port.includes('B')) { + rMap.set(`${turnout.id}_B`, { + g: turnout, + param: 'B', + separatorType: separatorTypeEnum.endA, + }); + } + } + }); + }); + rMap.forEach((item) => { + if (!item.repetition) { + const sType = item.separatorType || separatorTypeEnum.section; + const separator = new Separator(); + const data = new SeparatorData(); + data.separatorType = sType; + separator.loadData(data); + let p; + if (item.g.type == Section.Type) { + p = item.g.getStartPoint(); + if (item.param == 'B') { + p = item.g.getEndPoint(); + } + } else if (item.g.type == Turnout.Type) { + const ps = item.g.getPortPoints(); + let l = 2; + if (item.param == 'A') { + l = 0; + } else if (item.param == 'B') { + l = 1; + } + p = ps[l][0]; + } + const tps = item.g.localToCanvasPoint(p); + separator.position.set(tps.x, tps.y); + separator.id = GraphicIdGenerator.next(); + this.storeGraphic(separator); + } + }); + } +} + +//碰撞检测 +export class SeparatorGraphicHitArea implements IHitArea { + separator: Separator; + constructor(separator: Separator) { + this.separator = separator; + } + contains(x: number, y: number): boolean { + let contains = false; + const endTypeArr = ['endA', 'endB']; + let d = SeparatorConsts.radius; + if (endTypeArr.includes(this.separator.datas.separatorType)) { + if (this.separator.datas.separatorType == 'endB') { + d = -d; + } + const tolerance = SeparatorConsts.lineWidth; + const p1 = new Point(0, 0); + const p2 = new Point(-d, 0); + const p3 = new Point(-d, -d); + const p4 = new Point(-d * 3, -d); + const p5 = new Point(-d, d); + const p6 = new Point(-d * 3, d); + const p = new Point(x, y); + contains = contains || linePoint(p1, p2, p, tolerance); + contains = contains || linePoint(p2, p3, p, tolerance); + contains = contains || linePoint(p3, p4, p, tolerance); + contains = contains || linePoint(p2, p5, p, tolerance); + contains = contains || linePoint(p5, p6, p, tolerance); + } + return contains; + } +} + +export class SeparatorInteraction extends GraphicInteractionPlugin { + static Name = 'Separator_transform'; + constructor(app: JlDrawApp) { + super(SeparatorInteraction.Name, app); + } + static init(app: JlDrawApp) { + return new SeparatorInteraction(app); + } + filter(...grahpics: JlGraphic[]): Separator[] | undefined { + return grahpics + .filter((g) => g.type === Separator.Type) + .map((g) => g as Separator); + } + bind(g: Separator): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.rotatable = true; + g.rectGraphic.hitArea = new SeparatorGraphicHitArea(g); + } + unbind(g: Separator): void { + g.eventMode = 'none'; + g.scalable = false; + g.rotatable = false; + } +} diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index 16ee051..c850163 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -178,6 +178,8 @@ import { errorNotify, successNotify } from 'src/utils/CommonNotify'; import { saveAsDraft } from 'src/api/DraftApi'; import { ApiError } from 'src/boot/axios'; import { OneClickGenerate } from 'src/graphics/trainWindow/oneClickDrawAssistant'; +import { Separator } from 'src/graphics/separator/Separator'; +import { SeparatorDraw } from 'src/graphics/separator/SeparatorDrawAssistant'; const route = useRoute(); const router = useRouter(); @@ -303,6 +305,10 @@ function buildRelations() { } function oneClickGeneration() { + const separatorDraw = drawStore + .getDrawApp() + .getDrawAssistant(Separator.Type) as SeparatorDraw; + separatorDraw.oneGenerates(); drawStore.getDrawApp().interactionPlugin(OneClickGenerate.Type).resume(); } diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index e72c60c..da66860 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -25,9 +25,10 @@ export namespace graphicData { polygons?: Polygon[]; trainWindows?: TrainWindow[]; axleCountings?: AxleCounting[]; + separators?: Separator[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18], 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 ("axleCountings" in data && data.axleCountings != undefined) { this.axleCountings = data.axleCountings; } + if ("separators" in data && data.separators != undefined) { + this.separators = data.separators; + } } } get canvas() { @@ -187,6 +191,12 @@ export namespace graphicData { set axleCountings(value: AxleCounting[]) { pb_1.Message.setRepeatedWrapperField(this, 17, value); } + get separators() { + return pb_1.Message.getRepeatedWrapperField(this, Separator, 18) as Separator[]; + } + set separators(value: Separator[]) { + pb_1.Message.setRepeatedWrapperField(this, 18, value); + } static fromObject(data: { canvas?: ReturnType; links?: ReturnType[]; @@ -205,6 +215,7 @@ export namespace graphicData { polygons?: ReturnType[]; trainWindows?: ReturnType[]; axleCountings?: ReturnType[]; + separators?: ReturnType[]; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -258,6 +269,9 @@ export namespace graphicData { if (data.axleCountings != null) { message.axleCountings = data.axleCountings.map(item => AxleCounting.fromObject(item)); } + if (data.separators != null) { + message.separators = data.separators.map(item => Separator.fromObject(item)); + } return message; } toObject() { @@ -279,6 +293,7 @@ export namespace graphicData { polygons?: ReturnType[]; trainWindows?: ReturnType[]; axleCountings?: ReturnType[]; + separators?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -331,6 +346,9 @@ export namespace graphicData { if (this.axleCountings != null) { data.axleCountings = this.axleCountings.map((item: AxleCounting) => item.toObject()); } + if (this.separators != null) { + data.separators = this.separators.map((item: Separator) => item.toObject()); + } return data; } serialize(): Uint8Array; @@ -371,6 +389,8 @@ export namespace graphicData { writer.writeRepeatedMessage(16, this.trainWindows, (item: TrainWindow) => item.serialize(writer)); if (this.axleCountings.length) writer.writeRepeatedMessage(17, this.axleCountings, (item: AxleCounting) => item.serialize(writer)); + if (this.separators.length) + writer.writeRepeatedMessage(18, this.separators, (item: Separator) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -431,6 +451,9 @@ export namespace graphicData { case 17: reader.readMessage(message.axleCountings, () => pb_1.Message.addToRepeatedWrapperField(message, 17, AxleCounting.deserialize(reader), AxleCounting)); break; + case 18: + reader.readMessage(message.separators, () => pb_1.Message.addToRepeatedWrapperField(message, 18, Separator.deserialize(reader), Separator)); + break; default: reader.skipField(); } } @@ -3955,4 +3978,120 @@ export namespace graphicData { C = 2 } } + export class Separator extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + common?: CommonInfo; + code?: string; + separatorType?: string; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("common" in data && data.common != undefined) { + this.common = data.common; + } + if ("code" in data && data.code != undefined) { + this.code = data.code; + } + if ("separatorType" in data && data.separatorType != undefined) { + this.separatorType = data.separatorType; + } + } + } + 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 separatorType() { + return pb_1.Message.getFieldWithDefault(this, 3, "") as string; + } + set separatorType(value: string) { + pb_1.Message.setField(this, 3, value); + } + static fromObject(data: { + common?: ReturnType; + code?: string; + separatorType?: string; + }): Separator { + const message = new Separator({}); + if (data.common != null) { + message.common = CommonInfo.fromObject(data.common); + } + if (data.code != null) { + message.code = data.code; + } + if (data.separatorType != null) { + message.separatorType = data.separatorType; + } + return message; + } + toObject() { + const data: { + common?: ReturnType; + code?: string; + separatorType?: string; + } = {}; + if (this.common != null) { + data.common = this.common.toObject(); + } + if (this.code != null) { + data.code = this.code; + } + if (this.separatorType != null) { + data.separatorType = this.separatorType; + } + 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.separatorType.length) + writer.writeString(3, this.separatorType); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Separator { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Separator(); + 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.separatorType = reader.readString(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): Separator { + return Separator.deserialize(bytes); + } + } } From 3f7014066d8e04f46cc12bf5f3672ae4cdbc5eee Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Thu, 29 Jun 2023 16:34:11 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=88=86=E9=9A=94=E7=AC=A6=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/separator/SeparatorDrawAssistant.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/graphics/separator/SeparatorDrawAssistant.ts b/src/graphics/separator/SeparatorDrawAssistant.ts index a315d21..af4d9ee 100644 --- a/src/graphics/separator/SeparatorDrawAssistant.ts +++ b/src/graphics/separator/SeparatorDrawAssistant.ts @@ -1,14 +1,11 @@ -import { FederatedPointerEvent, IHitArea, IPointData, Point } from 'pixi.js'; +import { FederatedPointerEvent, IHitArea, Point } from 'pixi.js'; import { GraphicDrawAssistant, GraphicIdGenerator, GraphicInteractionPlugin, - GraphicRelation, GraphicRelationParam, - GraphicStore, JlDrawApp, JlGraphic, - distance2, linePoint, } from 'src/jl-graphic'; import { Section } from '../section/Section'; @@ -28,7 +25,7 @@ export class SeparatorDraw extends GraphicDrawAssistant< > { SeparatorGraph: Separator; constructor(app: JlDrawApp, template: SeparatorTemplate) { - super(app, template, 'sym_o_square', '不展示1'); + super(app, template, 'sym_o_square', '不展示'); this.SeparatorGraph = this.graphicTemplate.new(); this.container.addChild(this.SeparatorGraph); SeparatorInteraction.init(app); From 04c4b8908e1fb01e38dea01d819a7e999d8929d5 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Thu, 29 Jun 2023 16:51:53 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=85=AC=E9=87=8C=E6=A0=87--=E8=BD=A6?= =?UTF-8?q?=E7=AB=99=E5=92=8C=E8=AE=A1=E8=BD=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties/AxleCountingProperty.vue | 40 +++++++++-- .../draw-app/properties/StationProperty.vue | 40 +++++++++-- .../graphics/AxleCountingInteraction.ts | 11 +-- src/drawApp/graphics/StationInteraction.ts | 11 ++- src/graphics/axleCounting/AxleCounting.ts | 5 +- src/graphics/station/Station.ts | 17 +++-- src/protos/stationLayoutGraphics.ts | 72 ++++++++++--------- 7 files changed, 133 insertions(+), 63 deletions(-) diff --git a/src/components/draw-app/properties/AxleCountingProperty.vue b/src/components/draw-app/properties/AxleCountingProperty.vue index c273ae4..1d29693 100644 --- a/src/components/draw-app/properties/AxleCountingProperty.vue +++ b/src/components/draw-app/properties/AxleCountingProperty.vue @@ -16,14 +16,23 @@ lazy-rules autogrow /> + @@ -72,6 +81,13 @@ import { computed, onMounted, reactive, watch } from 'vue'; const drawStore = useDrawStore(); const axleCountingModel = reactive(new AxleCountingData()); +const kilometerSystem = reactive({ coordinateSystem: '', kilometer: 0 }); + +const CoordinateSystemOptions = [ + { label: '车辆段', value: 'DEPOT' }, + { label: '停车场', value: 'PARKING_LOT' }, + { label: '正线', value: 'MAIN_LINE' }, +]; drawStore.$subscribe; watch( @@ -79,6 +95,11 @@ watch( (val) => { if (val && val.type == AxleCounting.Type) { axleCountingModel.copyFrom(val.saveData() as AxleCountingData); + if (axleCountingModel.kilometerSystem) { + kilometerSystem.coordinateSystem = + axleCountingModel.kilometerSystem.coordinateSystem; + kilometerSystem.kilometer = axleCountingModel.kilometerSystem.kilometer; + } } } ); @@ -87,11 +108,20 @@ onMounted(() => { const axleCounting = drawStore.selectedGraphic as AxleCounting; if (axleCounting) { axleCountingModel.copyFrom(axleCounting.saveData()); + if (axleCountingModel.kilometerSystem) { + kilometerSystem.coordinateSystem = + axleCountingModel.kilometerSystem.coordinateSystem; + kilometerSystem.kilometer = axleCountingModel.kilometerSystem.kilometer; + } } }); function onUpdate() { const axleCounting = drawStore.selectedGraphic as AxleCounting; + axleCountingModel.kilometerSystem = { + coordinateSystem: kilometerSystem.coordinateSystem, + kilometer: kilometerSystem.kilometer, + }; if (axleCounting) { drawStore .getDrawApp() diff --git a/src/components/draw-app/properties/StationProperty.vue b/src/components/draw-app/properties/StationProperty.vue index 7a7f49b..56663ff 100644 --- a/src/components/draw-app/properties/StationProperty.vue +++ b/src/components/draw-app/properties/StationProperty.vue @@ -10,14 +10,23 @@ lazy-rules autogrow /> + { concentrationStations.value = (showSelectData as never)[ stationModel.concentrationStations + '' ]; + if (stationModel.kilometerSystem) { + kilometerSystem.coordinateSystem = + stationModel.kilometerSystem.coordinateSystem; + kilometerSystem.kilometer = stationModel.kilometerSystem.kilometer; + } } }); @@ -88,6 +114,10 @@ function onUpdate() { stationModel.concentrationStations = JSON.parse( (showSelect as never)[concentrationStations.value] ); + stationModel.kilometerSystem = { + coordinateSystem: kilometerSystem.coordinateSystem, + kilometer: kilometerSystem.kilometer, + }; const station = drawStore.selectedGraphic as Station; if (station) { drawStore.getDrawApp().updateGraphicAndRecord(station, stationModel); diff --git a/src/drawApp/graphics/AxleCountingInteraction.ts b/src/drawApp/graphics/AxleCountingInteraction.ts index 7498c9c..ed80bfd 100644 --- a/src/drawApp/graphics/AxleCountingInteraction.ts +++ b/src/drawApp/graphics/AxleCountingInteraction.ts @@ -5,6 +5,7 @@ import { } from 'src/graphics/axleCounting/AxleCounting'; import { graphicData } from 'src/protos/stationLayoutGraphics'; import { GraphicDataBase } from './GraphicDataBase'; +import { KilometerSystem } from 'src/graphics/signal/Signal'; export class AxleCountingData extends GraphicDataBase @@ -31,17 +32,17 @@ export class AxleCountingData set code(v: string) { this.data.code = v; } - get kilometerCode(): string { - return this.data.kilometerCode; + get kilometerSystem(): KilometerSystem { + return this.data.kilometerSystem; } - set kilometerCode(v: string) { - this.data.kilometerCode = v; + set kilometerSystem(v: KilometerSystem) { + this.data.kilometerSystem = new graphicData.KilometerSystem(v); } get axleCountingRef(): graphicData.RelatedRef[] { return this.data.axleCountingRef; } set axleCountingRef(points: graphicData.RelatedRef[]) { - this.data.axleCountingRef=points + this.data.axleCountingRef = points; } clone(): AxleCountingData { return new AxleCountingData(this.data.cloneMessage()); diff --git a/src/drawApp/graphics/StationInteraction.ts b/src/drawApp/graphics/StationInteraction.ts index df32f2d..398cd24 100644 --- a/src/drawApp/graphics/StationInteraction.ts +++ b/src/drawApp/graphics/StationInteraction.ts @@ -15,6 +15,7 @@ import { JlGraphic, } from 'src/jl-graphic'; import { DisplayObject, FederatedMouseEvent } from 'pixi.js'; +import { KilometerSystem } from 'src/graphics/signal/Signal'; export class StationData extends GraphicDataBase implements IStationData { constructor(data?: graphicData.Station) { @@ -38,11 +39,11 @@ export class StationData extends GraphicDataBase implements IStationData { set code(v: string) { this.data.code = v; } - get kilometerCode(): string { - return this.data.kilometerCode; + get kilometerSystem(): KilometerSystem { + return this.data.kilometerSystem; } - set kilometerCode(v: string) { - this.data.kilometerCode = v; + set kilometerSystem(v: KilometerSystem) { + this.data.kilometerSystem = new graphicData.KilometerSystem(v); } get hasControl(): boolean { return this.data.hasControl; @@ -164,12 +165,10 @@ export class StationOperateInteraction extends GraphicInteractionPlugin powerUnlockConfig.handler = () => { station.states.ipRtuStusInLocalCtrl = true; station.doRepaint(); - console.log(2222); }; chainConfig.handler = () => { station.states.ipRtuStusDown = true; station.doRepaint(); - console.log(2222); }; removeChainConfig.handler = () => { console.log(2222); diff --git a/src/graphics/axleCounting/AxleCounting.ts b/src/graphics/axleCounting/AxleCounting.ts index 75876c7..d6fa539 100644 --- a/src/graphics/axleCounting/AxleCounting.ts +++ b/src/graphics/axleCounting/AxleCounting.ts @@ -7,12 +7,13 @@ import { VectorText, } from 'src/jl-graphic'; import { IRelatedRefData, protoPort2Data } from '../CommonGraphics'; +import { KilometerSystem } from '../signal/Signal'; export interface IAxleCountingData extends GraphicData { get code(): string; // 编号 set code(v: string); - get kilometerCode(): string; // 公里标 - set kilometerCode(v: string); + get kilometerSystem(): KilometerSystem; + set kilometerSystem(v: KilometerSystem); get axleCountingRef(): IRelatedRefData[]; //关联的设备 set axleCountingRef(ref: IRelatedRefData[]); clone(): IAxleCountingData; diff --git a/src/graphics/station/Station.ts b/src/graphics/station/Station.ts index d9ffe72..1956a58 100644 --- a/src/graphics/station/Station.ts +++ b/src/graphics/station/Station.ts @@ -6,12 +6,13 @@ import { JlGraphicTemplate, VectorText, } from 'src/jl-graphic'; +import { KilometerSystem } from '../signal/Signal'; export interface IStationData extends GraphicData { get code(): string; // 编号 set code(v: string); - get kilometerCode(): string; // 公里标 - set kilometerCode(v: string); + get kilometerSystem(): KilometerSystem; + set kilometerSystem(v: KilometerSystem); get hasControl(): boolean; /// 是否有控制 set hasControl(v: boolean); get concentrationStations(): boolean; ////是否集中站 @@ -174,16 +175,18 @@ export class Station extends JlGraphic { codeGraph.style.fill = stationConsts.codeColor; codeGraph.setVectorFontSize(stationConsts.codeFontSize); codeGraph.anchor.set(0.5); - const kilometerCode = this.datas?.kilometerCode || 12345.67; - if (Math.floor(Number(kilometerCode)).toString().length > 3) { - const kiloBit = Math.floor(Number(kilometerCode) / 1000).toString(); + const kilometerCode = this.datas.kilometerSystem?.kilometer || 12345678; + if (Math.floor(kilometerCode * 1000).toString().length > 3) { + const kiloBit = Math.floor(Number(kilometerCode) / 1000000).toString(); kilometerGraph.text = 'K' + kiloBit + '+' + - kilometerCode.toString().substring(kiloBit.length); + ( + Number(kilometerCode.toString().substring(kiloBit.length)) / 1000 + ).toFixed(3); } else { - kilometerGraph.text = kilometerCode; + kilometerGraph.text = (kilometerCode * 1000).toFixed(3); } kilometerGraph.style.fill = stationConsts.kilometerCodeColor; kilometerGraph.setVectorFontSize(stationConsts.kilometerCodeFontSize); diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index da66860..7f078f6 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -1822,7 +1822,7 @@ export namespace graphicData { code?: string; hasControl?: boolean; concentrationStations?: boolean; - kilometerCode?: string; + kilometerSystem?: KilometerSystem; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls); @@ -1839,8 +1839,8 @@ export namespace graphicData { if ("concentrationStations" in data && data.concentrationStations != undefined) { this.concentrationStations = data.concentrationStations; } - if ("kilometerCode" in data && data.kilometerCode != undefined) { - this.kilometerCode = data.kilometerCode; + if ("kilometerSystem" in data && data.kilometerSystem != undefined) { + this.kilometerSystem = data.kilometerSystem; } } } @@ -1871,18 +1871,21 @@ export namespace graphicData { set concentrationStations(value: boolean) { pb_1.Message.setField(this, 4, value); } - get kilometerCode() { - return pb_1.Message.getFieldWithDefault(this, 5, "") as string; + get kilometerSystem() { + return pb_1.Message.getWrapperField(this, KilometerSystem, 6) as KilometerSystem; } - set kilometerCode(value: string) { - pb_1.Message.setField(this, 5, value); + set kilometerSystem(value: KilometerSystem) { + pb_1.Message.setWrapperField(this, 6, value); + } + get has_kilometerSystem() { + return pb_1.Message.getField(this, 6) != null; } static fromObject(data: { common?: ReturnType; code?: string; hasControl?: boolean; concentrationStations?: boolean; - kilometerCode?: string; + kilometerSystem?: ReturnType; }): Station { const message = new Station({}); if (data.common != null) { @@ -1897,8 +1900,8 @@ export namespace graphicData { if (data.concentrationStations != null) { message.concentrationStations = data.concentrationStations; } - if (data.kilometerCode != null) { - message.kilometerCode = data.kilometerCode; + if (data.kilometerSystem != null) { + message.kilometerSystem = KilometerSystem.fromObject(data.kilometerSystem); } return message; } @@ -1908,7 +1911,7 @@ export namespace graphicData { code?: string; hasControl?: boolean; concentrationStations?: boolean; - kilometerCode?: string; + kilometerSystem?: ReturnType; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -1922,8 +1925,8 @@ export namespace graphicData { if (this.concentrationStations != null) { data.concentrationStations = this.concentrationStations; } - if (this.kilometerCode != null) { - data.kilometerCode = this.kilometerCode; + if (this.kilometerSystem != null) { + data.kilometerSystem = this.kilometerSystem.toObject(); } return data; } @@ -1939,8 +1942,8 @@ export namespace graphicData { writer.writeBool(3, this.hasControl); if (this.concentrationStations != false) writer.writeBool(4, this.concentrationStations); - if (this.kilometerCode.length) - writer.writeString(5, this.kilometerCode); + if (this.has_kilometerSystem) + writer.writeMessage(6, this.kilometerSystem, () => this.kilometerSystem.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -1962,8 +1965,8 @@ export namespace graphicData { case 4: message.concentrationStations = reader.readBool(); break; - case 5: - message.kilometerCode = reader.readString(); + case 6: + reader.readMessage(message.kilometerSystem, () => message.kilometerSystem = KilometerSystem.deserialize(reader)); break; default: reader.skipField(); } @@ -2237,7 +2240,7 @@ export namespace graphicData { constructor(data?: any[] | { common?: CommonInfo; code?: string; - kilometerCode?: string; + kilometerSystem?: KilometerSystem; axleCountingRef?: RelatedRef[]; }) { super(); @@ -2249,8 +2252,8 @@ export namespace graphicData { if ("code" in data && data.code != undefined) { this.code = data.code; } - if ("kilometerCode" in data && data.kilometerCode != undefined) { - this.kilometerCode = data.kilometerCode; + if ("kilometerSystem" in data && data.kilometerSystem != undefined) { + this.kilometerSystem = data.kilometerSystem; } if ("axleCountingRef" in data && data.axleCountingRef != undefined) { this.axleCountingRef = data.axleCountingRef; @@ -2272,11 +2275,14 @@ export namespace graphicData { set code(value: string) { pb_1.Message.setField(this, 2, value); } - get kilometerCode() { - return pb_1.Message.getFieldWithDefault(this, 3, "") as string; + get kilometerSystem() { + return pb_1.Message.getWrapperField(this, KilometerSystem, 3) as KilometerSystem; } - set kilometerCode(value: string) { - pb_1.Message.setField(this, 3, value); + set kilometerSystem(value: KilometerSystem) { + pb_1.Message.setWrapperField(this, 3, value); + } + get has_kilometerSystem() { + return pb_1.Message.getField(this, 3) != null; } get axleCountingRef() { return pb_1.Message.getRepeatedWrapperField(this, RelatedRef, 4) as RelatedRef[]; @@ -2287,7 +2293,7 @@ export namespace graphicData { static fromObject(data: { common?: ReturnType; code?: string; - kilometerCode?: string; + kilometerSystem?: ReturnType; axleCountingRef?: ReturnType[]; }): AxleCounting { const message = new AxleCounting({}); @@ -2297,8 +2303,8 @@ export namespace graphicData { if (data.code != null) { message.code = data.code; } - if (data.kilometerCode != null) { - message.kilometerCode = data.kilometerCode; + if (data.kilometerSystem != null) { + message.kilometerSystem = KilometerSystem.fromObject(data.kilometerSystem); } if (data.axleCountingRef != null) { message.axleCountingRef = data.axleCountingRef.map(item => RelatedRef.fromObject(item)); @@ -2309,7 +2315,7 @@ export namespace graphicData { const data: { common?: ReturnType; code?: string; - kilometerCode?: string; + kilometerSystem?: ReturnType; axleCountingRef?: ReturnType[]; } = {}; if (this.common != null) { @@ -2318,8 +2324,8 @@ export namespace graphicData { if (this.code != null) { data.code = this.code; } - if (this.kilometerCode != null) { - data.kilometerCode = this.kilometerCode; + if (this.kilometerSystem != null) { + data.kilometerSystem = this.kilometerSystem.toObject(); } if (this.axleCountingRef != null) { data.axleCountingRef = this.axleCountingRef.map((item: RelatedRef) => item.toObject()); @@ -2334,8 +2340,8 @@ export namespace graphicData { writer.writeMessage(1, this.common, () => this.common.serialize(writer)); if (this.code.length) writer.writeString(2, this.code); - if (this.kilometerCode.length) - writer.writeString(3, this.kilometerCode); + if (this.has_kilometerSystem) + writer.writeMessage(3, this.kilometerSystem, () => this.kilometerSystem.serialize(writer)); if (this.axleCountingRef.length) writer.writeRepeatedMessage(4, this.axleCountingRef, (item: RelatedRef) => item.serialize(writer)); if (!w) @@ -2354,7 +2360,7 @@ export namespace graphicData { message.code = reader.readString(); break; case 3: - message.kilometerCode = reader.readString(); + reader.readMessage(message.kilometerSystem, () => message.kilometerSystem = KilometerSystem.deserialize(reader)); break; case 4: reader.readMessage(message.axleCountingRef, () => pb_1.Message.addToRepeatedWrapperField(message, 4, RelatedRef.deserialize(reader), RelatedRef)); From 4121dde0d2d75785b7c85c85257219fe5d694d1b Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Thu, 29 Jun 2023 17:10:53 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=88=86=E9=9A=94=E7=AC=A6=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draw-app/properties/SeparatorProperty.vue | 10 ++++++- .../separator/SeparatorDrawAssistant.ts | 27 ++++++++++++++----- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/src/components/draw-app/properties/SeparatorProperty.vue b/src/components/draw-app/properties/SeparatorProperty.vue index 5785cc1..81003d2 100644 --- a/src/components/draw-app/properties/SeparatorProperty.vue +++ b/src/components/draw-app/properties/SeparatorProperty.vue @@ -3,6 +3,7 @@ { + const find = typeOptions.find((item) => { + return item.value == separatorModel.separatorType; + }); + return !!find; +}); + drawStore.$subscribe; watch( () => drawStore.selectedGraphic, diff --git a/src/graphics/separator/SeparatorDrawAssistant.ts b/src/graphics/separator/SeparatorDrawAssistant.ts index af4d9ee..799b1c7 100644 --- a/src/graphics/separator/SeparatorDrawAssistant.ts +++ b/src/graphics/separator/SeparatorDrawAssistant.ts @@ -101,16 +101,24 @@ export class SeparatorDraw extends GraphicDrawAssistant< const r = relation.getRelationParam(turnout); port.push(r.param); const other = relation.getOtherRelationParam(turnout); - if (!rMap.has(setKey(r)) && r.param == 'C') { + if (!rMap.has(setKey(r))) { + let t = separatorTypeEnum.section; + if (r.param == 'C' && other.param == 'C') { + t = separatorTypeEnum.turnout; + } rMap.set(setKey(r), { ...r, - separatorType: separatorTypeEnum.turnout, + separatorType: t, }); } - if (!rMap.has(setKey(other)) && other.param == 'C') { + if (!rMap.has(setKey(other))) { + let t = separatorTypeEnum.section; + if (r.param == 'C' && other.param == 'C') { + t = separatorTypeEnum.turnout; + } rMap.set(setKey(other), { ...other, - separatorType: separatorTypeEnum.turnout, + separatorType: t, repetition: true, }); } @@ -172,9 +180,17 @@ export class SeparatorGraphicHitArea implements IHitArea { } contains(x: number, y: number): boolean { let contains = false; + const p = new Point(x, y); + const typeArr = ['section', 'turnout']; const endTypeArr = ['endA', 'endB']; let d = SeparatorConsts.radius; - if (endTypeArr.includes(this.separator.datas.separatorType)) { + if (typeArr.includes(this.separator.datas.separatorType)) { + const tolerance = SeparatorConsts.lineWidth; + const p1 = new Point(0, -SeparatorConsts.height / 2); + const p2 = new Point(0, SeparatorConsts.height / 2); + contains = contains || linePoint(p1, p2, p, tolerance); + return contains; + } else if (endTypeArr.includes(this.separator.datas.separatorType)) { if (this.separator.datas.separatorType == 'endB') { d = -d; } @@ -185,7 +201,6 @@ export class SeparatorGraphicHitArea implements IHitArea { const p4 = new Point(-d * 3, -d); const p5 = new Point(-d, d); const p6 = new Point(-d * 3, d); - const p = new Point(x, y); contains = contains || linePoint(p1, p2, p, tolerance); contains = contains || linePoint(p2, p3, p, tolerance); contains = contains || linePoint(p3, p4, p, tolerance); From 2f1dafe83bc7663da251a4db827802688be7daa6 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Thu, 29 Jun 2023 17:18:16 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=8A=A0=E9=BB=98=E8=AE=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/axleCounting/AxleCountingDrawAssistant.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts index 241c463..9071f8e 100644 --- a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts +++ b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts @@ -109,7 +109,7 @@ export class AxleCountingDraw extends GraphicDrawAssistant< } axleCounting.id = GraphicIdGenerator.next(); axleCounting.datas.axleCountingRef = [refData2, refData1]; - axleCounting.code = `${graphic.code}-${port}+${refGraphic.code}-${refPort}`; + axleCounting.datas.code = `${graphic.datas.code}-${port}+${refGraphic.datas.code}-${refPort}`; this.storeGraphic(axleCounting); axleCounting.loadRelations(); } @@ -136,7 +136,7 @@ export class AxleCountingDraw extends GraphicDrawAssistant< } axleCounting.id = GraphicIdGenerator.next(); axleCounting.datas.axleCountingRef = [refData]; - axleCounting.code = `${graphic.code}-${port}`; + axleCounting.datas.code = `${graphic.datas.code}-${port}`; this.storeGraphic(axleCounting); axleCounting.loadRelations(); }