Skip to content

Commit b004ce7

Browse files
committed
Tables reintroduced, resize guard modified
1 parent e3d7648 commit b004ce7

File tree

27 files changed

+362
-102
lines changed

27 files changed

+362
-102
lines changed

README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,19 @@ The project is in active development. The roadmap is as follows:
3636
- [ ] Loading points and lines from SHP
3737
- [ ] Extract Utils to separate SDK form metacity editors
3838

39-
### v0.3.0 - 👨‍💻 In progress
39+
### v0.3.2 - 👨‍💻 In progress
4040

41-
- [x] Auto setup shading based on height
42-
- [ ] Resize guard update graphics (The "Oops" message is pretty lame)
4341
- [ ] Projecting models onto models (2D onto 3D) - ✨WIP https://github.com/vojtatom/geometry
44-
- [ ] JSON metadata for nodes in hierarchy
45-
- [ ] Assign metadata to model nodes
4642
- [ ] Project export
4743
- [ ] Styling???
4844

45+
### v0.2.1 - ✅ Released
46+
47+
- [x] Auto setup shading based on height
48+
- [x] JSON metadata for nodes in hierarchy
49+
- [x] Assign metadata to model nodes
50+
- [x] Resize guard update graphics (The "Oops" message is pretty lame)
51+
4952
### v0.2.0 - ✅ Released
5053

5154
- [x] Infrastructure for the built-in viewer (vite setup, etc.)

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"dev": "vite",
8-
"build": "tsc && vite build",
8+
"build": "tsc && vite build --emptyOutDir",
99
"preview": "vite preview"
1010
},
1111
"dependencies": {

studio/src/assets/cat.gif

25.3 KB
Loading

studio/src/assets/cat2.gif

10.5 KB
Loading

studio/src/assets/index.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ body,
3737
}
3838
}
3939

