From 7f6d852076a0f77d335f759d0270f72ad6ad64c5 Mon Sep 17 00:00:00 2001 From: Ruben Thoms Date: Tue, 20 Aug 2024 17:09:51 +0200 Subject: [PATCH] Adjustments after merging and wip --- ...ttingsToViewInterface.ts => interfaces.ts} | 6 +- frontend/src/modules/2DViewer/loadModule.tsx | 5 +- .../src/modules/2DViewer/registerModule.ts | 4 +- .../modules/2DViewer/settings/settings.tsx | 5 +- frontend/src/modules/2DViewer/state.ts | 1 - frontend/src/modules/2DViewer/view/view.tsx | 5 +- .../src/modules/Intersection/interfaces.ts | 2 +- .../Intersection/settings/settings.tsx | 2 - .../Intersection/settingsToViewInterface.ts | 76 ------------------- .../view/components/layersWrapper.tsx | 3 +- .../src/modules/Intersection/view/view.tsx | 3 +- .../components/Layers/addLayerDropdown.tsx | 4 +- 12 files changed, 19 insertions(+), 97 deletions(-) rename frontend/src/modules/2DViewer/{settingsToViewInterface.ts => interfaces.ts} (67%) delete mode 100644 frontend/src/modules/2DViewer/state.ts delete mode 100644 frontend/src/modules/Intersection/settingsToViewInterface.ts diff --git a/frontend/src/modules/2DViewer/settingsToViewInterface.ts b/frontend/src/modules/2DViewer/interfaces.ts similarity index 67% rename from frontend/src/modules/2DViewer/settingsToViewInterface.ts rename to frontend/src/modules/2DViewer/interfaces.ts index 102976294..f7c233450 100644 --- a/frontend/src/modules/2DViewer/settingsToViewInterface.ts +++ b/frontend/src/modules/2DViewer/interfaces.ts @@ -7,7 +7,11 @@ export type SettingsToViewInterface = { layerManager: LayerManager; }; -export const interfaceInitialization: InterfaceInitialization = { +export type Interfaces = { + settingsToView: SettingsToViewInterface; +}; + +export const settingsToViewInterfaceInitialization: InterfaceInitialization = { layerManager: (get) => { return get(layerManagerAtom); }, diff --git a/frontend/src/modules/2DViewer/loadModule.tsx b/frontend/src/modules/2DViewer/loadModule.tsx index af2a9945d..5b15739f3 100644 --- a/frontend/src/modules/2DViewer/loadModule.tsx +++ b/frontend/src/modules/2DViewer/loadModule.tsx @@ -1,12 +1,11 @@ import { ModuleRegistry } from "@framework/ModuleRegistry"; +import { Interfaces, settingsToViewInterfaceInitialization } from "./interfaces"; import { MODULE_NAME } from "./registerModule"; import { Settings } from "./settings/settings"; -import { SettingsToViewInterface, interfaceInitialization } from "./settingsToViewInterface"; -import { State } from "./state"; import { View } from "./view/view"; -const module = ModuleRegistry.initModule(MODULE_NAME, {}, {}, interfaceInitialization); +const module = ModuleRegistry.initModule(MODULE_NAME, { settingsToViewInterfaceInitialization }); module.settingsFC = Settings; module.viewFC = View; diff --git a/frontend/src/modules/2DViewer/registerModule.ts b/frontend/src/modules/2DViewer/registerModule.ts index a434e198c..5f0b9d195 100644 --- a/frontend/src/modules/2DViewer/registerModule.ts +++ b/frontend/src/modules/2DViewer/registerModule.ts @@ -1,11 +1,11 @@ import { ModuleCategory, ModuleDevState } from "@framework/Module"; import { ModuleRegistry } from "@framework/ModuleRegistry"; -import { State } from "./state"; +import { Interfaces } from "./interfaces"; export const MODULE_NAME = "2DViewer"; -ModuleRegistry.registerModule({ +ModuleRegistry.registerModule({ moduleName: MODULE_NAME, category: ModuleCategory.MAIN, devState: ModuleDevState.DEV, diff --git a/frontend/src/modules/2DViewer/settings/settings.tsx b/frontend/src/modules/2DViewer/settings/settings.tsx index 6380f6256..dba023c30 100644 --- a/frontend/src/modules/2DViewer/settings/settings.tsx +++ b/frontend/src/modules/2DViewer/settings/settings.tsx @@ -27,16 +27,15 @@ import { PolygonLayerSettingsComponent } from "./components/layerSettings/polygo import { SurfaceLayerSettingsComponent } from "./components/layerSettings/surfaceLayer"; import { WellboreLayerSettingsComponent } from "./components/layerSettings/wellboreLayer"; +import { Interfaces } from "../interfaces"; import { isFaultPolygonLayer } from "../layers/FaultPolygonLayer"; import { LayerFactory } from "../layers/LayerFactory"; import { isPolygonLayer } from "../layers/PolygonLayer"; import { isSurfaceLayer } from "../layers/SurfaceLayer"; import { isWellboreLayer } from "../layers/WellboreLayer"; import { LAYER_TYPE_TO_STRING_MAPPING, LayerType } from "../layers/types"; -import { SettingsToViewInterface } from "../settingsToViewInterface"; -import { State } from "../state"; -export function Settings(props: ModuleSettingsProps): React.ReactNode { +export function Settings(props: ModuleSettingsProps): React.ReactNode { const ensembleSet = useEnsembleSet(props.workbenchSession); const selectedFieldIdentifier = useAtomValue(selectedFieldIdentifierAtom); diff --git a/frontend/src/modules/2DViewer/state.ts b/frontend/src/modules/2DViewer/state.ts deleted file mode 100644 index 90ff7f709..000000000 --- a/frontend/src/modules/2DViewer/state.ts +++ /dev/null @@ -1 +0,0 @@ -export type State = Record; diff --git a/frontend/src/modules/2DViewer/view/view.tsx b/frontend/src/modules/2DViewer/view/view.tsx index 9b210c07c..33eae06d1 100644 --- a/frontend/src/modules/2DViewer/view/view.tsx +++ b/frontend/src/modules/2DViewer/view/view.tsx @@ -18,14 +18,13 @@ import { Axes2DLayer, MapLayer, WellsLayer } from "@webviz/subsurface-viewer/dis import { Rgb, parse } from "culori"; import { isEqual } from "lodash"; +import { Interfaces } from "../interfaces"; import { FaultPolygonLayer } from "../layers/FaultPolygonLayer"; import { PolygonLayer } from "../layers/PolygonLayer"; import { SurfaceLayer } from "../layers/SurfaceLayer"; import { WellboreLayer } from "../layers/WellboreLayer"; -import { SettingsToViewInterface } from "../settingsToViewInterface"; -import { State } from "../state"; -export function View(props: ModuleViewProps): React.ReactNode { +export function View(props: ModuleViewProps): React.ReactNode { const statusWriter = useViewStatusWriter(props.viewContext); const layerManager = props.viewContext.useSettingsToViewInterfaceValue("layerManager"); const allItems = useLayerManagerTopicValue(layerManager, LayerManagerTopic.ITEMS_CHANGED); diff --git a/frontend/src/modules/Intersection/interfaces.ts b/frontend/src/modules/Intersection/interfaces.ts index ccac90da8..7ab415bd3 100644 --- a/frontend/src/modules/Intersection/interfaces.ts +++ b/frontend/src/modules/Intersection/interfaces.ts @@ -2,6 +2,7 @@ import { EnsembleIdent } from "@framework/EnsembleIdent"; import { InterfaceInitialization } from "@framework/UniDirectionalModuleComponentsInterface"; import { IntersectionType } from "@framework/types/intersection"; import { ColorScale } from "@lib/utils/ColorScale"; +import { LayerManager } from "@modules/_shared/layers/LayerManager"; import { gridLayerAtom, @@ -19,7 +20,6 @@ import { selectedWellboreAtom, } from "./settings/atoms/derivedAtoms"; import { WellboreHeader } from "./typesAndEnums"; -import { LayerManager } from "./utils/layers/LayerManager"; export type SettingsToViewInterface = { showGridlines: boolean; diff --git a/frontend/src/modules/Intersection/settings/settings.tsx b/frontend/src/modules/Intersection/settings/settings.tsx index 9e78abbd2..dd61e6833 100644 --- a/frontend/src/modules/Intersection/settings/settings.tsx +++ b/frontend/src/modules/Intersection/settings/settings.tsx @@ -51,7 +51,6 @@ import { SurfacesUncertaintyLayerSettingsComponent } from "./components/layerSet import { WellpicksLayerSettingsComponent } from "./components/layerSettings/wellpicksLayer"; import { Interfaces } from "../interfaces"; -import { State } from "../state"; import { isGridLayer } from "../utils/layers/GridLayer"; import { LayerFactory } from "../utils/layers/LayerFactory"; import { isSeismicLayer } from "../utils/layers/SeismicLayer"; @@ -59,7 +58,6 @@ import { isSurfaceLayer } from "../utils/layers/SurfaceLayer"; import { isSurfacesUncertaintyLayer } from "../utils/layers/SurfacesUncertaintyLayer"; import { isWellpicksLayer } from "../utils/layers/WellpicksLayer"; import { LAYER_TYPE_TO_STRING_MAPPING, LayerType } from "../utils/layers/types"; -import { ViewAtoms } from "../view/atoms/atomDefinitions"; export function Settings(props: ModuleSettingsProps): JSX.Element { const ensembleSet = useEnsembleSet(props.workbenchSession); diff --git a/frontend/src/modules/Intersection/settingsToViewInterface.ts b/frontend/src/modules/Intersection/settingsToViewInterface.ts deleted file mode 100644 index 974c630ae..000000000 --- a/frontend/src/modules/Intersection/settingsToViewInterface.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { InterfaceInitialization } from "@framework/UniDirectionalModuleComponentsInterface"; -import { IntersectionType } from "@framework/types/intersection"; -import { ColorScale } from "@lib/utils/ColorScale"; -import { LayerManager } from "@modules_shared/layers/LayerManager"; - -import { - gridLayerAtom, - intersectionExtensionLengthAtom, - intersectionTypeAtom, - seismicColorScaleAtom, - showGridlinesAtom, - showSeismicAtom, - zFactorAtom, -} from "./settings/atoms/baseAtoms"; -import { - layerManagerAtom, - selectedCustomIntersectionPolylineIdAtom, - selectedEnsembleIdentAtom, - selectedWellboreAtom, -} from "./settings/atoms/derivedAtoms"; - -export type SettingsToViewInterface = { - showGridlines: boolean; - gridLayer: number; - zFactor: number; - intersectionExtensionLength: number; - intersectionType: IntersectionType; - seismicColorScale: ColorScale | null; - showSeismic: boolean; - ensembleIdent: EnsembleIdent | null; - selectedCustomIntersectionPolylineId: string | null; - layerManager: LayerManager; - wellboreHeader: { - uuid: string; - identifier: string; - depthReferencePoint: string; - depthReferenceElevation: number; - } | null; -}; - -export const interfaceInitialization: InterfaceInitialization = { - showGridlines: (get) => { - return get(showGridlinesAtom); - }, - gridLayer: (get) => { - return get(gridLayerAtom); - }, - zFactor: (get) => { - return get(zFactorAtom); - }, - intersectionExtensionLength: (get) => { - return get(intersectionExtensionLengthAtom); - }, - intersectionType: (get) => { - return get(intersectionTypeAtom); - }, - seismicColorScale: (get) => { - return get(seismicColorScaleAtom); - }, - showSeismic: (get) => { - return get(showSeismicAtom); - }, - ensembleIdent: (get) => { - return get(selectedEnsembleIdentAtom); - }, - selectedCustomIntersectionPolylineId: (get) => { - return get(selectedCustomIntersectionPolylineIdAtom); - }, - layerManager: (get) => { - return get(layerManagerAtom); - }, - wellboreHeader: (get) => { - return get(selectedWellboreAtom); - }, -}; diff --git a/frontend/src/modules/Intersection/view/components/layersWrapper.tsx b/frontend/src/modules/Intersection/view/components/layersWrapper.tsx index c663a65f0..f706244ff 100644 --- a/frontend/src/modules/Intersection/view/components/layersWrapper.tsx +++ b/frontend/src/modules/Intersection/view/components/layersWrapper.tsx @@ -19,14 +19,13 @@ import { makeSurfaceStatisticalFanchartFromRealizationSurface } from "@framework import { IntersectionType } from "@framework/types/intersection"; import { useElementBoundingRect } from "@lib/hooks/useElementBoundingRect"; import { Interfaces } from "@modules/Intersection/interfaces"; -import { BaseLayer, LayerStatus, useLayers } from "@modules/Intersection/utils/layers/BaseLayer"; import { GridLayer, isGridLayer } from "@modules/Intersection/utils/layers/GridLayer"; import { SeismicLayer, isSeismicLayer } from "@modules/Intersection/utils/layers/SeismicLayer"; import { isSurfaceLayer } from "@modules/Intersection/utils/layers/SurfaceLayer"; import { isSurfacesUncertaintyLayer } from "@modules/Intersection/utils/layers/SurfacesUncertaintyLayer"; import { isWellpicksLayer } from "@modules/Intersection/utils/layers/WellpicksLayer"; +import { BaseLayer, LayerStatus, useLayers } from "@modules/_shared/layers/BaseLayer"; import { ColorLegendsContainer } from "@modules_shared/components/ColorLegendsContainer"; -import { BaseLayer, LayerStatus, useLayers } from "@modules_shared/layers/BaseLayer"; import { isEqual } from "lodash"; diff --git a/frontend/src/modules/Intersection/view/view.tsx b/frontend/src/modules/Intersection/view/view.tsx index 1aae13ddc..d2f85c5c7 100644 --- a/frontend/src/modules/Intersection/view/view.tsx +++ b/frontend/src/modules/Intersection/view/view.tsx @@ -6,7 +6,7 @@ import { useEnsembleSet } from "@framework/WorkbenchSession"; import { IntersectionType } from "@framework/types/intersection"; import { CircularProgress } from "@lib/components/CircularProgress"; import { resolveClassNames } from "@lib/utils/resolveClassNames"; -import { BaseLayer, LayerStatus, useLayersStatuses } from "@modules_shared/layers/BaseLayer"; +import { BaseLayer, LayerStatus, useLayersStatuses } from "@modules/_shared/layers/BaseLayer"; import { LayerManagerTopic, useLayerManagerTopicValue } from "@modules_shared/layers/LayerManager"; import { useAtomValue } from "jotai"; @@ -17,7 +17,6 @@ import { LayersWrapper } from "./components/layersWrapper"; import { useWellboreCasingsQuery } from "./queries/wellboreSchematicsQueries"; import { Interfaces } from "../interfaces"; -import { LayerStatus, useLayersStatuses } from "../utils/layers/BaseLayer"; import { isGridLayer } from "../utils/layers/GridLayer"; import { isSeismicLayer } from "../utils/layers/SeismicLayer"; import { isSurfaceLayer } from "../utils/layers/SurfaceLayer"; diff --git a/frontend/src/modules/_shared/components/Layers/addLayerDropdown.tsx b/frontend/src/modules/_shared/components/Layers/addLayerDropdown.tsx index cd8b44218..35f08ff99 100644 --- a/frontend/src/modules/_shared/components/Layers/addLayerDropdown.tsx +++ b/frontend/src/modules/_shared/components/Layers/addLayerDropdown.tsx @@ -19,7 +19,9 @@ export type AddLayerDropdownProps = { export function AddLayerDropdown(props: AddLayerDropdownProps): React.ReactNode { function handleAddLayer(type: TLayerType) { - props.parent.prependItem(props.layerFactory.makeLayer(type, props.layerManager)); + const layer = props.layerFactory.makeLayer(type, props.layerManager); + layer.setQueryClient(props.layerManager.getQueryClient()); + props.parent.prependItem(layer); } return (