垂直电梯备用

This commit is contained in:
joylink_zhaoerwei 2024-10-23 15:51:18 +08:00
parent afd27d4b3e
commit eb9d0734ae
13 changed files with 364 additions and 17 deletions

@ -1 +1 @@
Subproject commit 236252fc0fa258e6beaae5b5ac0a7e28ebbcb04b Subproject commit e46b6804e2637ce911efdb379d30645de9948326

View File

@ -42,6 +42,12 @@
<button-property <button-property
v-else-if="drawStore.selectedGraphicType === Button.Type" v-else-if="drawStore.selectedGraphicType === Button.Type"
/> />
<escalator-property
v-else-if="drawStore.selectedGraphicType === Escalator.Type"
/>
<vertical-elevator-property
v-else-if="drawStore.selectedGraphicType === VerticalElevator.Type"
/>
</q-card-section> </q-card-section>
</template> </template>
<!-- <template v-else-if="drawStore.selectedGraphics.length > 1"> <!-- <template v-else-if="drawStore.selectedGraphics.length > 1">
@ -65,6 +71,11 @@ import CircleProperty from './properties/CircleProperty.vue';
import { Circle } from 'src/graphics/circle/Circle'; import { Circle } from 'src/graphics/circle/Circle';
import ButtonProperty from './properties/ButtonProperty.vue'; import ButtonProperty from './properties/ButtonProperty.vue';
import { Button } from 'src/graphics/button/Button'; import { Button } from 'src/graphics/button/Button';
import EscalatorProperty from './properties/BAS/EscalatorProperty.vue';
import { Escalator } from 'src/graphics/BAS/escalator/Escalator';
import VerticalElevatorProperty from './properties/BAS/VerticalElevatorProperty.vue';
import { VerticalElevator } from 'src/graphics/BAS/verticalElevator/VerticalElevator';
import { watch } from 'vue'; import { watch } from 'vue';
const drawStore = useDrawStore(); const drawStore = useDrawStore();

View File

@ -0,0 +1,23 @@
<template>
<q-form class="q-gutter-sm">
<q-input outlined readonly v-model="escalatorModel.id" label="id" />
<q-input
outlined
v-model="escalatorModel.code"
@blur="onUpdate"
label="code"
lazy-rules
/>
</q-form>
</template>
<script setup lang="ts">
import { useFormData } from 'src/components/DrawAppFormUtils';
import { useDrawStore } from 'src/stores/draw-store';
import { EscalatorData } from 'src/drawApp/graphics/BAS/EscalatorInteraction';
const { data: escalatorModel, onUpdate } = useFormData(
new EscalatorData(),
useDrawStore().getDrawApp()
);
</script>

View File

@ -0,0 +1,23 @@
<template>
<q-form class="q-gutter-sm">
<q-input outlined readonly v-model="verticalElevatorModel.id" label="id" />
<q-input
outlined
v-model="verticalElevatorModel.code"
@blur="onUpdate"
label="code"
lazy-rules
/>
</q-form>
</template>
<script setup lang="ts">
import { useFormData } from 'src/components/DrawAppFormUtils';
import { VerticalElevatorData } from 'src/drawApp/graphics/BAS/VerticalElevatorInteraction';
import { useDrawStore } from 'src/stores/draw-store';
const { data: verticalElevatorModel, onUpdate } = useFormData(
new VerticalElevatorData(),
useDrawStore().getDrawApp()
);
</script>

View File

