站台调整

This commit is contained in:
joylink_zhaoerwei 2023-12-25 17:46:12 +08:00
parent 07984139b5
commit f44ee05c17
2 changed files with 107 additions and 161 deletions

View File

@ -1,6 +1,6 @@
import { JlGraphic, calculateMirrorPoint, JlGraphicTemplate, getRectangleCenter, VectorText } from 'jl-graphic';
import { Container, Graphics, Color, Point, Rectangle } from 'pixi.js';
import { CategoryType, platformConstsMap } from './PlatformConfig.js';
import { platformConstsMap, CategoryType } from './PlatformConfig.js';
class RectGraphic extends Container {
static Type = 'RectPlatForm';
@ -49,8 +49,6 @@ class DoorGraphic extends Container {
const doorConsts = platformConsts.doorGraphic;
const doorGraphic = this.doorGraphic;
const doorCloseGraphic = this.doorCloseGraphic;
doorGraphic.clear();
doorCloseGraphic.clear();
let lineColor = doorConsts.doorGreen;
if (ipRtuStusDown) {
lineColor = doorConsts.blueShowColor;
@ -58,15 +56,17 @@ class DoorGraphic extends Container {
else if (stateData.psdCut) {
lineColor = doorConsts.doorRed;
}
doorGraphic.lineStyle(platformConsts.lineWidth, new Color(lineColor));
doorGraphic.moveTo(-platformConsts.width / 2 - platformConsts.lineWidth / 2, 0);
doorGraphic.lineTo(-doorConsts.doorOpenSpacing, 0);
doorGraphic.moveTo(doorConsts.doorOpenSpacing, 0);
doorGraphic.lineTo(platformConsts.width / 2 + platformConsts.lineWidth / 2, 0);
doorGraphic.clear()
.lineStyle(platformConsts.lineWidth, new Color(lineColor))
.moveTo(-platformConsts.width / 2 - platformConsts.lineWidth / 2, 0)
.lineTo(-doorConsts.doorOpenSpacing, 0)
.moveTo(doorConsts.doorOpenSpacing, 0)
.lineTo(platformConsts.width / 2 + platformConsts.lineWidth / 2, 0);
//屏蔽门闭合
doorCloseGraphic.lineStyle(platformConsts.lineWidth, new Color(lineColor));
doorCloseGraphic.moveTo(-doorConsts.doorOpenSpacing, 0);
doorCloseGraphic.lineTo(doorConsts.doorOpenSpacing, 0);
doorCloseGraphic.clear()
.lineStyle(platformConsts.lineWidth, new Color(lineColor))
.moveTo(-doorConsts.doorOpenSpacing, 0)
.lineTo(doorConsts.doorOpenSpacing, 0);
}
clear() {
this.doorGraphic.clear();
@ -113,9 +113,9 @@ class CodeGraph extends Container {
(codeConsts.besideSpacing * 2) / 3, (platformConsts.height * 3) / 4);
character.style.fill = codeConsts.whiteNumbers;
const circle = this.circle;
circle.clear();
circle.lineStyle(0.5, codeConsts.whiteCircle);
circle.drawCircle(0, 0, codeConsts.circleRadius);
circle.clear()
.lineStyle(0.5, codeConsts.whiteCircle)
.drawCircle(0, 0, codeConsts.circleRadius);
circle.position.set(-platformConsts.width / 2 -
platformConsts.lineWidth / 2 -
(codeConsts.besideSpacing * 4) / 3, (platformConsts.height * 3) / 5);
@ -208,11 +208,11 @@ class LozengeGraphic extends Container {
draw(platformConsts) {
const LozengeConsts = platformConsts.lozengeGraphic;
const lozengeGraphic = this.lozengeGraphic;
lozengeGraphic.clear();
lozengeGraphic.lineStyle(1, new Color(LozengeConsts.lozengeRed));
lozengeGraphic.beginFill(LozengeConsts.lozengeRed, 1);
lozengeGraphic.drawRect(0, 0, platformConsts.height / 4, platformConsts.height / 4);
lozengeGraphic.endFill();
lozengeGraphic.clear()
.lineStyle(1, new Color(LozengeConsts.lozengeRed))
.beginFill(LozengeConsts.lozengeRed, 1)
.drawRect(0, 0, platformConsts.height / 4, platformConsts.height / 4)
.endFill();
const rect = new Rectangle(0, 0, platformConsts.height / 4, platformConsts.height / 4);
lozengeGraphic.pivot = getRectangleCenter(rect);
lozengeGraphic.rotation = Math.PI / 4;
@ -241,15 +241,19 @@ class Platform extends JlGraphic {
super(Platform.Type);
this.categoryType = categoryType;
this.addChild(this.rectGraphic);
if (categoryType == CategoryType.XiAn) {
const platformConsts = platformConstsMap.get(this.categoryType);
const platformConsts = platformConstsMap.get(this.categoryType);
if (platformConsts.doorGraphic) {
this.doorGraphic = new DoorGraphic();
this.lozengeGraphic = new LozengeGraphic();
this.codeGraph = new CodeGraph(platformConsts);
this.addChild(this.doorGraphic);
this.addChild(this.codeGraph);
}
if (platformConsts.lozengeGraphic) {
this.lozengeGraphic = new LozengeGraphic();
this.addChild(this.lozengeGraphic);
}
if (platformConsts.codeGraphic) {
this.codeGraph = new CodeGraph(platformConsts);
this.addChild(this.codeGraph);
}
}
get datas() {
return this.getDatas();
@ -275,10 +279,30 @@ class Platform extends JlGraphic {
this.doorGraphic.draw(states, false, platformConsts);
const doorConsts = platformConsts.doorGraphic;
this.doorGraphic.position.set(0, -platformConsts.height / 2 - doorConsts.doorPlatformSpacing);
if (this.datas.direction == 'down') {
this.doorGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.doorGraphic.position));
}
}
if (this.codeGraph) {
this.codeGraph.draw(platformConsts);
this.codeGraph.position.set(0, 0);
if (this.datas.direction == 'down') {
const psChange = [
this.codeGraph?.children[0],
this.codeGraph?.children[1],
this.codeGraph?.children[3],
this.codeGraph?.children[4],
];
psChange.forEach((g) => {
if (g) {
g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position));
}
});
const codeConsts = platformConsts.codeGraphic;
this.codeGraph?.children[2].position.set(platformConsts.width / 2 +
platformConsts.lineWidth / 2 +
(codeConsts.besideSpacing * 4) / 3, (-platformConsts.height * 10) / 11);
}
}
if (this.lozengeGraphic) {
const LozengeConsts = platformConsts.lozengeGraphic;
@ -286,26 +310,9 @@ class Platform extends JlGraphic {
this.lozengeGraphic.position.set(0, -platformConsts.height / 2 -
LozengeConsts.doorPlatformSpacing -
platformConsts.height / 3);
}
//站台方向
if (this.datas.direction == 'down') {
const psChange = [
this.doorGraphic,
this.lozengeGraphic,
this.codeGraph?.children[0],
this.codeGraph?.children[1],
this.codeGraph?.children[3],
this.codeGraph?.children[4],
];
psChange.forEach((g) => {
if (g) {
g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position));
}
});
const codeConsts = platformConsts.codeGraphic;
this.codeGraph?.children[2].position.set(platformConsts.width / 2 +
platformConsts.lineWidth / 2 +
(codeConsts.besideSpacing * 4) / 3, (-platformConsts.height * 10) / 11);
if (this.datas.direction == 'down') {
this.lozengeGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.lozengeGraphic.position));
}
}
this.changeState();
}

