列车调整
This commit is contained in:
parent
a3617b30a5
commit
0a209a963a
@ -19,9 +19,9 @@
|
|||||||
<template v-if="drawStore.drawGraphicType === Station.Type">
|
<template v-if="drawStore.drawGraphicType === Station.Type">
|
||||||
<station-template></station-template>
|
<station-template></station-template>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="drawStore.drawGraphicType === Train.Type">
|
<!-- <template v-if="drawStore.drawGraphicType === Train.Type">
|
||||||
<train-template></train-template>
|
<train-template></train-template>
|
||||||
</template>
|
</template> -->
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
@ -54,9 +54,9 @@
|
|||||||
<station-line-property
|
<station-line-property
|
||||||
v-if="drawStore.selectedGraphicType === StationLine.Type"
|
v-if="drawStore.selectedGraphicType === StationLine.Type"
|
||||||
></station-line-property>
|
></station-line-property>
|
||||||
<train-property
|
<!-- <train-property
|
||||||
v-if="drawStore.selectedGraphicType === Train.Type"
|
v-if="drawStore.selectedGraphicType === Train.Type"
|
||||||
></train-property>
|
></train-property> -->
|
||||||
<iscs-fan-property
|
<iscs-fan-property
|
||||||
v-else-if="drawStore.selectedGraphicType === IscsFan.Type"
|
v-else-if="drawStore.selectedGraphicType === IscsFan.Type"
|
||||||
></iscs-fan-property>
|
></iscs-fan-property>
|
||||||
@ -86,14 +86,14 @@ import LinkTemplate from './templates/LinkTemplate.vue';
|
|||||||
import RectTemplate from './templates/RectTemplate.vue';
|
import RectTemplate from './templates/RectTemplate.vue';
|
||||||
import PlatformTemplate from './templates/PlatformTemplate.vue';
|
import PlatformTemplate from './templates/PlatformTemplate.vue';
|
||||||
import StationTemplate from './templates/StationTemplate.vue';
|
import StationTemplate from './templates/StationTemplate.vue';
|
||||||
import TrainTemplate from './templates/TrainTemplate.vue';
|
// import TrainTemplate from './templates/TrainTemplate.vue';
|
||||||
import CanvasProperty from './properties/CanvasProperty.vue';
|
import CanvasProperty from './properties/CanvasProperty.vue';
|
||||||
import LinkProperty from './properties/LinkProperty.vue';
|
import LinkProperty from './properties/LinkProperty.vue';
|
||||||
import RectProperty from './properties/RectProperty.vue';
|
import RectProperty from './properties/RectProperty.vue';
|
||||||
import PlatformProperty from './properties/PlatformProperty.vue';
|
import PlatformProperty from './properties/PlatformProperty.vue';
|
||||||
import StationProperty from './properties/StationProperty.vue';
|
import StationProperty from './properties/StationProperty.vue';
|
||||||
import StationLineProperty from './properties/StationLineProperty.vue';
|
import StationLineProperty from './properties/StationLineProperty.vue';
|
||||||
import TrainProperty from './properties/TrainProperty.vue';
|
// import TrainProperty from './properties/TrainProperty.vue';
|
||||||
import TrainWindowProperty from './properties/TrainWindowProperty.vue';
|
import TrainWindowProperty from './properties/TrainWindowProperty.vue';
|
||||||
import IscsFanProperty from './properties/IscsFanProperty.vue';
|
import IscsFanProperty from './properties/IscsFanProperty.vue';
|
||||||
import SignalProperty from './properties/SignalProperty.vue';
|
import SignalProperty from './properties/SignalProperty.vue';
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
import * as pb_1 from 'google-protobuf';
|
import * as pb_1 from 'google-protobuf';
|
||||||
import { ITrainData, Train } from 'src/graphics/train/Train';
|
import { ITrainData, ITrainState, Train } from 'src/graphics/train/Train';
|
||||||
import { graphicData } from 'src/protos/stationLayoutGraphics';
|
import { graphicData } from 'src/protos/stationLayoutGraphics';
|
||||||
import { GraphicDataBase } from './GraphicDataBase';
|
import { GraphicDataBase, GraphicStateBase } from './GraphicDataBase';
|
||||||
|
import { state } from 'src/protos/device_status';
|
||||||
|
|
||||||
export class TrainData extends GraphicDataBase implements ITrainData {
|
export class TrainData extends GraphicDataBase implements ITrainData {
|
||||||
constructor(data?: graphicData.Train) {
|
constructor(data?: graphicData.Train) {
|
||||||
@ -25,18 +26,6 @@ export class TrainData extends GraphicDataBase implements ITrainData {
|
|||||||
set code(v: string) {
|
set code(v: string) {
|
||||||
this.data.code = v;
|
this.data.code = v;
|
||||||
}
|
}
|
||||||
get trainDirection(): string {
|
|
||||||
return this.data.trainDirection;
|
|
||||||
}
|
|
||||||
set trainDirection(v: string) {
|
|
||||||
this.data.trainDirection = v;
|
|
||||||
}
|
|
||||||
get hasBorder(): boolean {
|
|
||||||
return this.data.hasBorder;
|
|
||||||
}
|
|
||||||
set hasBorder(v: boolean) {
|
|
||||||
this.data.hasBorder = v;
|
|
||||||
}
|
|
||||||
clone(): TrainData {
|
clone(): TrainData {
|
||||||
return new TrainData(this.data.cloneMessage());
|
return new TrainData(this.data.cloneMessage());
|
||||||
}
|
}
|
||||||
@ -47,3 +36,186 @@ export class TrainData extends GraphicDataBase implements ITrainData {
|
|||||||
return pb_1.Message.equals(this.data, other.data);
|
return pb_1.Message.equals(this.data, other.data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class TrainState extends GraphicStateBase implements ITrainState {
|
||||||
|
constructor(proto?: StateTrain) {
|
||||||
|
let states;
|
||||||
|
if (proto) {
|
||||||
|
states = proto;
|
||||||
|
} else {
|
||||||
|
states = new StateTrain();
|
||||||
|
}
|
||||||
|
super(states, Train.Type);
|
||||||
|
}
|
||||||
|
|
||||||
|
get states(): StateTrain {
|
||||||
|
return this.getState<StateTrain>();
|
||||||
|
}
|
||||||
|
|
||||||
|
get trainId(): string {
|
||||||
|
return this.states.trainId;
|
||||||
|
}
|
||||||
|
set trainId(v: string) {
|
||||||
|
this.states.trainId = v;
|
||||||
|
}
|
||||||
|
get globalId(): string {
|
||||||
|
return this.states.globalId;
|
||||||
|
}
|
||||||
|
set globalId(v: string) {
|
||||||
|
this.states.globalId = v;
|
||||||
|
}
|
||||||
|
get groupId(): string {
|
||||||
|
return this.states.groupId;
|
||||||
|
}
|
||||||
|
set groupId(v: string) {
|
||||||
|
this.states.groupId = v;
|
||||||
|
}
|
||||||
|
get localSubId(): number {
|
||||||
|
return this.states.localSubId;
|
||||||
|
}
|
||||||
|
set localSubId(v: number) {
|
||||||
|
this.states.localSubId = v;
|
||||||
|
}
|
||||||
|
get trainType(): number {
|
||||||
|
return this.states.trainType;
|
||||||
|
}
|
||||||
|
set trainType(v: number) {
|
||||||
|
this.states.trainType = v;
|
||||||
|
}
|
||||||
|
get speed(): number {
|
||||||
|
return this.states.speed;
|
||||||
|
}
|
||||||
|
set speed(v: number) {
|
||||||
|
this.states.speed = v;
|
||||||
|
}
|
||||||
|
get direction(): number {
|
||||||
|
return this.states.direction;
|
||||||
|
}
|
||||||
|
set direction(v: number) {
|
||||||
|
this.states.direction = v;
|
||||||
|
}
|
||||||
|
get destinationId(): number {
|
||||||
|
return this.states.destinationId;
|
||||||
|
}
|
||||||
|
set destinationId(v: number) {
|
||||||
|
this.states.destinationId = v;
|
||||||
|
}
|
||||||
|
get stationId(): number {
|
||||||
|
return this.states.stationId;
|
||||||
|
}
|
||||||
|
set stationId(v: number) {
|
||||||
|
this.states.stationId = v;
|
||||||
|
}
|
||||||
|
get sideId(): number {
|
||||||
|
return this.states.sideId;
|
||||||
|
}
|
||||||
|
set sideId(v: number) {
|
||||||
|
this.states.sideId = v;
|
||||||
|
}
|
||||||
|
get trackName(): string {
|
||||||
|
return this.states.trackName;
|
||||||
|
}
|
||||||
|
set trackName(v: string) {
|
||||||
|
this.states.trackName = v;
|
||||||
|
}
|
||||||
|
get recordType(): boolean {
|
||||||
|
return this.states.recordType;
|
||||||
|
}
|
||||||
|
set recordType(v: boolean) {
|
||||||
|
this.states.recordType = v;
|
||||||
|
}
|
||||||
|
get recordTime(): number {
|
||||||
|
return this.states.recordTime;
|
||||||
|
}
|
||||||
|
set recordTime(v: number) {
|
||||||
|
this.states.recordTime = v;
|
||||||
|
}
|
||||||
|
get driverId(): string {
|
||||||
|
return this.states.driverId;
|
||||||
|
}
|
||||||
|
set driverId(v: string) {
|
||||||
|
this.states.driverId = v;
|
||||||
|
}
|
||||||
|
get routeId(): number {
|
||||||
|
return this.states.routeId;
|
||||||
|
}
|
||||||
|
set routeId(v: number) {
|
||||||
|
this.states.routeId = v;
|
||||||
|
}
|
||||||
|
get mode(): number {
|
||||||
|
return this.states.mode;
|
||||||
|
}
|
||||||
|
set mode(v: number) {
|
||||||
|
this.states.mode = v;
|
||||||
|
}
|
||||||
|
get nccWindow(): number {
|
||||||
|
return this.states.nccWindow;
|
||||||
|
}
|
||||||
|
set nccWindow(v: number) {
|
||||||
|
this.states.nccWindow = v;
|
||||||
|
}
|
||||||
|
get nccWindowOffset(): number {
|
||||||
|
return this.states.nccWindowOffset;
|
||||||
|
}
|
||||||
|
set nccWindowOffset(v: number) {
|
||||||
|
this.states.nccWindowOffset = v;
|
||||||
|
}
|
||||||
|
get rate(): number {
|
||||||
|
return this.states.rate;
|
||||||
|
}
|
||||||
|
set rate(v: number) {
|
||||||
|
this.states.rate = v;
|
||||||
|
}
|
||||||
|
get devType(): number {
|
||||||
|
return this.states.devType;
|
||||||
|
}
|
||||||
|
set devType(v: number) {
|
||||||
|
this.states.devType = v;
|
||||||
|
}
|
||||||
|
get devName(): string {
|
||||||
|
return this.states.devName;
|
||||||
|
}
|
||||||
|
set devName(v: string) {
|
||||||
|
this.states.devName = v;
|
||||||
|
}
|
||||||
|
get blockFlag(): number {
|
||||||
|
return this.states.blockFlag;
|
||||||
|
}
|
||||||
|
set blockFlag(v: number) {
|
||||||
|
this.states.blockFlag = v;
|
||||||
|
}
|
||||||
|
get show(): boolean {
|
||||||
|
return this.states.show;
|
||||||
|
}
|
||||||
|
set show(v: boolean) {
|
||||||
|
this.states.show = v;
|
||||||
|
}
|
||||||
|
get lineId(): number {
|
||||||
|
return this.states.lineId;
|
||||||
|
}
|
||||||
|
set lineId(v: number) {
|
||||||
|
this.states.lineId = v;
|
||||||
|
}
|
||||||
|
get id(): string {
|
||||||
|
return this.states.id;
|
||||||
|
}
|
||||||
|
set id(v: string) {
|
||||||
|
this.states.id = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
clone(): TrainState {
|
||||||
|
return new TrainState(this.states.cloneMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class StateTrain extends state.Train {
|
||||||
|
id: string;
|
||||||
|
constructor(data?: state.Train) {
|
||||||
|
super(data);
|
||||||
|
if (data?.trainIndex) {
|
||||||
|
this.id = data?.trainIndex;
|
||||||
|
} else {
|
||||||
|
this.id = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@ import { IPointData, Point } from 'pixi.js';
|
|||||||
import { IscsFan } from 'src/graphics/iscs-fan/IscsFan';
|
import { IscsFan } from 'src/graphics/iscs-fan/IscsFan';
|
||||||
import { Link } from 'src/graphics/link/Link';
|
import { Link } from 'src/graphics/link/Link';
|
||||||
import { LinkDraw } from 'src/graphics/link/LinkDrawAssistant';
|
import { LinkDraw } from 'src/graphics/link/LinkDrawAssistant';
|
||||||
import { Train } from 'src/graphics/train/Train';
|
import { Train, TrainTemplate } from 'src/graphics/train/Train';
|
||||||
import { TrainDraw } from 'src/graphics/train/TrainDrawAssistant';
|
import { TrainDraw } from 'src/graphics/train/TrainDrawAssistant';
|
||||||
import { Signal, SignalTemplate } from 'src/graphics/signal/Signal';
|
import { Signal, SignalTemplate } from 'src/graphics/signal/Signal';
|
||||||
import { SignalDraw } from 'src/graphics/signal/SignalDrawAssistant';
|
import { SignalDraw } from 'src/graphics/signal/SignalDrawAssistant';
|
||||||
@ -19,7 +19,7 @@ import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu';
|
|||||||
import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
|
import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
|
||||||
import { IscsFanData } from './graphics/IscsFanInteraction';
|
import { IscsFanData } from './graphics/IscsFanInteraction';
|
||||||
import { LinkData } from './graphics/LinkInteraction';
|
import { LinkData } from './graphics/LinkInteraction';
|
||||||
import { TrainData } from './graphics/TrainInteraction';
|
import { TrainData, TrainState } from './graphics/TrainInteraction';
|
||||||
import {
|
import {
|
||||||
SignalData,
|
SignalData,
|
||||||
DrawSignalInteraction,
|
DrawSignalInteraction,
|
||||||
@ -152,6 +152,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
|||||||
| TrainLineDraw
|
| TrainLineDraw
|
||||||
| PathLineDraw
|
| PathLineDraw
|
||||||
| TrainWindowDraw
|
| TrainWindowDraw
|
||||||
|
| TrainDraw
|
||||||
)[] = [];
|
)[] = [];
|
||||||
if (draftType === 'Line') {
|
if (draftType === 'Line') {
|
||||||
drawAssistants = [
|
drawAssistants = [
|
||||||
@ -167,9 +168,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
|||||||
app,
|
app,
|
||||||
new SignalTemplate(new SignalData(), new SignalState())
|
new SignalTemplate(new SignalData(), new SignalState())
|
||||||
),
|
),
|
||||||
// new TrainDraw(app, () => {
|
new TrainDraw(app, new TrainTemplate(new TrainData(), new TrainState())),
|
||||||
// return new TrainData();
|
|
||||||
// }),
|
|
||||||
new SectionDraw(app, new SectionTemplate(new SectionData())),
|
new SectionDraw(app, new SectionTemplate(new SectionData())),
|
||||||
new TurnoutDraw(app, new TurnoutTemplate(new TurnoutData())),
|
new TurnoutDraw(app, new TurnoutTemplate(new TurnoutData())),
|
||||||
new TrainWindowDraw(app, new TrainWindowTemplate(new TrainWindowData())),
|
new TrainWindowDraw(app, new TrainWindowTemplate(new TrainWindowData())),
|
||||||
|
@ -1,23 +1,74 @@
|
|||||||
import { Color, Graphics, Container } from 'pixi.js';
|
import { Color, Graphics, Container, Point } from 'pixi.js';
|
||||||
import {
|
import {
|
||||||
GraphicData,
|
GraphicData,
|
||||||
|
GraphicState,
|
||||||
JlGraphic,
|
JlGraphic,
|
||||||
JlGraphicTemplate,
|
JlGraphicTemplate,
|
||||||
VectorText,
|
VectorText,
|
||||||
|
calculateMirrorPoint,
|
||||||
} from 'src/jl-graphic';
|
} from 'src/jl-graphic';
|
||||||
|
|
||||||
export interface ITrainData extends GraphicData {
|
export interface ITrainData extends GraphicData {
|
||||||
get code(): string; // 车号
|
get code(): string; // 车号
|
||||||
set code(v: string);
|
set code(v: string);
|
||||||
get trainDirection(): string; // 行驶方向
|
|
||||||
set trainDirection(v: string);
|
|
||||||
get hasBorder(): boolean; // 是否有边框
|
|
||||||
set hasBorder(v: boolean);
|
|
||||||
clone(): ITrainData;
|
clone(): ITrainData;
|
||||||
copyFrom(data: ITrainData): void;
|
copyFrom(data: ITrainData): void;
|
||||||
eq(other: ITrainData): boolean;
|
eq(other: ITrainData): boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface ITrainState extends GraphicState {
|
||||||
|
get trainId(): string; // 列车表号
|
||||||
|
set trainId(v: string);
|
||||||
|
get globalId(): string; // 列车车次号
|
||||||
|
set globalId(v: string);
|
||||||
|
get groupId(): string; // 列车车组号
|
||||||
|
set groupId(v: string);
|
||||||
|
get localSubId(): number; // 局部序列号
|
||||||
|
set localSubId(v: number);
|
||||||
|
get trainType(): number; // 列车类型
|
||||||
|
set trainType(v: number);
|
||||||
|
get speed(): number; // 速度
|
||||||
|
set speed(v: number);
|
||||||
|
get direction(): number; // 运行方向
|
||||||
|
set direction(v: number);
|
||||||
|
get destinationId(): number; // 目的地ID
|
||||||
|
set destinationId(v: number);
|
||||||
|
get stationId(): number; // 行驶站号
|
||||||
|
set stationId(v: number);
|
||||||
|
get sideId(): number; // 站台号
|
||||||
|
set sideId(v: number);
|
||||||
|
get trackName(): string; // 轨道名称
|
||||||
|
set trackName(v: string);
|
||||||
|
get recordType(): boolean; // 到发点类型
|
||||||
|
set recordType(v: boolean);
|
||||||
|
get recordTime(): number; // 到发时间
|
||||||
|
set recordTime(v: number);
|
||||||
|
get driverId(): string; // 司机号
|
||||||
|
set driverId(v: string);
|
||||||
|
get routeId(): number; // 运行路径号
|
||||||
|
set routeId(v: number);
|
||||||
|
get mode(): number; // 列车状态
|
||||||
|
set mode(v: number);
|
||||||
|
get nccWindow(): number; // 车次窗编号
|
||||||
|
set nccWindow(v: number);
|
||||||
|
get nccWindowOffset(): number; // 车次窗位置
|
||||||
|
set nccWindowOffset(v: number);
|
||||||
|
get rate(): number; // 满载率
|
||||||
|
set rate(v: number);
|
||||||
|
get devType(): number; // 所在设备类型
|
||||||
|
set devType(v: number);
|
||||||
|
get devName(): string; // 所在设备名称
|
||||||
|
set devName(v: string);
|
||||||
|
get blockFlag(): number; // 阻塞标记
|
||||||
|
set blockFlag(v: number);
|
||||||
|
get show(): boolean; // 是否显示
|
||||||
|
set show(v: boolean);
|
||||||
|
get lineId(): number; // 线路id
|
||||||
|
set lineId(v: number);
|
||||||
|
get id(): string; // 设备唯一
|
||||||
|
set id(v: string);
|
||||||
|
}
|
||||||
|
|
||||||
interface bodyWH {
|
interface bodyWH {
|
||||||
width: number; // 宽
|
width: number; // 宽
|
||||||
height: number; // 高
|
height: number; // 高
|
||||||
@ -31,12 +82,22 @@ export enum TrainColorEnum {
|
|||||||
borderColor = '0xA3E198', // 边框的颜色
|
borderColor = '0xA3E198', // 边框的颜色
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum statusTextColor {
|
||||||
|
H = '0xFFFF00', // H扣车
|
||||||
|
S = '0x6260F3', // S跳停
|
||||||
|
D = '0x00FF00', // D开门
|
||||||
|
A = '0xFF0000', // A报警
|
||||||
|
}
|
||||||
|
|
||||||
export const trainConsts = {
|
export const trainConsts = {
|
||||||
codeWidth: 120,
|
codeWidth: 120,
|
||||||
codeHeight: 40,
|
codeHeight: 40,
|
||||||
codePadding: 5,
|
codePadding: 5,
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
codeFontSize: 22,
|
codeFontSize: 22,
|
||||||
|
textFontSize: 16, // 状态字母大小
|
||||||
|
textMarginY: 10, // 状态字母与列车距离
|
||||||
|
statusTextList: ['H', 'S', 'D', 'A'],
|
||||||
marginX: 2, // 图形x轴边距
|
marginX: 2, // 图形x轴边距
|
||||||
pauseW: 2, // 停止框宽度
|
pauseW: 2, // 停止框宽度
|
||||||
};
|
};
|
||||||
@ -44,12 +105,10 @@ export const trainConsts = {
|
|||||||
export class TrainHead extends Container {
|
export class TrainHead extends Container {
|
||||||
arrow: Graphics; // 箭头
|
arrow: Graphics; // 箭头
|
||||||
pause: Graphics; // 停止
|
pause: Graphics; // 停止
|
||||||
isLeftDirection: boolean; // 是否向左
|
constructor() {
|
||||||
constructor(direction: string) {
|
|
||||||
super();
|
super();
|
||||||
this.arrow = new Graphics();
|
this.arrow = new Graphics();
|
||||||
this.pause = new Graphics();
|
this.pause = new Graphics();
|
||||||
this.isLeftDirection = direction == 'left';
|
|
||||||
this.addChild(this.arrow);
|
this.addChild(this.arrow);
|
||||||
this.addChild(this.pause);
|
this.addChild(this.pause);
|
||||||
}
|
}
|
||||||
@ -57,7 +116,7 @@ export class TrainHead extends Container {
|
|||||||
this.arrow.clear();
|
this.arrow.clear();
|
||||||
this.pause.clear();
|
this.pause.clear();
|
||||||
}
|
}
|
||||||
doRepaint(bodyWH?: bodyWH) {
|
doRepaint(direction = 'left', bodyWH?: bodyWH) {
|
||||||
this.clear();
|
this.clear();
|
||||||
const marginX = trainConsts.marginX;
|
const marginX = trainConsts.marginX;
|
||||||
const pauseW = trainConsts.pauseW;
|
const pauseW = trainConsts.pauseW;
|
||||||
@ -71,26 +130,39 @@ export class TrainHead extends Container {
|
|||||||
-marginX - pauseW - marginX - codeWidth / 2,
|
-marginX - pauseW - marginX - codeWidth / 2,
|
||||||
-codeHeight / 2,
|
-codeHeight / 2,
|
||||||
];
|
];
|
||||||
let pausePoint = [-marginX - pauseW - codeWidth / 2, -codeHeight / 2];
|
let pausePoint = [
|
||||||
if (!this.isLeftDirection) {
|
-marginX - pauseW / 2 - codeWidth / 2,
|
||||||
arrowPoint = [
|
-codeHeight / 2,
|
||||||
codeWidth / 2 + marginX + pauseW + marginX + codeHeight * 0.4,
|
-marginX - pauseW / 2 - codeWidth / 2,
|
||||||
0,
|
codeHeight / 2,
|
||||||
codeWidth / 2 + marginX + pauseW + marginX,
|
];
|
||||||
codeHeight / 2,
|
if (direction != 'left') {
|
||||||
codeWidth / 2 + marginX + pauseW + marginX,
|
const aP: Array<number> = [];
|
||||||
-codeHeight / 2,
|
arrowPoint.forEach((item, index) => {
|
||||||
];
|
if (index % 2 == 1) {
|
||||||
pausePoint = [marginX + codeWidth / 2, -codeHeight / 2];
|
const p = new Point(arrowPoint[index - 1], item);
|
||||||
|
const newP = calculateMirrorPoint(new Point(0, 0), p);
|
||||||
|
aP.push(newP.x, newP.y);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
arrowPoint = aP;
|
||||||
|
const pP: Array<number> = [];
|
||||||
|
pausePoint.forEach((item, index) => {
|
||||||
|
if (index % 2 == 1) {
|
||||||
|
const p = new Point(pausePoint[index - 1], item);
|
||||||
|
const newP = calculateMirrorPoint(new Point(0, 0), p);
|
||||||
|
pP.push(newP.x, newP.y);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pausePoint = pP;
|
||||||
}
|
}
|
||||||
const arrow = this.arrow;
|
const arrow = this.arrow;
|
||||||
arrow.beginFill(TrainColorEnum.headColor, 1);
|
arrow.beginFill(TrainColorEnum.headColor, 1);
|
||||||
arrow.drawPolygon(arrowPoint);
|
arrow.drawPolygon(arrowPoint);
|
||||||
arrow.endFill();
|
arrow.endFill();
|
||||||
this.pause.beginFill(TrainColorEnum.headColor, 1);
|
this.pause.lineStyle(pauseW, TrainColorEnum.headColor, 1);
|
||||||
this.pause.drawRect(0, 0, pauseW, codeHeight);
|
this.pause.moveTo(pausePoint[0], pausePoint[1]);
|
||||||
this.pause.endFill();
|
this.pause.lineTo(pausePoint[2], pausePoint[3]);
|
||||||
this.pause.position.set(...pausePoint);
|
|
||||||
}
|
}
|
||||||
stop() {
|
stop() {
|
||||||
this.arrow.visible = false;
|
this.arrow.visible = false;
|
||||||
@ -121,49 +193,77 @@ export class TrainBody extends Container {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
doRepaint(datas?: ITrainData): void {
|
doRepaint(states?: ITrainState): void {
|
||||||
this.clear();
|
this.clear();
|
||||||
const codeGraph = this.codeGraph;
|
const codeGraph = this.codeGraph;
|
||||||
const codeRact = this.codeRact;
|
const codeRact = this.codeRact;
|
||||||
const code = datas?.code;
|
const code = states?.trainId;
|
||||||
codeGraph.text = code || '01110111';
|
codeGraph.text = code || '01110111';
|
||||||
codeGraph.setVectorFontSize(trainConsts.codeFontSize);
|
|
||||||
codeGraph.anchor.set(0.5);
|
codeGraph.anchor.set(0.5);
|
||||||
const style = {
|
const style = {
|
||||||
fill: TrainColorEnum.codeColor,
|
fill: TrainColorEnum.codeColor,
|
||||||
|
fontSize: trainConsts.codeFontSize,
|
||||||
padding: 5,
|
padding: 5,
|
||||||
};
|
};
|
||||||
codeGraph.style = style;
|
codeGraph.style = style;
|
||||||
const { width: codeWidth, height: codeHeight } = this.getBodyWH();
|
const { width: codeWidth, height: codeHeight } = this.getBodyWH();
|
||||||
const hasBorder = datas ? datas.hasBorder : true;
|
codeRact.lineStyle(
|
||||||
if (hasBorder) {
|
trainConsts.borderWidth,
|
||||||
codeRact.visible = true;
|
new Color(TrainColorEnum.borderColor)
|
||||||
codeRact.lineStyle(
|
);
|
||||||
trainConsts.borderWidth,
|
codeRact.beginFill(new Color(TrainColorEnum.bodyColor));
|
||||||
new Color(TrainColorEnum.borderColor)
|
codeRact.drawRect(-codeWidth / 2, -codeHeight / 2, codeWidth, codeHeight);
|
||||||
);
|
codeRact.endFill();
|
||||||
codeRact.beginFill(new Color(TrainColorEnum.bodyColor));
|
}
|
||||||
codeRact.drawRect(-codeWidth / 2, -codeHeight / 2, codeWidth, codeHeight);
|
}
|
||||||
codeRact.endFill();
|
|
||||||
} else {
|
class StatusText extends Container {
|
||||||
codeRact.visible = false;
|
sText: VectorText = new VectorText('');
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.addChild(this.sText);
|
||||||
|
}
|
||||||
|
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 style = {
|
||||||
|
fill: c,
|
||||||
|
fontSize: trainConsts.textFontSize,
|
||||||
|
};
|
||||||
|
this.sText.style = style;
|
||||||
|
const { width: codeWidth, height: codeHeight } = bodyWH;
|
||||||
|
const { width: textHWidth, height: textHeight } =
|
||||||
|
this.sText.getLocalBounds();
|
||||||
|
const num = trainConsts.statusTextList.length;
|
||||||
|
let index = trainConsts.statusTextList.findIndex((item) => {
|
||||||
|
return item == text;
|
||||||
|
});
|
||||||
|
if (index < 0) {
|
||||||
|
index = 1.5; // 中间
|
||||||
}
|
}
|
||||||
|
const textMargin = (codeWidth - textHWidth * num) / (num - 1);
|
||||||
|
this.sText.position.set(
|
||||||
|
-codeWidth / 2 + (textHWidth * (index * 2 + 1)) / 2 + textMargin * index,
|
||||||
|
-codeHeight / 2 - textHeight / 2 - trainConsts.textMarginY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
clear(): void {
|
||||||
|
this.sText.text = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class Train extends JlGraphic {
|
export class Train extends JlGraphic {
|
||||||
static Type = 'Train';
|
static Type = 'Train';
|
||||||
|
|
||||||
headLeft: TrainHead;
|
trainHead: TrainHead;
|
||||||
headRight: TrainHead;
|
|
||||||
trainbody: TrainBody;
|
trainbody: TrainBody;
|
||||||
|
statusTextMap: Map<string, StatusText> = new Map();
|
||||||
constructor() {
|
constructor() {
|
||||||
super(Train.Type);
|
super(Train.Type);
|
||||||
this.trainbody = new TrainBody();
|
this.trainbody = new TrainBody();
|
||||||
this.headLeft = new TrainHead('left');
|
this.trainHead = new TrainHead();
|
||||||
this.headRight = new TrainHead('right');
|
this.addChild(this.trainHead);
|
||||||
this.addChild(this.headLeft);
|
|
||||||
this.addChild(this.headRight);
|
|
||||||
this.addChild(this.trainbody);
|
this.addChild(this.trainbody);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -171,40 +271,52 @@ export class Train extends JlGraphic {
|
|||||||
return this.getDatas<ITrainData>();
|
return this.getDatas<ITrainData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get states(): ITrainState {
|
||||||
|
return this.getStates<ITrainState>();
|
||||||
|
}
|
||||||
|
|
||||||
doRepaint(): void {
|
doRepaint(): void {
|
||||||
this.trainbody.doRepaint(this.datas);
|
this.trainbody.doRepaint(this.states);
|
||||||
const bodyWH = this.trainbody.getBodyWH();
|
const bodyWH = this.trainbody.getBodyWH();
|
||||||
this.headLeft.doRepaint(bodyWH);
|
let direction = 'left';
|
||||||
this.headRight.doRepaint(bodyWH);
|
if (this.states.direction) {
|
||||||
// 运行方向控制箭头停止显隐
|
direction = 'right';
|
||||||
if (this.datas.trainDirection == 'right') {
|
|
||||||
this.headLeft.visible = false;
|
|
||||||
this.headRight.visible = true;
|
|
||||||
} else {
|
|
||||||
this.headLeft.visible = true;
|
|
||||||
this.headRight.visible = false;
|
|
||||||
}
|
}
|
||||||
|
this.trainHead.doRepaint(direction, bodyWH);
|
||||||
|
// this.showStatus('H');
|
||||||
}
|
}
|
||||||
|
|
||||||
stop() {
|
stop() {
|
||||||
this.headLeft.stop();
|
this.trainHead.stop();
|
||||||
this.headRight.stop();
|
|
||||||
}
|
}
|
||||||
run() {
|
run() {
|
||||||
this.headLeft.run();
|
this.trainHead.run();
|
||||||
this.headRight.run();
|
}
|
||||||
|
|
||||||
|
showStatus(s: string) {
|
||||||
|
const bodyWH = this.trainbody.getBodyWH();
|
||||||
|
const textD = new StatusText();
|
||||||
|
textD.doRepaint(s, bodyWH);
|
||||||
|
this.addChild(textD);
|
||||||
|
this.statusTextMap.set(s, textD);
|
||||||
|
}
|
||||||
|
hideStatus(s: string) {
|
||||||
|
const textD = this.statusTextMap.get(s);
|
||||||
|
if (textD) {
|
||||||
|
textD.clear();
|
||||||
|
this.statusTextMap.delete(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export class TrainTemplate extends JlGraphicTemplate<Train> {
|
export class TrainTemplate extends JlGraphicTemplate<Train> {
|
||||||
trainDirection: string;
|
constructor(dataTemplate: ITrainData, stateTemplate: ITrainState) {
|
||||||
hasBorder: boolean;
|
super(Train.Type, { dataTemplate, stateTemplate });
|
||||||
constructor() {
|
|
||||||
super(Train.Type, {});
|
|
||||||
this.trainDirection = 'left';
|
|
||||||
this.hasBorder = true;
|
|
||||||
}
|
}
|
||||||
new(): Train {
|
new(): Train {
|
||||||
return new Train();
|
const train = new Train();
|
||||||
|
train.loadData(this.datas);
|
||||||
|
train.loadState(this.states);
|
||||||
|
return train;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,14 @@ export interface ITrainDrawOptions {
|
|||||||
|
|
||||||
export class TrainDraw extends GraphicDrawAssistant<TrainTemplate, ITrainData> {
|
export class TrainDraw extends GraphicDrawAssistant<TrainTemplate, ITrainData> {
|
||||||
_Train: Train | null = null;
|
_Train: Train | null = null;
|
||||||
headLeft: TrainHead;
|
trainHead: TrainHead;
|
||||||
trainbody: TrainBody;
|
trainbody: TrainBody;
|
||||||
|
|
||||||
constructor(app: JlDrawApp) {
|
constructor(app: JlDrawApp, template: TrainTemplate) {
|
||||||
super(app, new TrainTemplate(), 'directions_bus_filled', '列车Train');
|
super(app, template, 'directions_bus_filled', '不展示');
|
||||||
this.headLeft = new TrainHead('left');
|
this.trainHead = new TrainHead();
|
||||||
this.trainbody = new TrainBody();
|
this.trainbody = new TrainBody();
|
||||||
this.container.addChild(this.headLeft);
|
this.container.addChild(this.trainHead);
|
||||||
this.container.addChild(this.trainbody);
|
this.container.addChild(this.trainbody);
|
||||||
trainInteraction.init(app);
|
trainInteraction.init(app);
|
||||||
}
|
}
|
||||||
@ -40,11 +40,11 @@ export class TrainDraw extends GraphicDrawAssistant<TrainTemplate, ITrainData> {
|
|||||||
}
|
}
|
||||||
this.trainbody.doRepaint();
|
this.trainbody.doRepaint();
|
||||||
const bodyWH = this.trainbody.getBodyWH();
|
const bodyWH = this.trainbody.getBodyWH();
|
||||||
this.headLeft.doRepaint(bodyWH);
|
this.trainHead.doRepaint('left', bodyWH);
|
||||||
}
|
}
|
||||||
|
|
||||||
clearCache(): void {
|
clearCache(): void {
|
||||||
this.headLeft.clear();
|
this.trainHead.clear();
|
||||||
this.trainbody.clear();
|
this.trainbody.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,10 +66,6 @@ export class TrainDraw extends GraphicDrawAssistant<TrainTemplate, ITrainData> {
|
|||||||
this.createAndStore(true);
|
this.createAndStore(true);
|
||||||
}
|
}
|
||||||
prepareData(data: ITrainData): boolean {
|
prepareData(data: ITrainData): boolean {
|
||||||
const template = this.graphicTemplate;
|
|
||||||
data.code = '01110111';
|
|
||||||
data.hasBorder = template.hasBorder;
|
|
||||||
data.trainDirection = template.trainDirection;
|
|
||||||
data.transform = this.container.saveTransform();
|
data.transform = this.container.saveTransform();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -2168,8 +2168,6 @@ export namespace graphicData {
|
|||||||
constructor(data?: any[] | {
|
constructor(data?: any[] | {
|
||||||
common?: CommonInfo;
|
common?: CommonInfo;
|
||||||
code?: string;
|
code?: string;
|
||||||
trainDirection?: string;
|
|
||||||
hasBorder?: boolean;
|
|
||||||
}) {
|
}) {
|
||||||
super();
|
super();
|
||||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||||
@ -2180,12 +2178,6 @@ export namespace graphicData {
|
|||||||
if ("code" in data && data.code != undefined) {
|
if ("code" in data && data.code != undefined) {
|
||||||
this.code = data.code;
|
this.code = data.code;
|
||||||
}
|
}
|
||||||
if ("trainDirection" in data && data.trainDirection != undefined) {
|
|
||||||
this.trainDirection = data.trainDirection;
|
|
||||||
}
|
|
||||||
if ("hasBorder" in data && data.hasBorder != undefined) {
|
|
||||||
this.hasBorder = data.hasBorder;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get common() {
|
get common() {
|
||||||
@ -2203,23 +2195,9 @@ export namespace graphicData {
|
|||||||
set code(value: string) {
|
set code(value: string) {
|
||||||
pb_1.Message.setField(this, 2, value);
|
pb_1.Message.setField(this, 2, value);
|
||||||
}
|
}
|
||||||
get trainDirection() {
|
|
||||||
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
|
|
||||||
}
|
|
||||||
set trainDirection(value: string) {
|
|
||||||
pb_1.Message.setField(this, 3, value);
|
|
||||||
}
|
|
||||||
get hasBorder() {
|
|
||||||
return pb_1.Message.getFieldWithDefault(this, 4, false) as boolean;
|
|
||||||
}
|
|
||||||
set hasBorder(value: boolean) {
|
|
||||||
pb_1.Message.setField(this, 4, value);
|
|
||||||
}
|
|
||||||
static fromObject(data: {
|
static fromObject(data: {
|
||||||
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||||
code?: string;
|
code?: string;
|
||||||
trainDirection?: string;
|
|
||||||
hasBorder?: boolean;
|
|
||||||
}): Train {
|
}): Train {
|
||||||
const message = new Train({});
|
const message = new Train({});
|
||||||
if (data.common != null) {
|
if (data.common != null) {
|
||||||
@ -2228,20 +2206,12 @@ export namespace graphicData {
|
|||||||
if (data.code != null) {
|
if (data.code != null) {
|
||||||
message.code = data.code;
|
message.code = data.code;
|
||||||
}
|
}
|
||||||
if (data.trainDirection != null) {
|
|
||||||
message.trainDirection = data.trainDirection;
|
|
||||||
}
|
|
||||||
if (data.hasBorder != null) {
|
|
||||||
message.hasBorder = data.hasBorder;
|
|
||||||
}
|
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
toObject() {
|
toObject() {
|
||||||
const data: {
|
const data: {
|
||||||
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||||
code?: string;
|
code?: string;
|
||||||
trainDirection?: string;
|
|
||||||
hasBorder?: boolean;
|
|
||||||
} = {};
|
} = {};
|
||||||
if (this.common != null) {
|
if (this.common != null) {
|
||||||
data.common = this.common.toObject();
|
data.common = this.common.toObject();
|
||||||
@ -2249,12 +2219,6 @@ export namespace graphicData {
|
|||||||
if (this.code != null) {
|
if (this.code != null) {
|
||||||
data.code = this.code;
|
data.code = this.code;
|
||||||
}
|
}
|
||||||
if (this.trainDirection != null) {
|
|
||||||
data.trainDirection = this.trainDirection;
|
|
||||||
}
|
|
||||||
if (this.hasBorder != null) {
|
|
||||||
data.hasBorder = this.hasBorder;
|
|
||||||
}
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
serialize(): Uint8Array;
|
serialize(): Uint8Array;
|
||||||
@ -2265,10 +2229,6 @@ export namespace graphicData {
|
|||||||
writer.writeMessage(1, this.common, () => this.common.serialize(writer));
|
writer.writeMessage(1, this.common, () => this.common.serialize(writer));
|
||||||
if (this.code.length)
|
if (this.code.length)
|
||||||
writer.writeString(2, this.code);
|
writer.writeString(2, this.code);
|
||||||
if (this.trainDirection.length)
|
|
||||||
writer.writeString(3, this.trainDirection);
|
|
||||||
if (this.hasBorder != false)
|
|
||||||
writer.writeBool(4, this.hasBorder);
|
|
||||||
if (!w)
|
if (!w)
|
||||||
return writer.getResultBuffer();
|
return writer.getResultBuffer();
|
||||||
}
|
}
|
||||||
@ -2284,12 +2244,6 @@ export namespace graphicData {
|
|||||||
case 2:
|
case 2:
|
||||||
message.code = reader.readString();
|
message.code = reader.readString();
|
||||||
break;
|
break;
|
||||||
case 3:
|
|
||||||
message.trainDirection = reader.readString();
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
message.hasBorder = reader.readBool();
|
|
||||||
break;
|
|
||||||
default: reader.skipField();
|
default: reader.skipField();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user