@ -0,0 +1,41 @@
import * as pb_1 from 'google-protobuf';
import {
IverticalElevatorData,
VerticalElevator,
} from 'src/graphics/BAS/verticalElevator/VerticalElevator';
import { GraphicDataBase } from '../GraphicDataBase';
import { iscsGraphicData } from 'src/protos/iscs_graphic_data';
export class VerticalElevatorData extends GraphicDataBase implements IverticalElevatorData {
constructor(data?: iscsGraphicData.VerticalElevator) {
let verticalElevator;
if (data) {
verticalElevator = data;
} else {
verticalElevator = new iscsGraphicData.VerticalElevator({
common: GraphicDataBase.defaultCommonInfo(VerticalElevator.Type),
});
}
super(verticalElevator);
}
public get data(): iscsGraphicData.VerticalElevator {
return this.getData<iscsGraphicData.VerticalElevator>();
}
get code(): string {
return this.data.code;
}
set code(v: string) {
this.data.code = v;
}
clone(): VerticalElevatorData {
return new VerticalElevatorData(this.data.cloneMessage());
}
copyFrom(data: VerticalElevatorData): void {
pb_1.Message.copyInto(data.data, this.data);
}
eq(other: VerticalElevatorData): boolean {
return pb_1.Message.equals(this.data, other.data);
}
}

View File

@ -65,6 +65,12 @@ import {
EscalatorTemplate, EscalatorTemplate,
} from 'src/graphics/BAS/escalator/Escalator'; } from 'src/graphics/BAS/escalator/Escalator';
import { EscalatorData } from './graphics/BAS/EscalatorInteraction'; import { EscalatorData } from './graphics/BAS/EscalatorInteraction';
import {
VerticalElevator,
VerticalElevatorTemplate,
} from 'src/graphics/BAS/verticalElevator/VerticalElevator';
import { VerticalElevatorData } from './graphics/BAS/VerticalElevatorInteraction';
import { VerticalElevatorDraw } from 'src/graphics/BAS/verticalElevator/VerticalElevatorDrawAssistant';
import { FirePump, FirePumpTemplate } from 'src/graphics/FAS/firePump/FirePump'; import { FirePump, FirePumpTemplate } from 'src/graphics/FAS/firePump/FirePump';
import { FirePumpDraw } from 'src/graphics/FAS/firePump/FirePumpAssistant'; import { FirePumpDraw } from 'src/graphics/FAS/firePump/FirePumpAssistant';
import { FirePumpData } from './graphics/FAS/FirePumpInteraction'; import { FirePumpData } from './graphics/FAS/FirePumpInteraction';
@ -103,6 +109,10 @@ export function initIscsDrawApp(): IDrawApp {
const app = drawApp; const app = drawApp;
initCommonDrawApp(app); initCommonDrawApp(app);
new EscalatorDraw(app, new EscalatorTemplate(new EscalatorData())); new EscalatorDraw(app, new EscalatorTemplate(new EscalatorData()));
new VerticalElevatorDraw(
app,
new VerticalElevatorTemplate(new VerticalElevatorData())
);
new FasFailureControlHostDraw( new FasFailureControlHostDraw(
app, app,
new FasFailureControlHostTemplate(new FasFailureControlHostData()) new FasFailureControlHostTemplate(new FasFailureControlHostData())
@ -330,6 +340,7 @@ export async function loadDrawDatas(): Promise<IGraphicStorage> {
break; break;
} }
} }
break;
case '电扶梯': case '电扶梯':
for (let i = 0; i < storage.basOfEscalatorStorages.length; i++) { for (let i = 0; i < storage.basOfEscalatorStorages.length; i++) {
const basOfEscalator = storage.basOfEscalatorStorages[i]; const basOfEscalator = storage.basOfEscalatorStorages[i];
@ -342,9 +353,13 @@ export async function loadDrawDatas(): Promise<IGraphicStorage> {
basOfEscalator.escalators.forEach((escalator) => { basOfEscalator.escalators.forEach((escalator) => {
datas.push(new EscalatorData(escalator)); datas.push(new EscalatorData(escalator));
}); });
basOfEscalator.verticalElevators.forEach((verticalElevator) => {
datas.push(new VerticalElevatorData(verticalElevator));
});
break; break;
} }
} }
break;
default: default:
break; break;
} }
@ -511,6 +526,11 @@ export function saveDrawDatas(app: IDrawApp) {
basOfEscalatorStorage.escalators.push( basOfEscalatorStorage.escalators.push(
(escalatorData as EscalatorData).data (escalatorData as EscalatorData).data
); );
} else if (g instanceof VerticalElevator) {
const verticalElevatorData = g.saveData();
basOfEscalatorStorage.verticalElevators.push(
(verticalElevatorData as VerticalElevatorData).data
);
} }
}); });
storage.basOfEscalatorStorages[i] = basOfEscalatorStorage; storage.basOfEscalatorStorages[i] = basOfEscalatorStorage;