View File

@ -53,29 +53,29 @@ export class DoorGraphic extends Container {
const doorConsts=platformConsts.doorGraphic as DoorConstsConfig
const doorGraphic = this.doorGraphic;
const doorCloseGraphic = this.doorCloseGraphic;
doorGraphic.clear();
doorCloseGraphic.clear();
let lineColor = doorConsts.doorGreen;
if (ipRtuStusDown) {
lineColor = doorConsts.blueShowColor;
} else if (stateData.psdCut) {
lineColor = doorConsts.doorRed;
}
doorGraphic.lineStyle(platformConsts.lineWidth, new Color(lineColor));
doorGraphic.moveTo(
doorGraphic.clear()
.lineStyle(platformConsts.lineWidth, new Color(lineColor))
.moveTo(
-platformConsts.width / 2 - platformConsts.lineWidth / 2,
0
);
doorGraphic.lineTo(-doorConsts.doorOpenSpacing, 0);
doorGraphic.moveTo(doorConsts.doorOpenSpacing, 0);
doorGraphic.lineTo(
)
.lineTo(-doorConsts.doorOpenSpacing, 0)
.moveTo(doorConsts.doorOpenSpacing, 0)
.lineTo(
platformConsts.width / 2 + platformConsts.lineWidth / 2,
0
);
)
//屏蔽门闭合
doorCloseGraphic.lineStyle(platformConsts.lineWidth, new Color(lineColor));
doorCloseGraphic.moveTo(-doorConsts.doorOpenSpacing, 0);
doorCloseGraphic.lineTo(doorConsts.doorOpenSpacing, 0);
doorCloseGraphic.clear()
.lineStyle(platformConsts.lineWidth, new Color(lineColor))
.moveTo(-doorConsts.doorOpenSpacing, 0)
.lineTo(doorConsts.doorOpenSpacing, 0);
}
clear(): void {
this.doorGraphic.clear();
@ -124,9 +124,9 @@ class CodeGraph extends Container {
);
character.style.fill = codeConsts.whiteNumbers;
const circle = this.circle;
circle.clear();
circle.lineStyle(0.5, codeConsts.whiteCircle);
circle.drawCircle(0, 0, codeConsts.circleRadius);
circle.clear()
.lineStyle(0.5, codeConsts.whiteCircle)
.drawCircle(0, 0, codeConsts.circleRadius)
circle.position.set(
-platformConsts.width / 2 -
platformConsts.lineWidth / 2 -
@ -233,16 +233,16 @@ class LozengeGraphic extends Container {
draw(platformConsts:PlatformConstsConfig): void {
const LozengeConsts=platformConsts.lozengeGraphic as LozengeConstsConfig
const lozengeGraphic = this.lozengeGraphic;
lozengeGraphic.clear();
lozengeGraphic.lineStyle(1, new Color(LozengeConsts.lozengeRed));
lozengeGraphic.beginFill(LozengeConsts.lozengeRed, 1);
lozengeGraphic.drawRect(
lozengeGraphic.clear()
.lineStyle(1, new Color(LozengeConsts.lozengeRed))
.beginFill(LozengeConsts.lozengeRed, 1)
.drawRect(
0,
0,
platformConsts.height / 4,
platformConsts.height / 4
);
lozengeGraphic.endFill();
)
.endFill();
const rect = new Rectangle(
0,
0,
@ -276,17 +276,20 @@ export class Platform extends JlGraphic {
super(Platform.Type);
this.categoryType = categoryType
this.addChild(this.rectGraphic);
if(categoryType==CategoryType.XiAn){
const platformConsts=platformConstsMap.get(this.categoryType) as PlatformConstsConfig
const platformConsts=platformConstsMap.get(this.categoryType) as PlatformConstsConfig
if(platformConsts.doorGraphic){
this.doorGraphic = new DoorGraphic()
this.lozengeGraphic = new LozengeGraphic()
this.codeGraph = new CodeGraph(platformConsts)
this.addChild(this.doorGraphic);
this.addChild(this.codeGraph);
}
if(platformConsts.lozengeGraphic){
this.lozengeGraphic = new LozengeGraphic()
this.addChild(this.lozengeGraphic);
}
if(platformConsts.codeGraphic){
this.codeGraph = new CodeGraph(platformConsts)
this.addChild(this.codeGraph);
}
}
get datas() {
return this.getDatas<IPlatformData>();
}
@ -313,10 +316,33 @@ export class Platform extends JlGraphic {
0,
-platformConsts.height / 2 -doorConsts.doorPlatformSpacing
);
if (this.datas.direction == 'down') {
this.doorGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.doorGraphic.position))
}
}
if(this.codeGraph){
this.codeGraph.draw(platformConsts);
this.codeGraph.position.set(0, 0);
if (this.datas.direction == 'down') {
const psChange = [
this.codeGraph?.children[0],
this.codeGraph?.children[1],
this.codeGraph?.children[3],
this.codeGraph?.children[4],
];
psChange.forEach((g) => {
if(g){
g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position));
}
});
const codeConsts=platformConsts.codeGraphic as CodeConstsConfig
this.codeGraph?.children[2].position.set(
platformConsts.width / 2 +
platformConsts.lineWidth / 2 +
(codeConsts.besideSpacing * 4) / 3,
(-platformConsts.height * 10) / 11
);
}
}
if(this.lozengeGraphic){
const LozengeConsts= platformConsts.lozengeGraphic as LozengeConstsConfig
@ -327,30 +353,9 @@ export class Platform extends JlGraphic {
LozengeConsts.doorPlatformSpacing -
platformConsts.height / 3
);
}
//站台方向
if (this.datas.direction == 'down') {
const psChange = [
this.doorGraphic,
this.lozengeGraphic,
this.codeGraph?.children[0],
this.codeGraph?.children[1],
this.codeGraph?.children[3],
this.codeGraph?.children[4],
];
psChange.forEach((g) => {
if(g){
g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position));
}
});
const codeConsts=platformConsts.codeGraphic as CodeConstsConfig
this.codeGraph?.children[2].position.set(
platformConsts.width / 2 +
platformConsts.lineWidth / 2 +
(codeConsts.besideSpacing * 4) / 3,
(-platformConsts.height * 10) / 11
);
if (this.datas.direction == 'down') {
this.lozengeGraphic.position.copyFrom(calculateMirrorPoint(new Point(0, 0), this.lozengeGraphic.position))
}
}
this.changeState();
}
@ -361,73 +366,7 @@ export class Platform extends JlGraphic {
this.lozengeGraphic?.changeState(states);
this.codeGraph?.changeState(states,platformConsts);
}
/* buildRelation() {
const stationas = this.queryStore.queryByType<Station>(Station.Type);
for (let i = 0; i < stationas.length; i++) {
const sP = stationas[i].localBoundsToCanvasPoints();
if (this.x > sP[0].x && this.x < sP[1].x) {
this.relationManage.addRelation(this, stationas[i]);
break;
}
}
const sections = this.queryStore.queryByType<Section>(Section.Type);
const minDistanceRefSections: Section[] = [];
sections.forEach((section) => {
const sP = section.localBoundsToCanvasPoints();
if (this.x > sP[0].x && this.x < sP[1].x) {
minDistanceRefSections.push(section);
}
});
if (minDistanceRefSections) {
const refSection = minDistanceRefSections.reduce((prev, cur) => {
return distance2(
prev.localToCanvasPoint(getRectangleCenter(prev.getLocalBounds())),
this.position
) >
distance2(
cur.localToCanvasPoint(getRectangleCenter(cur.getLocalBounds())),
this.position
)
? cur
: prev;
});
this.relationManage.deleteRelationOfGraphicAndOtherType(
this,
Section.Type
);
this.relationManage.addRelation(this, refSection);
}
}
saveRelations() {
const refStation = this.relationManage
.getRelationsOfGraphicAndOtherType(this, Station.Type)
.map((relation) => relation.getOtherGraphic<Station>(this).datas.id);
if (refStation.length) {
this.datas.refStation = refStation[0];
}
const refSection = this.relationManage
.getRelationsOfGraphicAndOtherType(this, Section.Type)
.map((relation) => relation.getOtherGraphic<Section>(this).datas.id);
if (refSection.length) {
this.datas.refSection = refSection[0];
}
}
loadRelations() {
if (this.datas.refStation) {
this.relationManage.addRelation(
this,
this.queryStore.queryById<Platform>(this.datas.refStation)
);
}
if (this.datas.refSection) {
this.relationManage.addRelation(
this,
this.queryStore.queryById<Platform>(this.datas.refSection)
);
}
} */
}
export class PlatformTemplate extends JlGraphicTemplate<Platform> {
categoryType:CategoryType;
constructor(