框架同步
This commit is contained in:
parent
490fdab81d
commit
b965bd7c77
@ -1 +1 @@
|
|||||||
Subproject commit 3e1bbc92bf3e1604ec54db0e9188a1677ac20388
|
Subproject commit 023c84c4ccf7f38e477253e1b49856bfb50aca18
|
@ -523,8 +523,12 @@ export class JlDrawApp extends GraphicApp implements IDrawApp {
|
|||||||
*/
|
*/
|
||||||
bindFormData(form: GraphicData): void {
|
bindFormData(form: GraphicData): void {
|
||||||
this.formData = form;
|
this.formData = form;
|
||||||
if (this.selectedGraphics.length == 1) {
|
if (this.formData && this.selectedGraphics.length == 1) {
|
||||||
this.formData.copyFrom(this.selectedGraphics[0].saveData());
|
if (this.formData.graphicType == this.selectedGraphics[0].type) {
|
||||||
|
this.formData.copyFrom(this.selectedGraphics[0].saveData());
|
||||||
|
} else {
|
||||||
|
this.formData = undefined;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,7 @@ import {
|
|||||||
WsMsgCli,
|
WsMsgCli,
|
||||||
type AppStateSubscription,
|
type AppStateSubscription,
|
||||||
type MessageCliOption,
|
type MessageCliOption,
|
||||||
|
GraphicQuery,
|
||||||
} from '../message';
|
} from '../message';
|
||||||
import { OperationRecord } from '../operation/JlOperation';
|
import { OperationRecord } from '../operation/JlOperation';
|
||||||
import {
|
import {
|
||||||
@ -472,7 +473,10 @@ export interface IGraphicScene extends EventEmitter<GraphicAppEvents> {
|
|||||||
* 处理图形状态
|
* 处理图形状态
|
||||||
* @param graphicStates
|
* @param graphicStates
|
||||||
*/
|
*/
|
||||||
handleGraphicStates(graphicStates: GraphicState[]): void;
|
handleGraphicStates(
|
||||||
|
graphicStates: GraphicState[],
|
||||||
|
queryer?: GraphicQuery
|
||||||
|
): void;
|
||||||
/**
|
/**
|
||||||
* 根据类型获取图形模板
|
* 根据类型获取图形模板
|
||||||
* @param type
|
* @param type
|
||||||
@ -1083,12 +1087,17 @@ abstract class GraphicSceneBase
|
|||||||
* 处理图形状态
|
* 处理图形状态
|
||||||
* @param graphicStates
|
* @param graphicStates
|
||||||
*/
|
*/
|
||||||
handleGraphicStates(graphicStates: GraphicState[]): void {
|
handleGraphicStates(
|
||||||
|
graphicStates: GraphicState[],
|
||||||
|
queryer?: GraphicQuery
|
||||||
|
): void {
|
||||||
graphicStates.forEach((state) => {
|
graphicStates.forEach((state) => {
|
||||||
const g = this.queryStore.queryByCodeAndType(
|
let g: JlGraphic | undefined;
|
||||||
state.code,
|
if (queryer) {
|
||||||
state.graphicType
|
g = queryer(state, this.queryStore);
|
||||||
);
|
} else {
|
||||||
|
g = this.queryStore.queryByCodeAndType(state.code, state.graphicType);
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (!g) {
|
if (!g) {
|
||||||
const template = this.getGraphicTemplatesByType(state.graphicType);
|
const template = this.getGraphicTemplatesByType(state.graphicType);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
import EventEmitter from 'eventemitter3';
|
import EventEmitter from 'eventemitter3';
|
||||||
import { IGraphicScene } from '../app';
|
import { IGraphicScene } from '../app';
|
||||||
import { GraphicState } from '../core';
|
import { GraphicQueryStore, GraphicState, JlGraphic } from '../core';
|
||||||
import {
|
import {
|
||||||
IMessageHandler,
|
IMessageHandler,
|
||||||
IUnsubscriptor,
|
IUnsubscriptor,
|
||||||
@ -146,6 +146,11 @@ export type GraphicStateMessageConvert = (
|
|||||||
message: Uint8Array
|
message: Uint8Array
|
||||||
) => GraphicState[];
|
) => GraphicState[];
|
||||||
|
|
||||||
|
export type GraphicQuery = (
|
||||||
|
state: GraphicState,
|
||||||
|
store: GraphicQueryStore
|
||||||
|
) => JlGraphic | undefined;
|
||||||
|
|
||||||
// 订阅消息处理器
|
// 订阅消息处理器
|
||||||
export type SubscriptionMessageHandle = (message: Uint8Array) => void;
|
export type SubscriptionMessageHandle = (message: Uint8Array) => void;
|
||||||
|
|
||||||
@ -159,6 +164,10 @@ export interface AppStateSubscription {
|
|||||||
* 图形状态消息转换
|
* 图形状态消息转换
|
||||||
*/
|
*/
|
||||||
messageConverter?: GraphicStateMessageConvert;
|
messageConverter?: GraphicStateMessageConvert;
|
||||||
|
/**
|
||||||
|
* 根据状态查询图形对象,默认为根据code和type查询图形对象
|
||||||
|
*/
|
||||||
|
graphicQueryer?: GraphicQuery;
|
||||||
/**
|
/**
|
||||||
* 订阅消息处理
|
* 订阅消息处理
|
||||||
*/
|
*/
|
||||||
@ -187,7 +196,7 @@ class AppMessageHandler implements IMessageHandler {
|
|||||||
const sub = this.sub;
|
const sub = this.sub;
|
||||||
if (sub.messageConverter) {
|
if (sub.messageConverter) {
|
||||||
const graphicStates = sub.messageConverter(data);
|
const graphicStates = sub.messageConverter(data);
|
||||||
this.app.handleGraphicStates(graphicStates);
|
this.app.handleGraphicStates(graphicStates, sub.graphicQueryer);
|
||||||
} else if (sub.messageHandle) {
|
} else if (sub.messageHandle) {
|
||||||
sub.messageHandle(data);
|
sub.messageHandle(data);
|
||||||
}
|
}
|
||||||
|
@ -4,11 +4,7 @@ import {
|
|||||||
FederatedPointerEvent,
|
FederatedPointerEvent,
|
||||||
Point,
|
Point,
|
||||||
} from 'pixi.js';
|
} from 'pixi.js';
|
||||||
import {
|
import { IGraphicAppConfig, IGraphicScene } from '../app/JlGraphicApp';
|
||||||
IGraphicApp,
|
|
||||||
IGraphicAppConfig,
|
|
||||||
IGraphicScene,
|
|
||||||
} from '../app/JlGraphicApp';
|
|
||||||
import { JlGraphic } from '../core/JlGraphic';
|
import { JlGraphic } from '../core/JlGraphic';
|
||||||
|
|
||||||
export enum InteractionPluginType {
|
export enum InteractionPluginType {
|
||||||
@ -417,10 +413,10 @@ export abstract class GraphicInteractionPlugin<G extends JlGraphic>
|
|||||||
implements InteractionPlugin
|
implements InteractionPlugin
|
||||||
{
|
{
|
||||||
readonly _type = InteractionPluginType.Graphic;
|
readonly _type = InteractionPluginType.Graphic;
|
||||||
app: IGraphicApp;
|
app: IGraphicScene;
|
||||||
name: string; // 唯一标识
|
name: string; // 唯一标识
|
||||||
_pause: boolean;
|
_pause: boolean;
|
||||||
constructor(name: string, app: IGraphicApp) {
|
constructor(name: string, app: IGraphicScene) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this._pause = true;
|
this._pause = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user