Skip to content

Commit a5aa29b

Browse files
authored
Merge pull request #38 from gregzanch/ui-updates
UI updates
2 parents e88e115 + eff4700 commit a5aa29b

File tree

12 files changed

+2108
-2073
lines changed

12 files changed

+2108
-2073
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
"styled-components": "^5.2.1",
7373
"three": "^0.111.0",
7474
"three-mesh-bvh": "^0.1.5",
75+
"three.meshline": "^1.3.0",
7576
"uplot": "^1.0.8",
7677
"uuidv4": "6.0.0",
7778
"zustand": "^3.3.1"

src/components/parameter-config/image-source-tab/ImageSourceTab.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import Select from 'react-select';
1414
import useToggle from "../../hooks/use-toggle";
1515
import { createPropertyInputs, useSolverProperty, PropertyButton, PropertyButtonDisabled } from "../SolverComponents";
1616
import PropertyRowFolder from "../property-row/PropertyRowFolder";
17-
import PropertyButton from '../property-row/PropertyButton';
1817
import PropertyRow from "../property-row/PropertyRow";
1918
import PropertyRowLabel from "../property-row/PropertyRowLabel";
2019
import PropertyRowCheckbox from "../property-row/PropertyRowCheckbox";
@@ -95,10 +94,10 @@ export const OrderSelect = ({ uuid }: { uuid: string }) => {
9594
"sourceIDs",
9695
"IMAGESOURCE_SET_PROPERTY"
9796
);
98-
97+
98+
console.log("update");
9999
return (
100100
<>
101-
{console.log("update")}
102101
{allOrders.map((o) => (
103102
<PropertyRow key={o.value}>
104103
<PropertyRowLabel label={o.value.toString()} hasToolTip={false} />
@@ -185,7 +184,7 @@ const Calculation = ({ uuid }: { uuid: string}) => {
185184
const imagesourcesolver = cram.state.solvers[uuid] as ImageSourceSolver;
186185
return (
187186
<PropertyRowFolder label="Calculation" open={open} onOpenClose={toggle}>
188-
<PropertyTextInput uuid={uuid} label="Maximum Order" property="maxReflectionOrderReset" tooltip="Sets the maximum reflection order"/>
187+
<PropertyNumberInput uuid={uuid} label="Maximum Order" property="maxReflectionOrderReset" tooltip="Sets the maximum reflection order"/>
189188
<PropertyButtonDisabled disableCondition={imagesourcesolver.sourceIDs.length!=1 || imagesourcesolver.receiverIDs.length!=1} event="UPDATE_IMAGESOURCE" args={uuid} label="Update" tooltip="Updates Imagesource Calculation" />
190189
<PropertyButtonDisabled disableCondition={imagesourcesolver.sourceIDs.length!=1 || imagesourcesolver.receiverIDs.length!=1} event="RESET_IMAGESOURCE" args={uuid} label="Clear" tooltip="Clears Imagesource Calculation" />
191190
</PropertyRowFolder>

src/components/results/LTPChart.tsx

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@ import {
2222
} from '@visx/legend';
2323
import { scaleOrdinal } from 'd3-scale';
2424
import { pickProps } from '../../common/helpers';
25-
import { on } from '../../messenger';
25+
import { emit, on } from '../../messenger';
2626
import chroma from 'chroma-js';
2727
import { ImageSourceSolver } from '../../compute/raytracer/image-source';
2828
import { useSolver } from '../../store';
29+
import PropertyRowCheckbox from "../parameter-config/property-row/PropertyRowCheckbox";
30+
import { createPropertyInputs } from '../parameter-config/SolverComponents';
2931
// accessors
3032
const getTime = (d) => d.time;
3133
const getPressure = (d) => d.pressure[0];
@@ -87,11 +89,19 @@ const useUpdate = () => {
8789

8890

8991
const Chart = ({ uuid, width = 400, height = 200, events = false }: LTPChartProps) => {
90-
const {info, data, from} = useResult(state=>pickProps(["info", "data", "from"], state.results[uuid] as Result<ResultKind.LinearTimeProgression>));
92+
const {info, data: _data, from} = useResult(state=>pickProps(["info", "data", "from"], state.results[uuid] as Result<ResultKind.LevelTimeProgression>));
9193

9294
const [count, update] = useUpdate();
95+
const [data, setData] = useState(_data);
9396

94-
useEffect(() => on("UPDATE_RESULT", (e) => e.uuid === uuid && update()), [uuid])
97+
98+
useEffect(() => on("UPDATE_RESULT", (e) => {
99+
if(e.uuid === uuid){
100+
//@ts-ignore
101+
setData(e.result.data);
102+
// update();
103+
}
104+
}), [uuid])
95105

96106
const scalePadding = 60;
97107
const scaleWidth = width-scalePadding;
@@ -102,7 +112,7 @@ const Chart = ({ uuid, width = 400, height = 200, events = false }: LTPChartProp
102112
range: [0, scaleWidth],
103113
domain: [0, Math.max(...data.map(getTime))],
104114
}),
105-
[width, count],
115+
[width, data],
106116
);
107117

108118
const scaleHeight = height - scalePadding;
@@ -112,12 +122,12 @@ const Chart = ({ uuid, width = 400, height = 200, events = false }: LTPChartProp
112122
range: [scaleHeight, 0],
113123
domain: [0, Math.max(...data.map(getPressure))],
114124
}),
115-
[height, count],
125+
[height, data],
116126
);
117127

118128
const ordinalColorScale = useMemo(
119129
() => scaleOrdinal(
120-
range(1, info.maxOrder+1),
130+
range(0, info.maxOrder+1),
121131
getOrderColors(info.maxOrder+1)
122132
),
123133
[info.maxOrder]
@@ -169,16 +179,35 @@ const Chart = ({ uuid, width = 400, height = 200, events = false }: LTPChartProp
169179

170180

171181
export const LTPChart = ({ uuid, width = 400, height = 300, events = false }: LTPChartProps) => {
172-
const {name, info} = useResult(state=>pickProps(["name", "info"], state.results[uuid] as Result<ResultKind.LinearTimeProgression>));
182+
const {name, info} = useResult(state=>pickProps(["name", "info"], state.results[uuid] as Result<ResultKind.LevelTimeProgression>));
183+
184+
const [order, setMaxOrder] = useState(info.maxOrder);
185+
186+
useEffect(()=>on("UPDATE_RESULT", (e)=>{
187+
if(e.uuid === uuid){
188+
//@ts-ignore
189+
setMaxOrder(e.result.info.maxOrder);
190+
}
191+
}), [uuid]);
192+
173193
const ordinalColorScale = useMemo(
174194
() => scaleOrdinal(
175-
range(1, info.maxOrder+1),
176-
getOrderColors(info.maxOrder+1)
195+
range(0, order+1),
196+
getOrderColors(order+1)
177197
),
178-
[info.maxOrder]
198+
[order]
179199
);
200+
// const ordinalColorScale = scaleOrdinal(
201+
// range(1, info.maxOrder+1),
202+
// getOrderColors(info.maxOrder+1)
203+
// );
180204

205+
const {from} = useResult(state=>pickProps(["from"], state.results[uuid] as Result<ResultKind.LevelTimeProgression>));
206+
let imagesourcesolver = useSolver.getState().solvers[from] as ImageSourceSolver;
181207

208+
const { PropertyTextInput, PropertyNumberInput, PropertyCheckboxInput } = createPropertyInputs<ImageSourceSolver>(
209+
"IMAGESOURCE_SET_PROPERTY"
210+
);
182211

183212
return width < 10 ? null : (
184213
<VerticalContainer>
@@ -197,7 +226,7 @@ export const LTPChart = ({ uuid, width = 400, height = 300, events = false }: LT
197226
key={`legend-quantile-${i}`}
198227
margin="0 5px"
199228
onClick={() => {
200-
if (events) alert(`clicked: ${JSON.stringify(label)}`);
229+
//if (events) alert(`clicked: ${JSON.stringify(label)}`);
201230
}}
202231
>
203232
<svg width={legendGlyphSize} height={legendGlyphSize}>
@@ -206,6 +235,18 @@ export const LTPChart = ({ uuid, width = 400, height = 300, events = false }: LT
206235
<LegendLabel align="left" margin="0 0 0 4px">
207236
{label.text}
208237
</LegendLabel>
238+
<PropertyRowCheckbox
239+
value={imagesourcesolver.plotOrders.includes(label.datum)}
240+
onChange={(e) =>
241+
{
242+
emit("IMAGESOURCE_SET_PROPERTY",{uuid: from,property: "toggleOrder",value: label.datum})
243+
if(this != undefined){
244+
//@ts-ignore
245+
console.log(this.refs.complete.state.checked)
246+
}
247+
}
248+
}
249+
/>
209250
</LegendItem>
210251
))}
211252
</LegendContainer>

src/components/results/LTPTestData.ts

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)