From 98b1db62901cc0914467b4cfd936d8b984f0b02c Mon Sep 17 00:00:00 2001 From: joylink_fanyuhong <18706759286@163.com> Date: Tue, 22 Oct 2024 17:16:24 +0800 Subject: [PATCH] =?UTF-8?q?=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 | 10 +- .../graphics/FAS/FasAlarmInteraction.ts | 8 +- .../FAS/FasFailureControlHostInteraction.ts | 8 +- .../graphics/FAS/FireShutterInteraction.ts | 44 ++++++ .../FAS/ManualAlarmButtonInteraction.ts | 8 +- .../graphics/FAS/SmokeDetectorInteraction.ts | 8 +- .../FAS/TemperatureDetectorInteraction.ts | 44 ++++++ src/drawApp/iscsApp.ts | 35 +++++ src/graphics/FAS/firePump/FirePump.json | 21 +++ src/graphics/FAS/firePump/FirePump.png | Bin 0 -> 1450 bytes src/graphics/FAS/firePump/FirePump.ts | 0 .../FAS/firePump/FirePumpAssistant.ts | 0 src/graphics/FAS/fireShutter/FireShutter.json | 21 +++ src/graphics/FAS/fireShutter/FireShutter.png | Bin 0 -> 988 bytes src/graphics/FAS/fireShutter/FireShutter.ts | 63 +++++++++ .../FAS/fireShutter/FireShutterAssistant.ts | 128 +++++++++++++++++ .../TemperatureDetector.json | 21 +++ .../TemperatureDetector.png | Bin 0 -> 644 bytes .../TemperatureDetector.ts | 66 +++++++++ .../TemperatureDetectorAssistant.ts | 131 ++++++++++++++++++ src/layouts/IscsDrawLayout.vue | 4 + 21 files changed, 603 insertions(+), 17 deletions(-) create mode 100644 src/drawApp/graphics/FAS/FireShutterInteraction.ts create mode 100644 src/drawApp/graphics/FAS/TemperatureDetectorInteraction.ts create mode 100644 src/graphics/FAS/firePump/FirePump.json create mode 100644 src/graphics/FAS/firePump/FirePump.png create mode 100644 src/graphics/FAS/firePump/FirePump.ts create mode 100644 src/graphics/FAS/firePump/FirePumpAssistant.ts create mode 100644 src/graphics/FAS/fireShutter/FireShutter.json create mode 100644 src/graphics/FAS/fireShutter/FireShutter.png create mode 100644 src/graphics/FAS/fireShutter/FireShutter.ts create mode 100644 src/graphics/FAS/fireShutter/FireShutterAssistant.ts create mode 100644 src/graphics/FAS/temperatureDetector/TemperatureDetector.json create mode 100644 src/graphics/FAS/temperatureDetector/TemperatureDetector.png create mode 100644 src/graphics/FAS/temperatureDetector/TemperatureDetector.ts create mode 100644 src/graphics/FAS/temperatureDetector/TemperatureDetectorAssistant.ts diff --git a/public/drawIcon.svg b/public/drawIcon.svg index 3a336c1..81078a9 100644 --- a/public/drawIcon.svg +++ b/public/drawIcon.svg @@ -108,6 +108,14 @@ - + + + + + + + + + diff --git a/src/drawApp/graphics/FAS/FasAlarmInteraction.ts b/src/drawApp/graphics/FAS/FasAlarmInteraction.ts index 171d2d9..747214b 100644 --- a/src/drawApp/graphics/FAS/FasAlarmInteraction.ts +++ b/src/drawApp/graphics/FAS/FasAlarmInteraction.ts @@ -5,15 +5,15 @@ import { iscsGraphicData } from 'src/protos/iscs_graphic_data'; export class FasAlarmData extends GraphicDataBase implements IFasAlarmData { constructor(data?: iscsGraphicData.FasAlarm) { - let cctvButton; + let fasAlarm; if (data) { - cctvButton = data; + fasAlarm = data; } else { - cctvButton = new iscsGraphicData.FasAlarm({ + fasAlarm = new iscsGraphicData.FasAlarm({ common: GraphicDataBase.defaultCommonInfo(FasAlarm.Type), }); } - super(cctvButton); + super(fasAlarm); } public get data(): iscsGraphicData.FasAlarm { diff --git a/src/drawApp/graphics/FAS/FasFailureControlHostInteraction.ts b/src/drawApp/graphics/FAS/FasFailureControlHostInteraction.ts index 1de14d3..346a00d 100644 --- a/src/drawApp/graphics/FAS/FasFailureControlHostInteraction.ts +++ b/src/drawApp/graphics/FAS/FasFailureControlHostInteraction.ts @@ -11,15 +11,15 @@ export class FasFailureControlHostData implements IFasFailureControlHostData { constructor(data?: iscsGraphicData.FasFailureControlHost) { - let cctvButton; + let fasFailureControlHost; if (data) { - cctvButton = data; + fasFailureControlHost = data; } else { - cctvButton = new iscsGraphicData.FasFailureControlHost({ + fasFailureControlHost = new iscsGraphicData.FasFailureControlHost({ common: GraphicDataBase.defaultCommonInfo(FasFailureControlHost.Type), }); } - super(cctvButton); + super(fasFailureControlHost); } public get data(): iscsGraphicData.FasFailureControlHost { diff --git a/src/drawApp/graphics/FAS/FireShutterInteraction.ts b/src/drawApp/graphics/FAS/FireShutterInteraction.ts new file mode 100644 index 0000000..5f4d172 --- /dev/null +++ b/src/drawApp/graphics/FAS/FireShutterInteraction.ts @@ -0,0 +1,44 @@ +import * as pb_1 from 'google-protobuf'; +import { GraphicDataBase } from '../GraphicDataBase'; +import { + FireShutter, + IFireShutterData, +} from 'src/graphics/FAS/fireShutter/FireShutter'; +import { iscsGraphicData } from 'src/protos/iscs_graphic_data'; + +export class FireShutterData + extends GraphicDataBase + implements IFireShutterData +{ + constructor(data?: iscsGraphicData.FireShutter) { + let fireShutter; + if (data) { + fireShutter = data; + } else { + fireShutter = new iscsGraphicData.FireShutter({ + common: GraphicDataBase.defaultCommonInfo(FireShutter.Type), + }); + } + super(fireShutter); + } + + public get data(): iscsGraphicData.FireShutter { + return this.getData(); + } + + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + clone(): FireShutterData { + return new FireShutterData(this.data.cloneMessage()); + } + copyFrom(data: FireShutterData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: FireShutterData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/graphics/FAS/ManualAlarmButtonInteraction.ts b/src/drawApp/graphics/FAS/ManualAlarmButtonInteraction.ts index 470a069..3aeed14 100644 --- a/src/drawApp/graphics/FAS/ManualAlarmButtonInteraction.ts +++ b/src/drawApp/graphics/FAS/ManualAlarmButtonInteraction.ts @@ -11,15 +11,15 @@ export class ManualAlarmButtonData implements IManualAlarmButtonData { constructor(data?: iscsGraphicData.ManualAlarmButton) { - let cctvButton; + let manualAlarmButton; if (data) { - cctvButton = data; + manualAlarmButton = data; } else { - cctvButton = new iscsGraphicData.ManualAlarmButton({ + manualAlarmButton = new iscsGraphicData.ManualAlarmButton({ common: GraphicDataBase.defaultCommonInfo(ManualAlarmButton.Type), }); } - super(cctvButton); + super(manualAlarmButton); } public get data(): iscsGraphicData.ManualAlarmButton { diff --git a/src/drawApp/graphics/FAS/SmokeDetectorInteraction.ts b/src/drawApp/graphics/FAS/SmokeDetectorInteraction.ts index 0deb9e8..60021b1 100644 --- a/src/drawApp/graphics/FAS/SmokeDetectorInteraction.ts +++ b/src/drawApp/graphics/FAS/SmokeDetectorInteraction.ts @@ -11,15 +11,15 @@ export class SmokeDetectorData implements ISmokeDetectorData { constructor(data?: iscsGraphicData.SmokeDetector) { - let cctvButton; + let smokeDetector; if (data) { - cctvButton = data; + smokeDetector = data; } else { - cctvButton = new iscsGraphicData.SmokeDetector({ + smokeDetector = new iscsGraphicData.SmokeDetector({ common: GraphicDataBase.defaultCommonInfo(SmokeDetector.Type), }); } - super(cctvButton); + super(smokeDetector); } public get data(): iscsGraphicData.SmokeDetector { diff --git a/src/drawApp/graphics/FAS/TemperatureDetectorInteraction.ts b/src/drawApp/graphics/FAS/TemperatureDetectorInteraction.ts new file mode 100644 index 0000000..a82a359 --- /dev/null +++ b/src/drawApp/graphics/FAS/TemperatureDetectorInteraction.ts @@ -0,0 +1,44 @@ +import * as pb_1 from 'google-protobuf'; +import { GraphicDataBase } from '../GraphicDataBase'; +import { + TemperatureDetector, + ITemperatureDetectorData, +} from 'src/graphics/FAS/temperatureDetector/TemperatureDetector'; +import { iscsGraphicData } from 'src/protos/iscs_graphic_data'; + +export class TemperatureDetectorData + extends GraphicDataBase + implements ITemperatureDetectorData +{ + constructor(data?: iscsGraphicData.TemperatureDetector) { + let cctvButton; + if (data) { + cctvButton = data; + } else { + cctvButton = new iscsGraphicData.TemperatureDetector({ + common: GraphicDataBase.defaultCommonInfo(TemperatureDetector.Type), + }); + } + super(cctvButton); + } + + public get data(): iscsGraphicData.TemperatureDetector { + return this.getData(); + } + + get code(): string { + return this.data.code; + } + set code(v: string) { + this.data.code = v; + } + clone(): TemperatureDetectorData { + return new TemperatureDetectorData(this.data.cloneMessage()); + } + copyFrom(data: TemperatureDetectorData): void { + pb_1.Message.copyInto(data.data, this.data); + } + eq(other: TemperatureDetectorData): boolean { + return pb_1.Message.equals(this.data, other.data); + } +} diff --git a/src/drawApp/iscsApp.ts b/src/drawApp/iscsApp.ts index 88db678..05a9dfe 100644 --- a/src/drawApp/iscsApp.ts +++ b/src/drawApp/iscsApp.ts @@ -47,6 +47,18 @@ import { } from 'src/graphics/FAS/smokeDetector/SmokeDetector'; import { SmokeDetectorData } from './graphics/FAS/SmokeDetectorInteraction'; import { SmokeDetectorDraw } from 'src/graphics/FAS/smokeDetector/SmokeDetectorAssistant'; +import { + TemperatureDetector, + TemperatureDetectorTemplate, +} from 'src/graphics/FAS/temperatureDetector/TemperatureDetector'; +import { TemperatureDetectorData } from './graphics/FAS/TemperatureDetectorInteraction'; +import { TemperatureDetectorDraw } from 'src/graphics/FAS/temperatureDetector/TemperatureDetectorAssistant'; +import { + FireShutter, + FireShutterTemplate, +} from 'src/graphics/FAS/fireShutter/FireShutter'; +import { FireShutterData } from './graphics/FAS/FireShutterInteraction'; +import { FireShutterDraw } from 'src/graphics/FAS/fireShutter/FireShutterAssistant'; // import { getOnlyToken } from 'src/configs/TokenManage'; let drawApp: IDrawApp | null = null; @@ -94,6 +106,11 @@ export function initIscsDrawApp(): IDrawApp { app, new SmokeDetectorTemplate(new SmokeDetectorData()) ); + new TemperatureDetectorDraw( + app, + new TemperatureDetectorTemplate(new TemperatureDetectorData()) + ); + new FireShutterDraw(app, new FireShutterTemplate(new FireShutterData())); app.addKeyboardListener( new KeyListener({ @@ -271,6 +288,14 @@ export async function loadDrawDatas(): Promise { fasOfPlatformAlarm.smokeDetectors.forEach((smokeDetector) => { datas.push(new SmokeDetectorData(smokeDetector)); }); + fasOfPlatformAlarm.temperatureDetectors.forEach( + (temperatureDetector) => { + datas.push(new TemperatureDetectorData(temperatureDetector)); + } + ); + fasOfPlatformAlarm.fireShutters.forEach((fireShutter) => { + datas.push(new FireShutterData(fireShutter)); + }); break; } } @@ -375,6 +400,16 @@ export function saveDrawDatas(app: IDrawApp) { fasStorage.smokeDetectors.push( (smokeDetectorData as SmokeDetectorData).data ); + } else if (g instanceof TemperatureDetector) { + const temperatureDetectorData = g.saveData(); + fasStorage.temperatureDetectors.push( + (temperatureDetectorData as TemperatureDetectorData).data + ); + } else if (g instanceof FireShutter) { + const fireShutterData = g.saveData(); + fasStorage.fireShutters.push( + (fireShutterData as FireShutterData).data + ); } }); storage.fasOfPlatformAlarmStorages[i] = fasStorage; diff --git a/src/graphics/FAS/firePump/FirePump.json b/src/graphics/FAS/firePump/FirePump.json new file mode 100644 index 0000000..4907c62 --- /dev/null +++ b/src/graphics/FAS/firePump/FirePump.json @@ -0,0 +1,21 @@ +{ + "frames": { + "normal.png": { + "frame": { "x": 0, "y": 0, "w": 23, "h": 34 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 23, "h": 34 }, + "sourceSize": { "w": 23, "h": 34 }, + "anchor": { "x": 0.5, "y": 0.5 } + } + }, + "meta": { + "app": "https://www.codeandweb.com/texturepacker", + "version": "1.1", + "image": "FirePump.png", + "format": "RGBA8888", + "size": { "w": 23, "h": 34 }, + "scale": "1", + "smartupdate": "$TexturePacker:SmartUpdate:e7620bd2d73cc0b3e2deea9704e7eefc:f129a1d9e4b9ba57720b3861c22b155b:eb2d421f7759984b7713aa4aa5354134$" + } +} diff --git a/src/graphics/FAS/firePump/FirePump.png b/src/graphics/FAS/firePump/FirePump.png new file mode 100644 index 0000000000000000000000000000000000000000..1b0d0bc840efbc95e0fb365a775d8fa1eacd56a1 GIT binary patch literal 1450 zcmV;b1y%ZqP)j!=1S+j&pr2d&OK*@3v9j7)EgqKp;!?tU__uOz*;Z{1yH32JXYoR3f9DaACYAl&#fh| zVk7SvsFGhG?-U%E=vn=0m6;Qv)9amFE8we`ul#?)wQ>)XfUVpBzAC6U23N()>Rvq$ zx(I%tI+3OV9zRIEr!hB&&vUXYqY$A0#+B~5PUENGD^bLP2vU~JiV#)ZQWK$}iU(q2 z7>kgqo&b!Q>WyjmytP=sosr1{r3k~p0F1$l;HrC$Wwe)(<+w-yVlA%Q#aD-e3RG5L z6UX=@fwH`u<|n2~IU3P?;|=E4*O7i7Tj`pFA;Yrd+5P))Z~#$sA>zNnU6wKX)?2*v z_S=kicTcjjL4YhQ@Xx(Hc<|r_;7q#39Ue0H!!#VeFvSfn+<6e*Wh2X{zBng8LK49?Shs4eiR&V2t zAuS4Qs|Ah5<>6L@fJv*_IHu8R5qhElaRt+kV)I)^xi zcn@U>!y#X{fgW|c^!hykkjn?HGzq9~Dj_wMQD<|cRU+~L-(TLN&)SY7sRQphtB z00^gxqmXEKAI1+n-Ss1#uj+v9X~5e~co$F-Vdi^*TY4 z5G4tzG=NePj7N9m(pIRsHeJo9ylFvAw-bFdPoq-`^(;Lw@$oJ3M^& zklk@AJ2ueO(TLia?2n7)&SX6T{?MF(L7!j#;^(}yxJawjVlWsGSZj%*2x~1t81n1) z-qV?-C1h`pIp+{-@!sRSN2_)d5sWd2D$W?b9Yr)=ep#221O~8;h)$!1BIvw`+_fHBNRhy;X?=v2cdH(!4hlhv6ag3^x=lO|e zSw<8^wA*c3trk%farNp|(ljMFIy&O< z?hAvD?R($(uKw^xH%_~yEK9moh5ujc^?DRVK~WU^3mNgeO`HSs`Tzg`07*qoM6N<$ Ef@-GHkN^Mx literal 0 HcmV?d00001 diff --git a/src/graphics/FAS/firePump/FirePump.ts b/src/graphics/FAS/firePump/FirePump.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/graphics/FAS/firePump/FirePumpAssistant.ts b/src/graphics/FAS/firePump/FirePumpAssistant.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/graphics/FAS/fireShutter/FireShutter.json b/src/graphics/FAS/fireShutter/FireShutter.json new file mode 100644 index 0000000..c39d0da --- /dev/null +++ b/src/graphics/FAS/fireShutter/FireShutter.json @@ -0,0 +1,21 @@ +{ + "frames": { + "normal.png": { + "frame": { "x": 0, "y": 0, "w": 33, "h": 33 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 33, "h": 33 }, + "sourceSize": { "w": 33, "h": 33 }, + "anchor": { "x": 0.5, "y": 0.5 } + } + }, + "meta": { + "app": "https://www.codeandweb.com/texturepacker", + "version": "1.1", + "image": "FireShutter.png", + "format": "RGBA8888", + "size": { "w": 33, "h": 33 }, + "scale": "1", + "smartupdate": "$TexturePacker:SmartUpdate:e7620bd2d73cc0b3e2deea9704e7eefc:f129a1d9e4b9ba57720b3861c22b155b:eb2d421f7759984b7713aa4aa5354134$" + } +} diff --git a/src/graphics/FAS/fireShutter/FireShutter.png b/src/graphics/FAS/fireShutter/FireShutter.png new file mode 100644 index 0000000000000000000000000000000000000000..8fca74f887a0be0e8fdcbf61861da88cfcf52ba1 GIT binary patch literal 988 zcmV<210(#2P)+(*4M)A$(6K32(aud#nc|?**^V%2)~@OLWd=s<^0C-a zDofgA$;t7eq*y_A0>ygK|IInP@AL8F{GSJo(AU?e7z_s1N^^5_ND~tiu#Q(+-{joI9zw!2d0Ui> z0a~=j0g%!M!JjfKB1itj;~wXWoru@0QAkCKQd$k~vss!n8N=_zz~cPoHuJLWwC&GiTP?w2zZER=EiGcTeb z^3W66>CCjG zdI&iNN)l`jJGeajBRK~6b;b+8v~Qe_7v9EcZ{m}0-p?39)nLj|*kAt~k2f^Z{`vt< z9Q%-(^4)CI6#%fW*}=yr&!H#^Gvl))Ln?>-pM&}Jd-MMqt0)Seo_?37pK2lG*Whwp z#crPqCXU|?Bl}Z6H zI5>nhUr#I+2f${tpeUKGyXu(;-29E|>PiX>My%GIh~iReGMU6XBI!ZqMFAlLMPK8;Qpvw6-=c-?gQAg zO^tY`MpXf*hFDyPpx5WGIJkx1b6`T)@Bv@9-0X=tcheF#w$k!2Zxv9W0Y z3$=#?!0GArU39i`O#g6NNXJ;t#ydBq!ITJ0QHWS{`2PP-hTm*={y^bV;7qM0000< KMNUMnLSTZe@yWLU literal 0 HcmV?d00001 diff --git a/src/graphics/FAS/fireShutter/FireShutter.ts b/src/graphics/FAS/fireShutter/FireShutter.ts new file mode 100644 index 0000000..1f5104a --- /dev/null +++ b/src/graphics/FAS/fireShutter/FireShutter.ts @@ -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 FireShutterJson from './fireShutter.json'; +import FireShutterAssets from './fireShutter.png'; + +export interface IFireShutterData extends GraphicData { + get code(): string; + set code(v: string); +} + +interface FireShutterTextures { + normal: Texture; +} + +export class FireShutter extends JlGraphic { + static Type = 'FireShutter'; + _fireShutter: Sprite; + fireShutterTextures: FireShutterTextures; + __state = 0; + + constructor(fireShutterTextures: FireShutterTextures) { + super(FireShutter.Type); + this._fireShutter = new Sprite(); + this.fireShutterTextures = fireShutterTextures; + this._fireShutter.anchor.set(0.5); + this.addChild(this._fireShutter); + this._fireShutter.texture = this.fireShutterTextures.normal; + } + get code(): string { + return this.datas.code; + } + get datas(): IFireShutterData { + return this.getDatas(); + } + + doRepaint(): void {} +} + +export class FireShutterTemplate extends JlGraphicTemplate { + fireShutterTextures?: FireShutterTextures; + constructor(dataTemplate: IFireShutterData) { + super(FireShutter.Type, { dataTemplate }); + this.loadAssets(); + } + new(): FireShutter { + if (this.fireShutterTextures) { + const g = new FireShutter(this.fireShutterTextures); + g.loadData(this.datas); + return g; + } + throw new Error('资源未加载/加载失败'); + } + async loadAssets(): Promise { + const texture = await Assets.load(FireShutterAssets); + const fireShutterSheet = new Spritesheet(texture, FireShutterJson); + const result = await fireShutterSheet.parse(); + this.fireShutterTextures = { + normal: result['normal.png'], + }; + return this.fireShutterTextures as FireShutterTextures; + } +} diff --git a/src/graphics/FAS/fireShutter/FireShutterAssistant.ts b/src/graphics/FAS/fireShutter/FireShutterAssistant.ts new file mode 100644 index 0000000..dc4c3b2 --- /dev/null +++ b/src/graphics/FAS/fireShutter/FireShutterAssistant.ts @@ -0,0 +1,128 @@ +import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js'; +import { + AbsorbableLine, + AbsorbablePosition, + GraphicDrawAssistant, + GraphicInteractionPlugin, + GraphicTransformEvent, + IDrawApp, + JlGraphic, +} from 'jl-graphic'; +import { + IFireShutterData, + FireShutter, + FireShutterTemplate, +} from './FireShutter'; + +export class FireShutterDraw extends GraphicDrawAssistant< + FireShutterTemplate, + IFireShutterData +> { + _fireShutter: FireShutter | null = null; + constructor(app: IDrawApp, template: FireShutterTemplate) { + super( + app, + template, + 'svguse:../drawIcon.svg#icon-fire-shutter', + '防火卷帘' + ); + FireShutterInteraction.init(app); + } + + bind(): void { + super.bind(); + if (!this._fireShutter) { + this._fireShutter = this.graphicTemplate.new(); + this.container.addChild(this._fireShutter); + } + } + + public get fireShutter(): FireShutter { + if (!this._fireShutter) { + this._fireShutter = this.graphicTemplate.new(); + this.container.addChild(this._fireShutter); + } + return this._fireShutter; + } + + redraw(cp: Point): void { + this.fireShutter.position.copyFrom(cp); + } + onLeftUp(e: FederatedMouseEvent): void { + this.fireShutter.position.copyFrom(this.toCanvasCoordinates(e.global)); + this.createAndStore(true); + } + prepareData(data: IFireShutterData): boolean { + data.transform = this.fireShutter.saveTransform(); + return true; + } + onEsc(): void { + this.finish(); + } +} + +/** + * 构建吸附线 + * @param fireShutter + */ +function buildAbsorbablePositions( + fireShutter: FireShutter +): AbsorbablePosition[] { + const aps: AbsorbablePosition[] = []; + const fireShutters = fireShutter.queryStore.queryByType( + FireShutter.Type + ); + const canvas = fireShutter.getCanvas(); + fireShutters.forEach((item) => { + if (item.id === fireShutter.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 FireShutterInteraction extends GraphicInteractionPlugin { + static Name = 'fas_alarm_transform'; + constructor(app: IDrawApp) { + super(FireShutterInteraction.Name, app); + } + static init(app: IDrawApp) { + return new FireShutterInteraction(app); + } + filter(...grahpics: JlGraphic[]): FireShutter[] | undefined { + return grahpics + .filter((g) => g.type === FireShutter.Type) + .map((g) => g as FireShutter); + } + bind(g: FireShutter): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.rotatable = true; + g.on('transformstart', this.transformstart, this); + } + unbind(g: FireShutter): 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 fireShutter = target.getGraphic() as FireShutter; + fireShutter.getGraphicApp().setOptions({ + absorbablePositions: buildAbsorbablePositions(fireShutter), + }); + } +} diff --git a/src/graphics/FAS/temperatureDetector/TemperatureDetector.json b/src/graphics/FAS/temperatureDetector/TemperatureDetector.json new file mode 100644 index 0000000..47369d4 --- /dev/null +++ b/src/graphics/FAS/temperatureDetector/TemperatureDetector.json @@ -0,0 +1,21 @@ +{ + "frames": { + "normal.png": { + "frame": { "x": 0, "y": 0, "w": 21, "h": 11 }, + "rotated": false, + "trimmed": false, + "spriteSourceSize": { "x": 0, "y": 0, "w": 21, "h": 11 }, + "sourceSize": { "w": 21, "h": 11 }, + "anchor": { "x": 0.5, "y": 0.5 } + } + }, + "meta": { + "app": "https://www.codeandweb.com/texturepacker", + "version": "1.1", + "image": "TemperatureDetector.png", + "format": "RGBA8888", + "size": { "w": 21, "h": 11 }, + "scale": "1", + "smartupdate": "$TexturePacker:SmartUpdate:e7620bd2d73cc0b3e2deea9704e7eefc:f129a1d9e4b9ba57720b3861c22b155b:eb2d421f7759984b7713aa4aa5354134$" + } +} diff --git a/src/graphics/FAS/temperatureDetector/TemperatureDetector.png b/src/graphics/FAS/temperatureDetector/TemperatureDetector.png new file mode 100644 index 0000000000000000000000000000000000000000..a3e24cf5be0ebf5f8c1b7f40b3b46dddf90d8d91 GIT binary patch literal 644 zcmV-~0((3v>sCIkZw9w_uc`?cTuJPzs)xQ2^Y7mwH7 zswu}o!i$FmV*?6k1Ztq(!1jp%P*4#IjHN9q6ZC>v;v_jNmXkDVZ5=v z^`-wcm@Ln1e6DS5`fZSX7khOyF#;tFsOm^kMU^mW6>8xFVXD8|wAJDqRdsoJ`PI_P z58qx#=}yAA*haQ*oVuQgOcEMdD^_hByO^y+ugjEAoji2u=AB!!^D|UY5DMITe12v4 zZ92q0mv7icyNxhm^YQSm{kiMoLWUU$w|_V4HB5F+y?FFq4Fxa&1WMrI_}%z01V^{3uD)$p6HzW*v~Y(Yqp#I z)y-~q(#>eqNv_pC^C{ZJ?C9m

BEm&`?wfs4B_z+SH#)~wOETK%>=>tm-Euv( zCf?i*0R8|dYY=S(); + } + + doRepaint(): void {} +} + +export class TemperatureDetectorTemplate extends JlGraphicTemplate { + temperatureDetectorTextures?: TemperatureDetectorTextures; + constructor(dataTemplate: ITemperatureDetectorData) { + super(TemperatureDetector.Type, { dataTemplate }); + this.loadAssets(); + } + new(): TemperatureDetector { + if (this.temperatureDetectorTextures) { + const g = new TemperatureDetector(this.temperatureDetectorTextures); + g.loadData(this.datas); + return g; + } + throw new Error('资源未加载/加载失败'); + } + async loadAssets(): Promise { + const texture = await Assets.load(TemperatureDetectorAsset); + const temperatureDetectorSheet = new Spritesheet( + texture, + TemperatureDetectorJson + ); + const result = await temperatureDetectorSheet.parse(); + this.temperatureDetectorTextures = { + normal: result['normal.png'], + }; + return this.temperatureDetectorTextures as TemperatureDetectorTextures; + } +} diff --git a/src/graphics/FAS/temperatureDetector/TemperatureDetectorAssistant.ts b/src/graphics/FAS/temperatureDetector/TemperatureDetectorAssistant.ts new file mode 100644 index 0000000..16eb0d2 --- /dev/null +++ b/src/graphics/FAS/temperatureDetector/TemperatureDetectorAssistant.ts @@ -0,0 +1,131 @@ +import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js'; +import { + AbsorbableLine, + AbsorbablePosition, + GraphicDrawAssistant, + GraphicInteractionPlugin, + GraphicTransformEvent, + IDrawApp, + JlGraphic, +} from 'jl-graphic'; +import { + ITemperatureDetectorData, + TemperatureDetector, + TemperatureDetectorTemplate, +} from './TemperatureDetector'; + +export class TemperatureDetectorDraw extends GraphicDrawAssistant< + TemperatureDetectorTemplate, + ITemperatureDetectorData +> { + _temperatureDetector: TemperatureDetector | null = null; + constructor(app: IDrawApp, template: TemperatureDetectorTemplate) { + super( + app, + template, + 'svguse:../drawIcon.svg#icon-temperature-detector', + '温感' + ); + TemperatureDetectorInteraction.init(app); + } + + bind(): void { + super.bind(); + if (!this._temperatureDetector) { + this._temperatureDetector = this.graphicTemplate.new(); + this.container.addChild(this._temperatureDetector); + } + } + + public get temperatureDetector(): TemperatureDetector { + if (!this._temperatureDetector) { + this._temperatureDetector = this.graphicTemplate.new(); + this.container.addChild(this._temperatureDetector); + } + return this._temperatureDetector; + } + + redraw(cp: Point): void { + this.temperatureDetector.position.copyFrom(cp); + } + onLeftUp(e: FederatedMouseEvent): void { + this.temperatureDetector.position.copyFrom( + this.toCanvasCoordinates(e.global) + ); + this.createAndStore(true); + } + prepareData(data: ITemperatureDetectorData): boolean { + data.transform = this.temperatureDetector.saveTransform(); + return true; + } + onEsc(): void { + this.finish(); + } +} + +/** + * 构建吸附线 + * @param temperatureDetector + */ +function buildAbsorbablePositions( + temperatureDetector: TemperatureDetector +): AbsorbablePosition[] { + const aps: AbsorbablePosition[] = []; + const temperatureDetectors = + temperatureDetector.queryStore.queryByType( + TemperatureDetector.Type + ); + const canvas = temperatureDetector.getCanvas(); + temperatureDetectors.forEach((item) => { + if (item.id === temperatureDetector.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 TemperatureDetectorInteraction extends GraphicInteractionPlugin { + static Name = 'temperature_detector_transform'; + constructor(app: IDrawApp) { + super(TemperatureDetectorInteraction.Name, app); + } + static init(app: IDrawApp) { + return new TemperatureDetectorInteraction(app); + } + filter(...grahpics: JlGraphic[]): TemperatureDetector[] | undefined { + return grahpics + .filter((g) => g.type === TemperatureDetector.Type) + .map((g) => g as TemperatureDetector); + } + bind(g: TemperatureDetector): void { + g.eventMode = 'static'; + g.cursor = 'pointer'; + g.scalable = true; + g.rotatable = true; + g.on('transformstart', this.transformstart, this); + } + unbind(g: TemperatureDetector): 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 temperatureDetector = target.getGraphic() as TemperatureDetector; + temperatureDetector.getGraphicApp().setOptions({ + absorbablePositions: buildAbsorbablePositions(temperatureDetector), + }); + } +} diff --git a/src/layouts/IscsDrawLayout.vue b/src/layouts/IscsDrawLayout.vue index 331613f..777803a 100644 --- a/src/layouts/IscsDrawLayout.vue +++ b/src/layouts/IscsDrawLayout.vue @@ -310,6 +310,8 @@ import { FasFailureControlHost } from 'src/graphics/FAS/fireFailureControlHost/F import { FasAlarm } from 'src/graphics/FAS/fasAlarm/FasAlarm'; import { ManualAlarmButton } from 'src/graphics/FAS/manualAlarmButton/ManualAlarmButton'; import { SmokeDetector } from 'src/graphics/FAS/smokeDetector/SmokeDetector'; +import { TemperatureDetector } from 'src/graphics/FAS/temperatureDetector/TemperatureDetector'; +import { FireShutter } from 'src/graphics/FAS/fireShutter/FireShutter'; const $q = useQuasar(); const route = useRoute(); @@ -398,6 +400,8 @@ function handleUtilsOption() { drawAssistantsTypes.push(FasAlarm.Type); drawAssistantsTypes.push(ManualAlarmButton.Type); drawAssistantsTypes.push(SmokeDetector.Type); + drawAssistantsTypes.push(TemperatureDetector.Type); + drawAssistantsTypes.push(FireShutter.Type); break; } drawAssistantsTypes.forEach((type) => {