Add get object by label function into model
This commit is contained in:
parent
d07a20d8fe
commit
66102a9936
@ -90,6 +90,31 @@ class Model extends Emitter<ModelEvent> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过标签获取指定类型的对象
|
||||||
|
* @param label 标签
|
||||||
|
* @param type 筛选类型
|
||||||
|
*/
|
||||||
|
public getObjectByLabel(
|
||||||
|
label: Label, type?:
|
||||||
|
(new (...p: any) => Range) |
|
||||||
|
(new (...p: any) => Group)
|
||||||
|
): CtrlObject[] {
|
||||||
|
const res: CtrlObject[] = [];
|
||||||
|
for (let i = 0; i < this.objectPool.length; i++) {
|
||||||
|
if (this.objectPool[i].hasLabel(label)) {
|
||||||
|
if (type) {
|
||||||
|
if (this.objectPool[i] instanceof type) {
|
||||||
|
res.push(this.objectPool[i]);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res.push(this.objectPool[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加组
|
* 添加组
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user