Merge branch 'master' of https://git.code.tencent.com/beijing-rtss-test/bj-rtss-client
This commit is contained in:
commit
f6827df35a
@ -1,12 +1,6 @@
|
||||
<template>
|
||||
<q-form>
|
||||
<q-input
|
||||
outlined
|
||||
readonly
|
||||
v-model="relayCabinetModel.id"
|
||||
label="id"
|
||||
hint=""
|
||||
/>
|
||||
<q-form class="q-gutter-md">
|
||||
<q-input outlined readonly v-model="relayCabinetModel.id" label="id" />
|
||||
<q-input
|
||||
outlined
|
||||
v-model="relayCabinetModel.code"
|
||||
@ -14,17 +8,36 @@
|
||||
label="继电器柜"
|
||||
lazy-rules
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
v-model.number="horizontalSpace"
|
||||
@blur="changehorizontalSpace"
|
||||
label="继电器水平间距"
|
||||
type="number"
|
||||
lazy-rules
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
v-model.number="verticalSpace"
|
||||
@blur="changeVerticalSpace"
|
||||
label="继电器垂直间距"
|
||||
type="number"
|
||||
lazy-rules
|
||||
/>
|
||||
</q-form>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { RelayCabinetData } from 'src/drawApp/relayCabinetGraphics/RelayCabinetInteraction';
|
||||
import { Relay } from 'src/graphics/relay/Relay';
|
||||
import { RelayCabinet } from 'src/graphics/relayCabinet/RelayCabinet';
|
||||
import { useRelayCabinetStore } from 'src/stores/relayCabinet-store';
|
||||
import { onMounted, reactive, watch } from 'vue';
|
||||
import { onMounted, reactive, ref, watch } from 'vue';
|
||||
|
||||
const relayCabinetStore = useRelayCabinetStore();
|
||||
const relayCabinetModel = reactive(new RelayCabinetData());
|
||||
const horizontalSpace = ref(50);
|
||||
const verticalSpace = ref(50);
|
||||
|
||||
relayCabinetStore.$subscribe;
|
||||
watch(
|
||||
@ -51,4 +64,74 @@ function onUpdate() {
|
||||
.updateGraphicAndRecord(RelayCabinet, relayCabinetModel);
|
||||
}
|
||||
}
|
||||
function containBoth(relayCabinet: RelayCabinet, relay: Relay) {
|
||||
const rect = relayCabinet.localBoundsToCanvasPoints();
|
||||
if (
|
||||
relay.x > rect[0].x &&
|
||||
relay.x < rect[1].x &&
|
||||
relay.y > rect[0].y &&
|
||||
relay.y < rect[3].y
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function changehorizontalSpace() {
|
||||
const RelayCabinet = relayCabinetStore.selectedGraphic as RelayCabinet;
|
||||
if (RelayCabinet) {
|
||||
const relays = RelayCabinet.queryStore
|
||||
.queryByType<Relay>(Relay.Type)
|
||||
.filter((g) => containBoth(RelayCabinet, g));
|
||||
const vertical = [...new Set(relays.map((g) => g.y))].sort((a, b) => a - b);
|
||||
const verticalRelay: Relay[][] = [];
|
||||
vertical.forEach((sameY, index) => {
|
||||
relays.forEach((relay) => {
|
||||
if (relay.y == sameY) {
|
||||
if (verticalRelay[index] == undefined) {
|
||||
verticalRelay[index] = [relay];
|
||||
} else {
|
||||
verticalRelay[index].push(relay);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
verticalRelay.forEach((relays) => {
|
||||
for (let i = 1; i < relays.length; i++) {
|
||||
if (relays[i].x - relays[i - 1].x !== horizontalSpace.value) {
|
||||
relays[i].x = relays[i - 1].x + horizontalSpace.value;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function changeVerticalSpace() {
|
||||
const RelayCabinet = relayCabinetStore.selectedGraphic as RelayCabinet;
|
||||
if (RelayCabinet) {
|
||||
const relays = RelayCabinet.queryStore
|
||||
.queryByType<Relay>(Relay.Type)
|
||||
.filter((g) => containBoth(RelayCabinet, g));
|
||||
const horizontal = [...new Set(relays.map((g) => g.x))].sort(
|
||||
(a, b) => a - b
|
||||
);
|
||||
const horizontalRelay: Relay[][] = [];
|
||||
horizontal.forEach((sameX, index) => {
|
||||
relays.forEach((relay) => {
|
||||
if (relay.x == sameX) {
|
||||
if (horizontalRelay[index] == undefined) {
|
||||
horizontalRelay[index] = [relay];
|
||||
} else {
|
||||
horizontalRelay[index].push(relay);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
horizontalRelay.forEach((relays) => {
|
||||
for (let i = 1; i < relays.length; i++) {
|
||||
if (relays[i].y - relays[i - 1].y !== verticalSpace.value) {
|
||||
relays[i].y = relays[i - 1].y + verticalSpace.value;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -59,7 +59,7 @@ function buildAbsorbablePositions(relayCabinet: Relay): AbsorbablePosition[] {
|
||||
if (other.id == relayCabinet.id) {
|
||||
return;
|
||||
}
|
||||
const ps = other.datas.transform.position;
|
||||
const ps = other.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);
|
||||
|
Loading…
Reference in New Issue
Block a user