This commit is contained in:
fan 2023-12-06 09:53:09 +08:00
commit 22ed1f3b45
9 changed files with 187 additions and 67 deletions

View File

@ -5,16 +5,30 @@
</q-card-section>
<q-form ref="myForm">
<selectConfig-utils ref="selectConfigUtils" :drawStore="drawStore" />
<div class="q-mt-md">
<q-btn
label="确认修改"
color="primary"
@click="onSubmit"
class="q-mr-md"
/>
<q-btn class="q-mr-md" label="返回" color="red" @click="goBack" />
<div class="q-mt-md q-gutter-md">
<q-btn label="确认修改" color="primary" @click="onSubmit" />
<q-btn label="返回" color="red" @click="goBack" />
<q-btn label="生成计轴" color="primary" @click="generateAxleCounting" />
</div>
<div class="q-mt-md q-gutter-md">
<q-btn
label="检查计轴"
color="primary"
@click="showErrorAxleCounting"
/>
<q-btn
v-if="showCheck"
label="上一个"
color="primary"
@click="clickSelectCenter(-1)"
/>
<q-btn
v-if="showCheck"
label="下一个"
color="primary"
@click="clickSelectCenter(1)"
/>
</div>
</q-form>
</q-card>
</template>
@ -32,6 +46,7 @@ import {
} from 'src/drawApp/commonApp';
import SelectConfigUtils from 'src/components/common/SelectConfigUtils.vue';
import { OneClickGenerate } from 'src/graphics/trainWindow/oneClickDrawAssistant';
import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting';
//使
const filterSelect = (g: JlGraphic) => g instanceof Turnout;
@ -125,4 +140,49 @@ function generateAxleCounting() {
drawStore.oneClickType = 'AxleCounting';
drawStore.getDrawApp().interactionPlugin(OneClickGenerate.Type).resume();
}
const selectConfig = ref<
{
axleCountingId: string;
axleCountingCode: string;
}[]
>([]);
function showErrorAxleCounting() {
showCheck.value = true;
const axleCountings = drawStore
.getDrawApp()
.queryStore.queryByType<AxleCounting>(AxleCounting.Type);
const erroeAxleCountings = axleCountings
.filter(
(g) =>
g.datas.type ==
graphicData.AxleCounting.TypeDetectionPoint.AxleCounting &&
g.datas.axleCountingRef.length < 2
)
.sort((a, b) => a.position.x - b.position.x);
erroeAxleCountings.forEach((axleCounting) => {
selectConfig.value.push({
axleCountingId: axleCounting.id,
axleCountingCode: axleCounting.datas.code,
});
});
}
const currentIndex = ref(-1);
const showCheck = ref(false);
function clickSelectCenter(add: number) {
if (
currentIndex.value + add < 0 ||
currentIndex.value + add >= selectConfig.value.length
)
return;
currentIndex.value = currentIndex.value + add;
const target = drawStore
.getDrawApp()
.queryStore.queryById(
selectConfig.value[currentIndex.value].axleCountingId
);
drawStore.getDrawApp().makeGraphicCenterShow(target);
drawStore.getDrawApp().updateSelected(target);
}
</script>

View File

