代码提交

This commit is contained in:
joylink_fanyuhong 2024-11-08 09:52:43 +08:00
parent 23ed471da1
commit f4812c7187
12 changed files with 832 additions and 0 deletions

View File

@ -173,4 +173,15 @@
<symbol id="icon-electric-butterfly-valve" width="24" height="24" viewBox="0 0 1024 1024">
<path d="M556.19 447.53v-87.35c60.65-19.14 104.68-76.47 104.68-144.21 0-83.41-66.74-151.02-149.07-151.02s-149.07 67.61-149.07 151.02c0 67.75 44.03 125.08 104.68 144.21v87.35H65.16v510.71h893.28V447.53H556.19zM452.1 224.37a18.004 18.004 0 0 0-21.86 0l-25.06 19.3c-8.54 5.88-20.21 3.94-26.37-4.4-6.24-8.35-4.97-20.21 2.9-26.99l25.08-19.32c20.25-15.54 48.42-15.54 68.68 0l19.39 14.8a17.988 17.988 0 0 0 21.83 0l19.39-14.8c20.26-15.55 48.44-15.55 68.7 0l19.38 14.8c2.41 1.83 5.17 3.65 8.01 4.12v0.12c9.47 1.09 16.62 9.12 16.6 18.65 0.02 9.54-7.13 17.57-16.6 18.65v0.12c-0.34-0.01-0.67-0.03-1-0.05-0.36 0.02-0.72 0.05-1.08 0.05-1.5 0-2.96-0.2-4.36-0.53-9.23-1.18-18.01-4.18-25.52-9.95l-18.88-14.57a17.945 17.945 0 0 0-21.84 0l-19.39 14.78c-20.25 15.56-48.43 15.56-68.67 0l-19.33-14.78z m346.07 545.4c-3.99 15.14-19.3 24.13-34.19 20.07l-169.9-46.29c-16.83 30-48.47 50.26-84.8 50.26-53.96 0-97.71-44.59-97.71-99.59 0-0.13 0.02-0.26 0.02-0.38l-186.9-50.92c-14.89-4.06-23.73-19.62-19.73-34.76 3.99-15.14 19.29-24.13 34.18-20.07l188.57 51.37c17.48-26.99 47.46-44.82 81.57-44.82 51.97 0 94.35 41.39 97.41 93.59l171.74 46.78c14.89 4.06 23.74 19.63 19.74 34.76z" p-id="6936"></path>
</symbol>
<symbol id="icon-fire-valve" width="24" height="24" viewBox="0 0 1024 1024">
<path d="M512 1024c282.784 0 512-229.216 512-512S794.784 0 512 0 0 229.216 0 512s229.216 512 512 512zM279.104 337.664a16 16 0 0 1 11.328 4.672L512 563.904 290.432 785.472a16 16 0 0 1-27.328-11.296V353.664a16 16 0 0 1 16-16z m465.792 0a16 16 0 0 1 15.744 13.12l0.256 2.88v420.48a16 16 0 0 1-25.12 13.184l-2.208-1.856L512 563.904l221.568-221.568a16 16 0 0 1 11.328-4.672z m-517.344 12.928v426.656H192V350.592h35.552z m604.448 0v426.656h-35.552V350.592H832zM512 172.8a142.208 142.208 0 1 1 0 284.448 142.208 142.208 0 0 1 0-284.448z m-31.872 62.208h-28.48v144h16.48V251.52c-0.512-4-0.512-4-0.64-7.008l-0.128-2.752h0.768c0.736 3.776 0.736 3.776 2.24 9.76 0.512 3.52 0.512 3.52 0.992 6.016l0.512 2.24 30.752 119.232h18.752l29.984-117.76c3.008-9.728 3.008-9.728 4.512-19.488 0.576 3.392 0.576 3.392 0.288 8.864l-0.288 3.904v124.48h16.512v-144h-28.48L515.36 347.52l-0.928 4.704-1.28 6.56c-0.768 5.984-0.768 5.984-1.536 9.728-0.576-10.784-0.576-10.784-2.144-17.76l-0.832-3.2-28.512-112.544z" p-id="8137"></path>
</symbol>
<symbol id="icon-electric-fire-extinguishing-valve" width="24" height="24" viewBox="0 0 1024 1024">
<path d="M136 368v592h752V368H136z m236-64v-24H288a16 16 0 0 1-16-16V16a16 16 0 0 1 16-16h448a16 16 0 0 1 16 16v248a16 16 0 0 1-16 16h-84v24h284a16 16 0 0 1 16 16v688a16 16 0 0 1-16 16H88a16 16 0 0 1-16-16V320a16 16 0 0 1 16-16h284z m-36-240v152h352V64H336z" fill="#4C4C4C" p-id="5319"></path>
<path d="M542.112 76l-27.768 54.132L556 142.392l-79.296 58.72 31.024-48.504L468 139.94 542.112 76z m143.728 833.408c-82.312-51.088-123.696-104.252-123.696-160.22V672.8a15.04 15.04 0 0 1 13.92-14.992c0.388-0.032 1.42-0.16 2.72-0.356a134.84 134.84 0 0 0 10.116-1.976c12.156-2.812 25.912-7.264 40.92-13.36 10.256-4.16 29.356-14.2 56.492-29.704a14.84 14.84 0 0 1 7.772-1.98 14.976 14.976 0 0 1 7.892 1.98c27.132 15.504 46.232 25.54 56.492 29.704 15.008 6.096 28.76 10.548 40.92 13.36a134.84 134.84 0 0 0 10.116 1.976c1.296 0.2 2.328 0.324 2.72 0.356a15.04 15.04 0 0 1 13.92 14.992v76.388c0 55.968-41.388 109.132-123.7 160.22a14.976 14.976 0 0 1-8.3 2.26 14.976 14.976 0 0 1-8.304-2.26z m110.228-160.22v-63.64c-1.124-0.24-2.28-0.5-3.456-0.772-13.72-3.172-28.98-8.104-45.46-14.796-10.752-4.364-28.228-13.412-53.008-27.428-24.78 14.016-42.256 23.064-53.012 27.428-16.48 6.692-31.74 11.624-45.46 14.8-1.176 0.268-2.328 0.524-3.456 0.764v63.64c0 42.56 33.852 86.12 101.928 129.9 68.072-43.78 101.924-87.336 101.924-129.896z m-76.408-38.792a10.472 10.472 0 0 1 9.8-1.68 9.828 9.828 0 0 1 6.688 7.916l0.176 1.24c1.168 9.1 3.352 14.488 12.708 26.476l6.576 8.42h-1.152a45.024 45.024 0 0 1 4.624 28.012c-0.456 2.848-1.1 5.22-1.652 6.696-8.28 27.06-28.196 40.888-58.712 42.152-12.976 0-26.1-3.76-38.996-11.112-18.636-12.008-27.056-29.36-27.824-49.48-0.264-6.96 0.42-13.776 1.756-20.188 0.816-3.928 1.756-7.124 2.42-8.888 1.556-3.788 5.24-6.26 9.48-6.264 4.088 0.112 7.708 2.304 9.32 5.952 0.416 0.94 0.9 1.928 1.44 2.932-0.124-8.56 0.828-16.76 3.104-24.352 5.056-16.848 16.292-29.152 34.484-35.168a10.484 10.484 0 0 1 9.236 1.368 9.64 9.64 0 0 1 4.096 8.828l-0.188 1.876c-0.9 9.556-0.468 18.48 2.248 27.852 2.388-4.668 5.752-8.848 10.368-12.588z m-20.872 99.696a48.412 48.412 0 0 0 25.26-7.28l0.544-0.44a47.06 47.06 0 0 0 7.036-7.4c4.08-5.364 6.76-11.296 7.46-17.532 0.724-8.624-0.536-14.008-6.268-21.364a119.844 119.844 0 0 1-8.2-11.744 175.112 175.112 0 0 0-0.188 9.28v1.348a9.824 9.824 0 0 1-7.272 9.248c-4.1 1.144-8.584-0.3-11.104-3.68-11.688-15.712-18.104-32.388-19.392-50.54-11.332 11.82-12.46 32.104-7.216 54.72l0.176 0.776a9.536 9.536 0 0 1-2.864 9.06 10.464 10.464 0 0 1-8.82 2.612c-5.888-1.016-11.204-3.836-15.992-8.008 0.684 14.304 6.78 25.144 18.336 32.692 9.644 5.492 19.24 8.252 28.504 8.252z m-371.088-79.108C245.384 679.896 204 626.732 204 570.76v-76.384a15.04 15.04 0 0 1 13.92-15c0.388-0.024 1.42-0.152 2.72-0.348a134.84 134.84 0 0 0 10.116-1.98c12.16-2.808 25.912-7.264 40.92-13.36 10.256-4.16 29.36-14.2 56.492-29.704a14.84 14.84 0 0 1 7.772-1.976 14.976 14.976 0 0 1 7.892 1.976c27.136 15.508 46.236 25.544 56.492 29.708 15.008 6.092 28.76 10.548 40.92 13.36a134.84 134.84 0 0 0 10.12 1.976c1.296 0.196 2.328 0.32 2.712 0.352a15.04 15.04 0 0 1 13.924 14.996v76.384c0 55.972-41.384 109.136-123.7 160.224a14.976 14.976 0 0 1-8.3 2.256 14.976 14.976 0 0 1-8.3-2.256z m110.228-160.224v-63.64c-1.128-0.24-2.28-0.496-3.46-0.768-13.72-3.172-28.98-8.104-45.456-14.8-10.76-4.36-28.232-13.412-53.012-27.428-24.78 14.016-42.256 23.064-53.012 27.432-16.48 6.692-31.74 11.624-45.456 14.796-1.18 0.272-2.332 0.528-3.46 0.768v63.64c0 42.56 33.852 86.116 101.928 129.896 68.076-43.78 101.928-87.336 101.928-129.896z m-168.98-57.188a11.072 11.072 0 0 1 11.072 11.072l-0.004 34.532c-0.14 3.776-0.064 3.88 2.428 4.256 15.148 2.252 24.536 12.06 24.536 24.888v35.88a11.072 11.072 0 1 1-22.14 0v-35.88c0-1.38-1.096-2.312-5.652-2.988-13.88-2.064-21.8-12.08-21.312-26.432v-34.256a11.072 11.072 0 0 1 11.072-11.072z m38.424 11.072a11.072 11.072 0 0 1 22.14 0v34.336c-0.14 3.72-0.084 3.8 2.376 4.168 15.108 2.24 24.472 12.024 24.472 24.808v35.68a11.072 11.072 0 1 1-22.14 0v-35.68c0-1.328-1.068-2.24-5.584-2.908-13.84-2.056-21.756-12.04-21.264-26.344v-34.06z m49.496 0a11.072 11.072 0 0 1 22.14 0v34.336c-0.14 3.72-0.084 3.8 2.376 4.168 15.104 2.24 24.472 12.024 24.472 24.808v35.68a11.072 11.072 0 1 1-22.14 0v-35.68c0-1.328-1.072-2.24-5.584-2.908-13.84-2.056-21.756-12.04-21.264-26.344v-34.06z m2.888 357.648a16 16 0 0 1-25.668-19.112l310.56-417.08a16 16 0 1 1 25.668 19.116l-310.56 417.076z" fill="#4C4C4C" p-id="5320"></path>
</symbol>
<symbol id="icon-fire-intercommunication-signal" width="40" height="24" viewBox="0 0 40 24" fill="none">
<rect width="40" height="24" fill="#D9D9D9"/>
<path d="M8.87216 17L10.5426 6.81818H11.5369L9.86648 17H8.87216ZM4.23864 14.1761L4.39773 13.1818H11.9943L11.8352 14.1761H4.23864ZM5.29261 17L6.96307 6.81818H7.95739L6.28693 17H5.29261ZM4.83523 10.6364L4.99432 9.64205H12.5909L12.4318 10.6364H4.83523Z" fill="white"/>
</symbol>
</svg>

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View File

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

