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