graphics框架更新
This commit is contained in:
parent
f980c4f557
commit
d96778aa7a
110
src/jl-graphic/app/BasicOperation.ts
Normal file
110
src/jl-graphic/app/BasicOperation.ts
Normal file
@ -0,0 +1,110 @@
|
||||
import { GraphicData, JlGraphic } from '../core';
|
||||
import { JlOperation } from '../operation';
|
||||
import { ICanvasProperties, IGraphicApp, IJlCanvas } from './JlGraphicApp';
|
||||
|
||||
/**
|
||||
* 更新画布操作
|
||||
*/
|
||||
export class UpdateCanvasOperation extends JlOperation {
|
||||
obj: IJlCanvas;
|
||||
old: ICanvasProperties;
|
||||
data: ICanvasProperties;
|
||||
description = '';
|
||||
|
||||
constructor(
|
||||
app: IGraphicApp,
|
||||
obj: IJlCanvas,
|
||||
old: ICanvasProperties,
|
||||
data: ICanvasProperties
|
||||
) {
|
||||
super(app, 'update-canvas');
|
||||
this.app = app;
|
||||
this.obj = obj;
|
||||
this.old = old;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
undo(): JlGraphic[] {
|
||||
this.obj.update(this.old);
|
||||
return [];
|
||||
}
|
||||
redo(): JlGraphic[] {
|
||||
this.obj.update(this.data);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 创建图形操作
|
||||
*/
|
||||
export class GraphicCreateOperation extends JlOperation {
|
||||
obj: JlGraphic[];
|
||||
description = '';
|
||||
|
||||
constructor(app: IGraphicApp, obj: JlGraphic[]) {
|
||||
super(app, 'graphic-create');
|
||||
this.app = app;
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
undo(): JlGraphic[] | void {
|
||||
this.app.deleteGraphics(...this.obj);
|
||||
}
|
||||
redo(): JlGraphic[] {
|
||||
this.app.addGraphics(...this.obj);
|
||||
return this.obj;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 删除图形操作
|
||||
*/
|
||||
export class GraphicDeleteOperation extends JlOperation {
|
||||
obj: JlGraphic[];
|
||||
|
||||
constructor(app: IGraphicApp, obj: JlGraphic[]) {
|
||||
super(app, 'graphic-delete');
|
||||
this.app = app;
|
||||
this.obj = obj;
|
||||
}
|
||||
|
||||
undo(): JlGraphic[] {
|
||||
this.app.addGraphics(...this.obj);
|
||||
return this.obj;
|
||||
}
|
||||
redo(): void {
|
||||
this.app.deleteGraphics(...this.obj);
|
||||
}
|
||||
}
|
||||
|
||||
export class GraphicDataUpdateOperation extends JlOperation {
|
||||
obj: JlGraphic[];
|
||||
oldData: GraphicData[];
|
||||
newData: GraphicData[];
|
||||
constructor(
|
||||
app: IGraphicApp,
|
||||
obj: JlGraphic[],
|
||||
oldData: GraphicData[],
|
||||
newData: GraphicData[]
|
||||
) {
|
||||
super(app, 'graphic-drag');
|
||||
this.obj = [...obj];
|
||||
this.oldData = oldData;
|
||||
this.newData = newData;
|
||||
}
|
||||
|
||||
undo(): void | JlGraphic[] {
|
||||
for (let i = 0; i < this.obj.length; i++) {
|
||||
const g = this.obj[i];
|
||||
// g.exitChildEdit();
|
||||
g.updateData(this.oldData[i]);
|
||||
}
|
||||
return this.obj;
|
||||
}
|
||||
redo(): void | JlGraphic[] {
|
||||
for (let i = 0; i < this.obj.length; i++) {
|
||||
const g = this.obj[i];
|
||||
// g.exitChildEdit();
|
||||
g.updateData(this.newData[i]);
|
||||
}
|
||||
return this.obj;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user