View File

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

View File

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

View File

@ -152,6 +152,24 @@ import {
ElectricButterflyValveTemplate,
} from 'src/graphics/FAS/electricButterflyValve/ElectricButterflyValve';
import { ElectricButterflyValveData } from './graphics/FAS/ElectricButterflyValveInteraction';
import { FireValveDraw } from 'src/graphics/FAS/fireValve/FireValveAssistant';
import {
FireValve,
FireValveTemplate,
} from 'src/graphics/FAS/fireValve/FireValve';
import { FireValveData } from './graphics/FAS/FireValveInteraction';
import { ElectricFireExtinguishingValveData } from './graphics/FAS/ElectricFireExtinguishingValveInteraction';
import { ElectricFireExtinguishingValveDraw } from 'src/graphics/FAS/electricFireExtinguishingValve/ElectricFireExtinguishingValveAssistant';
import {
ElectricFireExtinguishingValve,
ElectricFireExtinguishingValveTemplate,
} from 'src/graphics/FAS/electricFireExtinguishingValve/ElectricFireExtinguishingValve';
import { FireIntercommunicationSignalData } from './graphics/FAS/FireIntercommunicationSignalInteraction';
import { FireIntercommunicationSignalDraw } from 'src/graphics/FAS/fireIntercommunicationSignal/FireIntercommunicationSignalAssistant';
import {
FireIntercommunicationSignal,
FireIntercommunicationSignalTemplate,
} from 'src/graphics/FAS/fireIntercommunicationSignal/FireIntercommunicationSignal';
// import { getOnlyToken } from 'src/configs/TokenManage';
let drawApp: IDrawApp | null = null;
@ -254,6 +272,19 @@ export function initIscsDrawApp(): IDrawApp {
app,
new ElectricButterflyValveTemplate(new ElectricButterflyValveData())
);
new FireValveDraw(app, new FireValveTemplate(new FireValveData()));
new ElectricFireExtinguishingValveDraw(
app,
new ElectricFireExtinguishingValveTemplate(
new ElectricFireExtinguishingValveData()
)
);
new FireIntercommunicationSignalDraw(
app,
new FireIntercommunicationSignalTemplate(
new FireIntercommunicationSignalData()
)
);
app.addKeyboardListener(
new KeyListener({
@ -502,6 +533,27 @@ export async function loadDrawDatas(): Promise<IGraphicStorage> {
);
}
);
fasOfPlatformAlarm.fireValves.forEach((fireValve) => {
datas.push(new FireValveData(fireValve));
});
fasOfPlatformAlarm.electricFireExtinguishingValves.forEach(
(electricFireExtinguishingValve) => {
datas.push(
new ElectricFireExtinguishingValveData(
electricFireExtinguishingValve
)
);
}
);
fasOfPlatformAlarm.fireIntercommunicationSignals.forEach(
(fireIntercommunicationSignal) => {
datas.push(
new FireIntercommunicationSignalData(
fireIntercommunicationSignal
)
);
}
);
break;
}
}
@ -713,6 +765,23 @@ export function saveDrawDatas(app: IDrawApp) {
fasStorage.electricButterflyValves.push(
(electricButterflyValveData as ElectricButterflyValveData).data
);
} else if (g instanceof FireValve) {
const fireValveData = g.saveData();
fasStorage.fireValves.push((fireValveData as FireValveData).data);
} else if (g instanceof ElectricFireExtinguishingValve) {
const electricFireExtinguishingValveData = g.saveData();
fasStorage.electricFireExtinguishingValves.push(
(
electricFireExtinguishingValveData as ElectricFireExtinguishingValveData
).data
);
} else if (g instanceof FireIntercommunicationSignal) {
const fireIntercommunicationSignalData = g.saveData();
fasStorage.fireIntercommunicationSignals.push(
(
fireIntercommunicationSignalData as FireIntercommunicationSignalData
).data
);
}
});
storage.fasOfPlatformAlarmStorages[i] = fasStorage;

