Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms committed Apr 26, 2024
1 parent b3473f7 commit 89a5ec5
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion frontend/src/framework/WorkbenchServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export type GlobalTopicDefinitions = {
"global.infoMessage": string;
"global.hoverRealization": { realization: number } | null;
"global.hoverTimestamp": { timestampUtcMs: number } | null;
"global.md": { md: number } | null;
"global.md": { wellboreUuid: string; md: number } | null;

"global.syncValue.ensembles": EnsembleIdent[];
"global.syncValue.date": { timeOrInterval: string };
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/modules/Grid3D/view/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,15 @@ export function View(props: ModuleViewProps<State, SettingsToViewInterface>): Re
const [hoveredMd, setHoveredMd] = React.useState<number | null>(null);
const [prevHoveredMd, setPrevHoveredMd] = React.useState<number | undefined>(undefined);
const syncedHoveredMd = useSubscribedValue("global.md", props.workbenchServices);
const wellboreUuid = useAtomValue(selectedWellboreUuidAtom);

if (syncedHoveredMd?.md !== prevHoveredMd) {
setPrevHoveredMd(syncedHoveredMd?.md);
setHoveredMd(syncedHoveredMd?.md ?? null);
if (syncedHoveredMd?.wellboreUuid === wellboreUuid) {
setHoveredMd(syncedHoveredMd?.md ?? null);
} else {
setHoveredMd(null);
}
}

const ensembleIdent = useAtomValue(selectedEnsembleIdentAtom);
Expand All @@ -65,7 +70,6 @@ export function View(props: ModuleViewProps<State, SettingsToViewInterface>): Re
"gridModelParameterDateOrInterval"
);
const gridCellIndexRanges = props.viewContext.useSettingsToViewInterfaceValue("gridCellIndexRanges");
const wellboreUuid = useAtomValue(selectedWellboreUuidAtom);
const showGridLines = props.viewContext.useSettingsToViewInterfaceValue("showGridlines");
const intersectionExtensionLength =
props.viewContext.useSettingsToViewInterfaceValue("intersectionExtensionLength");
Expand Down
29 changes: 19 additions & 10 deletions frontend/src/modules/Intersection/view/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React from "react";
import { ModuleViewProps } from "@framework/Module";
import { useViewStatusWriter } from "@framework/StatusWriter";
import { SyncSettingKey, SyncSettingsHelper } from "@framework/SyncSettings";
import { useSubscribedValue } from "@framework/WorkbenchServices";
import { useEnsembleSet } from "@framework/WorkbenchSession";
import { IntersectionType } from "@framework/types/intersection";
import { ColorScaleGradientType } from "@lib/utils/ColorScale";
Expand All @@ -25,16 +26,29 @@ import { State } from "../state";
export function View(props: ModuleViewProps<State, SettingsToViewInterface>): JSX.Element {
const statusWriter = useViewStatusWriter(props.viewContext);
const ensembleSet = useEnsembleSet(props.workbenchSession);
const syncedSettingKeys = props.viewContext.useSyncedSettingKeys();
const syncHelper = new SyncSettingsHelper(syncedSettingKeys, props.workbenchServices);

const colorScale = props.workbenchSettings.useContinuousColorScale({
gradientType: ColorScaleGradientType.Sequential,
});

const ensembleIdent = useAtomValue(selectedEnsembleIdentAtom);
const intersectionReferenceSystem = useAtomValue(intersectionReferenceSystemAtom);
const wellboreHeader = useAtomValue(selectedWellboreAtom);

const syncedSettingKeys = props.viewContext.useSyncedSettingKeys();
const syncHelper = new SyncSettingsHelper(syncedSettingKeys, props.workbenchServices);
const [hoveredMd, setHoveredMd] = React.useState<number | null>(null);
const [prevHoveredMd, setPrevHoveredMd] = React.useState<number | undefined>(undefined);
const syncedHoveredMd = useSubscribedValue("global.md", props.workbenchServices);

if (syncedHoveredMd?.md !== prevHoveredMd) {
setPrevHoveredMd(syncedHoveredMd?.md);
if (syncedHoveredMd?.wellboreUuid === wellboreHeader?.uuid) {
setHoveredMd(syncedHoveredMd?.md ?? null);
} else {
setHoveredMd(null);
}
}

const syncedCameraPosition = syncHelper.useValue(
SyncSettingKey.CAMERA_POSITION_INTERSECTION,
Expand All @@ -48,15 +62,12 @@ export function View(props: ModuleViewProps<State, SettingsToViewInterface>): JS
const gridModelParameterDateOrInterval = props.viewContext.useSettingsToViewInterfaceValue(
"gridModelParameterDateOrInterval"
);
const wellboreHeader = useAtomValue(selectedWellboreAtom);
const showGridLines = props.viewContext.useSettingsToViewInterfaceValue("showGridlines");
const intersectionExtensionLength =
props.viewContext.useSettingsToViewInterfaceValue("intersectionExtensionLength");
const curveFittingEpsilon = props.viewContext.useSettingsToViewInterfaceValue("curveFittingEpsilon");
const intersectionType = useAtomValue(intersectionTypeAtom);

const [hoveredMd, setHoveredMd] = React.useState<number | null>(null);
const [hoveredMd3dGrid, setHoveredMd3dGrid] = React.useState<number | null>(null);
const selectedCustomIntersectionPolyline = useAtomValue(selectedCustomIntersectionPolylineAtom);

let ensembleName = "";
Expand All @@ -77,15 +88,13 @@ export function View(props: ModuleViewProps<State, SettingsToViewInterface>): JS
if (intersectionReferenceSystem) {
if (intersectionType === IntersectionType.WELLBORE) {
const path = intersectionReferenceSystem.path;
console.debug("Wellbore points count: ", path.length);
polylineUtmXy.push(
...calcExtendedSimplifiedWellboreTrajectoryInXYPlane(
path,
intersectionExtensionLength,
curveFittingEpsilon
).flat()
);
console.debug("Wellbore points count after extension: ", polylineUtmXy.length / 2);
} else if (intersectionType === IntersectionType.CUSTOM_POLYLINE && selectedCustomIntersectionPolyline) {
for (const point of selectedCustomIntersectionPolyline.points) {
polylineUtmXy.push(point[0], point[1]);
Expand Down Expand Up @@ -126,11 +135,11 @@ export function View(props: ModuleViewProps<State, SettingsToViewInterface>): JS
const items = event.readoutItems;
const wellboreReadoutItem = items.find((item) => isWellborepathLayer(item.layer));
const md = wellboreReadoutItem?.md;
if (!md) {
if (!md || !wellboreHeader) {
props.workbenchServices.publishGlobalData("global.md", null);
return;
}
props.workbenchServices.publishGlobalData("global.md", { md: md });
props.workbenchServices.publishGlobalData("global.md", { wellboreUuid: wellboreHeader.uuid, md: md });
},
[props.workbenchServices]

Check warning on line 144 in frontend/src/modules/Intersection/view/view.tsx

View workflow job for this annotation

GitHub Actions / frontend

React Hook React.useCallback has a missing dependency: 'wellboreHeader'. Either include it or remove the dependency array
);
Expand All @@ -155,7 +164,7 @@ export function View(props: ModuleViewProps<State, SettingsToViewInterface>): JS
colorScale={colorScale}
showGridLines={showGridLines}
intersectionExtensionLength={potentialIntersectionExtensionLength}
hoveredMd={hoveredMd3dGrid}
hoveredMd={hoveredMd}
onReadout={handleReadout}
onCameraPositionChange={handleCameraPositionChange}
intersectionType={intersectionType}
Expand Down

0 comments on commit 89a5ec5

Please sign in to comment.