同步代码

This commit is contained in:
fan 2023-06-20 11:06:00 +08:00
parent 8082948b65
commit d57b7bdbfa
4 changed files with 35 additions and 7 deletions

@ -1 +1 @@
Subproject commit 6d905a2fbeca5e52b94df9a4a29282828e9a679b
Subproject commit 33ac26a8259c7a1b247612e826861bc8a183d4c9

View File

@ -45,7 +45,6 @@ export abstract class GraphicDrawAssistant<
icon: string; // 界面显示的图标
container: Container = new Container();
graphicTemplate: GT;
createGraphicData: () => GD;
escListener: KeyListener = new KeyListener({
value: 'Escape',
@ -61,7 +60,6 @@ export abstract class GraphicDrawAssistant<
constructor(
graphicApp: JlDrawApp,
graphicTemplate: GT,
createGraphicData: () => GD,
icon: string,
description: string
) {
@ -69,7 +67,6 @@ export abstract class GraphicDrawAssistant<
this.app = graphicApp;
this.type = graphicTemplate.type;
this.graphicTemplate = graphicTemplate;
this.createGraphicData = createGraphicData;
this.icon = icon;
this.description = description;
this.app.registerGraphicTemplates(this.graphicTemplate);
@ -163,7 +160,7 @@ export abstract class GraphicDrawAssistant<
* App
*/
createAndStore(finish: boolean): JlGraphic | null {
const data = this.createGraphicData();
const data = this.graphicTemplate.datas as GD;
data.id = this.nextId();
data.graphicType = this.graphicTemplate.type;
if (!this.prepareData(data)) {

View File

@ -923,15 +923,47 @@ export abstract class JlGraphic extends Container {
}
}
export type CreateData = () => GraphicData;
export type CreateState = () => GraphicState;
export interface IGraphicTemplateOptions {
dataTemplate?: GraphicData;
stateTemplate?: GraphicState;
}
/**
*
*/
export abstract class JlGraphicTemplate<G extends JlGraphic> {
readonly type: string;
options: IGraphicTemplateOptions;
constructor(type: string) {
constructor(type: string, options: IGraphicTemplateOptions) {
this.type = type;
this.options = options;
}
get datas(): GraphicData {
if (this.options.dataTemplate) {
return this.options.dataTemplate.clone();
}
throw new Error(`type=${this.type}的图形模板没有数据模板`);
}
get states(): GraphicState {
if (this.options.stateTemplate) {
return this.options.stateTemplate.clone();
}
throw new Error(`type=${this.type}的图形模板没有状态模板`);
}
// getDataCreator<T extends CreateData>(): T {
// return this.options.dataCreator as T;
// }
// getStateCreator<T extends CreateState>(): T {
// return this.options.stateCreator as T;
// }
/**
*
*/

View File

@ -10,7 +10,6 @@ import {
import { JlGraphic } from '../core';
import { DraggablePoint } from '../graphic';
import {
assertBezierPoints,
calculateDistanceFromPointToLine,
calculateFootPointFromPointToLine,
calculateLineSegmentingPoint,