diff --git a/src/drawApp/index.ts b/src/drawApp/index.ts index 129ce9e..6631a18 100644 --- a/src/drawApp/index.ts +++ b/src/drawApp/index.ts @@ -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()) diff --git a/src/graphics/platform/Platform.ts b/src/graphics/platform/Platform.ts index 4e071f6..fd75468 100644 --- a/src/graphics/platform/Platform.ts +++ b/src/graphics/platform/Platform.ts @@ -268,6 +268,9 @@ export class Platform extends JlGraphic { get datas(): IPlatformData { return this.getDatas(); } + get states(): IPlatformState { + return this.getStates(); + } doRepaint(): void { this.doorGraphic.clear(); if (this.datas.hasdoor) { @@ -310,14 +313,18 @@ export class Platform extends JlGraphic { export class PlatformTemplate extends JlGraphicTemplate { 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; } } diff --git a/src/graphics/station/Station.ts b/src/graphics/station/Station.ts index eea07c2..a666739 100644 --- a/src/graphics/station/Station.ts +++ b/src/graphics/station/Station.ts @@ -179,6 +179,9 @@ export class Station extends JlGraphic { get datas(): IStationData { return this.getDatas(); } + get states(): IStationState { + return this.getStates(); + } doRepaint(): void { const codeGraph = this.codeGraph; const kilometerGraph = this.kilometerGraph; @@ -209,13 +212,17 @@ export class Station extends JlGraphic { export class StationTemplate extends JlGraphicTemplate { 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; } }