Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Co-authored-by: Hans Kallekleiv <[email protected]>
  • Loading branch information
rubenthoms and HansKallekleiv committed Apr 12, 2024
1 parent 0cd01ff commit b60aed1
Show file tree
Hide file tree
Showing 11 changed files with 761 additions and 149 deletions.
4 changes: 3 additions & 1 deletion frontend/src/lib/components/Checkbox/checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ export const Checkbox: React.FC<CheckboxProps> = (props) => {

const handleChange = React.useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
setChecked(event.target.checked);
if (props.checked === undefined) {
setChecked(event.target.checked);
}
onChange && onChange(event, event.target.checked);
},
[setChecked, onChange]

Check warning on line 35 in frontend/src/lib/components/Checkbox/checkbox.tsx

View workflow job for this annotation

GitHub Actions / frontend

React Hook React.useCallback has a missing dependency: 'props.checked'. Either include it or remove the dependency array
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/lib/components/Overlay/overlay.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from "react";

import { createPortal } from "@lib/utils/createPortal";

export type OverlayProps = {
visible: boolean;
};

export const Overlay: React.FC<OverlayProps> = (props: OverlayProps) => {
return (
return createPortal(
<div
className="fixed inset-0 z-50 bg-black bg-opacity-50"
style={{ display: props.visible ? "block" : "none" }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export const userSelectedGridModelNameAtom = atom<string | null>(null);
export const userSelectedGridModelParameterNameAtom = atom<string | null>(null);
export const userSelectedGridModelParameterDateOrIntervalAtom = atom<string | null>(null);
export const userSelectedWellboreUuidAtom = atom<string | null>(null);
export const userSelectedCustomIntersectionPolylineIdAtom = atom<string | null>(null);
314 changes: 298 additions & 16 deletions frontend/src/modules/Grid3DIntersection/settings/settings.tsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type SettingsToViewInterface = {
export const interfaceInitialization: InterfaceInitialization<SettingsToViewInterface> = {
baseStates: {
showGridlines: false,
gridLayer: -1,
gridLayer: 1,
zFactor: 1,
intersectionExtensionLength: 1000,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ import { EnsembleSetAtom } from "@framework/GlobalAtoms";

import { atom } from "jotai";

import { userSelectedEnsembleIdentAtom, userSelectedWellboreUuidAtom } from "../settings/atoms/baseAtoms";
import {
userSelectedCustomIntersectionPolylineIdAtom,
userSelectedEnsembleIdentAtom,
userSelectedWellboreUuidAtom,
} from "../settings/atoms/baseAtoms";
import { drilledWellboreHeadersQueryAtom } from "../settings/atoms/queryAtoms";
import { CustomIntersectionPolyline, IntersectionType } from "../typesAndEnums";

export const selectedEnsembleIdentAtom = atom<EnsembleIdent | null>((get) => {
const ensembleSet = get(EnsembleSetAtom);
Expand Down Expand Up @@ -34,3 +39,28 @@ export const selectedWellboreUuidAtom = atom((get) => {

return userSelectedWellboreUuid;
});

export const intersectionTypeAtom = atom<IntersectionType>(IntersectionType.WELLBORE);
export const addCustomIntersectionPolylineEditModeActiveAtom = atom<boolean>(false);
export const editCustomIntersectionPolylineEditModeActiveAtom = atom<boolean>(false);

export const currentCustomIntersectionPolylineAtom = atom<number[][]>([]);

export const customIntersectionPolylinesAtom = atom<CustomIntersectionPolyline[]>([]);
export const selectedCustomIntersectionPolylineIdAtom = atom((get) => {
const userSelectedCustomIntersectionPolylineId = get(userSelectedCustomIntersectionPolylineIdAtom);
const customIntersectionPolylines = get(customIntersectionPolylinesAtom);

if (!customIntersectionPolylines.length) {
return null;
}

if (
!userSelectedCustomIntersectionPolylineId ||
!customIntersectionPolylines.some((el) => el.id === userSelectedCustomIntersectionPolylineId)
) {
return customIntersectionPolylines[0].id;
}

return userSelectedCustomIntersectionPolylineId;
});
10 changes: 10 additions & 0 deletions frontend/src/modules/Grid3DIntersection/typesAndEnums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export enum IntersectionType {
CUSTOM_POLYLINE = "custom-polyline",
WELLBORE = "wellbore",
}

export type CustomIntersectionPolyline = {
id: string;
name: string;
polyline: number[][];
};
63 changes: 46 additions & 17 deletions frontend/src/modules/Grid3DIntersection/view/atoms/derivedAtoms.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,63 @@
import { IntersectionReferenceSystem } from "@equinor/esv-intersection";
import { selectedWellboreUuidAtom } from "@modules/Grid3DIntersection/sharedAtoms/sharedAtoms";
import {
currentCustomIntersectionPolylineAtom,

Check failure on line 3 in frontend/src/modules/Grid3DIntersection/view/atoms/derivedAtoms.ts

View workflow job for this annotation

GitHub Actions / frontend

'currentCustomIntersectionPolylineAtom' is defined but never used
customIntersectionPolylinesAtom,
intersectionTypeAtom,
selectedCustomIntersectionPolylineIdAtom,
selectedWellboreUuidAtom,
} from "@modules/Grid3DIntersection/sharedAtoms/sharedAtoms";
import { IntersectionType } from "@modules/Grid3DIntersection/typesAndEnums";

import { atom } from "jotai";

import { fieldWellboreTrajectoriesQueryAtom } from "./queryAtoms";

export const selectedCustomIntersectionPolylineAtom = atom((get) => {
const customIntersectionPolylineId = get(selectedCustomIntersectionPolylineIdAtom);
const customIntersectionPolylines = get(customIntersectionPolylinesAtom);

return customIntersectionPolylines.find((el) => el.id === customIntersectionPolylineId);
});

export const intersectionReferenceSystemAtom = atom((get) => {
const fieldWellboreTrajectories = get(fieldWellboreTrajectoriesQueryAtom);
const wellboreUuid = get(selectedWellboreUuidAtom);

if (!fieldWellboreTrajectories.data || !wellboreUuid) {
return null;
}
const customIntersectionPolyline = get(selectedCustomIntersectionPolylineAtom);
const intersectionType = get(intersectionTypeAtom);

if (intersectionType === IntersectionType.WELLBORE) {
if (!fieldWellboreTrajectories.data || !wellboreUuid) {
return null;
}

const wellboreTrajectory = fieldWellboreTrajectories.data.find(
(wellbore) => wellbore.wellbore_uuid === wellboreUuid
);
const wellboreTrajectory = fieldWellboreTrajectories.data.find(
(wellbore) => wellbore.wellbore_uuid === wellboreUuid
);

if (wellboreTrajectory) {
const path: number[][] = [];
for (const [index, northing] of wellboreTrajectory.northing_arr.entries()) {
const easting = wellboreTrajectory.easting_arr[index];
const tvd_msl = wellboreTrajectory.tvd_msl_arr[index];
if (wellboreTrajectory) {
const path: number[][] = [];
for (const [index, northing] of wellboreTrajectory.northing_arr.entries()) {
const easting = wellboreTrajectory.easting_arr[index];
const tvd_msl = wellboreTrajectory.tvd_msl_arr[index];

path.push([easting, northing, tvd_msl]);
}
const offset = wellboreTrajectory.tvd_msl_arr[0];
path.push([easting, northing, tvd_msl]);
}
const offset = wellboreTrajectory.tvd_msl_arr[0];

const referenceSystem = new IntersectionReferenceSystem(path);
referenceSystem.offset = offset;

const referenceSystem = new IntersectionReferenceSystem(path);
referenceSystem.offset = offset;
return referenceSystem;
}
} else if (intersectionType === IntersectionType.CUSTOM_POLYLINE && customIntersectionPolyline) {
if (customIntersectionPolyline.polyline.length < 2) {
return null;
}
const referenceSystem = new IntersectionReferenceSystem(
customIntersectionPolyline.polyline.map((point) => [point[0], point[1], 0])
);
referenceSystem.offset = 0;

return referenceSystem;
}
Expand Down
Loading

0 comments on commit b60aed1

Please sign in to comment.