View File

@ -0,0 +1,78 @@
import { GraphicData, JlGraphic, JlGraphicTemplate } from 'jl-graphic';
import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js';
import FasDeviceJson from '../pndDevice/PngDevice.json';
import FasDeviceAssets from '../pndDevice/FasDevice.png';
export interface IElectricFireExtinguishingValveData extends GraphicData {
get code(): string;
set code(v: string);
}
interface ElectricFireExtinguishingValveTextures {
normal: Texture;
fireAlarm: Texture;
fault: Texture;
interruption: Texture;
}
export class ElectricFireExtinguishingValve extends JlGraphic {
static Type = 'ElectricFireExtinguishingValve';
_electricFireExtinguishingValve: Sprite;
electricFireExtinguishingValveTextures: ElectricFireExtinguishingValveTextures;
__state = 0;
constructor(
electricFireExtinguishingValveTextures: ElectricFireExtinguishingValveTextures
) {
super(ElectricFireExtinguishingValve.Type);
this._electricFireExtinguishingValve = new Sprite();
this.electricFireExtinguishingValveTextures =
electricFireExtinguishingValveTextures;
this._electricFireExtinguishingValve.anchor.set(0.5);
this.addChild(this._electricFireExtinguishingValve);
this._electricFireExtinguishingValve.texture =
this.electricFireExtinguishingValveTextures.normal;
}
get code(): string {
return this.datas.code;
}
get datas(): IElectricFireExtinguishingValveData {
return this.getDatas<IElectricFireExtinguishingValveData>();
}
doRepaint(): void {}
}
export class ElectricFireExtinguishingValveTemplate extends JlGraphicTemplate<ElectricFireExtinguishingValve> {
electricFireExtinguishingValveTextures?: ElectricFireExtinguishingValveTextures;
constructor(dataTemplate: IElectricFireExtinguishingValveData) {
super(ElectricFireExtinguishingValve.Type, { dataTemplate });
this.loadAssets();
}
new(): ElectricFireExtinguishingValve {
if (this.electricFireExtinguishingValveTextures) {
const g = new ElectricFireExtinguishingValve(
this.electricFireExtinguishingValveTextures
);
g.loadData(this.datas);
return g;
}
throw new Error('资源未加载/加载失败');
}
async loadAssets(): Promise<ElectricFireExtinguishingValveTextures> {
const texture = await Assets.load(FasDeviceAssets);
const electricFireExtinguishingValveSheet = new Spritesheet(
texture,
FasDeviceJson
);
const result = await electricFireExtinguishingValveSheet.parse();
this.electricFireExtinguishingValveTextures = {
normal: result['electricFireExtinguishingValveNormal.png'],
fireAlarm: result['_electricFireExtinguishingValveFireAlarm.png'],
fault: result['_electricFireExtinguishingValveFault.png'],
interruption: result['electricFireExtinguishingValveInterruption.png'],
};
return this
.electricFireExtinguishingValveTextures as ElectricFireExtinguishingValveTextures;
}
}

