Add all group all range build in label
This commit is contained in:
@@ -5,6 +5,11 @@ import { ObjectID } from "./Renderer";
|
||||
* 数据标签
|
||||
*/
|
||||
class Label {
|
||||
|
||||
/**
|
||||
* 是否为内置标签
|
||||
*/
|
||||
public isBuildIn: boolean = false;
|
||||
|
||||
/**
|
||||
* 唯一标识符
|
||||
@@ -54,12 +59,21 @@ class Label {
|
||||
*/
|
||||
public isDeleted(): boolean {
|
||||
if (this.deleteFlag) return true;
|
||||
if (this.isBuildIn) return false;
|
||||
for (let i = 0; i < this.model.labelPool.length; i++) {
|
||||
if (this.model.labelPool[i].equal(this)) return false;
|
||||
}
|
||||
this.deleteFlag = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置为内置标签
|
||||
*/
|
||||
public setBuildInLabel(): this {
|
||||
this.isBuildIn = true;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+22
-14
@@ -51,6 +51,16 @@ class Model extends Emitter<ModelEvent> {
|
||||
*/
|
||||
public labelPool: Label[] = [];
|
||||
|
||||
/**
|
||||
* 内置标签-全部范围标签
|
||||
*/
|
||||
public allRangeLabel = new Label(this, "AllRange").setBuildInLabel();
|
||||
|
||||
/**
|
||||
* 内置标签-全部群标签
|
||||
*/
|
||||
public allGroupLabel = new Label(this, "AllGroup").setBuildInLabel();
|
||||
|
||||
/**
|
||||
* 添加标签
|
||||
*/
|
||||
@@ -94,23 +104,21 @@ class Model extends Emitter<ModelEvent> {
|
||||
/**
|
||||
* 通过标签获取指定类型的对象
|
||||
* @param label 标签
|
||||
* @param type 筛选类型
|
||||
*/
|
||||
public getObjectByLabel(
|
||||
label: Label, type?:
|
||||
(new (...p: any) => Range) |
|
||||
(new (...p: any) => Group)
|
||||
): CtrlObject[] {
|
||||
public getObjectByLabel(label: Label): 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]);
|
||||
}
|
||||
|
||||
if (label.equal(this.allGroupLabel) && this.objectPool[i] instanceof Group) {
|
||||
res.push(this.objectPool[i]);
|
||||
}
|
||||
|
||||
else if (label.equal(this.allRangeLabel) && this.objectPool[i] instanceof Range) {
|
||||
res.push(this.objectPool[i]);
|
||||
}
|
||||
|
||||
else if (this.objectPool[i].hasLabel(label)) {
|
||||
res.push(this.objectPool[i]);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user