psl设备调整
This commit is contained in:
parent
622200a090
commit
31518d433e
@ -1 +1 @@
|
||||
Subproject commit 45f19cff37b1e5797d160617642d140a116e2689
|
||||
Subproject commit cf291d63729070dad03fadb1bef5ba1fec45cd57
|
@ -37,4 +37,8 @@
|
||||
<line y1="32" x2="35" y2="32" stroke="white" stroke-width="4"/>
|
||||
<circle cx="17.5" cy="16.5" r="7.5" fill="white"/>
|
||||
</symbol>
|
||||
<symbol id="icon-psl-light" width="30" height="30" viewBox="0 0 40 40" fill="none">
|
||||
<circle cx="15" cy="15" r="10.5" stroke="white"/>
|
||||
<circle cx="15" cy="15" r="14.5" stroke="white"/>
|
||||
</symbol>
|
||||
</svg>
|
||||
|
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.5 KiB |
38
src/drawApp/graphics/PslLightInteraction.ts
Normal file
38
src/drawApp/graphics/PslLightInteraction.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import * as pb_1 from 'google-protobuf';
|
||||
import { IPslLightData, PslLight } from 'src/graphics/pslLight/pslLight';
|
||||
import { pslGraphicData } from 'src/protos/pslGraphics';
|
||||
import { GraphicDataBase } from './GraphicDataBase';
|
||||
|
||||
export class PslLightData extends GraphicDataBase implements IPslLightData {
|
||||
constructor(data?: pslGraphicData.PslLight) {
|
||||
let pslLight;
|
||||
if (data) {
|
||||
pslLight = data;
|
||||
} else {
|
||||
pslLight = new pslGraphicData.PslLight({
|
||||
common: GraphicDataBase.defaultCommonInfo(PslLight.Type),
|
||||
});
|
||||
}
|
||||
super(pslLight);
|
||||
}
|
||||
|
||||
public get data(): pslGraphicData.PslLight {
|
||||
return this.getData<pslGraphicData.PslLight>();
|
||||
}
|
||||
|
||||
get code(): string {
|
||||
return this.data.code;
|
||||
}
|
||||
set code(v: string) {
|
||||
this.data.code = v;
|
||||
}
|
||||
clone(): PslLightData {
|
||||
return new PslLightData(this.data.cloneMessage());
|
||||
}
|
||||
copyFrom(data: PslLightData): void {
|
||||
pb_1.Message.copyInto(data.data, this.data);
|
||||
}
|
||||
eq(other: PslLightData): boolean {
|
||||
return pb_1.Message.equals(this.data, other.data);
|
||||
}
|
||||
}
|
61
src/graphics/pslLight/psl-light-data.json
Normal file
61
src/graphics/pslLight/psl-light-data.json
Normal file
@ -0,0 +1,61 @@
|
||||
{
|
||||
"frames": {
|
||||
"red-off.png": {
|
||||
"frame": { "x": 0, "y": 0, "w": 63, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
|
||||
"sourceSize": { "w": 64, "h": 64 },
|
||||
"anchor": { "x": 0.5, "y": 0.5 }
|
||||
},
|
||||
"red-on.png": {
|
||||
"frame": { "x": 63, "y": 0, "w": 64, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
|
||||
"sourceSize": { "w": 64, "h": 64 },
|
||||
"anchor": { "x": 0.5, "y": 0.5 }
|
||||
},
|
||||
"blue-off.png": {
|
||||
"frame": { "x": 128, "y": 0, "w": 63, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
|
||||
"sourceSize": { "w": 64, "h": 64 },
|
||||
"anchor": { "x": 0.5, "y": 0.5 }
|
||||
},
|
||||
"blue-on.png": {
|
||||
"frame": { "x": 192, "y": 0, "w": 64, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
|
||||
"sourceSize": { "w": 64, "h": 64 },
|
||||
"anchor": { "x": 0.5, "y": 0.5 }
|
||||
},
|
||||
"green-off.png": {
|
||||
"frame": { "x": 256, "y": 0, "w": 64, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
|
||||
"sourceSize": { "w": 64, "h": 64 },
|
||||
"anchor": { "x": 0.5, "y": 0.5 }
|
||||
},
|
||||
"green-on.png": {
|
||||
"frame": { "x": 320, "y": 0, "w": 64, "h": 64 },
|
||||
"rotated": false,
|
||||
"trimmed": false,
|
||||
"spriteSourceSize": { "x": 0, "y": 0, "w": 64, "h": 64 },
|
||||
"sourceSize": { "w": 64, "h": 64 },
|
||||
"anchor": { "x": 0.5, "y": 0.5 }
|
||||
}
|
||||
},
|
||||
"meta": {
|
||||
"app": "https://www.codeandweb.com/texturepacker",
|
||||
"version": "1.1",
|
||||
"image": "psl-light.png",
|
||||
"format": "RGBA8888",
|
||||
"size": { "w": 384, "h": 64 },
|
||||
"scale": "1",
|
||||
"smartupdate": "$TexturePacker:SmartUpdate:e7620bd2d73cc0b3e2deea9704e7eefc:f129a1d9e4b9ba57720b3861c22b155b:eb2d421f7759984b7713aa4aa5354134$"
|
||||
}
|
||||
}
|
BIN
src/graphics/pslLight/psl-light-spritesheet.png
Normal file
BIN
src/graphics/pslLight/psl-light-spritesheet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
80
src/graphics/pslLight/pslLight.ts
Normal file
80
src/graphics/pslLight/pslLight.ts
Normal file
@ -0,0 +1,80 @@
|
||||
import {
|
||||
GraphicData,
|
||||
GraphicState,
|
||||
JlGraphic,
|
||||
JlGraphicTemplate,
|
||||
} from 'src/jl-graphic';
|
||||
import Psl_Light_Assets from './psl-light-spritesheet.png';
|
||||
import Psl_Light_JSON from './psl-light-data.json';
|
||||
|
||||
import { Assets, Sprite, Spritesheet, Texture } from 'pixi.js';
|
||||
|
||||
interface PslLightTextures {
|
||||
redOn: Texture;
|
||||
redOff: Texture;
|
||||
greenOn: Texture;
|
||||
greenOff: Texture;
|
||||
blueOn: Texture;
|
||||
blueOff: Texture;
|
||||
}
|
||||
|
||||
export interface IPslLightData extends GraphicData {
|
||||
get code(): string;
|
||||
set code(v: string);
|
||||
}
|
||||
|
||||
export interface IPslLightState extends GraphicState {
|
||||
get state(): number;
|
||||
set state(v: number);
|
||||
}
|
||||
|
||||
export class PslLight extends JlGraphic {
|
||||
static Type = 'PslLight';
|
||||
_pslLight: Sprite;
|
||||
pslLightTextures: PslLightTextures;
|
||||
__state = 0;
|
||||
|
||||
constructor(pslLightTextures: PslLightTextures) {
|
||||
super(PslLight.Type);
|
||||
this.pslLightTextures = pslLightTextures;
|
||||
this._pslLight = new Sprite();
|
||||
this._pslLight.texture = this.pslLightTextures.greenOn;
|
||||
this._pslLight.anchor.set(0.5);
|
||||
this.addChild(this._pslLight);
|
||||
}
|
||||
doRepaint(): void {
|
||||
this._pslLight.rotation = 0;
|
||||
this._pslLight.texture = this.pslLightTextures.greenOn;
|
||||
}
|
||||
}
|
||||
|
||||
export class PslLightTemplate extends JlGraphicTemplate<PslLight> {
|
||||
pslLightTextures?: PslLightTextures;
|
||||
constructor(dataTemplate: IPslLightData) {
|
||||
super(PslLight.Type, { dataTemplate });
|
||||
this.loadAssets();
|
||||
}
|
||||
new(): PslLight {
|
||||
if (this.pslLightTextures) {
|
||||
const g = new PslLight(this.pslLightTextures);
|
||||
g.loadData(this.datas);
|
||||
// g.loadState(this.states);
|
||||
return g;
|
||||
}
|
||||
throw new Error('资源未加载/加载失败');
|
||||
}
|
||||
async loadAssets(): Promise<PslLightTextures> {
|
||||
const texture = await Assets.load(Psl_Light_Assets);
|
||||
const pslLightSheet = new Spritesheet(texture, Psl_Light_JSON);
|
||||
const result = await pslLightSheet.parse();
|
||||
this.pslLightTextures = {
|
||||
redOff: result['red-off.png'],
|
||||
redOn: result['red-on.png'],
|
||||
blueOff: result['blue-off.png'],
|
||||
blueOn: result['blue-on.png'],
|
||||
greenOff: result['green-off.png'],
|
||||
greenOn: result['green-on.png'],
|
||||
};
|
||||
return this.pslLightTextures as PslLightTextures;
|
||||
}
|
||||
}
|
76
src/graphics/pslLight/pslLightDrawAssistant.ts
Normal file
76
src/graphics/pslLight/pslLightDrawAssistant.ts
Normal file
@ -0,0 +1,76 @@
|
||||
import { FederatedMouseEvent, Point } from 'pixi.js';
|
||||
import {
|
||||
GraphicDrawAssistant,
|
||||
GraphicInteractionPlugin,
|
||||
JlDrawApp,
|
||||
JlGraphic,
|
||||
} from 'src/jl-graphic';
|
||||
import { IPslLightData, PslLight, PslLightTemplate } from './pslLight';
|
||||
|
||||
export class PslLightDraw extends GraphicDrawAssistant<
|
||||
PslLightTemplate,
|
||||
IPslLightData
|
||||
> {
|
||||
_pslLight: PslLight | null = null;
|
||||
constructor(app: JlDrawApp, template: PslLightTemplate) {
|
||||
super(app, template, 'svguse:../../drawIcon.svg#icon-psl-light', 'PSL灯');
|
||||
PslLightInteraction.init(app);
|
||||
}
|
||||
|
||||
bind(): void {
|
||||
super.bind();
|
||||
if (!this._pslLight) {
|
||||
this._pslLight = this.graphicTemplate.new();
|
||||
this.container.addChild(this._pslLight);
|
||||
}
|
||||
}
|
||||
|
||||
public get pslLight(): PslLight {
|
||||
if (!this._pslLight) {
|
||||
this._pslLight = this.graphicTemplate.new();
|
||||
this.container.addChild(this._pslLight);
|
||||
}
|
||||
return this._pslLight;
|
||||
}
|
||||
|
||||
redraw(cp: Point): void {
|
||||
this.pslLight.position.copyFrom(cp);
|
||||
}
|
||||
onLeftUp(e: FederatedMouseEvent): void {
|
||||
this.pslLight.position.copyFrom(this.toCanvasCoordinates(e.global));
|
||||
this.createAndStore(true);
|
||||
}
|
||||
prepareData(data: IPslLightData): boolean {
|
||||
data.transform = this.pslLight.saveTransform();
|
||||
return true;
|
||||
}
|
||||
onEsc(): void {
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
export class PslLightInteraction extends GraphicInteractionPlugin<PslLight> {
|
||||
static Name = 'psl_light_transform';
|
||||
constructor(app: JlDrawApp) {
|
||||
super(PslLightInteraction.Name, app);
|
||||
}
|
||||
static init(app: JlDrawApp) {
|
||||
return new PslLightInteraction(app);
|
||||
}
|
||||
filter(...grahpics: JlGraphic[]): PslLight[] | undefined {
|
||||
return grahpics
|
||||
.filter((g) => g.type === PslLight.Type)
|
||||
.map((g) => g as PslLight);
|
||||
}
|
||||
bind(g: PslLight): void {
|
||||
g.eventMode = 'static';
|
||||
g.cursor = 'pointer';
|
||||
g.scalable = true;
|
||||
g.rotatable = true;
|
||||
}
|
||||
unbind(g: PslLight): void {
|
||||
g.eventMode = 'none';
|
||||
g.scalable = false;
|
||||
g.rotatable = false;
|
||||
}
|
||||
}
|
@ -77,6 +77,15 @@
|
||||
lazy-rules
|
||||
:rules="[(val) => val.length > 0 || '请选择厂家!']"
|
||||
/>
|
||||
<q-select
|
||||
v-model="pictureType"
|
||||
:options="pictureTypeList"
|
||||
emit-value
|
||||
map-options
|
||||
label="类型 * "
|
||||
lazy-rules
|
||||
:rules="[(val) => val >= 0 || '请选择类型!']"
|
||||
/>
|
||||
|
||||
<q-card-actions align="right">
|
||||
<q-btn color="primary" label="创建" type="submit" />
|
||||
@ -141,6 +150,7 @@ import {
|
||||
import { publishDraft } from '../api/PublishApi';
|
||||
import { ApiError } from 'src/boot/axios';
|
||||
import { CategoryItem, getCategoryList } from 'src/api/CategoryInfoApi';
|
||||
import { PictureType } from 'src/protos/picture';
|
||||
|
||||
interface OptionsItem {
|
||||
label: string;
|
||||
@ -333,7 +343,12 @@ async function deleteData(row: DraftItem) {
|
||||
}
|
||||
|
||||
const categoryOptions: OptionsItem[] = [];
|
||||
const pictureTypeList: { label: string; value: PictureType }[] = [
|
||||
{ label: '信号布置图', value: PictureType.StationLayout },
|
||||
{ label: 'PSL', value: PictureType.Psl },
|
||||
];
|
||||
const categoryId = ref('');
|
||||
const pictureType = ref(null);
|
||||
function categoryName(val?: number) {
|
||||
let n = '';
|
||||
if (val) {
|
||||
|
169
src/protos/pslGraphics.ts
Normal file
169
src/protos/pslGraphics.ts
Normal file
@ -0,0 +1,169 @@
|
||||
/**
|
||||
* Generated by the protoc-gen-ts. DO NOT EDIT!
|
||||
* compiler version: 4.23.1
|
||||
* source: pslGraphics.proto
|
||||
* git: https://github.com/thesayyn/protoc-gen-ts */
|
||||
import * as dependency_1 from "./stationLayoutGraphics";
|
||||
import * as pb_1 from "google-protobuf";
|
||||
export namespace pslGraphicData {
|
||||
export class PslGraphicStorage extends pb_1.Message {
|
||||
#one_of_decls: number[][] = [];
|
||||
constructor(data?: any[] | {
|
||||
psllights?: PslLight[];
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [1], this.#one_of_decls);
|
||||
if (!Array.isArray(data) && typeof data == "object") {
|
||||
if ("psllights" in data && data.psllights != undefined) {
|
||||
this.psllights = data.psllights;
|
||||
}
|
||||
}
|
||||
}
|
||||
get psllights() {
|
||||
return pb_1.Message.getRepeatedWrapperField(this, PslLight, 1) as PslLight[];
|
||||
}
|
||||
set psllights(value: PslLight[]) {
|
||||
pb_1.Message.setRepeatedWrapperField(this, 1, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
psllights?: ReturnType<typeof PslLight.prototype.toObject>[];
|
||||
}): PslGraphicStorage {
|
||||
const message = new PslGraphicStorage({});
|
||||
if (data.psllights != null) {
|
||||
message.psllights = data.psllights.map(item => PslLight.fromObject(item));
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
psllights?: ReturnType<typeof PslLight.prototype.toObject>[];
|
||||
} = {};
|
||||
if (this.psllights != null) {
|
||||
data.psllights = this.psllights.map((item: PslLight) => item.toObject());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
serialize(w: pb_1.BinaryWriter): void;
|
||||
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
|
||||
const writer = w || new pb_1.BinaryWriter();
|
||||
if (this.psllights.length)
|
||||
writer.writeRepeatedMessage(1, this.psllights, (item: PslLight) => item.serialize(writer));
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): PslGraphicStorage {
|
||||
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new PslGraphicStorage();
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup())
|
||||
break;
|
||||
switch (reader.getFieldNumber()) {
|
||||
case 1:
|
||||
reader.readMessage(message.psllights, () => pb_1.Message.addToRepeatedWrapperField(message, 1, PslLight.deserialize(reader), PslLight));
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
serializeBinary(): Uint8Array {
|
||||
return this.serialize();
|
||||
}
|
||||
static deserializeBinary(bytes: Uint8Array): PslGraphicStorage {
|
||||
return PslGraphicStorage.deserialize(bytes);
|
||||
}
|
||||
}
|
||||
export class PslLight extends pb_1.Message {
|
||||
#one_of_decls: number[][] = [];
|
||||
constructor(data?: any[] | {
|
||||
common?: dependency_1.graphicData.CommonInfo;
|
||||
code?: string;
|
||||
}) {
|
||||
super();
|
||||
pb_1.Message.initialize(this, Array.isArray(data) ? data : [], 0, -1, [], this.#one_of_decls);
|
||||
if (!Array.isArray(data) && typeof data == "object") {
|
||||
if ("common" in data && data.common != undefined) {
|
||||
this.common = data.common;
|
||||
}
|
||||
if ("code" in data && data.code != undefined) {
|
||||
this.code = data.code;
|
||||
}
|
||||
}
|
||||
}
|
||||
get common() {
|
||||
return pb_1.Message.getWrapperField(this, dependency_1.graphicData.CommonInfo, 1) as dependency_1.graphicData.CommonInfo;
|
||||
}
|
||||
set common(value: dependency_1.graphicData.CommonInfo) {
|
||||
pb_1.Message.setWrapperField(this, 1, value);
|
||||
}
|
||||
get has_common() {
|
||||
return pb_1.Message.getField(this, 1) != null;
|
||||
}
|
||||
get code() {
|
||||
return pb_1.Message.getFieldWithDefault(this, 2, "") as string;
|
||||
}
|
||||
set code(value: string) {
|
||||
pb_1.Message.setField(this, 2, value);
|
||||
}
|
||||
static fromObject(data: {
|
||||
common?: ReturnType<typeof dependency_1.graphicData.CommonInfo.prototype.toObject>;
|
||||
code?: string;
|
||||
}): PslLight {
|
||||
const message = new PslLight({});
|
||||
if (data.common != null) {
|
||||
message.common = dependency_1.graphicData.CommonInfo.fromObject(data.common);
|
||||
}
|
||||
if (data.code != null) {
|
||||
message.code = data.code;
|
||||
}
|
||||
return message;
|
||||
}
|
||||
toObject() {
|
||||
const data: {
|
||||
common?: ReturnType<typeof dependency_1.graphicData.CommonInfo.prototype.toObject>;
|
||||
code?: string;
|
||||
} = {};
|
||||
if (this.common != null) {
|
||||
data.common = this.common.toObject();
|
||||
}
|
||||
if (this.code != null) {
|
||||
data.code = this.code;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
serialize(): Uint8Array;
|
||||
serialize(w: pb_1.BinaryWriter): void;
|
||||
serialize(w?: pb_1.BinaryWriter): Uint8Array | void {
|
||||
const writer = w || new pb_1.BinaryWriter();
|
||||
if (this.has_common)
|
||||
writer.writeMessage(1, this.common, () => this.common.serialize(writer));
|
||||
if (this.code.length)
|
||||
writer.writeString(2, this.code);
|
||||
if (!w)
|
||||
return writer.getResultBuffer();
|
||||
}
|
||||
static deserialize(bytes: Uint8Array | pb_1.BinaryReader): PslLight {
|
||||
const reader = bytes instanceof pb_1.BinaryReader ? bytes : new pb_1.BinaryReader(bytes), message = new PslLight();
|
||||
while (reader.nextField()) {
|
||||
if (reader.isEndGroup())
|
||||
break;
|
||||
switch (reader.getFieldNumber()) {
|
||||
case 1:
|
||||
reader.readMessage(message.common, () => message.common = dependency_1.graphicData.CommonInfo.deserialize(reader));
|
||||
break;
|
||||
case 2:
|
||||
message.code = reader.readString();
|
||||
break;
|
||||
default: reader.skipField();
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
serializeBinary(): Uint8Array {
|
||||
return this.serialize();
|
||||
}
|
||||
static deserializeBinary(bytes: Uint8Array): PslLight {
|
||||
return PslLight.deserialize(bytes);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user