Skip to content

Commit 5d4eb2f

Browse files
committed
added al-graph-editor
1 parent 8382ee9 commit 5d4eb2f

File tree

12 files changed

+148
-59
lines changed

12 files changed

+148
-59
lines changed

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ It can be used to display GLTF and DICOM files. GLTF can be used in conjunction
2424

2525
Aleph is highly componentised, using a combination of reusable [A-Frame components](https://aframe.io/docs/0.9.0/core/component.html) and [StencilJS Web Components](https://stenciljs.com/docs/decorators).
2626

27-
[Redux](https://redux.js.org) is used to manage state, with A-Frame custom elements being rendered reactively.
27+
[Redux](https://redux.js.org) is used to manage state, with A-Frame custom elements rendered reactively.
2828

2929
### A-Frame Components
3030

@@ -36,8 +36,8 @@ Aleph is highly componentised, using a combination of reusable [A-Frame componen
3636
- [al-edge](/src/aframe/components/AlEdgeComponent.ts)
3737
- [al-fixed-to-orbit-camera](/src/aframe/components/AlFixedToOrbitCamera.ts)
3838
- [al-gltf-model](/src/aframe/components/AlGltfModelComponent.ts)
39-
- [al-node](/src/aframe/components/AlNodeComponent.ts)
4039
- [al-node-spawner](/src/aframe/components/AlNodeSpawnerComponent.ts)
40+
- [al-node](/src/aframe/components/AlNodeComponent.ts)
4141
- [al-orbit-control](/src/aframe/components/AlOrbitControlComponent.ts)
4242
- [al-render-order](/src/aframe/components/AlRenderOrderComponent.ts)
4343
- [al-render-overlaid](/src/aframe/components/AlRenderOverlaidComponent.ts)
@@ -57,6 +57,8 @@ Aleph is highly componentised, using a combination of reusable [A-Frame componen
5757
- [al-url-picker](/src/components/al-url-picker/readme.md)
5858
- [al-viewer](/src/components/al-viewer/readme.md)
5959

60+
The two top-level components are `al-control-panel` and `al-viewer`. `al-control-panel` wraps up the tabs-based interface containing `al-url-picker`, `al-settings`, `al-graph-editor`, and `al-console`. `al-viewer` contains the A-Frame scene and all 3D rendering logic. It also contains the Redux store and acts as single source of truth. `al-viewer` can be used without `al-control-panel`, which provides additional options.
61+
6062
## Example
6163

6264
https://aframe-viewer.com

src/aframe/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "./components/AlAngleComponent";
22
import "./components/AlBackgroundComponent";
3-
import "./components/AlBillboard";
3+
import "./components/AlBillboardComponent";
44
import "./components/AlBoundingBoxComponent";
55
import "./components/AlCursorComponent";
66
import "./components/AlEdgeComponent";

src/components.d.ts

+22
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ export namespace Components {
6161
interface AlEdgeEditor {
6262
'edge': [string, AlEdge];
6363
}
64+
interface AlGraphEditor {
65+
'angles': Map<string, AlAngle> | null;
66+
'edges': Map<string, AlEdge> | null;
67+
'node': [string, AlNode];
68+
'nodes': Map<string, AlNode> | null;
69+
'selected': string | null;
70+
}
6471
interface AlNodeEditor {
6572
'node': [string, AlNode];
6673
}
@@ -167,6 +174,12 @@ declare global {
167174
new (): HTMLAlEdgeEditorElement;
168175
};
169176

177+
interface HTMLAlGraphEditorElement extends Components.AlGraphEditor, HTMLStencilElement {}
178+
var HTMLAlGraphEditorElement: {
179+
prototype: HTMLAlGraphEditorElement;
180+
new (): HTMLAlGraphEditorElement;
181+
};
182+
170183
interface HTMLAlNodeEditorElement extends Components.AlNodeEditor, HTMLStencilElement {}
171184
var HTMLAlNodeEditorElement: {
172185
prototype: HTMLAlNodeEditorElement;
@@ -207,6 +220,7 @@ declare global {
207220
'al-console': HTMLAlConsoleElement;
208221
'al-control-panel': HTMLAlControlPanelElement;
209222
'al-edge-editor': HTMLAlEdgeEditorElement;
223+
'al-graph-editor': HTMLAlGraphEditorElement;
210224
'al-node-editor': HTMLAlNodeEditorElement;
211225
'al-node-list': HTMLAlNodeListElement;
212226
'al-settings': HTMLAlSettingsElement;
@@ -250,6 +264,13 @@ declare namespace LocalJSX {
250264
'onDeleteEdge'?: (event: CustomEvent<any>) => void;
251265
'onSaveEdge'?: (event: CustomEvent<any>) => void;
252266
}
267+
interface AlGraphEditor extends JSXBase.HTMLAttributes<HTMLAlGraphEditorElement> {
268+
'angles'?: Map<string, AlAngle> | null;
269+
'edges'?: Map<string, AlEdge> | null;
270+
'node'?: [string, AlNode];
271+
'nodes'?: Map<string, AlNode> | null;
272+
'selected'?: string | null;
273+
}
253274
interface AlNodeEditor extends JSXBase.HTMLAttributes<HTMLAlNodeEditorElement> {
254275
'node'?: [string, AlNode];
255276
'onDeleteNode'?: (event: CustomEvent<any>) => void;
@@ -329,6 +350,7 @@ declare namespace LocalJSX {
329350
'al-console': AlConsole;
330351
'al-control-panel': AlControlPanel;
331352
'al-edge-editor': AlEdgeEditor;
353+
'al-graph-editor': AlGraphEditor;
332354
'al-node-editor': AlNodeEditor;
333355
'al-node-list': AlNodeList;
334356
'al-settings': AlSettings;

src/components/al-angle-editor/readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525
### Used by
2626

27-
- [al-control-panel](..\al-control-panel)
27+
- [al-graph-editor](..\al-graph-editor)
2828

2929
### Graph
3030
```mermaid
3131
graph TD;
32-
al-control-panel --> al-angle-editor
32+
al-graph-editor --> al-angle-editor
3333
style al-angle-editor fill:#f9f,stroke:#333,stroke-width:4px
3434
```
3535

src/components/al-control-panel/al-control-panel.tsx

+1-40
Original file line numberDiff line numberDiff line change
@@ -47,36 +47,6 @@ export class AlSettings {
4747
return "";
4848
}
4949

50-
private _getSelectedNode(): [string, AlNode] | null {
51-
if (this.selected && this.nodes) {
52-
const n = this.nodes.get(this.selected);
53-
if (n) {
54-
return [this.selected, n];
55-
}
56-
}
57-
return null;
58-
}
59-
60-
private _getSelectedEdge(): [string, AlEdge] | null {
61-
if (this.selected && this.edges) {
62-
const e = this.edges.get(this.selected);
63-
if (e) {
64-
return [this.selected, e];
65-
}
66-
}
67-
return null;
68-
}
69-
70-
private _getSelectedAngle(): [string, AlAngle] | null {
71-
if (this.selected && this.angles) {
72-
const a = this.angles.get(this.selected);
73-
if (a) {
74-
return [this.selected, a];
75-
}
76-
}
77-
return null;
78-
}
79-
8050
public render() {
8151
const tabContentHeight: string =
8252
this.tabContentHeight || this.el.parentElement.clientHeight + "px";
@@ -126,16 +96,7 @@ export class AlSettings {
12696
{this.graphTabEnabled ? (
12797
<ion-tab tab="graph">
12898
<Scroll height={tabContentHeight}>
129-
<al-node-list
130-
nodes={this.nodes}
131-
selected={this.selected}
132-
></al-node-list>
133-
<ion-item-divider></ion-item-divider>
134-
<al-node-editor node={this._getSelectedNode()}></al-node-editor>
135-
<al-edge-editor edge={this._getSelectedEdge()}></al-edge-editor>
136-
<al-angle-editor
137-
angle={this._getSelectedAngle()}
138-
></al-angle-editor>
99+
<al-graph-editor selected={this.selected} nodes={this.nodes} angles={this.angles} edges={this.edges}></al-graph-editor>
139100
</Scroll>
140101
</ion-tab>
141102
) : null}

src/components/al-control-panel/readme.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@
3333
- [al-tabs](..\al-tabs)
3434
- [al-url-picker](..\al-url-picker)
3535
- [al-settings](..\al-settings)
36-
- [al-node-list](..\al-node-list)
37-
- [al-node-editor](..\al-node-editor)
38-
- [al-edge-editor](..\al-edge-editor)
39-
- [al-angle-editor](..\al-angle-editor)
36+
- [al-graph-editor](..\al-graph-editor)
4037
- [al-console](..\al-console)
4138

4239
### Graph
@@ -45,11 +42,12 @@ graph TD;
4542
al-control-panel --> al-tabs
4643
al-control-panel --> al-url-picker
4744
al-control-panel --> al-settings
48-
al-control-panel --> al-node-list
49-
al-control-panel --> al-node-editor
50-
al-control-panel --> al-edge-editor
51-
al-control-panel --> al-angle-editor
45+
al-control-panel --> al-graph-editor
5246
al-control-panel --> al-console
47+
al-graph-editor --> al-node-list
48+
al-graph-editor --> al-node-editor
49+
al-graph-editor --> al-edge-editor
50+
al-graph-editor --> al-angle-editor
5351
style al-control-panel fill:#f9f,stroke:#333,stroke-width:4px
5452
```
5553

src/components/al-edge-editor/readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525
### Used by
2626

27-
- [al-control-panel](..\al-control-panel)
27+
- [al-graph-editor](..\al-graph-editor)
2828

2929
### Graph
3030
```mermaid
3131
graph TD;
32-
al-control-panel --> al-edge-editor
32+
al-graph-editor --> al-edge-editor
3333
style al-edge-editor fill:#f9f,stroke:#333,stroke-width:4px
3434
```
3535

src/components/al-graph-editor/al-graph-editor.css

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { Component, h, Prop } from "@stencil/core";
2+
import { AlAngle, AlEdge, AlNode } from "../../interfaces";
3+
4+
@Component({
5+
tag: "al-graph-editor",
6+
styleUrl: "al-graph-editor.css",
7+
shadow: true
8+
})
9+
export class AlGraphEditor {
10+
11+
@Prop({ mutable: true }) public node: [string, AlNode];
12+
@Prop({ mutable: true }) public nodes: Map<string, AlNode> | null = null;
13+
@Prop({ mutable: true }) public angles: Map<string, AlAngle> | null = null;
14+
@Prop({ mutable: true }) public edges: Map<string, AlEdge> | null = null;
15+
@Prop({ mutable: true }) public selected: string | null = null;
16+
17+
private _getSelectedNode(): [string, AlNode] | null {
18+
if (this.selected && this.nodes) {
19+
const n = this.nodes.get(this.selected);
20+
if (n) {
21+
return [this.selected, n];
22+
}
23+
}
24+
return null;
25+
}
26+
27+
private _getSelectedEdge(): [string, AlEdge] | null {
28+
if (this.selected && this.edges) {
29+
const e = this.edges.get(this.selected);
30+
if (e) {
31+
return [this.selected, e];
32+
}
33+
}
34+
return null;
35+
}
36+
37+
private _getSelectedAngle(): [string, AlAngle] | null {
38+
if (this.selected && this.angles) {
39+
const a = this.angles.get(this.selected);
40+
if (a) {
41+
return [this.selected, a];
42+
}
43+
}
44+
return null;
45+
}
46+
47+
public render() {
48+
return [
49+
<al-node-list
50+
nodes={this.nodes}
51+
selected={this.selected}
52+
></al-node-list>,
53+
<ion-item-divider></ion-item-divider>,
54+
<al-node-editor node={this._getSelectedNode()}></al-node-editor>,
55+
<al-edge-editor edge={this._getSelectedEdge()}></al-edge-editor>,
56+
<al-angle-editor
57+
angle={this._getSelectedAngle()}
58+
></al-angle-editor>
59+
];
60+
}
61+
}
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# al-graph-editor
2+
3+
4+
5+
<!-- Auto Generated Below -->
6+
7+
8+
## Properties
9+
10+
| Property | Attribute | Description | Type | Default |
11+
| ---------- | ---------- | ----------- | ---------------------- | ----------- |
12+
| `angles` | -- | | `Map<string, AlAngle>` | `null` |
13+
| `edges` | -- | | `Map<string, AlEdge>` | `null` |
14+
| `node` | -- | | `[string, AlNode]` | `undefined` |
15+
| `nodes` | -- | | `Map<string, AlNode>` | `null` |
16+
| `selected` | `selected` | | `string` | `null` |
17+
18+
19+
## Dependencies
20+
21+
### Used by
22+
23+
- [al-control-panel](..\al-control-panel)
24+
25+
### Depends on
26+
27+
- [al-node-list](..\al-node-list)
28+
- [al-node-editor](..\al-node-editor)
29+
- [al-edge-editor](..\al-edge-editor)
30+
- [al-angle-editor](..\al-angle-editor)
31+
32+
### Graph
33+
```mermaid
34+
graph TD;
35+
al-graph-editor --> al-node-list
36+
al-graph-editor --> al-node-editor
37+
al-graph-editor --> al-edge-editor
38+
al-graph-editor --> al-angle-editor
39+
al-control-panel --> al-graph-editor
40+
style al-graph-editor fill:#f9f,stroke:#333,stroke-width:4px
41+
```
42+
43+
----------------------------------------------
44+
45+
*Built with [StencilJS](https://stenciljs.com/)*

src/components/al-node-editor/readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525
### Used by
2626

27-
- [al-control-panel](..\al-control-panel)
27+
- [al-graph-editor](..\al-graph-editor)
2828

2929
### Graph
3030
```mermaid
3131
graph TD;
32-
al-control-panel --> al-node-editor
32+
al-graph-editor --> al-node-editor
3333
style al-node-editor fill:#f9f,stroke:#333,stroke-width:4px
3434
```
3535

src/components/al-node-list/readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@
2424

2525
### Used by
2626

27-
- [al-control-panel](..\al-control-panel)
27+
- [al-graph-editor](..\al-graph-editor)
2828

2929
### Graph
3030
```mermaid
3131
graph TD;
32-
al-control-panel --> al-node-list
32+
al-graph-editor --> al-node-list
3333
style al-node-list fill:#f9f,stroke:#333,stroke-width:4px
3434
```
3535

0 commit comments

Comments
 (0)