Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms committed Apr 18, 2024
1 parent 128e076 commit 3c1e707
Show file tree
Hide file tree
Showing 18 changed files with 172 additions and 95 deletions.
38 changes: 19 additions & 19 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
{
"configurations": [
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": { "host": "localhost", "port": 5678 },
"pathMappings": [
"configurations": [
{
"localRoot": "${workspaceFolder}/backend_py/primary",
"remoteRoot": "/home/appuser/backend_py/primary"
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": { "host": "localhost", "port": 5678 },
"pathMappings": [
{
"localRoot": "${workspaceFolder}/backend_py/primary",
"remoteRoot": "/home/appuser/backend_py/primary"
}
]
},
{
"name": "TS: Launch Chrome and Attach",
"request": "launch",
"type": "chrome",
"webRoot": "${workspaceFolder}/frontend",
"url": "http://localhost:8080"
}
]
},
{
"name": "TS: Launch Chrome and Attach",
"request": "launch",
"type": "chrome",
"webRoot": "${workspaceFolder}/frontend",
"url": "http://localhost:8080"
}
]
]
}
1 change: 0 additions & 1 deletion backend_py/primary/primary/routers/grid3d/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ async def grid_parameter(
Optional[str], Query(description="Time point or time interval string")
] = None,
single_k_layer: Annotated[int, Query(description="Show only a single k layer")] = -1,
parameter_date_or_interval: Annotated[Optional[str], Query(description="Grid parameter date or interval")] = None,
) -> schemas.Grid3dMappedProperty:
"""Get a grid parameter"""

