Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions packages/obc/src/components/tables/RelationsTree/example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,9 @@ const panel = BUI.Component.create(() => {
};

return BUI.html`
<bim-panel label="Classifications Tree">
<bim-panel-section label="Importing">
<bim-panel label="Relations Tree">
<bim-panel-section label="Model Tree">
${loadIfcBtn}
</bim-panel-section>
<bim-panel-section label="Classifications">
<bim-text-input @input=${onSearch} placeholder="Search..." debounce="200"></bim-text-input>
${relationsTree}
</bim-panel-section>
Expand Down
45 changes: 37 additions & 8 deletions packages/obc/src/components/tables/RelationsTree/src/template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,54 @@ const getDecompositionTree = async (
Entity: OBC.IfcCategoryMap[type],
Name: entityAttrs.Name?.value,
modelID: model.uuid,
expressID,
},
};

for (const attrName of inverseAttributes) {
const relations = indexer.getEntityRelations(model, expressID, attrName);
entityRow.data.expressID = expressID;
if (!relations) continue;
if (!entityRow.children) entityRow.children = [];
entityRow.data.relations = JSON.stringify(relations);
const entityGroups: any = {};
for (const id of relations) {
const decompositionRow = await getDecompositionTree(
components,
model,
id,
inverseAttributes,
);
if (!entityRow.children) entityRow.children = [];
entityRow.children.push(...decompositionRow);
for (const row of decompositionRow) {
if (row.data.relations) {
entityRow.children.push(row);
} else {
const data = model.data.get(id);
if (!data) {
entityRow.children.push(row);
continue;
}
const type = data[1][1];
const entity = OBC.IfcCategoryMap[type];
if (!(entity in entityGroups)) entityGroups[entity] = [];
row.data.Entity = row.data.Name;
delete row.data.Name;
entityGroups[entity].push(row);
}
}
}

for (const entity in entityGroups) {
const children = entityGroups[entity];
const relations = children.map((child: any) => child.data.expressID);
const row: BUI.TableGroupData = {
data: {
Entity: entity,
modelID: model.uuid,
relations: JSON.stringify(relations),
},
children,
};
entityRow.children.push(row);
}
}

Expand Down Expand Up @@ -111,7 +142,7 @@ const getRowFragmentIdMap = (components: OBC.Components, row: BUI.TableRow) => {
expressID: number;
relations: string;
};
if (!(modelID && expressID)) return null;
if (!modelID) return null;
const model = fragments.groups.get(modelID);
if (!model) return null;
const fragmentIDMap = model.getFragmentMap([
Expand Down Expand Up @@ -145,10 +176,10 @@ export const relationsTreeTemplate = (state: RelationsTreeUIState) => {
e.stopImmediatePropagation();
const { row } = e.detail;
const highlighter = components.get(OBF.Highlighter);
const fragmentIDMap = getRowFragmentIdMap(components, row);
if (!(fragmentIDMap && Object.keys(fragmentIDMap).length !== 0)) return;
row.onmouseover = () => {
if (!hoverHighlighterName) return;
const fragmentIDMap = getRowFragmentIdMap(components, row);
if (!(fragmentIDMap && Object.keys(fragmentIDMap).length !== 0)) return;
row.style.backgroundColor = "var(--bim-ui_bg-contrast-20)";
highlighter.highlightByID(
hoverHighlighterName,
Expand All @@ -166,8 +197,6 @@ export const relationsTreeTemplate = (state: RelationsTreeUIState) => {

row.onclick = () => {
if (!selectHighlighterName) return;
const fragmentIDMap = getRowFragmentIdMap(components, row);
if (!(fragmentIDMap && Object.keys(fragmentIDMap).length !== 0)) return;
highlighter.highlightByID(
selectHighlighterName,
fragmentIDMap,
Expand Down