Change object id into uuid
This commit is contained in:
parent
a788968525
commit
a2b1819dd8
92
package-lock.json
generated
92
package-lock.json
generated
@ -15,13 +15,15 @@
|
||||
"express": "^4.17.3",
|
||||
"gl-matrix": "^3.4.3",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
"react-dom": "^17.0.2",
|
||||
"uuid": "^8.3.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@atao60/fse-cli": "^0.1.7",
|
||||
"@types/detect-port": "^1.3.2",
|
||||
"@types/react": "^17.0.38",
|
||||
"@types/react-dom": "^17.0.11",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"autoprefixer": "^10.4.2",
|
||||
"css-loader": "^6.5.1",
|
||||
"electron": "^18.0.4",
|
||||
@ -1273,6 +1275,12 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/uuid": {
|
||||
"version": "8.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz",
|
||||
"integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/ws": {
|
||||
"version": "8.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.0.tgz",
|
||||
@ -1737,9 +1745,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/async": {
|
||||
"version": "2.6.3",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz",
|
||||
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==",
|
||||
"version": "2.6.4",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
|
||||
"integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.14"
|
||||
@ -5214,9 +5222,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/node-forge": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.2.1.tgz",
|
||||
"integrity": "sha512-Fcvtbb+zBcZXbTTVwqGA5W+MKBj56UjVRevvchv5XrcyXbmNdesfZL37nlcWOfpgHhgmxApw3tQbTr4CqNmX4w==",
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz",
|
||||
"integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": ">= 6.13.0"
|
||||
@ -6354,6 +6362,16 @@
|
||||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/request/node_modules/uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"uuid": "bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/require-directory": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
|
||||
@ -6937,15 +6955,6 @@
|
||||
"websocket-driver": "^0.7.4"
|
||||
}
|
||||
},
|
||||
"node_modules/sockjs/node_modules/uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/socks": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/socks/-/socks-2.6.2.tgz",
|
||||
@ -7628,13 +7637,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.",
|
||||
"dev": true,
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||
"bin": {
|
||||
"uuid": "bin/uuid"
|
||||
"uuid": "dist/bin/uuid"
|
||||
}
|
||||
},
|
||||
"node_modules/validate-npm-package-license": {
|
||||
@ -9238,6 +9245,12 @@
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/uuid": {
|
||||
"version": "8.3.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz",
|
||||
"integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/ws": {
|
||||
"version": "8.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.0.tgz",
|
||||
@ -9620,9 +9633,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"async": {
|
||||
"version": "2.6.3",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-2.6.3.tgz",
|
||||
"integrity": "sha512-zflvls11DCy+dQWzTW2dzuilv8Z5X/pjfmZOWba6TNIVDm+2UDaJmXSOXlasHKfNBs8oo3M0aT50fDEWfKZjXg==",
|
||||
"version": "2.6.4",
|
||||
"resolved": "https://registry.npmjs.org/async/-/async-2.6.4.tgz",
|
||||
"integrity": "sha512-mzo5dfJYwAn29PeiJ0zvwTo04zj8HDJj0Mn8TD7sno7q12prdbnasKJHhkm2c1LgrhlJ0teaea8860oxi51mGA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lodash": "^4.17.14"
|
||||
@ -12326,9 +12339,9 @@
|
||||
}
|
||||
},
|
||||
"node-forge": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.2.1.tgz",
|
||||
"integrity": "sha512-Fcvtbb+zBcZXbTTVwqGA5W+MKBj56UjVRevvchv5XrcyXbmNdesfZL37nlcWOfpgHhgmxApw3tQbTr4CqNmX4w==",
|
||||
"version": "1.3.1",
|
||||
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-1.3.1.tgz",
|
||||
"integrity": "sha512-dPEtOeMvF9VMcYV/1Wb8CPoVAXtp6MKMlcbAt4ddqmGqUJ6fQZFXkNZNkNlfevtNkGtaSoXf/vNNNSvgrdXwtA==",
|
||||
"dev": true
|
||||
},
|
||||
"node-gyp": {
|
||||
@ -13181,6 +13194,14 @@
|
||||
"tough-cookie": "~2.5.0",
|
||||
"tunnel-agent": "^0.6.0",
|
||||
"uuid": "^3.3.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"require-directory": {
|
||||
@ -13619,14 +13640,6 @@
|
||||
"faye-websocket": "^0.11.3",
|
||||
"uuid": "^8.3.2",
|
||||
"websocket-driver": "^0.7.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"uuid": {
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"socks": {
|
||||
@ -14161,10 +14174,9 @@
|
||||
"integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM="
|
||||
},
|
||||
"uuid": {
|
||||
"version": "3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz",
|
||||
"integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==",
|
||||
"dev": true
|
||||
"version": "8.3.2",
|
||||
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
|
||||
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg=="
|
||||
},
|
||||
"validate-npm-package-license": {
|
||||
"version": "3.0.4",
|
||||
|
@ -49,6 +49,7 @@
|
||||
"@types/detect-port": "^1.3.2",
|
||||
"@types/react": "^17.0.38",
|
||||
"@types/react-dom": "^17.0.11",
|
||||
"@types/uuid": "^8.3.4",
|
||||
"autoprefixer": "^10.4.2",
|
||||
"css-loader": "^6.5.1",
|
||||
"electron": "^18.0.4",
|
||||
@ -72,6 +73,7 @@
|
||||
"express": "^4.17.3",
|
||||
"gl-matrix": "^3.4.3",
|
||||
"react": "^17.0.2",
|
||||
"react-dom": "^17.0.2"
|
||||
"react-dom": "^17.0.2",
|
||||
"uuid": "^8.3.2"
|
||||
}
|
||||
}
|
||||
|
@ -117,10 +117,26 @@ class BehaviorPopupComponent extends Component<
|
||||
if (this.props.status && recorder instanceof BehaviorRecorder) {
|
||||
let newBehavior = this.props.status.model.addBehavior(recorder);
|
||||
|
||||
// 初始化名字
|
||||
newBehavior.name = recorder.getTerms(
|
||||
// 根据用户的命名搜索下一个名字
|
||||
let searchKey = recorder.getTerms(
|
||||
recorder.behaviorName, this.props.setting?.language
|
||||
) + " " + (recorder.nameIndex - 1).toString();
|
||||
);
|
||||
|
||||
let nextIndex = 1;
|
||||
this.props.status.model.behaviorPool.forEach((obj) => {
|
||||
if (obj.behaviorId === recorder.behaviorId && obj.name.indexOf(searchKey) >= 0) {
|
||||
let searchRes = obj.name.match(/(\d+)$/);
|
||||
if (searchRes) {
|
||||
let nameNumber = parseInt(searchRes[1]);
|
||||
if (!isNaN(nameNumber)) {
|
||||
nextIndex = Math.max(nextIndex, nameNumber + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 初始化名字
|
||||
newBehavior.name = `${searchKey} ${nextIndex}`;
|
||||
|
||||
// 赋予一个随机颜色
|
||||
newBehavior.color = randomColor(true);
|
||||
|
@ -56,12 +56,6 @@ class Status extends Emitter<IStatusEvent> {
|
||||
|
||||
public setting: Setting = undefined as any;
|
||||
|
||||
/**
|
||||
* 对象命名
|
||||
*/
|
||||
public objectNameIndex = 1;
|
||||
public labelNameIndex = 1;
|
||||
|
||||
/**
|
||||
* 渲染器
|
||||
*/
|
||||
@ -300,34 +294,72 @@ class Status extends Emitter<IStatusEvent> {
|
||||
*/
|
||||
public mouseMod: MouseMod = MouseMod.Drag;
|
||||
|
||||
private readonly SEARCH_NAME_KEY_REG = /(\d+)$/;
|
||||
private getNextNumber(name: string, searchKey: string): number {
|
||||
if (name.indexOf(searchKey) < 0) return 1;
|
||||
let searchRes = name.match(this.SEARCH_NAME_KEY_REG);
|
||||
if (searchRes) {
|
||||
let nameNumber = parseInt(searchRes[1]);
|
||||
if (isNaN(nameNumber)) {
|
||||
return 1;
|
||||
} else {
|
||||
return nameNumber + 1;
|
||||
}
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
public newGroup() {
|
||||
const group = this.model.addGroup();
|
||||
group.color = randomColor();
|
||||
group.displayName = I18N(this.setting.language, "Object.List.New.Group", {
|
||||
id: this.objectNameIndex.toString()
|
||||
let searchKey = I18N(this.setting.language, "Object.List.New.Group", { id: "" });
|
||||
let nextIndex = 1;
|
||||
this.model.objectPool.forEach((obj) => {
|
||||
if (obj instanceof Group) {
|
||||
nextIndex = Math.max(nextIndex, this.getNextNumber(
|
||||
obj.displayName, searchKey
|
||||
));
|
||||
}
|
||||
});
|
||||
group.displayName = I18N(this.setting.language, "Object.List.New.Group", {
|
||||
id: nextIndex.toString()
|
||||
});
|
||||
this.objectNameIndex ++;
|
||||
return group;
|
||||
}
|
||||
|
||||
public newRange() {
|
||||
const range = this.model.addRange();
|
||||
range.color = randomColor();
|
||||
range.displayName = I18N(this.setting.language, "Object.List.New.Range", {
|
||||
id: this.objectNameIndex.toString()
|
||||
let searchKey = I18N(this.setting.language, "Object.List.New.Range", { id: "" });
|
||||
let nextIndex = 1;
|
||||
this.model.objectPool.forEach((obj) => {
|
||||
if (obj instanceof Range) {
|
||||
nextIndex = Math.max(nextIndex, this.getNextNumber(
|
||||
obj.displayName, searchKey
|
||||
));
|
||||
}
|
||||
});
|
||||
range.displayName = I18N(this.setting.language, "Object.List.New.Range", {
|
||||
id: nextIndex.toString()
|
||||
});
|
||||
this.objectNameIndex ++;
|
||||
return range;
|
||||
}
|
||||
|
||||
public newLabel() {
|
||||
let searchKey = I18N(this.setting.language, "Object.List.New.Label", { id: "" });
|
||||
let nextIndex = 1;
|
||||
this.model.labelPool.forEach((obj) => {
|
||||
nextIndex = Math.max(nextIndex, this.getNextNumber(
|
||||
obj.name, searchKey
|
||||
));
|
||||
});
|
||||
const label = this.model.addLabel(
|
||||
I18N(this.setting.language, "Object.List.New.Label", {
|
||||
id: this.labelNameIndex.toString()
|
||||
id: nextIndex.toString()
|
||||
})
|
||||
);
|
||||
label.color = randomColor(true);
|
||||
this.labelNameIndex ++;
|
||||
return label;
|
||||
}
|
||||
|
||||
|
@ -36,9 +36,6 @@ class Archive<
|
||||
*/
|
||||
public save(model: Model): string {
|
||||
let fileData: Record<string, any> = {};
|
||||
|
||||
// 保存 Next ID
|
||||
fileData.idIndex = model.idIndex;
|
||||
|
||||
// 保存对象
|
||||
fileData.objects = [];
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { Emitter, EventType } from "@Model/Emitter";
|
||||
import { v4 as uuid } from "uuid";
|
||||
import type { Individual } from "@Model/Individual";
|
||||
import type { Group } from "@Model/Group";
|
||||
import type { Model } from "@Model/Model";
|
||||
@ -10,7 +11,7 @@ import { getDefaultValue, IParameter, IParameterOption, IParameterValue } from "
|
||||
type IBehaviorConstructor<
|
||||
P extends IParameter = {},
|
||||
E extends Record<EventType, any> = {}
|
||||
> = new (id: string, parameter: IParameterValue<P>) => Behavior<P, E>;
|
||||
> = new (parameter: IParameterValue<P>) => Behavior<P, E>;
|
||||
|
||||
type IAnyBehavior = Behavior<any, any>;
|
||||
type IAnyBehaviorRecorder = BehaviorRecorder<any, any>;
|
||||
@ -76,18 +77,6 @@ class BehaviorRecorder<
|
||||
E extends Record<EventType, any> = {}
|
||||
> extends BehaviorInfo<{}> {
|
||||
|
||||
/**
|
||||
* 命名序号
|
||||
*/
|
||||
public nameIndex: number = 0;
|
||||
|
||||
/**
|
||||
* 获取下一个 ID
|
||||
*/
|
||||
public getNextId() {
|
||||
return `B-${this.behaviorId}-${this.nameIndex ++}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 行为类型
|
||||
*/
|
||||
@ -107,13 +96,13 @@ class BehaviorRecorder<
|
||||
* 创建一个新的行为实例
|
||||
*/
|
||||
public new(): Behavior<P, E> {
|
||||
return new this.behavior(this.getNextId(), getDefaultValue(this.parameterOption));
|
||||
return new this.behavior(getDefaultValue(this.parameterOption));
|
||||
}
|
||||
|
||||
public constructor(behavior: IBehaviorConstructor<P, E>) {
|
||||
super();
|
||||
this.behavior = behavior;
|
||||
this.behaviorInstance = new this.behavior(this.getNextId(), {} as any);
|
||||
this.behaviorInstance = new this.behavior({} as any);
|
||||
this.parameterOption = this.behaviorInstance.parameterOption;
|
||||
this.iconName = this.behaviorInstance.iconName;
|
||||
this.behaviorId = this.behaviorInstance.behaviorId;
|
||||
@ -168,9 +157,9 @@ class Behavior<
|
||||
*/
|
||||
public parameterOption: IParameterOption<P> = {} as any;
|
||||
|
||||
public constructor(id: string, parameter: IParameterValue<P>) {
|
||||
public constructor(parameter: IParameterValue<P>) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.id = uuid();
|
||||
this.parameter = parameter;
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { LabelObject } from "@Model/Label"
|
||||
import { v4 as uuid } from "uuid";
|
||||
import type { IAnyObject, Model } from "@Model/Model";
|
||||
import type { ObjectID } from "@Model/Model";
|
||||
|
||||
@ -45,10 +46,10 @@ class CtrlObject extends LabelObject {
|
||||
/**
|
||||
* 构造器
|
||||
*/
|
||||
public constructor(model: Model, id: ObjectID) {
|
||||
public constructor(model: Model) {
|
||||
super();
|
||||
this.model = model;
|
||||
this.id = id;
|
||||
this.id = uuid();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -407,9 +407,9 @@ class Group extends CtrlObject {
|
||||
return dataBuffer;
|
||||
}
|
||||
|
||||
public constructor(model: Model, id: ObjectID) {
|
||||
public constructor(model: Model) {
|
||||
|
||||
super(model, id);
|
||||
super(model);
|
||||
|
||||
if (model.renderer) {
|
||||
this.renderParameter = getDefaultValue(model.renderer.pointsParameterOption);
|
||||
|
@ -1,4 +1,5 @@
|
||||
import type { Model, ObjectID } from "@Model/Model";
|
||||
import { v4 as uuid } from "uuid";
|
||||
|
||||
/**
|
||||
* 数据标签
|
||||
@ -35,9 +36,9 @@ class Label {
|
||||
* @param id 标签 ID
|
||||
* @param name 用户定义的名称
|
||||
*/
|
||||
public constructor(model: Model, id: ObjectID, name?: string) {
|
||||
public constructor(model: Model, name?: string) {
|
||||
this.model = model;
|
||||
this.id = id;
|
||||
this.id = uuid();
|
||||
this.name = name ?? this.name;
|
||||
}
|
||||
|
||||
|
@ -2,9 +2,8 @@ import { Label } from "@Model/Label";
|
||||
import { Group } from "@Model/Group";
|
||||
import { Range } from "@Model/Range";
|
||||
import { IParamValue } from "@Model/Parameter";
|
||||
import { Individual } from "@Model/Individual";
|
||||
import { CtrlObject } from "@Model/CtrlObject";
|
||||
import { Emitter, EventType, EventMixin } from "@Model/Emitter";
|
||||
import { Emitter } from "@Model/Emitter";
|
||||
import { AbstractRenderer } from "@Model/Renderer";
|
||||
import { Behavior, IAnyBehavior, IAnyBehaviorRecorder } from "@Model/Behavior";
|
||||
|
||||
@ -30,14 +29,6 @@ type ModelEvent = {
|
||||
*/
|
||||
class Model extends Emitter<ModelEvent> {
|
||||
|
||||
/**
|
||||
* 下一个需要分配的 ID
|
||||
*/
|
||||
public idIndex: number = 1;
|
||||
public nextId(label: string = "U"): string {
|
||||
return `${label}-${this.idIndex ++}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对象列表
|
||||
*/
|
||||
@ -75,10 +66,10 @@ class Model extends Emitter<ModelEvent> {
|
||||
* 添加标签
|
||||
*/
|
||||
public addLabel(name: string): Label {
|
||||
console.log(`Model: Creat label with id ${this.idIndex}`);
|
||||
let label = new Label(this, this.nextId("L"), name);
|
||||
let label = new Label(this, name);
|
||||
this.labelPool.push(label);
|
||||
this.emit("labelChange", this.labelPool);
|
||||
console.log(`Model: Creat label with id ${label.id}`);
|
||||
return label;
|
||||
}
|
||||
|
||||
@ -140,10 +131,10 @@ class Model extends Emitter<ModelEvent> {
|
||||
* 添加组
|
||||
*/
|
||||
public addGroup(): Group {
|
||||
console.log(`Model: Creat group with id ${this.idIndex}`);
|
||||
let group = new Group(this, this.nextId("G"));
|
||||
let group = new Group(this);
|
||||
this.objectPool.push(group);
|
||||
this.emit("objectChange", this.objectPool);
|
||||
console.log(`Model: Creat group with id ${group.id}`);
|
||||
return group;
|
||||
}
|
||||
|
||||
@ -151,10 +142,10 @@ class Model extends Emitter<ModelEvent> {
|
||||
* 添加范围
|
||||
*/
|
||||
public addRange(): Range {
|
||||
console.log(`Model: Creat range with id ${this.idIndex}`);
|
||||
let range = new Range(this, this.nextId("R"));
|
||||
let range = new Range(this);
|
||||
this.objectPool.push(range);
|
||||
this.emit("objectChange", this.objectPool);
|
||||
console.log(`Model: Creat range with id ${range.id}`);
|
||||
return range;
|
||||
}
|
||||
|
||||
@ -393,14 +384,4 @@ class Model extends Emitter<ModelEvent> {
|
||||
}
|
||||
}
|
||||
|
||||
export {
|
||||
Individual,
|
||||
Group,
|
||||
Emitter,
|
||||
EventType,
|
||||
EventMixin,
|
||||
Model,
|
||||
CtrlObject,
|
||||
ObjectID,
|
||||
IAnyObject
|
||||
}
|
||||
export { Model, ObjectID, IAnyObject }
|
@ -17,9 +17,9 @@ class Range extends CtrlObject {
|
||||
*/
|
||||
public radius: number[] = [1, 1, 1];
|
||||
|
||||
public constructor(model: Model, id: ObjectID) {
|
||||
public constructor(model: Model) {
|
||||
|
||||
super(model, id);
|
||||
super(model);
|
||||
|
||||
if (model.renderer) {
|
||||
this.renderParameter = getDefaultValue(model.renderer.cubeParameterOption);
|
||||
|
@ -4,6 +4,8 @@ import { useSetting, IMixinSettingProps } from "@Context/Setting";
|
||||
import { Localization } from "@Component/Localization/Localization";
|
||||
import { DetailsList } from "@Component/DetailsList/DetailsList";
|
||||
import { ObjectID } from "@Model/Model";
|
||||
import { Group } from "@Model/Group";
|
||||
import { Range } from "@Model/Range";
|
||||
import { Icon } from "@fluentui/react";
|
||||
import "./ObjectList.scss";
|
||||
|
||||
@ -24,12 +26,21 @@ class ObjectList extends Component<IMixinStatusProps & IMixinSettingProps> {
|
||||
return <DetailsList
|
||||
className="object-list"
|
||||
items={objList.concat([]).map((object => {
|
||||
|
||||
let objectType = "";
|
||||
if (object instanceof Group) {
|
||||
objectType = "G";
|
||||
} else if (object instanceof Range) {
|
||||
objectType = "R";
|
||||
}
|
||||
|
||||
return {
|
||||
key: object.id.toString(),
|
||||
name: object.displayName,
|
||||
color: object.color,
|
||||
display: object.display,
|
||||
update: object.update,
|
||||
type: objectType,
|
||||
select: this.props.status ?
|
||||
this.props.status.focusObject.has(object.id.toString()) ||
|
||||
this.props.status.focusObject.has(object.id) :
|
||||
@ -41,10 +52,10 @@ class ObjectList extends Component<IMixinStatusProps & IMixinSettingProps> {
|
||||
this.props.status.setFocusObject(new Set<ObjectID>().add(item.key));
|
||||
}
|
||||
if (this.props.setting) {
|
||||
if (item.key.slice(0, 1) === "R") {
|
||||
if (item.type === "R") {
|
||||
this.props.setting.layout.focus("RangeDetails");
|
||||
}
|
||||
if (item.key.slice(0, 1) === "G") {
|
||||
else if (item.type === "G") {
|
||||
this.props.setting.layout.focus("GroupDetails");
|
||||
}
|
||||
this.props.setting.layout.focus("ObjectList");
|
||||
@ -71,13 +82,13 @@ class ObjectList extends Component<IMixinStatusProps & IMixinSettingProps> {
|
||||
}}
|
||||
renderCheckbox={(item, click) => {
|
||||
let icon = "CheckMark";
|
||||
if (item.key.slice(0, 1) === "R") {
|
||||
if (item.type === "R") {
|
||||
icon = "CubeShape";
|
||||
}
|
||||
if (item.key.slice(0, 1) === "G") {
|
||||
else if (item.type === "G") {
|
||||
icon = "WebAppBuilderFragment";
|
||||
}
|
||||
return <div
|
||||
return <div
|
||||
className="object-list-checkbox details-list-checkbox"
|
||||
onClick={click}
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user