This commit is contained in:
fan 2023-06-20 17:15:03 +08:00
commit 5e12d9a2e5
3 changed files with 28 additions and 8 deletions

View File

@ -30,11 +30,11 @@ import { Rect, RectTemplate } from 'src/graphics/rect/Rect';
import { RectDraw } from 'src/graphics/rect/RectDrawAssistant';
import { RectData } from './graphics/RectInteraction';
import { Platform, PlatformTemplate } from 'src/graphics/platform/Platform';
import { PlatformData } from './graphics/PlatformInteraction';
import { PlatformData, PlatformState } from './graphics/PlatformInteraction';
import { PlatformDraw } from 'src/graphics/platform/PlatformDrawAssistant';
import { Station, StationTemplate } from 'src/graphics/station/Station';
import { StationDraw } from 'src/graphics/station/StationDrawAssistant';
import { StationData } from './graphics/StationInteraction';
import { StationData, StationState } from './graphics/StationInteraction';
import {
StationLine,
StationLineTemplate,
@ -155,8 +155,14 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
)[] = [];
if (draftType === 'Line') {
drawAssistants = [
new PlatformDraw(app, new PlatformTemplate(new PlatformData())),
new StationDraw(app, new StationTemplate(new StationData())),
new PlatformDraw(
app,
new PlatformTemplate(new PlatformData(), new PlatformState())
),
new StationDraw(
app,
new StationTemplate(new StationData(), new StationState())
),
new SignalDraw(
app,
new SignalTemplate(new SignalData(), new SignalState())

View File

@ -268,6 +268,9 @@ export class Platform extends JlGraphic {
get datas(): IPlatformData {
return this.getDatas<IPlatformData>();
}
get states(): IPlatformState {
return this.getStates<IPlatformState>();
}
doRepaint(): void {
this.doorGraphic.clear();
if (this.datas.hasdoor) {
@ -310,14 +313,18 @@ export class Platform extends JlGraphic {
export class PlatformTemplate extends JlGraphicTemplate<Platform> {
hasdoor: boolean;
direction: string;
constructor(dataTemplate: IPlatformData) {
constructor(dataTemplate: IPlatformData, stateTemplate: IPlatformState) {
super(Platform.Type, {
dataTemplate,
stateTemplate,
});
this.hasdoor = true;
this.direction = 'up';
}
new(): Platform {
return new Platform();
const platform = new Platform();
platform.loadData(this.datas);
platform.loadState(this.states);
return platform;
}
}

View File

@ -179,6 +179,9 @@ export class Station extends JlGraphic {
get datas(): IStationData {
return this.getDatas<IStationData>();
}
get states(): IStationState {
return this.getStates<IStationState>();
}
doRepaint(): void {
const codeGraph = this.codeGraph;
const kilometerGraph = this.kilometerGraph;
@ -209,13 +212,17 @@ export class Station extends JlGraphic {
export class StationTemplate extends JlGraphicTemplate<Station> {
hasControl: boolean;
constructor(dataTemplate: IStationData) {
constructor(dataTemplate: IStationData, stateTemplate: IStationState) {
super(Station.Type, {
dataTemplate,
stateTemplate,
});
this.hasControl = true;
}
new(): Station {
return new Station();
const station = new Station();
station.loadData(this.datas);
station.loadState(this.states);
return station;
}
}