-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
341 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
firebird-ng/src/app/geometry-tree/geometry-tree.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<p>geometry-tree works!</p> | ||
|
||
<mat-tree [dataSource]="dataSource" [treeControl]="treeControl"> | ||
<!-- This is the tree node template for leaf nodes --> | ||
<mat-tree-node *matTreeNodeDef="let node" matTreeNodePadding> | ||
<!-- use a disabled button to provide padding for tree leaf --> | ||
<button mat-icon-button disabled></button> | ||
{{node.name}} | ||
[{{node.type}}] | ||
</mat-tree-node> | ||
<!-- This is the tree node template for expandable nodes --> | ||
<mat-tree-node *matTreeNodeDef="let node;when: hasChild" matTreeNodePadding> | ||
<button mat-icon-button matTreeNodeToggle | ||
[attr.aria-label]="'Toggle ' + node.name"> | ||
<mat-icon class="mat-icon-rtl-mirror"> | ||
{{treeControl.isExpanded(node) ? 'expand_more' : 'chevron_right'}} | ||
</mat-icon> | ||
</button> | ||
{{node.name}} | ||
[{{node.type}}] | ||
</mat-tree-node> | ||
</mat-tree> |
Empty file.
23 changes: 23 additions & 0 deletions
23
firebird-ng/src/app/geometry-tree/geometry-tree.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { GeometryTreeComponent } from './geometry-tree.component'; | ||
|
||
describe('GeometryTreeComponent', () => { | ||
let component: GeometryTreeComponent; | ||
let fixture: ComponentFixture<GeometryTreeComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [GeometryTreeComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(GeometryTreeComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
119 changes: 119 additions & 0 deletions
119
firebird-ng/src/app/geometry-tree/geometry-tree.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
import {Component, OnInit} from '@angular/core'; | ||
import { | ||
MatNestedTreeNode, | ||
MatTree, | ||
MatTreeNode, | ||
MatTreeNodeDef, | ||
MatTreeNodeOutlet, MatTreeNodePadding, | ||
MatTreeNodeToggle | ||
} from "@angular/material/tree"; | ||
import {NestedTreeControl, FlatTreeControl, } from '@angular/cdk/tree'; | ||
import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree'; | ||
|
||
import {MatIcon, MatIconModule} from '@angular/material/icon'; | ||
import {MatButtonModule, MatIconButton} from '@angular/material/button'; | ||
import {GeometryService} from "../geometry.service"; | ||
import {Object3D} from "three"; | ||
|
||
/** | ||
* Food data with nested structure. | ||
* Each node has a name and an optional list of children. | ||
*/ | ||
interface FoodNode { | ||
name: string; | ||
children?: FoodNode[]; | ||
} | ||
|
||
const TREE_DATA: FoodNode[] = [ | ||
{ | ||
name: 'Fruit', | ||
children: [{name: 'Apple'}, {name: 'Banana'}, {name: 'Fruit loops'}], | ||
}, | ||
{ | ||
name: 'Vegetables', | ||
children: [ | ||
{ | ||
name: 'Green', | ||
children: [{name: 'Broccoli'}, {name: 'Brussels sprouts'}], | ||
}, | ||
{ | ||
name: 'Orange', | ||
children: [{name: 'Pumpkins'}, {name: 'Carrots'}], | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
/** Flat node with expandable and level information */ | ||
interface ExampleFlatNode { | ||
expandable: boolean; | ||
name: string; | ||
level: number; | ||
type: string; | ||
} | ||
|
||
@Component({ | ||
selector: 'app-geometry-tree', | ||
standalone: true, | ||
imports: [ | ||
MatTree, | ||
MatTreeNode, | ||
MatNestedTreeNode, | ||
MatIconButton, | ||
MatTreeNodeToggle, | ||
MatTreeNodeDef, | ||
MatIcon, | ||
MatTreeNodeOutlet, | ||
MatTreeNodePadding | ||
], | ||
templateUrl: './geometry-tree.component.html', | ||
styleUrl: './geometry-tree.component.scss' | ||
}) | ||
export class GeometryTreeComponent implements OnInit{ | ||
|
||
private _transformer = (node: Object3D, level: number) => { | ||
return { | ||
expandable: !!node.children && node.children.length > 0, | ||
name: node.name, | ||
level: level, | ||
type: node.type | ||
}; | ||
}; | ||
|
||
treeControl = new FlatTreeControl<ExampleFlatNode>( | ||
node => node.level, | ||
node => node.expandable, | ||
); | ||
|
||
treeFlattener = new MatTreeFlattener( | ||
this._transformer, | ||
node => node.level, | ||
node => node.expandable, | ||
node => node.children, | ||
); | ||
|
||
dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener); | ||
|
||
|
||
hasChild = (_: number, node: ExampleFlatNode) => node.expandable; | ||
|
||
constructor(private geomService: GeometryService) { | ||
//this.dataSource.data = TREE_DATA; | ||
} | ||
|
||
ngOnInit(): void { | ||
if(!this.geomService.geometry) this.geomService.loadGeometry().then(result => { | ||
if(result.threeGeometry) { | ||
this.dataSource.data = result.threeGeometry.children; | ||
} | ||
else { | ||
console.error("this.geomService.loadGeometry() ! result.threeGeometry"); | ||
} | ||
}).catch(reason=>{ | ||
console.error("ERROR LOADING GEOMETRY"); | ||
console.log(reason); | ||
}); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.