Expand Down
9 changes: 6 additions & 3 deletions frontend/src/api/services/Grid3DService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ export class Grid3DService {
* @param gridName Grid name
* @param parameterName Grid parameter
* @param realizationNum Realization
* @param parameterTimeOrIntervalStr Time point or time interval string
* @param singleKLayer Show only a single k layer
* @param parameterDateOrInterval Grid parameter date or interval
* @returns Grid3dMappedProperty Successful Response
* @throws ApiError
*/
Expand All @@ -119,8 +119,8 @@ export class Grid3DService {
gridName: string,
parameterName: string,
realizationNum: number,
parameterTimeOrIntervalStr?: (string | null),
singleKLayer: number = -1,
parameterDateOrInterval?: (string | null),
): CancelablePromise<Grid3dMappedProperty> {
return this.httpRequest.request({
method: 'GET',
Expand All @@ -131,8 +131,8 @@ export class Grid3DService {
'grid_name': gridName,
'parameter_name': parameterName,
'realization_num': realizationNum,
'parameter_time_or_interval_str': parameterTimeOrIntervalStr,
'single_k_layer': singleKLayer,
'parameter_date_or_interval': parameterDateOrInterval,
},
errors: {
422: `Validation Error`,
Expand All @@ -147,6 +147,7 @@ export class Grid3DService {
* @param parameterName Grid parameter
* @param realizationNum Realization
* @param requestBody
* @param parameterTimeOrIntervalStr Time point or time interval string
* @returns PolylineIntersection Successful Response
* @throws ApiError
*/
Expand All @@ -157,6 +158,7 @@ export class Grid3DService {
parameterName: string,
realizationNum: number,
requestBody: Body_post_get_polyline_intersection,
parameterTimeOrIntervalStr?: (string | null),
): CancelablePromise<PolylineIntersection> {
return this.httpRequest.request({
method: 'POST',
Expand All @@ -167,6 +169,7 @@ export class Grid3DService {
'grid_name': gridName,
'parameter_name': parameterName,
'realization_num': realizationNum,
'parameter_time_or_interval_str': parameterTimeOrIntervalStr,
},
body: requestBody,
mediaType: 'application/json',
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/framework/WorkbenchSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ export class WorkbenchSettings {
};
}

getColorPalettes(): Record<ColorPaletteType, ColorPalette[]> {
return this._colorPalettes;
}

useColorSet(): ColorSet {
const [colorSet, setColorSet] = React.useState<ColorSet>(
new ColorSet(this.getSelectedColorPalette(ColorPaletteType.Categorical))
Expand Down
4 changes: 0 additions & 4 deletions frontend/src/framework/internal/PrivateWorkbenchSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ export class PrivateWorkbenchSettings extends WorkbenchSettings {
});
}

getColorPalettes(): { [key: string]: ColorPalette[] } {
return this._colorPalettes;
}

getSelectedColorPalette(type: ColorPaletteType): ColorPalette {
const colorPalette = this._colorPalettes[type].find((el) => el.getId() === this._selectedColorPalettes[type]);
if (!colorPalette) {
Expand Down
27 changes: 0 additions & 27 deletions frontend/src/modules/Grid3D/queryHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,33 +33,6 @@ export function useGridSurface(
});
}

export function useGridProperty(
caseUuid: string | null,
ensembleName: string | null,
gridName: string | null,
parameterName: string | null,
realizationNum: number | null,
singleKLayer: number,
allowEnable: boolean
): UseQueryResult<GridMappedProperty_trans> {
return useQuery({
queryKey: ["useGridProperty", caseUuid, ensembleName, gridName, parameterName, realizationNum, singleKLayer],
queryFn: () =>
apiService.grid3D.gridParameter(
caseUuid ?? "",
ensembleName ?? "",
gridName ?? "",
parameterName ?? "",
realizationNum ?? 0,
singleKLayer
),
select: transformGridMappedProperty,
staleTime: 0,
gcTime: 0,
enabled: allowEnable && caseUuid && ensembleName && gridName && parameterName && realizationNum !== null ? true : false,
});
}

export function useGridModelInfos(
caseUuid: string | null,
ensembleName: string | null,
Expand Down
5 changes: 5 additions & 0 deletions frontend/src/modules/Grid3D/settings/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ import { Radio } from "@lib/components/RadioGroup";
import { Select, SelectOption } from "@lib/components/Select";
import { Switch } from "@lib/components/Switch";
import { TableSelect, TableSelectOption } from "@lib/components/TableSelect";
import { ColorScale } from "@lib/utils/ColorScale";
import { resolveClassNames } from "@lib/utils/resolveClassNames";

Check failure on line 24 in frontend/src/modules/Grid3D/settings/settings.tsx

View workflow job for this annotation

GitHub Actions / frontend

'resolveClassNames' is defined but never used
import { ColorScaleSelector } from "@modules/_shared/components/ColorScaleSelector/colorScaleSelector";
import { Check, Delete, Edit } from "@mui/icons-material";

Check failure on line 26 in frontend/src/modules/Grid3D/settings/settings.tsx

View workflow job for this annotation

GitHub Actions / frontend

'Check' is defined but never used

import { useAtom, useAtomValue, useSetAtom } from "jotai";
Expand Down Expand Up @@ -199,6 +201,8 @@ export function Settings(props: ModuleSettingsProps<State, SettingsToViewInterfa
}
}

function handleColorScaleChange(colorScale: ColorScale, range: [number, number]) {}

const realizationOptions = makeRealizationOptions(availableRealizations);
const gridModelInfo = gridModelInfos.data?.find((info) => info.grid_name === selectedGridModelName) ?? null;
const datesOrIntervalsForSelectedParameter =
Expand Down Expand Up @@ -270,6 +274,7 @@ export function Settings(props: ModuleSettingsProps<State, SettingsToViewInterfa
max={gridModelDimensions?.k_count}
/>
</Label>
<ColorScaleSelector workbenchSettings={props.workbenchSettings} onChange={handleColorScaleChange} />
</div>
</CollapsibleGroup>
<CollapsibleGroup title="Intersection" expanded>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export function SubsurfaceViewerWrapper(props: SubsurfaceViewerWrapperProps): Re
}
}

function handleDragStart(pickingInfo: PickingInfo): void {
function handleDragStart(): void {
setHoverPreviewPoint(null);
setIsDragging(true);
if (!polylineEditPointsModusActive) {
Expand Down Expand Up @@ -514,7 +514,7 @@ export function SubsurfaceViewerWrapper(props: SubsurfaceViewerWrapperProps): Re
<SubsurfaceViewerWithCameraState
id={subsurfaceViewerId}
layers={layers}
coords={{ visible: false, multiPicking: true }}
coords={{ visible: false, multiPicking: polylineEditPointsModusActive }}
colorTables={props.colorTables}
onMouseEvent={handleMouseEvent}
userCameraInteractionActive={userCameraInteractionActive}
Expand Down Expand Up @@ -788,7 +788,6 @@ function SubsurfaceViewerWithCameraState(props: SubsurfaceViewerWithCameraStateP
const handleCameraChange = React.useCallback(
function handleCameraChange(viewport: ViewStateType): void {
if (props.userCameraInteractionActive || props.userCameraInteractionActive === undefined) {
console.debug(viewport);
setCameraPosition(viewport);
}
},
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/modules/Grid3D/view/queries/gridQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export function useGridParameterQuery(
gridName ?? "",
parameterName ?? "",
realizationNum ?? 0,
singleKLayer,
parameterDateOrValue
parameterDateOrValue,
singleKLayer
),
select: transformGridMappedProperty,
staleTime: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function useGridPolylineIntersection(
ensembleIdent: EnsembleIdent | null,
gridModelName: string | null,
gridModelParameterName: string | null,
gridModelDateOrInterval: string | null,
realizationNum: number | null,
polyline_utm_xy: number[]
): UseQueryResult<PolylineIntersection_trans> {
Expand All @@ -19,6 +20,7 @@ export function useGridPolylineIntersection(
ensembleIdent?.toString() ?? "",
gridModelName,
gridModelParameterName,
gridModelDateOrInterval,
realizationNum,
polyline_utm_xy,
],
Expand All @@ -29,7 +31,8 @@ export function useGridPolylineIntersection(
gridModelName ?? "",
gridModelParameterName ?? "",
realizationNum ?? 0,
{ polyline_utm_xy }
{ polyline_utm_xy },
gridModelDateOrInterval
),
select: transformPolylineIntersection,
staleTime: 0,
Expand Down
15 changes: 12 additions & 3 deletions frontend/src/modules/Grid3D/view/utils/layers.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { BoundingBox3d_api, WellboreTrajectory_api } from "@api";
import { Layer, PickingInfo } from "@deck.gl/core/typed";
import { ColorScale } from "@lib/utils/ColorScale";
import { AxesLayer, Grid3DLayer, WellsLayer } from "@webviz/subsurface-viewer/dist/layers";

import { Rgb, formatRgb, parse } from "culori";
import { Feature } from "geojson";

import {
Expand Down Expand Up @@ -43,7 +45,7 @@ export function makeGrid3DLayer(
gridSurfaceData: GridSurface_trans,
gridParameterData: GridMappedProperty_trans,
showGridLines: boolean,
gridMinAndMaxPropValues: [number, number]
colorScale: ColorScale
): WorkingGrid3dLayer {
const offsetXyz = [gridSurfaceData.origin_utm_x, gridSurfaceData.origin_utm_y, 0];
const pointsNumberArray = gridSurfaceData.pointsFloat32Arr.map((val, i) => val + offsetXyz[i % 3]);
Expand All @@ -53,12 +55,19 @@ export function makeGrid3DLayer(
pointsData: pointsNumberArray,
polysData: polysNumberArray,
propertiesData: gridParameterData.polyPropsFloat32Arr,
colorMapName: "Continuous",
colorMapRange: gridMinAndMaxPropValues,
ZIncreasingDownwards: false,
gridLines: showGridLines,
material: { ambient: 0.4, diffuse: 0.7, shininess: 8, specularColor: [25, 25, 25] },
pickable: true,
colorMapFunction: (value: number) => {
const interpolatedColor = colorScale.getColorPalette().getInterpolatedColor(value);
// const nonNormalizedValue = value * (colorScale.getMax() - colorScale.getMin()) + colorScale.getMin();
const color = parse(interpolatedColor) as Rgb; // colorScale.getColorForValue(nonNormalizedValue)) as Rgb;
if (color === undefined) {
return [0, 0, 0];
}
return [color.r * 255, color.g * 255, color.b * 255];
},
});
return grid3dLayer as unknown as WorkingGrid3dLayer;
}
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/modules/Grid3D/view/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export function View(props: ModuleViewProps<State, SettingsToViewInterface>): Re
ensembleIdent ?? null,
gridModelName,
gridModelParameterName,
gridModelParameterDateOrInterval,
realization,
polylineUtmXy
);
Expand Down Expand Up @@ -244,9 +245,8 @@ export function View(props: ModuleViewProps<State, SettingsToViewInterface>): Re
if (gridSurfaceQuery.data && gridParameterQuery.data) {
const minPropValue = gridParameterQuery.data.min_grid_prop_value;
const maxPropValue = gridParameterQuery.data.max_grid_prop_value;
layers.push(
makeGrid3DLayer(gridSurfaceQuery.data, gridParameterQuery.data, showGridLines, [minPropValue, maxPropValue])
);
colorScale.setRange(minPropValue, maxPropValue);
layers.push(makeGrid3DLayer(gridSurfaceQuery.data, gridParameterQuery.data, showGridLines, colorScale));

if (polylineIntersectionQuery.data) {
layers.push(
Expand Down
26 changes: 0 additions & 26 deletions frontend/src/modules/Intersection/queryHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,6 @@ export function useGridSurface(
});
}

export function useGridProperty(
caseUuid: string | null,
ensembleName: string | null,
gridName: string | null,
parameterName: string | null,
realizationNum: number | null,
singleKLayer: number = -1
): UseQueryResult<GridMappedProperty_trans> {
return useQuery({
queryKey: ["useGridProperty", caseUuid, ensembleName, gridName, parameterName, realizationNum, singleKLayer],
queryFn: () =>
apiService.grid3D.gridParameter(
caseUuid ?? "",
ensembleName ?? "",
gridName ?? "",
parameterName ?? "",
realizationNum ?? 0,
singleKLayer
),
select: transformGridMappedProperty,
staleTime: 0,
gcTime: 0,
enabled: caseUuid && ensembleName && gridName && parameterName && realizationNum !== null ? true : false,
});
}

export function useGridModelInfos(
caseUuid: string | null,
ensembleName: string | null,
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/modules/Intersection/view/queries/gridQueries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export function useGridParameterQuery(
gridName ?? "",
parameterName ?? "",
realizationNum ?? 0,
singleKLayer,
parameterDateOrValue
parameterDateOrValue,
singleKLayer
),
select: transformGridMappedProperty,
staleTime: 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function useGridPolylineIntersection(
ensembleIdent: EnsembleIdent | null,
gridModelName: string | null,
gridModelParameterName: string | null,
gridModelDateOrInterval: string | null,
realizationNum: number | null,
polyline_utm_xy: number[]
): UseQueryResult<PolylineIntersection_trans> {
Expand All @@ -19,6 +20,7 @@ export function useGridPolylineIntersection(
ensembleIdent?.toString() ?? "",
gridModelName,
gridModelParameterName,
gridModelDateOrInterval,
realizationNum,
polyline_utm_xy,
],
Expand All @@ -29,7 +31,8 @@ export function useGridPolylineIntersection(
gridModelName ?? "",
gridModelParameterName ?? "",
realizationNum ?? 0,
{ polyline_utm_xy }
{ polyline_utm_xy },
gridModelDateOrInterval
),
select: transformPolylineIntersection,
staleTime: 0,
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/modules/Intersection/view/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export function View(props: ModuleViewProps<State, SettingsToViewInterface>): JS
ensembleIdent ?? null,
gridModelName,
gridModelParameterName,
gridModelParameterDateOrInterval,
realization,

polylineUtmXy
);
if (polylineIntersectionQuery.isError) {
Expand Down
Loading

0 comments on commit 3c1e707

Please sign in to comment.