Skip to content

Commit 4f4db27

Browse files
committed
First version of lazy tree structure menu
1 parent 6d2addb commit 4f4db27

File tree

9 files changed

+61
-20
lines changed

9 files changed

+61
-20
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
.spatial-tree-node {
2+
max-height: 100vh;
3+
width: 25rem;
4+
}
5+
6+
.root-node{
7+
overflow-y: auto;
8+
}

examples/simple-angular/src/app/spatial-tree/spatial-tree-node/spatial-tree-node.component.html

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<mat-accordion>
2-
<mat-expansion-panel (opened)="loadChild()" class="mat-elevation-z0" style="height: auto;" hideToggle>
2+
<mat-expansion-panel
3+
(opened)="loadChild()"
4+
class="mat-elevation-z0 spatial-tree-node"
5+
[ngClass] = "{'root-node': rootNode && clicked}"
6+
hideToggle>
37
<mat-expansion-panel-header>
48
<mat-panel-title>
5-
<mat-checkbox class="example-margin" click-stop-propagation>{{ prefix + " - " + ifcID }}</mat-checkbox>
9+
<mat-checkbox class="example-margin" click-stop-propagation>{{ prefix }}</mat-checkbox>
610
</mat-panel-title>
7-
<mat-panel-description> This is a summary of the content </mat-panel-description>
11+
<mat-panel-description> {{"ID: " + ifcID}} </mat-panel-description>
812
</mat-expansion-panel-header>
913
<ng-content></ng-content>
1014
</mat-expansion-panel>

