This commit is contained in:
fan 2023-10-12 10:12:29 +08:00
commit 7f05058cb4
14 changed files with 548 additions and 367 deletions

View File

@ -7,18 +7,9 @@
</q-card-section>
<q-separator inset></q-separator>
<q-card-section>
<!-- <template v-if="drawStore.drawGraphicType === Rect.Type">
<rect-template></rect-template>
</template> -->
<template v-if="drawStore.drawGraphicType === Platform.Type">
<platform-template></platform-template>
</template>
<template v-if="drawStore.drawGraphicType === Section.Type">
<section-template></section-template>
</template>
<template v-if="drawStore.drawGraphicType === Station.Type">
<station-template></station-template>
</template>
<!-- <template v-if="drawStore.drawGraphicType === Train.Type">
<train-template></train-template>
</template> -->
@ -48,6 +39,9 @@
<platform-property
v-if="drawStore.selectedGraphicType === Platform.Type"
></platform-property>
<screenDoor-property
v-if="drawStore.selectedGraphicType === ScreenDoor.Type"
></screenDoor-property>
<station-property
v-if="drawStore.selectedGraphicType === Station.Type"
></station-property>
@ -132,14 +126,15 @@
</template>
<script setup lang="ts">
// import RectTemplate from './templates/RectTemplate.vue';
import PlatformTemplate from './templates/PlatformTemplate.vue';
import StationTemplate from './templates/StationTemplate.vue';
// import TrainTemplate from './templates/TrainTemplate.vue';
import SectionTemplate from './templates/SectionTemplate.vue';
import CanvasProperty from './properties/CanvasProperty.vue';
import PlatformProperty from './properties/PlatformProperty.vue';
import { Platform } from 'src/graphics/platform/Platform';
import ScreenDoorProperty from './properties/ScreenDoorProperty.vue';
import { ScreenDoor } from 'src/graphics/screenDoor/ScreenDoor';
import StationProperty from './properties/StationProperty.vue';
import { Station } from 'src/graphics/station/Station';
// import TrainTemplate from './templates/TrainTemplate.vue';
import SectionTemplate from './templates/SectionTemplate.vue';
// import TrainProperty from './properties/TrainProperty.vue';
import TrainWindowProperty from './properties/TrainWindowProperty.vue';
import AxleCountingProperty from './properties/AxleCountingProperty.vue';
@ -151,8 +146,6 @@ import SectionProperty from './properties/SectionProperty.vue';
import SeparatorProperty from './properties/SeparatorProperty.vue';
import TransponderProperty from './properties/TransponderProperty.vue';
import SectionLinkProperty from './properties/SectionLinkProperty.vue';
import { Platform } from 'src/graphics/platform/Platform';
import { Station } from 'src/graphics/station/Station';
// import { Train } from 'src/graphics/train/Train';
import { useDrawStore } from 'src/stores/draw-store';
import { Signal } from 'src/graphics/signal/Signal';

View File

