信号机故障报警仪图形调整

This commit is contained in:
joylink_zhaoerwei 2023-10-25 10:31:39 +08:00
parent eb0b8a9655
commit afa8cb5e8c
4 changed files with 53 additions and 40 deletions

View File

@ -1,8 +1,12 @@
<template> <template>
<draggable-dialog seamless title="采集列表" :width="600" :height="500"> <draggable-dialog seamless title="采集列表" :width="600" :height="485">
<div class="row" v-for="row in setCellMessage.rows" :key="row"> <div class="row" v-for="row in setCellMessage.rows" :key="row">
<div <div
class="ceil" class="ceil"
:class="{
heightLight:
ciCjList.cjList[col - 1].bitList[row - 1].refRelays.length,
}"
v-for="col in setCellMessage.cols" v-for="col in setCellMessage.cols"
:key="col" :key="col"
@click="handleCellClick(row, col)" @click="handleCellClick(row, col)"
@ -93,4 +97,7 @@ function handleCellClick(row: number, col: number) {
text-align: center; text-align: center;
line-height: 30px; line-height: 30px;
} }
.heightLight {
background-color: red;
}
</style> </style>

View File

@ -1,11 +1,11 @@
import { Assets, Sprite, Texture } from 'pixi.js'; import { Color, Graphics, Rectangle } from 'pixi.js';
import { import {
GraphicData, GraphicData,
JlGraphic, JlGraphic,
JlGraphicTemplate, JlGraphicTemplate,
VectorText, VectorText,
getRectangleCenter,
} from 'src/jl-graphic'; } from 'src/jl-graphic';
import signalFaultAlarmSprites from './signalFaultAlarmSprites.png';
export interface ISignalFaultAlarmData extends GraphicData { export interface ISignalFaultAlarmData extends GraphicData {
get code(): string; // 编号 get code(): string; // 编号
@ -16,27 +16,19 @@ export interface ISignalFaultAlarmData extends GraphicData {
} }
export const signalFaultAlarmConsts = { export const signalFaultAlarmConsts = {
scaleX: 0.2, width: 480,
scaleY: 0.2, height: 60,
lineWidth: 3,
}; };
export class SignalFaultAlarm extends JlGraphic { export class SignalFaultAlarm extends JlGraphic {
static Type = 'SignalFaultAlarm'; static Type = 'SignalFaultAlarm';
signalFaultAlarm: Sprite; signalFaultAlarmGraphic: Graphics = new Graphics();
signalFaultAlarmTextures: Texture;
labelGraphic = new VectorText(); labelGraphic = new VectorText();
constructor(signalFaultAlarmTextures: Texture) { constructor() {
super(SignalFaultAlarm.Type); super(SignalFaultAlarm.Type);
this.signalFaultAlarmTextures = signalFaultAlarmTextures; this.addChild(this.signalFaultAlarmGraphic);
this.signalFaultAlarm = new Sprite(); this.setTextGraphic(this.labelGraphic);
this.signalFaultAlarm.texture = this.signalFaultAlarmTextures;
this.signalFaultAlarm.anchor.set(0.5, 0.5);
this.signalFaultAlarm.scale.set(
signalFaultAlarmConsts.scaleX,
signalFaultAlarmConsts.scaleY
);
this.addChild(this.signalFaultAlarm);
this.setTextGraphic(this.labelGraphic, 'label');
this.addChild(this.labelGraphic); this.addChild(this.labelGraphic);
} }
@ -44,37 +36,51 @@ export class SignalFaultAlarm extends JlGraphic {
return this.getDatas<ISignalFaultAlarmData>(); return this.getDatas<ISignalFaultAlarmData>();
} }
doRepaint(): void { doRepaint(): void {
this.datas.code = this.datas.code || '信号机故障报警仪';
this.labelGraphic.text = this.datas.code; this.labelGraphic.text = this.datas.code;
this.labelGraphic.position.set(0, 25); const signalFaultAlarmGraphic = this.signalFaultAlarmGraphic;
const color =
'0X' +
(
this.getCanvas() as unknown as { backgroundColor: string }
).backgroundColor.substring(1);
signalFaultAlarmGraphic
.clear()
.lineStyle(signalFaultAlarmConsts.lineWidth, new Color(color))
.beginFill(color)
.drawRect(
0,
0,
signalFaultAlarmConsts.width,
signalFaultAlarmConsts.height
);
signalFaultAlarmGraphic.pivot = getRectangleCenter(
new Rectangle(
0,
0,
signalFaultAlarmConsts.width,
signalFaultAlarmConsts.height
)
);
signalFaultAlarmGraphic.endFill;
} }
setTextGraphic(g: VectorText, name: string) { setTextGraphic(g: VectorText) {
g.setVectorFontSize(10); g.setVectorFontSize(10);
g.anchor.set(0.5); g.anchor.set(0.5);
g.style.fill = '#0f0'; g.style.fill = '#0f0';
g.transformSave = true; g.position.set(0, 0);
g.name = name;
} }
} }
export class SignalFaultAlarmTemplate extends JlGraphicTemplate<SignalFaultAlarm> { export class SignalFaultAlarmTemplate extends JlGraphicTemplate<SignalFaultAlarm> {
signalFaultAlarmTextures?: Texture;
constructor(dataTemplate: ISignalFaultAlarmData) { constructor(dataTemplate: ISignalFaultAlarmData) {
super(SignalFaultAlarm.Type, { super(SignalFaultAlarm.Type, {
dataTemplate, dataTemplate,
}); });
} }
new(): SignalFaultAlarm { new(): SignalFaultAlarm {
if (this.signalFaultAlarmTextures) { const relay = new SignalFaultAlarm();
const signalFaultAlarm = new SignalFaultAlarm( relay.loadData(this.datas);
this.signalFaultAlarmTextures return relay;
);
signalFaultAlarm.loadData(this.datas);
return signalFaultAlarm;
}
throw new Error('资源未加载/加载失败');
}
async loadAssets(): Promise<Texture> {
this.signalFaultAlarmTextures = await Assets.load(signalFaultAlarmSprites);
return this.signalFaultAlarmTextures as Texture;
} }
} }

View File

@ -23,18 +23,18 @@ export class SignalFaultAlarmDraw extends GraphicDrawAssistant<
SignalFaultAlarmTemplate, SignalFaultAlarmTemplate,
ISignalFaultAlarmData ISignalFaultAlarmData
> { > {
signalFaultAlarmGraphic: SignalFaultAlarm | null = null; signalFaultAlarmGraphic: SignalFaultAlarm;
constructor(app: IDrawApp, template: SignalFaultAlarmTemplate) { constructor(app: IDrawApp, template: SignalFaultAlarmTemplate) {
super(app, template, 'notifications_active', '信号机故障报警仪'); super(app, template, 'notifications_active', '信号机故障报警仪');
this.signalFaultAlarmGraphic = this.graphicTemplate.new();
this.container.addChild(this.signalFaultAlarmGraphic);
signalFaultAlarmInteraction.init(app); signalFaultAlarmInteraction.init(app);
} }
bind(): void { bind(): void {
super.bind(); super.bind();
if (!this.signalFaultAlarmGraphic) { this.signalFaultAlarmGraphic.loadData(this.graphicTemplate.datas);
this.signalFaultAlarmGraphic = this.graphicTemplate.new(); this.signalFaultAlarmGraphic.doRepaint();
this.container.addChild(this.signalFaultAlarmGraphic);
}
} }
onLeftDown(e: FederatedPointerEvent): void { onLeftDown(e: FederatedPointerEvent): void {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.1 KiB