@ -115,7 +115,7 @@ import { AxleCountingData } from 'src/drawApp/graphics/AxleCountingInteraction';
import { AxleCounting } from 'src/graphics/axleCounting/AxleCounting';
import { Section } from 'src/graphics/section/Section';
import { Turnout } from 'src/graphics/turnout/Turnout';
import { GraphicIdGenerator } from 'src/jl-graphic';
import { getRectangleCenter, GraphicIdGenerator } from 'src/jl-graphic';
import { useDrawStore } from 'src/stores/draw-store';
import { computed } from 'vue';
import { useQuasar } from 'quasar';
@ -200,21 +200,35 @@ function oneClickAxleCounting() {
return;
}
}
const ref = select.datas.axleCountingRef;
const refDevice = select.queryStore.queryById<Section | Turnout>(ref[0].id);
const refDeviceOther = select.queryStore.queryById<Section | Turnout>(
ref[1].id
);
for (let i = 0; i < 2; i++) {
const axleCounting = new AxleCounting(1);
axleCounting.loadData(new AxleCountingData());
axleCounting.id = GraphicIdGenerator.next();
const offsetX = i == 0 ? -40 : 40;
axleCounting.position.set(select.x + offsetX, select.y + 30);
const ref = select.datas.axleCountingRef;
for (let j = 0; j < 2; j++) {
if (ref[j].devicePort == i) {
const refSection = select.queryStore.queryById(ref[j].id) as Section;
axleCounting.datas.axleCountingRef = [select.datas.axleCountingRef[j]];
axleCounting.datas.code = `${refSection.datas.code}-${ref[j].devicePort}`;
break;
}
}
const [leftDevice, rightDevice] =
refDevice.localToCanvasPoint(
getRectangleCenter(refDevice.getLocalBounds())
).x <
refDeviceOther.localToCanvasPoint(
getRectangleCenter(refDeviceOther.getLocalBounds())
).x
? [
{ device: refDevice, ref: ref[0] },
{ device: refDeviceOther, ref: ref[1] },
]
: [
{ device: refDeviceOther, ref: ref[1] },
{ device: refDevice, ref: ref[0] },
];
const deviceUse = i == 0 ? rightDevice : leftDevice;
axleCounting.datas.axleCountingRef = [deviceUse.ref];
axleCounting.datas.code = `${deviceUse.device.datas.code}-${deviceUse.ref.devicePort}`;
const app = drawStore.getDrawApp();
app.addGraphicAndRecord(axleCounting);
axleCounting.loadRelations();

View File

@ -18,11 +18,22 @@ const sectionCode = computed(() => {
return '';
});
const formRef = ref<InstanceType<typeof QForm> | null>(null);
const direction = ref(0);
const directionOptions = [
const runningDirection = ref(0);
const runningDirectionOptions = [
{ label: 'A到B', value: graphicData.Section.RunningDirection.AtoB },
{ label: 'B到A', value: graphicData.Section.RunningDirection.BtoA },
];
const direction = ref(0);
const directionOptions = [
{
label: '上行',
value: graphicData.Direction.UP,
},
{
label: '下行',
value: graphicData.Direction.DOWN,
},
];
async function onSubmit() {
const res = await formRef.value?.validate();
@ -33,8 +44,8 @@ async function onSubmit() {
const queue: {
node: Section | Turnout;
direction: graphicData.Section.RunningDirection;
}[] = [{ node: section, direction: direction.value }];
runningDirection: graphicData.Section.RunningDirection;
}[] = [{ node: section, runningDirection: runningDirection.value }];
const reverseDirection = (d: graphicData.Section.RunningDirection) =>
d === graphicData.Section.RunningDirection.AtoB
@ -43,7 +54,7 @@ async function onSubmit() {
const traverse = (
current: Section | Turnout,
direction: graphicData.Section.RunningDirection
runningDirection: graphicData.Section.RunningDirection
) => {
if (visited.includes(current.datas.id)) return;
visited.push(current.datas.id);
@ -53,12 +64,12 @@ async function onSubmit() {
[current.datas.pbRef?.id, 'B'],
]
.filter((item): item is [string, 'A' | 'B'] => !!item[0])
.forEach(([id, port], idx) => {
.forEach(([id, port]) => {
const target = current.queryStore.queryById<Section | Turnout>(id);
if (target instanceof Turnout) {
queue.push({
node: target,
direction,
runningDirection,
});
} else {
const isPortDiffrent =
@ -66,46 +77,32 @@ async function onSubmit() {
(port === 'A' && target.datas.pbRef?.id === current.datas.id);
queue.push({
node: target,
direction: isPortDiffrent
? direction
: reverseDirection(direction),
runningDirection: isPortDiffrent
? runningDirection
: reverseDirection(runningDirection),
});
}
});
const data = current.datas.clone();
data.normalRunningDirection = direction;
data.normalRunningDirection = runningDirection;
data.direction = direction.value;
current.updateData(data);
} else {
[
current.datas.paRef?.id,
current.datas.pbRef?.id,
current.datas.pcRef?.id,
]
[current.datas.paRef?.id, current.datas.pbRef?.id]
.filter((id): id is string => !!id)
.forEach((id, idx) => {
.forEach((id) => {
const target = current.queryStore.queryById<Section | Turnout>(id);
if (
target instanceof Turnout &&
target.datas.pcRef?.id === current.datas.id &&
idx === 2
) {
queue.push({
node: target,
direction: reverseDirection(direction),
});
} else {
queue.push({
node: target,
direction,
});
}
queue.push({
node: target,
runningDirection,
});
});
}
};
do {
const { node, direction } = queue.shift()!;
traverse(node, direction);
const { node, runningDirection } = queue.shift()!;
traverse(node, runningDirection);
} while (queue.length > 0);
}
</script>
@ -134,6 +131,15 @@ async function onSubmit() {
outlined
label="运行方向"
hint="请选择区段的常规运行方向"
v-model="runningDirection"
:options="runningDirectionOptions"
emit-value
map-options
/>
<QSelect
outlined
label="上下行方向"
hint="请选择区段的上下行方向"
v-model="direction"
:options="directionOptions"
emit-value

View File

@ -34,6 +34,16 @@
@blur="onUpdate"
label="常规运行方向"
></q-select>
<q-select
outlined
class="q-mt-lg"
v-model="sectionModel.direction"
:options="directionOptions"
emit-value
map-options
@blur="onUpdate"
label="上下行方向"
></q-select>
<q-checkbox
v-if="
sectionModel.sectionType === graphicData.Section.SectionType.Physical
@ -149,7 +159,7 @@ const sectionTypeText = computed(() => {
return ['物理区段', '', '道岔物理区段'][sectionModel.sectionType];
});
const runningDirectionOptions = computed(() => [
const runningDirectionOptions = [
{
label: 'A到B',
value: graphicData.Section.RunningDirection.AtoB,
@ -158,7 +168,22 @@ const runningDirectionOptions = computed(() => [
label: 'B到A',
value: graphicData.Section.RunningDirection.BtoA,
},
]);
{
label: '双向',
value: graphicData.Section.RunningDirection.BOTH,
},
];
const directionOptions = [
{
label: '上行',
value: graphicData.Direction.UP,
},
{
label: '下行',
value: graphicData.Direction.DOWN,
},
];
const sectionRelations = computed(() => {
const section = drawStore.selectedGraphic as Section;

View File

@ -115,6 +115,12 @@ export class SectionData extends GraphicDataBase implements ISectionData {
set isTurnBackZone(v: boolean) {
this.data.isTurnBackZone = v;
}
get direction(): graphicData.Direction {
return this.data.direction;
}
set direction(v: graphicData.Direction) {
this.data.direction = v;
}
clone(): SectionData {
return new SectionData(this.data.cloneMessage());
}

View File

@ -101,6 +101,9 @@ export class AxleCounting extends JlGraphic {
doRepaint(): void {
this.twoCircle.draw(this.datas);
}
buildRelation(): void {
this.loadRelations();
}
loadRelations(): void {
if (this.datas.axleCountingRef.length) {
this.datas.axleCountingRef.forEach((device) => {

View File

@ -25,6 +25,8 @@ import { SectionGraphic } from '../sectionGraphic/SectionGraphic';
import { state } from 'src/protos/device_state';
import { graphicData } from 'src/protos/stationLayoutGraphics';
const tolerance = 0.01;
export enum SectionType {
Physical = 0,
Logic = 1,
@ -61,6 +63,8 @@ export interface ISectionData extends GraphicData {
set normalRunningDirection(v: graphicData.Section.RunningDirection);
get isTurnBackZone(): boolean;
set isTurnBackZone(v: boolean);
get direction(): graphicData.Direction;
set direction(v: graphicData.Direction);
clone(): ISectionData;
copyFrom(data: ISectionData): void;
eq(other: ISectionData): boolean;
@ -244,7 +248,7 @@ export class Section extends JlGraphic implements ILineGraphic {
distance2(
this.localToCanvasPoint(this.getStartPoint()),
section.localToCanvasPoint(section.getStartPoint())
) <= epsilon
) <= tolerance
) {
param = [SectionPort.A, SectionPort.A];
}
@ -252,7 +256,7 @@ export class Section extends JlGraphic implements ILineGraphic {
distance2(
this.localToCanvasPoint(this.getEndPoint()),
section.localToCanvasPoint(section.getStartPoint())
) <= epsilon
) <= tolerance
) {
param = [SectionPort.B, SectionPort.A];
}
@ -260,7 +264,7 @@ export class Section extends JlGraphic implements ILineGraphic {
distance2(
this.localToCanvasPoint(this.getStartPoint()),
section.localToCanvasPoint(section.getEndPoint())
) <= epsilon
) <= tolerance
) {
param = [SectionPort.A, SectionPort.B];
}
@ -268,7 +272,7 @@ export class Section extends JlGraphic implements ILineGraphic {
distance2(
this.localToCanvasPoint(this.getEndPoint()),
section.localToCanvasPoint(section.getEndPoint())
) <= epsilon
) <= tolerance
) {
param = [SectionPort.B, SectionPort.B];
}

View File

@ -104,11 +104,11 @@ export class OneClickGenerateDraw extends GraphicDrawAssistant<
elem.datas.kilometerSystem = new graphicData.KilometerSystem({
kilometer: elem.datas.kilometerSystem.kilometer,
coordinateSystem: elem.datas.kilometerSystem.coordinateSystem,
direction: graphicData.Direction.LEFT,
direction: graphicData.KilometerSystem.Direction.LEFT,
});
} else {
elem.datas.kilometerSystem = new graphicData.KilometerSystem({
direction: graphicData.Direction.LEFT,
direction: graphicData.KilometerSystem.Direction.LEFT,
});
}
} else {
@ -116,11 +116,11 @@ export class OneClickGenerateDraw extends GraphicDrawAssistant<
elem.datas.kilometerSystem = new graphicData.KilometerSystem({
kilometer: elem.datas.kilometerSystem.kilometer,
coordinateSystem: elem.datas.kilometerSystem.coordinateSystem,
direction: graphicData.Direction.RIGHT,
direction: graphicData.KilometerSystem.Direction.RIGHT,
});
} else {
elem.datas.kilometerSystem = new graphicData.KilometerSystem({
direction: graphicData.Direction.RIGHT,
direction: graphicData.KilometerSystem.Direction.RIGHT,
});
}
}
@ -138,14 +138,14 @@ export class OneClickGenerateDraw extends GraphicDrawAssistant<
elem.datas.kilometerSystem = new graphicData.KilometerSystem({
kilometer: ks.kilometer,
coordinateSystem: ks.coordinateSystem,
direction: graphicData.Direction.LEFT,
direction: graphicData.KilometerSystem.Direction.LEFT,
});
} else {
const ks = elem.datas.kilometerSystem;
elem.datas.kilometerSystem = new graphicData.KilometerSystem({
kilometer: ks.kilometer,
coordinateSystem: ks.coordinateSystem,
direction: graphicData.Direction.RIGHT,
direction: graphicData.KilometerSystem.Direction.RIGHT,
});
}
}

View File

@ -21,6 +21,8 @@ import { KilometerSystem } from '../signal/Signal';
import { TrackSection } from '../trackSection/TrackSection';
import { graphicData } from 'src/protos/stationLayoutGraphics';
const tolerance = 0.01;
export interface ITurnoutData extends GraphicData {
get code(): string;
set code(code: string);
@ -268,7 +270,7 @@ export class Turnout extends JlGraphic {
distance2(
section.localToCanvasPoint(section.getStartPoint()),
this.localToCanvasPoint(port[port.length - 1])
) <= epsilon
) <= tolerance
) {
this.relationManage.addRelation(
new GraphicRelationParam(
@ -282,7 +284,7 @@ export class Turnout extends JlGraphic {
distance2(
section.localToCanvasPoint(section.getEndPoint()),
this.localToCanvasPoint(port[port.length - 1])
) <= epsilon
) <= tolerance
) {
this.relationManage.addRelation(
new GraphicRelationParam(
@ -306,7 +308,7 @@ export class Turnout extends JlGraphic {
distance2(
this.localToCanvasPoint(thisPort[thisPort.length - 1]),
turnout.localToCanvasPoint(otherPort[otherPort.length - 1])
) <= epsilon
) <= tolerance
) {
const angle = angleOfIncludedAngle(
this.localToCanvasPoint(thisPort[thisPort.length - 1]) /* 交点 */,