消防泵代码提交
This commit is contained in:
parent
61911d9ee5
commit
afd27d4b3e
@ -118,4 +118,13 @@
|
||||
<path d="M791.04 384h-563.2c-15.36 0-25.6-10.24-25.6-25.6s10.24-25.6 25.6-25.6h563.2c15.36 0 25.6 10.24 25.6 25.6 0 12.8-10.24 25.6-25.6 25.6zM253.44 384h25.6v512h-25.6zM739.84 384h25.6v512h-25.6z" fill="#ffffff" p-id="3529"></path>
|
||||
<path d="M279.04 435.2h460.8v25.6h-460.8zM279.04 512h460.8v25.6h-460.8zM279.04 588.8h460.8v25.6h-460.8zM279.04 665.6h460.8v25.6h-460.8zM279.04 742.4h460.8v25.6h-460.8zM279.04 819.2h460.8v25.6h-460.8z" fill="#ffffff" p-id="3530"></path>
|
||||
</symbol>
|
||||
<symbol id="icon-fire-pump" viewBox="0 0 1024 1024" fill="none" width="24" height="24">
|
||||
<path d="M796.373333 321.493333a277.333333 277.333333 0 1 0-554.666666 0h85.333333a192 192 0 0 1 384 0h85.333333z" fill="#ffffff" p-id="4458"></path>
|
||||
<path d="M113.706667 300.16m42.666666 0l725.333334 0q42.666667 0 42.666666 42.666667l0 0q0 42.666667-42.666666 42.666666l-725.333334 0q-42.666667 0-42.666666-42.666666l0 0q0-42.666667 42.666666-42.666667Z" fill="#ffffff" p-id="4459"></path>
|
||||
<path d="M156.373333 897.493333m42.666667 0l640 0q42.666667 0 42.666667 42.666667l0 0q0 42.666667-42.666667 42.666667l-640 0q-42.666667 0-42.666667-42.666667l0 0q0-42.666667 42.666667-42.666667Z" fill="#ffffff" p-id="4460"></path>
|
||||
<path d="M711.04 342.826667h85.333333v167.68h-85.333333V342.826667z m0 547.541333v-245.632h85.333333v245.632c0 48.64-31.786667 92.458667-78.762666 92.458667H320.469333C273.493333 982.826667 241.706667 939.008 241.706667 890.368v-245.376h85.333333v245.376c0 2.773333 0.426667 5.205333 1.024 7.125333h381.952a23.808 23.808 0 0 0 1.024-7.125333z m-384-380.074667H241.706667V342.826667h85.333333v167.466666z" fill="#ffffff" p-id="4461"></path>
|
||||
<path d="M393.088 497.962667m42.666667 0l0 0q42.666667 0 42.666666 42.666666l0 213.333334q0 42.666667-42.666666 42.666666l0 0q-42.666667 0-42.666667-42.666666l0-213.333334q0-42.666667 42.666667-42.666666Z" fill="#ffffff" p-id="4462"></path>
|
||||
<path d="M563.754667 497.962667m42.666666 0l0 0q42.666667 0 42.666667 42.666666l0 213.333334q0 42.666667-42.666667 42.666666l0 0q-42.666667 0-42.666666-42.666666l0-213.333334q0-42.666667 42.666666-42.666666Z" fill="#ffffff" p-id="4463"></path>
|
||||
<path d="M796.373333 470.826667h85.333334v213.333333h-85.333334zM156.373333 470.826667h85.333334v213.333333H156.373333z" fill="#ffffff" p-id="4464"></path>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 21 KiB After Width: | Height: | Size: 23 KiB |
38
src/drawApp/graphics/FAS/FirePumpInteraction.ts
Normal file
38
src/drawApp/graphics/FAS/FirePumpInteraction.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import * as pb_1 from 'google-protobuf';
|
||||
import { GraphicDataBase } from '../GraphicDataBase';
|
||||
import { FirePump, IFirePumpData } from 'src/graphics/FAS/firePump/FirePump';
|
||||
import { iscsGraphicData } from 'src/protos/iscs_graphic_data';
|
||||
|
||||
export class FirePumpData extends GraphicDataBase implements IFirePumpData {
|
||||
constructor(data?: iscsGraphicData.FirePump) {
|
||||
let firePump;
|
||||
if (data) {
|
||||
firePump = data;
|
||||
} else {
|
||||
firePump = new iscsGraphicData.FirePump({
|
||||
common: GraphicDataBase.defaultCommonInfo(FirePump.Type),
|
||||
});
|
||||
}
|
||||
super(firePump);
|
||||
}
|
||||
|
||||
public get data(): iscsGraphicData.FirePump {
|
||||
return this.getData<iscsGraphicData.FirePump>();
|
||||
}
|
||||
|
||||
get code(): string {
|
||||
return this.data.code;
|
||||
}
|
||||
set code(v: string) {
|
||||
this.data.code = v;
|
||||
}
|
||||
clone(): FirePumpData {
|
||||
return new FirePumpData(this.data.cloneMessage());
|
||||
}
|
||||
copyFrom(data: FirePumpData): void {
|
||||
pb_1.Message.copyInto(data.data, this.data);
|
||||
}
|
||||
eq(other: FirePumpData): boolean {
|
||||
return pb_1.Message.equals(this.data, other.data);
|
||||
}
|
||||
}
|
@ -65,6 +65,9 @@ import {
|
||||
EscalatorTemplate,
|
||||
} from 'src/graphics/BAS/escalator/Escalator';
|
||||
import { EscalatorData } from './graphics/BAS/EscalatorInteraction';
|
||||
import { FirePump, FirePumpTemplate } from 'src/graphics/FAS/firePump/FirePump';
|
||||
import { FirePumpDraw } from 'src/graphics/FAS/firePump/FirePumpAssistant';
|
||||
import { FirePumpData } from './graphics/FAS/FirePumpInteraction';
|
||||
// import { getOnlyToken } from 'src/configs/TokenManage';
|
||||
|
||||
let drawApp: IDrawApp | null = null;
|
||||
@ -118,6 +121,7 @@ export function initIscsDrawApp(): IDrawApp {
|
||||
new TemperatureDetectorTemplate(new TemperatureDetectorData())
|
||||
);
|
||||
new FireShutterDraw(app, new FireShutterTemplate(new FireShutterData()));
|
||||
new FirePumpDraw(app, new FirePumpTemplate(new FirePumpData()));
|
||||
|
||||
app.addKeyboardListener(
|
||||
new KeyListener({
|
||||
@ -303,6 +307,9 @@ export async function loadDrawDatas(): Promise<IGraphicStorage> {
|
||||
fasOfPlatformAlarm.fireShutters.forEach((fireShutter) => {
|
||||
datas.push(new FireShutterData(fireShutter));
|
||||
});
|
||||
fasOfPlatformAlarm.firePumps.forEach((firePump) => {
|
||||
datas.push(new FirePumpData(firePump));
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -442,6 +449,9 @@ export function saveDrawDatas(app: IDrawApp) {
|
||||
fasStorage.fireShutters.push(
|
||||
(fireShutterData as FireShutterData).data
|
||||
);
|
||||
} else if (g instanceof FirePump) {
|
||||
const firePumpData = g.saveData();
|
||||
fasStorage.firePumps.push((firePumpData as FirePumpData).data);
|
||||
}
|
||||
});
|
||||
storage.fasOfPlatformAlarmStorages[i] = fasStorage;
|
||||
|
@ -0,0 +1,63 @@
|
||||
import { GraphicData, JlGraphic, JlGraphicTemplate } from 'jl-graphic';
|
||||
import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js';
|
||||
// import { iscsGraphicData } from 'src/protos/iscs_graphic_data';
|
||||
import FirePumpJson from './FirePump.json';
|
||||
import FirePumpAssets from './FirePump.png';
|
||||
|
||||
export interface IFirePumpData extends GraphicData {
|
||||
get code(): string;
|
||||
set code(v: string);
|
||||
}
|
||||
|
||||
interface FirePumpTextures {
|
||||
normal: Texture;
|
||||
}
|
||||
|
||||
export class FirePump extends JlGraphic {
|
||||
static Type = 'FirePump';
|
||||
_firePump: Sprite;
|
||||
firePumpTextures: FirePumpTextures;
|
||||
__state = 0;
|
||||
|
||||
constructor(firePumpTextures: FirePumpTextures) {
|
||||
super(FirePump.Type);
|
||||
this._firePump = new Sprite();
|
||||
this.firePumpTextures = firePumpTextures;
|
||||
this._firePump.anchor.set(0.5);
|
||||
this.addChild(this._firePump);
|
||||
this._firePump.texture = this.firePumpTextures.normal;
|
||||
}
|
||||
get code(): string {
|
||||
return this.datas.code;
|
||||
}
|
||||
get datas(): IFirePumpData {
|
||||
return this.getDatas<IFirePumpData>();
|
||||
}
|
||||
|
||||
doRepaint(): void {}
|
||||
}
|
||||
|
||||
export class FirePumpTemplate extends JlGraphicTemplate<FirePump> {
|
||||
firePumpTextures?: FirePumpTextures;
|
||||
constructor(dataTemplate: IFirePumpData) {
|
||||
super(FirePump.Type, { dataTemplate });
|
||||
this.loadAssets();
|
||||
}
|
||||
new(): FirePump {
|
||||
if (this.firePumpTextures) {
|
||||
const g = new FirePump(this.firePumpTextures);
|
||||
g.loadData(this.datas);
|
||||
return g;
|
||||
}
|
||||
throw new Error('资源未加载/加载失败');
|
||||
}
|
||||
async loadAssets(): Promise<FirePumpTextures> {
|
||||
const texture = await Assets.load(FirePumpAssets);
|
||||
const firePumpSheet = new Spritesheet(texture, FirePumpJson);
|
||||
const result = await firePumpSheet.parse();
|
||||
this.firePumpTextures = {
|
||||
normal: result['normal.png'],
|
||||
};
|
||||
return this.firePumpTextures as FirePumpTextures;
|
||||
}
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js';
|
||||
import {
|
||||
AbsorbableLine,
|
||||
AbsorbablePosition,
|
||||
GraphicDrawAssistant,
|
||||
GraphicInteractionPlugin,
|
||||
GraphicTransformEvent,
|
||||
IDrawApp,
|
||||
JlGraphic,
|
||||
} from 'jl-graphic';
|
||||
import { IFirePumpData, FirePump, FirePumpTemplate } from './FirePump';
|
||||
|
||||
export class FirePumpDraw extends GraphicDrawAssistant<
|
||||
FirePumpTemplate,
|
||||
IFirePumpData
|
||||
> {
|
||||
_firePump: FirePump | null = null;
|
||||
constructor(app: IDrawApp, template: FirePumpTemplate) {
|
||||
super(app, template, 'svguse:../drawIcon.svg#icon-fire-pump', '消防泵');
|
||||
FirePumpInteraction.init(app);
|
||||
}
|
||||
|
||||
bind(): void {
|
||||
super.bind();
|
||||
if (!this._firePump) {
|
||||
this._firePump = this.graphicTemplate.new();
|
||||
this.container.addChild(this._firePump);
|
||||
}
|
||||
}
|
||||
|
||||
public get firePump(): FirePump {
|
||||
if (!this._firePump) {
|
||||
this._firePump = this.graphicTemplate.new();
|
||||
this.container.addChild(this._firePump);
|
||||
}
|
||||
return this._firePump;
|
||||
}
|
||||
|
||||
redraw(cp: Point): void {
|
||||
this.firePump.position.copyFrom(cp);
|
||||
}
|
||||
onLeftUp(e: FederatedMouseEvent): void {
|
||||
this.firePump.position.copyFrom(this.toCanvasCoordinates(e.global));
|
||||
this.createAndStore(true);
|
||||
}
|
||||
prepareData(data: IFirePumpData): boolean {
|
||||
data.transform = this.firePump.saveTransform();
|
||||
return true;
|
||||
}
|
||||
onEsc(): void {
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建吸附线
|
||||
* @param firePump
|
||||
*/
|
||||
function buildAbsorbablePositions(firePump: FirePump): AbsorbablePosition[] {
|
||||
const aps: AbsorbablePosition[] = [];
|
||||
const firePumps = firePump.queryStore.queryByType<FirePump>(FirePump.Type);
|
||||
const canvas = firePump.getCanvas();
|
||||
firePumps.forEach((item) => {
|
||||
if (item.id === firePump.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 FirePumpInteraction extends GraphicInteractionPlugin<FirePump> {
|
||||
static Name = 'fire_pump_transform';
|
||||
constructor(app: IDrawApp) {
|
||||
super(FirePumpInteraction.Name, app);
|
||||
}
|
||||
static init(app: IDrawApp) {
|
||||
return new FirePumpInteraction(app);
|
||||
}
|
||||
filter(...grahpics: JlGraphic[]): FirePump[] | undefined {
|
||||
return grahpics
|
||||
.filter((g) => g.type === FirePump.Type)
|
||||
.map((g) => g as FirePump);
|
||||
}
|
||||
bind(g: FirePump): void {
|
||||
g.eventMode = 'static';
|
||||
g.cursor = 'pointer';
|
||||
g.scalable = true;
|
||||
g.rotatable = true;
|
||||
g.on('transformstart', this.transformstart, this);
|
||||
}
|
||||
unbind(g: FirePump): 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 firePump = target.getGraphic() as FirePump;
|
||||
firePump.getGraphicApp().setOptions({
|
||||
absorbablePositions: buildAbsorbablePositions(firePump),
|
||||
});
|
||||
}
|
||||
}
|
@ -313,6 +313,7 @@ import { SmokeDetector } from 'src/graphics/FAS/smokeDetector/SmokeDetector';
|
||||
import { Escalator } from 'src/graphics/BAS/escalator/Escalator';
|
||||
import { TemperatureDetector } from 'src/graphics/FAS/temperatureDetector/TemperatureDetector';
|
||||
import { FireShutter } from 'src/graphics/FAS/fireShutter/FireShutter';
|
||||
import { FirePump } from 'src/graphics/FAS/firePump/FirePump';
|
||||
|
||||
const $q = useQuasar();
|
||||
const route = useRoute();
|
||||
@ -403,6 +404,7 @@ function handleUtilsOption() {
|
||||
drawAssistantsTypes.push(SmokeDetector.Type);
|
||||
drawAssistantsTypes.push(TemperatureDetector.Type);
|
||||
drawAssistantsTypes.push(FireShutter.Type);
|
||||
drawAssistantsTypes.push(FirePump.Type);
|
||||
break;
|
||||
}
|
||||
drawAssistantsTypes.forEach((type) => {
|
||||
|
Loading…
Reference in New Issue
Block a user