examples/simple-angular/src/app/spatial-tree/spatial-tree-node/spatial-tree-node.component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,15 @@ export class SpatialTreeNodeComponent implements AfterContentInit {
1010

1111
@Input('ifcID') ifcID: number;
1212
@Input('prefix') prefix: string;
13+
@Input('rootNode') rootNode: boolean;
1314
@Input('ifcViewer') ifcViewer?: IfcViewerAPI;
1415
@Output("onSelect") onSelect = new EventEmitter();
1516
props: object;
17+
clicked: boolean;
1618

1719
constructor() {
20+
this.clicked = false;
21+
this.rootNode = false;
1822
this.props = {};
1923
this.prefix = "";
2024
this.ifcID = -1;
@@ -25,6 +29,7 @@ export class SpatialTreeNodeComponent implements AfterContentInit {
2529
}
2630

2731
loadChild(){
32+
this.clicked = true;
2833
this.onSelect.emit(this.ifcID);
2934
}
3035

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,32 @@
11
<div class="tree-menu">
22
<app-spatial-tree-node
3-
(onSelect)="updateProperty($event, ifcSites)"
4-
*ngFor="let project of ifcProjects; index as i"
3+
[rootNode]="true"
54
[ifcID]="ifcProjects[i]"
5+
(onSelect)="getSpatialChildren($event, ifcSites)"
6+
*ngFor="let project of ifcProjects; index as i"
67
prefix="IfcProject"
78
>
89
<app-spatial-tree-node
9-
*ngFor="let project of ifcSites; index as j"
10+
(onSelect)="getSpatialChildren($event, ifcBuildings)"
11+
*ngFor="let site of ifcSites; index as j"
1012
[ifcID]="ifcSites[j]"
1113
prefix="IfcSite"
1214
>
15+
<app-spatial-tree-node
16+
(onSelect)="getSpatialChildren($event, ifcStoreys)"
17+
*ngFor="let building of ifcBuildings; index as k"
18+
[ifcID]="ifcBuildings[k]"
19+
prefix="IfcBuilding"
20+
>
21+
<app-spatial-tree-node
22+
*ngFor="let storey of ifcStoreys; index as l"
23+
[ifcID]="ifcStoreys[l]"
24+
prefix="IfcBuildingStorey"
25+
>
26+
27+
28+
</app-spatial-tree-node>
29+
</app-spatial-tree-node>
1330
</app-spatial-tree-node>
1431
</app-spatial-tree-node>
1532
</div>

examples/simple-angular/src/app/spatial-tree/spatial-tree.component.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Component, AfterViewInit, Input } from '@angular/core';
2-
import { MatMenuTrigger } from '@angular/material/menu';
32
import { IFCPROJECT } from 'web-ifc';
43
import { IfcViewerAPI } from '../../../../../viewer/dist';
4+
// import { MatMenuTrigger } from '@angular/material/menu';
55

66
@Component({
77
selector: 'app-spatial-tree',
@@ -17,6 +17,8 @@ export class SpatialTreeComponent implements AfterViewInit {
1717
ifcSites: number[];
1818
ifcBuildings: number[];
1919
ifcStoreys: number[];
20+
ifcProducts: {[key: number]: number[]};
21+
spatialChildren: {[key: number]: number[]};
2022

2123
constructor() {
2224
this.currentModel = -1;
@@ -25,6 +27,8 @@ export class SpatialTreeComponent implements AfterViewInit {
2527
this.ifcSites = [];
2628
this.ifcBuildings = [];
2729
this.ifcStoreys = [];
30+
this.ifcProducts = {};
31+
this.spatialChildren = {};
2832
}
2933

3034
ngAfterViewInit(): void {}
@@ -36,11 +40,14 @@ export class SpatialTreeComponent implements AfterViewInit {
3640
if (ifcProjectsIds) this.ifcProjects = ifcProjectsIds;
3741
}
3842

39-
updateProperty(id: number, property: number[]){
43+
getSpatialChildren(id: number, spatialChildren: number[]){
4044
const found = { expressID: id, hasChildren: [], hasSpatialChildren: [] };
41-
this.ifcViewer?.getAllSpatialChildren(this.currentModel, found, false);
45+
this.ifcViewer?.getAllSpatialChildren(this.currentModel, found, false, true);
4246
console.log(found);
43-
property.length = 0;
44-
property.push(...found.hasSpatialChildren);
47+
if(spatialChildren != undefined){
48+
spatialChildren.length = 0;
49+
spatialChildren.push(...found.hasSpatialChildren);
50+
}
51+
this.ifcProducts[id] = found.hasChildren;
4552
}
4653
}

viewer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"@types/stats.js": "^0.17.0",
3232
"stats.js": "^0.17.0",
3333
"three": "^0.128.0",
34-
"web-ifc-three": "0.0.26"
34+
"web-ifc-three": "0.0.27"
3535
},
3636
"devDependencies": {
3737
"@types/jest": "^26.0.23",

viewer/src/components/ifc/ifc-manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ export class IfcManager extends IfcComponent {
7373
return this.loader.getAllItemsOfType(modelID, type, verbose);
7474
}
7575

76-
getAllSpatialChildren(modelID: number, item: Node, recursive = false) {
77-
return this.loader.getAllSpatialChildren(modelID, item, recursive);
76+
getAllSpatialChildren(modelID: number, item: Node, recursive = false, onlyID = false) {
77+
return this.loader.getAllSpatialChildren(modelID, item, recursive, onlyID);
7878
}
7979

8080
prePickIfcItem() {

viewer/src/ifc-viewer-api.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ export class IfcViewerAPI {
5252
return this.ifcManager.getAllItemsOfType(modelID, type, verbose);
5353
}
5454

55-
getAllSpatialChildren(modelID: number, item: Node, recursive = false) {
56-
return this.ifcManager.getAllSpatialChildren(modelID, item, recursive);
55+
getAllSpatialChildren(modelID: number, item: Node, recursive = false, onlyID = false) {
56+
return this.ifcManager.getAllSpatialChildren(modelID, item, recursive, onlyID);
5757
}
5858

5959
addClippingPlane = () => {

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15955,10 +15955,10 @@ wcwidth@^1.0.1:
1595515955
dependencies:
1595615956
defaults "^1.0.3"
1595715957

15958-
web-ifc-three@0.0.26:
15959-
version "0.0.26"
15960-
resolved "https://registry.yarnpkg.com/web-ifc-three/-/web-ifc-three-0.0.26.tgz#7e1d771ad6317eb132006bd9e72e7c5e95053908"
15961-
integrity sha512-WerN11MYnora9S+InsyuQx5drorn7AAZSmISFxftfbupZBlH0YPMOmp1YKY0pY8EmArrg/Y0h/oDso+ZfOvu3w==
15958+
web-ifc-three@0.0.27:
15959+
version "0.0.27"
15960+
resolved "https://registry.yarnpkg.com/web-ifc-three/-/web-ifc-three-0.0.27.tgz#0cdd6e6c0262c7498a7317cf1a6aa78a31603c17"
15961+
integrity sha512-QotYoD3x7XdTCZTM/77EdFHkdvNJft7APw/jTrq2ahhXDIVz5o0MkvzpEXIjd/5JLH7kN1BKKjRZW69XkU+J+Q==
1596215962
dependencies:
1596315963
stats.js "^0.17.0"
1596415964
three "^0.128.0"

0 commit comments

Comments
 (0)