View File

@ -16,7 +16,7 @@ export class EscalatorDraw extends GraphicDrawAssistant<
> { > {
_escalator: Escalator | null = null; _escalator: Escalator | null = null;
constructor(app: IDrawApp, template: EscalatorTemplate) { constructor(app: IDrawApp, template: EscalatorTemplate) {
super(app, template, 'sym_o_lightbulb', '自动扶梯'); super(app, template, 'escalator', '自动扶梯');
EscalatorInteraction.init(app); EscalatorInteraction.init(app);
} }

View File

@ -0,0 +1,75 @@
import { GraphicData, JlGraphic, JlGraphicTemplate } from 'jl-graphic';
import tcc_Light_Assets from './verticalElevator-spritesheet.png';
import tcc_Light_JSON from './verticalElevator-data.json';
import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js';
interface VerticalElevatorTextures {
redOn: Texture;
redOff: Texture;
greenOn: Texture;
greenOff: Texture;
blueOn: Texture;
blueOff: Texture;
}
export interface IverticalElevatorData extends GraphicData {
get code(): string;
set code(v: string);
}
export class VerticalElevator extends JlGraphic {
static Type = 'VerticalElevator';
_verticalElevator: Sprite;
verticalElevatorTextures: VerticalElevatorTextures;
__state = 0;
constructor(verticalElevatorTextures: VerticalElevatorTextures) {
super(VerticalElevator.Type);
this.verticalElevatorTextures = verticalElevatorTextures;
this._verticalElevator = new Sprite();
this._verticalElevator.texture = this.verticalElevatorTextures.greenOff;
this._verticalElevator.scale.set(0.25);
this._verticalElevator.anchor.set(0.5);
this.addChild(this._verticalElevator);
}
get code(): string {
return this.datas.code;
}
get datas(): IverticalElevatorData {
return this.getDatas<IverticalElevatorData>();
}
doRepaint(): void {
this._verticalElevator.texture = this.verticalElevatorTextures.greenOn;
}
}
export class VerticalElevatorTemplate extends JlGraphicTemplate<VerticalElevator> {
verticalElevatorTextures?: VerticalElevatorTextures;
constructor(dataTemplate: IverticalElevatorData) {
super(VerticalElevator.Type, { dataTemplate });
this.loadAssets();
}
new(): VerticalElevator {
if (this.verticalElevatorTextures) {
const g = new VerticalElevator(this.verticalElevatorTextures);
g.loadData(this.datas);
return g;
}
throw new Error('资源未加载/加载失败');
}
async loadAssets(): Promise<VerticalElevatorTextures> {
const texture = await Assets.load(tcc_Light_Assets);
const verticalElevatorSheet = new Spritesheet(texture, tcc_Light_JSON);
const result = await verticalElevatorSheet.parse();
this.verticalElevatorTextures = {
redOff: result['red-off.png'],
redOn: result['red-on.png'],
blueOff: result['blue-off.png'],
blueOn: result['blue-on.png'],
greenOff: result['green-off.png'],
greenOn: result['green-on.png'],
};
return this.verticalElevatorTextures as VerticalElevatorTextures;
}
}

View File

@ -0,0 +1,124 @@
import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js';
import {
AbsorbableLine,
AbsorbablePosition,
GraphicDrawAssistant,
GraphicInteractionPlugin,
GraphicTransformEvent,
IDrawApp,
JlGraphic,
} from 'jl-graphic';
import {
IverticalElevatorData,
VerticalElevator,
VerticalElevatorTemplate,
} from './VerticalElevator';
export class VerticalElevatorDraw extends GraphicDrawAssistant<
VerticalElevatorTemplate,
IverticalElevatorData
> {
_verticalElevator: VerticalElevator | null = null;
constructor(app: IDrawApp, template: VerticalElevatorTemplate) {
super(app, template, 'elevator', '垂直电梯');
VerticalElevatorInteraction.init(app);
}
bind(): void {
super.bind();
if (!this._verticalElevator) {
this._verticalElevator = this.graphicTemplate.new();
this.container.addChild(this._verticalElevator);
}
}
public get verticalElevator(): VerticalElevator {
if (!this._verticalElevator) {
this._verticalElevator = this.graphicTemplate.new();
this.container.addChild(this._verticalElevator);
}
return this._verticalElevator;
}
redraw(cp: Point): void {
this.verticalElevator.position.copyFrom(cp);
}
onLeftUp(e: FederatedMouseEvent): void {
this.verticalElevator.position.copyFrom(this.toCanvasCoordinates(e.global));
this.createAndStore(true);
}
prepareData(data: IverticalElevatorData): boolean {
data.transform = this.verticalElevator.saveTransform();
return true;
}
onEsc(): void {
this.finish();
}
}
/**
* 线
* @param verticalElevator
*/
function buildAbsorbablePositions(
verticalElevator: VerticalElevator
): AbsorbablePosition[] {
const aps: AbsorbablePosition[] = [];
const verticalElevators =
verticalElevator.queryStore.queryByType<VerticalElevator>(
VerticalElevator.Type
);
const canvas = verticalElevator.getCanvas();
verticalElevators.forEach((item) => {
if (item.id === verticalElevator.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;
}
export class VerticalElevatorInteraction extends GraphicInteractionPlugin<VerticalElevator> {
static Name = 'tcc_light_transform';
constructor(app: IDrawApp) {
super(VerticalElevatorInteraction.Name, app);
}
static init(app: IDrawApp) {
return new VerticalElevatorInteraction(app);
}
filter(...grahpics: JlGraphic[]): VerticalElevator[] | undefined {
return grahpics
.filter((g) => g.type === VerticalElevator.Type)
.map((g) => g as VerticalElevator);
}
bind(g: VerticalElevator): void {
g.eventMode = 'static';
g.cursor = 'pointer';
g.scalable = true;
g.rotatable = true;
g.on('transformstart', this.transformstart, this);
}
unbind(g: VerticalElevator): void {
g.eventMode = 'none';
g.scalable = false;
g.rotatable = false;
g.off('transformstart', this.transformstart, this);
}
transformstart(e: GraphicTransformEvent) {
const target = e.target as DisplayObject;
const verticalElevator = target.getGraphic() as VerticalElevator;
verticalElevator.getGraphicApp().setOptions({
absorbablePositions: buildAbsorbablePositions(verticalElevator),
});
}
}

View File

@ -0,0 +1,29 @@
{
"frames": {
"green-off.png": {
"frame": { "x": 0, "y": 0, "w": 128, "h": 128 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
"sourceSize": { "w": 128, "h": 128 },
"anchor": { "x": 0.5, "y": 0.5 }
},
"green-on.png": {
"frame": { "x": 128, "y": 0, "w": 128, "h": 128 },
"rotated": false,
"trimmed": false,
"spriteSourceSize": { "x": 0, "y": 0, "w": 128, "h": 128 },
"sourceSize": { "w": 128, "h": 64 },
"anchor": { "x": 0.5, "y": 0.5 }
}
},
"meta": {
"app": "https://www.codeandweb.com/texturepacker",
"version": "1.1",
"image": "tcc-light.png",
"format": "RGBA8888",
"size": { "w": 256, "h": 128 },
"scale": "0.5",
"smartupdate": "$TexturePacker:SmartUpdate:e7620bd2d73cc0b3e2deea9704e7eefc:f129a1d9e4b9ba57720b3861c22b155b:eb2d421f7759984b7713aa4aa5354134$"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

View File

@ -314,6 +314,7 @@ import { Escalator } from 'src/graphics/BAS/escalator/Escalator';
import { TemperatureDetector } from 'src/graphics/FAS/temperatureDetector/TemperatureDetector'; import { TemperatureDetector } from 'src/graphics/FAS/temperatureDetector/TemperatureDetector';
import { FireShutter } from 'src/graphics/FAS/fireShutter/FireShutter'; import { FireShutter } from 'src/graphics/FAS/fireShutter/FireShutter';
import { FirePump } from 'src/graphics/FAS/firePump/FirePump'; import { FirePump } from 'src/graphics/FAS/firePump/FirePump';
import { VerticalElevator } from 'src/graphics/BAS/verticalElevator/VerticalElevator';
const $q = useQuasar(); const $q = useQuasar();
const route = useRoute(); const route = useRoute();
@ -395,7 +396,7 @@ function handleUtilsOption() {
]; ];
switch (drawStore.selectSubmenuAndStation.submenu) { switch (drawStore.selectSubmenuAndStation.submenu) {
case '电扶梯': case '电扶梯':
drawAssistantsTypes.push(Escalator.Type); drawAssistantsTypes.push(...[Escalator.Type, VerticalElevator.Type]);
break; break;
case '火灾报警平面图': case '火灾报警平面图':
drawAssistantsTypes.push(FasFailureControlHost.Type); drawAssistantsTypes.push(FasFailureControlHost.Type);

View File

@ -2194,7 +2194,7 @@ export namespace iscsGraphicData {
canvas?: dependency_1.common.Canvas; canvas?: dependency_1.common.Canvas;
commonGraphicStorage?: CommonGraphicStorage; commonGraphicStorage?: CommonGraphicStorage;
escalators?: Escalator[]; escalators?: Escalator[];
verticalElevator?: VerticalElevator[]; verticalElevators?: VerticalElevator[];
}) { }) {
super(); super();
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4, 5], this.#one_of_decls); pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [4, 5], this.#one_of_decls);
@ -2211,8 +2211,8 @@ export namespace iscsGraphicData {
if ("escalators" in data && data.escalators != undefined) { if ("escalators" in data && data.escalators != undefined) {
this.escalators = data.escalators; this.escalators = data.escalators;
} }
if ("verticalElevator" in data && data.verticalElevator != undefined) { if ("verticalElevators" in data && data.verticalElevators != undefined) {
this.verticalElevator = data.verticalElevator; this.verticalElevators = data.verticalElevators;
} }
} }
} }
@ -2246,10 +2246,10 @@ export namespace iscsGraphicData {
set escalators(value: Escalator[]) { set escalators(value: Escalator[]) {
pb_1.Message.setRepeatedWrapperField(this, 4, value); pb_1.Message.setRepeatedWrapperField(this, 4, value);
} }
get verticalElevator() { get verticalElevators() {
return pb_1.Message.getRepeatedWrapperField(this, VerticalElevator, 5) as VerticalElevator[]; return pb_1.Message.getRepeatedWrapperField(this, VerticalElevator, 5) as VerticalElevator[];
} }
set verticalElevator(value: VerticalElevator[]) { set verticalElevators(value: VerticalElevator[]) {
pb_1.Message.setRepeatedWrapperField(this, 5, value); pb_1.Message.setRepeatedWrapperField(this, 5, value);
} }
static fromObject(data: { static fromObject(data: {
@ -2257,7 +2257,7 @@ export namespace iscsGraphicData {
canvas?: ReturnType<typeof dependency_1.common.Canvas.prototype.toObject>; canvas?: ReturnType<typeof dependency_1.common.Canvas.prototype.toObject>;
commonGraphicStorage?: ReturnType<typeof CommonGraphicStorage.prototype.toObject>; commonGraphicStorage?: ReturnType<typeof CommonGraphicStorage.prototype.toObject>;
escalators?: ReturnType<typeof Escalator.prototype.toObject>[]; escalators?: ReturnType<typeof Escalator.prototype.toObject>[];
verticalElevator?: ReturnType<typeof VerticalElevator.prototype.toObject>[]; verticalElevators?: ReturnType<typeof VerticalElevator.prototype.toObject>[];
}): BASOfEscalatorStorage { }): BASOfEscalatorStorage {
const message = new BASOfEscalatorStorage({}); const message = new BASOfEscalatorStorage({});
if (data.stationName != null) { if (data.stationName != null) {
@ -2272,8 +2272,8 @@ export namespace iscsGraphicData {
if (data.escalators != null) { if (data.escalators != null) {
message.escalators = data.escalators.map(item => Escalator.fromObject(item)); message.escalators = data.escalators.map(item => Escalator.fromObject(item));
} }
if (data.verticalElevator != null) { if (data.verticalElevators != null) {
message.verticalElevator = data.verticalElevator.map(item => VerticalElevator.fromObject(item)); message.verticalElevators = data.verticalElevators.map(item => VerticalElevator.fromObject(item));
} }
return message; return message;
} }
@ -2283,7 +2283,7 @@ export namespace iscsGraphicData {
canvas?: ReturnType<typeof dependency_1.common.Canvas.prototype.toObject>; canvas?: ReturnType<typeof dependency_1.common.Canvas.prototype.toObject>;
commonGraphicStorage?: ReturnType<typeof CommonGraphicStorage.prototype.toObject>; commonGraphicStorage?: ReturnType<typeof CommonGraphicStorage.prototype.toObject>;
escalators?: ReturnType<typeof Escalator.prototype.toObject>[]; escalators?: ReturnType<typeof Escalator.prototype.toObject>[];
verticalElevator?: ReturnType<typeof VerticalElevator.prototype.toObject>[]; verticalElevators?: ReturnType<typeof VerticalElevator.prototype.toObject>[];
} = {}; } = {};
if (this.stationName != null) { if (this.stationName != null) {
data.stationName = this.stationName; data.stationName = this.stationName;
@ -2297,8 +2297,8 @@ export namespace iscsGraphicData {
if (this.escalators != null) { if (this.escalators != null) {
data.escalators = this.escalators.map((item: Escalator) => item.toObject()); data.escalators = this.escalators.map((item: Escalator) => item.toObject());
} }
if (this.verticalElevator != null) { if (this.verticalElevators != null) {
data.verticalElevator = this.verticalElevator.map((item: VerticalElevator) => item.toObject()); data.verticalElevators = this.verticalElevators.map((item: VerticalElevator) => item.toObject());
} }
return data; return data;
} }
@ -2314,8 +2314,8 @@ export namespace iscsGraphicData {
writer.writeMessage(3, this.commonGraphicStorage, () => this.commonGraphicStorage.serialize(writer)); writer.writeMessage(3, this.commonGraphicStorage, () => this.commonGraphicStorage.serialize(writer));
if (this.escalators.length) if (this.escalators.length)
writer.writeRepeatedMessage(4, this.escalators, (item: Escalator) => item.serialize(writer)); writer.writeRepeatedMessage(4, this.escalators, (item: Escalator) => item.serialize(writer));
if (this.verticalElevator.length) if (this.verticalElevators.length)
writer.writeRepeatedMessage(5, this.verticalElevator, (item: VerticalElevator) => item.serialize(writer)); writer.writeRepeatedMessage(5, this.verticalElevators, (item: VerticalElevator) => item.serialize(writer));
if (!w) if (!w)
return writer.getResultBuffer(); return writer.getResultBuffer();
} }
@ -2338,7 +2338,7 @@ export namespace iscsGraphicData {
reader.readMessage(message.escalators, () => pb_1.Message.addToRepeatedWrapperField(message, 4, Escalator.deserialize(reader), Escalator)); reader.readMessage(message.escalators, () => pb_1.Message.addToRepeatedWrapperField(message, 4, Escalator.deserialize(reader), Escalator));
break; break;
case 5: case 5:
reader.readMessage(message.verticalElevator, () => pb_1.Message.addToRepeatedWrapperField(message, 5, VerticalElevator.deserialize(reader), VerticalElevator)); reader.readMessage(message.verticalElevators, () => pb_1.Message.addToRepeatedWrapperField(message, 5, VerticalElevator.deserialize(reader), VerticalElevator));
break; break;
default: reader.skipField(); default: reader.skipField();
} }