From 5236853d1e0c2f50c8f9bd6814573313bd8c0e5f Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Fri, 7 Jul 2023 14:34:26 +0800 Subject: [PATCH 01/24] =?UTF-8?q?=E5=88=97=E8=BD=A6=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drawApp/graphics/TrainInteraction.ts | 133 ++++++++++++---- src/graphics/separator/Separator.ts | 4 +- src/graphics/train/Train.ts | 191 +++++++++++++---------- 3 files changed, 213 insertions(+), 115 deletions(-) diff --git a/src/drawApp/graphics/TrainInteraction.ts b/src/drawApp/graphics/TrainInteraction.ts index 95d7f42..687e8bc 100644 --- a/src/drawApp/graphics/TrainInteraction.ts +++ b/src/drawApp/graphics/TrainInteraction.ts @@ -47,18 +47,22 @@ export class TrainData extends GraphicDataBase implements ITrainData { } export class TrainState extends GraphicStateBase implements ITrainState { - constructor(proto?: StateTrain) { + constructor(proto?: train.TrainInfo) { let states; if (proto) { states = proto; } else { - states = new StateTrain(); + states = new train.TrainInfo(); } super(states, Train.Type); } - get states(): StateTrain { - return this.getState(); + get code(): string { + return this.states.trainIndex; + } + + get states(): train.TrainInfo { + return this.getState(); } get lineId(): number { @@ -94,11 +98,11 @@ export class TrainState extends GraphicStateBase implements ITrainState { set devName(v: string) { this.states.devName = v; } - get id(): string { - return this.states.id; + get trainIndex(): string { + return this.states.trainIndex; } - set id(v: string) { - this.states.id = v; + set trainIndex(v: string) { + this.states.trainIndex = v; } get groupId(): string { return this.states.groupId; @@ -169,12 +173,6 @@ export class TrainState extends GraphicStateBase implements ITrainState { set speed(v: number) { this.states.speed = v; } - get show(): boolean { - return this.states.show; - } - set show(v: boolean) { - this.states.show = v; - } get type(): boolean { return this.states.type; } @@ -193,27 +191,48 @@ export class TrainState extends GraphicStateBase implements ITrainState { set rate(v: number) { this.states.rate = v; } + get remove(): train.TrainRemove { + return this.states.remove; + } + set remove(v: train.TrainRemove) { + this.states.remove = v; + } + get block(): train.TrainBlock { + return this.states.block; + } + set block(v: train.TrainBlock) { + this.states.block = v; + } + get record(): train.TrainRecord { + return this.states.record; + } + set record(v: train.TrainRecord) { + this.states.record = v; + } clone(): TrainState { return new TrainState(this.states.cloneMessage()); } -} - -class StateTrain extends train.TrainInfo { - id: string; - constructor(data?: train.TrainInfo) { - super(data); - if (data?.trainIndex) { - this.id = data?.trainIndex; - } else { - this.id = ''; - } + copyFrom(data: GraphicStateBase): void { + pb_1.Message.copyInto(data._state, this._state); + } + eq(data: GraphicStateBase): boolean { + return pb_1.Message.equals(this._state, data._state); } } const negativeDirectionConfig: MenuItemOptions = { name: '反方向运行', }; +const runStopConfig: MenuItemOptions = { + name: '前进/停止', +}; +const diriveModelConfig: MenuItemOptions = { + name: '驾驶模式', +}; +const accuracyConfig: MenuItemOptions = { + name: '正常/早点/晚点', +}; const HoldTrainConfig: MenuItemOptions = { name: '扣车', }; @@ -229,6 +248,9 @@ const TrainOperateMenu: ContextMenu = ContextMenu.init({ { items: [ negativeDirectionConfig, + runStopConfig, + diriveModelConfig, + accuracyConfig, HoldTrainConfig, openDoorConfig, editGroupConfig, @@ -275,20 +297,73 @@ export class TrainOperateInteraction extends GraphicInteractionPlugin { mode.ipModeTrainDirUp = false; mode.ipModeTrainDirDown = true; } - train.chagneDirection(); + train.doRepaint(); + }; + runStopConfig.handler = () => { + train.states.mode.ipModeTrainStoped = + !train.states.mode.ipModeTrainStoped; + train.doRepaint(); + }; + diriveModelConfig.handler = () => { + const arr: Array = [ + 'ipModeTrainDriveModeAm', + 'ipModeTrainDriveModeCm', + 'ipModeTrainDriveBlockAm', + 'ipModeTrainDriveBlockCm', + 'ipModeTrainDriveModeRmf', + ]; + let findIndex = arr.findIndex((key) => { + return train.states.mode[key]; + }); + if (findIndex == arr.length - 1) { + findIndex = -1; + } + arr.forEach((key) => { + (train.states.mode[key] as boolean) = false; + }); + (train.states.mode[arr[findIndex + 1]] as boolean) = true; + train.doRepaint(); }; HoldTrainConfig.handler = () => { train.states.mode.ipModeTrainHolded = !train.states.mode.ipModeTrainHolded; - train.chagneState(); + train.doRepaint(); + }; + accuracyConfig.handler = () => { + const arr: Array = [ + 'ipModeTrainTypeSchedule', + 'ipModeTrainSchdEarly', + 'ipModeTrainSchdLate', + ]; + let findIndex = -1; + arr.forEach((key, index) => { + if (train.states.mode[key]) { + findIndex = index; + } + }); + arr.forEach((key, index) => { + if (index != 0) { + (train.states.mode[key] as boolean) = false; + } + }); + if (findIndex != arr.length - 1) { + train.states.mode.ipModeTrainTypeSchedule = true; + } + if (findIndex == arr.length - 1) { + train.states.mode.ipModeTrainTypeSchedule = false; + } else { + (train.states.mode[arr[findIndex + 1]] as boolean) = true; + } + train.doRepaint(); }; openDoorConfig.handler = () => { train.states.mode.ipModeTrainDoorOpen = !train.states.mode.ipModeTrainDoorOpen; - train.chagneState(); + train.doRepaint(); }; editGroupConfig.handler = () => { - train.states.trainId = '022'; + train.states.trainId = '02'; + train.states.destinationId = 123; train.doRepaint(); }; TrainOperateMenu.open(e.global); diff --git a/src/graphics/separator/Separator.ts b/src/graphics/separator/Separator.ts index 032ee1e..7890ddd 100644 --- a/src/graphics/separator/Separator.ts +++ b/src/graphics/separator/Separator.ts @@ -19,9 +19,9 @@ export enum separatorTypeEnum { } export const SeparatorConsts = { - height: 15, + height: 12, lineWidth: 2, - lineColor: '0x617799', + lineColor: '0xFFFFFF', circleColor: '0xEF0200', radius: 5, }; diff --git a/src/graphics/train/Train.ts b/src/graphics/train/Train.ts index 7e20031..d432abf 100644 --- a/src/graphics/train/Train.ts +++ b/src/graphics/train/Train.ts @@ -1,6 +1,7 @@ import { Color, Graphics, Container, Point } from 'pixi.js'; import { GraphicData, + GraphicIdGenerator, GraphicState, JlGraphic, JlGraphicTemplate, @@ -29,8 +30,8 @@ export interface ITrainState extends GraphicState { set devType(v: state.DeviceType); get devName(): string; // 所在设备名称 set devName(v: string); - get id(): string; // 设备唯一 - set id(v: string); + get trainIndex(): string; // 设备唯一,与trainIndex相同 + set trainIndex(v: string); get groupId(): string; // 列车车组号 set groupId(v: string); get trainId(): string; // 列车表号 @@ -53,14 +54,18 @@ export interface ITrainState extends GraphicState { set departTime(v: number); get speed(): number; // 速度 set speed(v: number); - get show(): boolean; // 是否显示 - set show(v: boolean); get type(): boolean; // 车次号变化状态 set type(v: boolean); get routeId(): number; // 运行路径号 set routeId(v: number); get rate(): number; // 满载率 set rate(v: number); + get remove(): train.TrainRemove; + set remove(v: train.TrainRemove); + get block(): train.TrainBlock; + set block(v: train.TrainBlock); + get record(): train.TrainRecord; + set record(v: train.TrainRecord); } interface bodyWH { @@ -71,36 +76,36 @@ interface bodyWH { // 列车颜色 export enum TrainColorEnum { headColor = '0xFFCE4D', // 箭头颜色 - bodyColor = '0xA388B1', // 背景色 + bodyColor = '0x1F3D99', // 背景色 + ITCbodyColor = '0x737373', // 点式背景色 codeColor = '0xffffff', // 车号颜色 - borderColor = '0xA3E198', // 边框的颜色 + borderColor = '0xffffff', // 边框的颜色 directionColor = '0x00FF00', // 方向箭头颜色 } -enum diriveModelColorEnum { // 驾驶模式对应颜色 - AM = '0x00FF00', // ATO自动驾驶 +enum DiriveModelColorEnum { // 驾驶模式对应颜色 + AM = '0xFF8000', // ATO自动驾驶 SM = '0xFFFF00', // ATP 监控下的人工驾驶模式 - RM = '0xFFC837', // 限制人工驾驶模式 - NRM = '0xA0522D', // 非限制人工驾驶模式 + RM = '0xC2C2C2', // 限制人工驾驶模式 + NRM = '0xFF0000', // 非限制人工驾驶模式 red = '0xF80103', // 红色表示通信中断 } -enum AAColorEnum { // 识别号AA颜色 - accuracy = '0xffffff', // 准点 - early = '0x00FF00', // 早点 - late = '0xA0522D', // 晚点 -} enum typeColorEnum { // 识别号BBB颜色 + accuracy = '0x11EF3D', // 准点 + early = '0x82F6FF', // 早点 + late = '0xE00D02', // 晚点 schedule = '0xffffff', // 计划车 - head = '0xE9FC01', // 头码车 - manual = '0xE9FC01', // 人工车 - special = '0xE9FC01', // 特殊车 + head = '0xffffff', // 头码车 + manual = '0xffffff', // 人工车 + special = '0xFFFF73', // 特殊车 } enum statusTextColor { - H = '0xFFFF00', // H扣车 - S = '0x6260F3', // S跳停 - D = '0x00FF00', // D开门 - A = '0xFF0000', // A报警 + 扣 = '0xFFFF00', // H扣车 + 跳 = '0x00CCFF', // S跳停 + 门 = '0x00FF00', // D开门 + 警 = '0xDA0000', // A报警 + '>>' = '0xFFFF00', // 列车重叠,点击可切换列车 } export const trainConsts = { @@ -110,10 +115,10 @@ export const trainConsts = { borderWidth: 1, codeFontSize: 22, textFontSize: 16, // 状态字母大小 - textMarginY: 10, // 状态字母与列车距离 - statusTextList: ['H', 'S', 'D', 'A'], + textMarginY: 5, // 状态字母与列车距离 + statusTextList: ['扣', '跳', '门', '警', '>>'], marginX: 2, // 图形x轴边距 - pauseW: 2, // 停止框宽度 + pauseW: 4, // 停止框宽度 }; export class TrainHead extends Container { @@ -132,10 +137,10 @@ export class TrainHead extends Container { } doRepaint(states: ITrainState, bodyWH?: bodyWH) { let direction = ''; - if (states.mode?.ipModeTrainDirUp) { + if (states.mode?.ipModeTrainDirDown) { direction = 'left'; } - if (states.mode?.ipModeTrainDirDown) { + if (states.mode?.ipModeTrainDirUp) { direction = 'right'; } this.clear(); @@ -180,21 +185,33 @@ export class TrainHead extends Container { }); pausePoint = pP; } - const arrow = this.arrow; - arrow.beginFill(TrainColorEnum.headColor, 1); - arrow.drawPolygon(arrowPoint); - arrow.endFill(); - this.pause.lineStyle(pauseW, TrainColorEnum.headColor, 1); + let aColor = DiriveModelColorEnum.AM; + let pColor = DiriveModelColorEnum.AM; + if ( + states.mode?.ipModeTrainDriveModeCm || + states.mode?.ipModeTrainDriveBlockCm + ) { + aColor = DiriveModelColorEnum.SM; + pColor = DiriveModelColorEnum.SM; + } else if ( + states.mode?.ipModeTrainDriveModeRmf || + states.mode?.ipModeTrainDriveModeRmr + ) { + aColor = DiriveModelColorEnum.RM; + pColor = DiriveModelColorEnum.RM; + } + this.pause.lineStyle(pauseW, pColor, 1); this.pause.moveTo(pausePoint[0], pausePoint[1]); this.pause.lineTo(pausePoint[2], pausePoint[3]); - } - stop() { - this.pause.visible = true; - this.arrow.visible = false; - } - run() { - this.pause.visible = false; - this.arrow.visible = true; + const arrow = this.arrow; + arrow.beginFill(aColor, 1); + arrow.drawPolygon(arrowPoint); + arrow.endFill(); + if (states.mode?.ipModeTrainStoped) { + this.arrow.visible = false; + } else { + this.arrow.visible = true; + } } } @@ -228,28 +245,33 @@ export class TrainBody extends Container { const codeAGraph = this.codeAGraph; const codeBGraph = this.codeBGraph; const codeRact = this.codeRact; - let codeA = states?.trainId; - let fillAColor = AAColorEnum.accuracy; - if (states.mode?.ipModeTrainTypeSchedule) { - if (states?.otpTime > 0) { - fillAColor = AAColorEnum.late; - } else if (states?.otpTime < 0) { - fillAColor = AAColorEnum.early; - } - } + const codeA = states?.groupId; + let codeB = states?.destinationId ? states?.destinationId + '' : ''; + const fillAColor = typeColorEnum.schedule; let fillBColor = typeColorEnum.schedule; - if (states.mode?.ipModeTrainTypeHead) { - codeA = states?.destinationId + ''; - fillBColor = typeColorEnum.head; + if (states.mode?.ipModeTrainTypeSchedule) { + fillBColor = typeColorEnum.accuracy; + if (states.mode?.ipModeTrainSchdLate) { + fillBColor = typeColorEnum.late; + } else if (states.mode?.ipModeTrainSchdEarly) { + fillBColor = typeColorEnum.early; + } + } else if (states.mode?.ipModeTrainTypeHead) { + codeB = states?.destinationId ? states?.destinationId + '' : ''; } else if (states.mode?.ipModeTrainTypeManual) { - codeA = 'MM'; - fillBColor = typeColorEnum.manual; + codeB = '---'; } else if (states.mode?.ipModeTrainTypeSpecial) { - codeA = ''; + codeB = 'MM'; + } + let bgColor = TrainColorEnum.ITCbodyColor; + if ( + states.mode?.ipModeTrainDriveModeAm || + states.mode?.ipModeTrainDriveModeCm + ) { + bgColor = TrainColorEnum.bodyColor; } - const codeB = states?.globalId; codeAGraph.text = codeA || '01'; - codeBGraph.text = codeB || '2222'; + codeBGraph.text = codeB || '222'; codeAGraph.anchor.set(0.5); codeBGraph.anchor.set(0.5); const styleA = { @@ -273,7 +295,7 @@ export class TrainBody extends Container { trainConsts.borderWidth, new Color(TrainColorEnum.borderColor) ); - codeRact.beginFill(new Color(TrainColorEnum.bodyColor)); + codeRact.beginFill(new Color(bgColor)); codeRact.drawRect(-codeWidth / 2, -codeHeight / 2, codeWidth, codeHeight); codeRact.endFill(); } @@ -288,7 +310,7 @@ class StatusText extends Container { doRepaint(text: string, bodyWH: bodyWH): void { this.sText.text = text; this.sText.anchor.set(0.5); - const c = (statusTextColor as never)[text] || statusTextColor.D; + const c = (statusTextColor as never)[text] || statusTextColor.门; const style = { fill: c, fontSize: trainConsts.textFontSize, @@ -302,7 +324,7 @@ class StatusText extends Container { return item == text; }); if (index < 0) { - index = 1.5; // 中间 + index = (num - 1) / 2; // 中间 } const textMargin = (codeWidth - textHWidth * num) / (num - 1); this.sText.position.set( @@ -337,17 +359,34 @@ export class Train extends JlGraphic { return this.getStates(); } + get code(): string { + return this.states.code; + } + doRepaint(): void { this.trainbody.doRepaint(this.states); const bodyWH = this.trainbody.getBodyWH(); this.trainHead.doRepaint(this.states, bodyWH); - } - - stop() { - this.trainHead.stop(); - } - run() { - this.trainHead.run(); + if (this.states.mode?.ipModeTrainHolded) { + this.showStatus('扣'); + } else { + this.hideStatus('扣'); + } + if (this.states.mode?.ipModeTrainSkipstop) { + this.showStatus('跳'); + } else { + this.hideStatus('跳'); + } + if (this.states.mode?.ipModeTrainDoorOpen) { + this.showStatus('门'); + } else { + this.hideStatus('门'); + } + if (this.states.mode?.ipModeTrainRsAlarm) { + this.showStatus('警'); + } else { + this.hideStatus('警'); + } } showStatus(s: string) { @@ -370,22 +409,6 @@ export class Train extends JlGraphic { this.statusTextMap.delete(s); } } - chagneDirection(): void { - const bodyWH = this.trainbody.getBodyWH(); - this.trainHead.doRepaint(this.states, bodyWH); - } - chagneState(): void { - if (this.states.mode?.ipModeTrainHolded) { - this.showStatus('H'); - } else { - this.hideStatus('H'); - } - if (this.states.mode?.ipModeTrainDoorOpen) { - this.showStatus('D'); - } else { - this.hideStatus('D'); - } - } } export class TrainTemplate extends JlGraphicTemplate { @@ -394,7 +417,7 @@ export class TrainTemplate extends JlGraphicTemplate { } new(): Train { const train = new Train(); - train.loadData(this.datas); + train.id = GraphicIdGenerator.next(); train.loadState(this.states); return train; } From 0df2fd6fac29cc5d3d4e748e4798c03195d3b323 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 10 Jul 2023 10:04:53 +0800 Subject: [PATCH 02/24] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E8=A1=A5=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AxleCountingSectionAssistant.ts | 80 ++++++++++--------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index a0da3ce..c2202db 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -132,49 +132,53 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< } } }); - const fourTurnout: Turnout[] = []; + const fourAxleCounting: AxleCounting[] = []; hasfourTurnout.forEach((axleCountings) => { - const axleCountingRelations = - axleCountings[0].relationManage.getRelationsOfGraphicAndOtherType( - axleCountings[0], - Turnout.Type - ); - axleCountingRelations.forEach((relation) => { - const refDevice = relation.getOtherGraphic
(axleCountings[0]); - fourTurnout; + axleCountings.forEach((axleCounting) => { + //计轴关联的道岔 + const axleCountingRelations = + axleCounting.relationManage.getRelationsOfGraphicAndOtherType( + axleCounting, + Turnout.Type + ); + axleCountingRelations.forEach((relation) => { + const refTurnout = relation.getOtherGraphic(axleCounting); + //道岔关联的计轴 + const turnoutRelations = + refTurnout.relationManage.getRelationsOfGraphicAndOtherType( + refTurnout, + AxleCounting.Type + ); + turnoutRelations.forEach((relation) => { + const refAxleCounting = + relation.getOtherGraphic(refTurnout); + if ( + refAxleCounting.id !== axleCountings[0].id && + refAxleCounting.id !== axleCountings[1].id + ) { + fourAxleCounting.push(refAxleCounting); + } + }); + }); }); }); - - /* axleCountings.sort((a, b) => a.x - b.x); - const downAxleCountings = axleCountings.filter((point) => { - return point.y > 350; - }); - for (let i = 0; i < downAxleCountings.length - 1; i++) { - const firstRef = downAxleCountings[i].datas.axleCountingRef.map( - (ref) => ref.id - ); - const nextRef = downAxleCountings[i + 1].datas.axleCountingRef.map( - (ref) => ref.id - ); - let nextNextRef: string[] = []; - if (i + 2 < downAxleCountings.length) { - nextNextRef = downAxleCountings[i + 2].datas.axleCountingRef.map( - (ref) => ref.id - ); + for (let x = 0; x < fourAxleCounting.length; x += 4) { + const AxleCountings = fourAxleCounting.slice(x, x + 4); + for (let y = 0; y < 4; y++) { + if (fourAxleCounting[x].id == AxleCountings[y].id) continue; + if (fourAxleCounting[x].y == AxleCountings[y].y) { + this.draw([fourAxleCounting[x], AxleCountings[y]]); + break; + } } - if (hasCommonElements(firstRef, nextRef)) { - this.draw([downAxleCountings[i], downAxleCountings[i + 1]]); - } else if ( - hasSamePosition( - downAxleCountings[i + 1].position, - downAxleCountings[i + 2].position - ) && - hasCommonElements(firstRef, nextNextRef) - ) { - this.draw([downAxleCountings[i], downAxleCountings[i + 2]]); - i += 2; + for (let y = 0; y < 4; y++) { + if (fourAxleCounting[x + 1].id == AxleCountings[y].id) continue; + if (fourAxleCounting[x + 1].y == AxleCountings[y].y) { + this.draw([fourAxleCounting[x + 1], AxleCountings[y]]); + break; + } } - } */ + } } } From 580045045a844efec95847a5153c2387fa752089 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 10 Jul 2023 13:37:13 +0800 Subject: [PATCH 03/24] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=A4=9A=E7=94=9F?= =?UTF-8?q?=E6=88=90=E7=9A=84=E8=AE=A1=E8=BD=B4=E5=8C=BA=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AxleCountingSectionAssistant.ts | 47 ++++++++++++------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index c2202db..aad9c9f 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -1,10 +1,4 @@ -import { - FederatedPointerEvent, - IHitArea, - IPoint, - IPointData, - Point, -} from 'pixi.js'; +import { FederatedPointerEvent, IHitArea, IPointData, Point } from 'pixi.js'; import { AbsorbableLine, AbsorbablePosition, @@ -23,14 +17,13 @@ import { AxleCountingSectionConsts, } from './AxleCountingSection'; import { AxleCounting } from '../axleCounting/AxleCounting'; -import { Section } from '../section/Section'; import { Turnout } from '../turnout/Turnout'; import { createRelatedRefProto } from '../CommonGraphics'; -function hasCommonElements(arr1: string[], arr2: string[]): boolean { +function hasCommonElements(arr1: string[], arr2: string[]) { for (let i = 0; i < arr1.length; i++) { if (arr2.includes(arr1[i])) { - return true; + return arr1[i]; } } return false; @@ -84,12 +77,6 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< return true; } draw(graphics: AxleCounting[]) { - /* const paRefPs = this.app.queryStore.queryById( - graphics[0].datas.axleCountingRef[0].id - ); - const RepbRefPs = this.app.queryStore.queryById( - graphics[1].datas.axleCountingRef[0].id - ); */ const axleCountingSection = new AxleCountingSection(); axleCountingSection.loadData(this.graphicTemplate.datas); axleCountingSection.datas.points = [ @@ -124,8 +111,32 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< const refDevice = axleCountings[i].datas.axleCountingRef.map( (ref) => ref.id ); - if (hasCommonElements(refDeviceTarget, refDevice)) { - this.draw([axleCounting, axleCountings[i]]); + const commonElementId = hasCommonElements(refDeviceTarget, refDevice); + if (commonElementId) { + const commonElement = this.app.queryStore.queryById(commonElementId); + let draw = true; + if (commonElement.type == 'Turnout') { + let targetPort, port; + axleCounting.datas.axleCountingRef.forEach((ref) => { + if (ref.id == commonElementId) { + targetPort = ref.devicePort; + } + }); + axleCountings[i].datas.axleCountingRef.forEach((ref) => { + if (ref.id == commonElementId) { + port = ref.devicePort; + } + }); + if ( + (targetPort == 1 && port == 2) || + (targetPort == 2 && port == 1) + ) { + draw = false; + } + } + if (draw) { + this.draw([axleCounting, axleCountings[i]]); + } } if (hasSamePosition(axleCounting, axleCountings[i])) { hasfourTurnout.push([axleCounting, axleCountings[i]]); From 744de6a8d9470fe15c82c65027019e0b7732a3b0 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 10 Jul 2023 14:02:56 +0800 Subject: [PATCH 04/24] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E7=9A=84=E5=9B=BE=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drawApp/index.ts | 57 +++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 35 deletions(-) diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 04db814..baebc11 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -111,14 +111,14 @@ const RedoOptions: MenuItemOptions = { const SelectAllOptions: MenuItemOptions = { name: '全选', }; -const oneLayerOptions: MenuItemOptions = { - name: '图层一', +const linkOptions: MenuItemOptions = { + name: '图层-Link', }; -const twoLayerOptions: MenuItemOptions = { - name: '图层二', +const axleCountingSectionOptions: MenuItemOptions = { + name: '图层-计轴区段', }; const threeLayerOptions: MenuItemOptions = { - name: '图层三', + name: '图层-逻辑区段', }; const layerOptions: MenuItemOptions = { @@ -126,7 +126,7 @@ const layerOptions: MenuItemOptions = { subMenu: [ { name: '图层菜单', - items: [oneLayerOptions, twoLayerOptions, threeLayerOptions], + items: [linkOptions, axleCountingSectionOptions, threeLayerOptions], }, ], }; @@ -223,12 +223,8 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { if (app._drawing) return; UndoOptions.disabled = !app.opRecord.hasUndo; RedoOptions.disabled = !app.opRecord.hasRedo; - const axleCountings = app.queryStore.queryByType( - AxleCounting.Type - ); - const trainWindows = app.queryStore.queryByType( - TrainWindow.Type - ); + const axleCountingSections = + app.queryStore.queryByType(AxleCountingSection.Type); const sections = app.queryStore.queryByType
(Section.Type); const sectionLinks = app.queryStore.queryByType( SectionLink.Type @@ -243,32 +239,16 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { SelectAllOptions.handler = () => { app.selectAllGraphics(); }; - oneLayerOptions.handler = () => { - axleCountings.forEach((axleCounting) => { - axleCounting.visible = false; - }); - sections.forEach((section) => { - section.visible = false; - }); - sectionLinks.forEach((sectionLink) => { - sectionLink.visible = true; - }); - turnouts.forEach((turnout) => { - turnout.visible = false; - }); + linkOptions.handler = () => { + console.log(222); }; - twoLayerOptions.handler = () => { - trainWindows.forEach((trainWindow) => { - trainWindow.visible = false; + axleCountingSectionOptions.handler = () => { + axleCountingSections.forEach((axleCountingSection) => { + axleCountingSection.visible = true; }); }; threeLayerOptions.handler = () => { - axleCountings.forEach((axleCounting) => { - axleCounting.visible = true; - }); - trainWindows.forEach((trainWindow) => { - trainWindow.visible = true; - }); + console.log(2222); }; DefaultCanvasMenu.open(e.global); }); @@ -416,8 +396,15 @@ export async function loadDrawDatas(app: GraphicApp) { storage.axleCountingSections.forEach((axleCountingSection) => { datas.push(new AxleCountingSectionData(axleCountingSection)); }); - app.loadGraphic(datas); + await app.loadGraphic(datas); } else { app.loadGraphic([]); } + //隐藏计轴区段 + const axleCountingSections = app.queryStore.queryByType( + AxleCountingSection.Type + ); + axleCountingSections.forEach((axleCountingSection) => { + axleCountingSection.visible = false; + }); } From 9f04d5825af78d2c7edf2f043eb40e9e83219237 Mon Sep 17 00:00:00 2001 From: fan Date: Mon, 10 Jul 2023 14:45:50 +0800 Subject: [PATCH 05/24] =?UTF-8?q?link=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/sectionLink/SectionLink.ts | 36 ++++ .../sectionLink/SectionLinkDrawAssistant.ts | 200 ++++++++++++------ src/layouts/DrawLayout.vue | 5 + 3 files changed, 179 insertions(+), 62 deletions(-) diff --git a/src/graphics/sectionLink/SectionLink.ts b/src/graphics/sectionLink/SectionLink.ts index 5be55ea..f085f74 100644 --- a/src/graphics/sectionLink/SectionLink.ts +++ b/src/graphics/sectionLink/SectionLink.ts @@ -5,6 +5,8 @@ import { JlGraphicTemplate, VectorText, IChildTransform, + getNormalVector, + movePointAlongNormal, } from 'src/jl-graphic'; import { ILineGraphic } from 'src/jl-graphic/plugins/GraphicEditPlugin'; @@ -23,12 +25,15 @@ export interface ISectionLinkData extends GraphicData { export const SectionLinkConsts = { lineColor: 0x5578b6, lineWidth: 5, + divisionColor: 0xff0000, + divisionWidth: 2, }; export class SectionLink extends JlGraphic implements ILineGraphic { static Type = 'SectionLink'; lineGraphic: Graphics; labelGraphic: VectorText; + divisionGraphic: Graphics = new Graphics(); constructor() { super(SectionLink.Type); @@ -42,6 +47,7 @@ export class SectionLink extends JlGraphic implements ILineGraphic { this.transformSave = true; this.addChild(this.lineGraphic); this.addChild(this.labelGraphic); + this.addChild(this.divisionGraphic); } doRepaint() { @@ -61,6 +67,36 @@ export class SectionLink extends JlGraphic implements ILineGraphic { this.lineGraphic.moveTo(p.x, p.y); } }); + const normalVector = getNormalVector( + this.datas.points[0], + this.datas.points[1] + ); + this.divisionGraphic.clear(); + this.divisionGraphic.lineStyle( + SectionLinkConsts.divisionWidth, + SectionLinkConsts.divisionColor + ); + const nextP = movePointAlongNormal(this.datas.points[0], normalVector, 5); + const nextP1 = movePointAlongNormal(this.datas.points[0], normalVector, -5); + this.divisionGraphic.moveTo(nextP1.x, nextP1.y); + this.divisionGraphic.lineTo(nextP.x, nextP.y); + const normalVector2 = getNormalVector( + this.datas.points[this.datas.points.length - 2], + this.datas.points[this.datas.points.length - 1] + ); + + const nextP2 = movePointAlongNormal( + this.datas.points[this.datas.points.length - 1], + normalVector2, + 5 + ); + const nextP3 = movePointAlongNormal( + this.datas.points[this.datas.points.length - 1], + normalVector2, + -5 + ); + this.divisionGraphic.moveTo(nextP3.x, nextP3.y); + this.divisionGraphic.lineTo(nextP2.x, nextP2.y); this.labelGraphic.text = this.datas.code; const labelPosition = this.datas?.childTransforms?.find( (item: IChildTransform) => item.name === this.labelGraphic.name diff --git a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts index 8856825..ca2f013 100644 --- a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts +++ b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts @@ -23,6 +23,8 @@ import { } from 'pixi.js'; import { Section } from '../section/Section'; import { Turnout } from '../turnout/Turnout'; +import { AxleCounting } from '../axleCounting/AxleCounting'; +import { IRelatedRefData } from '../CommonGraphics'; export class SectionLinkDraw extends GraphicDrawAssistant< SectionLinkTemplate, @@ -65,51 +67,148 @@ export class SectionLinkDraw extends GraphicDrawAssistant< data.points = this.points; return true; } - oneGenerates() { - // localToCanvasPoints - const sectionList = this.app.queryStore.queryByType
(Section.Type); - const turnoutList = this.app.queryStore.queryByType(Turnout.Type); - console.log(sectionList.length, turnoutList.length); - sectionList.forEach((section: Section) => { - const sectionLink = new SectionLink(); - sectionLink.loadData(this.graphicTemplate.datas); - sectionLink.id = GraphicIdGenerator.next(); - const points: IPointData[] = []; - section.datas.points.forEach((p) => { - points.push(section.localToCanvasPoint(p)); - }); - sectionLink.datas.points = points; - this.storeGraphic(sectionLink); + generateBySection(section: Section) { + const sectionLink = new SectionLink(); + sectionLink.loadData(this.graphicTemplate.datas); + sectionLink.id = GraphicIdGenerator.next(); + const points: IPointData[] = []; + section.datas.points.forEach((p) => { + points.push(section.localToCanvasPoint(p)); }); - turnoutList.forEach((turnout: Turnout) => { - const sectionLinkA = new SectionLink(); - const sectionLinkB = new SectionLink(); - const sectionLinkC = new SectionLink(); - sectionLinkA.loadData(this.graphicTemplate.datas); - sectionLinkB.loadData(this.graphicTemplate.datas); - sectionLinkC.loadData(this.graphicTemplate.datas); - const forkP = new Point(turnout.position.x, turnout.position.y); - const pointA = [forkP]; - const pointB = [forkP]; - const pointC = [forkP]; + sectionLink.datas.points = points; + this.storeGraphic(sectionLink); + } + generateByTurnoutAxle(turnout: Turnout, port: number) { + const sectionLink = new SectionLink(); + sectionLink.loadData(this.graphicTemplate.datas); + sectionLink.id = GraphicIdGenerator.next(); + const forkP = new Point(turnout.position.x, turnout.position.y); + const points: IPointData[] = [forkP]; + if (port === 0) { turnout.datas.pointA.forEach((p) => { - pointA.push(turnout.localToCanvasPoint(p)); + points.push(turnout.localToCanvasPoint(p)); }); + } else if (port === 1) { turnout.datas.pointB.forEach((p) => { - pointB.push(turnout.localToCanvasPoint(p)); + points.push(turnout.localToCanvasPoint(p)); }); + } else if (port === 2) { turnout.datas.pointC.forEach((p) => { - pointC.push(turnout.localToCanvasPoint(p)); + points.push(turnout.localToCanvasPoint(p)); }); - sectionLinkA.id = GraphicIdGenerator.next(); - sectionLinkB.id = GraphicIdGenerator.next(); - sectionLinkC.id = GraphicIdGenerator.next(); - sectionLinkA.datas.points = pointA; - sectionLinkB.datas.points = pointB; - sectionLinkC.datas.points = pointC; - this.storeGraphic(sectionLinkA); - this.storeGraphic(sectionLinkB); - this.storeGraphic(sectionLinkC); + } + sectionLink.datas.points = points; + this.storeGraphic(sectionLink); + } + generateByTurnout(turnout: Turnout, port: number, pRef: IRelatedRefData) { + const refg = this.app.queryStore.queryById(pRef.id) as Turnout; + const sectionLink = new SectionLink(); + sectionLink.loadData(this.graphicTemplate.datas); + sectionLink.id = GraphicIdGenerator.next(); + const forkP1 = new Point(refg.position.x, refg.position.y); + const forkP2 = new Point(turnout.position.x, turnout.position.y); + const points: IPointData[] = [forkP1]; + if (pRef.devicePort === 0) { + refg.datas.pointA.forEach((p) => { + points.push(refg.localToCanvasPoint(p)); + }); + } else if (pRef.devicePort === 1) { + refg.datas.pointB.forEach((p) => { + points.push(refg.localToCanvasPoint(p)); + }); + } else if (pRef.devicePort === 2) { + refg.datas.pointC.forEach((p) => { + points.push(refg.localToCanvasPoint(p)); + }); + } + let dataPoint: IPointData[] = []; + if (port === 0) { + dataPoint = turnout.datas.pointA; + } else if (port === 1) { + dataPoint = turnout.datas.pointB; + } else if (port === 2) { + dataPoint = turnout.datas.pointC; + } + const pLength = dataPoint.length; + for (let i = 1; i < pLength + 1; i++) { + points.push(turnout.localToCanvasPoint(dataPoint[pLength - i])); + } + points.push(forkP2); + sectionLink.datas.points = points; + this.storeGraphic(sectionLink); + } + oneGenerates() { + const axleCountingList = this.app.queryStore.queryByType( + AxleCounting.Type + ); + const turnoutList = this.app.queryStore.queryByType(Turnout.Type); + const generated = new Map(); + axleCountingList.forEach((axleCounting) => { + axleCounting.datas.axleCountingRef.forEach((device) => { + const g = this.app.queryStore.queryById(device.id); + if (g.type === Section.Type) { + const g1 = axleCountingList.find((axleCounting) => { + const s = axleCounting.datas.axleCountingRef.find( + (ref) => ref.id === device.id + ); + return s; + }); + if (g1) { + this.generateBySection(g as Section); + generated.set(g.id, ['A', 'B']); + } + } else if (g.type === Turnout.Type) { + this.generateByTurnoutAxle(g as Turnout, device.devicePort); + if (generated.get(g.id)) { + const pList = generated.get(g.id); + pList.push(device.devicePort); + generated.set(g.id, pList); + } else { + generated.set(g.id, [device.devicePort]); + } + } + }); + }); + turnoutList.forEach((turnout) => { + const pList = generated.get(turnout.id); + if (!pList) { + return; + } + let pRef = null; + if ( + !pList.includes(0) && + turnout.datas.paRef && + turnout.datas.paRef.deviceType === 1 + ) { + pRef = turnout.datas.paRef; + this.generateByTurnout(turnout, 0, pRef); + } + if ( + !pList.includes(1) && + turnout.datas.pbRef && + turnout.datas.pbRef.deviceType === 1 + ) { + pRef = turnout.datas.pbRef; + this.generateByTurnout(turnout, 1, pRef); + } + if ( + !pList.includes(2) && + turnout.datas.pcRef && + turnout.datas.pcRef.deviceType === 1 + ) { + pRef = turnout.datas.pcRef; + this.generateByTurnout(turnout, 2, pRef); + } + generated.set(turnout.id, [0, 1, 2]); + if (pRef) { + if (generated.get(pRef.id)) { + const pListn = generated.get(pRef.id); + pListn.push(pRef.devicePort); + generated.set(pRef.id, pListn); + } else { + generated.set(pRef.id, [pRef.devicePort]); + } + } }); } clearCache(): void { @@ -153,31 +252,8 @@ export class SectionLinkEditPlugin extends GraphicInteractionPlugin g.lineGraphic.eventMode = 'static'; g.lineGraphic.cursor = 'pointer'; g.lineGraphic.hitArea = new SectionLinkGraphicHitArea(g); - // g.transformSave = true; - // g.labelGraphic.eventMode = 'static'; - // g.labelGraphic.cursor = 'pointer'; - // g.labelGraphic.selectable = true; - // g.labelGraphic.draggable = true; - // g.on('selected', this.onSelected, this); - // g.on('unselected', this.onUnselected, this); - // g.on('_rightclick', this.onContextMenu, this); } unbind(g: SectionLink): void { - // g.off('selected', this.onSelected, this); - // g.off('unselected', this.onUnselected, this); - // g.off('_rightclick', this.onContextMenu, this); + // console.log } - - // onContextMenu(e: FederatedMouseEvent) { - // const target = e.target as DisplayObject; - // const section = target.getGraphic() as SectionLink; - // this.app.updateSelected(section); - // } - - // onSelected(g: DisplayObject): void { - // const sectionLink = g as SectionLink; - // } - // onUnselected(g: DisplayObject): void { - // const sectionLink = g as SectionLink; - // } } diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index dcec201..0fb428b 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -191,6 +191,7 @@ import { Separator } from 'src/graphics/separator/Separator'; import { SeparatorDraw } from 'src/graphics/separator/SeparatorDrawAssistant'; import { SectionLink } from 'src/graphics/sectionLink/SectionLink'; import { SectionLinkDraw } from 'src/graphics/sectionLink/SectionLinkDrawAssistant'; +import { store } from 'quasar/wrappers'; const route = useRoute(); const router = useRouter(); @@ -335,6 +336,10 @@ function oneClickAxleCounting() { } function oneClickLink() { drawStore.oneClickType = 'SectionLink'; + const linkList = drawStore + .getDrawApp() + .queryStore.queryByType(SectionLink.Type); + drawStore.getDrawApp().deleteGraphics(...linkList); const draw = drawStore .getDrawApp() .getDrawAssistant(SectionLink.Type) as SectionLinkDraw; From 397f04af9d015bc5d7191b4876c01a1efebe2840 Mon Sep 17 00:00:00 2001 From: fan Date: Mon, 10 Jul 2023 14:48:10 +0800 Subject: [PATCH 06/24] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bj-rtss-message | 2 +- graphic-pixi | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bj-rtss-message b/bj-rtss-message index f6f49ec..f12288d 160000 --- a/bj-rtss-message +++ b/bj-rtss-message @@ -1 +1 @@ -Subproject commit f6f49ec19378c9a9845c53bd4425143f654ae59e +Subproject commit f12288dffe11443fbf16c02b9e1f39f3b44ceda2 diff --git a/graphic-pixi b/graphic-pixi index a7debf1..0a0cb0a 160000 --- a/graphic-pixi +++ b/graphic-pixi @@ -1 +1 @@ -Subproject commit a7debf165e24e6200d7c986555f31c721792af38 +Subproject commit 0a0cb0a77afd9783081c2dc6ba19687b0b3aa0f7 From 4ff2a61cae8cd3b05a2156c793b411099be77f54 Mon Sep 17 00:00:00 2001 From: fan Date: Mon, 10 Jul 2023 14:48:42 +0800 Subject: [PATCH 07/24] =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bj-rtss-message | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bj-rtss-message b/bj-rtss-message index f12288d..f6f49ec 160000 --- a/bj-rtss-message +++ b/bj-rtss-message @@ -1 +1 @@ -Subproject commit f12288dffe11443fbf16c02b9e1f39f3b44ceda2 +Subproject commit f6f49ec19378c9a9845c53bd4425143f654ae59e From 1247e1cc6f1c684cef997f9dfac2343a1e902d59 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 10 Jul 2023 15:03:47 +0800 Subject: [PATCH 08/24] =?UTF-8?q?=E5=A2=9E=E9=87=8F=E7=94=9F=E6=88=90?= =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=8C=BA=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AxleCountingSectionAssistant.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index aad9c9f..32c9735 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -76,7 +76,12 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< data.transform = this.container.saveTransform(); return true; } - draw(graphics: AxleCounting[]) { + draw(graphics: AxleCounting[], map: Map) { + if ( + map.has(`${graphics[0].id}+${graphics[1].id}`) || + map.has(`${graphics[1].id}+${graphics[0].id}`) + ) + return; const axleCountingSection = new AxleCountingSection(); axleCountingSection.loadData(this.graphicTemplate.datas); axleCountingSection.datas.points = [ @@ -93,11 +98,17 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< } oneGenerates() { - const axleCountingSectionAll = + const map = new Map(); + const axleCountingSections = this.app.queryStore.queryByType( AxleCountingSection.Type ); - this.app.deleteGraphics(...axleCountingSectionAll); + axleCountingSections.forEach((axleCountingSection) => { + map.set( + `${axleCountingSection.datas.paRef?.id}+${axleCountingSection.datas.pbRef?.id}`, + 1 + ); + }); const axleCountings = this.app.queryStore.queryByType( AxleCounting.Type ); @@ -135,7 +146,7 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< } } if (draw) { - this.draw([axleCounting, axleCountings[i]]); + this.draw([axleCounting, axleCountings[i]], map); } } if (hasSamePosition(axleCounting, axleCountings[i])) { @@ -178,14 +189,14 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< for (let y = 0; y < 4; y++) { if (fourAxleCounting[x].id == AxleCountings[y].id) continue; if (fourAxleCounting[x].y == AxleCountings[y].y) { - this.draw([fourAxleCounting[x], AxleCountings[y]]); + this.draw([fourAxleCounting[x], AxleCountings[y]], map); break; } } for (let y = 0; y < 4; y++) { if (fourAxleCounting[x + 1].id == AxleCountings[y].id) continue; if (fourAxleCounting[x + 1].y == AxleCountings[y].y) { - this.draw([fourAxleCounting[x + 1], AxleCountings[y]]); + this.draw([fourAxleCounting[x + 1], AxleCountings[y]], map); break; } } From b23c0902b0095e4239d3e137c3c06b46befe6286 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 10 Jul 2023 15:10:06 +0800 Subject: [PATCH 09/24] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AxleCountingSectionAssistant.ts | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index 32c9735..f48b4ea 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -203,27 +203,6 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< } } } - -function buildAbsorbablePositions( - axleCountingSection: AxleCountingSection -): AbsorbablePosition[] { - const aps: AbsorbablePosition[] = []; - const axleCountingSections = - axleCountingSection.queryStore.queryByType( - AxleCountingSection.Type - ); - const { width } = axleCountingSection.getGraphicApp().canvas; - axleCountingSections.forEach((other) => { - if (other.id == axleCountingSection.id) { - return; - } - const ps = other.datas.transform.position; - const xs = new AbsorbableLine({ x: 0, y: ps.y }, { x: width, y: ps.y }); - aps.push(xs); - }); - return aps; -} - class AxleCountingSectionGraphicHitArea implements IHitArea { axleCountingSection: AxleCountingSection; constructor(axleCountingSection: AxleCountingSection) { @@ -266,7 +245,6 @@ export class AxleCountingSectionInteraction extends GraphicInteractionPlugin Date: Mon, 10 Jul 2023 15:29:46 +0800 Subject: [PATCH 10/24] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/axleCounting/AxleCountingDrawAssistant.ts | 1 - .../axleCountingSection/AxleCountingSectionAssistant.ts | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts index 3c62ab5..85ec97b 100644 --- a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts +++ b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts @@ -14,7 +14,6 @@ import { IAxleCountingData, AxleCounting, AxleCountingTemplate, - AxleCountingConsts, } from './AxleCounting'; import { Section, SectionPort, SectionType } from '../section/Section'; import { Turnout, TurnoutPort } from '../turnout/Turnout'; diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index f48b4ea..4246bf5 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -1,7 +1,5 @@ import { FederatedPointerEvent, IHitArea, IPointData, Point } from 'pixi.js'; import { - AbsorbableLine, - AbsorbablePosition, GraphicDrawAssistant, GraphicIdGenerator, GraphicInteractionPlugin, From 6bd0951bafdc4341e1241227c3bee1811a846e50 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 10 Jul 2023 15:45:07 +0800 Subject: [PATCH 11/24] =?UTF-8?q?link=E5=9B=BE=E5=B1=82=E5=92=8C=E8=AE=A1?= =?UTF-8?q?=E8=BD=B4=E5=8C=BA=E6=AE=B5=E5=9B=BE=E5=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/drawApp/index.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index baebc11..1f379a9 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -230,6 +230,12 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { SectionLink.Type ); const turnouts = app.queryStore.queryByType(Turnout.Type); + const disvisibleGraphics = [ + ...sections, + ...turnouts, + ...sectionLinks, + ...axleCountingSections, + ]; UndoOptions.handler = () => { app.opRecord.undo(); }; @@ -240,9 +246,17 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { app.selectAllGraphics(); }; linkOptions.handler = () => { - console.log(222); + disvisibleGraphics.forEach((g) => { + g.visible = false; + }); + sectionLinks.forEach((axleCountingSection) => { + axleCountingSection.visible = true; + }); }; axleCountingSectionOptions.handler = () => { + disvisibleGraphics.forEach((g) => { + g.visible = false; + }); axleCountingSections.forEach((axleCountingSection) => { axleCountingSection.visible = true; }); @@ -400,11 +414,17 @@ export async function loadDrawDatas(app: GraphicApp) { } else { app.loadGraphic([]); } - //隐藏计轴区段 + //隐藏计轴区段--Link const axleCountingSections = app.queryStore.queryByType( AxleCountingSection.Type ); axleCountingSections.forEach((axleCountingSection) => { axleCountingSection.visible = false; }); + const sectionLinks = app.queryStore.queryByType( + SectionLink.Type + ); + sectionLinks.forEach((sectionLink) => { + sectionLink.visible = false; + }); } From 5573f7ea425eecdc5c4584704ea23173fd2607a2 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Mon, 10 Jul 2023 16:34:33 +0800 Subject: [PATCH 12/24] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E5=8C=BA=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../graphics/LogicSectionInteraction.ts | 63 ++++ src/drawApp/index.ts | 53 +++- src/graphics/logicSection/LogicSection.ts | 122 ++++++++ .../logicSection/LogicSectionDrawAssistant.ts | 273 ++++++++++++++++++ src/layouts/DrawLayout.vue | 12 + src/protos/stationLayoutGraphics.ts | 25 +- 6 files changed, 543 insertions(+), 5 deletions(-) create mode 100644 src/drawApp/graphics/LogicSectionInteraction.ts create mode 100644 src/graphics/logicSection/LogicSection.ts create mode 100644 src/graphics/logicSection/LogicSectionDrawAssistant.ts diff --git a/src/drawApp/graphics/LogicSectionInteraction.ts b/src/drawApp/graphics/LogicSectionInteraction.ts new file mode 100644 index 0000000..a800c88 --- /dev/null +++ b/src/drawApp/graphics/LogicSectionInteraction.ts @@ -0,0 +1,63 @@ +import * as pb_1 from 'google-protobuf'; +import { GraphicDataBase } from './GraphicDataBase'; +import { + ILogicSectionData, + LogicSection, +} from 'src/graphics/logicSection/LogicSection'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; +import { IPointData } from 'pixi.js'; + +export class LogicSectionData + extends GraphicDataBase + implements ILogicSectionData +{ + constructor(data?: graphicData.AxleCountingSection) { + let logicSection; + if (!data) { + logicSection = new graphicData.AxleCountingSection({ + common: GraphicDataBase.defaultCommonInfo(LogicSection.Type), + }); + } else { + logicSection = data; + } + super(logicSection); + } + public get data(): graphicData.AxleCountingSection { + return this.getData(); + } + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + get points(): IPointData[] { + return this.data.points; + } + set points(points: IPointData[]) { + this.data.points = points.map( + (p) => new graphicData.Point({ x: p.x, y: p.y }) + ); + } + get paRef(): graphicData.RelatedRef { + return this.data.paRef; + } + set paRef(ref: graphicData.RelatedRef) { + this.data.paRef = ref; + } + get pbRef(): graphicData.RelatedRef { + return this.data.pbRef; + } + set pbRef(ref: graphicData.RelatedRef) { + this.data.pbRef = ref; + } + clone(): LogicSectionData { + return new LogicSectionData(this.data.cloneMessage()); + } + copyFrom(data: LogicSectionData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: LogicSectionData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 1f379a9..6a3576c 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -71,6 +71,12 @@ import { } from 'src/graphics/sectionLink/SectionLink'; import { SectionLinkDraw } from 'src/graphics/sectionLink/SectionLinkDrawAssistant'; import { SectionLinkData } from './graphics/SectionLinkInteraction'; +import { LogicSectionDraw } from 'src/graphics/logicSection/LogicSectionDrawAssistant'; +import { + LogicSection, + LogicSectionTemplate, +} from 'src/graphics/logicSection/LogicSection'; +import { LogicSectionData } from './graphics/LogicSectionInteraction'; // export function fromStoragePoint(p: graphicData.Point): Point { // return new Point(p.x, p.y); @@ -111,13 +117,16 @@ const RedoOptions: MenuItemOptions = { const SelectAllOptions: MenuItemOptions = { name: '全选', }; +const AllOptions: MenuItemOptions = { + name: '全部图层', +}; const linkOptions: MenuItemOptions = { name: '图层-Link', }; const axleCountingSectionOptions: MenuItemOptions = { name: '图层-计轴区段', }; -const threeLayerOptions: MenuItemOptions = { +const LogicSectionOptions: MenuItemOptions = { name: '图层-逻辑区段', }; @@ -126,7 +135,12 @@ const layerOptions: MenuItemOptions = { subMenu: [ { name: '图层菜单', - items: [linkOptions, axleCountingSectionOptions, threeLayerOptions], + items: [ + AllOptions, + linkOptions, + axleCountingSectionOptions, + LogicSectionOptions, + ], }, ], }; @@ -178,6 +192,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { | SeparatorDraw | SectionLinkDraw | AxleCountingSectionDraw + | LogicSectionDraw )[] = []; if (draftType === 'Line') { drawAssistants = [ @@ -211,6 +226,10 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { app, new AxleCountingSectionTemplate(new AxleCountingSectionData()) ), + new LogicSectionDraw( + app, + new LogicSectionTemplate(new LogicSectionData()) + ), ]; DrawSignalInteraction.init(app); } @@ -225,6 +244,9 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { RedoOptions.disabled = !app.opRecord.hasRedo; const axleCountingSections = app.queryStore.queryByType(AxleCountingSection.Type); + const logicSections = app.queryStore.queryByType( + LogicSection.Type + ); const sections = app.queryStore.queryByType
(Section.Type); const sectionLinks = app.queryStore.queryByType( SectionLink.Type @@ -235,6 +257,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { ...turnouts, ...sectionLinks, ...axleCountingSections, + ...logicSections, ]; UndoOptions.handler = () => { app.opRecord.undo(); @@ -245,6 +268,11 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { SelectAllOptions.handler = () => { app.selectAllGraphics(); }; + AllOptions.handler = () => { + disvisibleGraphics.forEach((g) => { + g.visible = true; + }); + }; linkOptions.handler = () => { disvisibleGraphics.forEach((g) => { g.visible = false; @@ -261,8 +289,13 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp { axleCountingSection.visible = true; }); }; - threeLayerOptions.handler = () => { - console.log(2222); + LogicSectionOptions.handler = () => { + disvisibleGraphics.forEach((g) => { + g.visible = false; + }); + logicSections.forEach((logicSection) => { + logicSection.visible = true; + }); }; DefaultCanvasMenu.open(e.global); }); @@ -346,6 +379,9 @@ export function saveDrawDatas(app: JlDrawApp) { storage.axleCountingSections.push( (axleCountingSectionData as AxleCountingSectionData).data ); + } else if (LogicSection.Type === g.type) { + const logicSectionData = (g as LogicSection).saveData(); + storage.logicSections.push((logicSectionData as LogicSectionData).data); } }); const base64 = fromUint8Array(storage.serialize()); @@ -410,6 +446,9 @@ export async function loadDrawDatas(app: GraphicApp) { storage.axleCountingSections.forEach((axleCountingSection) => { datas.push(new AxleCountingSectionData(axleCountingSection)); }); + storage.logicSections.forEach((logicSection) => { + datas.push(new LogicSectionData(logicSection)); + }); await app.loadGraphic(datas); } else { app.loadGraphic([]); @@ -427,4 +466,10 @@ export async function loadDrawDatas(app: GraphicApp) { sectionLinks.forEach((sectionLink) => { sectionLink.visible = false; }); + const logicSections = app.queryStore.queryByType( + LogicSection.Type + ); + logicSections.forEach((logicSection) => { + logicSection.visible = false; + }); } diff --git a/src/graphics/logicSection/LogicSection.ts b/src/graphics/logicSection/LogicSection.ts new file mode 100644 index 0000000..3e6ec3d --- /dev/null +++ b/src/graphics/logicSection/LogicSection.ts @@ -0,0 +1,122 @@ +import { Graphics, IPointData } from 'pixi.js'; +import { + GraphicData, + GraphicRelationParam, + JlGraphic, + JlGraphicTemplate, + VectorText, +} from 'src/jl-graphic'; +import { IRelatedRefData, protoPort2Data } from '../CommonGraphics'; +import { SectionPort } from '../section/Section'; + +export interface ILogicSectionData extends GraphicData { + get code(): string; // 编号 + set code(v: string); + get points(): IPointData[]; // 线坐标点 + set points(points: IPointData[]); + get paRef(): IRelatedRefData | undefined; + set paRef(ref: IRelatedRefData | undefined); + get pbRef(): IRelatedRefData | undefined; + set pbRef(ref: IRelatedRefData | undefined); + clone(): ILogicSectionData; + copyFrom(data: ILogicSectionData): void; + eq(other: ILogicSectionData): boolean; +} + +export const LogicSectionConsts = { + lineColor: '0xff0000', + lineWidth: 2, +}; + +export class LogicSection extends JlGraphic { + static Type = 'LogicSection'; + lineGraphic: Graphics; + labelGraphic: VectorText; + constructor() { + super(LogicSection.Type); + this.lineGraphic = new Graphics(); + this.labelGraphic = new VectorText(); + this.labelGraphic.setVectorFontSize(14); + this.labelGraphic.anchor.set(0.5); + this.labelGraphic.style.fill = '#0f0'; + this.labelGraphic.transformSave = true; + this.labelGraphic.name = 'label'; + this.transformSave = true; + this.addChild(this.lineGraphic); + this.addChild(this.labelGraphic); + } + + get datas(): ILogicSectionData { + return this.getDatas(); + } + doRepaint(): void { + if (this.datas.points.length < 2) { + throw new Error('LogicSection坐标数据异常'); + } + this.lineGraphic.clear(); + this.lineGraphic.lineStyle( + LogicSectionConsts.lineWidth, + LogicSectionConsts.lineColor + ); + this.datas.points.forEach((p, i) => { + if (i !== 0) { + this.lineGraphic.lineTo(p.x, p.y); + } else { + this.lineGraphic.moveTo(p.x, p.y); + } + }); + this.labelGraphic.text = this.datas.code; + const labelPosition = this.datas.childTransforms?.find( + (t) => t.name === this.labelGraphic.name + )?.transform.position; + if (labelPosition) { + this.labelGraphic.position.set(labelPosition.x, labelPosition.y); + } else { + this.labelGraphic.position.set( + this.datas.points[0].x, + this.datas.points[0].y + 20 + ); + } + } + get linePoints(): IPointData[] { + return this.datas.points; + } + set linePoints(points: IPointData[]) { + const old = this.datas.clone(); + old.points = points; + this.updateData(old); + } + loadRelations() { + if (this.datas?.paRef?.id) { + this.relationManage.addRelation( + new GraphicRelationParam(this, SectionPort.A), + new GraphicRelationParam( + this.queryStore.queryById(this.datas.paRef.id), + protoPort2Data(this.datas.paRef.devicePort) + ) + ); + } + if (this.datas?.pbRef?.id) { + this.relationManage.addRelation( + new GraphicRelationParam(this, SectionPort.B), + new GraphicRelationParam( + this.queryStore.queryById(this.datas.pbRef.id), + protoPort2Data(this.datas.pbRef.devicePort) + ) + ); + } + } +} + +export class LogicSectionTemplate extends JlGraphicTemplate { + constructor(dataTemplate: ILogicSectionData) { + super(LogicSection.Type, { + dataTemplate, + }); + } + new(): LogicSection { + const logicSection = new LogicSection(); + logicSection.loadData(this.datas); + return logicSection; + } +} diff --git a/src/graphics/logicSection/LogicSectionDrawAssistant.ts b/src/graphics/logicSection/LogicSectionDrawAssistant.ts new file mode 100644 index 0000000..d04d76f --- /dev/null +++ b/src/graphics/logicSection/LogicSectionDrawAssistant.ts @@ -0,0 +1,273 @@ +import { FederatedPointerEvent, IHitArea, IPointData, Point } from 'pixi.js'; +import { + AbsorbableLine, + AbsorbablePosition, + GraphicDrawAssistant, + GraphicIdGenerator, + GraphicInteractionPlugin, + JlDrawApp, + JlGraphic, + linePoint, +} from 'src/jl-graphic'; + +import { + ILogicSectionData, + LogicSection, + LogicSectionTemplate, + LogicSectionConsts, +} from './LogicSection'; +import { AxleCounting } from '../axleCounting/AxleCounting'; +import { Turnout } from '../turnout/Turnout'; +import { createRelatedRefProto } from '../CommonGraphics'; + +function hasCommonElements(arr1: string[], arr2: string[]) { + for (let i = 0; i < arr1.length; i++) { + if (arr2.includes(arr1[i])) { + return arr1[i]; + } + } + return false; +} + +function hasSamePosition(point1: IPointData, point2: IPointData): boolean { + if ( + Math.abs(point1.x - point2.x) < 20 && + Math.abs(point1.y - point2.y) < 20 + ) { + return true; + } + return false; +} + +export interface ILogicSectionDrawOptions { + newData: () => ILogicSectionData; +} + +export class LogicSectionDraw extends GraphicDrawAssistant< + LogicSectionTemplate, + ILogicSectionData +> { + codeGraph: LogicSection; + constructor(app: JlDrawApp, template: LogicSectionTemplate) { + super(app, template, 'sym_o_circle', '不展示'); + this.codeGraph = this.graphicTemplate.new(); + this.container.addChild(this.codeGraph); + LogicSectionInteraction.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: ILogicSectionData): boolean { + data.transform = this.container.saveTransform(); + return true; + } + draw(graphics: JlGraphic[], map: Map) { + if ( + map.has(`${graphics[0].id}+${graphics[1].id}`) || + map.has(`${graphics[1].id}+${graphics[0].id}`) + ) + return; + const logicSection = new LogicSection(); + logicSection.loadData(this.graphicTemplate.datas); + logicSection.datas.points = [graphics[0].position, graphics[1].position]; + logicSection.id = GraphicIdGenerator.next(); + const paRef = createRelatedRefProto(graphics[0].type, graphics[0].id); + const pbRef = createRelatedRefProto(graphics[1].type, graphics[1].id); + logicSection.datas.paRef = paRef; + logicSection.datas.pbRef = pbRef; + this.storeGraphic(logicSection); + logicSection.loadRelations(); + } + + oneGenerates() { + const map = new Map(); + const logicSections = this.app.queryStore.queryByType( + LogicSection.Type + ); + logicSections.forEach((logicSection) => { + map.set( + `${logicSection.datas.paRef?.id}+${logicSection.datas.pbRef?.id}`, + 1 + ); + }); + const axleCountings = this.app.queryStore.queryByType( + AxleCounting.Type + ); + const hasfourTurnout: AxleCounting[][] = []; + axleCountings.forEach((axleCounting) => { + const refDeviceTarget = axleCounting.datas.axleCountingRef.map( + (ref) => ref.id + ); + for (let i = 0; i < axleCountings.length - 1; i++) { + if (axleCountings[i].id == axleCounting.id) return; + const refDevice = axleCountings[i].datas.axleCountingRef.map( + (ref) => ref.id + ); + const commonElementId = hasCommonElements(refDeviceTarget, refDevice); + if (commonElementId) { + const commonElement = this.app.queryStore.queryById(commonElementId); + let draw = true; + if (commonElement.type == 'Turnout') { + let targetPort, port; + axleCounting.datas.axleCountingRef.forEach((ref) => { + if (ref.id == commonElementId) { + targetPort = ref.devicePort; + } + }); + axleCountings[i].datas.axleCountingRef.forEach((ref) => { + if (ref.id == commonElementId) { + port = ref.devicePort; + } + }); + if ( + (targetPort == 1 && port == 2) || + (targetPort == 2 && port == 1) + ) { + draw = false; + } + } + if (draw) { + this.draw([axleCounting, axleCountings[i]], map); + } + } + if (hasSamePosition(axleCounting, axleCountings[i])) { + hasfourTurnout.push([axleCounting, axleCountings[i]]); + } + } + }); + const fourAxleCounting: AxleCounting[] = []; + hasfourTurnout.forEach((axleCountings) => { + axleCountings.forEach((axleCounting) => { + //计轴关联的道岔 + const axleCountingRelations = + axleCounting.relationManage.getRelationsOfGraphicAndOtherType( + axleCounting, + Turnout.Type + ); + axleCountingRelations.forEach((relation) => { + const refTurnout = relation.getOtherGraphic(axleCounting); + //道岔关联的计轴 + const turnoutRelations = + refTurnout.relationManage.getRelationsOfGraphicAndOtherType( + refTurnout, + AxleCounting.Type + ); + turnoutRelations.forEach((relation) => { + const refAxleCounting = + relation.getOtherGraphic(refTurnout); + if ( + refAxleCounting.id !== axleCountings[0].id && + refAxleCounting.id !== axleCountings[1].id + ) { + fourAxleCounting.push(refAxleCounting); + } + }); + }); + }); + }); + for (let x = 0; x < fourAxleCounting.length; x += 4) { + const AxleCountings = fourAxleCounting.slice(x, x + 4); + for (let y = 0; y < 4; y++) { + if (fourAxleCounting[x].id == AxleCountings[y].id) continue; + if (fourAxleCounting[x].y == AxleCountings[y].y) { + this.draw([fourAxleCounting[x], AxleCountings[y]], map); + break; + } + } + for (let y = 0; y < 4; y++) { + if (fourAxleCounting[x + 1].id == AxleCountings[y].id) continue; + if (fourAxleCounting[x + 1].y == AxleCountings[y].y) { + this.draw([fourAxleCounting[x + 1], AxleCountings[y]], map); + break; + } + } + } + const turnouts = this.app.queryStore.queryByType(Turnout.Type); + turnouts.forEach((turnout) => { + const turnoutRelations = + turnout.relationManage.getRelationsOfGraphicAndOtherType( + turnout, + AxleCounting.Type + ); + turnoutRelations.forEach((ref) => { + const t = ref.getRelationParam(turnout); + const other = ref.getOtherGraphic(turnout) as AxleCounting; + if (t.param == 'C') { + this.draw([turnout, other], map); + } + }); + }); + } +} +class LogicSectionGraphicHitArea implements IHitArea { + logicSection: LogicSection; + constructor(logicSection: LogicSection) { + this.logicSection = logicSection; + } + contains(x: number, y: number): boolean { + for (let i = 1; i < this.logicSection.datas.points.length; i++) { + const p1 = this.logicSection.datas.points[i - 1]; + const p2 = this.logicSection.datas.points[i]; + if (linePoint(p1, p2, { x, y }, LogicSectionConsts.lineWidth)) { + return true; + } + } + return false; + } +} + +export class LogicSectionInteraction extends GraphicInteractionPlugin { + static Name = 'LogicSection_transform'; + constructor(app: JlDrawApp) { + super(LogicSectionInteraction.Name, app); + } + static init(app: JlDrawApp) { + return new LogicSectionInteraction(app); + } + filter(...grahpics: JlGraphic[]): LogicSection[] | undefined { + return grahpics + .filter((g) => g.type === LogicSection.Type) + .map((g) => g as LogicSection); + } + bind(g: LogicSection): 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 LogicSectionGraphicHitArea(g); + g.labelGraphic.eventMode = 'static'; + g.labelGraphic.cursor = 'pointer'; + g.labelGraphic.selectable = true; + g.labelGraphic.draggable = true; + } + unbind(g: LogicSection): void { + g.eventMode = 'none'; + g.scalable = false; + g.rotatable = false; + g.lineGraphic.eventMode = 'none'; + g.lineGraphic.draggable = false; + g.lineGraphic.selectable = false; + g.lineGraphic.transformSave = false; + g.labelGraphic.eventMode = 'none'; + g.labelGraphic.draggable = false; + g.labelGraphic.selectable = false; + g.labelGraphic.transformSave = false; + } +} diff --git a/src/layouts/DrawLayout.vue b/src/layouts/DrawLayout.vue index 9135592..708e0c6 100644 --- a/src/layouts/DrawLayout.vue +++ b/src/layouts/DrawLayout.vue @@ -34,6 +34,9 @@ > 一键生成计轴区段 + + 一键生成逻辑区段 + @@ -201,6 +204,8 @@ import { SectionLinkDraw } from 'src/graphics/sectionLink/SectionLinkDrawAssista import { store } from 'quasar/wrappers'; import { AxleCountingSection } from 'src/graphics/axleCountingSection/AxleCountingSection'; import { AxleCountingSectionDraw } from 'src/graphics/axleCountingSection/AxleCountingSectionAssistant'; +import { LogicSection } from 'src/graphics/logicSection/LogicSection'; +import { LogicSectionDraw } from 'src/graphics/logicSection/LogicSectionDrawAssistant'; const route = useRoute(); const router = useRouter(); @@ -350,6 +355,13 @@ function oneClickAxleCountingSection() { .getDrawAssistant(AxleCountingSection.Type) as AxleCountingSectionDraw; axleCountingSectionDraw.oneGenerates(); } +function oneClickLogicSection() { + //一键生成逻辑区段 + const logicSectionDraw = drawStore + .getDrawApp() + .getDrawAssistant(LogicSection.Type) as LogicSectionDraw; + logicSectionDraw.oneGenerates(); +} function oneClickLink() { drawStore.oneClickType = 'SectionLink'; const linkList = drawStore diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index 17a6ae5..a73b14d 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -24,9 +24,10 @@ export namespace graphicData { separators?: Separator[]; sectionLinks?: SectionLink[]; axleCountingSections?: AxleCountingSection[]; + logicSections?: AxleCountingSection[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16], 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], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("canvas" in data && data.canvas != undefined) { this.canvas = data.canvas; @@ -76,6 +77,9 @@ export namespace graphicData { if ("axleCountingSections" in data && data.axleCountingSections != undefined) { this.axleCountingSections = data.axleCountingSections; } + if ("logicSections" in data && data.logicSections != undefined) { + this.logicSections = data.logicSections; + } } } get canvas() { @@ -177,6 +181,12 @@ export namespace graphicData { set axleCountingSections(value: AxleCountingSection[]) { pb_1.Message.setRepeatedWrapperField(this, 16, value); } + get logicSections() { + return pb_1.Message.getRepeatedWrapperField(this, AxleCountingSection, 17) as AxleCountingSection[]; + } + set logicSections(value: AxleCountingSection[]) { + pb_1.Message.setRepeatedWrapperField(this, 17, value); + } static fromObject(data: { canvas?: ReturnType; links?: ReturnType[]; @@ -194,6 +204,7 @@ export namespace graphicData { separators?: ReturnType[]; sectionLinks?: ReturnType[]; axleCountingSections?: ReturnType[]; + logicSections?: ReturnType[]; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -244,6 +255,9 @@ export namespace graphicData { if (data.axleCountingSections != null) { message.axleCountingSections = data.axleCountingSections.map(item => AxleCountingSection.fromObject(item)); } + if (data.logicSections != null) { + message.logicSections = data.logicSections.map(item => AxleCountingSection.fromObject(item)); + } return message; } toObject() { @@ -264,6 +278,7 @@ export namespace graphicData { separators?: ReturnType[]; sectionLinks?: ReturnType[]; axleCountingSections?: ReturnType[]; + logicSections?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -313,6 +328,9 @@ export namespace graphicData { if (this.axleCountingSections != null) { data.axleCountingSections = this.axleCountingSections.map((item: AxleCountingSection) => item.toObject()); } + if (this.logicSections != null) { + data.logicSections = this.logicSections.map((item: AxleCountingSection) => item.toObject()); + } return data; } serialize(): Uint8Array; @@ -351,6 +369,8 @@ export namespace graphicData { writer.writeRepeatedMessage(15, this.sectionLinks, (item: SectionLink) => item.serialize(writer)); if (this.axleCountingSections.length) writer.writeRepeatedMessage(16, this.axleCountingSections, (item: AxleCountingSection) => item.serialize(writer)); + if (this.logicSections.length) + writer.writeRepeatedMessage(17, this.logicSections, (item: AxleCountingSection) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -408,6 +428,9 @@ export namespace graphicData { case 16: reader.readMessage(message.axleCountingSections, () => pb_1.Message.addToRepeatedWrapperField(message, 16, AxleCountingSection.deserialize(reader), AxleCountingSection)); break; + case 17: + reader.readMessage(message.logicSections, () => pb_1.Message.addToRepeatedWrapperField(message, 17, AxleCountingSection.deserialize(reader), AxleCountingSection)); + break; default: reader.skipField(); } } From 88c16a240ef861adfd0038a1e10f7f049e527448 Mon Sep 17 00:00:00 2001 From: fan Date: Mon, 10 Jul 2023 16:54:49 +0800 Subject: [PATCH 13/24] =?UTF-8?q?link=E7=94=9F=E6=88=90=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/graphics/sectionLink/SectionLinkDrawAssistant.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts index ca2f013..626b759 100644 --- a/src/graphics/sectionLink/SectionLinkDrawAssistant.ts +++ b/src/graphics/sectionLink/SectionLinkDrawAssistant.ts @@ -146,7 +146,7 @@ export class SectionLinkDraw extends GraphicDrawAssistant< axleCountingList.forEach((axleCounting) => { axleCounting.datas.axleCountingRef.forEach((device) => { const g = this.app.queryStore.queryById(device.id); - if (g.type === Section.Type) { + if (g.type === Section.Type && !generated.get(device.id)) { const g1 = axleCountingList.find((axleCounting) => { const s = axleCounting.datas.axleCountingRef.find( (ref) => ref.id === device.id From 34ac0ac03c01bddd096ceaa0155e4b18cf42560f Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Mon, 10 Jul 2023 17:01:08 +0800 Subject: [PATCH 14/24] =?UTF-8?q?=E5=BE=AE=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draw-app/properties/AxleCountingSectionProperty.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/draw-app/properties/AxleCountingSectionProperty.vue b/src/components/draw-app/properties/AxleCountingSectionProperty.vue index 9d3cf5c..88e7e8c 100644 --- a/src/components/draw-app/properties/AxleCountingSectionProperty.vue +++ b/src/components/draw-app/properties/AxleCountingSectionProperty.vue @@ -40,7 +40,7 @@ 关联的计轴
{ +const axleCountingRelations = computed(() => { const axleCountingSection = drawStore.selectedGraphic as AxleCountingSection; const sectionRelations = axleCountingSection?.relationManage.getRelationsOfGraphicAndOtherType( @@ -112,7 +112,7 @@ const sectionRelations = computed(() => { (relation) => `${ relation.getOtherGraphic(axleCountingSection).datas.code - }(${relation.getOtherRelationParam(axleCountingSection).param})` + }` ); return Array.from(new Set(ref)); }); From 8c717d45dd94543e0ee1c57dabd83d0e88b56046 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Tue, 11 Jul 2023 15:35:35 +0800 Subject: [PATCH 15/24] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E4=B8=8E=E9=81=93=E5=B2=94=E4=BD=8D=E7=BD=AE=E5=85=B3=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AxleCountingSectionProperty.vue | 62 ++++++---- .../AxleCountingSectionInteraction.ts | 7 ++ .../AxleCountingSection.ts | 13 +- .../AxleCountingSectionAssistant.ts | 100 +++++++++++---- src/protos/stationLayoutGraphics.ts | 115 +++++++++++++++++- 5 files changed, 247 insertions(+), 50 deletions(-) diff --git a/src/components/draw-app/properties/AxleCountingSectionProperty.vue b/src/components/draw-app/properties/AxleCountingSectionProperty.vue index 88e7e8c..c85d1d9 100644 --- a/src/components/draw-app/properties/AxleCountingSectionProperty.vue +++ b/src/components/draw-app/properties/AxleCountingSectionProperty.vue @@ -16,24 +16,6 @@ lazy-rules autogrow /> - - @@ -51,6 +33,23 @@
+ + + + 关联道岔的位置关系 +
+ + {{ item }} + +
+
+
@@ -59,19 +58,17 @@ import { AxleCountingSectionData } from 'src/drawApp/graphics/AxleCountingSectionInteraction'; import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting'; import { AxleCountingSection } from 'src/graphics/axleCountingSection/AxleCountingSection'; +import { Turnout } from 'src/graphics/turnout/Turnout'; import { useDrawStore } from 'src/stores/draw-store'; import { computed, onMounted, reactive, watch } from 'vue'; const drawStore = useDrawStore(); const axleCountingSectionModel = reactive(new AxleCountingSectionData()); -const kilometerSystem = reactive({ coordinateSystem: '', kilometer: 0 }); -const CoordinateSystemOptions = [ - { label: '车辆段', value: 'DEPOT' }, - { label: '停车场', value: 'PARKING_LOT' }, - { label: '正线', value: 'MAIN_LINE' }, - { label: '换线', value: 'TRANSFER' }, -]; +enum turoutPos { + '正位', + '反位', +} drawStore.$subscribe; watch( @@ -116,4 +113,19 @@ const axleCountingRelations = computed(() => { ); return Array.from(new Set(ref)); }); + +const turnoutRelations = computed(() => { + const axleCountingSection = drawStore.selectedGraphic as AxleCountingSection; + const refTurnoutAndPos: { turnout: Turnout; pos: number }[] = []; + axleCountingSection?.datas.turnoutPosRef.forEach((ref) => { + const refTurout = axleCountingSection.queryStore.queryById( + ref.id + ) as Turnout; + refTurnoutAndPos.push({ turnout: refTurout, pos: ref.position }); + }); + const ref = refTurnoutAndPos.map( + (ref) => `${ref.turnout.datas.code}+${turoutPos[ref.pos]}` + ); + return Array.from(new Set(ref)); +}); diff --git a/src/drawApp/graphics/AxleCountingSectionInteraction.ts b/src/drawApp/graphics/AxleCountingSectionInteraction.ts index 72d3770..4372843 100644 --- a/src/drawApp/graphics/AxleCountingSectionInteraction.ts +++ b/src/drawApp/graphics/AxleCountingSectionInteraction.ts @@ -3,6 +3,7 @@ import { GraphicDataBase } from './GraphicDataBase'; import { IAxleCountingSectionData, AxleCountingSection, + ITurnoutPosRefData, } from 'src/graphics/axleCountingSection/AxleCountingSection'; import { graphicData } from 'src/protos/stationLayoutGraphics'; import { IPointData } from 'pixi.js'; @@ -51,6 +52,12 @@ export class AxleCountingSectionData set pbRef(ref: graphicData.RelatedRef) { this.data.pbRef = ref; } + get turnoutPosRef(): ITurnoutPosRefData[] { + return this.data.turnoutPos; + } + set turnoutPosRef(points: ITurnoutPosRefData[]) { + this.data.turnoutPos = points.map((p) => new graphicData.TurnoutPosRef(p)); + } clone(): AxleCountingSectionData { return new AxleCountingSectionData(this.data.cloneMessage()); } diff --git a/src/graphics/axleCountingSection/AxleCountingSection.ts b/src/graphics/axleCountingSection/AxleCountingSection.ts index 3c445b8..b5b7e97 100644 --- a/src/graphics/axleCountingSection/AxleCountingSection.ts +++ b/src/graphics/axleCountingSection/AxleCountingSection.ts @@ -9,15 +9,24 @@ import { import { IRelatedRefData, protoPort2Data } from '../CommonGraphics'; import { SectionPort } from '../section/Section'; +export interface ITurnoutPosRefData { + get id(): string; //道岔的ID + set id(v: string); + get position(): number; //道岔的正反为,0是正位,1是反位 + set position(v: number); +} + export interface IAxleCountingSectionData extends GraphicData { get code(): string; // 编号 set code(v: string); get points(): IPointData[]; // 线坐标点 set points(points: IPointData[]); - get paRef(): IRelatedRefData | undefined; + get paRef(): IRelatedRefData | undefined; //区段A端关联的设备 set paRef(ref: IRelatedRefData | undefined); - get pbRef(): IRelatedRefData | undefined; + get pbRef(): IRelatedRefData | undefined; //区段B端关联的设备 set pbRef(ref: IRelatedRefData | undefined); + get turnoutPosRef(): ITurnoutPosRefData[]; //关联道岔的正反位 + set turnoutPosRef(ref: ITurnoutPosRefData[]); clone(): IAxleCountingSectionData; copyFrom(data: IAxleCountingSectionData): void; eq(other: IAxleCountingSectionData): boolean; diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index 4246bf5..c6a8e56 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -13,6 +13,7 @@ import { AxleCountingSection, AxleCountingSectionTemplate, AxleCountingSectionConsts, + ITurnoutPosRefData, } from './AxleCountingSection'; import { AxleCounting } from '../axleCounting/AxleCounting'; import { Turnout } from '../turnout/Turnout'; @@ -74,12 +75,11 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< 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; + draw( + graphics: AxleCounting[], + commonElement: JlGraphic[], + turoutPos?: number + ) { const axleCountingSection = new AxleCountingSection(); axleCountingSection.loadData(this.graphicTemplate.datas); axleCountingSection.datas.points = [ @@ -89,24 +89,42 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< axleCountingSection.id = GraphicIdGenerator.next(); const paRef = createRelatedRefProto(graphics[0].type, graphics[0].id); const pbRef = createRelatedRefProto(graphics[1].type, graphics[1].id); + const turnoutPosData: ITurnoutPosRefData[] = []; + if (commonElement[0].type == 'Turnout') { + commonElement.forEach((Turnout) => { + if (commonElement.length > 1) { + turnoutPosData.push({ + id: Turnout.id, + position: 0, + }); + } else { + if (turoutPos == 0) { + turnoutPosData.push({ + id: Turnout.id, + position: 0, + }); + } else { + turnoutPosData.push({ + id: Turnout.id, + position: 1, + }); + } + } + }); + } axleCountingSection.datas.paRef = paRef; axleCountingSection.datas.pbRef = pbRef; + axleCountingSection.datas.turnoutPosRef = turnoutPosData; this.storeGraphic(axleCountingSection); axleCountingSection.loadRelations(); } oneGenerates() { - const map = new Map(); const axleCountingSections = this.app.queryStore.queryByType( AxleCountingSection.Type ); - axleCountingSections.forEach((axleCountingSection) => { - map.set( - `${axleCountingSection.datas.paRef?.id}+${axleCountingSection.datas.pbRef?.id}`, - 1 - ); - }); + this.app.deleteGraphics(...axleCountingSections); const axleCountings = this.app.queryStore.queryByType( AxleCounting.Type ); @@ -124,6 +142,8 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< if (commonElementId) { const commonElement = this.app.queryStore.queryById(commonElementId); let draw = true; + let turoutPos = 0; + //道岔BC端处的计轴不构成计轴区段 if (commonElement.type == 'Turnout') { let targetPort, port; axleCounting.datas.axleCountingRef.forEach((ref) => { @@ -142,9 +162,16 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< ) { draw = false; } + if (targetPort == 2 || port == 2) { + turoutPos = 1; + } } if (draw) { - this.draw([axleCounting, axleCountings[i]], map); + this.draw( + [axleCounting, axleCountings[i]], + [commonElement], + turoutPos + ); } } if (hasSamePosition(axleCounting, axleCountings[i])) { @@ -152,7 +179,11 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< } } }); - const fourAxleCounting: AxleCounting[] = []; + //补4个道岔处的BB连接处的计轴区段 + const fourAxleCounting: { + axleCounting: AxleCounting; + refTurout: Turnout; + }[] = []; hasfourTurnout.forEach((axleCountings) => { axleCountings.forEach((axleCounting) => { //计轴关联的道岔 @@ -176,7 +207,10 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< refAxleCounting.id !== axleCountings[0].id && refAxleCounting.id !== axleCountings[1].id ) { - fourAxleCounting.push(refAxleCounting); + fourAxleCounting.push({ + axleCounting: refAxleCounting, + refTurout: refTurnout, + }); } }); }); @@ -185,16 +219,38 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< for (let x = 0; x < fourAxleCounting.length; x += 4) { const AxleCountings = fourAxleCounting.slice(x, x + 4); for (let y = 0; y < 4; y++) { - if (fourAxleCounting[x].id == AxleCountings[y].id) continue; - if (fourAxleCounting[x].y == AxleCountings[y].y) { - this.draw([fourAxleCounting[x], AxleCountings[y]], map); + if ( + fourAxleCounting[x].axleCounting.id == + AxleCountings[y].axleCounting.id + ) + continue; + if ( + fourAxleCounting[x].axleCounting.y == AxleCountings[y].axleCounting.y + ) { + this.draw( + [fourAxleCounting[x].axleCounting, AxleCountings[y].axleCounting], + [fourAxleCounting[x].refTurout, AxleCountings[y].refTurout] + ); break; } } for (let y = 0; y < 4; y++) { - if (fourAxleCounting[x + 1].id == AxleCountings[y].id) continue; - if (fourAxleCounting[x + 1].y == AxleCountings[y].y) { - this.draw([fourAxleCounting[x + 1], AxleCountings[y]], map); + if ( + fourAxleCounting[x + 1].axleCounting.id == + AxleCountings[y].axleCounting.id + ) + continue; + if ( + fourAxleCounting[x + 1].axleCounting.y == + AxleCountings[y].axleCounting.y + ) { + this.draw( + [ + fourAxleCounting[x + 1].axleCounting, + AxleCountings[y].axleCounting, + ], + [fourAxleCounting[x + 1].refTurout, AxleCountings[y].refTurout] + ); break; } } diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index a73b14d..d8fedea 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -3359,6 +3359,96 @@ export namespace graphicData { C = 2 } } + export class TurnoutPosRef extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + id?: string; + position?: number; + }) { + 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 ("position" in data && data.position != undefined) { + this.position = data.position; + } + } + } + get id() { + return pb_1.Message.getFieldWithDefault(this, 1, "") as string; + } + set id(value: string) { + pb_1.Message.setField(this, 1, value); + } + get position() { + return pb_1.Message.getFieldWithDefault(this, 2, 0) as number; + } + set position(value: number) { + pb_1.Message.setField(this, 2, value); + } + static fromObject(data: { + id?: string; + position?: number; + }): TurnoutPosRef { + const message = new TurnoutPosRef({}); + if (data.id != null) { + message.id = data.id; + } + if (data.position != null) { + message.position = data.position; + } + return message; + } + toObject() { + const data: { + id?: string; + position?: number; + } = {}; + if (this.id != null) { + data.id = this.id; + } + if (this.position != null) { + data.position = this.position; + } + 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.position != 0) + writer.writeInt32(2, this.position); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): TurnoutPosRef { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new TurnoutPosRef(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + message.id = reader.readString(); + break; + case 2: + message.position = reader.readInt32(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): TurnoutPosRef { + return TurnoutPosRef.deserialize(bytes); + } + } export class Separator extends pb_1.Message { #one_of_decls: number[][] = []; constructor(data?: any[] | { @@ -3622,9 +3712,10 @@ export namespace graphicData { points?: Point[]; paRef?: RelatedRef; pbRef?: RelatedRef; + turnoutPos?: TurnoutPosRef[]; }) { super(); - pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 6], this.#one_of_decls); if (!Array.isArray(data) && typeof data == "object") { if ("common" in data && data.common != undefined) { this.common = data.common; @@ -3641,6 +3732,9 @@ export namespace graphicData { if ("pbRef" in data && data.pbRef != undefined) { this.pbRef = data.pbRef; } + if ("turnoutPos" in data && data.turnoutPos != undefined) { + this.turnoutPos = data.turnoutPos; + } } } get common() { @@ -3682,12 +3776,19 @@ export namespace graphicData { get has_pbRef() { return pb_1.Message.getField(this, 5) != null; } + get turnoutPos() { + return pb_1.Message.getRepeatedWrapperField(this, TurnoutPosRef, 6) as TurnoutPosRef[]; + } + set turnoutPos(value: TurnoutPosRef[]) { + pb_1.Message.setRepeatedWrapperField(this, 6, value); + } static fromObject(data: { common?: ReturnType; code?: string; points?: ReturnType[]; paRef?: ReturnType; pbRef?: ReturnType; + turnoutPos?: ReturnType[]; }): AxleCountingSection { const message = new AxleCountingSection({}); if (data.common != null) { @@ -3705,6 +3806,9 @@ export namespace graphicData { if (data.pbRef != null) { message.pbRef = RelatedRef.fromObject(data.pbRef); } + if (data.turnoutPos != null) { + message.turnoutPos = data.turnoutPos.map(item => TurnoutPosRef.fromObject(item)); + } return message; } toObject() { @@ -3714,6 +3818,7 @@ export namespace graphicData { points?: ReturnType[]; paRef?: ReturnType; pbRef?: ReturnType; + turnoutPos?: ReturnType[]; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -3730,6 +3835,9 @@ export namespace graphicData { if (this.pbRef != null) { data.pbRef = this.pbRef.toObject(); } + if (this.turnoutPos != null) { + data.turnoutPos = this.turnoutPos.map((item: TurnoutPosRef) => item.toObject()); + } return data; } serialize(): Uint8Array; @@ -3746,6 +3854,8 @@ export namespace graphicData { writer.writeMessage(4, this.paRef, () => this.paRef.serialize(writer)); if (this.has_pbRef) writer.writeMessage(5, this.pbRef, () => this.pbRef.serialize(writer)); + if (this.turnoutPos.length) + writer.writeRepeatedMessage(6, this.turnoutPos, (item: TurnoutPosRef) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -3770,6 +3880,9 @@ export namespace graphicData { case 5: reader.readMessage(message.pbRef, () => message.pbRef = RelatedRef.deserialize(reader)); break; + case 6: + reader.readMessage(message.turnoutPos, () => pb_1.Message.addToRepeatedWrapperField(message, 6, TurnoutPosRef.deserialize(reader), TurnoutPosRef)); + break; default: reader.skipField(); } } From 1c11f4eb0de9be98a7b0e37e4d716c7a19eeb577 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Tue, 11 Jul 2023 16:18:02 +0800 Subject: [PATCH 16/24] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=92=8C=E8=AE=A1?= =?UTF-8?q?=E8=BD=B4=E7=9A=84=E7=B4=A2=E5=BC=95=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../properties/AxleCountingProperty.vue | 9 ++++ .../AxleCountingSectionProperty.vue | 9 ++++ .../graphics/AxleCountingInteraction.ts | 6 +++ .../AxleCountingSectionInteraction.ts | 6 +++ src/graphics/axleCounting/AxleCounting.ts | 2 + .../AxleCountingSection.ts | 2 + src/protos/stationLayoutGraphics.ts | 46 +++++++++++++++++++ 7 files changed, 80 insertions(+) diff --git a/src/components/draw-app/properties/AxleCountingProperty.vue b/src/components/draw-app/properties/AxleCountingProperty.vue index c503ea4..22244b8 100644 --- a/src/components/draw-app/properties/AxleCountingProperty.vue +++ b/src/components/draw-app/properties/AxleCountingProperty.vue @@ -6,6 +6,15 @@ v-model="axleCountingModel.id" label="id" hint="" + /> + + new graphicData.TurnoutPosRef(p)); } + get indexNumber(): number { + return this.data.indexNumber; + } + set indexNumber(v: number) { + this.data.indexNumber = v; + } clone(): AxleCountingSectionData { return new AxleCountingSectionData(this.data.cloneMessage()); } diff --git a/src/graphics/axleCounting/AxleCounting.ts b/src/graphics/axleCounting/AxleCounting.ts index 5538fb9..1334812 100644 --- a/src/graphics/axleCounting/AxleCounting.ts +++ b/src/graphics/axleCounting/AxleCounting.ts @@ -16,6 +16,8 @@ export interface IAxleCountingData extends GraphicData { set kilometerSystem(v: KilometerSystem); get axleCountingRef(): IRelatedRefData[]; //关联的设备 set axleCountingRef(ref: IRelatedRefData[]); + get indexNumber(): number; // 索引编号 + set indexNumber(v: number); clone(): IAxleCountingData; copyFrom(data: IAxleCountingData): void; eq(other: IAxleCountingData): boolean; diff --git a/src/graphics/axleCountingSection/AxleCountingSection.ts b/src/graphics/axleCountingSection/AxleCountingSection.ts index b5b7e97..c2e36a0 100644 --- a/src/graphics/axleCountingSection/AxleCountingSection.ts +++ b/src/graphics/axleCountingSection/AxleCountingSection.ts @@ -27,6 +27,8 @@ export interface IAxleCountingSectionData extends GraphicData { set pbRef(ref: IRelatedRefData | undefined); get turnoutPosRef(): ITurnoutPosRefData[]; //关联道岔的正反位 set turnoutPosRef(ref: ITurnoutPosRefData[]); + get indexNumber(): number; // 索引编号 + set indexNumber(v: number); clone(): IAxleCountingSectionData; copyFrom(data: IAxleCountingSectionData): void; eq(other: IAxleCountingSectionData): boolean; diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index d8fedea..3956e27 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -2080,6 +2080,7 @@ export namespace graphicData { code?: string; kilometerSystem?: KilometerSystem; axleCountingRef?: RelatedRef[]; + indexNumber?: number; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4], this.#one_of_decls); @@ -2096,6 +2097,9 @@ export namespace graphicData { if ("axleCountingRef" in data && data.axleCountingRef != undefined) { this.axleCountingRef = data.axleCountingRef; } + if ("indexNumber" in data && data.indexNumber != undefined) { + this.indexNumber = data.indexNumber; + } } } get common() { @@ -2128,11 +2132,18 @@ export namespace graphicData { set axleCountingRef(value: RelatedRef[]) { pb_1.Message.setRepeatedWrapperField(this, 4, value); } + get indexNumber() { + return pb_1.Message.getFieldWithDefault(this, 5, 0) as number; + } + set indexNumber(value: number) { + pb_1.Message.setField(this, 5, value); + } static fromObject(data: { common?: ReturnType; code?: string; kilometerSystem?: ReturnType; axleCountingRef?: ReturnType[]; + indexNumber?: number; }): AxleCounting { const message = new AxleCounting({}); if (data.common != null) { @@ -2147,6 +2158,9 @@ export namespace graphicData { if (data.axleCountingRef != null) { message.axleCountingRef = data.axleCountingRef.map(item => RelatedRef.fromObject(item)); } + if (data.indexNumber != null) { + message.indexNumber = data.indexNumber; + } return message; } toObject() { @@ -2155,6 +2169,7 @@ export namespace graphicData { code?: string; kilometerSystem?: ReturnType; axleCountingRef?: ReturnType[]; + indexNumber?: number; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -2168,6 +2183,9 @@ export namespace graphicData { if (this.axleCountingRef != null) { data.axleCountingRef = this.axleCountingRef.map((item: RelatedRef) => item.toObject()); } + if (this.indexNumber != null) { + data.indexNumber = this.indexNumber; + } return data; } serialize(): Uint8Array; @@ -2182,6 +2200,8 @@ export namespace graphicData { writer.writeMessage(3, this.kilometerSystem, () => this.kilometerSystem.serialize(writer)); if (this.axleCountingRef.length) writer.writeRepeatedMessage(4, this.axleCountingRef, (item: RelatedRef) => item.serialize(writer)); + if (this.indexNumber != 0) + writer.writeInt32(5, this.indexNumber); if (!w) return writer.getResultBuffer(); } @@ -2203,6 +2223,9 @@ export namespace graphicData { case 4: reader.readMessage(message.axleCountingRef, () => pb_1.Message.addToRepeatedWrapperField(message, 4, RelatedRef.deserialize(reader), RelatedRef)); break; + case 5: + message.indexNumber = reader.readInt32(); + break; default: reader.skipField(); } } @@ -3713,6 +3736,7 @@ export namespace graphicData { paRef?: RelatedRef; pbRef?: RelatedRef; turnoutPos?: TurnoutPosRef[]; + indexNumber?: number; }) { super(); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3, 6], this.#one_of_decls); @@ -3735,6 +3759,9 @@ export namespace graphicData { if ("turnoutPos" in data && data.turnoutPos != undefined) { this.turnoutPos = data.turnoutPos; } + if ("indexNumber" in data && data.indexNumber != undefined) { + this.indexNumber = data.indexNumber; + } } } get common() { @@ -3782,6 +3809,12 @@ export namespace graphicData { set turnoutPos(value: TurnoutPosRef[]) { pb_1.Message.setRepeatedWrapperField(this, 6, value); } + get indexNumber() { + return pb_1.Message.getFieldWithDefault(this, 7, 0) as number; + } + set indexNumber(value: number) { + pb_1.Message.setField(this, 7, value); + } static fromObject(data: { common?: ReturnType; code?: string; @@ -3789,6 +3822,7 @@ export namespace graphicData { paRef?: ReturnType; pbRef?: ReturnType; turnoutPos?: ReturnType[]; + indexNumber?: number; }): AxleCountingSection { const message = new AxleCountingSection({}); if (data.common != null) { @@ -3809,6 +3843,9 @@ export namespace graphicData { if (data.turnoutPos != null) { message.turnoutPos = data.turnoutPos.map(item => TurnoutPosRef.fromObject(item)); } + if (data.indexNumber != null) { + message.indexNumber = data.indexNumber; + } return message; } toObject() { @@ -3819,6 +3856,7 @@ export namespace graphicData { paRef?: ReturnType; pbRef?: ReturnType; turnoutPos?: ReturnType[]; + indexNumber?: number; } = {}; if (this.common != null) { data.common = this.common.toObject(); @@ -3838,6 +3876,9 @@ export namespace graphicData { if (this.turnoutPos != null) { data.turnoutPos = this.turnoutPos.map((item: TurnoutPosRef) => item.toObject()); } + if (this.indexNumber != null) { + data.indexNumber = this.indexNumber; + } return data; } serialize(): Uint8Array; @@ -3856,6 +3897,8 @@ export namespace graphicData { writer.writeMessage(5, this.pbRef, () => this.pbRef.serialize(writer)); if (this.turnoutPos.length) writer.writeRepeatedMessage(6, this.turnoutPos, (item: TurnoutPosRef) => item.serialize(writer)); + if (this.indexNumber != 0) + writer.writeInt32(7, this.indexNumber); if (!w) return writer.getResultBuffer(); } @@ -3883,6 +3926,9 @@ export namespace graphicData { case 6: reader.readMessage(message.turnoutPos, () => pb_1.Message.addToRepeatedWrapperField(message, 6, TurnoutPosRef.deserialize(reader), TurnoutPosRef)); break; + case 7: + message.indexNumber = reader.readInt32(); + break; default: reader.skipField(); } } From c23fdb4cbfe5dcd296db183566c54e5afed2f23e Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Tue, 11 Jul 2023 16:44:04 +0800 Subject: [PATCH 17/24] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/draw-app/DrawProperties.vue | 6 + .../properties/LogicSectionProperty.vue | 98 +++++++ .../graphics/LogicSectionInteraction.ts | 22 +- src/graphics/logicSection/LogicSection.ts | 34 +-- .../logicSection/LogicSectionDrawAssistant.ts | 173 +++--------- src/protos/device_state.ts | 249 ++++++++++++++++++ src/protos/stationLayoutGraphics.ts | 180 ++++++++++++- 7 files changed, 577 insertions(+), 185 deletions(-) create mode 100644 src/components/draw-app/properties/LogicSectionProperty.vue diff --git a/src/components/draw-app/DrawProperties.vue b/src/components/draw-app/DrawProperties.vue index 788d6ee..17fb7bb 100644 --- a/src/components/draw-app/DrawProperties.vue +++ b/src/components/draw-app/DrawProperties.vue @@ -77,6 +77,10 @@ drawStore.selectedGraphicType === AxleCountingSection.Type " > + + @@ -104,6 +108,7 @@ import StationProperty from './properties/StationProperty.vue'; import TrainWindowProperty from './properties/TrainWindowProperty.vue'; import AxleCountingProperty from './properties/AxleCountingProperty.vue'; import AxleCountingSectionProperty from './properties/AxleCountingSectionProperty.vue'; +import LogicSectionProperty from './properties/LogicSectionProperty.vue'; import SignalProperty from './properties/SignalProperty.vue'; import TurnoutProperty from './properties/TurnoutProperty.vue'; import SectionProperty from './properties/SectionProperty.vue'; @@ -121,6 +126,7 @@ import { Section } from 'src/graphics/section/Section'; import { TrainWindow } from 'src/graphics/trainWindow/TrainWindow'; import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting'; import { AxleCountingSection } from 'src/graphics/axleCountingSection/AxleCountingSection'; +import { LogicSection } from 'src/graphics/logicSection/LogicSection'; import { Separator } from 'src/graphics/separator/Separator'; import { SectionLink } from 'src/graphics/sectionLink/SectionLink'; diff --git a/src/components/draw-app/properties/LogicSectionProperty.vue b/src/components/draw-app/properties/LogicSectionProperty.vue new file mode 100644 index 0000000..93c9545 --- /dev/null +++ b/src/components/draw-app/properties/LogicSectionProperty.vue @@ -0,0 +1,98 @@ + + + diff --git a/src/drawApp/graphics/LogicSectionInteraction.ts b/src/drawApp/graphics/LogicSectionInteraction.ts index a800c88..a8bef9f 100644 --- a/src/drawApp/graphics/LogicSectionInteraction.ts +++ b/src/drawApp/graphics/LogicSectionInteraction.ts @@ -11,7 +11,7 @@ export class LogicSectionData extends GraphicDataBase implements ILogicSectionData { - constructor(data?: graphicData.AxleCountingSection) { + constructor(data?: graphicData.LogicSection) { let logicSection; if (!data) { logicSection = new graphicData.AxleCountingSection({ @@ -22,8 +22,8 @@ export class LogicSectionData } super(logicSection); } - public get data(): graphicData.AxleCountingSection { - return this.getData(); + public get data(): graphicData.LogicSection { + return this.getData(); } get code(): string { return this.data.code; @@ -39,17 +39,17 @@ export class LogicSectionData (p) => new graphicData.Point({ x: p.x, y: p.y }) ); } - get paRef(): graphicData.RelatedRef { - return this.data.paRef; + get axleSectionId(): string { + return this.data.axleSectionId; } - set paRef(ref: graphicData.RelatedRef) { - this.data.paRef = ref; + set axleSectionId(v: string) { + this.data.axleSectionId = v; } - get pbRef(): graphicData.RelatedRef { - return this.data.pbRef; + get indexNumber(): number { + return this.data.indexNumber; } - set pbRef(ref: graphicData.RelatedRef) { - this.data.pbRef = ref; + set indexNumber(v: number) { + this.data.indexNumber = v; } clone(): LogicSectionData { return new LogicSectionData(this.data.cloneMessage()); diff --git a/src/graphics/logicSection/LogicSection.ts b/src/graphics/logicSection/LogicSection.ts index 3e6ec3d..2001de4 100644 --- a/src/graphics/logicSection/LogicSection.ts +++ b/src/graphics/logicSection/LogicSection.ts @@ -6,18 +6,16 @@ import { JlGraphicTemplate, VectorText, } from 'src/jl-graphic'; -import { IRelatedRefData, protoPort2Data } from '../CommonGraphics'; -import { SectionPort } from '../section/Section'; export interface ILogicSectionData extends GraphicData { get code(): string; // 编号 set code(v: string); get points(): IPointData[]; // 线坐标点 set points(points: IPointData[]); - get paRef(): IRelatedRefData | undefined; - set paRef(ref: IRelatedRefData | undefined); - get pbRef(): IRelatedRefData | undefined; - set pbRef(ref: IRelatedRefData | undefined); + get axleSectionId(): string; // 计轴区段ID + set axleSectionId(v: string); + get indexNumber(): number; // 索引编号 + set indexNumber(v: number); clone(): ILogicSectionData; copyFrom(data: ILogicSectionData): void; eq(other: ILogicSectionData): boolean; @@ -87,23 +85,13 @@ export class LogicSection extends JlGraphic { this.updateData(old); } loadRelations() { - if (this.datas?.paRef?.id) { - this.relationManage.addRelation( - new GraphicRelationParam(this, SectionPort.A), - new GraphicRelationParam( - this.queryStore.queryById(this.datas.paRef.id), - protoPort2Data(this.datas.paRef.devicePort) - ) - ); - } - if (this.datas?.pbRef?.id) { - this.relationManage.addRelation( - new GraphicRelationParam(this, SectionPort.B), - new GraphicRelationParam( - this.queryStore.queryById(this.datas.pbRef.id), - protoPort2Data(this.datas.pbRef.devicePort) - ) - ); + if (this.datas?.axleSectionId) { + const axleSection = this.queryStore.queryById(this.datas.axleSectionId); + axleSection && + this.relationManage.addRelation( + new GraphicRelationParam(this), + new GraphicRelationParam(axleSection) + ); } } } diff --git a/src/graphics/logicSection/LogicSectionDrawAssistant.ts b/src/graphics/logicSection/LogicSectionDrawAssistant.ts index d04d76f..489d767 100644 --- a/src/graphics/logicSection/LogicSectionDrawAssistant.ts +++ b/src/graphics/logicSection/LogicSectionDrawAssistant.ts @@ -1,7 +1,5 @@ -import { FederatedPointerEvent, IHitArea, IPointData, Point } from 'pixi.js'; +import { FederatedPointerEvent, IHitArea, Point } from 'pixi.js'; import { - AbsorbableLine, - AbsorbablePosition, GraphicDrawAssistant, GraphicIdGenerator, GraphicInteractionPlugin, @@ -16,28 +14,9 @@ import { LogicSectionTemplate, LogicSectionConsts, } from './LogicSection'; -import { AxleCounting } from '../axleCounting/AxleCounting'; import { Turnout } from '../turnout/Turnout'; -import { createRelatedRefProto } from '../CommonGraphics'; - -function hasCommonElements(arr1: string[], arr2: string[]) { - for (let i = 0; i < arr1.length; i++) { - if (arr2.includes(arr1[i])) { - return arr1[i]; - } - } - return false; -} - -function hasSamePosition(point1: IPointData, point2: IPointData): boolean { - if ( - Math.abs(point1.x - point2.x) < 20 && - Math.abs(point1.y - point2.y) < 20 - ) { - return true; - } - return false; -} +import { LogicSectionData } from 'src/drawApp/graphics/LogicSectionInteraction'; +import { AxleCountingSection } from '../axleCountingSection/AxleCountingSection'; export interface ILogicSectionDrawOptions { newData: () => ILogicSectionData; @@ -76,20 +55,10 @@ export class LogicSectionDraw extends GraphicDrawAssistant< data.transform = this.container.saveTransform(); return true; } - draw(graphics: JlGraphic[], map: Map) { - if ( - map.has(`${graphics[0].id}+${graphics[1].id}`) || - map.has(`${graphics[1].id}+${graphics[0].id}`) - ) - return; + draw(data: ILogicSectionData) { const logicSection = new LogicSection(); - logicSection.loadData(this.graphicTemplate.datas); - logicSection.datas.points = [graphics[0].position, graphics[1].position]; + logicSection.loadData(data); logicSection.id = GraphicIdGenerator.next(); - const paRef = createRelatedRefProto(graphics[0].type, graphics[0].id); - const pbRef = createRelatedRefProto(graphics[1].type, graphics[1].id); - logicSection.datas.paRef = paRef; - logicSection.datas.pbRef = pbRef; this.storeGraphic(logicSection); logicSection.loadRelations(); } @@ -99,118 +68,38 @@ export class LogicSectionDraw extends GraphicDrawAssistant< const logicSections = this.app.queryStore.queryByType( LogicSection.Type ); + // this.app.deleteGraphics(...logicSections); + // return; logicSections.forEach((logicSection) => { - map.set( - `${logicSection.datas.paRef?.id}+${logicSection.datas.pbRef?.id}`, - 1 - ); + map.set(`${logicSection.datas.axleSectionId}`, 1); }); - const axleCountings = this.app.queryStore.queryByType( - AxleCounting.Type - ); - const hasfourTurnout: AxleCounting[][] = []; - axleCountings.forEach((axleCounting) => { - const refDeviceTarget = axleCounting.datas.axleCountingRef.map( - (ref) => ref.id + const axleCountingSections = + this.app.queryStore.queryByType( + AxleCountingSection.Type ); - for (let i = 0; i < axleCountings.length - 1; i++) { - if (axleCountings[i].id == axleCounting.id) return; - const refDevice = axleCountings[i].datas.axleCountingRef.map( - (ref) => ref.id - ); - const commonElementId = hasCommonElements(refDeviceTarget, refDevice); - if (commonElementId) { - const commonElement = this.app.queryStore.queryById(commonElementId); - let draw = true; - if (commonElement.type == 'Turnout') { - let targetPort, port; - axleCounting.datas.axleCountingRef.forEach((ref) => { - if (ref.id == commonElementId) { - targetPort = ref.devicePort; - } - }); - axleCountings[i].datas.axleCountingRef.forEach((ref) => { - if (ref.id == commonElementId) { - port = ref.devicePort; - } - }); - if ( - (targetPort == 1 && port == 2) || - (targetPort == 2 && port == 1) - ) { - draw = false; - } - } - if (draw) { - this.draw([axleCounting, axleCountings[i]], map); - } - } - if (hasSamePosition(axleCounting, axleCountings[i])) { - hasfourTurnout.push([axleCounting, axleCountings[i]]); - } + axleCountingSections.forEach((axleCountingSection) => { + if (map.has(`${axleCountingSection.id}`)) { + return; } - }); - const fourAxleCounting: AxleCounting[] = []; - hasfourTurnout.forEach((axleCountings) => { - axleCountings.forEach((axleCounting) => { - //计轴关联的道岔 - const axleCountingRelations = - axleCounting.relationManage.getRelationsOfGraphicAndOtherType( - axleCounting, - Turnout.Type - ); - axleCountingRelations.forEach((relation) => { - const refTurnout = relation.getOtherGraphic(axleCounting); - //道岔关联的计轴 - const turnoutRelations = - refTurnout.relationManage.getRelationsOfGraphicAndOtherType( - refTurnout, - AxleCounting.Type - ); - turnoutRelations.forEach((relation) => { - const refAxleCounting = - relation.getOtherGraphic(refTurnout); - if ( - refAxleCounting.id !== axleCountings[0].id && - refAxleCounting.id !== axleCountings[1].id - ) { - fourAxleCounting.push(refAxleCounting); - } - }); + const turnoutPosRef = axleCountingSection.datas.turnoutPosRef; + if (turnoutPosRef.length > 0) { + turnoutPosRef.forEach((turnout) => { + if (turnout.position == 1) { + const t = this.app.queryStore.queryById(turnout.id) as Turnout; + const data = new LogicSectionData(); + data.points = [ + t.position, + ...t.localToCanvasPoints(...t.datas.pointC), + ]; + data.axleSectionId = axleCountingSection.id; + this.draw(data); + } }); - }); - }); - for (let x = 0; x < fourAxleCounting.length; x += 4) { - const AxleCountings = fourAxleCounting.slice(x, x + 4); - for (let y = 0; y < 4; y++) { - if (fourAxleCounting[x].id == AxleCountings[y].id) continue; - if (fourAxleCounting[x].y == AxleCountings[y].y) { - this.draw([fourAxleCounting[x], AxleCountings[y]], map); - break; - } } - for (let y = 0; y < 4; y++) { - if (fourAxleCounting[x + 1].id == AxleCountings[y].id) continue; - if (fourAxleCounting[x + 1].y == AxleCountings[y].y) { - this.draw([fourAxleCounting[x + 1], AxleCountings[y]], map); - break; - } - } - } - const turnouts = this.app.queryStore.queryByType(Turnout.Type); - turnouts.forEach((turnout) => { - const turnoutRelations = - turnout.relationManage.getRelationsOfGraphicAndOtherType( - turnout, - AxleCounting.Type - ); - turnoutRelations.forEach((ref) => { - const t = ref.getRelationParam(turnout); - const other = ref.getOtherGraphic(turnout) as AxleCounting; - if (t.param == 'C') { - this.draw([turnout, other], map); - } - }); + const data = new LogicSectionData(); + data.points = axleCountingSection.datas.points; + data.axleSectionId = axleCountingSection.id; + this.draw(data); }); } } diff --git a/src/protos/device_state.ts b/src/protos/device_state.ts index fa49ba8..6301baa 100644 --- a/src/protos/device_state.ts +++ b/src/protos/device_state.ts @@ -509,4 +509,253 @@ export namespace state { return TrainState.deserialize(bytes); } } + export class VariationStatus extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + updatedTrain?: TrainState[]; + removedTrainId?: string[]; + updatedSwitch?: SwitchState[]; + updatedSection?: SectionState[]; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 2, 3, 4], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("updatedTrain" in data && data.updatedTrain != undefined) { + this.updatedTrain = data.updatedTrain; + } + if ("removedTrainId" in data && data.removedTrainId != undefined) { + this.removedTrainId = data.removedTrainId; + } + if ("updatedSwitch" in data && data.updatedSwitch != undefined) { + this.updatedSwitch = data.updatedSwitch; + } + if ("updatedSection" in data && data.updatedSection != undefined) { + this.updatedSection = data.updatedSection; + } + } + } + get updatedTrain() { + return pb_1.Message.getRepeatedWrapperField(this, TrainState, 1) as TrainState[]; + } + set updatedTrain(value: TrainState[]) { + pb_1.Message.setRepeatedWrapperField(this, 1, value); + } + get removedTrainId() { + return pb_1.Message.getFieldWithDefault(this, 2, []) as string[]; + } + set removedTrainId(value: string[]) { + pb_1.Message.setField(this, 2, value); + } + get updatedSwitch() { + return pb_1.Message.getRepeatedWrapperField(this, SwitchState, 3) as SwitchState[]; + } + set updatedSwitch(value: SwitchState[]) { + pb_1.Message.setRepeatedWrapperField(this, 3, value); + } + get updatedSection() { + return pb_1.Message.getRepeatedWrapperField(this, SectionState, 4) as SectionState[]; + } + set updatedSection(value: SectionState[]) { + pb_1.Message.setRepeatedWrapperField(this, 4, value); + } + static fromObject(data: { + updatedTrain?: ReturnType[]; + removedTrainId?: string[]; + updatedSwitch?: ReturnType[]; + updatedSection?: ReturnType[]; + }): VariationStatus { + const message = new VariationStatus({}); + if (data.updatedTrain != null) { + message.updatedTrain = data.updatedTrain.map(item => TrainState.fromObject(item)); + } + if (data.removedTrainId != null) { + message.removedTrainId = data.removedTrainId; + } + if (data.updatedSwitch != null) { + message.updatedSwitch = data.updatedSwitch.map(item => SwitchState.fromObject(item)); + } + if (data.updatedSection != null) { + message.updatedSection = data.updatedSection.map(item => SectionState.fromObject(item)); + } + return message; + } + toObject() { + const data: { + updatedTrain?: ReturnType[]; + removedTrainId?: string[]; + updatedSwitch?: ReturnType[]; + updatedSection?: ReturnType[]; + } = {}; + if (this.updatedTrain != null) { + data.updatedTrain = this.updatedTrain.map((item: TrainState) => item.toObject()); + } + if (this.removedTrainId != null) { + data.removedTrainId = this.removedTrainId; + } + if (this.updatedSwitch != null) { + data.updatedSwitch = this.updatedSwitch.map((item: SwitchState) => item.toObject()); + } + if (this.updatedSection != null) { + data.updatedSection = this.updatedSection.map((item: SectionState) => 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.updatedTrain.length) + writer.writeRepeatedMessage(1, this.updatedTrain, (item: TrainState) => item.serialize(writer)); + if (this.removedTrainId.length) + writer.writeRepeatedString(2, this.removedTrainId); + if (this.updatedSwitch.length) + writer.writeRepeatedMessage(3, this.updatedSwitch, (item: SwitchState) => item.serialize(writer)); + if (this.updatedSection.length) + writer.writeRepeatedMessage(4, this.updatedSection, (item: SectionState) => item.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): VariationStatus { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new VariationStatus(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.updatedTrain, () => pb_1.Message.addToRepeatedWrapperField(message, 1, TrainState.deserialize(reader), TrainState)); + break; + case 2: + pb_1.Message.addToRepeatedField(message, 2, reader.readString()); + break; + case 3: + reader.readMessage(message.updatedSwitch, () => pb_1.Message.addToRepeatedWrapperField(message, 3, SwitchState.deserialize(reader), SwitchState)); + break; + case 4: + reader.readMessage(message.updatedSection, () => pb_1.Message.addToRepeatedWrapperField(message, 4, SectionState.deserialize(reader), SectionState)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): VariationStatus { + return VariationStatus.deserialize(bytes); + } + } + export class AllDevicesStatus extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + trainState?: TrainState[]; + switchState?: SwitchState[]; + sectionState?: SectionState[]; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1, 2, 3], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("trainState" in data && data.trainState != undefined) { + this.trainState = data.trainState; + } + if ("switchState" in data && data.switchState != undefined) { + this.switchState = data.switchState; + } + if ("sectionState" in data && data.sectionState != undefined) { + this.sectionState = data.sectionState; + } + } + } + get trainState() { + return pb_1.Message.getRepeatedWrapperField(this, TrainState, 1) as TrainState[]; + } + set trainState(value: TrainState[]) { + pb_1.Message.setRepeatedWrapperField(this, 1, value); + } + get switchState() { + return pb_1.Message.getRepeatedWrapperField(this, SwitchState, 2) as SwitchState[]; + } + set switchState(value: SwitchState[]) { + pb_1.Message.setRepeatedWrapperField(this, 2, value); + } + get sectionState() { + return pb_1.Message.getRepeatedWrapperField(this, SectionState, 3) as SectionState[]; + } + set sectionState(value: SectionState[]) { + pb_1.Message.setRepeatedWrapperField(this, 3, value); + } + static fromObject(data: { + trainState?: ReturnType[]; + switchState?: ReturnType[]; + sectionState?: ReturnType[]; + }): AllDevicesStatus { + const message = new AllDevicesStatus({}); + if (data.trainState != null) { + message.trainState = data.trainState.map(item => TrainState.fromObject(item)); + } + if (data.switchState != null) { + message.switchState = data.switchState.map(item => SwitchState.fromObject(item)); + } + if (data.sectionState != null) { + message.sectionState = data.sectionState.map(item => SectionState.fromObject(item)); + } + return message; + } + toObject() { + const data: { + trainState?: ReturnType[]; + switchState?: ReturnType[]; + sectionState?: ReturnType[]; + } = {}; + if (this.trainState != null) { + data.trainState = this.trainState.map((item: TrainState) => item.toObject()); + } + if (this.switchState != null) { + data.switchState = this.switchState.map((item: SwitchState) => item.toObject()); + } + if (this.sectionState != null) { + data.sectionState = this.sectionState.map((item: SectionState) => 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.trainState.length) + writer.writeRepeatedMessage(1, this.trainState, (item: TrainState) => item.serialize(writer)); + if (this.switchState.length) + writer.writeRepeatedMessage(2, this.switchState, (item: SwitchState) => item.serialize(writer)); + if (this.sectionState.length) + writer.writeRepeatedMessage(3, this.sectionState, (item: SectionState) => item.serialize(writer)); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): AllDevicesStatus { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new AllDevicesStatus(); + while (reader.nextField()) { + if (reader.isEndGroup()) + break; + switch (reader.getFieldNumber()) { + case 1: + reader.readMessage(message.trainState, () => pb_1.Message.addToRepeatedWrapperField(message, 1, TrainState.deserialize(reader), TrainState)); + break; + case 2: + reader.readMessage(message.switchState, () => pb_1.Message.addToRepeatedWrapperField(message, 2, SwitchState.deserialize(reader), SwitchState)); + break; + case 3: + reader.readMessage(message.sectionState, () => pb_1.Message.addToRepeatedWrapperField(message, 3, SectionState.deserialize(reader), SectionState)); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): AllDevicesStatus { + return AllDevicesStatus.deserialize(bytes); + } + } } diff --git a/src/protos/stationLayoutGraphics.ts b/src/protos/stationLayoutGraphics.ts index 3956e27..38b5dd2 100644 --- a/src/protos/stationLayoutGraphics.ts +++ b/src/protos/stationLayoutGraphics.ts @@ -24,7 +24,7 @@ export namespace graphicData { separators?: Separator[]; sectionLinks?: SectionLink[]; axleCountingSections?: AxleCountingSection[]; - logicSections?: AxleCountingSection[]; + logicSections?: LogicSection[]; }) { 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); @@ -182,9 +182,9 @@ export namespace graphicData { pb_1.Message.setRepeatedWrapperField(this, 16, value); } get logicSections() { - return pb_1.Message.getRepeatedWrapperField(this, AxleCountingSection, 17) as AxleCountingSection[]; + return pb_1.Message.getRepeatedWrapperField(this, LogicSection, 17) as LogicSection[]; } - set logicSections(value: AxleCountingSection[]) { + set logicSections(value: LogicSection[]) { pb_1.Message.setRepeatedWrapperField(this, 17, value); } static fromObject(data: { @@ -204,7 +204,7 @@ export namespace graphicData { separators?: ReturnType[]; sectionLinks?: ReturnType[]; axleCountingSections?: ReturnType[]; - logicSections?: ReturnType[]; + logicSections?: ReturnType[]; }): RtssGraphicStorage { const message = new RtssGraphicStorage({}); if (data.canvas != null) { @@ -256,7 +256,7 @@ export namespace graphicData { message.axleCountingSections = data.axleCountingSections.map(item => AxleCountingSection.fromObject(item)); } if (data.logicSections != null) { - message.logicSections = data.logicSections.map(item => AxleCountingSection.fromObject(item)); + message.logicSections = data.logicSections.map(item => LogicSection.fromObject(item)); } return message; } @@ -278,7 +278,7 @@ export namespace graphicData { separators?: ReturnType[]; sectionLinks?: ReturnType[]; axleCountingSections?: ReturnType[]; - logicSections?: ReturnType[]; + logicSections?: ReturnType[]; } = {}; if (this.canvas != null) { data.canvas = this.canvas.toObject(); @@ -329,7 +329,7 @@ export namespace graphicData { data.axleCountingSections = this.axleCountingSections.map((item: AxleCountingSection) => item.toObject()); } if (this.logicSections != null) { - data.logicSections = this.logicSections.map((item: AxleCountingSection) => item.toObject()); + data.logicSections = this.logicSections.map((item: LogicSection) => item.toObject()); } return data; } @@ -370,7 +370,7 @@ export namespace graphicData { if (this.axleCountingSections.length) writer.writeRepeatedMessage(16, this.axleCountingSections, (item: AxleCountingSection) => item.serialize(writer)); if (this.logicSections.length) - writer.writeRepeatedMessage(17, this.logicSections, (item: AxleCountingSection) => item.serialize(writer)); + writer.writeRepeatedMessage(17, this.logicSections, (item: LogicSection) => item.serialize(writer)); if (!w) return writer.getResultBuffer(); } @@ -429,7 +429,7 @@ export namespace graphicData { reader.readMessage(message.axleCountingSections, () => pb_1.Message.addToRepeatedWrapperField(message, 16, AxleCountingSection.deserialize(reader), AxleCountingSection)); break; case 17: - reader.readMessage(message.logicSections, () => pb_1.Message.addToRepeatedWrapperField(message, 17, AxleCountingSection.deserialize(reader), AxleCountingSection)); + reader.readMessage(message.logicSections, () => pb_1.Message.addToRepeatedWrapperField(message, 17, LogicSection.deserialize(reader), LogicSection)); break; default: reader.skipField(); } @@ -3941,4 +3941,166 @@ export namespace graphicData { return AxleCountingSection.deserialize(bytes); } } + export class LogicSection extends pb_1.Message { + #one_of_decls: number[][] = []; + constructor(data?: any[] | { + common?: CommonInfo; + code?: string; + points?: Point[]; + axleSectionId?: string; + indexNumber?: number; + }) { + super(); + pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [3], this.#one_of_decls); + if (!Array.isArray(data) && typeof data == "object") { + if ("common" in data && data.common != undefined) { + this.common = data.common; + } + if ("code" in data && data.code != undefined) { + this.code = data.code; + } + if ("points" in data && data.points != undefined) { + this.points = data.points; + } + if ("axleSectionId" in data && data.axleSectionId != undefined) { + this.axleSectionId = data.axleSectionId; + } + if ("indexNumber" in data && data.indexNumber != undefined) { + this.indexNumber = data.indexNumber; + } + } + } + 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 axleSectionId() { + return pb_1.Message.getFieldWithDefault(this, 4, "") as string; + } + set axleSectionId(value: string) { + pb_1.Message.setField(this, 4, value); + } + get indexNumber() { + return pb_1.Message.getFieldWithDefault(this, 5, 0) as number; + } + set indexNumber(value: number) { + pb_1.Message.setField(this, 5, value); + } + static fromObject(data: { + common?: ReturnType; + code?: string; + points?: ReturnType[]; + axleSectionId?: string; + indexNumber?: number; + }): LogicSection { + const message = new LogicSection({}); + 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.axleSectionId != null) { + message.axleSectionId = data.axleSectionId; + } + if (data.indexNumber != null) { + message.indexNumber = data.indexNumber; + } + return message; + } + toObject() { + const data: { + common?: ReturnType; + code?: string; + points?: ReturnType[]; + axleSectionId?: string; + indexNumber?: number; + } = {}; + 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.axleSectionId != null) { + data.axleSectionId = this.axleSectionId; + } + if (this.indexNumber != null) { + data.indexNumber = this.indexNumber; + } + 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.axleSectionId.length) + writer.writeString(4, this.axleSectionId); + if (this.indexNumber != 0) + writer.writeInt32(5, this.indexNumber); + if (!w) + return writer.getResultBuffer(); + } + static deserialize(bytes: Uint8Array | pb_1.BinaryReader): LogicSection { + const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new LogicSection(); + 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.axleSectionId = reader.readString(); + break; + case 5: + message.indexNumber = reader.readInt32(); + break; + default: reader.skipField(); + } + } + return message; + } + serializeBinary(): Uint8Array { + return this.serialize(); + } + static deserializeBinary(bytes: Uint8Array): LogicSection { + return LogicSection.deserialize(bytes); + } + } } From d4bc0f6648f3a4781bab95e471564d09fab946f2 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Tue, 11 Jul 2023 17:09:49 +0800 Subject: [PATCH 18/24] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E6=8B=86=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AxleCountingSectionAssistant.ts | 107 +++++++++++++++++- 1 file changed, 102 insertions(+), 5 deletions(-) diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index c6a8e56..c33b63a 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -1,4 +1,11 @@ -import { FederatedPointerEvent, IHitArea, IPointData, Point } from 'pixi.js'; +import { + DisplayObject, + FederatedMouseEvent, + FederatedPointerEvent, + IHitArea, + IPointData, + Point, +} from 'pixi.js'; import { GraphicDrawAssistant, GraphicIdGenerator, @@ -6,6 +13,7 @@ import { JlDrawApp, JlGraphic, linePoint, + splitLineEvenly, } from 'src/jl-graphic'; import { @@ -18,6 +26,13 @@ import { import { AxleCounting } from '../axleCounting/AxleCounting'; import { Turnout } from '../turnout/Turnout'; import { createRelatedRefProto } from '../CommonGraphics'; +import { MenuItemOptions } from 'src/jl-graphic/ui/Menu'; +import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu'; +import { Dialog } from 'quasar'; +import { LogicSection } from '../logicSection/LogicSection'; +import { LogicSectionData } from 'src/drawApp/graphics/LogicSectionInteraction'; +import { graphicData } from 'src/protos/stationLayoutGraphics'; +import SectionSplitDialog from 'src/components/draw-app/dialogs/SectionSplitDialog.vue'; function hasCommonElements(arr1: string[], arr2: string[]) { for (let i = 0; i < arr1.length; i++) { @@ -51,7 +66,7 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< super(app, template, 'sym_o_circle', '不展示'); this.codeGraph = this.graphicTemplate.new(); this.container.addChild(this.codeGraph); - AxleCountingSectionInteraction.init(app); + AxleCountingSectionInteraction.init(app, this); } bind(): void { @@ -274,13 +289,28 @@ class AxleCountingSectionGraphicHitArea implements IHitArea { } } +export const splitSectionConfig: MenuItemOptions = { + name: '拆分计轴区段', +}; +const SectionEditMenu: ContextMenu = ContextMenu.init({ + name: '区段编辑菜单', + groups: [ + { + items: [splitSectionConfig], + }, + ], +}); + export class AxleCountingSectionInteraction extends GraphicInteractionPlugin { static Name = 'AxleCountingSection_transform'; - constructor(app: JlDrawApp) { + drawAssistant: AxleCountingSectionDraw; + constructor(app: JlDrawApp, da: AxleCountingSectionDraw) { super(AxleCountingSectionInteraction.Name, app); + this.drawAssistant = da; + app.registerMenu(SectionEditMenu); } - static init(app: JlDrawApp) { - return new AxleCountingSectionInteraction(app); + static init(app: JlDrawApp, da: AxleCountingSectionDraw) { + return new AxleCountingSectionInteraction(app, da); } filter(...grahpics: JlGraphic[]): AxleCountingSection[] | undefined { return grahpics @@ -299,6 +329,7 @@ export class AxleCountingSectionInteraction extends GraphicInteractionPlugin { + Dialog.create({ + title: '拆分逻辑区段', + message: '请选择生成数量和方向', + component: SectionSplitDialog, + cancel: true, + persistent: true, + }).onOk((data: { num: number; dir: 'ltr' | 'rtl' }) => { + const logicSections = this.app.queryStore.queryByType( + LogicSection.Type + ); + logicSections.forEach((logicSection) => { + if (logicSection.datas.axleSectionId == axleCountingSection.id) { + this.app.deleteGraphics(logicSection); + } + }); + const { num, dir } = data; + const axleCountingSectionData = axleCountingSection.datas; + const points = splitLineEvenly( + axleCountingSection.localToCanvasPoint( + axleCountingSectionData.points[0] + ), + axleCountingSection.localToCanvasPoint( + axleCountingSectionData.points[ + axleCountingSectionData.points.length - 1 + ] + ), + num + ); + // let codeAppend = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.slice(0, num); + if ( + (dir === 'ltr' && + axleCountingSectionData.points[0].x > + axleCountingSectionData.points[ + axleCountingSectionData.points.length - 1 + ].x) || + (dir === 'rtl' && + axleCountingSectionData.points[0].x < + axleCountingSectionData.points[ + axleCountingSectionData.points.length - 1 + ].x) + ) { + // codeAppend = codeAppend.split('').reverse().join(''); + } + points.forEach((ps, i) => { + const data = new LogicSectionData(); + data.id = GraphicIdGenerator.next(); + data.axleSectionId = axleCountingSection.id; + // data.code = `${codeAppend.charAt(i % 26)}`; + data.points = ps.map( + (p) => new graphicData.Point({ x: p.x, y: p.y }) + ); + const g = new LogicSection(); + g.loadData(data); + this.drawAssistant.storeGraphic(g); + }); + }); + }; + SectionEditMenu.open(e.global); } } From dbd01d71a312059f2284b90e5b8190d132f2a636 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Tue, 11 Jul 2023 17:35:11 +0800 Subject: [PATCH 19/24] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../logicSection/LogicSectionDrawAssistant.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/graphics/logicSection/LogicSectionDrawAssistant.ts b/src/graphics/logicSection/LogicSectionDrawAssistant.ts index 489d767..b7b1492 100644 --- a/src/graphics/logicSection/LogicSectionDrawAssistant.ts +++ b/src/graphics/logicSection/LogicSectionDrawAssistant.ts @@ -78,13 +78,11 @@ export class LogicSectionDraw extends GraphicDrawAssistant< AxleCountingSection.Type ); axleCountingSections.forEach((axleCountingSection) => { - if (map.has(`${axleCountingSection.id}`)) { - return; - } const turnoutPosRef = axleCountingSection.datas.turnoutPosRef; if (turnoutPosRef.length > 0) { turnoutPosRef.forEach((turnout) => { - if (turnout.position == 1) { + if (turnout.position == 1 && !map.has(`${turnout.id}`)) { + map.set(`${turnout.id}`, 1); const t = this.app.queryStore.queryById(turnout.id) as Turnout; const data = new LogicSectionData(); data.points = [ @@ -96,10 +94,13 @@ export class LogicSectionDraw extends GraphicDrawAssistant< } }); } - const data = new LogicSectionData(); - data.points = axleCountingSection.datas.points; - data.axleSectionId = axleCountingSection.id; - this.draw(data); + if (!map.has(`${axleCountingSection.id}`)) { + map.set(`${axleCountingSection.id}`, 1); + const data = new LogicSectionData(); + data.points = axleCountingSection.datas.points; + data.axleSectionId = axleCountingSection.id; + this.draw(data); + } }); } } From e73fe0ede652cf2615f1be3b4d3bc5496f50c53e Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Tue, 11 Jul 2023 17:42:04 +0800 Subject: [PATCH 20/24] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E5=A2=9E=E9=87=8F=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AxleCountingSectionAssistant.ts | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts index c33b63a..6d9e64e 100644 --- a/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts +++ b/src/graphics/axleCountingSection/AxleCountingSectionAssistant.ts @@ -93,8 +93,14 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< draw( graphics: AxleCounting[], commonElement: JlGraphic[], + map: Map, turoutPos?: number ) { + if ( + map.has(`${graphics[0].id}+${graphics[1].id}`) || + map.has(`${graphics[1].id}+${graphics[0].id}`) + ) + return; const axleCountingSection = new AxleCountingSection(); axleCountingSection.loadData(this.graphicTemplate.datas); axleCountingSection.datas.points = [ @@ -135,11 +141,17 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< } oneGenerates() { + const map = new Map(); const axleCountingSections = this.app.queryStore.queryByType( AxleCountingSection.Type ); - this.app.deleteGraphics(...axleCountingSections); + axleCountingSections.forEach((axleCountingSection) => { + map.set( + `${axleCountingSection.datas.paRef?.id}+${axleCountingSection.datas.pbRef?.id}`, + 1 + ); + }); const axleCountings = this.app.queryStore.queryByType( AxleCounting.Type ); @@ -185,6 +197,7 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< this.draw( [axleCounting, axleCountings[i]], [commonElement], + map, turoutPos ); } @@ -244,7 +257,8 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< ) { this.draw( [fourAxleCounting[x].axleCounting, AxleCountings[y].axleCounting], - [fourAxleCounting[x].refTurout, AxleCountings[y].refTurout] + [fourAxleCounting[x].refTurout, AxleCountings[y].refTurout], + map ); break; } @@ -264,7 +278,8 @@ export class AxleCountingSectionDraw extends GraphicDrawAssistant< fourAxleCounting[x + 1].axleCounting, AxleCountings[y].axleCounting, ], - [fourAxleCounting[x + 1].refTurout, AxleCountings[y].refTurout] + [fourAxleCounting[x + 1].refTurout, AxleCountings[y].refTurout], + map ); break; } From bc0844523bf71272caf36d4793a815f2d918ac78 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Wed, 12 Jul 2023 10:12:15 +0800 Subject: [PATCH 21/24] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=92=8C=E8=AE=A1?= =?UTF-8?q?=E8=BD=B4=E5=8C=BA=E6=AE=B5=E7=9A=84code=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draw-app/properties/AxleCountingSectionProperty.vue | 4 ++-- src/graphics/axleCounting/AxleCountingDrawAssistant.ts | 2 +- src/graphics/axleCountingSection/AxleCountingSection.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/draw-app/properties/AxleCountingSectionProperty.vue b/src/components/draw-app/properties/AxleCountingSectionProperty.vue index d4bd857..f1657c9 100644 --- a/src/components/draw-app/properties/AxleCountingSectionProperty.vue +++ b/src/components/draw-app/properties/AxleCountingSectionProperty.vue @@ -75,7 +75,7 @@ const drawStore = useDrawStore(); const axleCountingSectionModel = reactive(new AxleCountingSectionData()); enum turoutPos { - '正位', + '定位', '反位', } @@ -133,7 +133,7 @@ const turnoutRelations = computed(() => { refTurnoutAndPos.push({ turnout: refTurout, pos: ref.position }); }); const ref = refTurnoutAndPos.map( - (ref) => `${ref.turnout.datas.code}+${turoutPos[ref.pos]}` + (ref) => `${ref.turnout.datas.code}:${turoutPos[ref.pos]}` ); return Array.from(new Set(ref)); }); diff --git a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts index 85ec97b..7ac26b5 100644 --- a/src/graphics/axleCounting/AxleCountingDrawAssistant.ts +++ b/src/graphics/axleCounting/AxleCountingDrawAssistant.ts @@ -118,7 +118,7 @@ export class AxleCountingDraw extends GraphicDrawAssistant< } axleCounting.id = GraphicIdGenerator.next(); axleCounting.datas.axleCountingRef = [refData2, refData1]; - axleCounting.datas.code = `${graphic.datas.code}-${port}+${refGraphic.datas.code}-${refPort}`; + axleCounting.datas.code = `${graphic.datas.code}-${port}\\${refGraphic.datas.code}-${refPort}`; this.storeGraphic(axleCounting); axleCounting.loadRelations(); } diff --git a/src/graphics/axleCountingSection/AxleCountingSection.ts b/src/graphics/axleCountingSection/AxleCountingSection.ts index c2e36a0..cc765e0 100644 --- a/src/graphics/axleCountingSection/AxleCountingSection.ts +++ b/src/graphics/axleCountingSection/AxleCountingSection.ts @@ -25,7 +25,7 @@ export interface IAxleCountingSectionData extends GraphicData { set paRef(ref: IRelatedRefData | undefined); get pbRef(): IRelatedRefData | undefined; //区段B端关联的设备 set pbRef(ref: IRelatedRefData | undefined); - get turnoutPosRef(): ITurnoutPosRefData[]; //关联道岔的正反位 + get turnoutPosRef(): ITurnoutPosRefData[]; //关联道岔的定反位--0是定位,1是反位 set turnoutPosRef(ref: ITurnoutPosRefData[]); get indexNumber(): number; // 索引编号 set indexNumber(v: number); From 37d73efc9d095d757845ed6f1ad72aaa1ef6af5f Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 12 Jul 2023 10:26:07 +0800 Subject: [PATCH 22/24] =?UTF-8?q?=E9=80=BB=E8=BE=91=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../draw-app/properties/LogicSectionProperty.vue | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/components/draw-app/properties/LogicSectionProperty.vue b/src/components/draw-app/properties/LogicSectionProperty.vue index 93c9545..8c51724 100644 --- a/src/components/draw-app/properties/LogicSectionProperty.vue +++ b/src/components/draw-app/properties/LogicSectionProperty.vue @@ -84,15 +84,9 @@ function onUpdate() { const logicSectionRelations = computed(() => { const logicSection = drawStore.selectedGraphic as LogicSection; - const sectionRelations = - logicSection?.relationManage.getRelationsOfGraphicAndOtherType( - logicSection, - AxleCountingSection.Type - ); - const ref = sectionRelations.map( - (relation) => - `${relation.getOtherGraphic(logicSection).datas.code}` - ); - return Array.from(new Set(ref)); + const axleCountingSection = logicSection.queryStore.queryById( + logicSection.datas.axleSectionId + ) as AxleCountingSection; + return [axleCountingSection.datas.code]; }); From 4427c5141009edeba864f365eff375a296137d74 Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Wed, 12 Jul 2023 10:41:28 +0800 Subject: [PATCH 23/24] =?UTF-8?q?=E8=AE=A1=E8=BD=B4=E5=8C=BA=E6=AE=B5?= =?UTF-8?q?=E5=85=B3=E8=81=94=E5=85=B3=E7=B3=BB=E7=AE=A1=E7=90=86=E4=B8=AD?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=81=93=E5=B2=94=E4=BD=8D=E7=BD=AE=E5=85=B3?= =?UTF-8?q?=E7=B3=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../axleCountingSection/AxleCountingSection.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/graphics/axleCountingSection/AxleCountingSection.ts b/src/graphics/axleCountingSection/AxleCountingSection.ts index cc765e0..3918ce5 100644 --- a/src/graphics/axleCountingSection/AxleCountingSection.ts +++ b/src/graphics/axleCountingSection/AxleCountingSection.ts @@ -116,6 +116,17 @@ export class AxleCountingSection extends JlGraphic { ) ); } + if (this.datas?.turnoutPosRef.length) { + this.datas.turnoutPosRef.forEach((ref) => { + this.relationManage.addRelation( + this, + new GraphicRelationParam( + this.queryStore.queryById(ref.id), + ref.position + ) + ); + }); + } } } From de6b1a70cc2f67a78a32ee592ae7bf6b78ec2117 Mon Sep 17 00:00:00 2001 From: dong <58670809@qq.com> Date: Wed, 12 Jul 2023 10:51:06 +0800 Subject: [PATCH 24/24] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jl-graphic/app/JlDrawApp.ts | 14 +++++++------- src/jl-graphic/app/JlGraphicApp.ts | 20 ++++++++++++++++++-- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/jl-graphic/app/JlDrawApp.ts b/src/jl-graphic/app/JlDrawApp.ts index 8a1bfa2..79f1071 100644 --- a/src/jl-graphic/app/JlDrawApp.ts +++ b/src/jl-graphic/app/JlDrawApp.ts @@ -456,13 +456,13 @@ export class JlDrawApp extends GraphicApp { * 删除选中图形对象 */ deleteSelectedGraphics() { - const deletes = this.selectedGraphics.slice( - 0, - this.selectedGraphics.length - ); - this.deleteGraphics(...this.selectedGraphics); - // 删除图形对象操作记录 - this.opRecord.record(new GraphicDeleteOperation(this, deletes)); + const deletes = this.deleteGraphics(...this.selectedGraphics); + if (deletes.length > 0) { + // 删除图形对象操作记录 + this.opRecord.record(new GraphicDeleteOperation(this, deletes)); + } else { + console.debug('没有删除元素,不记录'); + } } updateCanvasAndRecord(data: ICanvasProperties) { diff --git a/src/jl-graphic/app/JlGraphicApp.ts b/src/jl-graphic/app/JlGraphicApp.ts index e073582..4be56ea 100644 --- a/src/jl-graphic/app/JlGraphicApp.ts +++ b/src/jl-graphic/app/JlGraphicApp.ts @@ -320,6 +320,11 @@ export interface IGraphicAppConfig { * 超出屏幕显示范围是否剪裁,默认true */ cullable?: boolean; + + /** + * 是否支持删除操作 + */ + isSupportDeletion?: (g: JlGraphic) => boolean; } /** @@ -729,8 +734,19 @@ export class GraphicApp extends EventEmitter { * 删除图形 * @param graphics 图形对象 */ - deleteGraphics(...graphics: JlGraphic[]) { - graphics.forEach((g) => this.doDeleteGraphics(g)); + deleteGraphics(...graphics: JlGraphic[]): JlGraphic[] { + const dels = graphics.filter((g) => { + if ( + this._options?.isSupportDeletion && + this._options.isSupportDeletion(g) + ) { + this.doDeleteGraphics(g); + return true; + } + console.debug(`type=${g.type},id=${g.id}的图形不支持删除`); + return false; + }); + return dels; } /**