diff --git a/src/drawApp/graphics/TrainInteraction.ts b/src/drawApp/graphics/TrainInteraction.ts index 6210271..1441f4b 100644 --- a/src/drawApp/graphics/TrainInteraction.ts +++ b/src/drawApp/graphics/TrainInteraction.ts @@ -5,7 +5,7 @@ import { state } from 'src/protos/device_state'; import { MenuItemOptions } from 'src/jl-graphic/ui/Menu'; import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu'; import { - GraphicApp, + IGraphicApp, GraphicInteractionPlugin, JlGraphic, } from 'src/jl-graphic'; @@ -99,13 +99,13 @@ export class TrainState extends GraphicStateBase implements ITrainState { this.states.headDirection = v; } get dynamicState(): state.TrainDynamicState { - return this.states.dynamicState; + return this.states.dynamicState || new state.TrainDynamicState(); } set dynamicState(v: state.TrainDynamicState) { this.states.dynamicState = new state.TrainDynamicState(v); } get vobcState(): state.TrainVobcState { - return this.states.vobcState; + return this.states.vobcState || new state.TrainVobcState(); } set vobcState(v: state.TrainVobcState) { this.states.vobcState = new state.TrainVobcState(v); @@ -135,11 +135,11 @@ const TrainOperateMenu: ContextMenu = ContextMenu.init({ export class TrainOperateInteraction extends GraphicInteractionPlugin { static Name = 'train_operate_menu'; - constructor(app: GraphicApp) { + constructor(app: IGraphicApp) { super(TrainOperateInteraction.Name, app); app.registerMenu(TrainOperateMenu); } - static init(app: GraphicApp) { + static init(app: IGraphicApp) { return new TrainOperateInteraction(app); } filter(...grahpics: JlGraphic[]): Train[] | undefined {