View File

@ -0,0 +1,136 @@
import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js';
import {
AbsorbableLine,
AbsorbablePosition,
GraphicDrawAssistant,
GraphicInteractionPlugin,
GraphicTransformEvent,
IDrawApp,
JlGraphic,
} from 'jl-graphic';
import {
ElectricFireExtinguishingValve,
IElectricFireExtinguishingValveData,
ElectricFireExtinguishingValveTemplate,
} from './ElectricFireExtinguishingValve';
export class ElectricFireExtinguishingValveDraw extends GraphicDrawAssistant<
ElectricFireExtinguishingValveTemplate,
IElectricFireExtinguishingValveData
> {
_electricFireExtinguishingValve: ElectricFireExtinguishingValve | null = null;
constructor(app: IDrawApp, template: ElectricFireExtinguishingValveTemplate) {
super(
app,
template,
'svguse:../drawIcon.svg#icon-electric-fire-extinguishing-valve',
'电动防烟防火阀'
);
ElectricFireExtinguishingValveInteraction.init(app);
}
bind(): void {
super.bind();
if (!this._electricFireExtinguishingValve) {
this._electricFireExtinguishingValve = this.graphicTemplate.new();
this.container.addChild(this._electricFireExtinguishingValve);
}
}
public get electricFireExtinguishingValve(): ElectricFireExtinguishingValve {
if (!this._electricFireExtinguishingValve) {
this._electricFireExtinguishingValve = this.graphicTemplate.new();
this.container.addChild(this._electricFireExtinguishingValve);
}
return this._electricFireExtinguishingValve;
}
redraw(cp: Point): void {
this.electricFireExtinguishingValve.position.copyFrom(cp);
}
onLeftUp(e: FederatedMouseEvent): void {
this.electricFireExtinguishingValve.position.copyFrom(
this.toCanvasCoordinates(e.global)
);
this.createAndStore(true);
}
prepareData(data: IElectricFireExtinguishingValveData): boolean {
data.transform = this.electricFireExtinguishingValve.saveTransform();
return true;
}
onEsc(): void {
this.finish();
}
}
/**
* 线
* @param electricFireExtinguishingValve
*/
function buildAbsorbablePositions(
electricFireExtinguishingValve: ElectricFireExtinguishingValve
): AbsorbablePosition[] {
const aps: AbsorbablePosition[] = [];
const electricFireExtinguishingValves =
electricFireExtinguishingValve.queryStore.queryByType<ElectricFireExtinguishingValve>(
ElectricFireExtinguishingValve.Type
);
const canvas = electricFireExtinguishingValve.getCanvas();
electricFireExtinguishingValves.forEach((item) => {
if (item.id === electricFireExtinguishingValve.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 ElectricFireExtinguishingValveInteraction extends GraphicInteractionPlugin<ElectricFireExtinguishingValve> {
static Name = 'electric_fire_extinguishing_valve_transform';
constructor(app: IDrawApp) {
super(ElectricFireExtinguishingValveInteraction.Name, app);
}
static init(app: IDrawApp) {
return new ElectricFireExtinguishingValveInteraction(app);
}
filter(
...grahpics: JlGraphic[]
): ElectricFireExtinguishingValve[] | undefined {
return grahpics
.filter((g) => g.type === ElectricFireExtinguishingValve.Type)
.map((g) => g as ElectricFireExtinguishingValve);
}
bind(g: ElectricFireExtinguishingValve): void {
g.eventMode = 'static';
g.cursor = 'pointer';
g.scalable = true;
g.rotatable = true;
g.on('transformstart', this.transformstart, this);
}
unbind(g: ElectricFireExtinguishingValve): 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 electricFireExtinguishingValve =
target.getGraphic() as ElectricFireExtinguishingValve;
electricFireExtinguishingValve.getGraphicApp().setOptions({
absorbablePositions: buildAbsorbablePositions(
electricFireExtinguishingValve
),
});
}
}

View File

@ -0,0 +1,75 @@
import { Graphics } from 'pixi.js';
import {
GraphicData,
JlGraphic,
JlGraphicTemplate,
VectorText,
} from 'jl-graphic';
export interface IFireIntercommunicationSignalData extends GraphicData {
get code(): string; // 编号
set code(v: string);
clone(): IFireIntercommunicationSignalData;
copyFrom(data: IFireIntercommunicationSignalData): void;
eq(other: IFireIntercommunicationSignalData): boolean;
}
const fireIntercommunicationSignalConsts = {
rectWidth: 64,
rectHeight: 24,
rectBackground: '0x99ccff',
textColor: '0x33cc00',
text: '2号线',
fontSize: 12,
};
export class FireIntercommunicationSignal extends JlGraphic {
static Type = 'FireIntercommunicationSignal';
rectGraphic: Graphics = new Graphics();
textGraphic: VectorText = new VectorText();
constructor() {
super(FireIntercommunicationSignal.Type);
this.addChild(this.rectGraphic);
this.addChild(this.textGraphic);
}
get datas(): IFireIntercommunicationSignalData {
return this.getDatas<IFireIntercommunicationSignalData>();
}
doRepaint(): void {
const rectGraphic = this.rectGraphic;
rectGraphic.clear();
rectGraphic.beginFill(fireIntercommunicationSignalConsts.rectBackground);
rectGraphic.drawRect(
0,
0,
fireIntercommunicationSignalConsts.rectWidth,
fireIntercommunicationSignalConsts.rectHeight
);
rectGraphic.endFill();
this.textGraphic.text = fireIntercommunicationSignalConsts.text;
this.textGraphic.setVectorFontSize(
fireIntercommunicationSignalConsts.fontSize
);
this.textGraphic.anchor.set(0.5);
this.textGraphic.style.fill = fireIntercommunicationSignalConsts.textColor;
this.textGraphic.position.set(
fireIntercommunicationSignalConsts.rectWidth / 2,
fireIntercommunicationSignalConsts.rectHeight / 2
);
}
}
export class FireIntercommunicationSignalTemplate extends JlGraphicTemplate<FireIntercommunicationSignal> {
constructor(dataTemplate: IFireIntercommunicationSignalData) {
super(FireIntercommunicationSignal.Type, {
dataTemplate,
});
}
new(): FireIntercommunicationSignal {
const fireIntercommunicationSignal = new FireIntercommunicationSignal();
fireIntercommunicationSignal.loadData(this.datas);
return fireIntercommunicationSignal;
}
}

View File

@ -0,0 +1,135 @@
import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js';
import {
AbsorbableLine,
AbsorbablePosition,
GraphicDrawAssistant,
GraphicInteractionPlugin,
GraphicTransformEvent,
IDrawApp,
JlGraphic,
} from 'jl-graphic';
import {
IFireIntercommunicationSignalData,
FireIntercommunicationSignal,
FireIntercommunicationSignalTemplate,
} from './FireIntercommunicationSignal';
export class FireIntercommunicationSignalDraw extends GraphicDrawAssistant<
FireIntercommunicationSignalTemplate,
IFireIntercommunicationSignalData
> {
_fireIntercommunicationSignal: FireIntercommunicationSignal | null = null;
constructor(app: IDrawApp, template: FireIntercommunicationSignalTemplate) {
super(
app,
template,
'svguse:../drawIcon.svg#icon-fire-intercommunication-signal',
'火灾互联互通信号'
);
FireIntercommunicationSignalInteraction.init(app);
}
bind(): void {
super.bind();
if (!this._fireIntercommunicationSignal) {
this._fireIntercommunicationSignal = this.graphicTemplate.new();
this.container.addChild(this._fireIntercommunicationSignal);
this._fireIntercommunicationSignal.doRepaint();
}
}
public get fireIntercommunicationSignal(): FireIntercommunicationSignal {
if (!this._fireIntercommunicationSignal) {
this._fireIntercommunicationSignal = this.graphicTemplate.new();
this.container.addChild(this._fireIntercommunicationSignal);
}
return this._fireIntercommunicationSignal;
}
redraw(cp: Point): void {
this.fireIntercommunicationSignal.position.copyFrom(cp);
}
onLeftUp(e: FederatedMouseEvent): void {
this.fireIntercommunicationSignal.position.copyFrom(
this.toCanvasCoordinates(e.global)
);
this.createAndStore(true);
}
prepareData(data: IFireIntercommunicationSignalData): boolean {
data.transform = this.fireIntercommunicationSignal.saveTransform();
return true;
}
onEsc(): void {
this.finish();
}
}
/**
* 线
* @param fireIntercommunicationSignal
*/
function buildAbsorbablePositions(
fireIntercommunicationSignal: FireIntercommunicationSignal
): AbsorbablePosition[] {
const aps: AbsorbablePosition[] = [];
const fireIntercommunicationSignals =
fireIntercommunicationSignal.queryStore.queryByType<FireIntercommunicationSignal>(
FireIntercommunicationSignal.Type
);
const canvas = fireIntercommunicationSignal.getCanvas();
fireIntercommunicationSignals.forEach((item) => {
if (item.id === fireIntercommunicationSignal.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 FireIntercommunicationSignalInteraction extends GraphicInteractionPlugin<FireIntercommunicationSignal> {
static Name = 'fire_intercommunication_signal_transform';
constructor(app: IDrawApp) {
super(FireIntercommunicationSignalInteraction.Name, app);
}
static init(app: IDrawApp) {
return new FireIntercommunicationSignalInteraction(app);
}
filter(...grahpics: JlGraphic[]): FireIntercommunicationSignal[] | undefined {
return grahpics
.filter((g) => g.type === FireIntercommunicationSignal.Type)
.map((g) => g as FireIntercommunicationSignal);
}
bind(g: FireIntercommunicationSignal): void {
g.eventMode = 'static';
g.cursor = 'pointer';
g.scalable = true;
g.rotatable = true;
g.on('transformstart', this.transformstart, this);
}
unbind(g: FireIntercommunicationSignal): 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 fireIntercommunicationSignal =
target.getGraphic() as FireIntercommunicationSignal;
fireIntercommunicationSignal.getGraphicApp().setOptions({
absorbablePositions: buildAbsorbablePositions(
fireIntercommunicationSignal
),
});
}
}

View File

@ -0,0 +1,70 @@
import { GraphicData, JlGraphic, JlGraphicTemplate } from 'jl-graphic';
import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js';
import FasDeviceJson from '../pndDevice/PngDevice.json';
import FasDeviceAssets from '../pndDevice/FasDevice.png';
export interface IFireValveData extends GraphicData {
get code(): string;
set code(v: string);
}
interface FireValveTextures {
normal: Texture;
fireAlarm: Texture;
fault: Texture;
interruption: Texture;
isolate: Texture;
}
export class FireValve extends JlGraphic {
static Type = 'FireValve';
_fireValve: Sprite;
fireValveTextures: FireValveTextures;
__state = 0;
constructor(fireValveTextures: FireValveTextures) {
super(FireValve.Type);
this._fireValve = new Sprite();
this.fireValveTextures = fireValveTextures;
this._fireValve.anchor.set(0.5);
this.addChild(this._fireValve);
this._fireValve.texture = this.fireValveTextures.normal;
}
get code(): string {
return this.datas.code;
}
get datas(): IFireValveData {
return this.getDatas<IFireValveData>();
}
doRepaint(): void {}
}
export class FireValveTemplate extends JlGraphicTemplate<FireValve> {
fireValveTextures?: FireValveTextures;
constructor(dataTemplate: IFireValveData) {
super(FireValve.Type, { dataTemplate });
this.loadAssets();
}
new(): FireValve {
if (this.fireValveTextures) {
const g = new FireValve(this.fireValveTextures);
g.loadData(this.datas);
return g;
}
throw new Error('资源未加载/加载失败');
}
async loadAssets(): Promise<FireValveTextures> {
const texture = await Assets.load(FasDeviceAssets);
const fireValveSheet = new Spritesheet(texture, FasDeviceJson);
const result = await fireValveSheet.parse();
this.fireValveTextures = {
normal: result['fireValveNormal.png'],
fireAlarm: result['fireValveFireAlarm.png'],
fault: result['fireValveFault.png'],
interruption: result['fireValveInterruption.png'],
isolate: result['fireValveIsolate.png'],
};
return this.fireValveTextures as FireValveTextures;
}
}

View File

@ -0,0 +1,117 @@
import { DisplayObject, FederatedMouseEvent, Point } from 'pixi.js';
import {
AbsorbableLine,
AbsorbablePosition,
GraphicDrawAssistant,
GraphicInteractionPlugin,
GraphicTransformEvent,
IDrawApp,
JlGraphic,
} from 'jl-graphic';
import { IFireValveData, FireValve, FireValveTemplate } from './FireValve';
export class FireValveDraw extends GraphicDrawAssistant<
FireValveTemplate,
IFireValveData
> {
_fireValve: FireValve | null = null;
constructor(app: IDrawApp, template: FireValveTemplate) {
super(app, template, 'svguse:../drawIcon.svg#icon-fire-valve', '防火阀');
FireValveInteraction.init(app);
}
bind(): void {
super.bind();
if (!this._fireValve) {
this._fireValve = this.graphicTemplate.new();
this.container.addChild(this._fireValve);
}
}
public get fireValve(): FireValve {
if (!this._fireValve) {
this._fireValve = this.graphicTemplate.new();
this.container.addChild(this._fireValve);
}
return this._fireValve;
}
redraw(cp: Point): void {
this.fireValve.position.copyFrom(cp);
}
onLeftUp(e: FederatedMouseEvent): void {
this.fireValve.position.copyFrom(this.toCanvasCoordinates(e.global));
this.createAndStore(true);
}
prepareData(data: IFireValveData): boolean {
data.transform = this.fireValve.saveTransform();
return true;
}
onEsc(): void {
this.finish();
}
}
/**
* 线
* @param fireValve
*/
function buildAbsorbablePositions(fireValve: FireValve): AbsorbablePosition[] {
const aps: AbsorbablePosition[] = [];
const fireValves = fireValve.queryStore.queryByType<FireValve>(
FireValve.Type
);
const canvas = fireValve.getCanvas();
fireValves.forEach((item) => {
if (item.id === fireValve.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 FireValveInteraction extends GraphicInteractionPlugin<FireValve> {
static Name = 'fire_valve_transform';
constructor(app: IDrawApp) {
super(FireValveInteraction.Name, app);
}
static init(app: IDrawApp) {
return new FireValveInteraction(app);
}
filter(...grahpics: JlGraphic[]): FireValve[] | undefined {
return grahpics
.filter((g) => g.type === FireValve.Type)
.map((g) => g as FireValve);
}
bind(g: FireValve): void {
g.eventMode = 'static';
g.cursor = 'pointer';
g.scalable = true;
g.rotatable = true;
g.on('transformstart', this.transformstart, this);
}
unbind(g: FireValve): 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 fireValve = target.getGraphic() as FireValve;
fireValve.getGraphicApp().setOptions({
absorbablePositions: buildAbsorbablePositions(fireValve),
});
}
}

View File

@ -340,6 +340,9 @@ import { StartPumpButton } from 'src/graphics/FAS/startPumpButton/StartPumpButto
import { TemperatureCable } from 'src/graphics/FAS/temperatureCable/TemperatureCable';
import { ElevatorLiftToTop } from 'src/graphics/FAS/elevatorLiftToTop/ElevatorLiftToTop';
import { ElectricButterflyValve } from 'src/graphics/FAS/electricButterflyValve/ElectricButterflyValve';
import { FireValve } from 'src/graphics/FAS/fireValve/FireValve';
import { ElectricFireExtinguishingValve } from 'src/graphics/FAS/electricFireExtinguishingValve/ElectricFireExtinguishingValve';
import { FireIntercommunicationSignal } from 'src/graphics/FAS/fireIntercommunicationSignal/FireIntercommunicationSignal';
const $q = useQuasar();
const route = useRoute();
@ -444,6 +447,9 @@ function handleUtilsOption() {
drawAssistantsTypes.push(TemperatureCable.Type);
drawAssistantsTypes.push(ElevatorLiftToTop.Type);
drawAssistantsTypes.push(ElectricButterflyValve.Type);
drawAssistantsTypes.push(FireValve.Type);
drawAssistantsTypes.push(ElectricFireExtinguishingValve.Type);
drawAssistantsTypes.push(FireIntercommunicationSignal.Type);
break;
}
drawAssistantsTypes.forEach((type) => {