框架更新报错修改

This commit is contained in:
Yuan 2023-06-20 13:48:23 +08:00
parent 2e849d8893
commit 6a8abaa990
25 changed files with 66 additions and 81 deletions

View File

@ -49,7 +49,7 @@ const sectionRelations = computed(() => {
const turnout = drawStore.selectedGraphic as Turnout; const turnout = drawStore.selectedGraphic as Turnout;
const sectionRelations = const sectionRelations =
turnout?.relationManage.getRelationsOfGraphicAndOtherType( turnout.relationManage.getRelationsOfGraphicAndOtherType(
turnout, turnout,
Section.Type Section.Type
); );

View File

@ -44,6 +44,24 @@ export class TurnoutData extends GraphicDataBase implements ITurnoutData {
set pointC(v: IPointData[]) { set pointC(v: IPointData[]) {
this.data.pointC = v.map((p) => new graphicData.Point({ x: p.x, y: p.y })); this.data.pointC = v.map((p) => new graphicData.Point({ x: p.x, y: p.y }));
} }
get paRef(): graphicData.RelatedRef {
return new graphicData.RelatedRef();
}
set paRef(ref: graphicData.RelatedRef) {
this.data.paRef = ref;
}
get pbRef(): graphicData.RelatedRef {
return new graphicData.RelatedRef();
}
set pbRef(ref: graphicData.RelatedRef) {
this.data.paRef = ref;
}
get pcRef(): graphicData.RelatedRef {
return new graphicData.RelatedRef();
}
set pcRef(ref: graphicData.RelatedRef) {
this.data.paRef = ref;
}
clone(): TurnoutData { clone(): TurnoutData {
return new TurnoutData(this.data.cloneMessage()); return new TurnoutData(this.data.cloneMessage());
} }

View File

@ -100,7 +100,7 @@ export class IscsFan extends JlGraphic {
export class IscsFanTemplate extends JlGraphicTemplate<IscsFan> { export class IscsFanTemplate extends JlGraphicTemplate<IscsFan> {
fanTextures?: FanTextures; fanTextures?: FanTextures;
constructor() { constructor() {
super(IscsFan.Type); super(IscsFan.Type, {});
} }
new(): IscsFan { new(): IscsFan {
if (this.fanTextures) { if (this.fanTextures) {

View File

@ -13,15 +13,9 @@ export class IscsFanDraw extends GraphicDrawAssistant<
> { > {
_iscsFan: IscsFan | null = null; _iscsFan: IscsFan | null = null;
constructor(app: JlDrawApp, createData: () => IIscsFanData) { constructor(app: JlDrawApp) {
const template = new IscsFanTemplate(); const template = new IscsFanTemplate();
super( super(app, template, 'svguse:../drawIcon.svg#icon-fans', '风机');
app,
template,
createData,
'svguse:../drawIcon.svg#icon-fans',
'风机'
);
IscsFanInteraction.init(app); IscsFanInteraction.init(app);
} }

View File

@ -90,7 +90,7 @@ export class LinkTemplate extends JlGraphicTemplate<Link> {
lineColor: string; lineColor: string;
segmentsCount: number; segmentsCount: number;
constructor() { constructor() {
super(Link.Type); super(Link.Type, {});
this.lineWidth = 2; this.lineWidth = 2;
this.lineColor = '#000000'; this.lineColor = '#000000';
this.curve = false; this.curve = false;

View File

@ -61,14 +61,8 @@ export class LinkDraw extends GraphicDrawAssistant<LinkTemplate, ILinkData> {
}, },
}); });
constructor(app: JlDrawApp, createData: () => ILinkData) { constructor(app: JlDrawApp) {
super( super(app, new LinkTemplate(), 'sym_o_horizontal_rule', '轨道Link');
app,
new LinkTemplate(),
createData,
'sym_o_horizontal_rule',
'轨道Link'
);
this.container.addChild(this.graphic); this.container.addChild(this.graphic);
this.graphicTemplate.curve = true; this.graphicTemplate.curve = true;

View File

@ -276,7 +276,7 @@ export class PlatformTemplate extends JlGraphicTemplate<Platform> {
hasdoor: boolean; hasdoor: boolean;
direction: string; direction: string;
constructor() { constructor() {
super(Platform.Type); super(Platform.Type, {});
this.hasdoor = true; this.hasdoor = true;
this.direction = 'up'; this.direction = 'up';
} }

View File

@ -28,11 +28,10 @@ export class PlatformDraw extends GraphicDrawAssistant<
platformGraphic: childJlGraphic = new rectGraphic(); platformGraphic: childJlGraphic = new rectGraphic();
doorGraphic: childJlGraphic = new doorGraphic(); doorGraphic: childJlGraphic = new doorGraphic();
constructor(app: JlDrawApp, createData: () => IPlatformData) { constructor(app: JlDrawApp) {
super( super(
app, app,
new PlatformTemplate(), new PlatformTemplate(),
createData,
'svguse:../../drawIcon.svg#icon-platform', 'svguse:../../drawIcon.svg#icon-platform',
'站台Platform' '站台Platform'
); );

View File

@ -60,7 +60,7 @@ export class PolygonTemplate extends JlGraphicTemplate<Polygon> {
lineWidth: number; lineWidth: number;
lineColor: string; lineColor: string;
constructor() { constructor() {
super(Polygon.Type); super(Polygon.Type, {});
this.lineWidth = polygonConsts.lineWidth; this.lineWidth = polygonConsts.lineWidth;
this.lineColor = polygonConsts.lineColor; this.lineColor = polygonConsts.lineColor;
} }

View File

@ -37,14 +37,8 @@ export class PolygonDraw extends GraphicDrawAssistant<
points: Point[] = []; points: Point[] = [];
polygonGraphic: Graphics = new Graphics(); polygonGraphic: Graphics = new Graphics();
constructor(app: JlDrawApp, createData: () => IPolygonData) { constructor(app: JlDrawApp) {
super( super(app, new PolygonTemplate(), 'sym_o_square', '多边形Polygon');
app,
new PolygonTemplate(),
createData,
'sym_o_square',
'多边形Polygon'
);
this.container.addChild(this.polygonGraphic); this.container.addChild(this.polygonGraphic);
PolygonPointsEditPlugin.init(app); PolygonPointsEditPlugin.init(app);
} }

View File

@ -87,7 +87,7 @@ export class RectTemplate extends JlGraphicTemplate<Rect> {
lineWidth: number; lineWidth: number;
lineColor: string; lineColor: string;
constructor() { constructor() {
super(Rect.Type); super(Rect.Type, {});
this.lineWidth = rectConsts.lineWidth; this.lineWidth = rectConsts.lineWidth;
this.lineColor = rectConsts.lineColor; this.lineColor = rectConsts.lineColor;
} }

View File

@ -18,8 +18,8 @@ export class RectDraw extends GraphicDrawAssistant<RectTemplate, IRectData> {
point2: Point | null = null; point2: Point | null = null;
rectGraphic: Graphics = new Graphics(); rectGraphic: Graphics = new Graphics();
constructor(app: JlDrawApp, createData: () => IRectData) { constructor(app: JlDrawApp) {
super(app, new RectTemplate(), createData, 'sym_o_square', '矩形Rect'); super(app, new RectTemplate(), 'sym_o_square', '矩形Rect');
this.container.addChild(this.rectGraphic); this.container.addChild(this.rectGraphic);
rectInteraction.init(app); rectInteraction.init(app);
} }

View File

@ -200,7 +200,7 @@ export enum SectionPort {
export class SectionTemplate extends JlGraphicTemplate<Section> { export class SectionTemplate extends JlGraphicTemplate<Section> {
constructor() { constructor() {
super(Section.Type); super(Section.Type, {});
} }
new() { new() {
return new Section(); return new Section();

View File

@ -40,14 +40,8 @@ export class SectionDraw extends GraphicDrawAssistant<
points: Point[] = []; points: Point[] = [];
graphic = new Graphics(); graphic = new Graphics();
constructor(app: JlDrawApp, createData: () => ISectionData) { constructor(app: JlDrawApp) {
super( super(app, new SectionTemplate(), 'sym_o_timeline', '区段Section');
app,
new SectionTemplate(),
createData,
'sym_o_timeline',
'区段Section'
);
this.container.addChild(this.graphic); this.container.addChild(this.graphic);
SectionPointEditPlugin.init(app); SectionPointEditPlugin.init(app);
@ -56,9 +50,9 @@ export class SectionDraw extends GraphicDrawAssistant<
onLeftDown(e: FederatedMouseEvent): void { onLeftDown(e: FederatedMouseEvent): void {
const { x, y } = this.toCanvasCoordinates(e.global); const { x, y } = this.toCanvasCoordinates(e.global);
const p = new Point(x, y); const p = new Point(x, y);
// this.points.pop();
this.points.push(p); this.points.push(p);
} }
onRightClick(): void { onRightClick(): void {
if (this.points.length < 2) { if (this.points.length < 2) {
this.finish(); this.finish();
@ -66,6 +60,7 @@ export class SectionDraw extends GraphicDrawAssistant<
} }
this.createAndStore(true); this.createAndStore(true);
} }
onEsc(): void { onEsc(): void {
if (this.points.length < 2) { if (this.points.length < 2) {
this.finish(); this.finish();
@ -87,12 +82,14 @@ export class SectionDraw extends GraphicDrawAssistant<
}); });
this.graphic.lineTo(cp.x, cp.y); this.graphic.lineTo(cp.x, cp.y);
} }
prepareData(data: ISectionData): boolean { prepareData(data: ISectionData): boolean {
data.points = this.points; data.points = this.points;
data.code = 'G000'; data.code = 'G000';
return true; return true;
} }
clearCache(): void { clearCache(): void {
this.points = []; this.points = [];
this.graphic.clear(); this.graphic.clear();
@ -125,14 +122,12 @@ function buildAbsorbablePositions(section: Section): AbsorbablePosition[] {
other.localToCanvasPoint(other.getStartPoint()), other.localToCanvasPoint(other.getStartPoint()),
other.localToCanvasPoint(other.getEndPoint()), other.localToCanvasPoint(other.getEndPoint()),
]; ];
// const apa = new AbsorbablePoint(ps);
// const apb = new AbsorbablePoint(pe);
const { width, height } = section.getGraphicApp().canvas; const { width, height } = section.getGraphicApp().canvas;
const xs = new AbsorbableLine({ x: 0, y: ps.y }, { x: width, y: ps.y }); const xs = new AbsorbableLine({ x: 0, y: ps.y }, { x: width, y: ps.y });
const ys = new AbsorbableLine({ x: ps.x, y: 0 }, { x: ps.x, y: height }); const ys = new AbsorbableLine({ x: ps.x, y: 0 }, { x: ps.x, y: height });
const xe = new AbsorbableLine({ x: 0, y: pe.y }, { x: width, y: pe.y }); const xe = new AbsorbableLine({ x: 0, y: pe.y }, { x: width, y: pe.y });
const ye = new AbsorbableLine({ x: pe.x, y: 0 }, { x: pe.x, y: height }); const ye = new AbsorbableLine({ x: pe.x, y: 0 }, { x: pe.x, y: height });
aps.push(/* apa, apb, */ xs, ys, xe, ye); aps.push(xs, ys, xe, ye);
}); });
const turnouts = section.queryStore.queryByType<Turnout>(Turnout.Type); const turnouts = section.queryStore.queryByType<Turnout>(Turnout.Type);
@ -216,9 +211,12 @@ export class SectionPointEditPlugin extends GraphicInteractionPlugin<Section> {
g.lineGraphic.eventMode = 'static'; g.lineGraphic.eventMode = 'static';
g.lineGraphic.cursor = 'pointer'; g.lineGraphic.cursor = 'pointer';
g.lineGraphic.hitArea = new SectionGraphicHitArea(g); g.lineGraphic.hitArea = new SectionGraphicHitArea(g);
g.transformSave = true;
g.labelGraphic.eventMode = 'static'; g.labelGraphic.eventMode = 'static';
g.labelGraphic.cursor = 'pointer'; g.labelGraphic.cursor = 'pointer';
g.labelGraphic.draggable = true; g.labelGraphic.draggable = true;
g.labelGraphic.transformSave = true;
g.labelGraphic.name = 'label';
g.on('selected', this.onSelected, this); g.on('selected', this.onSelected, this);
g.on('unselected', this.onUnselected, this); g.on('unselected', this.onUnselected, this);
} }

View File

@ -158,7 +158,7 @@ export class Station extends JlGraphic {
export class StationTemplate extends JlGraphicTemplate<Station> { export class StationTemplate extends JlGraphicTemplate<Station> {
hasControl: boolean; hasControl: boolean;
constructor() { constructor() {
super(Station.Type); super(Station.Type, {});
this.hasControl = true; this.hasControl = true;
} }
new(): Station { new(): Station {

View File

@ -19,11 +19,10 @@ export class StationDraw extends GraphicDrawAssistant<
IStationData IStationData
> { > {
codeGraph: Station; codeGraph: Station;
constructor(app: JlDrawApp, createData: () => IStationData) { constructor(app: JlDrawApp) {
super( super(
app, app,
new StationTemplate(), new StationTemplate(),
createData,
'svguse:../../drawIcon.svg#icon-station', 'svguse:../../drawIcon.svg#icon-station',
'车站Station' '车站Station'
); );
@ -34,7 +33,7 @@ export class StationDraw extends GraphicDrawAssistant<
bind(): void { bind(): void {
super.bind(); super.bind();
this.codeGraph.loadData(this.createGraphicData()); this.codeGraph.loadData(this.graphicTemplate.datas);
this.codeGraph.doRepaint(); this.codeGraph.doRepaint();
} }

View File

@ -129,7 +129,7 @@ export class StationLine extends JlGraphic {
export class StationLineTemplate extends JlGraphicTemplate<StationLine> { export class StationLineTemplate extends JlGraphicTemplate<StationLine> {
hasTransfer: boolean; hasTransfer: boolean;
constructor() { constructor() {
super(StationLine.Type); super(StationLine.Type, {});
this.hasTransfer = true; this.hasTransfer = true;
} }
new(): StationLine { new(): StationLine {

View File

@ -25,11 +25,10 @@ export class StationLineDraw extends GraphicDrawAssistant<
IStationLineData IStationLineData
> { > {
codeGraph: StationLine; codeGraph: StationLine;
constructor(app: JlDrawApp, createData: () => IStationLineData) { constructor(app: JlDrawApp) {
super( super(
app, app,
new StationLineTemplate(), new StationLineTemplate(),
createData,
'svguse:../../drawIcon.svg#icon-station', 'svguse:../../drawIcon.svg#icon-station',
'车站StationLine' '车站StationLine'
); );
@ -40,7 +39,7 @@ export class StationLineDraw extends GraphicDrawAssistant<
bind(): void { bind(): void {
super.bind(); super.bind();
this.codeGraph.loadData(this.createGraphicData()); this.codeGraph.loadData(this.graphicTemplate.datas);
this.codeGraph.doRepaint(); this.codeGraph.doRepaint();
} }

View File

@ -200,7 +200,7 @@ export class TrainTemplate extends JlGraphicTemplate<Train> {
trainDirection: string; trainDirection: string;
hasBorder: boolean; hasBorder: boolean;
constructor() { constructor() {
super(Train.Type); super(Train.Type, {});
this.trainDirection = 'left'; this.trainDirection = 'left';
this.hasBorder = true; this.hasBorder = true;
} }

View File

@ -23,14 +23,8 @@ export class TrainDraw extends GraphicDrawAssistant<TrainTemplate, ITrainData> {
headLeft: TrainHead; headLeft: TrainHead;
trainbody: TrainBody; trainbody: TrainBody;
constructor(app: JlDrawApp, createData: () => ITrainData) { constructor(app: JlDrawApp) {
super( super(app, new TrainTemplate(), 'directions_bus_filled', '列车Train');
app,
new TrainTemplate(),
createData,
'directions_bus_filled',
'列车Train'
);
this.headLeft = new TrainHead('left'); this.headLeft = new TrainHead('left');
this.trainbody = new TrainBody(); this.trainbody = new TrainBody();
this.container.addChild(this.headLeft); this.container.addChild(this.headLeft);

View File

@ -30,7 +30,7 @@ export class TrainLine extends JlGraphic {
export class ItrainLineTemplate extends JlGraphicTemplate<TrainLine> { export class ItrainLineTemplate extends JlGraphicTemplate<TrainLine> {
trainTextures?: Texture; trainTextures?: Texture;
constructor() { constructor() {
super(TrainLine.Type); super(TrainLine.Type, {});
} }
new(): TrainLine { new(): TrainLine {
if (this.trainTextures) { if (this.trainTextures) {

View File

@ -13,9 +13,9 @@ export class TrainLineDraw extends GraphicDrawAssistant<
> { > {
train: TrainLine | null = null; train: TrainLine | null = null;
constructor(app: JlDrawApp, createData: () => ITrainLineData) { constructor(app: JlDrawApp) {
const template = new ItrainLineTemplate(); const template = new ItrainLineTemplate();
super(app, template, createData, 'directions_bus_filled', '列车线网'); super(app, template, 'directions_bus_filled', '列车线网');
ItrainLineInteraction.init(app); ItrainLineInteraction.init(app);
} }

View File

@ -38,8 +38,8 @@ export class TrainWindowDraw extends GraphicDrawAssistant<
ITrainWindowData ITrainWindowData
> { > {
trainWindowGraph: TrainWindow; trainWindowGraph: TrainWindow;
constructor(app: JlDrawApp, createData: () => ITrainWindowData) { constructor(app: JlDrawApp) {
super(app, new TrainWindowTemplate(), createData, 'sym_o_square', '不展示'); super(app, new TrainWindowTemplate(), 'sym_o_square', '不展示');
this.trainWindowGraph = this.graphicTemplate.new(); this.trainWindowGraph = this.graphicTemplate.new();
this.container.addChild(this.trainWindowGraph); this.container.addChild(this.trainWindowGraph);
TrainWindowInteraction.init(app); TrainWindowInteraction.init(app);
@ -47,7 +47,7 @@ export class TrainWindowDraw extends GraphicDrawAssistant<
bind(): void { bind(): void {
super.bind(); super.bind();
this.trainWindowGraph.loadData(this.createGraphicData()); this.trainWindowGraph.loadData(this.graphicTemplate.datas);
this.trainWindowGraph.doRepaint(); this.trainWindowGraph.doRepaint();
} }
@ -87,7 +87,7 @@ export class TrainWindowDraw extends GraphicDrawAssistant<
const offsetX = (direction * TrainWindowConsts.width + interval) * i; const offsetX = (direction * TrainWindowConsts.width + interval) * i;
point.x += offsetX; point.x += offsetX;
const trainWindow = new TrainWindow(); const trainWindow = new TrainWindow();
trainWindow.loadData(this.createGraphicData()); trainWindow.loadData(this.graphicTemplate.datas);
trainWindow.position.copyFrom(point); trainWindow.position.copyFrom(point);
trainWindow.id = GraphicIdGenerator.next(); trainWindow.id = GraphicIdGenerator.next();
trainWindows.push(trainWindow); trainWindows.push(trainWindow);
@ -109,7 +109,7 @@ export class TrainWindowDraw extends GraphicDrawAssistant<
for (let i = 0; i < points.length - 1; i++) { for (let i = 0; i < points.length - 1; i++) {
const x = (points[i].x + points[i + 1].x) / 2; const x = (points[i].x + points[i + 1].x) / 2;
const trainWindow = new TrainWindow(); const trainWindow = new TrainWindow();
trainWindow.loadData(this.createGraphicData()); trainWindow.loadData(this.graphicTemplate.datas);
trainWindow.position.set( trainWindow.position.set(
x, x,
points[i].y - direction * TrainWindowConsts.offsetSection points[i].y - direction * TrainWindowConsts.offsetSection

View File

@ -112,6 +112,8 @@ export class Turnout extends JlGraphic {
this.graphics.label.style.fill = '#0f0'; this.graphics.label.style.fill = '#0f0';
this.graphics.label.setVectorFontSize(16); this.graphics.label.setVectorFontSize(16);
this.graphics.label.position.set(20, 20); this.graphics.label.position.set(20, 20);
this.graphics.label.transformSave = true;
this.graphics.label.name = 'label';
this.addChild(this.graphics.label); this.addChild(this.graphics.label);
} }
@ -282,7 +284,7 @@ export enum TurnoutPort {
export class TurnoutTemplate extends JlGraphicTemplate<Turnout> { export class TurnoutTemplate extends JlGraphicTemplate<Turnout> {
constructor() { constructor() {
super(Turnout.Type); super(Turnout.Type, {});
} }
new() { new() {

View File

@ -37,14 +37,8 @@ export class TurnoutDraw extends GraphicDrawAssistant<
ITurnoutData ITurnoutData
> { > {
turnout: Turnout; turnout: Turnout;
constructor(app: JlDrawApp, createData: () => ITurnoutData) { constructor(app: JlDrawApp) {
super( super(app, new TurnoutTemplate(), 'sym_o_ramp_left', '道岔Turnout');
app,
new TurnoutTemplate(),
createData,
'sym_o_ramp_left',
'道岔Turnout'
);
this.turnout = this.graphicTemplate.new(); this.turnout = this.graphicTemplate.new();
this.container.addChild(this.turnout); this.container.addChild(this.turnout);