图形绘制的引入修改

This commit is contained in:
joylink_zhaoerwei 2023-09-01 10:02:58 +08:00
parent a2c0bceb2d
commit 32cfc5f329
18 changed files with 77 additions and 83 deletions

View File

@ -5,7 +5,7 @@ import {
GraphicDrawAssistant,
GraphicIdGenerator,
GraphicInteractionPlugin,
JlDrawApp,
IDrawApp,
JlGraphic,
distance2,
} from 'src/jl-graphic';
@ -16,7 +16,7 @@ import {
AxleCountingTemplate,
AxleCountingConsts,
} from './AxleCounting';
import { Section, SectionPort, SectionType } from '../section/Section';
import { Section, SectionPort } from '../section/Section';
import { Turnout, TurnoutPort } from '../turnout/Turnout';
import { IRelatedRefData, createRelatedRefProto } from '../CommonGraphics';
import { Signal } from '../signal/Signal';
@ -42,7 +42,7 @@ export class AxleCountingDraw extends GraphicDrawAssistant<
IAxleCountingData
> {
codeGraph: AxleCounting;
constructor(app: JlDrawApp, template: AxleCountingTemplate) {
constructor(app: IDrawApp, template: AxleCountingTemplate) {
super(app, template, 'sym_o_circle', '不展示');
this.codeGraph = this.graphicTemplate.new();
this.container.addChild(this.codeGraph);
@ -198,12 +198,6 @@ export class AxleCountingDraw extends GraphicDrawAssistant<
if (axleCountingPs.y > height.y) {
direction = -1;
}
if (
section.datas.sectionType === SectionType.Logic ||
section.datas.children.includes(refDevice.id)
) {
return;
}
if (refDevice.type == Section.Type || refDevice.type == Turnout.Type)
this.draw(
axleCountingPs,
@ -352,10 +346,10 @@ function buildAbsorbablePositions(
export class AxleCountingInteraction extends GraphicInteractionPlugin<AxleCounting> {
static Name = 'AxleCounting_transform';
constructor(app: JlDrawApp) {
constructor(app: IDrawApp) {
super(AxleCountingInteraction.Name, app);
}
static init(app: JlDrawApp) {
static init(app: IDrawApp) {
return new AxleCountingInteraction(app);
}
filter(...grahpics: JlGraphic[]): AxleCounting[] | undefined {

View File

@ -10,11 +10,11 @@ import {
import {
AbsorbablePosition,
DraggablePoint,
GraphicApp,
IGraphicApp,
GraphicDrawAssistant,
GraphicInteractionPlugin,
GraphicTransformEvent,
JlDrawApp,
IDrawApp,
JlGraphic,
KeyListener,
calculateMirrorPoint,
@ -61,7 +61,7 @@ export class LinkDraw extends GraphicDrawAssistant<LinkTemplate, ILinkData> {
},
});
constructor(app: JlDrawApp) {
constructor(app: IDrawApp) {
super(app, new LinkTemplate(), 'sym_o_horizontal_rule', '轨道Link');
this.container.addChild(this.graphic);
this.graphicTemplate.curve = true;
@ -268,10 +268,10 @@ function onEditPointCreate(
*/
export class LinkPointsEditPlugin extends GraphicInteractionPlugin<Link> {
static Name = 'LinkPointsDrag';
constructor(app: GraphicApp) {
constructor(app: IGraphicApp) {
super(LinkPointsEditPlugin.Name, app);
}
static init(app: GraphicApp): LinkPointsEditPlugin {
static init(app: IGraphicApp): LinkPointsEditPlugin {
return new LinkPointsEditPlugin(app);
}
filter(...grahpics: JlGraphic[]): Link[] | undefined {

View File

@ -1,8 +1,8 @@
import {
GraphicApp,
IGraphicApp,
GraphicDrawAssistant,
GraphicInteractionPlugin,
JlDrawApp,
IDrawApp,
JlGraphic,
linePoint,
} from 'src/jl-graphic';
@ -17,7 +17,7 @@ export class LogicSectionDraw extends GraphicDrawAssistant<
> {
points: Point[] = [];
graphic = new Graphics();
constructor(app: JlDrawApp, template: LogicSectionTemplate) {
constructor(app: IDrawApp, template: LogicSectionTemplate) {
super(app, template, 'sym_o_timeline', '不展示');
this.container.addChild(this.graphic);
LogicSectionEditPlugin.init(app);
@ -60,10 +60,10 @@ export class LogicSectionGraphicHitArea implements IHitArea {
export class LogicSectionEditPlugin extends GraphicInteractionPlugin<LogicSection> {
static Name = 'LogicSectionInteraction';
constructor(app: GraphicApp) {
constructor(app: IGraphicApp) {
super(LogicSectionEditPlugin.Name, app);
}
static init(app: GraphicApp) {
static init(app: IGraphicApp) {
return new LogicSectionEditPlugin(app);
}
filter(...grahpics: JlGraphic[]): LogicSection[] | undefined {

View File

@ -1,9 +1,9 @@
import {
GraphicDrawAssistant,
JlDrawApp,
IDrawApp,
linePoint,
GraphicInteractionPlugin,
GraphicApp,
IGraphicApp,
JlGraphic,
DraggablePoint,
GraphicTransformEvent,
@ -37,7 +37,7 @@ export class PathLineDraw extends GraphicDrawAssistant<
code = '';
graphic: Graphics = new Graphics();
constructor(app: JlDrawApp, template: PathLineTemplate) {
constructor(app: IDrawApp, template: PathLineTemplate) {
super(app, template, 'sym_o_horizontal_rule', '不展示');
this.container.addChild(this.graphic);
PathLinePointsEditPlugin.init(app);
@ -106,10 +106,10 @@ export class PathLineGraphicHitArea implements IHitArea {
export class PathLinePointsEditPlugin extends GraphicInteractionPlugin<PathLine> {
static Name = 'LinkPointsDrag';
constructor(app: GraphicApp) {
constructor(app: IGraphicApp) {
super(PathLinePointsEditPlugin.Name, app);
}
static init(app: GraphicApp): PathLinePointsEditPlugin {
static init(app: IGraphicApp): PathLinePointsEditPlugin {
return new PathLinePointsEditPlugin(app);
}
filter(...grahpics: JlGraphic[]): PathLine[] | undefined {

View File

@ -372,7 +372,7 @@ export class Platform extends JlGraphic {
return this.datas.code;
}
doRepaint(): void {
const station = this.queryStore.queryByCodeAndType<Station>(
const station = this.getGraphicApp().queryStore.queryByCodeAndType<Station>(
this.states.rtuId > 9 ? '' + this.states.rtuId : '0' + this.states.rtuId,
Station.Type
);

View File

@ -4,7 +4,7 @@ import {
AbsorbablePosition,
GraphicDrawAssistant,
GraphicInteractionPlugin,
JlDrawApp,
IDrawApp,
JlGraphic,
} from 'src/jl-graphic';
@ -19,7 +19,7 @@ export class PlatformDraw extends GraphicDrawAssistant<
IPlatformData
> {
platformGraphic: Platform;
constructor(app: JlDrawApp, template: PlatformTemplate) {
constructor(app: IDrawApp, template: PlatformTemplate) {
super(
app,
template,
@ -76,10 +76,10 @@ function buildAbsorbablePositions(platform: Platform): AbsorbablePosition[] {
export class platformInteraction extends GraphicInteractionPlugin<Platform> {
static Name = 'platform_transform';
constructor(app: JlDrawApp) {
constructor(app: IDrawApp) {
super(platformInteraction.Name, app);
}
static init(app: JlDrawApp) {
static init(app: IDrawApp) {
return new platformInteraction(app);
}
filter(...grahpics: JlGraphic[]): Platform[] | undefined {

View File

@ -7,11 +7,11 @@ import {
} from 'pixi.js';
import {
DraggablePoint,
GraphicApp,
IGraphicApp,
GraphicDrawAssistant,
GraphicInteractionPlugin,
GraphicTransformEvent,
JlDrawApp,
IDrawApp,
JlGraphic,
linePoint,
} from 'src/jl-graphic';
@ -37,7 +37,7 @@ export class PolygonDraw extends GraphicDrawAssistant<
points: Point[] = [];
polygonGraphic: Graphics = new Graphics();
constructor(app: JlDrawApp, template: PolygonTemplate) {
constructor(app: IDrawApp, template: PolygonTemplate) {
super(app, template, 'sym_o_square', '多边形Polygon');
this.container.addChild(this.polygonGraphic);
PolygonPointsEditPlugin.init(app);
@ -151,10 +151,10 @@ function onEditPointCreate(g: ILineGraphic, dp: DraggablePoint): void {
*/
export class PolygonPointsEditPlugin extends GraphicInteractionPlugin<Polygon> {
static Name = 'PolygonPointsDrag';
constructor(app: GraphicApp) {
constructor(app: IGraphicApp) {
super(PolygonPointsEditPlugin.Name, app);
}
static init(app: GraphicApp): PolygonPointsEditPlugin {
static init(app: IGraphicApp): PolygonPointsEditPlugin {
return new PolygonPointsEditPlugin(app);
}
filter(...grahpics: JlGraphic[]): Polygon[] | undefined {

View File

@ -2,7 +2,7 @@ import { FederatedPointerEvent, Graphics, Point, IHitArea } from 'pixi.js';
import {
GraphicDrawAssistant,
GraphicInteractionPlugin,
JlDrawApp,
IDrawApp,
JlGraphic,
pointBox,
} from 'src/jl-graphic';
@ -18,7 +18,7 @@ export class RectDraw extends GraphicDrawAssistant<RectTemplate, IRectData> {
point2: Point | null = null;
rectGraphic: Graphics = new Graphics();
constructor(app: JlDrawApp, template: RectTemplate) {
constructor(app: IDrawApp, template: RectTemplate) {
super(app, template, 'sym_o_square', '矩形Rect');
this.container.addChild(this.rectGraphic);
rectInteraction.init(app);
@ -88,10 +88,10 @@ export class RectGraphicHitArea implements IHitArea {
export class rectInteraction extends GraphicInteractionPlugin<Rect> {
static Name = 'platform_transform';
constructor(app: JlDrawApp) {
constructor(app: IDrawApp) {
super(rectInteraction.Name, app);
}
static init(app: JlDrawApp) {
static init(app: IDrawApp) {
return new rectInteraction(app);
}
filter(...grahpics: JlGraphic[]): Rect[] | undefined {

View File

@ -1,10 +1,10 @@
import {
GraphicDrawAssistant,
JlDrawApp,
IDrawApp,
JlGraphic,
GraphicInteractionPlugin,
linePoint,
GraphicApp,
IGraphicApp,
AbsorbablePosition,
DraggablePoint,
GraphicTransformEvent,
@ -40,7 +40,7 @@ export class RunLineDraw extends GraphicDrawAssistant<
points: Point[] = [];
graphic: Graphics = new Graphics();
constructor(app: JlDrawApp, template: RunLineTemplate) {
constructor(app: IDrawApp, template: RunLineTemplate) {
super(app, template, 'sym_o_horizontal_rule', '运行线RunLine');
this.container.addChild(this.graphic);
RunLinePointsEditPlugin.init(app);
@ -162,10 +162,10 @@ function onEditPointCreate(
export class RunLinePointsEditPlugin extends GraphicInteractionPlugin<RunLine> {
static Name = 'LinkPointsDrag';
constructor(app: GraphicApp) {
constructor(app: IGraphicApp) {
super(RunLinePointsEditPlugin.Name, app);
}
static init(app: GraphicApp): RunLinePointsEditPlugin {
static init(app: IGraphicApp): RunLinePointsEditPlugin {
return new RunLinePointsEditPlugin(app);
}
filter(...grahpics: JlGraphic[]): RunLine[] | undefined {

View File

@ -1,13 +1,13 @@
import {
ChildTransform,
DraggablePoint,
GraphicApp,
IGraphicApp,
GraphicDrawAssistant,
GraphicInteractionPlugin,
GraphicRelation,
GraphicTransform,
GraphicTransformEvent,
JlDrawApp,
IDrawApp,
JlGraphic,
VectorText,
calculateLineMidpoint,
@ -60,7 +60,7 @@ export class SectionDraw extends GraphicDrawAssistant<
points: Point[] = [];
graphic = new Graphics();
constructor(app: JlDrawApp, template: SectionTemplate) {
constructor(app: IDrawApp, template: SectionTemplate) {
super(app, template, 'sym_o_timeline', '区段Section');
this.container.addChild(this.graphic);
@ -400,12 +400,12 @@ export class SectionPointEditPlugin extends GraphicInteractionPlugin<Section> {
static Name = 'SectionPointDrag';
drawAssistant: SectionDraw;
constructor(app: GraphicApp, da: SectionDraw) {
constructor(app: IGraphicApp, da: SectionDraw) {
super(SectionPointEditPlugin.Name, app);
this.drawAssistant = da;
app.registerMenu(SectionEditMenu);
}
static init(app: GraphicApp, da: SectionDraw) {
static init(app: IGraphicApp, da: SectionDraw) {
return new SectionPointEditPlugin(app, da);
}
filter(...grahpics: JlGraphic[]): Section[] | undefined {

View File

@ -4,7 +4,7 @@ import {
GraphicIdGenerator,
GraphicInteractionPlugin,
GraphicRelationParam,
JlDrawApp,
IDrawApp,
JlGraphic,
linePoint,
} from 'src/jl-graphic';
@ -25,7 +25,7 @@ export class SeparatorDraw extends GraphicDrawAssistant<
ISeparatorData
> {
SeparatorGraph: Separator;
constructor(app: JlDrawApp, template: SeparatorTemplate) {
constructor(app: IDrawApp, template: SeparatorTemplate) {
super(app, template, 'sym_o_square', '不展示');
this.SeparatorGraph = this.graphicTemplate.new();
this.container.addChild(this.SeparatorGraph);
@ -258,10 +258,10 @@ export class SeparatorGraphicHitArea implements IHitArea {
export class SeparatorInteraction extends GraphicInteractionPlugin<Separator> {
static Name = 'Separator_transform';
constructor(app: JlDrawApp) {
constructor(app: IDrawApp) {
super(SeparatorInteraction.Name, app);
}
static init(app: JlDrawApp) {
static init(app: IDrawApp) {
return new SeparatorInteraction(app);
}
filter(...grahpics: JlGraphic[]): Separator[] | undefined {

View File

@ -5,7 +5,7 @@ import {
GraphicDrawAssistant,
GraphicInteractionPlugin,
GraphicTransformEvent,
JlDrawApp,
IDrawApp,
JlGraphic,
} from 'src/jl-graphic';
@ -21,7 +21,7 @@ export class SignalDraw extends GraphicDrawAssistant<
> {
_signal: Signal | null = null;
constructor(app: JlDrawApp, template: SignalTemplate) {
constructor(app: IDrawApp, template: SignalTemplate) {
super(
app,
template,
@ -129,10 +129,10 @@ function buildCodeAbsorbablePositions(signal: Signal): AbsorbablePosition[] {
export class signalInteraction extends GraphicInteractionPlugin<Signal> {
static Name = 'signal_transform';
constructor(app: JlDrawApp) {
constructor(app: IDrawApp) {
super(signalInteraction.Name, app);
}
static init(app: JlDrawApp) {
static init(app: IDrawApp) {
return new signalInteraction(app);
}
filter(...grahpics: JlGraphic[]): Signal[] | undefined {

View File

@ -4,7 +4,7 @@ import {
AbsorbablePosition,
GraphicDrawAssistant,
GraphicInteractionPlugin,
JlDrawApp,
IDrawApp,
JlGraphic,
} from 'src/jl-graphic';
@ -19,7 +19,7 @@ export class StationDraw extends GraphicDrawAssistant<
IStationData
> {
codeGraph: Station;
constructor(app: JlDrawApp, template: StationTemplate) {
constructor(app: IDrawApp, template: StationTemplate) {
super(
app,
template,
@ -72,10 +72,10 @@ function buildAbsorbablePositions(station: Station): AbsorbablePosition[] {
export class stationInteraction extends GraphicInteractionPlugin<Station> {
static Name = 'station_transform';
constructor(app: JlDrawApp) {
constructor(app: IDrawApp) {
super(stationInteraction.Name, app);
}
static init(app: JlDrawApp) {
static init(app: IDrawApp) {
return new stationInteraction(app);
}
filter(...grahpics: JlGraphic[]): Station[] | undefined {

View File

@ -4,7 +4,7 @@ import {
AbsorbablePosition,
GraphicDrawAssistant,
GraphicInteractionPlugin,
JlDrawApp,
IDrawApp,
JlGraphic,
} from 'src/jl-graphic';
@ -24,7 +24,7 @@ export class StationLineDraw extends GraphicDrawAssistant<
IStationLineData
> {
codeGraph: StationLine;
constructor(app: JlDrawApp, template: StationLineTemplate) {
constructor(app: IDrawApp, template: StationLineTemplate) {
super(
app,
template,
@ -86,10 +86,10 @@ function buildAbsorbablePositions(Station: StationLine): AbsorbablePosition[] {
export class stationLineInteraction extends GraphicInteractionPlugin<StationLine> {
static Name = 'stationLine_transform';
static stationLine: StationLine;
constructor(app: JlDrawApp) {
constructor(app: IDrawApp) {
super(stationLineInteraction.Name, app);
}
static init(app: JlDrawApp) {
static init(app: IDrawApp) {
return new stationLineInteraction(app);
}
filter(...grahpics: JlGraphic[]): StationLine[] | undefined {

View File

@ -2,7 +2,7 @@ import { Point, FederatedPointerEvent } from 'pixi.js';
import {
GraphicDrawAssistant,
GraphicInteractionPlugin,
JlDrawApp,
IDrawApp,
JlGraphic,
} from 'src/jl-graphic';
@ -15,7 +15,7 @@ export interface ITrainDrawOptions {
export class TrainDraw extends GraphicDrawAssistant<TrainTemplate, ITrainData> {
_Train: Train | null = null;
constructor(app: JlDrawApp, template: TrainTemplate) {
constructor(app: IDrawApp, template: TrainTemplate) {
super(app, template, 'directions_bus_filled', '不展示');
trainInteraction.init(app);
}
@ -48,10 +48,10 @@ export class TrainDraw extends GraphicDrawAssistant<TrainTemplate, ITrainData> {
export class trainInteraction extends GraphicInteractionPlugin<Train> {
static Name = 'train_transform';
constructor(app: JlDrawApp) {
constructor(app: IDrawApp) {
super(trainInteraction.Name, app);
}
static init(app: JlDrawApp) {
static init(app: IDrawApp) {
return new trainInteraction(app);
}
filter(...grahpics: JlGraphic[]): Train[] | undefined {

View File

@ -2,7 +2,7 @@ import { FederatedMouseEvent, Point } from 'pixi.js';
import {
GraphicDrawAssistant,
GraphicInteractionPlugin,
JlDrawApp,
IDrawApp,
JlGraphic,
} from 'src/jl-graphic';
import { ITrainLineData, TrainLine, ItrainLineTemplate } from './TrainLine';
@ -13,7 +13,7 @@ export class TrainLineDraw extends GraphicDrawAssistant<
> {
train: TrainLine | null = null;
constructor(app: JlDrawApp, template: ItrainLineTemplate) {
constructor(app: IDrawApp, template: ItrainLineTemplate) {
super(app, template, 'directions_bus_filled', '列车线网');
ItrainLineInteraction.init(app);
}
@ -51,10 +51,10 @@ export class TrainLineDraw extends GraphicDrawAssistant<
export class ItrainLineInteraction extends GraphicInteractionPlugin<TrainLine> {
static Name = 'trainLine_transform';
constructor(app: JlDrawApp) {
constructor(app: IDrawApp) {
super(ItrainLineInteraction.Name, app);
}
static init(app: JlDrawApp) {
static init(app: IDrawApp) {
return new ItrainLineInteraction(app);
}
filter(...grahpics: JlGraphic[]): TrainLine[] | undefined {

View File

@ -5,7 +5,7 @@ import {
GraphicDrawAssistant,
GraphicIdGenerator,
GraphicInteractionPlugin,
JlDrawApp,
IDrawApp,
JlGraphic,
} from 'src/jl-graphic';
@ -69,7 +69,7 @@ export class TrainWindowDraw extends GraphicDrawAssistant<
ITrainWindowData
> {
trainWindowGraph: TrainWindow;
constructor(app: JlDrawApp, template: TrainWindowTemplate) {
constructor(app: IDrawApp, template: TrainWindowTemplate) {
super(app, template, 'sym_o_square', '不展示');
this.trainWindowGraph = this.graphicTemplate.new();
this.container.addChild(this.trainWindowGraph);
@ -243,10 +243,10 @@ function buildAbsorbablePositions(
export class TrainWindowInteraction extends GraphicInteractionPlugin<TrainWindow> {
static Name = 'TrainWindow_transform';
constructor(app: JlDrawApp) {
constructor(app: IDrawApp) {
super(TrainWindowInteraction.Name, app);
}
static init(app: JlDrawApp) {
static init(app: IDrawApp) {
return new TrainWindowInteraction(app);
}
filter(...grahpics: JlGraphic[]): TrainWindow[] | undefined {

View File

@ -1,12 +1,12 @@
import {
AbsorbablePosition,
DraggablePoint,
GraphicApp,
IGraphicApp,
GraphicDrawAssistant,
GraphicInteractionPlugin,
GraphicRelation,
GraphicTransformEvent,
JlDrawApp,
IDrawApp,
JlGraphic,
VectorText,
linePoint,
@ -44,7 +44,7 @@ export class TurnoutDraw extends GraphicDrawAssistant<
ITurnoutData
> {
turnout: Turnout;
constructor(app: JlDrawApp, template: TurnoutTemplate) {
constructor(app: IDrawApp, template: TurnoutTemplate) {
super(app, template, 'sym_o_ramp_left', '道岔Turnout');
this.turnout = this.graphicTemplate.new();
@ -205,11 +205,11 @@ const turnoutSectionEditMenu: ContextMenu = ContextMenu.init({
export class TurnoutPointsInteractionPlugin extends GraphicInteractionPlugin<Turnout> {
static Name = 'TurnoutPointsDrag';
static init(app: JlDrawApp) {
static init(app: IDrawApp) {
return new TurnoutPointsInteractionPlugin(app);
}
constructor(app: GraphicApp) {
constructor(app: IGraphicApp) {
super(TurnoutPointsInteractionPlugin.Name, app);
app.registerMenu(turnoutSectionEditMenu);
}