@ -1,6 +1,15 @@
<template>
<q-form class="q-gutter-sm">
<q-input outlined readonly v-model="platformModel.id" label="id" hint="" />
<q-input outlined readonly v-model="platformModel.id" label="id" />
<q-input
outlined
label="站台编号"
type="textarea"
@blur="onUpdate"
v-model="platformModel.code"
lazy-rules
autogrow
/>
<q-input
outlined
v-model.number="platformModel.index"
@ -8,24 +17,6 @@
@blur="onUpdate"
label="索引"
/>
<q-select
outlined
@blur="onUpdate"
v-model="platformModel.hasdoor"
emit-value
map-options
:options="optionsDoor"
label="是否有屏蔽门"
/>
<q-select
outlined
@blur="onUpdate"
v-model="platformModel.direction"
emit-value
map-options
:options="optionsDirection"
label="方向"
/>
<q-input
v-if="platformModel.hasdoor"
outlined
@ -62,14 +53,6 @@ const { data: platformModel, onUpdate } = useFormData(
new PlatformData(),
drawStore.getDrawApp()
);
const optionsDoor = [
{ label: '是', value: true },
{ label: '否', value: false },
];
const optionsDirection = [
{ label: '向上', value: 'up' },
{ label: '向下', value: 'down' },
];
const stationRelation = computed(() => {
const platform = drawStore.selectedGraphic as Platform;

View File

@ -0,0 +1,63 @@
<template>
<q-form class="q-gutter-sm">
<q-input outlined readonly v-model="screenDoorModel.id" label="id" />
<q-input
outlined
label="屏蔽门编号"
type="textarea"
@blur="onUpdate"
v-model="screenDoorModel.code"
lazy-rules
autogrow
/>
<q-input
v-if="screenDoorModel.hasdoor"
outlined
v-model.number="screenDoorModel.sonDoorAmount"
type="number"
@blur="onUpdate"
label="子屏蔽门的数量"
/>
<q-list bordered separator class="rounded-borders">
<q-item>
<q-item-section no-wrap class="q-gutter-y-sm column">
<q-item-label> 关联的站台 </q-item-label>
<div class="q-gutter-sm row">
<q-chip square color="primary" text-color="white">
{{ platformRelation }}
</q-chip>
</div>
</q-item-section>
</q-item>
</q-list>
</q-form>
</template>
<script setup lang="ts">
import { ScreenDoorData } from 'src/drawApp/graphics/ScreenDoorInteraction';
import { useFormData } from 'src/components/DrawAppFormUtils';
import { useDrawStore } from 'src/stores/draw-store';
import { computed } from 'vue';
import { ScreenDoor } from 'src/graphics/screenDoor/ScreenDoor';
import { Platform } from 'src/graphics/platform/Platform';
const drawStore = useDrawStore();
const { data: screenDoorModel, onUpdate } = useFormData(
new ScreenDoorData(),
drawStore.getDrawApp()
);
const platformRelation = computed(() => {
const screenDoor = drawStore.selectedGraphic as ScreenDoor;
const refStations = screenDoor?.relationManage
.getRelationsOfGraphicAndOtherType(screenDoor, Platform.Type)
.map(
(relation) => relation.getOtherGraphic<Platform>(screenDoor).datas.code
);
let refStation;
if (refStations) {
return (refStation = refStations[0]);
}
return refStation;
});
</script>

View File

@ -1,76 +0,0 @@
<template>
<q-form>
<q-input
outlined
v-model.number="template.lineWidth"
type="number"
@blur="onUpdate"
label="线宽 *"
lazy-rules
:rules="[(val) => (val && val > 0) || '线宽必须大于0']"
/>
<q-input
outlined
v-model="template.lineColor"
@blur="onUpdate"
label="线色 *"
lazy-rules
:rules="[(val) => (val && val.length > 0) || '线色不能为空']"
>
<template v-slot:append>
<q-icon name="colorize" class="cursor-pointer">
<q-popup-proxy cover transition-show="scale" transition-hide="scale">
<q-color
v-model="template.lineColor"
@change="
(val) => {
template.lineColor = val;
onUpdate();
}
"
/>
</q-popup-proxy>
</q-icon>
</template>
</q-input>
</q-form>
</template>
<script setup lang="ts">
import { PlatformTemplate } from 'src/graphics/platform/Platform';
import { useDrawStore } from 'src/stores/draw-store';
import { onMounted, reactive } from 'vue';
const drawStore = useDrawStore();
const template = reactive({
lineWidth: 1,
lineColor: '#0000ff',
curve: false,
segmentsCount: 10,
});
onMounted(() => {
const type = drawStore.drawGraphicType;
if (type) {
const gt = drawStore.drawGraphicTemplate;
if (gt) {
// const lt = gt as PlatformTemplate;
// template.lineWidth = lt.lineWidth;
// template.lineColor = lt.lineColor;
// template.curve = lt.curve;
// template.segmentsCount = lt.segmentsCount;
}
}
});
function onUpdate() {
const gt = drawStore.drawGraphicTemplate as PlatformTemplate;
if (gt) {
// gt.lineWidth = template.lineWidth;
// gt.lineColor = template.lineColor;
// gt.curve = template.curve;
// gt.segmentsCount = template.segmentsCount;
}
}
</script>

View File

@ -1,70 +0,0 @@
<template>
<q-form>
<q-input
outlined
v-model.number="template.lineWidth"
type="number"
@blur="onUpdate"
label="字体大小 *"
lazy-rules
:rules="[(val) => (val && val > 0) || '线宽必须大于0']"
/>
<q-input
outlined
v-model="template.lineColor"
@blur="onUpdate"
label="字体颜色 *"
lazy-rules
:rules="[(val) => (val && val.length > 0) || '线色不能为空']"
>
<template v-slot:append>
<q-icon name="colorize" class="cursor-pointer">
<q-popup-proxy cover transition-show="scale" transition-hide="scale">
<q-color
v-model="template.lineColor"
@change="
(val) => {
template.lineColor = val;
onUpdate();
}
"
/>
</q-popup-proxy>
</q-icon>
</template>
</q-input>
</q-form>
</template>
<script setup lang="ts">
import { LinkTemplate } from 'src/graphics/link/Link';
import { useDrawStore } from 'src/stores/draw-store';
import { onMounted, reactive } from 'vue';
const drawStore = useDrawStore();
const template = reactive({
lineWidth: 1,
lineColor: '#0000ff',
});
onMounted(() => {
const type = drawStore.drawGraphicType;
if (type) {
const gt = drawStore.drawGraphicTemplate;
if (gt) {
const lt = gt as LinkTemplate;
template.lineWidth = lt.lineWidth;
template.lineColor = lt.lineColor;
}
}
});
function onUpdate() {
const gt = drawStore.drawGraphicTemplate as LinkTemplate;
if (gt) {
gt.lineWidth = template.lineWidth;
gt.lineColor = template.lineColor;
}
}
</script>

View File

@ -15,6 +15,12 @@ import { graphicData } from 'src/protos/stationLayoutGraphics';
import { Platform, PlatformTemplate } from 'src/graphics/platform/Platform';
import { PlatformData, PlatformState } from './graphics/PlatformInteraction';
import { PlatformDraw } from 'src/graphics/platform/PlatformDrawAssistant';
import {
ScreenDoor,
ScreenDoorTemplate,
} from 'src/graphics/screenDoor/ScreenDoor';
import { ScreenDoorData } from './graphics/ScreenDoorInteraction';
import { ScreenDoorDraw } from 'src/graphics/screenDoor/ScreenDoorDrawAssistant';
import { Station, StationTemplate } from 'src/graphics/station/Station';
import { StationDraw } from 'src/graphics/station/StationDrawAssistant';
import { StationData, StationState } from './graphics/StationInteraction';
@ -141,6 +147,7 @@ export const drawCommonLayerList = [
{ label: '区段', value: Section.Type, defaultShow: true },
{ label: '区段检测点', value: AxleCounting.Type, defaultShow: true },
{ label: '站台', value: Platform.Type, defaultShow: true },
{ label: '屏蔽门', value: ScreenDoor.Type, defaultShow: true },
{ label: '车站', value: Station.Type, defaultShow: true },
{ label: '道岔', value: Turnout.Type, defaultShow: true },
{ label: '信号机', value: Signal.Type, defaultShow: true },
@ -163,7 +170,7 @@ export function initCommonDrawApp(app: IDrawApp) {
app,
new PlatformTemplate(new PlatformData(), new PlatformState())
);
new ScreenDoorDraw(app, new ScreenDoorTemplate(new ScreenDoorData()));
new StationDraw(
app,
new StationTemplate(new StationData(), new StationState())
@ -238,6 +245,9 @@ export function loadCommonDrawDatas(
storage.Platforms.forEach((platform) => {
datas.push(new PlatformData(platform));
});
storage.screenDoors.forEach((screenDoor) => {
datas.push(new ScreenDoorData(screenDoor));
});
storage.stations.forEach((station) => {
datas.push(new StationData(station));
});
@ -304,6 +314,9 @@ export function saveCommonDrawDatas(app: IDrawApp) {
} else if (Station.Type === g.type) {
const stationData = (g as Station).saveData();
storage.stations.push((stationData as StationData).data);
} else if (ScreenDoor.Type === g.type) {
const screenDoor = (g as ScreenDoor).saveData();
storage.screenDoors.push((screenDoor as ScreenDoorData).data);
} else if (Turnout.Type === g.type) {
const turnoutData = (g as Turnout).saveData();
storage.turnouts.push((turnoutData as TurnoutData).data);

View File

@ -40,18 +40,6 @@ export class PlatformData extends GraphicDataBase implements IPlatformData {
set code(v: string) {
this.data.code = v;
}
get hasdoor(): boolean {
return this.data.hasdoor;
}
set hasdoor(v: boolean) {
this.data.hasdoor = v;
}
get direction(): string {
return this.data.direction;
}
set direction(v: string) {
this.data.direction = v;
}
get index(): number {
return this.data.index;
}
@ -64,12 +52,6 @@ export class PlatformData extends GraphicDataBase implements IPlatformData {
set refStation(v: string) {
this.data.refStation = v;
}
get sonDoorAmount(): number {
return this.data.sonDoorAmount;
}
set sonDoorAmount(v: number) {
this.data.sonDoorAmount = v;
}
clone(): PlatformData {
return new PlatformData(this.data.cloneMessage());

View File

@ -0,0 +1,53 @@
import * as pb_1 from 'google-protobuf';
import {
IScreenDoorData,
ScreenDoor,
} from 'src/graphics/screenDoor/ScreenDoor';
import { graphicData } from 'src/protos/stationLayoutGraphics';
import { GraphicDataBase } from './GraphicDataBase';
export class ScreenDoorData extends GraphicDataBase implements IScreenDoorData {
constructor(data?: graphicData.ScreenDoor) {
let screenDoor;
if (!data) {
screenDoor = new graphicData.ScreenDoor({
common: GraphicDataBase.defaultCommonInfo(ScreenDoor.Type),
});
} else {
screenDoor = data;
}
super(screenDoor);
}
public get data(): graphicData.ScreenDoor {
return this.getData<graphicData.ScreenDoor>();
}
get code(): string {
return this.data.code;
}
set code(v: string) {
this.data.code = v;
}
get refPlatform(): string {
return this.data.refPlatform;
}
set refPlatform(v: string) {
this.data.refPlatform = v;
}
get sonDoorAmount(): number {
return this.data.sonDoorAmount;
}
set sonDoorAmount(v: number) {
this.data.sonDoorAmount = v;
}
clone(): ScreenDoorData {
return new ScreenDoorData(this.data.cloneMessage());
}
copyFrom(data: ScreenDoorData): void {
pb_1.Message.copyInto(data.data, this.data);
}
eq(other: ScreenDoorData): boolean {
return pb_1.Message.equals(this.data, other.data);
}
}

View File

@ -14,16 +14,10 @@ import { Station } from '../station/Station';
export interface IPlatformData extends GraphicData {
get code(): string; // 编号
set code(v: string);
get hasdoor(): boolean; // 是否有屏蔽门
set hasdoor(v: boolean);
get direction(): string; // 屏蔽门上下
set direction(v: string);
get index(): number;
set index(v: number);
get refStation(): string; // 关联的车站
set refStation(v: string);
get sonDoorAmount(): number; //子屏蔽门的数量
set sonDoorAmount(v: number);
clone(): IPlatformData;
copyFrom(data: IPlatformData): void;
eq(other: IPlatformData): boolean;
@ -129,71 +123,6 @@ export class rectGraphic extends Container {
this.rectGraphic.clear();
}
}
//子元素--门
class smallDoorGraphic extends Container {
smallDoorGraphic: Graphics;
labelGraphic: VectorText;
constructor() {
super();
this.smallDoorGraphic = new Graphics();
this.labelGraphic = new VectorText();
this.labelGraphic.setVectorFontSize(12);
this.labelGraphic.anchor.set(0.5);
this.addChild(this.smallDoorGraphic);
this.addChild(this.labelGraphic);
}
draw(data: IPlatformData, stateData: IPlatformState, i: number): void {
const start =
(-platformConsts.smallDoorWidth * data.sonDoorAmount) / 2 +
platformConsts.smallDoorWidth * i;
const smallDoorGraphic = this.smallDoorGraphic;
const lineColor = PlatformColorEnum.doorGreen;
// if (stateData.psdCut) {
// lineColor = PlatformColorEnum.doorRed;
// }
const direction = data.direction;
smallDoorGraphic
.lineStyle(platformConsts.lineWidth, new Color(lineColor))
.moveTo(start, 0)
.lineTo(start + platformConsts.smallDoorWidth - 3, 0);
if (direction == 'down') {
this.labelGraphic.text = data.sonDoorAmount - i;
} else {
this.labelGraphic.text = i + 1;
}
this.labelGraphic.style.fill = 'red';
if (i % 2 == 0) {
this.labelGraphic.position.set(start + 4, 7);
} else {
this.labelGraphic.position.set(start + 4, -7);
}
}
}
export class doorGraphic extends Container {
constructor() {
super();
}
draw(data: IPlatformData, stateData: IPlatformState): void {
for (let i = 0; i < data.sonDoorAmount; i++) {
const smallDoor = new smallDoorGraphic();
smallDoor.draw(data, stateData, i);
this.addChild(smallDoor);
}
}
clear(): void {
this.children.forEach((g) => {
(g as smallDoorGraphic).smallDoorGraphic.clear();
(g as smallDoorGraphic).labelGraphic.text = '';
});
}
// changeState(stateData: IPlatformState): void {
// // if (stateData.psdOpen) {
// // this.doorCloseGraphic.visible = false;
// // } else {
// // this.doorCloseGraphic.visible = true;
// // }
// }
}
//子元素--字符
class codeGraph extends Container {
static Type = 'Code';
@ -406,13 +335,11 @@ class emergClose extends JlGraphic {
export class Platform extends JlGraphic {
static Type = 'Platform';
platformGraphic: rectGraphic = new rectGraphic();
doorGraphic: doorGraphic = new doorGraphic();
emergClose: emergClose = new emergClose();
codeGraph: codeGraph = new codeGraph();
constructor() {
super(Platform.Type);
this.addChild(this.platformGraphic);
this.addChild(this.doorGraphic);
this.addChild(this.emergClose);
this.addChild(this.codeGraph);
}
@ -427,19 +354,9 @@ export class Platform extends JlGraphic {
return this.datas.index + '';
}
doRepaint(): void {
this.datas.sonDoorAmount = this.datas?.sonDoorAmount || 30;
this.doorGraphic.clear();
if (this.datas.hasdoor) {
this.doorGraphic.draw(this.datas, this.states);
}
this.platformGraphic.draw(this.states);
this.emergClose.draw();
this.codeGraph.draw();
this.doorGraphic.position.set(
0,
-platformConsts.height / 2 - platformConsts.doorPlatformSpacing
);
this.emergClose.position.set(
0,
-platformConsts.height / 2 -
@ -448,16 +365,15 @@ export class Platform extends JlGraphic {
);
this.codeGraph.position.set(0, 0);
//站台方向
if (this.datas.direction == 'down') {
/* if (this.datas.direction == 'down') {
const psChange = [
this.doorGraphic,
this.emergClose,
...this.codeGraph.children,
];
psChange.forEach((g) => {
g.position.copyFrom(calculateMirrorPoint(new Point(0, 0), g.position));
});
}
} */
// this.changeState();
}
buildRelation() {

View File

@ -50,9 +50,6 @@ export class PlatformDraw extends GraphicDrawAssistant<
}
prepareData(data: IPlatformData): boolean {
const template = this.graphicTemplate;
data.hasdoor = template.hasdoor;
data.direction = template.direction;
data.transform = this.container.saveTransform();
return true;
}

View File

@ -0,0 +1,134 @@
import { Color, Container, Graphics } from 'pixi.js';
import {
GraphicData,
JlGraphic,
JlGraphicTemplate,
VectorText,
} from 'src/jl-graphic';
import { Platform } from '../platform/Platform';
export interface IScreenDoorData extends GraphicData {
get code(): string; // 编号
set code(v: string);
get refPlatform(): string; // 关联的站台
set refPlatform(v: string);
get sonDoorAmount(): number; //子屏蔽门的数量
set sonDoorAmount(v: number);
clone(): IScreenDoorData;
copyFrom(data: IScreenDoorData): void;
eq(other: IScreenDoorData): boolean;
}
const screenDoorConsts = {
lineWidth: 3,
smallDoorWidth: 10,
doorGreen: '0x00FF00', //屏蔽门的颜色
doorRed: '0xff0000',
};
class smallDoorGraphic extends Container {
smallDoorGraphic: Graphics;
labelGraphic: VectorText;
constructor() {
super();
this.smallDoorGraphic = new Graphics();
this.labelGraphic = new VectorText();
this.labelGraphic.setVectorFontSize(12);
this.labelGraphic.anchor.set(0.5);
this.addChild(this.smallDoorGraphic);
this.addChild(this.labelGraphic);
}
draw(data: IScreenDoorData, i: number): void {
const start =
(-screenDoorConsts.smallDoorWidth * data.sonDoorAmount) / 2 +
screenDoorConsts.smallDoorWidth * i;
const smallDoorGraphic = this.smallDoorGraphic;
const lineColor = screenDoorConsts.doorGreen;
const direction = 'down';
smallDoorGraphic
.lineStyle(screenDoorConsts.lineWidth, new Color(lineColor))
.moveTo(start, 0)
.lineTo(start + screenDoorConsts.smallDoorWidth - 3, 0);
if (direction == 'down') {
this.labelGraphic.text = data.sonDoorAmount - i;
} else {
this.labelGraphic.text = i + 1;
}
this.labelGraphic.style.fill = 'red';
if (i % 2 == 0) {
this.labelGraphic.position.set(start + 4, 7);
} else {
this.labelGraphic.position.set(start + 4, -7);
}
}
}
export class ScreenDoor extends JlGraphic {
static Type = 'ScreenDoor';
doorGraphic = new Container();
constructor() {
super(ScreenDoor.Type);
this.addChild(this.doorGraphic);
}
get datas(): IScreenDoorData {
return this.getDatas<IScreenDoorData>();
}
doRepaint(): void {
const doorGraphic = this.doorGraphic;
doorGraphic.children.forEach((g) => {
(g as smallDoorGraphic).smallDoorGraphic.clear();
(g as smallDoorGraphic).labelGraphic.text = '';
});
this.datas.sonDoorAmount = this.datas?.sonDoorAmount || 30;
for (let i = 0; i < this.datas.sonDoorAmount; i++) {
const smallDoor = new smallDoorGraphic();
smallDoor.draw(this.datas, i);
doorGraphic.addChild(smallDoor);
}
}
buildRelation() {
const stationas = this.queryStore.queryByType<Platform>(Platform.Type);
for (let i = 0; i < stationas.length; i++) {
const sP = stationas[i].localBoundsToCanvasPoints();
if (this.x > sP[0].x && this.x < sP[1].x) {
this.relationManage.addRelation(this, stationas[i]);
break;
}
}
}
saveRelations() {
const refStation = this.relationManage
.getRelationsOfGraphicAndOtherType(this, Platform.Type)
.map((relation) => relation.getOtherGraphic<Platform>(this).datas.id);
if (refStation.length) {
this.datas.refPlatform = refStation[0];
}
}
loadRelations() {
if (this.datas.refPlatform) {
this.relationManage.addRelation(
this,
this.queryStore.queryById<Platform>(this.datas.refPlatform)
);
}
}
}
export class ScreenDoorTemplate extends JlGraphicTemplate<ScreenDoor> {
hasdoor: boolean;
direction: string;
constructor(dataTemplate: IScreenDoorData) {
super(ScreenDoor.Type, {
dataTemplate,
});
this.hasdoor = true;
this.direction = 'up';
}
new(): ScreenDoor {
const screenDoor = new ScreenDoor();
screenDoor.loadData(this.datas);
return screenDoor;
}
}

View File

@ -0,0 +1,98 @@
import { FederatedPointerEvent, Point } from 'pixi.js';
import {
AbsorbableLine,
AbsorbablePosition,
GraphicDrawAssistant,
GraphicInteractionPlugin,
IDrawApp,
JlGraphic,
} from 'src/jl-graphic';
import { IScreenDoorData, ScreenDoor, ScreenDoorTemplate } from './ScreenDoor';
import { Platform } from 'src/graphics/platform/Platform';
export interface IScreenDoorDrawOptions {
newData: () => IScreenDoorData;
}
export class ScreenDoorDraw extends GraphicDrawAssistant<
ScreenDoorTemplate,
IScreenDoorData
> {
screenDoorGraphic: ScreenDoor;
constructor(app: IDrawApp, template: ScreenDoorTemplate) {
super(app, template, 'sym_o_square', '屏蔽门ScreenDoor');
this.screenDoorGraphic = this.graphicTemplate.new();
this.container.addChild(this.screenDoorGraphic);
screenDoorInteraction.init(app);
}
bind(): void {
super.bind();
this.screenDoorGraphic.loadData(this.graphicTemplate.datas);
this.screenDoorGraphic.doRepaint();
}
onLeftDown(e: FederatedPointerEvent): void {
this.container.position.copyFrom(this.toCanvasCoordinates(e.global));
this.createAndStore(true);
}
redraw(p: Point): void {
this.container.position.copyFrom(p);
}
prepareData(data: IScreenDoorData): boolean {
data.transform = this.container.saveTransform();
return true;
}
}
function buildAbsorbablePositions(
screenDoor: ScreenDoor
): AbsorbablePosition[] {
const aps: AbsorbablePosition[] = [];
const platforms = screenDoor.queryStore.queryByType<Platform>(Platform.Type);
const { width, height } = screenDoor.getGraphicApp().canvas;
platforms.forEach((platform) => {
const ps = platform.datas.transform.position;
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 });
aps.push(xs, ys);
});
return aps;
}
export class screenDoorInteraction extends GraphicInteractionPlugin<ScreenDoor> {
static Name = 'screenDoor_transform';
constructor(app: IDrawApp) {
super(screenDoorInteraction.Name, app);
}
static init(app: IDrawApp) {
return new screenDoorInteraction(app);
}
filter(...grahpics: JlGraphic[]): ScreenDoor[] | undefined {
return grahpics
.filter((g) => g.type === ScreenDoor.Type)
.map((g) => g as ScreenDoor);
}
bind(g: ScreenDoor): void {
g.eventMode = 'static';
g.cursor = 'pointer';
g.scalable = true;
g.rotatable = true;
g.on('selected', this.onSelected, this);
}
unbind(g: ScreenDoor): void {
g.eventMode = 'none';
g.scalable = false;
g.rotatable = false;
g.off('selected', this.onSelected, this);
}
onSelected(): void {
const screenDoor = this.app.selectedGraphics[0] as ScreenDoor;
this.app.setOptions({
absorbablePositions: buildAbsorbablePositions(screenDoor),
});
}
}

View File

@ -183,6 +183,7 @@ import { CurvatureDraw } from 'src/graphics/curvature/CurvatureAssistant';
import { TrackSection } from 'src/graphics/trackSection/TrackSection';
import { TrackSectionDraw } from 'src/graphics/trackSection/TrackSectionDrawAssistant';
import { Platform } from 'src/graphics/platform/Platform';
import { ScreenDoor } from 'src/graphics/screenDoor/ScreenDoor';
import { Station } from 'src/graphics/station/Station';
import { Signal } from 'src/graphics/signal/Signal';
import { Turnout } from 'src/graphics/turnout/Turnout';
@ -299,6 +300,7 @@ onMounted(() => {
}
const drawAssistantsTypes = [
Platform.Type,
ScreenDoor.Type,
Station.Type,
Signal.Type,
Section.Type,

View File

@ -38,9 +38,10 @@ export namespace graphicData {
trackLogicSections?: TrackLogicSection[];
UniqueIdPrefix?: UniqueIdOfStationLayout;
kilometerConvertList?: KilometerConvert[];
screenDoors?: ScreenDoor[];
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4, 5, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32], this.#one_of_decls);
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4, 5, 8, 9, 10, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 32, 33], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("canvas" in data && data.canvas != undefined) {
this.canvas = data.canvas;
@ -120,6 +121,9 @@ export namespace graphicData {
if ("kilometerConvertList" in data && data.kilometerConvertList != undefined) {
this.kilometerConvertList = data.kilometerConvertList;
}
if ("screenDoors" in data && data.screenDoors != undefined) {
this.screenDoors = data.screenDoors;
}
}
}
get canvas() {
@ -284,6 +288,12 @@ export namespace graphicData {
set kilometerConvertList(value: KilometerConvert[]) {
pb_1.Message.setRepeatedWrapperField(this, 32, value);
}
get screenDoors() {
return pb_1.Message.getRepeatedWrapperField(this, ScreenDoor, 33) as ScreenDoor[];
}
set screenDoors(value: ScreenDoor[]) {
pb_1.Message.setRepeatedWrapperField(this, 33, value);
}
static fromObject(data: {
canvas?: ReturnType<typeof Canvas.prototype.toObject>;
Platforms?: ReturnType<typeof Platform.prototype.toObject>[];
@ -311,6 +321,7 @@ export namespace graphicData {
trackLogicSections?: ReturnType<typeof TrackLogicSection.prototype.toObject>[];
UniqueIdPrefix?: ReturnType<typeof UniqueIdOfStationLayout.prototype.toObject>;
kilometerConvertList?: ReturnType<typeof KilometerConvert.prototype.toObject>[];
screenDoors?: ReturnType<typeof ScreenDoor.prototype.toObject>[];
}): RtssGraphicStorage {
const message = new RtssGraphicStorage({});
if (data.canvas != null) {
@ -391,6 +402,9 @@ export namespace graphicData {
if (data.kilometerConvertList != null) {
message.kilometerConvertList = data.kilometerConvertList.map(item => KilometerConvert.fromObject(item));
}
if (data.screenDoors != null) {
message.screenDoors = data.screenDoors.map(item => ScreenDoor.fromObject(item));
}
return message;
}
toObject() {
@ -421,6 +435,7 @@ export namespace graphicData {
trackLogicSections?: ReturnType<typeof TrackLogicSection.prototype.toObject>[];
UniqueIdPrefix?: ReturnType<typeof UniqueIdOfStationLayout.prototype.toObject>;
kilometerConvertList?: ReturnType<typeof KilometerConvert.prototype.toObject>[];
screenDoors?: ReturnType<typeof ScreenDoor.prototype.toObject>[];
} = {};
if (this.canvas != null) {
data.canvas = this.canvas.toObject();
@ -500,6 +515,9 @@ export namespace graphicData {
if (this.kilometerConvertList != null) {
data.kilometerConvertList = this.kilometerConvertList.map((item: KilometerConvert) => item.toObject());
}
if (this.screenDoors != null) {
data.screenDoors = this.screenDoors.map((item: ScreenDoor) => item.toObject());
}
return data;
}
serialize(): Uint8Array;
@ -558,6 +576,8 @@ export namespace graphicData {
writer.writeMessage(31, this.UniqueIdPrefix, () => this.UniqueIdPrefix.serialize(writer));
if (this.kilometerConvertList.length)
writer.writeRepeatedMessage(32, this.kilometerConvertList, (item: KilometerConvert) => item.serialize(writer));
if (this.screenDoors.length)
writer.writeRepeatedMessage(33, this.screenDoors, (item: ScreenDoor) => item.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
@ -645,6 +665,9 @@ export namespace graphicData {
case 32:
reader.readMessage(message.kilometerConvertList, () => pb_1.Message.addToRepeatedWrapperField(message, 32, KilometerConvert.deserialize(reader), KilometerConvert));
break;
case 33:
reader.readMessage(message.screenDoors, () => pb_1.Message.addToRepeatedWrapperField(message, 33, ScreenDoor.deserialize(reader), ScreenDoor));
break;
default: reader.skipField();
}
}
@ -1268,11 +1291,8 @@ export namespace graphicData {
constructor(data?: any[] | {
common?: CommonInfo;
code?: string;
hasdoor?: boolean;
direction?: string;
index?: number;
refStation?: string;
sonDoorAmount?: number;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
@ -1283,21 +1303,12 @@ export namespace graphicData {
if ("code" in data && data.code != undefined) {
this.code = data.code;
}
if ("hasdoor" in data && data.hasdoor != undefined) {
this.hasdoor = data.hasdoor;
}
if ("direction" in data && data.direction != undefined) {
this.direction = data.direction;
}
if ("index" in data && data.index != undefined) {
this.index = data.index;
}
if ("refStation" in data && data.refStation != undefined) {
this.refStation = data.refStation;
}
if ("sonDoorAmount" in data && data.sonDoorAmount != undefined) {
this.sonDoorAmount = data.sonDoorAmount;
}
}
}
get common() {
@ -1315,18 +1326,6 @@ export namespace graphicData {
set code(value: string) {
pb_1.Message.setField(this, 2, value);
}
get hasdoor() {
return pb_1.Message.getFieldWithDefault(this, 3, false) as boolean;
}
set hasdoor(value: boolean) {
pb_1.Message.setField(this, 3, value);
}
get direction() {
return pb_1.Message.getFieldWithDefault(this, 4, "") as string;
}
set direction(value: string) {
pb_1.Message.setField(this, 4, value);
}
get index() {
return pb_1.Message.getFieldWithDefault(this, 5, 0) as number;
}
@ -1339,20 +1338,11 @@ export namespace graphicData {
set refStation(value: string) {
pb_1.Message.setField(this, 8, value);
}
get sonDoorAmount() {
return pb_1.Message.getFieldWithDefault(this, 9, 0) as number;
}
set sonDoorAmount(value: number) {
pb_1.Message.setField(this, 9, value);
}
static fromObject(data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
code?: string;
hasdoor?: boolean;
direction?: string;
index?: number;
refStation?: string;
sonDoorAmount?: number;
}): Platform {
const message = new Platform({});
if (data.common != null) {
@ -1361,32 +1351,20 @@ export namespace graphicData {
if (data.code != null) {
message.code = data.code;
}
if (data.hasdoor != null) {
message.hasdoor = data.hasdoor;
}
if (data.direction != null) {
message.direction = data.direction;
}
if (data.index != null) {
message.index = data.index;
}
if (data.refStation != null) {
message.refStation = data.refStation;
}
if (data.sonDoorAmount != null) {
message.sonDoorAmount = data.sonDoorAmount;
}
return message;
}
toObject() {
const data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
code?: string;
hasdoor?: boolean;
direction?: string;
index?: number;
refStation?: string;
sonDoorAmount?: number;
} = {};
if (this.common != null) {
data.common = this.common.toObject();
@ -1394,21 +1372,12 @@ export namespace graphicData {
if (this.code != null) {
data.code = this.code;
}
if (this.hasdoor != null) {
data.hasdoor = this.hasdoor;
}
if (this.direction != null) {
data.direction = this.direction;
}
if (this.index != null) {
data.index = this.index;
}
if (this.refStation != null) {
data.refStation = this.refStation;
}
if (this.sonDoorAmount != null) {
data.sonDoorAmount = this.sonDoorAmount;
}
return data;
}
serialize(): Uint8Array;
@ -1419,16 +1388,10 @@ export namespace graphicData {
writer.writeMessage(1, this.common, () => this.common.serialize(writer));
if (this.code.length)
writer.writeString(2, this.code);
if (this.hasdoor != false)
writer.writeBool(3, this.hasdoor);
if (this.direction.length)
writer.writeString(4, this.direction);
if (this.index != 0)
writer.writeInt32(5, this.index);
if (this.refStation.length)
writer.writeString(8, this.refStation);
if (this.sonDoorAmount != 0)
writer.writeInt32(9, this.sonDoorAmount);
if (!w)
return writer.getResultBuffer();
}
@ -1444,21 +1407,12 @@ export namespace graphicData {
case 2:
message.code = reader.readString();
break;
case 3:
message.hasdoor = reader.readBool();
break;
case 4:
message.direction = reader.readString();
break;
case 5:
message.index = reader.readInt32();
break;
case 8:
message.refStation = reader.readString();
break;
case 9:
message.sonDoorAmount = reader.readInt32();
break;
default: reader.skipField();
}
}
@ -1471,6 +1425,145 @@ export namespace graphicData {
return Platform.deserialize(bytes);
}
}
export class ScreenDoor extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
common?: CommonInfo;
code?: string;
sonDoorAmount?: number;
refPlatform?: string;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("common" in data && data.common != undefined) {
this.common = data.common;
}
if ("code" in data && data.code != undefined) {
this.code = data.code;
}
if ("sonDoorAmount" in data && data.sonDoorAmount != undefined) {
this.sonDoorAmount = data.sonDoorAmount;
}
if ("refPlatform" in data && data.refPlatform != undefined) {
this.refPlatform = data.refPlatform;
}
}
}
get common() {
return pb_1.Message.getWrapperField(this, CommonInfo, 1) as CommonInfo;
}
set common(value: CommonInfo) {
pb_1.Message.setWrapperField(this, 1, value);
}
get has_common() {
return pb_1.Message.getField(this, 1) != null;
}
get code() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set code(value: string) {
pb_1.Message.setField(this, 2, value);
}
get sonDoorAmount() {
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
}
set sonDoorAmount(value: number) {
pb_1.Message.setField(this, 3, value);
}
get refPlatform() {
return pb_1.Message.getFieldWithDefault(this, 4, "") as string;
}
set refPlatform(value: string) {
pb_1.Message.setField(this, 4, value);
}
static fromObject(data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
code?: string;
sonDoorAmount?: number;
refPlatform?: string;
}): ScreenDoor {
const message = new ScreenDoor({});
if (data.common != null) {
message.common = CommonInfo.fromObject(data.common);
}
if (data.code != null) {
message.code = data.code;
}
if (data.sonDoorAmount != null) {
message.sonDoorAmount = data.sonDoorAmount;
}
if (data.refPlatform != null) {
message.refPlatform = data.refPlatform;
}
return message;
}
toObject() {
const data: {
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
code?: string;
sonDoorAmount?: number;
refPlatform?: string;
} = {};
if (this.common != null) {
data.common = this.common.toObject();
}
if (this.code != null) {
data.code = this.code;
}
if (this.sonDoorAmount != null) {
data.sonDoorAmount = this.sonDoorAmount;
}
if (this.refPlatform != null) {
data.refPlatform = this.refPlatform;
}
return data;
}
serialize(): Uint8Array;
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.has_common)
writer.writeMessage(1, this.common, () => this.common.serialize(writer));
if (this.code.length)
writer.writeString(2, this.code);
if (this.sonDoorAmount != 0)
writer.writeInt32(3, this.sonDoorAmount);
if (this.refPlatform.length)
writer.writeString(4, this.refPlatform);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): ScreenDoor {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new ScreenDoor();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
reader.readMessage(message.common, () => message.common = CommonInfo.deserialize(reader));
break;
case 2:
message.code = reader.readString();
break;
case 3:
message.sonDoorAmount = reader.readInt32();
break;
case 4:
message.refPlatform = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): ScreenDoor {
return ScreenDoor.deserialize(bytes);
}
}
export class Station extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {