Add range object archive function
This commit is contained in:
parent
597c7e9493
commit
1d36aac37d
@ -109,7 +109,7 @@ class CtrlObject extends LabelObject {
|
||||
return this.deleteFlag;
|
||||
}
|
||||
|
||||
public toArchive(): IArchiveCtrlObject {
|
||||
public toArchive<T>(): IArchiveCtrlObject & T {
|
||||
return {
|
||||
displayName: this.displayName,
|
||||
color: this.color.concat([]),
|
||||
@ -118,10 +118,10 @@ class CtrlObject extends LabelObject {
|
||||
id: this.id,
|
||||
renderParameter: parameter2ArchiveObject(this.renderParameter),
|
||||
deleteFlag: !!this.deleteFlag
|
||||
};
|
||||
} as any;
|
||||
}
|
||||
|
||||
public fromArchive(archive: IArchiveCtrlObject, paster?: IArchiveParseFn): void {
|
||||
public fromArchive<T>(archive: IArchiveCtrlObject & T, paster?: IArchiveParseFn): void {
|
||||
this.displayName = archive.displayName;
|
||||
this.color = archive.color.concat([]);
|
||||
this.display = !!archive.display;
|
||||
|
@ -1,6 +1,11 @@
|
||||
import { CtrlObject } from "@Model/CtrlObject";
|
||||
import { Model, ObjectID } from "@Model/Model";
|
||||
import { getDefaultValue } from "@Model/Parameter";
|
||||
import { CtrlObject, IArchiveCtrlObject } from "@Model/CtrlObject";
|
||||
import { Model } from "@Model/Model";
|
||||
import { getDefaultValue, IArchiveParseFn, parameter2ArchiveObject } from "@Model/Parameter";
|
||||
|
||||
interface IArchiveRange {
|
||||
position: Range["position"];
|
||||
radius: Range["radius"];
|
||||
}
|
||||
|
||||
/**
|
||||
* 范围
|
||||
@ -26,7 +31,20 @@ class Range extends CtrlObject {
|
||||
}
|
||||
}
|
||||
|
||||
public override toArchive<T>(): IArchiveCtrlObject & T {
|
||||
return {
|
||||
...super.toArchive(),
|
||||
position: this.position.concat([]),
|
||||
radius: this.radius.concat([])
|
||||
};
|
||||
}
|
||||
|
||||
public override fromArchive<T>(archive: IArchiveCtrlObject & T, paster?: IArchiveParseFn): void {
|
||||
super.fromArchive(archive, paster);
|
||||
this.position = (archive as any).position.concat([]),
|
||||
this.radius = (archive as any).radius.concat([])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Range;
|
||||
export { Range };
|
||||
export { Range, IArchiveRange };
|
Loading…
Reference in New Issue
Block a user