添加应答器
This commit is contained in:
parent
76eac675ee
commit
df294d817d
@ -81,6 +81,9 @@
|
|||||||
<section-link-property
|
<section-link-property
|
||||||
v-else-if="drawStore.selectedGraphicType === SectionLink.Type"
|
v-else-if="drawStore.selectedGraphicType === SectionLink.Type"
|
||||||
></section-link-property>
|
></section-link-property>
|
||||||
|
<transponder-property
|
||||||
|
v-else-if="drawStore.selectedGraphicType === Transponder.Type"
|
||||||
|
></transponder-property>
|
||||||
<stop-position-property
|
<stop-position-property
|
||||||
v-else-if="drawStore.selectedGraphicType === StopPosition.Type"
|
v-else-if="drawStore.selectedGraphicType === StopPosition.Type"
|
||||||
></stop-position-property>
|
></stop-position-property>
|
||||||
@ -113,6 +116,7 @@ import SignalProperty from './properties/SignalProperty.vue';
|
|||||||
import TurnoutProperty from './properties/TurnoutProperty.vue';
|
import TurnoutProperty from './properties/TurnoutProperty.vue';
|
||||||
import SectionProperty from './properties/SectionProperty.vue';
|
import SectionProperty from './properties/SectionProperty.vue';
|
||||||
import SeparatorProperty from './properties/SeparatorProperty.vue';
|
import SeparatorProperty from './properties/SeparatorProperty.vue';
|
||||||
|
import TransponderProperty from './properties/TransponderProperty.vue';
|
||||||
import SectionLinkProperty from './properties/SectionLinkProperty.vue';
|
import SectionLinkProperty from './properties/SectionLinkProperty.vue';
|
||||||
import { Platform } from 'src/graphics/platform/Platform';
|
import { Platform } from 'src/graphics/platform/Platform';
|
||||||
import { Station } from 'src/graphics/station/Station';
|
import { Station } from 'src/graphics/station/Station';
|
||||||
@ -126,6 +130,7 @@ import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting';
|
|||||||
import { AxleCountingSection } from 'src/graphics/axleCountingSection/AxleCountingSection';
|
import { AxleCountingSection } from 'src/graphics/axleCountingSection/AxleCountingSection';
|
||||||
import { LogicSection } from 'src/graphics/logicSection/LogicSection';
|
import { LogicSection } from 'src/graphics/logicSection/LogicSection';
|
||||||
import { Separator } from 'src/graphics/separator/Separator';
|
import { Separator } from 'src/graphics/separator/Separator';
|
||||||
|
import { Transponder } from 'src/graphics/transponder/Transponder';
|
||||||
import { SectionLink } from 'src/graphics/sectionLink/SectionLink';
|
import { SectionLink } from 'src/graphics/sectionLink/SectionLink';
|
||||||
import StopPositionProperty from './properties/StopPositionProperty.vue';
|
import StopPositionProperty from './properties/StopPositionProperty.vue';
|
||||||
import { StopPosition } from 'src/graphics/stopPosition/StopPosition';
|
import { StopPosition } from 'src/graphics/stopPosition/StopPosition';
|
||||||
|
79
src/components/draw-app/properties/TransponderProperty.vue
Normal file
79
src/components/draw-app/properties/TransponderProperty.vue
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<template>
|
||||||
|
<q-form>
|
||||||
|
<q-input
|
||||||
|
outlined
|
||||||
|
readonly
|
||||||
|
v-model="transponderModel.id"
|
||||||
|
label="id"
|
||||||
|
hint=""
|
||||||
|
/>
|
||||||
|
<q-input
|
||||||
|
outlined
|
||||||
|
class="q-mt-lg"
|
||||||
|
v-model="transponderModel.code"
|
||||||
|
@blur="onUpdate"
|
||||||
|
label="编号"
|
||||||
|
/>
|
||||||
|
<q-input
|
||||||
|
outlined
|
||||||
|
class="q-mt-lg"
|
||||||
|
v-model.number="transponderModel.index"
|
||||||
|
@blur="onUpdate"
|
||||||
|
label="索引"
|
||||||
|
/>
|
||||||
|
<q-select
|
||||||
|
outlined
|
||||||
|
style="margin-top: 10px"
|
||||||
|
v-model="transponderModel.transponderType"
|
||||||
|
:options="typeOptions"
|
||||||
|
:map-options="true"
|
||||||
|
:emit-value="true"
|
||||||
|
@update:model-value="onUpdate"
|
||||||
|
label="应答器类型"
|
||||||
|
></q-select>
|
||||||
|
</q-form>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { TransponderData } from 'src/drawApp/graphics/TransponderInteraction';
|
||||||
|
import {
|
||||||
|
Transponder,
|
||||||
|
transponderTypeEnum,
|
||||||
|
} from 'src/graphics/transponder/Transponder';
|
||||||
|
import { useDrawStore } from 'src/stores/draw-store';
|
||||||
|
import { onMounted, reactive, watch } from 'vue';
|
||||||
|
|
||||||
|
const drawStore = useDrawStore();
|
||||||
|
const transponderModel = reactive(new TransponderData());
|
||||||
|
const typeOptions = [
|
||||||
|
{ label: '固定应答器', value: transponderTypeEnum.FB },
|
||||||
|
{ label: '轮径校正应答器', value: transponderTypeEnum.WB },
|
||||||
|
{ label: '休眠唤醒应答器', value: transponderTypeEnum.DB },
|
||||||
|
];
|
||||||
|
|
||||||
|
drawStore.$subscribe;
|
||||||
|
watch(
|
||||||
|
() => drawStore.selectedGraphic,
|
||||||
|
(val) => {
|
||||||
|
if (val && val.type == Transponder.Type) {
|
||||||
|
transponderModel.copyFrom(val.saveData() as TransponderData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
const Transponder = drawStore.selectedGraphic as Transponder;
|
||||||
|
if (Transponder) {
|
||||||
|
transponderModel.copyFrom(Transponder.saveData());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function onUpdate() {
|
||||||
|
const Transponder = drawStore.selectedGraphic as Transponder;
|
||||||
|
if (Transponder) {
|
||||||
|
drawStore
|
||||||
|
.getDrawApp()
|
||||||
|
.updateGraphicAndRecord(Transponder, transponderModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
55
src/drawApp/graphics/TransponderInteraction.ts
Normal file
55
src/drawApp/graphics/TransponderInteraction.ts
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
import * as pb_1 from 'google-protobuf';
|
||||||
|
import {
|
||||||
|
ITransponderData,
|
||||||
|
Transponder,
|
||||||
|
} from 'src/graphics/transponder/Transponder';
|
||||||
|
import { graphicData } from 'src/protos/stationLayoutGraphics';
|
||||||
|
import { GraphicDataBase } from './GraphicDataBase';
|
||||||
|
|
||||||
|
export class TransponderData
|
||||||
|
extends GraphicDataBase
|
||||||
|
implements ITransponderData
|
||||||
|
{
|
||||||
|
constructor(data?: graphicData.Transponder) {
|
||||||
|
let transponder;
|
||||||
|
if (!data) {
|
||||||
|
transponder = new graphicData.Transponder({
|
||||||
|
common: GraphicDataBase.defaultCommonInfo(Transponder.Type),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
transponder = data;
|
||||||
|
}
|
||||||
|
super(transponder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public get data(): graphicData.Transponder {
|
||||||
|
return this.getData<graphicData.Transponder>();
|
||||||
|
}
|
||||||
|
get code(): string {
|
||||||
|
return this.data.code;
|
||||||
|
}
|
||||||
|
set code(v: string) {
|
||||||
|
this.data.code = v;
|
||||||
|
}
|
||||||
|
get transponderType(): number {
|
||||||
|
return this.data.transponderType;
|
||||||
|
}
|
||||||
|
set transponderType(v: number) {
|
||||||
|
this.data.transponderType = v;
|
||||||
|
}
|
||||||
|
get index(): number {
|
||||||
|
return this.data.index;
|
||||||
|
}
|
||||||
|
set index(v: number) {
|
||||||
|
this.data.index = v;
|
||||||
|
}
|
||||||
|
clone(): TransponderData {
|
||||||
|
return new TransponderData(this.data.cloneMessage());
|
||||||
|
}
|
||||||
|
copyFrom(data: TransponderData): void {
|
||||||
|
pb_1.Message.copyInto(data.data, this.data);
|
||||||
|
}
|
||||||
|
eq(other: TransponderData): boolean {
|
||||||
|
return pb_1.Message.equals(this.data, other.data);
|
||||||
|
}
|
||||||
|
}
|
@ -99,6 +99,12 @@ import { Notify, Dialog } from 'quasar';
|
|||||||
import { checkMapData } from 'src/api/Simulation';
|
import { checkMapData } from 'src/api/Simulation';
|
||||||
import { SpksSwitchDraw } from 'src/graphics/spksSwitch/SpksSwitchDrawAssistant';
|
import { SpksSwitchDraw } from 'src/graphics/spksSwitch/SpksSwitchDrawAssistant';
|
||||||
import { GatedBoxDraw } from 'src/graphics/gatedBox/GatedBoxDrawAssistant';
|
import { GatedBoxDraw } from 'src/graphics/gatedBox/GatedBoxDrawAssistant';
|
||||||
|
import { TransponderDraw } from 'src/graphics/transponder/TransponderDrawAssistant';
|
||||||
|
import {
|
||||||
|
Transponder,
|
||||||
|
TransponderTemplate,
|
||||||
|
} from 'src/graphics/transponder/Transponder';
|
||||||
|
import { TransponderData } from './graphics/TransponderInteraction';
|
||||||
|
|
||||||
// export function fromStoragePoint(p: graphicData.Point): Point {
|
// export function fromStoragePoint(p: graphicData.Point): Point {
|
||||||
// return new Point(p.x, p.y);
|
// return new Point(p.x, p.y);
|
||||||
@ -234,6 +240,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
|||||||
| StopPositionDraw
|
| StopPositionDraw
|
||||||
| SpksSwitchDraw
|
| SpksSwitchDraw
|
||||||
| GatedBoxDraw
|
| GatedBoxDraw
|
||||||
|
| TransponderDraw
|
||||||
)[] = [];
|
)[] = [];
|
||||||
if (draftType === 'Line') {
|
if (draftType === 'Line') {
|
||||||
drawAssistants = [
|
drawAssistants = [
|
||||||
@ -271,6 +278,7 @@ export function initDrawApp(dom: HTMLElement): JlDrawApp {
|
|||||||
app,
|
app,
|
||||||
new LogicSectionTemplate(new LogicSectionData())
|
new LogicSectionTemplate(new LogicSectionData())
|
||||||
),
|
),
|
||||||
|
new TransponderDraw(app, new TransponderTemplate(new TransponderData())),
|
||||||
new StopPositionDraw(
|
new StopPositionDraw(
|
||||||
app,
|
app,
|
||||||
new StopPositionTemplate(new StopPositionData())
|
new StopPositionTemplate(new StopPositionData())
|
||||||
@ -482,6 +490,9 @@ export function saveDrawDatas(app: JlDrawApp) {
|
|||||||
} else if (GatedBox.Type === g.type) {
|
} else if (GatedBox.Type === g.type) {
|
||||||
const gatedBoxData = (g as GatedBox).saveData();
|
const gatedBoxData = (g as GatedBox).saveData();
|
||||||
storage.gateBoxs.push((gatedBoxData as GatedBoxData).data);
|
storage.gateBoxs.push((gatedBoxData as GatedBoxData).data);
|
||||||
|
} else if (Transponder.Type === g.type) {
|
||||||
|
const transponderData = (g as Transponder).saveData();
|
||||||
|
storage.transponders.push((transponderData as TransponderData).data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
const base64 = fromUint8Array(storage.serialize());
|
const base64 = fromUint8Array(storage.serialize());
|
||||||
@ -559,6 +570,9 @@ export async function loadDrawDatas(app: GraphicApp) {
|
|||||||
storage.gateBoxs.forEach((gatedBox) => {
|
storage.gateBoxs.forEach((gatedBox) => {
|
||||||
datas.push(new GatedBoxData(gatedBox));
|
datas.push(new GatedBoxData(gatedBox));
|
||||||
});
|
});
|
||||||
|
storage.transponders.forEach((transponder) => {
|
||||||
|
datas.push(new TransponderData(transponder));
|
||||||
|
});
|
||||||
await app.loadGraphic(datas);
|
await app.loadGraphic(datas);
|
||||||
} else {
|
} else {
|
||||||
app.loadGraphic([]);
|
app.loadGraphic([]);
|
||||||
|
164
src/graphics/transponder/Transponder.ts
Normal file
164
src/graphics/transponder/Transponder.ts
Normal file
@ -0,0 +1,164 @@
|
|||||||
|
import { Container, Graphics } from 'pixi.js';
|
||||||
|
import {
|
||||||
|
GraphicData,
|
||||||
|
JlGraphic,
|
||||||
|
JlGraphicTemplate,
|
||||||
|
VectorText,
|
||||||
|
} from 'src/jl-graphic';
|
||||||
|
|
||||||
|
export interface ITransponderData extends GraphicData {
|
||||||
|
get code(): string; // 编号
|
||||||
|
set code(v: string);
|
||||||
|
get transponderType(): number; // 类型
|
||||||
|
set transponderType(v: number);
|
||||||
|
get index(): number; // 索引
|
||||||
|
set index(v: number);
|
||||||
|
clone(): ITransponderData;
|
||||||
|
copyFrom(data: ITransponderData): void;
|
||||||
|
eq(other: ITransponderData): boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum transponderTypeEnum {
|
||||||
|
FB, // 固定应答器
|
||||||
|
WB, // 轮径校正应答器
|
||||||
|
DB, // 休眠唤醒应答器
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TransponderConsts = {
|
||||||
|
height: 12,
|
||||||
|
lineWidth: 2,
|
||||||
|
lineColor: '0xFFFFFF',
|
||||||
|
wblineColor: '0xFF0000',
|
||||||
|
textFontSize: 12,
|
||||||
|
textMarginY: 5, // 名称与应答器的距离
|
||||||
|
};
|
||||||
|
export const transponderTypePoints = {
|
||||||
|
[transponderTypeEnum[transponderTypeEnum.FB]]: [
|
||||||
|
[-TransponderConsts.height / 2, -TransponderConsts.height / 2],
|
||||||
|
[TransponderConsts.height / 2, -TransponderConsts.height / 2],
|
||||||
|
[TransponderConsts.height / 2, TransponderConsts.height / 2],
|
||||||
|
[-TransponderConsts.height / 2, TransponderConsts.height / 2],
|
||||||
|
[
|
||||||
|
-TransponderConsts.height / 2,
|
||||||
|
-TransponderConsts.height / 2 - TransponderConsts.lineWidth / 2,
|
||||||
|
],
|
||||||
|
[-TransponderConsts.height / 2, -TransponderConsts.height / 2],
|
||||||
|
[TransponderConsts.height / 2, TransponderConsts.height / 2],
|
||||||
|
[TransponderConsts.height / 2, -TransponderConsts.height / 2],
|
||||||
|
[-TransponderConsts.height / 2, TransponderConsts.height / 2],
|
||||||
|
],
|
||||||
|
[transponderTypeEnum[transponderTypeEnum.WB]]: [
|
||||||
|
[-TransponderConsts.height / 2, -TransponderConsts.height / 2],
|
||||||
|
[TransponderConsts.height / 2, -TransponderConsts.height / 2],
|
||||||
|
[TransponderConsts.height / 2, TransponderConsts.height / 2],
|
||||||
|
[-TransponderConsts.height / 2, TransponderConsts.height / 2],
|
||||||
|
[
|
||||||
|
-TransponderConsts.height / 2,
|
||||||
|
-TransponderConsts.height / 2 - TransponderConsts.lineWidth / 2,
|
||||||
|
],
|
||||||
|
[0, -TransponderConsts.height / 2],
|
||||||
|
[0, TransponderConsts.height / 2],
|
||||||
|
[TransponderConsts.height / 2, 0],
|
||||||
|
[-TransponderConsts.height / 2, 0],
|
||||||
|
],
|
||||||
|
[transponderTypeEnum[transponderTypeEnum.DB]]: [
|
||||||
|
[-TransponderConsts.height, -TransponderConsts.height / 2],
|
||||||
|
[TransponderConsts.height, -TransponderConsts.height / 2],
|
||||||
|
[TransponderConsts.height, TransponderConsts.height / 2],
|
||||||
|
[-TransponderConsts.height, TransponderConsts.height / 2],
|
||||||
|
[
|
||||||
|
-TransponderConsts.height,
|
||||||
|
-TransponderConsts.height / 2 - TransponderConsts.lineWidth / 2,
|
||||||
|
],
|
||||||
|
[-TransponderConsts.height, -TransponderConsts.height / 2],
|
||||||
|
[TransponderConsts.height, TransponderConsts.height / 2],
|
||||||
|
[TransponderConsts.height, -TransponderConsts.height / 2],
|
||||||
|
[-TransponderConsts.height, TransponderConsts.height / 2],
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export class TransponderCode extends Container {
|
||||||
|
codeText: VectorText = new VectorText('');
|
||||||
|
name = 'transponderCode';
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.addChild(this.codeText);
|
||||||
|
}
|
||||||
|
clear() {
|
||||||
|
this.codeText.text = '';
|
||||||
|
}
|
||||||
|
paint(datas: ITransponderData) {
|
||||||
|
this.codeText.text = datas.code;
|
||||||
|
this.codeText.anchor.set(0.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Transponder extends JlGraphic {
|
||||||
|
static Type = 'Transponder';
|
||||||
|
polygonGraphic: Graphics = new Graphics();
|
||||||
|
labelGraphic: TransponderCode = new TransponderCode();
|
||||||
|
constructor() {
|
||||||
|
super(Transponder.Type);
|
||||||
|
this.addChild(this.polygonGraphic);
|
||||||
|
this.addChild(this.labelGraphic);
|
||||||
|
}
|
||||||
|
get datas(): ITransponderData {
|
||||||
|
return this.getDatas<ITransponderData>();
|
||||||
|
}
|
||||||
|
clear() {
|
||||||
|
this.polygonGraphic.clear();
|
||||||
|
this.labelGraphic.clear();
|
||||||
|
}
|
||||||
|
doRepaint(): void {
|
||||||
|
this.clear();
|
||||||
|
const polygonGraphic = this.polygonGraphic;
|
||||||
|
const type = transponderTypeEnum[this.datas.transponderType];
|
||||||
|
const ps = transponderTypePoints[type];
|
||||||
|
const lineColor =
|
||||||
|
type == 'WB'
|
||||||
|
? TransponderConsts.wblineColor
|
||||||
|
: TransponderConsts.lineColor;
|
||||||
|
polygonGraphic.lineStyle(TransponderConsts.lineWidth, lineColor);
|
||||||
|
const indexArr = [0, 5, 7];
|
||||||
|
ps.forEach((item, index) => {
|
||||||
|
if (indexArr.includes(index)) {
|
||||||
|
polygonGraphic.moveTo(item[0], item[1]);
|
||||||
|
} else {
|
||||||
|
polygonGraphic.lineTo(item[0], item[1]);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.labelGraphic.paint(this.datas);
|
||||||
|
const style = {
|
||||||
|
fill: lineColor,
|
||||||
|
fontSize: TransponderConsts.textFontSize,
|
||||||
|
};
|
||||||
|
this.labelGraphic.codeText.style = style;
|
||||||
|
const codeTransform = this.datas?.childTransforms?.find(
|
||||||
|
(item) => item.name === 'transponderCode'
|
||||||
|
);
|
||||||
|
if (codeTransform) {
|
||||||
|
const position = codeTransform?.transform.position;
|
||||||
|
const rotation = codeTransform?.transform?.rotation;
|
||||||
|
this.labelGraphic.position.set(position?.x, position?.y);
|
||||||
|
this.labelGraphic.rotation = rotation || 0;
|
||||||
|
} else {
|
||||||
|
const { height: polygonHeight } = this.polygonGraphic.getLocalBounds();
|
||||||
|
const { height: textHeight } = this.labelGraphic.getLocalBounds();
|
||||||
|
this.labelGraphic.position.set(
|
||||||
|
0,
|
||||||
|
polygonHeight / 2 + textHeight / 2 + TransponderConsts.textMarginY
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TransponderTemplate extends JlGraphicTemplate<Transponder> {
|
||||||
|
constructor(dataTemplate: ITransponderData) {
|
||||||
|
super(Transponder.Type, {
|
||||||
|
dataTemplate,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
new(): Transponder {
|
||||||
|
return new Transponder();
|
||||||
|
}
|
||||||
|
}
|
187
src/graphics/transponder/TransponderDrawAssistant.ts
Normal file
187
src/graphics/transponder/TransponderDrawAssistant.ts
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
import { DisplayObject, FederatedPointerEvent, IHitArea, Point } from 'pixi.js';
|
||||||
|
import {
|
||||||
|
AbsorbableLine,
|
||||||
|
AbsorbablePosition,
|
||||||
|
GraphicDrawAssistant,
|
||||||
|
GraphicInteractionPlugin,
|
||||||
|
GraphicTransformEvent,
|
||||||
|
JlDrawApp,
|
||||||
|
JlGraphic,
|
||||||
|
linePoint,
|
||||||
|
} from 'src/jl-graphic';
|
||||||
|
import {
|
||||||
|
ITransponderData,
|
||||||
|
Transponder,
|
||||||
|
TransponderConsts,
|
||||||
|
TransponderTemplate,
|
||||||
|
transponderTypeEnum,
|
||||||
|
transponderTypePoints,
|
||||||
|
} from './Transponder';
|
||||||
|
|
||||||
|
export class TransponderDraw extends GraphicDrawAssistant<
|
||||||
|
TransponderTemplate,
|
||||||
|
ITransponderData
|
||||||
|
> {
|
||||||
|
TransponderGraph: Transponder;
|
||||||
|
constructor(app: JlDrawApp, template: TransponderTemplate) {
|
||||||
|
super(app, template, 'border_all', '应答器Transponder');
|
||||||
|
this.TransponderGraph = this.graphicTemplate.new();
|
||||||
|
this.container.addChild(this.TransponderGraph);
|
||||||
|
TransponderInteraction.init(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
bind(): void {
|
||||||
|
super.bind();
|
||||||
|
this.TransponderGraph.loadData(this.graphicTemplate.datas);
|
||||||
|
this.TransponderGraph.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: ITransponderData): boolean {
|
||||||
|
data.transform = this.container.saveTransform();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//碰撞检测
|
||||||
|
export class TransponderGraphicHitArea implements IHitArea {
|
||||||
|
transponder: Transponder;
|
||||||
|
constructor(transponder: Transponder) {
|
||||||
|
this.transponder = transponder;
|
||||||
|
}
|
||||||
|
contains(x: number, y: number): boolean {
|
||||||
|
let contains = false;
|
||||||
|
const p = new Point(x, y);
|
||||||
|
const type = transponderTypeEnum[this.transponder.datas.transponderType];
|
||||||
|
const ps = transponderTypePoints[type];
|
||||||
|
const tolerance = TransponderConsts.lineWidth;
|
||||||
|
const indexArr = [0, 5, 7];
|
||||||
|
ps.forEach((item, index) => {
|
||||||
|
if (!indexArr.includes(index)) {
|
||||||
|
const p1 = new Point(ps[index - 1][0], ps[index - 1][1]);
|
||||||
|
const p2 = new Point(item[0], item[1]);
|
||||||
|
contains = contains || linePoint(p1, p2, p, tolerance);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return contains;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export class TransponderInteraction extends GraphicInteractionPlugin<Transponder> {
|
||||||
|
static Name = 'Transponder_transform';
|
||||||
|
constructor(app: JlDrawApp) {
|
||||||
|
super(TransponderInteraction.Name, app);
|
||||||
|
}
|
||||||
|
static init(app: JlDrawApp) {
|
||||||
|
return new TransponderInteraction(app);
|
||||||
|
}
|
||||||
|
filter(...grahpics: JlGraphic[]): Transponder[] | undefined {
|
||||||
|
return grahpics
|
||||||
|
.filter((g) => g.type === Transponder.Type)
|
||||||
|
.map((g) => g as Transponder);
|
||||||
|
}
|
||||||
|
bind(g: Transponder): void {
|
||||||
|
g.polygonGraphic.eventMode = 'static';
|
||||||
|
g.polygonGraphic.cursor = 'pointer';
|
||||||
|
g.polygonGraphic.scalable = true;
|
||||||
|
g.polygonGraphic.hitArea = new TransponderGraphicHitArea(g);
|
||||||
|
g.on('transformstart', this.transformstart, this);
|
||||||
|
g.labelGraphic.on('transformstart', this.codetransformstart, this);
|
||||||
|
g.labelGraphic.draggable = true;
|
||||||
|
g.labelGraphic.selectable = true;
|
||||||
|
g.labelGraphic.rotatable = true;
|
||||||
|
g.labelGraphic.transformSave = true;
|
||||||
|
g.labelGraphic.eventMode = 'static';
|
||||||
|
}
|
||||||
|
unbind(g: Transponder): void {
|
||||||
|
g.polygonGraphic.eventMode = 'none';
|
||||||
|
g.polygonGraphic.scalable = false;
|
||||||
|
g.polygonGraphic.rotatable = false;
|
||||||
|
g.off('transformstart', this.transformstart, this);
|
||||||
|
g.labelGraphic.off('transformstart', this.codetransformstart, this);
|
||||||
|
g.labelGraphic.draggable = false;
|
||||||
|
g.labelGraphic.selectable = false;
|
||||||
|
g.labelGraphic.rotatable = false;
|
||||||
|
g.labelGraphic.transformSave = false;
|
||||||
|
g.labelGraphic.eventMode = 'none';
|
||||||
|
}
|
||||||
|
transformstart(e: GraphicTransformEvent) {
|
||||||
|
const target = e.target as DisplayObject;
|
||||||
|
const transponder = target.getGraphic() as Transponder;
|
||||||
|
transponder.getGraphicApp().setOptions({
|
||||||
|
absorbablePositions: buildAbsorbablePositions(transponder),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
codetransformstart(e: GraphicTransformEvent) {
|
||||||
|
const target = e.target as DisplayObject;
|
||||||
|
const transponder = target.getGraphic() as Transponder;
|
||||||
|
transponder.getGraphicApp().setOptions({
|
||||||
|
absorbablePositions: buildCodeAbsorbablePositions(transponder),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 构建吸附线
|
||||||
|
* @param transponder
|
||||||
|
*/
|
||||||
|
function buildAbsorbablePositions(
|
||||||
|
transponder: Transponder
|
||||||
|
): AbsorbablePosition[] {
|
||||||
|
const aps: AbsorbablePosition[] = [];
|
||||||
|
const transponders = transponder.queryStore.queryByType<Transponder>(
|
||||||
|
Transponder.Type
|
||||||
|
);
|
||||||
|
const canvas = transponder.getCanvas();
|
||||||
|
transponders.forEach((item) => {
|
||||||
|
if (item.id === transponder.id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const ala = new AbsorbableLine(
|
||||||
|
new Point(item.x, 0),
|
||||||
|
new Point(item.x, canvas.height)
|
||||||
|
);
|
||||||
|
const alb = new AbsorbableLine(
|
||||||
|
new Point(0, item.y),
|
||||||
|
new Point(canvas.width, item.y)
|
||||||
|
);
|
||||||
|
aps.push(ala);
|
||||||
|
aps.push(alb);
|
||||||
|
});
|
||||||
|
return aps;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 名称构建吸附线
|
||||||
|
* @param transponder
|
||||||
|
*/
|
||||||
|
function buildCodeAbsorbablePositions(
|
||||||
|
transponder: Transponder
|
||||||
|
): AbsorbablePosition[] {
|
||||||
|
const aps: AbsorbablePosition[] = [];
|
||||||
|
const transponders = transponder.queryStore.queryByType<Transponder>(
|
||||||
|
Transponder.Type
|
||||||
|
);
|
||||||
|
const canvas = transponder.getCanvas();
|
||||||
|
transponders.forEach((item) => {
|
||||||
|
const ala = new AbsorbableLine(
|
||||||
|
new Point(item.x, 0),
|
||||||
|
new Point(item.x, canvas.height)
|
||||||
|
);
|
||||||
|
const alb = new AbsorbableLine(
|
||||||
|
new Point(0, item.y),
|
||||||
|
new Point(canvas.width, item.y)
|
||||||
|
);
|
||||||
|
aps.push(ala);
|
||||||
|
aps.push(alb);
|
||||||
|
});
|
||||||
|
return aps;
|
||||||
|
}
|
@ -24,9 +24,10 @@ export namespace graphicData {
|
|||||||
spksSwitchs?: SpksSwitch[];
|
spksSwitchs?: SpksSwitch[];
|
||||||
esbButtons?: EsbButton[];
|
esbButtons?: EsbButton[];
|
||||||
gateBoxs?: GatedBox[];
|
gateBoxs?: GatedBox[];
|
||||||
|
transponders?: Transponder[];
|
||||||
}) {
|
}) {
|
||||||
super();
|
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], 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], this.#one_of_decls);
|
||||||
if (!Array.isArray(data) && typeof data == "object") {
|
if (!Array.isArray(data) && typeof data == "object") {
|
||||||
if ("canvas" in data && data.canvas != undefined) {
|
if ("canvas" in data && data.canvas != undefined) {
|
||||||
this.canvas = data.canvas;
|
this.canvas = data.canvas;
|
||||||
@ -76,6 +77,9 @@ export namespace graphicData {
|
|||||||
if ("gateBoxs" in data && data.gateBoxs != undefined) {
|
if ("gateBoxs" in data && data.gateBoxs != undefined) {
|
||||||
this.gateBoxs = data.gateBoxs;
|
this.gateBoxs = data.gateBoxs;
|
||||||
}
|
}
|
||||||
|
if ("transponders" in data && data.transponders != undefined) {
|
||||||
|
this.transponders = data.transponders;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
get canvas() {
|
get canvas() {
|
||||||
@ -177,6 +181,12 @@ export namespace graphicData {
|
|||||||
set gateBoxs(value: GatedBox[]) {
|
set gateBoxs(value: GatedBox[]) {
|
||||||
pb_1.Message.setRepeatedWrapperField(this, 21, value);
|
pb_1.Message.setRepeatedWrapperField(this, 21, value);
|
||||||
}
|
}
|
||||||
|
get transponders() {
|
||||||
|
return pb_1.Message.getRepeatedWrapperField(this, Transponder, 22) as Transponder[];
|
||||||
|
}
|
||||||
|
set transponders(value: Transponder[]) {
|
||||||
|
pb_1.Message.setRepeatedWrapperField(this, 22, value);
|
||||||
|
}
|
||||||
static fromObject(data: {
|
static fromObject(data: {
|
||||||
canvas?: ReturnType<typeof Canvas.prototype.toObject>;
|
canvas?: ReturnType<typeof Canvas.prototype.toObject>;
|
||||||
Platforms?: ReturnType<typeof Platform.prototype.toObject>[];
|
Platforms?: ReturnType<typeof Platform.prototype.toObject>[];
|
||||||
@ -194,6 +204,7 @@ export namespace graphicData {
|
|||||||
spksSwitchs?: ReturnType<typeof SpksSwitch.prototype.toObject>[];
|
spksSwitchs?: ReturnType<typeof SpksSwitch.prototype.toObject>[];
|
||||||
esbButtons?: ReturnType<typeof EsbButton.prototype.toObject>[];
|
esbButtons?: ReturnType<typeof EsbButton.prototype.toObject>[];
|
||||||
gateBoxs?: ReturnType<typeof GatedBox.prototype.toObject>[];
|
gateBoxs?: ReturnType<typeof GatedBox.prototype.toObject>[];
|
||||||
|
transponders?: ReturnType<typeof Transponder.prototype.toObject>[];
|
||||||
}): RtssGraphicStorage {
|
}): RtssGraphicStorage {
|
||||||
const message = new RtssGraphicStorage({});
|
const message = new RtssGraphicStorage({});
|
||||||
if (data.canvas != null) {
|
if (data.canvas != null) {
|
||||||
@ -244,6 +255,9 @@ export namespace graphicData {
|
|||||||
if (data.gateBoxs != null) {
|
if (data.gateBoxs != null) {
|
||||||
message.gateBoxs = data.gateBoxs.map(item => GatedBox.fromObject(item));
|
message.gateBoxs = data.gateBoxs.map(item => GatedBox.fromObject(item));
|
||||||
}
|
}
|
||||||
|
if (data.transponders != null) {
|
||||||
|
message.transponders = data.transponders.map(item => Transponder.fromObject(item));
|
||||||
|
}
|
||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
toObject() {
|
toObject() {
|
||||||
@ -264,6 +278,7 @@ export namespace graphicData {
|
|||||||
spksSwitchs?: ReturnType<typeof SpksSwitch.prototype.toObject>[];
|
spksSwitchs?: ReturnType<typeof SpksSwitch.prototype.toObject>[];
|
||||||
esbButtons?: ReturnType<typeof EsbButton.prototype.toObject>[];
|
esbButtons?: ReturnType<typeof EsbButton.prototype.toObject>[];
|
||||||
gateBoxs?: ReturnType<typeof GatedBox.prototype.toObject>[];
|
gateBoxs?: ReturnType<typeof GatedBox.prototype.toObject>[];
|
||||||
|
transponders?: ReturnType<typeof Transponder.prototype.toObject>[];
|
||||||
} = {};
|
} = {};
|
||||||
if (this.canvas != null) {
|
if (this.canvas != null) {
|
||||||
data.canvas = this.canvas.toObject();
|
data.canvas = this.canvas.toObject();
|
||||||
@ -313,6 +328,9 @@ export namespace graphicData {
|
|||||||
if (this.gateBoxs != null) {
|
if (this.gateBoxs != null) {
|
||||||
data.gateBoxs = this.gateBoxs.map((item: GatedBox) => item.toObject());
|
data.gateBoxs = this.gateBoxs.map((item: GatedBox) => item.toObject());
|
||||||
}
|
}
|
||||||
|
if (this.transponders != null) {
|
||||||
|
data.transponders = this.transponders.map((item: Transponder) => item.toObject());
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
serialize(): Uint8Array;
|
serialize(): Uint8Array;
|
||||||
@ -351,6 +369,8 @@ export namespace graphicData {
|
|||||||
writer.writeRepeatedMessage(20, this.esbButtons, (item: EsbButton) => item.serialize(writer));
|
writer.writeRepeatedMessage(20, this.esbButtons, (item: EsbButton) => item.serialize(writer));
|
||||||
if (this.gateBoxs.length)
|
if (this.gateBoxs.length)
|
||||||
writer.writeRepeatedMessage(21, this.gateBoxs, (item: GatedBox) => item.serialize(writer));
|
writer.writeRepeatedMessage(21, this.gateBoxs, (item: GatedBox) => item.serialize(writer));
|
||||||
|
if (this.transponders.length)
|
||||||
|
writer.writeRepeatedMessage(22, this.transponders, (item: Transponder) => item.serialize(writer));
|
||||||
if (!w)
|
if (!w)
|
||||||
return writer.getResultBuffer();
|
return writer.getResultBuffer();
|
||||||
}
|
}
|
||||||
@ -408,6 +428,9 @@ export namespace graphicData {
|
|||||||
case 21:
|
case 21:
|
||||||
reader.readMessage(message.gateBoxs, () => pb_1.Message.addToRepeatedWrapperField(message, 21, GatedBox.deserialize(reader), GatedBox));
|
reader.readMessage(message.gateBoxs, () => pb_1.Message.addToRepeatedWrapperField(message, 21, GatedBox.deserialize(reader), GatedBox));
|
||||||
break;
|
break;
|
||||||
|
case 22:
|
||||||
|
reader.readMessage(message.transponders, () => pb_1.Message.addToRepeatedWrapperField(message, 22, Transponder.deserialize(reader), Transponder));
|
||||||
|
break;
|
||||||
default: reader.skipField();
|
default: reader.skipField();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2774,6 +2797,145 @@ export namespace graphicData {
|
|||||||
return Separator.deserialize(bytes);
|
return Separator.deserialize(bytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export class Transponder extends pb_1.Message {
|
||||||
|
#one_of_decls: number[][] = [];
|
||||||
|
constructor(data?: any[] | {
|
||||||
|
common?: CommonInfo;
|
||||||
|
code?: string;
|
||||||
|
transponderType?: number;
|
||||||
|
index?: number;
|
||||||
|
}) {
|
||||||
|
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 ("transponderType" in data && data.transponderType != undefined) {
|
||||||
|
this.transponderType = data.transponderType;
|
||||||
|
}
|
||||||
|
if ("index" in data && data.index != undefined) {
|
||||||
|
this.index = data.index;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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 transponderType() {
|
||||||
|
return pb_1.Message.getFieldWithDefault(this, 3, 0) as number;
|
||||||
|
}
|
||||||
|
set transponderType(value: number) {
|
||||||
|
pb_1.Message.setField(this, 3, value);
|
||||||
|
}
|
||||||
|
get index() {
|
||||||
|
return pb_1.Message.getFieldWithDefault(this, 4, 0) as number;
|
||||||
|
}
|
||||||
|
set index(value: number) {
|
||||||
|
pb_1.Message.setField(this, 4, value);
|
||||||
|
}
|
||||||
|
static fromObject(data: {
|
||||||
|
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||||
|
code?: string;
|
||||||
|
transponderType?: number;
|
||||||
|
index?: number;
|
||||||
|
}): Transponder {
|
||||||
|
const message = new Transponder({});
|
||||||
|
if (data.common != null) {
|
||||||
|
message.common = CommonInfo.fromObject(data.common);
|
||||||
|
}
|
||||||
|
if (data.code != null) {
|
||||||
|
message.code = data.code;
|
||||||
|
}
|
||||||
|
if (data.transponderType != null) {
|
||||||
|
message.transponderType = data.transponderType;
|
||||||
|
}
|
||||||
|
if (data.index != null) {
|
||||||
|
message.index = data.index;
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
toObject() {
|
||||||
|
const data: {
|
||||||
|
common?: ReturnType<typeof CommonInfo.prototype.toObject>;
|
||||||
|
code?: string;
|
||||||
|
transponderType?: number;
|
||||||
|
index?: number;
|
||||||
|
} = {};
|
||||||
|
if (this.common != null) {
|
||||||
|
data.common = this.common.toObject();
|
||||||
|
}
|
||||||
|
if (this.code != null) {
|
||||||
|
data.code = this.code;
|
||||||
|
}
|
||||||
|
if (this.transponderType != null) {
|
||||||
|
data.transponderType = this.transponderType;
|
||||||
|
}
|
||||||
|
if (this.index != null) {
|
||||||
|
data.index = this.index;
|
||||||
|
}
|
||||||
|
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.transponderType != 0)
|
||||||
|
writer.writeInt32(3, this.transponderType);
|
||||||
|
if (this.index != 0)
|
||||||
|
writer.writeInt32(4, this.index);
|
||||||
|
if (!w)
|
||||||
|
return writer.getResultBuffer();
|
||||||
|
}
|
||||||
|
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): Transponder {
|
||||||
|
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new Transponder();
|
||||||
|
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.transponderType = reader.readInt32();
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
message.index = reader.readInt32();
|
||||||
|
break;
|
||||||
|
default: reader.skipField();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
serializeBinary(): Uint8Array {
|
||||||
|
return this.serialize();
|
||||||
|
}
|
||||||
|
static deserializeBinary(bytes: Uint8Array): Transponder {
|
||||||
|
return Transponder.deserialize(bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
export class SimpleRef extends pb_1.Message {
|
export class SimpleRef extends pb_1.Message {
|
||||||
#one_of_decls: number[][] = [];
|
#one_of_decls: number[][] = [];
|
||||||
constructor(data?: any[] | {
|
constructor(data?: any[] | {
|
||||||
|
Loading…
Reference in New Issue
Block a user