Compare commits

...

2 Commits

Author SHA1 Message Date
joylink_fanyuhong
3c67d4b5b7 Merge branch 'develop' of https://gitea.joylink.club/joylink/rtss-simulation-app-client into develop 2024-10-24 09:30:11 +08:00
joylink_fanyuhong
f5d87acd4c fas设备添加 2024-10-24 09:29:44 +08:00
16 changed files with 786 additions and 1 deletions

View File

@ -127,4 +127,11 @@
<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>
<symbol id="icon-spray-pump" viewBox="0 0 1024 1024" fill="none" width="32" height="32">
<path d="M622.3872 593.92H371.5072a30.1056 30.1056 0 0 1-33.1776-25.6v-194.56A30.1056 30.1056 0 0 1 371.5072 348.16h250.88A29.9008 29.9008 0 0 1 655.36 373.76v194.56A29.9008 29.9008 0 0 1 622.3872 593.92z m20.48-220.16a18.2272 18.2272 0 0 0-20.48-15.36H371.5072a22.3232 22.3232 0 0 0-20.48 20.48v189.44a18.0224 18.0224 0 0 0 20.48 15.36h250.88a18.2272 18.2272 0 0 0 20.48-15.36v-194.56z" fill="#ffffff" p-id="5416"></path>
<path d="M622.3872 601.7024H371.5072a37.6832 37.6832 0 0 1-40.96-33.3824v-194.56a37.6832 37.6832 0 0 1 40.96-33.3824h250.88a37.6832 37.6832 0 0 1 40.96 33.3824v194.56a37.6832 37.6832 0 0 1-40.96 33.3824z m-250.88-235.52a14.9504 14.9504 0 0 0-12.288 12.6976v189.44c0 3.6864 5.12 7.5776 12.288 7.5776h250.88c7.168 0 12.0832-3.8912 12.0832-7.5776v-194.56c0-3.6864-4.9152-7.5776-12.0832-7.5776zM698.9824 715.1616a29.2864 29.2864 0 0 0-29.0816 29.0816v83.7632a29.0816 29.0816 0 0 0 58.1632 0v-83.7632a29.2864 29.2864 0 0 0-29.0816-29.0816zM588.5952 643.6864l18.432 20.48a46.08 46.08 0 0 0 0 9.4208 25.3952 25.3952 0 0 0 0 5.5296 40.96 40.96 0 0 0-40.96 40.96v53.6576h-53.0432a40.96 40.96 0 0 0-17.6128 3.8912 40.96 40.96 0 0 0-17.6128-3.8912h-55.7056a39.3216 39.3216 0 0 0-3.6864-6.3488 40.96 40.96 0 0 0 7.5776-23.7568v-22.528a40.96 40.96 0 0 0-40.96-40.96v-5.5296a47.3088 47.3088 0 0 0-1.024-9.4208l18.432-20.48h186.368m17.408-40.96H385.024a11.4688 11.4688 0 0 0-11.6736 11.6736l-40.96 47.5136a11.6736 11.6736 0 0 0 11.264 11.6736h-11.264v47.5136h52.6336v23.552H327.68v47.3088h57.344v23.7568h92.7744v11.8784h-52.0192v23.552h139.264v-24.576h-52.0192v-11.8784h151.1424v-47.3088h-58.1632V721.1008h52.4288v-47.5136h-11.264a11.4688 11.4688 0 0 0 11.0592-11.6736l-40.96-47.5136a11.6736 11.6736 0 0 0-11.6736-11.6736zM603.136 336.896H387.8912a43.8272 43.8272 0 0 1-44.032-43.8272V225.28a43.8272 43.8272 0 0 1 44.032-43.8272h215.2448A43.8272 43.8272 0 0 1 646.9632 225.28v67.3792a43.8272 43.8272 0 0 1-43.8272 44.2368z m-215.2448-114.0736a3.072 3.072 0 0 0-3.072 2.8672v67.3792a3.072 3.072 0 0 0 3.072 2.8672h215.2448a2.8672 2.8672 0 0 0 2.8672-2.8672V225.28a2.8672 2.8672 0 0 0-2.8672-2.8672zM292.0448 496.0256a23.552 23.552 0 1 1 21.504-32.3584l14.1312-9.0112v35.6352l-13.312-9.216a23.3472 23.3472 0 0 1-21.504 14.9504zM292.0448 715.1616a29.0816 29.0816 0 0 0-29.0816 29.0816v83.7632a29.0816 29.0816 0 1 0 57.9584 0v-83.7632a29.0816 29.0816 0 0 0-28.8768-29.0816z" fill="#ffffff" p-id="5417"></path>
</symbol>
<symbol id="icon-stabilized-pressure-pump" viewBox="0 0 1024 1024" fill="#ffffff" width="24" height="24">
<path d="M630.162024 748.306329V354.468353c-43.444787 0-78.774682 31.963456-78.774683 71.652006V676.831505c0 39.475932 35.223587 71.474824 78.774683 71.474824z m39.369623-393.837976h354.432917v54.748936H669.531647v-54.748936z m0 212.298301h354.432917v78.774682H669.531647v-78.774682z m0-118.144306h354.432917v78.774683H669.531647V448.622348z m472.612659 228.067412v-250.604838c0-39.511368-35.329896-71.616569-78.774683-71.616569v393.837976c43.551095 0 78.774682-31.998893 78.774683-71.616569zM748.306329 315.063294h196.918989c21.793266 0 39.405059-17.611794 39.405059-39.40506V196.918988h-275.658235V275.693671a39.273945 39.273945 0 0 0 39.334187 39.369623zM315.09873 157.513929h78.774682V78.739246H315.09873V0H236.288611v78.774682H157.513929v78.774683l157.584801-0.035436z m0 0" p-id="7999"></path><path d="M984.630377 866.450635v-78.774682h39.369623v-102.729557H669.531647v102.764993h39.405059v78.774682H315.09873v-196.954424h78.774682v-78.774683h39.40506v39.40506h78.774682v-157.513929h-78.774682v39.405059h-39.40506v-78.774682H315.09873V275.693671h78.774682V196.954424h-236.359483v78.774683h78.774682v157.549365h-39.334187v236.288611H236.359484v118.179742H78.774682C35.29446 787.746825 0.035436 822.970412 0 866.486071v157.513929h1181.655674v-157.549365h-197.025297z m-78.774683 0h-118.179741v-78.774682h118.179741v78.774682z m0 0" p-id="8000"></path><path d="M157.549365 669.531647v-236.288611c-43.480223 0.035436-78.739246 35.29446-78.774683 78.774682H0v78.774683h78.774682c-0.035436 20.907361 8.256636 40.964252 23.033533 55.741149s34.833789 23.068969 55.74115 22.998097z m0 0" p-id="8001"></path>
</symbol>
</svg>

