From 2ca2c584351558dcbae88378e3fe0935453c7e6c Mon Sep 17 00:00:00 2001 From: joylink_zhaoerwei Date: Fri, 12 Jan 2024 11:01:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/common/CommonGraphics.d.ts | 12 ++ components/common/common.d.ts | 6 + components/packages/Platform/THPlatform.d.ts | 6 +- components/packages/Platform/THPlatform.js | 31 ++-- .../packages/Platform/common/JlPlatform.d.ts | 27 ++-- .../packages/Platform/common/JlPlatform.js | 105 ++++++++------ src/packages/Platform/THPlatform.ts | 39 +++-- src/packages/Platform/common/JlPlatform.ts | 133 ++++++++++-------- 8 files changed, 225 insertions(+), 134 deletions(-) create mode 100644 components/common/CommonGraphics.d.ts diff --git a/components/common/CommonGraphics.d.ts b/components/common/CommonGraphics.d.ts new file mode 100644 index 0000000..7edcc90 --- /dev/null +++ b/components/common/CommonGraphics.d.ts @@ -0,0 +1,12 @@ +import { Graphics } from 'pixi.js'; +/** + * + * @param polygon + * @param x 箭头顶点x坐标 + * @param y 箭头顶点y坐标 + * @param length 箭头长度 + * @param radius 箭头三角半径 + * @param lineWidth 箭头线宽 + * @param mirror 是否镜像翻转 (基于箭头顶点) + */ +export declare function drawArrow(polygon: Graphics, x: number, y: number, length: number, radius: number, lineWidth: number, mirror: boolean): void; diff --git a/components/common/common.d.ts b/components/common/common.d.ts index cfaf6bb..48b3c0a 100644 --- a/components/common/common.d.ts +++ b/components/common/common.d.ts @@ -36,6 +36,12 @@ export interface KilometerSystem { get direction(): Direction; set direction(v: Direction); } +export interface KilometerSystemNoDir { + get coordinateSystem(): string; + set coordinateSystem(v: string); + get kilometer(): number; + set kilometer(v: number); +} export interface IRelatedRef { deviceType: DeviceType; id: number; diff --git a/components/packages/Platform/THPlatform.d.ts b/components/packages/Platform/THPlatform.d.ts index 2a03871..30c0e91 100644 --- a/components/packages/Platform/THPlatform.d.ts +++ b/components/packages/Platform/THPlatform.d.ts @@ -1,5 +1,5 @@ import { GraphicState } from 'jl-graphic'; -import { JlPlatform, DoorCodeLozenge } from './common/JlPlatform'; +import { JlPlatform, DoorGraphic, LozengeGraphic, CodeGraphic } from './common/JlPlatform'; export interface ITHPlatformState extends GraphicState { get emergstop(): boolean; set emergstop(v: boolean); @@ -37,7 +37,9 @@ export interface ITHPlatformState extends GraphicState { set rtuId(v: number); } export declare class THPlatform extends JlPlatform { - doorCodeLozenge: DoorCodeLozenge; + doorGraphic: DoorGraphic; + codeGraphic: CodeGraphic; + lozengeGraphic: LozengeGraphic; constructor(); get states(): ITHPlatformState; doRepaint(): void; diff --git a/components/packages/Platform/THPlatform.js b/components/packages/Platform/THPlatform.js index 3e79d9d..fa9a7b4 100644 --- a/components/packages/Platform/THPlatform.js +++ b/components/packages/Platform/THPlatform.js @@ -1,13 +1,19 @@ import { THConsts } from './common/PlatformConfig.js'; -import { JlPlatform, DoorCodeLozenge } from './common/JlPlatform.js'; +import { JlPlatform, DoorGraphic, CodeGraphic, LozengeGraphic } from './common/JlPlatform.js'; import { THStation } from '../Station/THStation.js'; class THPlatform extends JlPlatform { - doorCodeLozenge; + doorGraphic; + codeGraphic; + lozengeGraphic; constructor() { super(THConsts); - this.doorCodeLozenge = new DoorCodeLozenge(THConsts); - this.addChild(this.doorCodeLozenge); + this.doorGraphic = new DoorGraphic(THConsts); + this.addChild(this.doorGraphic); + this.codeGraphic = new CodeGraphic(THConsts); + this.addChild(this.codeGraphic); + this.lozengeGraphic = new LozengeGraphic(THConsts); + this.addChild(this.lozengeGraphic); } get states() { return this.getStates(); @@ -23,7 +29,7 @@ class THPlatform extends JlPlatform { const station = this.getGraphicApp().queryStore.queryByCodeAndType(this.states.rtuId > 9 ? '' + this.states.rtuId : '0' + this.states.rtuId, THStation.Type); - const doorGraphic = this.doorCodeLozenge.doorGraphic; + const doorGraphic = this.doorGraphic; doorGraphic.stateFillColor = THConsts.doorGraphic.doorGreen; if (!!station?.states.ipRtuStusDown) { doorGraphic.stateFillColor = THConsts.doorGraphic.doorBlue; @@ -32,7 +38,14 @@ class THPlatform extends JlPlatform { doorGraphic.stateFillColor = THConsts.doorGraphic.doorRed; } super.draw(); - this.doorCodeLozenge.draw(this.datas.hasdoor, this.datas.direction); + this.doorGraphic.draw(); + this.codeGraphic.draw(); + this.lozengeGraphic.draw(); + if (this.datas.direction == 'down') { + this.doorGraphic.changePosition(); + this.codeGraphic.changePosition(); + this.lozengeGraphic.changePosition(); + } //门的状态 if (this.datas.hasdoor) { if (this.states.psdOpen) { @@ -43,13 +56,13 @@ class THPlatform extends JlPlatform { } } if (this.states.emergstop) { - this.doorCodeLozenge.lozengeGraphic.lozenge.visible = true; + this.lozengeGraphic.lozenge.visible = true; } else { - this.doorCodeLozenge.lozengeGraphic.lozenge.visible = false; + this.lozengeGraphic.lozenge.visible = false; } //扣车 - const codeGraphic = this.doorCodeLozenge.codeGraphic; + const codeGraphic = this.codeGraphic; if (this.states.upHold || this.states.upOccHold || this.states.downHold || diff --git a/components/packages/Platform/common/JlPlatform.d.ts b/components/packages/Platform/common/JlPlatform.d.ts index 97cce0f..b86138c 100644 --- a/components/packages/Platform/common/JlPlatform.d.ts +++ b/components/packages/Platform/common/JlPlatform.d.ts @@ -2,34 +2,41 @@ import { JlGraphic, VectorText } from 'jl-graphic'; import { Container, Graphics } from 'pixi.js'; import { IPlatformData, PlatformConstsConfig } from './PlatformConfig'; declare class RectGraphic extends Container { + platformConsts: PlatformConstsConfig; rect: Graphics; stateFillColor?: string; - constructor(); - draw(platformConsts: PlatformConstsConfig): void; + constructor(platformConsts: PlatformConstsConfig); + draw(): void; clear(): void; } -declare class DoorGraphic extends Container { +export declare class DoorGraphic extends Container { + platformConsts: PlatformConstsConfig; doorGraphic: Graphics; doorCloseGraphic: Graphics; stateFillColor?: string; - constructor(); - draw(platformConsts: PlatformConstsConfig): void; + constructor(platformConsts: PlatformConstsConfig); + draw(): void; + changePosition(): void; clear(): void; } -declare class CodeGraphic extends Container { +export declare class CodeGraphic extends Container { + platformConsts: PlatformConstsConfig; character: VectorText; runLevel: VectorText; runTime: VectorText; stopTime: VectorText; circle: Graphics; constructor(platformConsts: PlatformConstsConfig); - draw(platformConsts: PlatformConstsConfig): void; + draw(): void; + changePosition(): void; clear(): void; } -declare class LozengeGraphic extends Container { +export declare class LozengeGraphic extends Container { + platformConsts: PlatformConstsConfig; lozenge: Graphics; - constructor(); - draw(platformConsts: PlatformConstsConfig): void; + constructor(platformConsts: PlatformConstsConfig); + draw(): void; + changePosition(): void; clear(): void; } export declare class DoorCodeLozenge extends Container { diff --git a/components/packages/Platform/common/JlPlatform.js b/components/packages/Platform/common/JlPlatform.js index 6e19071..196e46d 100644 --- a/components/packages/Platform/common/JlPlatform.js +++ b/components/packages/Platform/common/JlPlatform.js @@ -1,18 +1,21 @@ -import { calculateMirrorPoint, JlGraphic, distance2, getRectangleCenter, VectorText } from 'jl-graphic'; -import { Container, Point, Graphics, Color, Rectangle } from 'pixi.js'; +import { calculateMirrorPoint, VectorText, getRectangleCenter, JlGraphic, distance2 } from 'jl-graphic'; +import { Container, Graphics, Color, Point, Rectangle } from 'pixi.js'; import { JlSection } from '../../Section/common/Section.js'; import { JlStation } from '../../Station/common/JlStation.js'; //子元素--矩形 class RectGraphic extends Container { + platformConsts; rect; stateFillColor; - constructor() { + constructor(platformConsts) { super(); + this.platformConsts = platformConsts; this.rect = new Graphics(); this.addChild(this.rect); } - draw(platformConsts) { + draw() { + const platformConsts = this.platformConsts; const rect = this.rect; const fillColor = this.stateFillColor || platformConsts.noTrainStop; rect @@ -28,17 +31,20 @@ class RectGraphic extends Container { } //子元素--门 class DoorGraphic extends Container { + platformConsts; doorGraphic; doorCloseGraphic; stateFillColor; - constructor() { + constructor(platformConsts) { super(); + this.platformConsts = platformConsts; this.doorGraphic = new Graphics(); this.doorCloseGraphic = new Graphics(); this.addChild(this.doorGraphic); this.addChild(this.doorCloseGraphic); } - draw(platformConsts) { + draw() { + const platformConsts = this.platformConsts; const doorConsts = platformConsts.doorGraphic; const doorGraphic = this.doorGraphic; const doorCloseGraphic = this.doorCloseGraphic; @@ -56,6 +62,10 @@ class DoorGraphic extends Container { .lineStyle(platformConsts.lineWidth, new Color(lineColor)) .moveTo(-doorConsts.doorOpenSpacing, 0) .lineTo(doorConsts.doorOpenSpacing, 0); + this.position.set(0, -platformConsts.height / 2 - doorConsts.doorPlatformSpacing); + } + changePosition() { + this.doorGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.position)); } clear() { this.doorGraphic.clear(); @@ -64,6 +74,7 @@ class DoorGraphic extends Container { } //子元素--字符 class CodeGraphic extends Container { + platformConsts; character = new VectorText(''); //扣车H runLevel = new VectorText(''); //运行等级 runTime = new VectorText(''); //运行时间 @@ -71,6 +82,7 @@ class CodeGraphic extends Container { circle = new Graphics(); constructor(platformConsts) { super(); + this.platformConsts = platformConsts; this.addChild(this.character); this.addChild(this.runLevel); this.addChild(this.circle); @@ -82,8 +94,9 @@ class CodeGraphic extends Container { this.stopTime.setVectorFontSize(codeConsts.besideFontSize); this.runTime.setVectorFontSize(codeConsts.besideFontSize); } - draw(platformConsts) { - const codeConsts = platformConsts.codeGraphic; + draw() { + const platformConsts = this.platformConsts; + const codeConsts = this.platformConsts.codeGraphic; //扣车 const character = this.character; character.text = 'H'; @@ -126,6 +139,25 @@ class CodeGraphic extends Container { runLevel.visible = false; stopTime.visible = false; runTime.visible = false; + this.position.set(0, 0); + } + changePosition() { + const platformConsts = this.platformConsts; + const codeConsts = platformConsts.codeGraphic; + const psChange = [ + this.character, + this.runLevel, + this.stopTime, + this.runTime, + ]; + psChange.forEach((g) => { + if (g) { + g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position)); + } + }); + this.circle.position.set(platformConsts.width / 2 + + platformConsts.lineWidth / 2 + + (codeConsts.besideSpacing * 4) / 3, (-platformConsts.height * 10) / 11); } clear() { this.character.destroy(); @@ -133,13 +165,16 @@ class CodeGraphic extends Container { } //子元素--站台旁菱形图标 class LozengeGraphic extends Container { + platformConsts; lozenge; - constructor() { + constructor(platformConsts) { super(); + this.platformConsts = platformConsts; this.lozenge = new Graphics(); this.addChild(this.lozenge); } - draw(platformConsts) { + draw() { + const platformConsts = this.platformConsts; const LozengeConsts = platformConsts.lozengeGraphic; const lozenge = this.lozenge; lozenge @@ -152,6 +187,12 @@ class LozengeGraphic extends Container { lozenge.pivot = getRectangleCenter(rect); lozenge.rotation = Math.PI / 4; lozenge.visible = false; + this.position.set(0, -platformConsts.height / 2 - + LozengeConsts.doorPlatformSpacing - + platformConsts.height / 3); + } + changePosition() { + this.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.position)); } clear() { this.lozenge.clear(); @@ -165,46 +206,24 @@ class DoorCodeLozenge extends Container { constructor(platformConsts) { super(); this.platformConsts = platformConsts; - this.doorGraphic = new DoorGraphic(); + this.doorGraphic = new DoorGraphic(this.platformConsts); this.addChild(this.doorGraphic); - this.lozengeGraphic = new LozengeGraphic(); + this.lozengeGraphic = new LozengeGraphic(this.platformConsts); this.addChild(this.lozengeGraphic); this.codeGraphic = new CodeGraphic(this.platformConsts); this.addChild(this.codeGraphic); } draw(hasDoor, direction) { - const platformConsts = this.platformConsts; this.doorGraphic.clear(); if (hasDoor) { - const doorConsts = platformConsts.doorGraphic; - this.doorGraphic.draw(platformConsts); - this.doorGraphic.position.set(0, -platformConsts.height / 2 - doorConsts.doorPlatformSpacing); + this.doorGraphic.draw(); } - const codeConsts = platformConsts.codeGraphic; - this.codeGraphic.draw(platformConsts); - this.codeGraphic.position.set(0, 0); - const LozengeConsts = platformConsts.lozengeGraphic; - this.lozengeGraphic.draw(platformConsts); - this.lozengeGraphic.position.set(0, -platformConsts.height / 2 - - LozengeConsts.doorPlatformSpacing - - platformConsts.height / 3); + this.codeGraphic.draw(); + this.lozengeGraphic.draw(); if (direction == 'down') { - this.doorGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.doorGraphic.position)); - this.lozengeGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.lozengeGraphic.position)); - const psChange = [ - this.codeGraphic.character, - this.codeGraphic.runLevel, - this.codeGraphic.stopTime, - this.codeGraphic.runTime, - ]; - psChange.forEach((g) => { - if (g) { - g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position)); - } - }); - this.codeGraphic.circle.position.set(platformConsts.width / 2 + - platformConsts.lineWidth / 2 + - (codeConsts.besideSpacing * 4) / 3, (-platformConsts.height * 10) / 11); + this.doorGraphic.changePosition(); + this.codeGraphic.changePosition(); + this.lozengeGraphic.changePosition(); } } } @@ -215,7 +234,7 @@ class JlPlatform extends JlGraphic { constructor(platformConsts) { super(JlPlatform.Type); this.platformConsts = platformConsts; - this.rectGraphic = new RectGraphic(); + this.rectGraphic = new RectGraphic(this.platformConsts); this.addChild(this.rectGraphic); } get datas() { @@ -225,7 +244,7 @@ class JlPlatform extends JlGraphic { return this.datas.code; } draw() { - this.rectGraphic.draw(this.platformConsts); + this.rectGraphic.draw(); } buildCommonRelation() { const stationas = this.queryStore.queryByType(JlStation.Type); @@ -279,4 +298,4 @@ class JlPlatform extends JlGraphic { } } -export { DoorCodeLozenge, JlPlatform }; +export { CodeGraphic, DoorCodeLozenge, DoorGraphic, JlPlatform, LozengeGraphic }; diff --git a/src/packages/Platform/THPlatform.ts b/src/packages/Platform/THPlatform.ts index 834fd42..3df9aa8 100644 --- a/src/packages/Platform/THPlatform.ts +++ b/src/packages/Platform/THPlatform.ts @@ -1,6 +1,11 @@ import { GraphicState } from 'jl-graphic'; import { THConsts } from './common/PlatformConfig'; -import { JlPlatform, DoorCodeLozenge } from './common/JlPlatform'; +import { + JlPlatform, + DoorGraphic, + LozengeGraphic, + CodeGraphic, +} from './common/JlPlatform'; import { THStation } from '../Station/THStation'; export interface ITHPlatformState extends GraphicState { @@ -41,11 +46,17 @@ export interface ITHPlatformState extends GraphicState { } export class THPlatform extends JlPlatform { - doorCodeLozenge: DoorCodeLozenge; + doorGraphic: DoorGraphic; + codeGraphic: CodeGraphic; + lozengeGraphic: LozengeGraphic; constructor() { super(THConsts); - this.doorCodeLozenge = new DoorCodeLozenge(THConsts); - this.addChild(this.doorCodeLozenge); + this.doorGraphic = new DoorGraphic(THConsts); + this.addChild(this.doorGraphic); + this.codeGraphic = new CodeGraphic(THConsts); + this.addChild(this.codeGraphic); + this.lozengeGraphic = new LozengeGraphic(THConsts); + this.addChild(this.lozengeGraphic); } get states(): ITHPlatformState { return this.getStates(); @@ -65,7 +76,7 @@ export class THPlatform extends JlPlatform { : '0' + this.states.rtuId, THStation.Type, ); - const doorGraphic = this.doorCodeLozenge.doorGraphic; + const doorGraphic = this.doorGraphic; doorGraphic.stateFillColor = THConsts.doorGraphic.doorGreen; if (!!station?.states.ipRtuStusDown) { doorGraphic.stateFillColor = THConsts.doorGraphic.doorBlue; @@ -73,10 +84,14 @@ export class THPlatform extends JlPlatform { doorGraphic.stateFillColor = THConsts.doorGraphic.doorRed; } super.draw(); - this.doorCodeLozenge.draw( - this.datas.hasdoor as boolean, - this.datas.direction as string, - ); + this.doorGraphic.draw(); + this.codeGraphic.draw(); + this.lozengeGraphic.draw(); + if (this.datas.direction == 'down') { + this.doorGraphic.changePosition(); + this.codeGraphic.changePosition(); + this.lozengeGraphic.changePosition(); + } //门的状态 if (this.datas.hasdoor) { if (this.states.psdOpen) { @@ -86,12 +101,12 @@ export class THPlatform extends JlPlatform { } } if (this.states.emergstop) { - this.doorCodeLozenge.lozengeGraphic.lozenge.visible = true; + this.lozengeGraphic.lozenge.visible = true; } else { - this.doorCodeLozenge.lozengeGraphic.lozenge.visible = false; + this.lozengeGraphic.lozenge.visible = false; } //扣车 - const codeGraphic = this.doorCodeLozenge.codeGraphic; + const codeGraphic = this.codeGraphic; if ( this.states.upHold || this.states.upOccHold || diff --git a/src/packages/Platform/common/JlPlatform.ts b/src/packages/Platform/common/JlPlatform.ts index 301d05c..c4c241b 100644 --- a/src/packages/Platform/common/JlPlatform.ts +++ b/src/packages/Platform/common/JlPlatform.ts @@ -18,14 +18,17 @@ import { JlStation } from '../../Station/common/JlStation'; //子元素--矩形 class RectGraphic extends Container { + platformConsts: PlatformConstsConfig; rect: Graphics; stateFillColor?: string; - constructor() { + constructor(platformConsts: PlatformConstsConfig) { super(); + this.platformConsts = platformConsts; this.rect = new Graphics(); this.addChild(this.rect); } - draw(platformConsts: PlatformConstsConfig): void { + draw(): void { + const platformConsts = this.platformConsts; const rect = this.rect; const fillColor = this.stateFillColor || platformConsts.noTrainStop; rect @@ -42,18 +45,21 @@ class RectGraphic extends Container { } } //子元素--门 -class DoorGraphic extends Container { +export class DoorGraphic extends Container { + platformConsts: PlatformConstsConfig; doorGraphic: Graphics; doorCloseGraphic: Graphics; stateFillColor?: string; - constructor() { + constructor(platformConsts: PlatformConstsConfig) { super(); + this.platformConsts = platformConsts; this.doorGraphic = new Graphics(); this.doorCloseGraphic = new Graphics(); this.addChild(this.doorGraphic); this.addChild(this.doorCloseGraphic); } - draw(platformConsts: PlatformConstsConfig): void { + draw(): void { + const platformConsts = this.platformConsts; const doorConsts = platformConsts.doorGraphic as DoorConstsConfig; const doorGraphic = this.doorGraphic; const doorCloseGraphic = this.doorCloseGraphic; @@ -71,6 +77,15 @@ class DoorGraphic extends Container { .lineStyle(platformConsts.lineWidth, new Color(lineColor)) .moveTo(-doorConsts.doorOpenSpacing, 0) .lineTo(doorConsts.doorOpenSpacing, 0); + this.position.set( + 0, + -platformConsts.height / 2 - doorConsts.doorPlatformSpacing, + ); + } + changePosition() { + this.doorGraphic.position.copyFrom( + calculateMirrorPoint(new Point(0, 0), this.position), + ); } clear(): void { this.doorGraphic.clear(); @@ -78,7 +93,8 @@ class DoorGraphic extends Container { } } //子元素--字符 -class CodeGraphic extends Container { +export class CodeGraphic extends Container { + platformConsts: PlatformConstsConfig; character: VectorText = new VectorText(''); //扣车H runLevel: VectorText = new VectorText(''); //运行等级 runTime: VectorText = new VectorText(''); //运行时间 @@ -86,6 +102,7 @@ class CodeGraphic extends Container { circle: Graphics = new Graphics(); constructor(platformConsts: PlatformConstsConfig) { super(); + this.platformConsts = platformConsts; this.addChild(this.character); this.addChild(this.runLevel); this.addChild(this.circle); @@ -97,8 +114,9 @@ class CodeGraphic extends Container { this.stopTime.setVectorFontSize(codeConsts.besideFontSize); this.runTime.setVectorFontSize(codeConsts.besideFontSize); } - draw(platformConsts: PlatformConstsConfig): void { - const codeConsts = platformConsts.codeGraphic as CodeConstsConfig; + draw(): void { + const platformConsts = this.platformConsts; + const codeConsts = this.platformConsts.codeGraphic as CodeConstsConfig; //扣车 const character = this.character; character.text = 'H'; @@ -156,20 +174,45 @@ class CodeGraphic extends Container { runLevel.visible = false; stopTime.visible = false; runTime.visible = false; + this.position.set(0, 0); + } + changePosition() { + const platformConsts = this.platformConsts; + const codeConsts = platformConsts.codeGraphic as CodeConstsConfig; + const psChange = [ + this.character, + this.runLevel, + this.stopTime, + this.runTime, + ]; + psChange.forEach((g) => { + if (g) { + g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position)); + } + }); + this.circle.position.set( + platformConsts.width / 2 + + platformConsts.lineWidth / 2 + + (codeConsts.besideSpacing * 4) / 3, + (-platformConsts.height * 10) / 11, + ); } clear(): void { this.character.destroy(); } } //子元素--站台旁菱形图标 -class LozengeGraphic extends Container { +export class LozengeGraphic extends Container { + platformConsts: PlatformConstsConfig; lozenge: Graphics; - constructor() { + constructor(platformConsts: PlatformConstsConfig) { super(); + this.platformConsts = platformConsts; this.lozenge = new Graphics(); this.addChild(this.lozenge); } - draw(platformConsts: PlatformConstsConfig): void { + draw(): void { + const platformConsts = this.platformConsts; const LozengeConsts = platformConsts.lozengeGraphic as LozengeConstsConfig; const lozenge = this.lozenge; lozenge @@ -187,6 +230,17 @@ class LozengeGraphic extends Container { lozenge.pivot = getRectangleCenter(rect); lozenge.rotation = Math.PI / 4; lozenge.visible = false; + this.position.set( + 0, + -platformConsts.height / 2 - + LozengeConsts.doorPlatformSpacing - + platformConsts.height / 3, + ); + } + changePosition() { + this.position.copyFrom( + calculateMirrorPoint(new Point(0, 0), this.position), + ); } clear(): void { this.lozenge.clear(); @@ -201,61 +255,24 @@ export class DoorCodeLozenge extends Container { constructor(platformConsts: PlatformConstsConfig) { super(); this.platformConsts = platformConsts; - this.doorGraphic = new DoorGraphic(); + this.doorGraphic = new DoorGraphic(this.platformConsts); this.addChild(this.doorGraphic); - this.lozengeGraphic = new LozengeGraphic(); + this.lozengeGraphic = new LozengeGraphic(this.platformConsts); this.addChild(this.lozengeGraphic); this.codeGraphic = new CodeGraphic(this.platformConsts); this.addChild(this.codeGraphic); } draw(hasDoor: boolean, direction: string) { - const platformConsts = this.platformConsts; this.doorGraphic.clear(); if (hasDoor) { - const doorConsts = platformConsts.doorGraphic as DoorConstsConfig; - this.doorGraphic.draw(platformConsts); - this.doorGraphic.position.set( - 0, - -platformConsts.height / 2 - doorConsts.doorPlatformSpacing, - ); + this.doorGraphic.draw(); } - const codeConsts = platformConsts.codeGraphic as CodeConstsConfig; - this.codeGraphic.draw(platformConsts); - this.codeGraphic.position.set(0, 0); - const LozengeConsts = platformConsts.lozengeGraphic as LozengeConstsConfig; - this.lozengeGraphic.draw(platformConsts); - this.lozengeGraphic.position.set( - 0, - -platformConsts.height / 2 - - LozengeConsts.doorPlatformSpacing - - platformConsts.height / 3, - ); + this.codeGraphic.draw(); + this.lozengeGraphic.draw(); if (direction == 'down') { - this.doorGraphic.position.copyFrom( - calculateMirrorPoint(new Point(0, 0), this.doorGraphic.position), - ); - this.lozengeGraphic.position.copyFrom( - calculateMirrorPoint(new Point(0, 0), this.lozengeGraphic.position), - ); - const psChange = [ - this.codeGraphic.character, - this.codeGraphic.runLevel, - this.codeGraphic.stopTime, - this.codeGraphic.runTime, - ]; - psChange.forEach((g) => { - if (g) { - g.position.copyFrom( - calculateMirrorPoint(new Point(0, 0), g.position), - ); - } - }); - this.codeGraphic.circle.position.set( - platformConsts.width / 2 + - platformConsts.lineWidth / 2 + - (codeConsts.besideSpacing * 4) / 3, - (-platformConsts.height * 10) / 11, - ); + this.doorGraphic.changePosition(); + this.codeGraphic.changePosition(); + this.lozengeGraphic.changePosition(); } } } @@ -267,7 +284,7 @@ export abstract class JlPlatform extends JlGraphic { constructor(platformConsts: PlatformConstsConfig) { super(JlPlatform.Type); this.platformConsts = platformConsts; - this.rectGraphic = new RectGraphic(); + this.rectGraphic = new RectGraphic(this.platformConsts); this.addChild(this.rectGraphic); } get datas() { @@ -277,7 +294,7 @@ export abstract class JlPlatform extends JlGraphic { return this.datas.code; } draw(): void { - this.rectGraphic.draw(this.platformConsts); + this.rectGraphic.draw(); } buildCommonRelation() { const stationas = this.queryStore.queryByType(JlStation.Type);