This commit is contained in:
fan 2023-10-12 16:39:28 +08:00
commit 64d6132fc1
6 changed files with 239 additions and 14 deletions

@ -1 +1 @@
Subproject commit 608836a62827cb638007e5be46e22644808c0a1e
Subproject commit 5604ad84ed5c6af4206937f5bbba9b2debfbfb6f

View File

@ -32,7 +32,6 @@ import { TextContentDraw } from 'src/graphics/textContent/TextContentDrawAssista
import { IbpTextData } from './graphics/IbpTextInteraction';
import { MenuItemOptions } from 'src/jl-graphic/ui/Menu';
import { ContextMenu } from 'src/jl-graphic/ui/ContextMenu';
import { savePslDrawToServer } from './pslApp';
let drawApp: IDrawApp | null = null;
const UndoOptions: MenuItemOptions = {
@ -107,6 +106,18 @@ export function initIBPDrawApp() {
return drawApp;
}
//所属集中站
let uniqueIdPrefix = new ibpGraphicData.UniqueIdType();
export function loadUniqueIdPrefix() {
return uniqueIdPrefix;
}
export function setUniqueIdPrefix(
newUniqueIdPrefix: ibpGraphicData.UniqueIdType
) {
uniqueIdPrefix = newUniqueIdPrefix;
}
export function saveIBPDrawToServer(app: IDrawApp) {
const base64 = saveIBPDrawDatas(app);
const ibpDrawStore = useIBPDrawStore();
@ -123,7 +134,7 @@ export function saveIBPDrawToServer(app: IDrawApp) {
});
}
function saveIBPDrawDatas(app: IDrawApp) {
export function saveIBPDrawDatas(app: IDrawApp) {
const storage = new ibpGraphicData.IBPGraphicStorage();
const canvasData = app.canvas.saveData();
storage.canvas = new graphicData.Canvas({
@ -145,6 +156,7 @@ function saveIBPDrawDatas(app: IDrawApp) {
storage.IBPTexts.push(g.saveData<IbpTextData>().data);
}
});
storage.UniqueIdPrefix = uniqueIdPrefix;
const base64 = fromUint8Array(storage.serialize());
return base64;
}
@ -176,6 +188,9 @@ async function IBPDrawDataLoader() {
storage.IBPTexts.forEach((ibpText) => {
datas.push(new IbpTextData(ibpText));
});
if (storage.UniqueIdPrefix) {
setUniqueIdPrefix(storage.UniqueIdPrefix);
}
return {
canvasProperty: storage.canvas,
datas: datas,

View File

@ -167,9 +167,13 @@ export class Platform extends JlGraphic {
minDistanceRefSections.push(section);
}
});
const refSection = minDistanceRefSections.reduce((prev, cur) => {
return distance2(prev.position, this.position) >
distance2(cur.position, this.position)
if (minDistanceRefSections) {
const refSection = minDistanceRefSections?.reduce((prev, cur) => {
return distance2(
prev.localToCanvasPoint(prev.getStartPoint()),
this.position
) >
distance2(cur.localToCanvasPoint(prev.getStartPoint()), this.position)
? cur
: prev;
});
@ -177,6 +181,7 @@ export class Platform extends JlGraphic {
this.relationManage.addRelation(this, refSection);
}
}
}
saveRelations() {
const platformRef = [];
const refStation = this.relationManage

View File

@ -1,5 +1,5 @@
<script setup lang="ts">
import { onMounted, reactive, ref, watch } from 'vue';
import { onMounted, reactive, ref, shallowRef, toRaw, watch } from 'vue';
import { useIBPDrawStore } from '../stores/ibp-draw-store';
import { useRoute, useRouter } from 'vue-router';
import { IBPButton } from 'src/graphics/IBPButton/IBPButton';
@ -7,8 +7,15 @@ import { IbpAlarm } from 'src/graphics/ibpAlarm/IbpAlarm';
import { IbpKey } from 'src/graphics/ibpKey/IbpKey';
import { Arrow } from 'src/graphics/arrow/Arrow';
import { TextContent } from 'src/graphics/textContent/TextContent';
import { getIBPDrawApp, saveIBPDrawToServer } from 'src/drawApp/ibpDrawApp';
import {
getIBPDrawApp,
saveIBPDrawToServer,
loadUniqueIdPrefix,
setUniqueIdPrefix,
saveIBPDrawDatas,
} from 'src/drawApp/ibpDrawApp';
import IbpDrawProperties from 'src/components/draw-app/IbpDrawProperties.vue';
import { ibpGraphicData } from 'src/protos/ibpGraphics';
const ibpDrawStore = useIBPDrawStore();
const route = useRoute();
@ -119,6 +126,20 @@ function saveData() {
saveIBPDrawToServer(app);
}
}
const isPrefixDialogOpen = ref(false);
const uniqueIdPrefix = ref(new ibpGraphicData.UniqueIdType().toObject());
function openUniqueIdPrefixDialog() {
isPrefixDialogOpen.value = true;
uniqueIdPrefix.value = loadUniqueIdPrefix();
}
function saveUniqueIdPrefix() {
setUniqueIdPrefix(new ibpGraphicData.UniqueIdType(uniqueIdPrefix.value));
isPrefixDialogOpen.value = false;
saveData();
}
function backConfirm() {
router.go(-1);
}
@ -135,6 +156,13 @@ function backConfirm() {
<QItem clickable @click="saveData" v-close-popup>
<QItemSection>保存</QItemSection>
</QItem>
<QItem
clickable
@click="openUniqueIdPrefixDialog"
v-close-popup
>
<QItemSection>UniqueId配置</QItemSection>
</QItem>
</QList>
</QMenu>
</QBtn>
@ -170,4 +198,41 @@ function backConfirm() {
<div id="draw-app-container" class="overflow-hidden"></div>
</QPageContainer>
</QLayout>
<QDialog
v-model="isPrefixDialogOpen"
persistent
transition-show="scale"
transition-hide="scale"
>
<QCard style="width: 300px">
<QCardSection>
<div class="text-h6">UniqueId配置</div>
</QCardSection>
<QCardSection>
<QInput
outlined
label="所属城市"
v-model="uniqueIdPrefix.city"
:rules="[(val) => val.trim() != '' || '城市不能为空']"
/>
<QInput
outlined
label="线路号"
v-model="uniqueIdPrefix.lineId"
:rules="[(val) => val.trim() != '' || '线路号不能为空']"
/>
<QInput
outlined
label="所属车站"
v-model="uniqueIdPrefix.belongsStation"
:rules="[(val) => val.trim() != '' || '所属车站不能为空']"
/>
</QCardSection>
<QCardActions align="right">
<QBtn color="primary" label="提交" @click="saveUniqueIdPrefix()" />
<QBtn label="取消" v-close-popup />
</QCardActions>
</QCard>
</QDialog>
</template>

View File

@ -15,6 +15,7 @@ export namespace ibpGraphicData {
ibpKeys?: IbpKey[];
ibpArrows?: IbpArrow[];
IBPTexts?: IBPText[];
UniqueIdPrefix?: UniqueIdType;
}) {
super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [2, 3, 4, 5, 6], this.#one_of_decls);
@ -37,6 +38,9 @@ export namespace ibpGraphicData {
if ("IBPTexts" in data && data.IBPTexts != undefined) {
this.IBPTexts = data.IBPTexts;
}
if ("UniqueIdPrefix" in data && data.UniqueIdPrefix != undefined) {
this.UniqueIdPrefix = data.UniqueIdPrefix;
}
}
}
get canvas() {
@ -78,6 +82,15 @@ export namespace ibpGraphicData {
set IBPTexts(value: IBPText[]) {
pb_1.Message.setRepeatedWrapperField(this, 6, value);
}
get UniqueIdPrefix() {
return pb_1.Message.getWrapperField(this, UniqueIdType, 7) as UniqueIdType;
}
set UniqueIdPrefix(value: UniqueIdType) {
pb_1.Message.setWrapperField(this, 7, value);
}
get has_UniqueIdPrefix() {
return pb_1.Message.getField(this, 7) != null;
}
static fromObject(data: {
canvas?: ReturnType<typeof dependency_1.graphicData.Canvas.prototype.toObject>;
ibpButtons?: ReturnType<typeof IBPButton.prototype.toObject>[];
@ -85,6 +98,7 @@ export namespace ibpGraphicData {
ibpKeys?: ReturnType<typeof IbpKey.prototype.toObject>[];
ibpArrows?: ReturnType<typeof IbpArrow.prototype.toObject>[];
IBPTexts?: ReturnType<typeof IBPText.prototype.toObject>[];
UniqueIdPrefix?: ReturnType<typeof UniqueIdType.prototype.toObject>;
}): IBPGraphicStorage {
const message = new IBPGraphicStorage({});
if (data.canvas != null) {
@ -105,6 +119,9 @@ export namespace ibpGraphicData {
if (data.IBPTexts != null) {
message.IBPTexts = data.IBPTexts.map(item => IBPText.fromObject(item));
}
if (data.UniqueIdPrefix != null) {
message.UniqueIdPrefix = UniqueIdType.fromObject(data.UniqueIdPrefix);
}
return message;
}
toObject() {
@ -115,6 +132,7 @@ export namespace ibpGraphicData {
ibpKeys?: ReturnType<typeof IbpKey.prototype.toObject>[];
ibpArrows?: ReturnType<typeof IbpArrow.prototype.toObject>[];
IBPTexts?: ReturnType<typeof IBPText.prototype.toObject>[];
UniqueIdPrefix?: ReturnType<typeof UniqueIdType.prototype.toObject>;
} = {};
if (this.canvas != null) {
data.canvas = this.canvas.toObject();
@ -134,6 +152,9 @@ export namespace ibpGraphicData {
if (this.IBPTexts != null) {
data.IBPTexts = this.IBPTexts.map((item: IBPText) => item.toObject());
}
if (this.UniqueIdPrefix != null) {
data.UniqueIdPrefix = this.UniqueIdPrefix.toObject();
}
return data;
}
serialize(): Uint8Array;
@ -152,6 +173,8 @@ export namespace ibpGraphicData {
writer.writeRepeatedMessage(5, this.ibpArrows, (item: IbpArrow) => item.serialize(writer));
if (this.IBPTexts.length)
writer.writeRepeatedMessage(6, this.IBPTexts, (item: IBPText) => item.serialize(writer));
if (this.has_UniqueIdPrefix)
writer.writeMessage(7, this.UniqueIdPrefix, () => this.UniqueIdPrefix.serialize(writer));
if (!w)
return writer.getResultBuffer();
}
@ -179,6 +202,9 @@ export namespace ibpGraphicData {
case 6:
reader.readMessage(message.IBPTexts, () => pb_1.Message.addToRepeatedWrapperField(message, 6, IBPText.deserialize(reader), IBPText));
break;
case 7:
reader.readMessage(message.UniqueIdPrefix, () => message.UniqueIdPrefix = UniqueIdType.deserialize(reader));
break;
default: reader.skipField();
}
}
@ -893,4 +919,117 @@ export namespace ibpGraphicData {
return IbpArrow.deserialize(bytes);
}
}
export class UniqueIdType extends pb_1.Message {
#one_of_decls: number[][] = [];
constructor(data?: any[] | {
city?: string;
lineId?: string;
belongsStation?: 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 ("city" in data && data.city != undefined) {
this.city = data.city;
}
if ("lineId" in data && data.lineId != undefined) {
this.lineId = data.lineId;
}
if ("belongsStation" in data && data.belongsStation != undefined) {
this.belongsStation = data.belongsStation;
}
}
}
get city() {
return pb_1.Message.getFieldWithDefault(this, 1, "") as string;
}
set city(value: string) {
pb_1.Message.setField(this, 1, value);
}
get lineId() {
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
}
set lineId(value: string) {
pb_1.Message.setField(this, 2, value);
}
get belongsStation() {
return pb_1.Message.getFieldWithDefault(this, 3, "") as string;
}
set belongsStation(value: string) {
pb_1.Message.setField(this, 3, value);
}
static fromObject(data: {
city?: string;
lineId?: string;
belongsStation?: string;
}): UniqueIdType {
const message = new UniqueIdType({});
if (data.city != null) {
message.city = data.city;
}
if (data.lineId != null) {
message.lineId = data.lineId;
}
if (data.belongsStation != null) {
message.belongsStation = data.belongsStation;
}
return message;
}
toObject() {
const data: {
city?: string;
lineId?: string;
belongsStation?: string;
} = {};
if (this.city != null) {
data.city = this.city;
}
if (this.lineId != null) {
data.lineId = this.lineId;
}
if (this.belongsStation != null) {
data.belongsStation = this.belongsStation;
}
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.city.length)
writer.writeString(1, this.city);
if (this.lineId.length)
writer.writeString(2, this.lineId);
if (this.belongsStation.length)
writer.writeString(3, this.belongsStation);
if (!w)
return writer.getResultBuffer();
}
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): UniqueIdType {
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new UniqueIdType();
while (reader.nextField()) {
if (reader.isEndGroup())
break;
switch (reader.getFieldNumber()) {
case 1:
message.city = reader.readString();
break;
case 2:
message.lineId = reader.readString();
break;
case 3:
message.belongsStation = reader.readString();
break;
default: reader.skipField();
}
}
return message;
}
serializeBinary(): Uint8Array {
return this.serialize();
}
static deserializeBinary(bytes: Uint8Array): UniqueIdType {
return UniqueIdType.deserialize(bytes);
}
}
}

View File

@ -1,6 +1,7 @@
import { defineStore } from 'pinia';
import { getIBPDrawApp, initIBPDrawApp } from 'src/drawApp/ibpDrawApp';
import { DrawAssistant, IDrawApp, IJlCanvas, JlGraphic } from 'src/jl-graphic';
import { markRaw } from 'vue';
export const useIBPDrawStore = defineStore('ibpDraw', {
state: () => ({
@ -60,7 +61,7 @@ export const useIBPDrawStore = defineStore('ibpDraw', {
}
});
app.on('graphicselectedchange', () => {
this.selectedGraphics = app.selectedGraphics;
this.selectedGraphics = markRaw(app.selectedGraphics);
});
this.selectedGraphics = [];
return app;