Skip to content

Commit 6d2addb

Browse files
committed
Start tree menu node component
1 parent f6181d1 commit 6d2addb

File tree

5 files changed

+41
-47
lines changed

5 files changed

+41
-47
lines changed
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
<mat-accordion class="tree-menu">
2-
<mat-expansion-panel class="mat-elevation-z0" hideToggle>
1+
<mat-accordion>
2+
<mat-expansion-panel (opened)="loadChild()" class="mat-elevation-z0" style="height: auto;" hideToggle>
33
<mat-expansion-panel-header>
44
<mat-panel-title>
55
<mat-checkbox class="example-margin" click-stop-propagation>{{ prefix + " - " + ifcID }}</mat-checkbox>
66
</mat-panel-title>
77
<mat-panel-description> This is a summary of the content </mat-panel-description>
88
</mat-expansion-panel-header>
9+
<ng-content></ng-content>
910
</mat-expansion-panel>
1011
</mat-accordion>

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Component, AfterContentInit, Input } from '@angular/core';
1+
import { Component, AfterContentInit, Input, Output, EventEmitter } from '@angular/core';
2+
import { IfcViewerAPI } from '../../../../../../viewer/dist';
23

34
@Component({
45
selector: 'app-spatial-tree-node',
@@ -9,6 +10,8 @@ export class SpatialTreeNodeComponent implements AfterContentInit {
910

1011
@Input('ifcID') ifcID: number;
1112
@Input('prefix') prefix: string;
13+
@Input('ifcViewer') ifcViewer?: IfcViewerAPI;
14+
@Output("onSelect") onSelect = new EventEmitter();
1215
props: object;
1316

1417
constructor() {
@@ -21,4 +24,8 @@ export class SpatialTreeNodeComponent implements AfterContentInit {
2124

2225
}
2326

27+
loadChild(){
28+
this.onSelect.emit(this.ifcID);
29+
}
30+
2431
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
.tree-menu {
2-
min-width: 20rem;
32
position: absolute;
4-
padding: 0;
5-
right: 0rem;
6-
height: 100vh;
7-
overflow: auto;
3+
right: 0;
84
}
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
2-
<app-spatial-tree-node
3-
class="tree-menu"
4-
*ngFor="let project of ifcProjects; index as i"
5-
[ifcID]="ifcProjects[i]"
6-
prefix="IfcProject"
7-
></app-spatial-tree-node>
1+
<div class="tree-menu">
2+
<app-spatial-tree-node
3+
(onSelect)="updateProperty($event, ifcSites)"
4+
*ngFor="let project of ifcProjects; index as i"
5+
[ifcID]="ifcProjects[i]"
6+
prefix="IfcProject"
7+
>
8+
<app-spatial-tree-node
9+
*ngFor="let project of ifcSites; index as j"
10+
[ifcID]="ifcSites[j]"
11+
prefix="IfcSite"
12+
>
13+
</app-spatial-tree-node>
14+
</app-spatial-tree-node>
15+
</div>

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

Lines changed: 14 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,19 @@ export class SpatialTreeComponent implements AfterViewInit {
1212
@Input('ifc') ifcViewer?: IfcViewerAPI;
1313

1414
spatialTree: any;
15-
currentModel?: number;
15+
currentModel: number;
1616
ifcProjects: number[];
17+
ifcSites: number[];
18+
ifcBuildings: number[];
19+
ifcStoreys: number[];
1720

1821
constructor() {
1922
this.currentModel = -1;
2023
this.spatialTree = {};
2124
this.ifcProjects = [];
25+
this.ifcSites = [];
26+
this.ifcBuildings = [];
27+
this.ifcStoreys = [];
2228
}
2329

2430
ngAfterViewInit(): void {}
@@ -30,35 +36,11 @@ export class SpatialTreeComponent implements AfterViewInit {
3036
if (ifcProjectsIds) this.ifcProjects = ifcProjectsIds;
3137
}
3238

33-
// createTreeBranche(item: any) {
34-
// const name = item.__proto__.constructor.name;
35-
// const properties = this.getProperties(item);
36-
// const spatialChildren = item.hasSpatialChildren.map((child: any) => this.createTreeBranche(child));
37-
// const children = item.hasChildren;
38-
// return {name, properties, spatialChildren, children};
39-
// }
40-
41-
// getGuid(item: any) {
42-
// if (item.GlobalId) return item.GlobalId.value as string;
43-
// return '';
44-
// }
45-
46-
// getProperties(item: any) {
47-
// if (!item) return '';
48-
// const result: any = [];
49-
// Object.keys(item).forEach((i) => {
50-
// if (i != 'hasChildren' && i != 'hasSpatialChildren')
51-
// result.push({ name: i, value: this.getValue(item[i]) });
52-
// });
53-
// return result;
54-
// }
55-
56-
// getValue(prop: any) {
57-
// if (prop === null || prop === undefined) return 'undefined';
58-
// if (typeof prop === 'number') return prop;
59-
// if (Array.isArray(prop)) return prop.map(p => p.value);
60-
// if (typeof prop === 'string' && prop.length > 0) return prop;
61-
// if (typeof prop === 'object' && prop.value) return prop.value;
62-
// return 'undefined';
63-
// }
39+
updateProperty(id: number, property: number[]){
40+
const found = { expressID: id, hasChildren: [], hasSpatialChildren: [] };
41+
this.ifcViewer?.getAllSpatialChildren(this.currentModel, found, false);
42+
console.log(found);
43+
property.length = 0;
44+
property.push(...found.hasSpatialChildren);
45+
}
6446
}

0 commit comments

Comments
 (0)