Before

Width:  |  Height:  |  Size: 23 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -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<iscsGraphicData.Acs>();
}
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);
}
}

View File

@ -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<iscsGraphicData.SprayPump>();
}
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);
}
}

View File

@ -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<iscsGraphicData.StabilizedPressurePump>();
}
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);
}
}

View File

@ -74,6 +74,21 @@ import { VerticalElevatorDraw } from 'src/graphics/BAS/verticalElevator/Vertical
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;
@ -132,6 +147,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({
@ -320,6 +341,19 @@ export async function loadDrawDatas(): Promise<IGraphicStorage> {
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;
}
}
@ -467,6 +501,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;

View File

@ -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<IAcsData>();
}
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<Acs> {
constructor(dataTemplate: IAcsData) {
super(Acs.Type, {
dataTemplate,
});
}
new(): Acs {
const acs = new Acs();
acs.loadData(this.datas);
return acs;
}
}

View File

@ -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<AcsTemplate, IAcsData> {
_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>(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<Acs> {
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),
});
}
}

View File

@ -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$"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -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 SprayPumpJson from './SprayPump.json';
import SparyPumpAssets from './SprayPump.png';
export interface ISprayPumpData extends GraphicData {
get code(): string;
set code(v: string);
}
interface SprayPumpTextures {
normal: Texture;
}
export class SprayPump extends JlGraphic {
static Type = 'SprayPump';
_sprayPump: Sprite;
sprayPumpTextures: SprayPumpTextures;
__state = 0;
constructor(sprayPumpTextures: SprayPumpTextures) {
super(SprayPump.Type);
this._sprayPump = new Sprite();
this.sprayPumpTextures = sprayPumpTextures;
this._sprayPump.anchor.set(0.5);
this.addChild(this._sprayPump);
this._sprayPump.texture = this.sprayPumpTextures.normal;
}
get code(): string {
return this.datas.code;
}
get datas(): ISprayPumpData {
return this.getDatas<ISprayPumpData>();
}
doRepaint(): void {}
}
export class SprayPumpTemplate extends JlGraphicTemplate<SprayPump> {
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<SprayPumpTextures> {
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;
}
}

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 { 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>(
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<SprayPump> {
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),
});
}
}

View File

@ -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$"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -0,0 +1,68 @@
import { GraphicData, JlGraphic, JlGraphicTemplate } from 'jl-graphic';
import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js';
// import { iscsGraphicData } from 'src/protos/iscs_graphic_data';
import StabilizedPressurePumpJson from './StabilizedPressurePump.json';
import StabilizedPressurePumpAssets from './StabilizedPressurePump.png';
export interface IStabilizedPressurePumpData extends GraphicData {
get code(): string;
set code(v: string);
}
interface StabilizedPressurePumpTextures {
normal: Texture;
}
export class StabilizedPressurePump extends JlGraphic {
static Type = 'StabilizedPressurePump';
_stabilizedPressurePump: Sprite;
stabilizedPressurePumpTextures: StabilizedPressurePumpTextures;
__state = 0;
constructor(stabilizedPressurePumpTextures: StabilizedPressurePumpTextures) {
super(StabilizedPressurePump.Type);
this._stabilizedPressurePump = new Sprite();
this.stabilizedPressurePumpTextures = stabilizedPressurePumpTextures;
this._stabilizedPressurePump.anchor.set(0.5);
this.addChild(this._stabilizedPressurePump);
this._stabilizedPressurePump.texture =
this.stabilizedPressurePumpTextures.normal;
}
get code(): string {
return this.datas.code;
}
get datas(): IStabilizedPressurePumpData {
return this.getDatas<IStabilizedPressurePumpData>();
}
doRepaint(): void {}
}
export class StabilizedPressurePumpTemplate extends JlGraphicTemplate<StabilizedPressurePump> {
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<StabilizedPressurePumpTextures> {
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;
}
}

View File

@ -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>(
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<StabilizedPressurePump> {
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),
});
}
}

View File

@ -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';
import { VerticalElevator } from 'src/graphics/BAS/verticalElevator/VerticalElevator';
const $q = useQuasar();
@ -406,6 +409,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) => {