集中区分割线关联数据增加端点

This commit is contained in:
joylink_zhaoerwei 2023-12-04 11:27:57 +08:00
parent 9677f87c96
commit 1b4e4fcc71
4 changed files with 112 additions and 65 deletions

View File

@ -28,15 +28,15 @@
/>
<q-list bordered separator class="rounded-borders">
<q-item
v-for="(sectionRelation, index) in sectionRelations"
:key="sectionRelation"
v-for="sectionRelation in sectionRelations"
:key="sectionRelation.label"
>
<q-item-section no-wrap class="q-gutter-y-sm column">
<q-item-label> 关联的区段-交点{{ index + 1 }} </q-item-label>
<q-item-label> {{ sectionRelation.label }} </q-item-label>
<div class="q-gutter-sm row">
<q-chip
v-for="item in sectionRelation"
:key="item"
v-for="(item, index) in sectionRelation.refSectionInfo"
:key="index"
square
color="primary"
text-color="white"
@ -67,26 +67,37 @@ const { data: concentrationDividingLineModel, onUpdate } = useFormData(
const centralizedStations = ref<{ label: string; value: string }[]>([]);
const sectionRelations = computed(() => {
const refSectionInfo: string[][] = [];
const refSectionInfo: { label: string; refSectionInfo: string[] }[] = [
{ label: '左边关联的区段', refSectionInfo: [] },
{ label: '右边关联的区段', refSectionInfo: [] },
];
enum devicePort {
'A',
'B',
}
const concentrationDividingLine =
drawStore.selectedGraphic as ConcentrationDividingLine;
concentrationDividingLine.datas.nodeConWithSecs.forEach((nodeConWithSec) => {
const refleftSection =
nodeConWithSec.leftSectionId !== ''
? drawStore
.getDrawApp()
.queryStore.queryById<Section>(nodeConWithSec.leftSectionId).datas
.code
nodeConWithSec.leftSection.id !== ''
? `${
drawStore
.getDrawApp()
.queryStore.queryById<Section>(nodeConWithSec.leftSection.id)
.datas.code
}(${devicePort[nodeConWithSec.leftSection.devicePort]})`
: '边界';
refSectionInfo[0].refSectionInfo.push(refleftSection);
const refRightSection =
nodeConWithSec.rightSectionId !== ''
? drawStore
.getDrawApp()
.queryStore.queryById<Section>(nodeConWithSec.rightSectionId).datas
.code
nodeConWithSec.rightSection.id !== ''
? `${
drawStore
.getDrawApp()
.queryStore.queryById<Section>(nodeConWithSec.rightSection.id)
.datas.code
}(${devicePort[nodeConWithSec.rightSection.devicePort]})`
: '边界';
refSectionInfo.push([`${refleftSection}`, `${refRightSection}`]);
refSectionInfo[1].refSectionInfo.push(refRightSection);
});
return refSectionInfo;
});

View File

@ -9,8 +9,9 @@ import {
import { ILineGraphic } from 'src/jl-graphic/plugins/GraphicEditPlugin';
import { SectionGraphic } from '../sectionGraphic/SectionGraphic';
import { graphicData } from 'src/protos/stationLayoutGraphics';
import { Section, SectionType } from '../section/Section';
import { Section, SectionPort, SectionType } from '../section/Section';
import { arePolylinesIntersect } from './ConcentrationDividingLineUtils';
import { createRelatedRefProto } from '../CommonGraphics';
export interface IConcentrationDividingLineData extends GraphicData {
get code(): string; // 编号
@ -115,8 +116,16 @@ export class ConcentrationDividingLine
: [section.id, sectionRelations[0].id];
nodeConWithSecs.push(
new graphicData.NodeConWithSec({
leftSectionId,
rightSectionId,
leftSection: createRelatedRefProto(
Section.Type,
leftSectionId,
SectionPort.B
),
rightSection: createRelatedRefProto(
Section.Type,
rightSectionId,
SectionPort.A
),
})
);
} else if (sectionRelations.length == 0) {
@ -124,8 +133,16 @@ export class ConcentrationDividingLine
relationParam === 'A' ? ['', section.id] : [section.id, ''];
nodeConWithSecs.push(
new graphicData.NodeConWithSec({
leftSectionId,
rightSectionId,
leftSection: createRelatedRefProto(
Section.Type,
leftSectionId,
SectionPort.B
),
rightSection: createRelatedRefProto(
Section.Type,
rightSectionId,
SectionPort.A
),
})
);
}
@ -133,10 +150,10 @@ export class ConcentrationDividingLine
});
nodeConWithSecs.sort((a, b) => {
const sectionAId =
a.leftSectionId !== '' ? a.leftSectionId : a.rightSectionId;
a.leftSection.id !== '' ? a.leftSection.id : a.rightSection.id;
const sectionA = this.queryStore.queryById<Section>(sectionAId);
const sectionBId =
b.leftSectionId !== '' ? b.leftSectionId : b.rightSectionId;
b.leftSection.id !== '' ? b.leftSection.id : b.rightSection.id;
const sectionB = this.queryStore.queryById<Section>(sectionBId);
return (
sectionA.localToCanvasPoint(

View File

@ -615,7 +615,6 @@ function oneClickgenerateStopPosition() {
function oneClickRelateCentralizedStation() {
const drawApp = drawStore.getDrawApp();
const devicePort = graphicData.RelatedRef.DevicePort;
const concentrationDividingLines = drawApp.queryStore
.queryByType<ConcentrationDividingLine>(ConcentrationDividingLine.Type)
.sort((a, b) => a.datas.points[0].x - b.datas.points[0].x);
@ -623,10 +622,16 @@ function oneClickRelateCentralizedStation() {
let containDeviceIds: string[] = [];
//
const rightDatas = concentrationDividingLines[i].datas;
const rightSections: Section[] = [];
const rightSections: {
section: Section;
port: graphicData.RelatedRef.DevicePort;
}[] = [];
rightDatas.nodeConWithSecs.forEach((node) => {
if (node.rightSectionId !== '') {
rightSections.push(drawApp.queryStore.queryById(node.rightSectionId));
if (node.rightSection.id !== '') {
rightSections.push({
section: drawApp.queryStore.queryById(node.rightSection.id),
port: node.rightSection.devicePort,
});
}
});
//
@ -635,16 +640,24 @@ function oneClickRelateCentralizedStation() {
const LeftDatas = concentrationDividingLines[j].datas;
if (LeftDatas.refLeftStationId == rightDatas.refRightStationId) {
LeftDatas.nodeConWithSecs.forEach((node) => {
if (node.leftSectionId !== '') {
leftSections.push(node.leftSectionId);
if (node.leftSection.id !== '') {
leftSections.push(node.leftSection.id);
}
});
}
}
containDeviceIds = [...rightSections.map((g) => g.id), ...leftSections];
containDeviceIds = [
...rightSections.map((g) => g.section.id),
...leftSections,
];
//
rightSections.forEach((rightSection) => {
findContainDevice(rightSection, devicePort.A, containDeviceIds, drawApp);
findContainDevice(
rightSection.section,
rightSection.port,
containDeviceIds,
drawApp
);
containDeviceIds = Array.from(new Set(containDeviceIds));
});

View File

@ -1854,55 +1854,61 @@ export namespace graphicData {
export class NodeConWithSec extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
leftSectionId?: string;
rightSectionId?: string;
leftSection?: RelatedRef;
rightSection?: RelatedRef;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
if (!Array.isArray(data) && typeof data == "object") {
if ("leftSectionId" in data && data.leftSectionId != undefined) {
this.leftSectionId = data.leftSectionId;
if ("leftSection" in data && data.leftSection != undefined) {
this.leftSection = data.leftSection;
}
if ("rightSectionId" in data && data.rightSectionId != undefined) {
this.rightSectionId = data.rightSectionId;
if ("rightSection" in data && data.rightSection != undefined) {
this.rightSection = data.rightSection;
}
}
}
get leftSectionId() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
get leftSection() {
return pb_1.Message.getWrapperField(this, RelatedRef, 1) as RelatedRef;
}
set leftSectionId(value: string) {
pb_1.Message.setField(this, 1, value);
set leftSection(value: RelatedRef) {
pb_1.Message.setWrapperField(this, 1, value);
}
get rightSectionId() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
get has_leftSection() {
return pb_1.Message.getField(this, 1) != null;
}
set rightSectionId(value: string) {
pb_1.Message.setField(this, 2, value);
get rightSection() {
return pb_1.Message.getWrapperField(this, RelatedRef, 2) as RelatedRef;
}
set rightSection(value: RelatedRef) {
pb_1.Message.setWrapperField(this, 2, value);
}
get has_rightSection() {
return pb_1.Message.getField(this, 2) != null;
}
static fromObject(data: {
leftSectionId?: string;
rightSectionId?: string;
leftSection?: ReturnType<typeof RelatedRef.prototype.toObject>;
rightSection?: ReturnType<typeof RelatedRef.prototype.toObject>;
}): NodeConWithSec {
const message = new NodeConWithSec({});
if (data.leftSectionId != null) {
message.leftSectionId = data.leftSectionId;
if (data.leftSection != null) {
message.leftSection = RelatedRef.fromObject(data.leftSection);
}
if (data.rightSectionId != null) {
message.rightSectionId = data.rightSectionId;
if (data.rightSection != null) {
message.rightSection = RelatedRef.fromObject(data.rightSection);
}
return message;
}
toObject() {
const data: {
leftSectionId?: string;
rightSectionId?: string;
leftSection?: ReturnType<typeof RelatedRef.prototype.toObject>;
rightSection?: ReturnType<typeof RelatedRef.prototype.toObject>;
} = {};
if (this.leftSectionId != null) {
data.leftSectionId = this.leftSectionId;
if (this.leftSection != null) {
data.leftSection = this.leftSection.toObject();
}
if (this.rightSectionId != null) {
data.rightSectionId = this.rightSectionId;
if (this.rightSection != null) {
data.rightSection = this.rightSection.toObject();
}
return data;
}
@ -1910,10 +1916,10 @@ export namespace graphicData {
serialize(w: pb_1.BinaryWriter): void;
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
const writer = w || new pb_1.BinaryWriter();
if (this.leftSectionId.length)
writer.writeString(1, this.leftSectionId);
if (this.rightSectionId.length)
writer.writeString(2, this.rightSectionId);
if (this.has_leftSection)
writer.writeMessage(1, this.leftSection, () => this.leftSection.serialize(writer));
if (this.has_rightSection)
writer.writeMessage(2, this.rightSection, () => this.rightSection.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
@ -1924,10 +1930,10 @@ export namespace graphicData {
break;
switch (reader.getFieldNumber()) {
case 1:
message.leftSectionId = reader.readString();
reader.readMessage(message.leftSection, () => message.leftSection = RelatedRef.deserialize(reader));
break;
case 2:
message.rightSectionId = reader.readString();
reader.readMessage(message.rightSection, () => message.rightSection = RelatedRef.deserialize(reader));
break;
default: reader.skipField();
}