40+
@layer components {
41+
.disable-blur {
42+
-webkit-image-rendering: pixelated;
43+
-moz-image-rendering: pixelated;
44+
-o-image-rendering: pixelated;
45+
image-rendering: pixelated;
46+
}
47+
}
48+
4049
@layer components {
4150
input[type='range'] {
4251
@apply appearance-none bg-transparent cursor-pointer outline-none;

studio/src/components/Editor/Canvas/WidgetCameraGround.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
import React from 'react';
21
import { TbCircuitGround } from 'react-icons/tb';
32

4-
import { useActiveView, useCameraZ, useRenderer } from '@utils/utils';
3+
import { useCameraZ } from '@utils/utils';
54

65
import { Range } from '@elements/Range';
76
import { Widget, WidgetDescription, WidgetLine, WidgetTitle } from '@elements/Widgets';
87

98
export function CameraGroundWidget() {
10-
const renderer = useRenderer();
11-
const activeView = useActiveView();
129
const [camTargetZ, setCamTargetZ] = useCameraZ();
1310

1411
const updateCamTargetZ = (value: number) => {
1512
if (isNaN(value)) return;
16-
17-
const view = renderer.views[activeView].view;
18-
view.camera.z = value;
1913
setCamTargetZ(value);
2014
};
2115

@@ -30,7 +24,9 @@ export function CameraGroundWidget() {
3024
<WidgetLine>
3125
<WidgetDescription>Set Ground Level for the camera</WidgetDescription>
3226
</WidgetLine>
33-
<WidgetLine className="py-2 px-4">Camera ground is at {camTargetZ}</WidgetLine>
27+
<WidgetLine className="py-2 px-4">
28+
Camera ground is at {camTargetZ.toFixed(2)}
29+
</WidgetLine>
3430
<WidgetLine className="px-4 mb-4">
3531
<Range min={-1000} max={1000} value={camTargetZ} onChange={updateCamTargetZ} />
3632
</WidgetLine>

studio/src/components/Editor/Context/TableContext.tsx

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ interface TablesContextProps {
99
setNodeToMove: React.Dispatch<React.SetStateAction<Node | undefined>>;
1010
nodeToLink: Node | undefined;
1111
setNodeToLink: React.Dispatch<React.SetStateAction<Node | undefined>>;
12+
tables: Tables;
13+
setTables: React.Dispatch<React.SetStateAction<Tables>>;
14+
activeSheet: number;
15+
setActiveSheet: React.Dispatch<React.SetStateAction<number>>;
1216
}
1317

1418
const context = React.createContext<TablesContextProps>({} as TablesContextProps);
@@ -19,7 +23,6 @@ export function TablesContext(props: { children: React.ReactNode }) {
1923
const [nodeToLink, setNodeToLink] = React.useState<Node | undefined>();
2024
const [tables, setTables] = React.useState<Tables>(new Tables([]));
2125
const [activeSheet, setActiveSheet] = React.useState<number>(0);
22-
const [activeRows, setActiveRows] = React.useState<Set<number>>(new Set<number>());
2326

2427
React.useEffect(() => {
2528
graph.addChangeListener(() => {
@@ -38,6 +41,10 @@ export function TablesContext(props: { children: React.ReactNode }) {
3841
setNodeToMove,
3942
nodeToLink,
4043
setNodeToLink,
44+
tables,
45+
setTables,
46+
activeSheet,
47+
setActiveSheet,
4148
}}
4249
>
4350
{props.children}
@@ -93,3 +100,33 @@ export function useLinkingNode(): [Node | undefined, (node: Node | undefined) =>
93100

94101
return [ctx.nodeToLink, updateNodeToLink];
95102
}
103+
104+
export function useTables(): [Tables, React.Dispatch<React.SetStateAction<Tables>>] {
105+
const ctx = React.useContext(context);
106+
return [ctx.tables, ctx.setTables];
107+
}
108+
109+
export function useSheets(): [(content: string) => void, (index: number) => void] {
110+
const ctx = React.useContext(context);
111+
const addSheet = (content: string) => {
112+
ctx.setTables(ctx.tables.addSheet(content));
113+
};
114+
115+
const removeSheet = (index: number) => {
116+
ctx.setTables(ctx.tables.removeSheet(index));
117+
};
118+
119+
return [addSheet, removeSheet];
120+
}
121+
122+
export function useActiveSheet(): [number, React.Dispatch<React.SetStateAction<number>>] {
123+
const ctx = React.useContext(context);
124+
return [ctx.activeSheet, ctx.setActiveSheet];
125+
}
126+
127+
export function useRowTypes(): (sheet: number, row: number, rowType: string) => void {
128+
const ctx = React.useContext(context);
129+
return (sheet: number, row: number, rowType: string) => {
130+
ctx.setTables(ctx.tables.setSheetRowType(sheet, row, rowType as any));
131+
};
132+
}

studio/src/components/Editor/SidePanel/Table/Hierarchy/NodeGroup.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react';
22
import { BsFillStopFill } from 'react-icons/bs';
33
import { FiDelete } from 'react-icons/fi';
44
import { MdDriveFileMoveRtl, MdOutlineDriveFileMove } from 'react-icons/md';
5-
import { VscSymbolInterface } from 'react-icons/vsc';
5+
import { VscJson } from 'react-icons/vsc';
66

77
import { EditorModel, GroupNode as GroupNodeClass, deleteGroup } from '@utils/utils';
88
import { useSelection } from '@utils/utils';
@@ -32,7 +32,7 @@ export function GroupNode(props: GroupNodeProps) {
3232
const [graph] = useGraph();
3333
const [nodeToMove, updateNodeToMove] = useMovingNode();
3434
const [nodeToLink, updateNodeToLink] = useLinkingNode();
35-
const [open, setOpen] = React.useState(false);
35+
const [open, setOpen] = React.useState(true);
3636

3737
const isSelected = React.useMemo(() => node.selected(submodels), [node, submodels]);
3838
const isLinking = React.useMemo(() => node === nodeToLink, [node, nodeToLink]);
@@ -118,7 +118,7 @@ export function GroupNode(props: GroupNodeProps) {
118118
onClick={handleLink}
119119
title="Link to selected rows in table"
120120
>
121-
<VscSymbolInterface />
121+
<VscJson />
122122
</HierarchyButton>
123123
</If>
124124
</HierarchyNodeRow>

studio/src/components/Editor/SidePanel/Table/Hierarchy/NodeModel.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { BsFillStopFill } from 'react-icons/bs';
33
import { MdOutlineDriveFileMove } from 'react-icons/md';
4-
import { VscSymbolInterface } from 'react-icons/vsc';
4+
import { VscJson, VscSymbolInterface } from 'react-icons/vsc';
55

66
import { EditorModel, ModelNode as ModelNodeClass } from '@utils/utils';
77
import { useSelection } from '@utils/utils';
@@ -73,7 +73,7 @@ export function ModelNode(props: ModelNodeProps) {
7373
onClick={handleLink}
7474
title="Link to selected rows in table"
7575
>
76-
<VscSymbolInterface />
76+
<VscJson />
7777
</HierarchyButton>
7878
</If>
7979
</HierarchyNodeRow>
Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,47 @@
1+
import { AiOutlineCheckCircle, AiOutlineClockCircle, AiOutlineCloseCircle } from 'react-icons/ai';
2+
13
import { useRenderer, useScene } from '@utils/utils';
24

35
import { Vitals } from '@editor/Utils/Vitals';
46

57
import { Button } from '@elements/Button';
68

7-
export function MetaMenu() {
9+
export function MetaMenu(props: { status?: 'editing' | 'saved' | 'failed' }) {
810
const renderer = useRenderer();
911
const scene = useScene();
1012

1113
return (
1214
<div className="flex flex-row p-4 w-full space-x-2 border-b items-center">
1315
<Button>Export</Button>
16+
{props.status == 'editing' && <Editing />}
17+
{props.status == 'saved' && <Saved />}
18+
{props.status == 'failed' && <Failed />}
1419
<Vitals scenes={[scene]} renderer={renderer} />
1520
</div>
1621
);
1722
}
23+
24+
function Saved() {
25+
return (
26+
<div className="text-blue-500 flex flex-row items-center px-2">
27+
<AiOutlineCheckCircle className="text-xl mr-2" /> Saved
28+
</div>
29+
);
30+
}
31+
32+
function Failed() {
33+
return (
34+
<div className="text-red-500 flex flex-row items-center px-2">
35+
<AiOutlineCloseCircle className="text-xl mr-2" /> Failed
36+
</div>
37+
);
38+
}
39+
40+
function Editing() {
41+
return (
42+
<div className="text-neutral-500 flex flex-row items-center px-2">
43+
<AiOutlineClockCircle className="text-xl mr-2" />
44+
Idle
45+
</div>
46+
);
47+
}

0 commit comments

Comments
 (0)