//引线标签
|
|
//业务标注引线标签id列表
|
let _logicMarkLeadLabelIds = new Set();
|
|
//设置业务标注引线标签
|
function setLogicMarkLeadLabels(obj) {
|
initialDrawableContainer();
|
clearLogicMarkLeadLabels();
|
if (obj == null || obj.length < 1) {
|
return;
|
}
|
obj.forEach(item => {
|
addLogicMarkLeadLabel(item);
|
});
|
}
|
|
//添加业务标注引线标签
|
function addLogicMarkLeadLabel(item) {
|
if (_drawableContainer == null) {
|
return;
|
}
|
//引线标签的配置类
|
let leadLabelConfig = new Glodon.Bimface.Plugins.Drawable.LeadLabelConfig();
|
//引线折点的相对位置
|
leadLabelConfig.offset = { x: 27, y: -47 };
|
//引线标签的内容
|
leadLabelConfig.text = item.text;
|
//引线标签关联的构件
|
leadLabelConfig.objectId = item.id;
|
leadLabelConfig.visibleDistance = item.distance;
|
leadLabelConfig.id = "LogicMarkLeadLabel" + item.id;
|
_logicMarkLeadLabelIds.add(leadLabelConfig.id);
|
|
let boundingBox = _modeler.getBoundingBoxById(item.id);
|
let boundingBoxMin = boundingBox.min;
|
let boundingBoxMax = boundingBox.max;
|
//引线标签的世界坐标
|
leadLabelConfig.worldPosition = {
|
x: (boundingBoxMin.x + boundingBoxMax.x) / 2,
|
y: (boundingBoxMin.y + boundingBoxMax.y) / 2,
|
z: (boundingBoxMin.z + boundingBoxMax.z) / 2
|
};
|
//引线标签是否可拖拽
|
leadLabelConfig.draggable = false;
|
//引线标签的视图
|
leadLabelConfig.viewer = _viewer;
|
//文本自适应
|
leadLabelConfig.width = null;
|
|
let leadLabel = new Glodon.Bimface.Plugins.Drawable.LeadLabel(leadLabelConfig);
|
_drawableContainer.addItem(leadLabel);
|
}
|
|
//清除业务标注引线标签
|
function clearLogicMarkLeadLabels() {
|
if (_drawableContainer == null) {
|
return;
|
}
|
if (_logicMarkLeadLabelIds.size > 0) {
|
_logicMarkLeadLabelIds.forEach(x => _drawableContainer.removeItemById(x));
|
_logicMarkLeadLabelIds.clear();
|
}
|
}
|