车次窗一键生成辅助线
This commit is contained in:
parent
e049c6cd39
commit
db143530c1
@ -47,6 +47,10 @@ import {
|
||||
} from 'src/graphics/trainLine/TrainLine';
|
||||
import { TrainLineDraw } from 'src/graphics/trainLine/TrainLineAssistant';
|
||||
import { TrainLineData } from './graphics/TrainLineInteraction';
|
||||
import {
|
||||
OneClickGenerateDraw,
|
||||
OneClickGenerateTemplate,
|
||||
} from 'src/graphics/trainWindow/oneClickDrawAssistant';
|
||||
import {
|
||||
TrainWindow,
|
||||
TrainWindowTemplate,
|
||||
@ -153,6 +157,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
||||
| PathLineDraw
|
||||
| TrainWindowDraw
|
||||
| TrainDraw
|
||||
| OneClickGenerateDraw
|
||||
)[] = [];
|
||||
if (draftType === 'Line') {
|
||||
drawAssistants = [
|
||||
@ -172,6 +177,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
||||
new SectionDraw(app, new SectionTemplate(new SectionData())),
|
||||
new TurnoutDraw(app, new TurnoutTemplate(new TurnoutData())),
|
||||
new TrainWindowDraw(app, new TrainWindowTemplate(new TrainWindowData())),
|
||||
new OneClickGenerateDraw(app, new OneClickGenerateTemplate()),
|
||||
];
|
||||
DrawSignalInteraction.init(app);
|
||||
} else {
|
||||
|
@ -23,7 +23,7 @@ export const TrainWindowConsts = {
|
||||
height: 15,
|
||||
lineWidth: 2,
|
||||
lineColor: '0x0fe81f',
|
||||
offsetSection: 60,
|
||||
offsetSection: 120,
|
||||
};
|
||||
|
||||
export class TrainWindow extends JlGraphic {
|
||||
|
@ -94,20 +94,8 @@ export class TrainWindowDraw extends GraphicDrawAssistant<
|
||||
}
|
||||
this.storeGraphic(...trainWindows);
|
||||
}
|
||||
oneGenerates() {
|
||||
oneGenerates(height: Point) {
|
||||
const sections = this.app.queryStore.queryByType<Section>(Section.Type);
|
||||
const sectionSelect = this.app.selectedGraphics[0] as Section;
|
||||
let height = 0;
|
||||
if (sections.length && sectionSelect !== undefined) {
|
||||
if (sectionSelect.datas.transform.position.y == 0) {
|
||||
height = sectionSelect.datas.points[0].y + 5;
|
||||
} else {
|
||||
height =
|
||||
sectionSelect.datas.points[0].y +
|
||||
sectionSelect.datas.transform.position.y +
|
||||
5;
|
||||
}
|
||||
}
|
||||
const trainWindowAll = this.app.queryStore.queryByType<TrainWindow>(
|
||||
TrainWindow.Type
|
||||
);
|
||||
@ -120,7 +108,7 @@ export class TrainWindowDraw extends GraphicDrawAssistant<
|
||||
ps.push(new Point(point.x + transPos.x, point.y + transPos.y));
|
||||
});
|
||||
let direction = 1;
|
||||
if (ps[0].y > height) {
|
||||
if (ps[0].y > height.y) {
|
||||
direction = -1;
|
||||
}
|
||||
for (let i = 0; i < ps.length - 1; i++) {
|
||||
@ -206,15 +194,15 @@ export class TrainWindowInteraction extends GraphicInteractionPlugin<TrainWindow
|
||||
g.scalable = true;
|
||||
g.rotatable = true;
|
||||
g.rectGraphic.hitArea = new RectGraphicHitArea(g);
|
||||
g.on('selected', this.onSelected, this);
|
||||
g.on('transformstart', this.move, this);
|
||||
}
|
||||
unbind(g: TrainWindow): void {
|
||||
g.eventMode = 'none';
|
||||
g.scalable = false;
|
||||
g.rotatable = false;
|
||||
g.off('selected', this.onSelected, this);
|
||||
g.off('selected', this.move, this);
|
||||
}
|
||||
onSelected(): void {
|
||||
move(): void {
|
||||
const trainWindow = this.app.selectedGraphics[0] as TrainWindow;
|
||||
this.app.setOptions({
|
||||
absorbablePositions: buildAbsorbablePositions(trainWindow),
|
||||
|
71
src/graphics/trainWindow/oneClickDrawAssistant.ts
Normal file
71
src/graphics/trainWindow/oneClickDrawAssistant.ts
Normal file
@ -0,0 +1,71 @@
|
||||
import { Color, FederatedPointerEvent, Graphics, Point } from 'pixi.js';
|
||||
import {
|
||||
GraphicData,
|
||||
GraphicDrawAssistant,
|
||||
JlDrawApp,
|
||||
JlGraphic,
|
||||
JlGraphicTemplate,
|
||||
} from 'src/jl-graphic';
|
||||
import { TrainWindow } from './TrainWindow';
|
||||
import { TrainWindowDraw } from './TrainWindowDrawAssistant';
|
||||
|
||||
interface IOneClickData extends GraphicData {
|
||||
get code(): string; // 编号
|
||||
}
|
||||
|
||||
export class OneClickGenerate extends JlGraphic {
|
||||
static Type = 'OneClickGenerate';
|
||||
lineGraphic: Graphics = new Graphics();
|
||||
constructor() {
|
||||
super(OneClickGenerate.Type);
|
||||
this.addChild(this.lineGraphic);
|
||||
}
|
||||
|
||||
doRepaint(): void {
|
||||
this.lineGraphic.clear();
|
||||
this.lineGraphic.lineStyle(1, new Color('0xff0000'));
|
||||
this.lineGraphic.moveTo(-1920, 0);
|
||||
this.lineGraphic.lineTo(1920, 0);
|
||||
}
|
||||
}
|
||||
|
||||
export class OneClickGenerateTemplate extends JlGraphicTemplate<OneClickGenerate> {
|
||||
constructor() {
|
||||
super(OneClickGenerate.Type, {});
|
||||
}
|
||||
new(): OneClickGenerate {
|
||||
return new OneClickGenerate();
|
||||
}
|
||||
}
|
||||
|
||||
export class OneClickGenerateDraw extends GraphicDrawAssistant<
|
||||
OneClickGenerateTemplate,
|
||||
IOneClickData
|
||||
> {
|
||||
lineGraph: OneClickGenerate;
|
||||
constructor(app: JlDrawApp, template: OneClickGenerateTemplate) {
|
||||
super(app, template, 'sym_o_square', '不展示');
|
||||
this.lineGraph = this.graphicTemplate.new();
|
||||
this.container.addChild(this.lineGraph);
|
||||
}
|
||||
|
||||
bind(): void {
|
||||
super.bind();
|
||||
this.lineGraph.doRepaint();
|
||||
}
|
||||
onLeftDown(e: FederatedPointerEvent): void {
|
||||
this.container.position.copyFrom(this.toCanvasCoordinates(e.global));
|
||||
const trainWindowDraw = this.app.getDrawAssistant(
|
||||
TrainWindow.Type
|
||||
) as TrainWindowDraw;
|
||||
trainWindowDraw.oneGenerates(this.toCanvasCoordinates(e.global));
|
||||
this.finish();
|
||||
}
|
||||
|
||||
redraw(p: Point): void {
|
||||
this.container.position.copyFrom(p);
|
||||
}
|
||||
prepareData(): boolean {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -177,8 +177,7 @@ import { useRoute, useRouter } from 'vue-router';
|
||||
import { errorNotify, successNotify } from 'src/utils/CommonNotify';
|
||||
import { saveAsDraft } from 'src/api/DraftApi';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
import { TrainWindowDraw } from 'src/graphics/trainWindow/TrainWindowDrawAssistant';
|
||||
import { TrainWindow } from 'src/graphics/trainWindow/TrainWindow';
|
||||
import { OneClickGenerate } from 'src/graphics/trainWindow/oneClickDrawAssistant';
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
@ -304,10 +303,7 @@ function buildRelations() {
|
||||
}
|
||||
|
||||
function oneClickGeneration() {
|
||||
const trainWindowDraw = drawStore
|
||||
.getDrawApp()
|
||||
.getDrawAssistant(TrainWindow.Type) as TrainWindowDraw;
|
||||
trainWindowDraw.oneGenerates();
|
||||
drawStore.getDrawApp().interactionPlugin(OneClickGenerate.Type).resume();
|
||||
}
|
||||
|
||||
function backConfirm() {
|
||||
|
Loading…
Reference in New Issue
Block a user