From f5d87acd4cecf378d160bac3581f3be7907f7d1e Mon Sep 17 00:00:00 2001 From: joylink_fanyuhong <18706759286@163.com> Date: Thu, 24 Oct 2024 09:29:44 +0800 Subject: [PATCH] =?UTF-8?q?fas=E8=AE=BE=E5=A4=87=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/drawIcon.svg | 7 + src/drawApp/graphics/FAS/AcsInteraction.ts | 38 +++++ .../graphics/FAS/SprayPumpInteraction.ts | 41 ++++++ .../FAS/StabilizedPressurePumpInteraction.ts | 44 ++++++ src/drawApp/iscsApp.ts | 45 ++++++ src/graphics/FAS/acs/Acs.ts | 70 ++++++++++ src/graphics/FAS/acs/AcsAssistant.ts | 112 +++++++++++++++ src/graphics/FAS/sprayPump/SprayPump.json | 21 +++ src/graphics/FAS/sprayPump/SprayPump.png | Bin 0 -> 1755 bytes src/graphics/FAS/sprayPump/SprayPump.ts | 63 +++++++++ .../FAS/sprayPump/SprayPumpAssistant.ts | 117 ++++++++++++++++ .../StabilizedPressurePump.json | 21 +++ .../StabilizedPressurePump.png | Bin 0 -> 1748 bytes .../StabilizedPressurePump.ts | 68 +++++++++ .../StabilizedPressurePumpAssistant.ts | 132 ++++++++++++++++++ src/layouts/IscsDrawLayout.vue | 6 + 16 files changed, 785 insertions(+) create mode 100644 src/drawApp/graphics/FAS/AcsInteraction.ts create mode 100644 src/drawApp/graphics/FAS/SprayPumpInteraction.ts create mode 100644 src/drawApp/graphics/FAS/StabilizedPressurePumpInteraction.ts create mode 100644 src/graphics/FAS/acs/Acs.ts create mode 100644 src/graphics/FAS/acs/AcsAssistant.ts create mode 100644 src/graphics/FAS/sprayPump/SprayPump.json create mode 100644 src/graphics/FAS/sprayPump/SprayPump.png create mode 100644 src/graphics/FAS/sprayPump/SprayPump.ts create mode 100644 src/graphics/FAS/sprayPump/SprayPumpAssistant.ts create mode 100644 src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePump.json create mode 100644 src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePump.png create mode 100644 src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePump.ts create mode 100644 src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePumpAssistant.ts diff --git a/public/drawIcon.svg b/public/drawIcon.svg index 65cadd3..15c7d92 100644 --- a/public/drawIcon.svg +++ b/public/drawIcon.svg @@ -127,4 +127,11 @@ + + + + + + + diff --git a/src/drawApp/graphics/FAS/AcsInteraction.ts b/src/drawApp/graphics/FAS/AcsInteraction.ts new file mode 100644 index 0000000..2faeca8 --- /dev/null +++ b/src/drawApp/graphics/FAS/AcsInteraction.ts @@ -0,0 +1,38 @@ +import * as pb_1 from 'google-protobuf'; +import { GraphicDataBase } from '../GraphicDataBase'; +import { Acs, IAcsData } from 'src/graphics/FAS/acs/Acs'; +import { iscsGraphicData } from 'src/protos/iscs_graphic_data'; + +export class AcsData extends GraphicDataBase implements IAcsData { + constructor(data?: iscsGraphicData.Acs) { + let acs; + if (data) { + acs = data; + } else { + acs = new iscsGraphicData.Acs({ + common: GraphicDataBase.defaultCommonInfo(Acs.Type), + }); + } + super(acs); + } + + public get data(): iscsGraphicData.Acs { + return this.getData(); + } + + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + clone(): AcsData { + return new AcsData(this.data.cloneMessage()); + } + copyFrom(data: AcsData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: AcsData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/graphics/FAS/SprayPumpInteraction.ts b/src/drawApp/graphics/FAS/SprayPumpInteraction.ts new file mode 100644 index 0000000..1790522 --- /dev/null +++ b/src/drawApp/graphics/FAS/SprayPumpInteraction.ts @@ -0,0 +1,41 @@ +import * as pb_1 from 'google-protobuf'; +import { GraphicDataBase } from '../GraphicDataBase'; +import { + SprayPump, + ISprayPumpData, +} from 'src/graphics/FAS/sprayPump/SprayPump'; +import { iscsGraphicData } from 'src/protos/iscs_graphic_data'; + +export class SprayPumpData extends GraphicDataBase implements ISprayPumpData { + constructor(data?: iscsGraphicData.SprayPump) { + let sprayPump; + if (data) { + sprayPump = data; + } else { + sprayPump = new iscsGraphicData.SprayPump({ + common: GraphicDataBase.defaultCommonInfo(SprayPump.Type), + }); + } + super(sprayPump); + } + + public get data(): iscsGraphicData.SprayPump { + return this.getData(); + } + + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + clone(): SprayPumpData { + return new SprayPumpData(this.data.cloneMessage()); + } + copyFrom(data: SprayPumpData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: SprayPumpData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/graphics/FAS/StabilizedPressurePumpInteraction.ts b/src/drawApp/graphics/FAS/StabilizedPressurePumpInteraction.ts new file mode 100644 index 0000000..1b3ee53 --- /dev/null +++ b/src/drawApp/graphics/FAS/StabilizedPressurePumpInteraction.ts @@ -0,0 +1,44 @@ +import * as pb_1 from 'google-protobuf'; +import { GraphicDataBase } from '../GraphicDataBase'; +import { iscsGraphicData } from 'src/protos/iscs_graphic_data'; +import { + StabilizedPressurePump, + IStabilizedPressurePumpData, +} from 'src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePump'; + +export class StabilizedPressurePumpData + extends GraphicDataBase + implements IStabilizedPressurePumpData +{ + constructor(data?: iscsGraphicData.StabilizedPressurePump) { + let stabilizedPressurePump; + if (data) { + stabilizedPressurePump = data; + } else { + stabilizedPressurePump = new iscsGraphicData.StabilizedPressurePump({ + common: GraphicDataBase.defaultCommonInfo(StabilizedPressurePump.Type), + }); + } + super(stabilizedPressurePump); + } + + public get data(): iscsGraphicData.StabilizedPressurePump { + return this.getData(); + } + + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + clone(): StabilizedPressurePumpData { + return new StabilizedPressurePumpData(this.data.cloneMessage()); + } + copyFrom(data: StabilizedPressurePumpData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: StabilizedPressurePumpData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/iscsApp.ts b/src/drawApp/iscsApp.ts index c7738cc..457e5a5 100644 --- a/src/drawApp/iscsApp.ts +++ b/src/drawApp/iscsApp.ts @@ -68,6 +68,21 @@ 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 { SprayPumpDraw } from 'src/graphics/FAS/sprayPump/SprayPumpAssistant'; +import { + SprayPump, + SprayPumpTemplate, +} from 'src/graphics/FAS/sprayPump/SprayPump'; +import { SprayPumpData } from './graphics/FAS/SprayPumpInteraction'; +import { StabilizedPressurePumpData } from './graphics/FAS/StabilizedPressurePumpInteraction'; +import { StabilizedPressurePumpDraw } from 'src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePumpAssistant'; +import { + StabilizedPressurePump, + StabilizedPressurePumpTemplate, +} from 'src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePump'; +import { AcsDraw } from 'src/graphics/FAS/acs/AcsAssistant'; +import { Acs, AcsTemplate } from 'src/graphics/FAS/acs/Acs'; +import { AcsData } from './graphics/FAS/AcsInteraction'; // import { getOnlyToken } from 'src/configs/TokenManage'; let drawApp: IDrawApp | null = null; @@ -122,6 +137,12 @@ export function initIscsDrawApp(): IDrawApp { ); new FireShutterDraw(app, new FireShutterTemplate(new FireShutterData())); new FirePumpDraw(app, new FirePumpTemplate(new FirePumpData())); + new SprayPumpDraw(app, new SprayPumpTemplate(new SprayPumpData())); + new StabilizedPressurePumpDraw( + app, + new StabilizedPressurePumpTemplate(new StabilizedPressurePumpData()) + ); + new AcsDraw(app, new AcsTemplate(new AcsData())); app.addKeyboardListener( new KeyListener({ @@ -310,6 +331,19 @@ export async function loadDrawDatas(): Promise { fasOfPlatformAlarm.firePumps.forEach((firePump) => { datas.push(new FirePumpData(firePump)); }); + fasOfPlatformAlarm.sprayPumps.forEach((sprayPump) => { + datas.push(new SprayPumpData(sprayPump)); + }); + fasOfPlatformAlarm.stabilizedPressurePumps.forEach( + (stabilizedPressurePump) => { + datas.push( + new StabilizedPressurePumpData(stabilizedPressurePump) + ); + } + ); + fasOfPlatformAlarm.acs.forEach((acs) => { + datas.push(new AcsData(acs)); + }); break; } } @@ -452,6 +486,17 @@ export function saveDrawDatas(app: IDrawApp) { } else if (g instanceof FirePump) { const firePumpData = g.saveData(); fasStorage.firePumps.push((firePumpData as FirePumpData).data); + } else if (g instanceof SprayPump) { + const sprayPumpData = g.saveData(); + fasStorage.sprayPumps.push((sprayPumpData as SprayPumpData).data); + } else if (g instanceof StabilizedPressurePump) { + const stabilizedPressurePumpData = g.saveData(); + fasStorage.stabilizedPressurePumps.push( + (stabilizedPressurePumpData as StabilizedPressurePumpData).data + ); + } else if (g instanceof Acs) { + const acsData = g.saveData(); + fasStorage.acs.push((acsData as AcsData).data); } }); storage.fasOfPlatformAlarmStorages[i] = fasStorage; diff --git a/src/graphics/FAS/acs/Acs.ts b/src/graphics/FAS/acs/Acs.ts new file mode 100644 index 0000000..025f053 --- /dev/null +++ b/src/graphics/FAS/acs/Acs.ts @@ -0,0 +1,70 @@ +import { Graphics } from 'pixi.js'; +import { + GraphicData, + JlGraphic, + JlGraphicTemplate, + VectorText, +} from 'jl-graphic'; + +export interface IAcsData extends GraphicData { + get code(): string; // 编号 + set code(v: string); + clone(): IAcsData; + copyFrom(data: IAcsData): void; + eq(other: IAcsData): boolean; +} + +const acsConsts = { + rectWidth: 64, + rectHeight: 24, + rectBackground: '0x99ccff', + textColor: '0x33cc00', + text: 'ACS联动', + fontSize: 12, +}; + +export class Acs extends JlGraphic { + static Type = 'Acs'; + rectGraphic: Graphics = new Graphics(); + textGraphic: VectorText = new VectorText(); + constructor() { + console.log('22222222'); + super(Acs.Type); + this.addChild(this.rectGraphic); + this.addChild(this.textGraphic); + } + + get datas(): IAcsData { + return this.getDatas(); + } + doRepaint(): void { + console.log('111111111'); + const rectGraphic = this.rectGraphic; + rectGraphic.clear(); + rectGraphic.beginFill(acsConsts.rectBackground); + rectGraphic.drawRect(0, 0, acsConsts.rectWidth, acsConsts.rectHeight); + rectGraphic.endFill(); + + this.textGraphic.text = acsConsts.text; + this.textGraphic.setVectorFontSize(acsConsts.fontSize); + this.textGraphic.anchor.set(0.5); + this.textGraphic.style.fill = acsConsts.textColor; + this.textGraphic.position.set( + acsConsts.rectWidth / 2, + acsConsts.rectHeight / 2 + ); + } +} + +export class AcsTemplate extends JlGraphicTemplate { + constructor(dataTemplate: IAcsData) { + super(Acs.Type, { + dataTemplate, + }); + } + new(): Acs { + const acs = new Acs(); + acs.loadData(this.datas); + return acs; + } +} diff --git a/src/graphics/FAS/acs/AcsAssistant.ts b/src/graphics/FAS/acs/AcsAssistant.ts new file mode 100644 index 0000000..e42164b --- /dev/null +++ b/src/graphics/FAS/acs/AcsAssistant.ts @@ -0,0 +1,112 @@ +import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js'; +import { + AbsorbableLine, + AbsorbablePosition, + GraphicDrawAssistant, + GraphicInteractionPlugin, + GraphicTransformEvent, + IDrawApp, + JlGraphic, +} from 'jl-graphic'; +import { IAcsData, Acs, AcsTemplate } from './Acs'; + +export class AcsDraw extends GraphicDrawAssistant { + _acs: Acs | null = null; + constructor(app: IDrawApp, template: AcsTemplate) { + super(app, template, 'svguse:../drawIcon.svg#icon-fas-alarm', 'ACS'); + AcsInteraction.init(app); + } + + bind(): void { + super.bind(); + if (!this._acs) { + this._acs = this.graphicTemplate.new(); + this.container.addChild(this._acs); + this._acs.doRepaint(); + } + } + + public get acs(): Acs { + if (!this._acs) { + this._acs = this.graphicTemplate.new(); + this.container.addChild(this._acs); + } + return this._acs; + } + + redraw(cp: Point): void { + console.log(this.acs, '==='); + this.acs.position.copyFrom(cp); + } + onLeftUp(e: FederatedMouseEvent): void { + this.acs.position.copyFrom(this.toCanvasCoordinates(e.global)); + this.createAndStore(true); + } + prepareData(data: IAcsData): boolean { + data.transform = this.acs.saveTransform(); + return true; + } + onEsc(): void { + this.finish(); + } +} + +/** + * 构建吸附线 + * @param fasAlarm + */ +function buildAbsorbablePositions(acs: Acs): AbsorbablePosition[] { + const aps: AbsorbablePosition[] = []; + const acses = acs.queryStore.queryByType(Acs.Type); + const canvas = acs.getCanvas(); + acses.forEach((item) => { + if (item.id === acs.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 AcsInteraction extends GraphicInteractionPlugin { + static Name = 'acs_transform'; + constructor(app: IDrawApp) { + super(AcsInteraction.Name, app); + } + static init(app: IDrawApp) { + return new AcsInteraction(app); + } + filter(...grahpics: JlGraphic[]): Acs[] | undefined { + return grahpics.filter((g) => g.type === Acs.Type).map((g) => g as Acs); + } + bind(g: Acs): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.rotatable = true; + g.on('transformstart', this.transformstart, this); + } + unbind(g: Acs): 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 acs = target.getGraphic() as Acs; + acs.getGraphicApp().setOptions({ + absorbablePositions: buildAbsorbablePositions(acs), + }); + } +} diff --git a/src/graphics/FAS/sprayPump/SprayPump.json b/src/graphics/FAS/sprayPump/SprayPump.json new file mode 100644 index 0000000..9ce17f2 --- /dev/null +++ b/src/graphics/FAS/sprayPump/SprayPump.json @@ -0,0 +1,21 @@ +{ + "frames": { + "normal.png": { + "frame": { "x": 0, "y": 0, "w": 22, "h": 46 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 22, "h": 46 }, + "sourceSize": { "w": 22, "h": 46 }, + "anchor": { "x": 0.5, "y": 0.5 } + } + }, + "meta": { + "app": "https://www.codeandweb.com/texturepacker", + "version": "1.1", + "image": "SprayPump.png", + "format": "RGBA8888", + "size": { "w": 27, "h": 26 }, + "scale": "1", + "smartupdate": "$TexturePacker:SmartUpdate:e7620bd2d73cc0b3e2deea9704e7eefc:f129a1d9e4b9ba57720b3861c22b155b:eb2d421f7759984b7713aa4aa5354134$" + } +} diff --git a/src/graphics/FAS/sprayPump/SprayPump.png b/src/graphics/FAS/sprayPump/SprayPump.png new file mode 100644 index 0000000000000000000000000000000000000000..01acaf835209ec1c089c9817d4b7ddc1a6ee7fe3 GIT binary patch literal 1755 zcmV<11|<23P)5500009a7bBm000ie z000ie0hKEb8vpKm&=bFR~3i9b8kJmyLx)YGqxN?juWI{JIIj`F^`x> z5D5#StRgvrZNw_sl0PBdut8+W9!HA8ir54x0x1UB0Yog>kxcA`jmeBX?V0IEb$8vW zdk>51879-iWEQaFN~La8u_72%h$2>sg8Nsm zqU|2 z=*$`7EW?&%t(!4mE#dZUSYHQgnN@fX@Yd4d5IJ&$#q;M$jvuGm+}sAFk3UZTjW;OX zd=sX5ePA$v7z25Z?{*2pVSSU6+l3MfAh{KC1H)x;51tHrp{z%&|2qk*I;635syC8!dd!;QzdvZNf3VKCq)osNF+ z+xNKn@eP>)uiU-MV@ZrpQ(T%djv^XyOcKW=QG~G;Ri*SESC&l5l5thx@|+vSFzWZW zSu?8tAddBPS#HbFm_B`H1Y2@UfZ_D>7rR(98sCf)PRB9cm^x2IFd`W0R;bh|hbpL| zs@zjxlz)aZ)0Xaza`_Wdx63JHXCWwcKk?IEoU8KdQ9g6>JuC0(D3?=ds`J*O#!#t} zPW{gVlc{s8hroxkY65#`{L2KZ1?1?h&{DyOjP+BFhcl42(0GAZQe}8 z&xvp%iddXFL!j;tX8K*G`Wa)0MfjdE{6m%NMZxNRQUqft%aWmU1Z&X{YH$byRg5u+ z2r?~kNfN3g!S6c!tb+`PoNu@J^0UwK#bd{qZ?$MPo3yixG)>7zBgW$~d7iU6neg$& zi@dP9%KaqWADmVdfA@iGd71fBr?88QNT);d&>_e&%FRv2{XV^o4L%)>_~haxocFAc zK4)O@K-(JHlY++PW^JU-VagI|HnIIa(Qru8>(QD_n44zH?lo(#|E2YR@c$khEiN2V z8%4OXq}SWr!@Ul^=I1(^BnhgD`RVJgbNlu!zV_{J0re~vf}$ZD2o`qqzV^ZbSFT>+ z;-yPOWm(ee_j&D=SNPGZuj;2SzR35V{Vq#So?jJue`RB8)No^1=n& z+8T{U1Ls@~URzt^=FOYj?soaHwb(euT1#XtaU7GTDa~e+R;z`o;+!K%65?mSueBsizpc^A65hiqQ!1o}wri3J5Ji*WtgHH`QC{=MJv&%1Z2y#IGow-#dz zA%yLhx;YwgE&GfZ)TOX+^ z4oxPssAsr2Yw5IF#MUx#j^SiNF9asQdXlh`ru=L$*uT*q6=5k!=p;$q7o{{(1 zs-iT8&~Df6ty(*{Dqm=2y0XJXX28qF@R%_)MF=AGi!cU>V*(H}b?T{e7@()h;mWhJ xU&I4d)>Ub3(); + } + + doRepaint(): void {} +} + +export class SprayPumpTemplate extends JlGraphicTemplate { + sprayPumpTextures?: SprayPumpTextures; + constructor(dataTemplate: ISprayPumpData) { + super(SprayPump.Type, { dataTemplate }); + this.loadAssets(); + } + new(): SprayPump { + if (this.sprayPumpTextures) { + const g = new SprayPump(this.sprayPumpTextures); + g.loadData(this.datas); + return g; + } + throw new Error('资源未加载/加载失败'); + } + async loadAssets(): Promise { + const texture = await Assets.load(SparyPumpAssets); + const sprayPumpSheet = new Spritesheet(texture, SprayPumpJson); + const result = await sprayPumpSheet.parse(); + this.sprayPumpTextures = { + normal: result['normal.png'], + }; + return this.sprayPumpTextures as SprayPumpTextures; + } +} diff --git a/src/graphics/FAS/sprayPump/SprayPumpAssistant.ts b/src/graphics/FAS/sprayPump/SprayPumpAssistant.ts new file mode 100644 index 0000000..a58adf4 --- /dev/null +++ b/src/graphics/FAS/sprayPump/SprayPumpAssistant.ts @@ -0,0 +1,117 @@ +import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js'; +import { + AbsorbableLine, + AbsorbablePosition, + GraphicDrawAssistant, + GraphicInteractionPlugin, + GraphicTransformEvent, + IDrawApp, + JlGraphic, +} from 'jl-graphic'; +import { ISprayPumpData, SprayPump, SprayPumpTemplate } from './SprayPump'; + +export class SprayPumpDraw extends GraphicDrawAssistant< + SprayPumpTemplate, + ISprayPumpData +> { + _sprayPump: SprayPump | null = null; + constructor(app: IDrawApp, template: SprayPumpTemplate) { + super(app, template, 'svguse:../drawIcon.svg#icon-spray-pump', '喷淋泵'); + SprayPumpInteraction.init(app); + } + + bind(): void { + super.bind(); + if (!this._sprayPump) { + this._sprayPump = this.graphicTemplate.new(); + this.container.addChild(this._sprayPump); + } + } + + public get sprayPump(): SprayPump { + if (!this._sprayPump) { + this._sprayPump = this.graphicTemplate.new(); + this.container.addChild(this._sprayPump); + } + return this._sprayPump; + } + + redraw(cp: Point): void { + this.sprayPump.position.copyFrom(cp); + } + onLeftUp(e: FederatedMouseEvent): void { + this.sprayPump.position.copyFrom(this.toCanvasCoordinates(e.global)); + this.createAndStore(true); + } + prepareData(data: ISprayPumpData): boolean { + data.transform = this.sprayPump.saveTransform(); + return true; + } + onEsc(): void { + this.finish(); + } +} + +/** + * 构建吸附线 + * @param sprayPump + */ +function buildAbsorbablePositions(sprayPump: SprayPump): AbsorbablePosition[] { + const aps: AbsorbablePosition[] = []; + const sprayPumps = sprayPump.queryStore.queryByType( + SprayPump.Type + ); + const canvas = sprayPump.getCanvas(); + sprayPumps.forEach((item) => { + if (item.id === sprayPump.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 SprayPumpInteraction extends GraphicInteractionPlugin { + static Name = 'spary_pump_transform'; + constructor(app: IDrawApp) { + super(SprayPumpInteraction.Name, app); + } + static init(app: IDrawApp) { + return new SprayPumpInteraction(app); + } + filter(...grahpics: JlGraphic[]): SprayPump[] | undefined { + return grahpics + .filter((g) => g.type === SprayPump.Type) + .map((g) => g as SprayPump); + } + bind(g: SprayPump): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.rotatable = true; + g.on('transformstart', this.transformstart, this); + } + unbind(g: SprayPump): 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 sprayPump = target.getGraphic() as SprayPump; + sprayPump.getGraphicApp().setOptions({ + absorbablePositions: buildAbsorbablePositions(sprayPump), + }); + } +} diff --git a/src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePump.json b/src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePump.json new file mode 100644 index 0000000..b05230f --- /dev/null +++ b/src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePump.json @@ -0,0 +1,21 @@ +{ + "frames": { + "normal.png": { + "frame": { "x": 0, "y": 0, "w": 36, "h": 25 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 36, "h": 25 }, + "sourceSize": { "w": 27, "h": 26 }, + "anchor": { "x": 0.5, "y": 0.5 } + } + }, + "meta": { + "app": "https://www.codeandweb.com/texturepacker", + "version": "1.1", + "image": "StabilizedPressurePump.png", + "format": "RGBA8888", + "size": { "w": 36, "h": 25 }, + "scale": "1", + "smartupdate": "$TexturePacker:SmartUpdate:e7620bd2d73cc0b3e2deea9704e7eefc:f129a1d9e4b9ba57720b3861c22b155b:eb2d421f7759984b7713aa4aa5354134$" + } +} diff --git a/src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePump.png b/src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePump.png new file mode 100644 index 0000000000000000000000000000000000000000..b36ecb01cb534a49b9e3b482850f74f393f21779 GIT binary patch literal 1748 zcmV;_1}piAP)X0ssI2)`lCr00009a7bBm000XU z000XU0RWnu7ytkUhDk(0R7i0Bq-gG_u3ZEOy%f z=79ML+X(|IjwFGygGwvRZo&i^VCNHiS5q@#_`w}tx$?^07hm$hC;s%I zw>Fy&qX$V;(vbUopZ_o`&YTd5ac#Eo;tL1A{>6I!Z_7<#0r+2a#GD;202N?Gz*5|` zYwLyL)X3FCum0kP!{R~y-=k-d+9;Hfu^BuS&NaP`k0I&J3# z|GMO~Ku#S?fn};7dQ#Aab7qf*S@fGtrJ6AfEHX??EqHw;ra+md2}H~Ne_a^bcXq8T zUHb*wCCGi-&I{98mdv(@ajMCZx=W@2WcFPT?pb)p+dD|pE|LYjy6?bC*L-MM3Pg_) zCh9y-!aoCXAkEf>Acm#IO=oQ%PFQJ8n4ke>RJzju zRCGsLj1DLZK{86cSqT~hSSB?$Em;+`4Y8^W2j@0I5vZ!Qb?4Y-WgrcuK}5kMZ`iXc zfFC_QRhc~$W`=cj6j&jTn4Io0ey9Kb?=ko;lu6dIHqY- zBZv})sxEX|8!T8|I@bF}Q>CF9fOVjdnHfP<4J?zhwWB$1tar2qpvxj~tg0Zcug?xX z?{U^%p3O{=s5kALbV_v1>><56`fx+*<3J)|d#z^se{=sM&pbWW$g)@ft8%*f#u3ic z3EDKsBfXPR**T6h+Q#;CSNHw-YkO9Ibmv!Xn`Ppar~Y!vIp>cZ8#Q~QW-pB~Ld!z9 zB+W9$o46_k)A*XSrAa|j2}NxXu&L45{j(Jeb;{MtShd1 zUyV%dy!np3x8HPhwziV7B22PNnq->__6RhH0uT~b(Z(1V zgLO1>K5;0YeC0LGMF&|yOC_MH21+y6%*g7BVe323+I`RO{`k!s{{FzdgGrANv(RV& z$*w{PDnaRl2)keZ)EkeVyCSHqY(D9eSD*T&n_B~mLRG1oWiy1UfA-*`cYfpOQ%|~S zVLD{wurR&!w!1IA?RzqAxqi2dQ4*3BojuUtBtocB7I4`WpEK+Idk)z&qnKqhYle&p z!VSPc**}(); + } + + doRepaint(): void {} +} + +export class StabilizedPressurePumpTemplate extends JlGraphicTemplate { + stabilizedPressurePumpTextures?: StabilizedPressurePumpTextures; + constructor(dataTemplate: IStabilizedPressurePumpData) { + super(StabilizedPressurePump.Type, { dataTemplate }); + this.loadAssets(); + } + new(): StabilizedPressurePump { + if (this.stabilizedPressurePumpTextures) { + const g = new StabilizedPressurePump(this.stabilizedPressurePumpTextures); + g.loadData(this.datas); + return g; + } + throw new Error('资源未加载/加载失败'); + } + async loadAssets(): Promise { + const texture = await Assets.load(StabilizedPressurePumpAssets); + const stabilizedPressurePumpSheet = new Spritesheet( + texture, + StabilizedPressurePumpJson + ); + const result = await stabilizedPressurePumpSheet.parse(); + this.stabilizedPressurePumpTextures = { + normal: result['normal.png'], + }; + return this + .stabilizedPressurePumpTextures as StabilizedPressurePumpTextures; + } +} diff --git a/src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePumpAssistant.ts b/src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePumpAssistant.ts new file mode 100644 index 0000000..20fc1a7 --- /dev/null +++ b/src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePumpAssistant.ts @@ -0,0 +1,132 @@ +import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js'; +import { + AbsorbableLine, + AbsorbablePosition, + GraphicDrawAssistant, + GraphicInteractionPlugin, + GraphicTransformEvent, + IDrawApp, + JlGraphic, +} from 'jl-graphic'; +import { + StabilizedPressurePump, + IStabilizedPressurePumpData, + StabilizedPressurePumpTemplate, +} from './StabilizedPressurePump'; + +export class StabilizedPressurePumpDraw extends GraphicDrawAssistant< + StabilizedPressurePumpTemplate, + IStabilizedPressurePumpData +> { + _stabilizedPressurePump: StabilizedPressurePump | null = null; + constructor(app: IDrawApp, template: StabilizedPressurePumpTemplate) { + super( + app, + template, + 'svguse:../drawIcon.svg#icon-stabilized-pressure-pump', + '稳压泵' + ); + StabilizedPressurePumpInteraction.init(app); + } + + bind(): void { + super.bind(); + if (!this._stabilizedPressurePump) { + this._stabilizedPressurePump = this.graphicTemplate.new(); + this.container.addChild(this._stabilizedPressurePump); + } + } + + public get stabilizedPressurePump(): StabilizedPressurePump { + if (!this._stabilizedPressurePump) { + this._stabilizedPressurePump = this.graphicTemplate.new(); + this.container.addChild(this._stabilizedPressurePump); + } + return this._stabilizedPressurePump; + } + + redraw(cp: Point): void { + this.stabilizedPressurePump.position.copyFrom(cp); + } + onLeftUp(e: FederatedMouseEvent): void { + this.stabilizedPressurePump.position.copyFrom( + this.toCanvasCoordinates(e.global) + ); + this.createAndStore(true); + } + prepareData(data: IStabilizedPressurePumpData): boolean { + data.transform = this.stabilizedPressurePump.saveTransform(); + return true; + } + onEsc(): void { + this.finish(); + } +} + +/** + * 构建吸附线 + * @param stabilizedPressurePump + */ +function buildAbsorbablePositions( + stabilizedPressurePump: StabilizedPressurePump +): AbsorbablePosition[] { + const aps: AbsorbablePosition[] = []; + const stabilizedPressurePumps = + stabilizedPressurePump.queryStore.queryByType( + StabilizedPressurePump.Type + ); + const canvas = stabilizedPressurePump.getCanvas(); + stabilizedPressurePumps.forEach((item) => { + if (item.id === stabilizedPressurePump.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 StabilizedPressurePumpInteraction extends GraphicInteractionPlugin { + static Name = 'stabilized_pressure_pump_transform'; + constructor(app: IDrawApp) { + super(StabilizedPressurePumpInteraction.Name, app); + } + static init(app: IDrawApp) { + return new StabilizedPressurePumpInteraction(app); + } + filter(...grahpics: JlGraphic[]): StabilizedPressurePump[] | undefined { + return grahpics + .filter((g) => g.type === StabilizedPressurePump.Type) + .map((g) => g as StabilizedPressurePump); + } + bind(g: StabilizedPressurePump): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.rotatable = true; + g.on('transformstart', this.transformstart, this); + } + unbind(g: StabilizedPressurePump): 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 stabilizedPressurePump = + target.getGraphic() as StabilizedPressurePump; + stabilizedPressurePump.getGraphicApp().setOptions({ + absorbablePositions: buildAbsorbablePositions(stabilizedPressurePump), + }); + } +} diff --git a/src/layouts/IscsDrawLayout.vue b/src/layouts/IscsDrawLayout.vue index 26a5637..91ca8a9 100644 --- a/src/layouts/IscsDrawLayout.vue +++ b/src/layouts/IscsDrawLayout.vue @@ -314,6 +314,9 @@ 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'; +import { SprayPump } from 'src/graphics/FAS/sprayPump/SprayPump'; +import { StabilizedPressurePump } from 'src/graphics/FAS/stabilizedPressurePump/StabilizedPressurePump'; +import { Acs } from 'src/graphics/FAS/acs/Acs'; const $q = useQuasar(); const route = useRoute(); @@ -405,6 +408,9 @@ function handleUtilsOption() { drawAssistantsTypes.push(TemperatureDetector.Type); drawAssistantsTypes.push(FireShutter.Type); drawAssistantsTypes.push(FirePump.Type); + drawAssistantsTypes.push(SprayPump.Type); + drawAssistantsTypes.push(StabilizedPressurePump.Type); + drawAssistantsTypes.push(Acs.Type); break; } drawAssistantsTypes.forEach((type) => {