代码调整
This commit is contained in:
parent
d57b7bdbfa
commit
bd671ada7d
@ -5,7 +5,7 @@ import { Link } from 'src/graphics/link/Link';
|
||||
import { LinkDraw } from 'src/graphics/link/LinkDrawAssistant';
|
||||
import { Train } from 'src/graphics/train/Train';
|
||||
import { TrainDraw } from 'src/graphics/train/TrainDrawAssistant';
|
||||
import { Signal } from 'src/graphics/signal/Signal';
|
||||
import { Signal, SignalTemplate } from 'src/graphics/signal/Signal';
|
||||
import { SignalDraw } from 'src/graphics/signal/SignalDrawAssistant';
|
||||
import {
|
||||
CombinationKey,
|
||||
@ -46,7 +46,7 @@ import { TrainWindowData } from './graphics/TrainWindowInteraction';
|
||||
import { Turnout } from 'src/graphics/turnout/Turnout';
|
||||
import { TurnoutDraw } from 'src/graphics/turnout/TurnoutDrawAssistant';
|
||||
import { TurnoutData } from './graphics/TurnoutInteraction';
|
||||
import { RunLine } from 'src/graphics/runLine/RunLine';
|
||||
import { RunLine, RunLineTemplate } from 'src/graphics/runLine/RunLine';
|
||||
import { RunLineDraw } from 'src/graphics/runLine/RunLineDrawAssistant';
|
||||
import { RunLineData, DrawRunLinePlugin } from './graphics/RunLineInteraction';
|
||||
import { saveDraft, getDraft } from 'src/api/DraftApi';
|
||||
@ -151,9 +151,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
||||
new StationDraw(app, () => {
|
||||
return new StationData();
|
||||
}),
|
||||
new SignalDraw(app, () => {
|
||||
return new SignalData();
|
||||
}),
|
||||
new SignalDraw(app, new SignalTemplate(new SignalData())),
|
||||
new TurnoutDraw(app, () => {
|
||||
return new TurnoutData();
|
||||
}),
|
||||
@ -174,15 +172,11 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
||||
new RectDraw(app, () => {
|
||||
return new RectData();
|
||||
}),
|
||||
new RunLineDraw(app, () => {
|
||||
return new RunLineData();
|
||||
}),
|
||||
new RunLineDraw(app, new RunLineTemplate(new RunLineData())),
|
||||
new TrainLineDraw(app, () => {
|
||||
return new TrainLineData();
|
||||
}),
|
||||
new PathLineDraw(app, () => {
|
||||
return new PathLineData();
|
||||
}),
|
||||
new PathLineDraw(app, new PathLineTemplate(new PathLineData())),
|
||||
];
|
||||
DrawRunLinePlugin.init(app);
|
||||
}
|
||||
|
@ -81,8 +81,8 @@ export class PathLine extends JlGraphic {
|
||||
export class PathLineTemplate extends JlGraphicTemplate<PathLine> {
|
||||
pathLineColor: string;
|
||||
pathLineWidth: number;
|
||||
constructor() {
|
||||
super(PathLine.Type);
|
||||
constructor(dataTemplate: IPathLineData) {
|
||||
super(PathLine.Type, { dataTemplate });
|
||||
this.pathLineColor = pathLineConsts.pathLineColor;
|
||||
this.pathLineWidth = pathLineConsts.pathLineWidth;
|
||||
}
|
||||
|
@ -13,14 +13,8 @@ export class PathLineDraw extends GraphicDrawAssistant<
|
||||
points: Point[] = [];
|
||||
graphic: Graphics = new Graphics();
|
||||
|
||||
constructor(app: JlDrawApp, createData: () => IPathLineData) {
|
||||
super(
|
||||
app,
|
||||
new PathLineTemplate(),
|
||||
createData,
|
||||
'sym_o_horizontal_rule',
|
||||
'不展示'
|
||||
);
|
||||
constructor(app: JlDrawApp, template: PathLineTemplate) {
|
||||
super(app, template, 'sym_o_horizontal_rule', '不展示');
|
||||
this.container.addChild(this.graphic);
|
||||
// PathLinePointsEditPlugin.init(app);
|
||||
}
|
||||
|
@ -241,8 +241,8 @@ export class RunLine extends JlGraphic {
|
||||
export class RunLineTemplate extends JlGraphicTemplate<RunLine> {
|
||||
runLineColor: string;
|
||||
runLineWidth: number;
|
||||
constructor() {
|
||||
super(RunLine.Type);
|
||||
constructor(dataTemplate: IRunLineData) {
|
||||
super(RunLine.Type, { dataTemplate });
|
||||
this.runLineColor = RunLineColorEnum.runLineColor;
|
||||
this.runLineWidth = runLineConsts.runLineWidth;
|
||||
}
|
||||
|
@ -40,14 +40,8 @@ export class RunLineDraw extends GraphicDrawAssistant<
|
||||
points: Point[] = [];
|
||||
graphic: Graphics = new Graphics();
|
||||
|
||||
constructor(app: JlDrawApp, createData: () => IRunLineData) {
|
||||
super(
|
||||
app,
|
||||
new RunLineTemplate(),
|
||||
createData,
|
||||
'sym_o_horizontal_rule',
|
||||
'运行线RunLine'
|
||||
);
|
||||
constructor(app: JlDrawApp, template: RunLineTemplate) {
|
||||
super(app, template, 'sym_o_horizontal_rule', '运行线RunLine');
|
||||
this.container.addChild(this.graphic);
|
||||
RunLinePointsEditPlugin.init(app);
|
||||
}
|
||||
|
@ -125,8 +125,8 @@ export class Signal extends JlGraphic {
|
||||
}
|
||||
|
||||
export class SignalTemplate extends JlGraphicTemplate<Signal> {
|
||||
constructor() {
|
||||
super(Signal.Type);
|
||||
constructor(dataTemplate: ISignalData) {
|
||||
super(Signal.Type, { dataTemplate });
|
||||
}
|
||||
new(): Signal {
|
||||
return new Signal();
|
||||
|
@ -21,11 +21,10 @@ export class SignalDraw extends GraphicDrawAssistant<
|
||||
> {
|
||||
_signal: Signal | null = null;
|
||||
|
||||
constructor(app: JlDrawApp, createData: () => ISignalData) {
|
||||
constructor(app: JlDrawApp, template: SignalTemplate) {
|
||||
super(
|
||||
app,
|
||||
new SignalTemplate(),
|
||||
createData,
|
||||
template,
|
||||
'svguse: ../../drawIcon.svg#icon-signal',
|
||||
'信号机Signal'
|
||||
);
|
||||
@ -36,7 +35,7 @@ export class SignalDraw extends GraphicDrawAssistant<
|
||||
public get signal(): Signal {
|
||||
if (!this._signal) {
|
||||
this._signal = this.graphicTemplate.new();
|
||||
this.signal.loadData(this.createGraphicData());
|
||||
this.signal.loadData(this.graphicTemplate.datas);
|
||||
this.container.addChild(this.signal);
|
||||
}
|
||||
return this._signal;
|
||||
|
Loading…
Reference in New Issue
Block a user