根据草稿图类型加载绘图工具

This commit is contained in:
joylink_zhaoerwei 2023-06-09 17:48:35 +08:00
parent 6b3bc45677
commit b21af0985a

View File

@ -1,7 +1,6 @@
import { fromUint8Array, toUint8Array } from 'js-base64';
import { IPointData, Point } from 'pixi.js';
import { IscsFan } from 'src/graphics/iscs-fan/IscsFan';
import { IscsFanDraw } from 'src/graphics/iscs-fan/IscsFanDrawAssistant';
import { Link } from 'src/graphics/link/Link';
import { LinkDraw } from 'src/graphics/link/LinkDrawAssistant';
import { Rect } from 'src/graphics/rect/Rect';
@ -107,8 +106,16 @@ export function destroyDrawApp(): void {
export function initDrawApp(dom: HTMLElement): JlDrawApp {
drawApp = new JlDrawApp(dom);
const app = drawApp;
app.setOptions({
drawAssistants: [
//根据草稿图类型加载绘图工具
const draftType = useDrawStore().$state.draftType;
let drawAssistants: (
| PlatformDraw
| StationDraw
| SignalDraw
| TurnoutDraw
)[] = [];
if (draftType === 'Line') {
drawAssistants = [
new PlatformDraw(app, () => {
return new PlatformData();
}),
@ -124,7 +131,52 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
// new TrainDraw(app, () => {
// return new TrainData();
// }),
],
];
app.addKeyboardListener(
new KeyListener({
value: 'KeyP',
onPress: () => {
app.interactionPlugin(Platform.Type).resume();
},
})
);
app.addKeyboardListener(
new KeyListener({
value: 'KeyT',
onPress: () => {
console.log(app.interactionPlugin(Turnout.Type));
app.interactionPlugin(Turnout.Type).resume();
},
})
);
app.addKeyboardListener(
new KeyListener({
value: 'KeyO',
onPress: () => {
app.interactionPlugin(Station.Type).resume();
},
})
);
app.addKeyboardListener(
new KeyListener({
value: 'KeyH',
onPress: () => {
app.interactionPlugin(Signal.Type).resume();
},
})
);
// app.addKeyboardListener(
// new KeyListener({
// value: 'KeyR',
// onPress: () => {
// app.interactionPlugin(Train.Type).resume();
// },
// })
// );
}
app.setOptions({
drawAssistants: drawAssistants,
});
// 画布右键菜单
@ -144,48 +196,6 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
};
DefaultCanvasMenu.open(e.global);
});
app.addKeyboardListener(
new KeyListener({
value: 'KeyP',
onPress: () => {
app.interactionPlugin(Platform.Type).resume();
},
})
);
app.addKeyboardListener(
new KeyListener({
value: 'KeyT',
onPress: () => {
console.log(app.interactionPlugin(Turnout.Type));
app.interactionPlugin(Turnout.Type).resume();
},
})
);
app.addKeyboardListener(
new KeyListener({
value: 'KeyO',
onPress: () => {
app.interactionPlugin(Station.Type).resume();
},
})
);
app.addKeyboardListener(
new KeyListener({
value: 'KeyH',
onPress: () => {
app.interactionPlugin(Signal.Type).resume();
},
})
);
// app.addKeyboardListener(
// new KeyListener({
// value: 'KeyR',
// onPress: () => {
// app.interactionPlugin(Train.Type).resume();
// },
// })
// );
app.addKeyboardListener(
new KeyListener({
value: 'KeyS',