From 72b770d62693b342c19975b7e5381d988a095359 Mon Sep 17 00:00:00 2001 From: "lj7788@126.com" Date: Sat, 28 Jun 2025 16:30:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E8=AE=A1=E5=88=92=E7=BB=91?= =?UTF-8?q?=E5=AE=9ABIM?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/manage/plan/bimSelectTools.js | 190 ++++++++++++++++-- .../views/manage/plan/bimSelectionDialog.vue | 156 ++++++++++---- 2 files changed, 289 insertions(+), 57 deletions(-) diff --git a/yanzhu-ui-vue3/src/views/manage/plan/bimSelectTools.js b/yanzhu-ui-vue3/src/views/manage/plan/bimSelectTools.js index f771a550..7752fda8 100644 --- a/yanzhu-ui-vue3/src/views/manage/plan/bimSelectTools.js +++ b/yanzhu-ui-vue3/src/views/manage/plan/bimSelectTools.js @@ -9,19 +9,42 @@ function selectFeature(that, featureId) { } } else { api.Feature.setColor(featureId, "rgba(255,0,255,1)"); + if (!that.showMode) { + api.Feature.setVisible(featureId, false); + } that.selectItems.push(featureId); } } + function hideFeatures(that) { let tmps = that.allBimData.filter((it) => it.id != that.plan.id); tmps.forEach((it) => { - console.log("hide-->", it.bim); it.bim.forEach((it) => { hideFeature(that, it); }); }); } +function getHideFeatures(that, checkedKeys) { + let result = []; + let tmps = that.allBimData.filter((it) => it.id != that.plan.id); + tmps.forEach((it) => { + it.bim.forEach((it) => { + result.push(it); + }); + }); + if (checkedKeys.length > 0) { + tmps = that.allFeatures + .filter((d) => !checkedKeys.includes(d.glid)) + .filter((d) => d != "0") + .map((d) => d.featureId); + tmps.forEach((d) => { + result.push(d); + }); + } + return result; +} + function hideFeature(that, featureId) { let api = bimSelectionDlgApi; api.Feature.setVisible(featureId, false); @@ -40,18 +63,19 @@ function selectSingle(that) { } function clearAllSelection(that) { - let api = bimSelectionDlgApi; - api.Public.clearHandler(); - that.selectItems.forEach((it) => { - selectFeature(that, it); + that.$modal.confirm("确定清除所有已选择构件吗?").then(() => { + let api = bimSelectionDlgApi; + that.selectItems.forEach((d) => { + api.Feature.setColor(d, "rgba(255,255,255,1)"); + }); + that.selectItems = []; + this.selEl++; }); } function initBim(that) { - console.log("initBim"); let tmps = that.allBimData.filter((it) => it.id == that.plan.id); if (tmps.length > 0) { - console.log("selected-->", tmps[0].bim); tmps[0].bim.forEach((it) => { selectFeature(that, it); }); @@ -94,9 +118,9 @@ function partLoadModel(that) { obj[modelId].join("#"), (res) => {}, (res) => { - console.log("load part success", res); that.viewPoint = p; that.$message.info("模型加载完成"); + that.bimLoaded = true; that.doMenu(2); initBim(that); }, @@ -106,6 +130,23 @@ function partLoadModel(that) { ); } } + if (featureIds.length == 0) { + setTimeout(() => { + that.$refs.tree.setChecked("root", true, true); + }, 1000); + + loadModels(that); + let func = () => { + if (that.loadedModelCount == that.models.length) { + setTimeout(() => { + setFeatueShowOrHide(that, []); + }, 1000); + } else { + setTimeout(func, 100); + } + }; + func(); + } } //构建树形数据 @@ -137,13 +178,13 @@ function buildTreeData(that) { getModelFeatures(that, d.lightweightName, node); }); that.treeExpendedKeys.push("root"); + that.$message.info("模型构件信息加载完成"); } //获取模型所有构件 function getModelFeatures(that, modelId, node) { let tmps = that.allBimData.filter((it) => it.id != that.plan.id); tmps.forEach((it) => { - console.log("hide-->", it.bim); it.bim.forEach((it) => { if (!that.readlyParts.includes(it)) { that.readlyParts.push(it); @@ -152,18 +193,18 @@ function getModelFeatures(that, modelId, node) { }); //获取模型构件 modelTreeAllChild(modelId, "").then((res) => { - let objs = res.data || [] + let objs = res.data || []; objs.forEach((o) => { - o.modelId=modelId - o.featureId=o.modelId+"^"+o.externalId - o.name=o.name||''; - o.name=o.name.replaceAll('"',"").replaceAll("'","").replaceAll('\\',''); - o.info=`[${o.externalId}]${o.groupname}-${o.name}` - if(o.externalId == "0"){ + o.modelId = modelId; + o.featureId = o.modelId + "^" + o.externalId; + o.name = o.name || ""; + o.name = o.name.replaceAll('"', "").replaceAll("'", "").replaceAll("\\", ""); + o.info = `[${o.externalId}]${o.groupname}-${o.name}`; + if (o.externalId == "0") { return; } - let featureId=o.modelId+"^"+o.externalId; + let featureId = o.modelId + "^" + o.externalId; if (!that.allParts.includes(featureId)) { that.allParts.push(featureId); } @@ -188,10 +229,125 @@ function getModelFeatures(that, modelId, node) { }); that.showParts = that.allParts.filter((it) => !that.hideParts.includes(it)); } + +//树上点击事件 +function onCheckTree(that, node, event) { + let api = bimSelectionDlgApi; + + if (that.partLoad) { + that.$refs.tree.setChecked("root", false, true); + that.partLoad = false; + that.models.forEach((it) => { + api.Model.remove(it.modelId); + }); + return; + } + if (loadModels(that) > 0) { + let func = () => { + if (that.loadedModelCount == that.models.length) { + setTimeout(() => { + setTreeNodeChecked(that, node, event); + }, 1000); + } else { + setTimeout(func, 100); + } + }; + func(); + } else { + setTreeNodeChecked(that, node, event); + } +} +//根据选择控制构件的隐藏和显示 +function setTreeNodeChecked(that, node, event) { + let api = bimSelectionDlgApi; + let checked = event.checkedNodes.includes(node); + if (node.type == "root") { + if (checked) { + that.models.forEach((it) => { + api.Model.setVisible(it.modelId, true); + api.Model.original(it.modelId); + }); + } else { + that.models.forEach((it) => { + api.Model.setVisible(it.modelId, false); + }); + } + } else if (node.type == "model") { + if (checked) { + api.Model.setVisible(node.modelId, true); + api.Model.original(node.modelId); + } else { + api.Model.setVisible(node.modelId, false); + } + } else { + api.Model.original(node.modelId); + } + setFeatueShowOrHide(that, event.checkedKeys); +} + +//处理构件的隐藏和显示 +function setFeatueShowOrHide(that, checkedKeys) { + let api = bimSelectionDlgApi; + //隐藏构件 + let hideFeatures = getHideFeatures(that, checkedKeys); + api.Feature.setVisible(hideFeatures.join("#"), false); + + //标注已选择的构件 + that.selectItems.forEach((it) => { + api.Feature.setColor(it, "rgba(255,0,255,1)"); + if (!that.showMode) { + api.Feature.setVisible(it, false); + } + }); + + api.Feature.setVisible(that.hideParts.join("#"), false); +} + +//加载模型 +function loadModels(that) { + let api = bimSelectionDlgApi; + let modelIds = that.models.map((it) => it.lightweightName); + let cnt = 0; + that.loadedModelCount = 0; + modelIds.forEach((modelId) => { + if (!api.m_model.has(modelId)) { + cnt++; + that.addModel(modelId); + return; + } + }); + return cnt; +} + +//框选构件 +function boxSelection(that) { + let api = bimSelectionDlgApi; + api.Feature.boxSelect((data) => { + data.forEach((featureId) => { + selectFeature(that, featureId); + }); + }); +} +//隐藏构件选择 +function hideSelection(that) { + let api = bimSelectionDlgApi; + api.Public.clearHandler(); + api.Feature.getByEvent(true, (n) => { + if (n && n["id"]) { + let featureId = n.id; + that.hideParts.push(featureId); + api.Feature.setVisible(featureId, false); + that.hideEl++; + } + }); +} export default { selectSingle, initBim, clearAllSelection, partLoadModel, buildTreeData, + onCheckTree, + boxSelection, + hideSelection, }; diff --git a/yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog.vue b/yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog.vue index 2ca3b001..3f8d362f 100644 --- a/yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog.vue +++ b/yanzhu-ui-vue3/src/views/manage/plan/bimSelectionDialog.vue @@ -23,16 +23,28 @@ -
+
{{ it.info }}
- 删除 + 删除 +
+
+ + +
+ 删除所有 +
+
+
+ +
{{ it.info }}
+
+ 删除
-
@@ -40,34 +52,39 @@
-