From de77569cef02d5e52f618c299c12238124033521 Mon Sep 17 00:00:00 2001 From: Ruben Thoms Date: Mon, 16 Sep 2024 13:37:19 +0200 Subject: [PATCH] Replaced old `2DViewer` with new implementation --- frontend/src/modules/2DViewer/interfaces.ts | 6 +- .../2DViewer/layers/FaultPolygonLayer.ts | 129 ------ .../modules/2DViewer/layers/LayerFactory.ts | 24 - .../layers/LayerManager.ts | 0 .../modules/2DViewer/layers/PolygonLayer.ts | 116 ----- .../layers/PublishSubscribeHandler.ts | 0 .../layers/SettingsGroup.ts | 0 .../layers/SharedSetting.ts | 0 .../modules/2DViewer/layers/SurfaceLayer.ts | 159 ------- .../{LayerSpike => 2DViewer}/layers/View.ts | 0 .../modules/2DViewer/layers/WellboreLayer.ts | 111 ----- .../layers/components/GroupComponent.tsx | 0 .../layers/components/LayerComponent.tsx | 0 .../layers/components/SettingComponent.tsx | 0 .../components/SharedSettingComponent.tsx | 0 .../layers/components/editNameComponent.tsx | 0 .../layers/components/layersActions.tsx | 0 .../components/removeButtonComponent.tsx | 0 .../layers/components/utils.tsx | 0 .../components/visibilityToggleComponent.tsx | 0 .../layers/delegates/GroupDelegate.ts | 0 .../layers/delegates/ItemDelegate.ts | 0 .../layers/delegates/LayerDelegate.ts | 0 .../layers/delegates/SettingDelegate.ts | 0 .../delegates/SettingsContextDelegate.ts | 0 .../layers/implementations/View.ts | 0 .../DrilledWellTrajectoriesContext.ts | 6 +- .../DrilledWellTrajectoriesLayer.ts | 6 +- .../DrilledWellTrajectoriesLayer/types.ts | 2 +- .../ObservedSurfaceContext.ts | 6 +- .../ObservedSurfaceLayer.ts | 6 +- .../layers/ObservedSurfaceLayer/types.ts | 2 +- .../RealizationGridContext.ts | 6 +- .../RealizationGridLayer.ts | 6 +- .../layers/RealizationGridLayer/types.ts | 2 +- .../RealizationPolygonsContext.ts | 6 +- .../RealizationPolygonsLayer.ts | 8 +- .../layers/RealizationPolygonsLayer/types.ts | 0 .../RealizationSurfaceContext.ts | 6 +- .../RealizationSurfaceLayer.ts | 8 +- .../layers/RealizationSurfaceLayer/types.ts | 0 .../StatisticalSurfaceContext.ts | 2 +- .../StatisticalSurfaceLayer.ts | 8 +- .../layers/StatisticalSurfaceLayer/types.ts | 2 +- .../settings/DrilledWellbores.tsx | 0 .../implementations/settings/Ensemble.tsx | 0 .../settings/GridAttribute.tsx | 0 .../implementations/settings/GridLayer.tsx | 0 .../implementations/settings/GridName.tsx | 0 .../settings/PolygonsAttribute.tsx | 0 .../implementations/settings/PolygonsName.tsx | 0 .../implementations/settings/Realization.tsx | 0 .../implementations/settings/Sensitivity.tsx | 0 .../settings/StatisticFunction.tsx | 0 .../settings/SurfaceAttribute.tsx | 0 .../implementations/settings/SurfaceName.tsx | 0 .../settings/TimeOrInterval.tsx | 0 .../layers/interfaces.ts | 0 .../layers/queryConstants.ts | 0 .../layers/settingsTypes.ts | 0 frontend/src/modules/2DViewer/layers/types.ts | 13 - frontend/src/modules/2DViewer/loadModule.tsx | 4 +- .../src/modules/2DViewer/registerModule.ts | 2 +- .../2DViewer/settings/atoms/baseAtoms.ts | 3 + .../2DViewer/settings/atoms/derivedAtoms.ts | 10 - .../components/ensembleStageSelect.tsx | 241 ---------- .../layerSettings/faultPolygonLayer.tsx | 230 ---------- .../components/layerSettings/polygonLayer.tsx | 240 ---------- .../components/layerSettings/surfaceLayer.tsx | 273 ----------- .../components/layerSettings/utils.ts | 19 - .../layerSettings/wellboreLayer.tsx | 128 ------ .../modules/2DViewer/settings/settings.tsx | 428 ++++++++++-------- .../modules/{LayerSpike => 2DViewer}/types.ts | 0 .../view/layerFactory.ts | 0 frontend/src/modules/2DViewer/view/view.tsx | 351 +++++--------- frontend/src/modules/LayerSpike/interfaces.ts | 18 - .../src/modules/LayerSpike/loadModule.tsx | 13 - .../src/modules/LayerSpike/registerModule.ts | 13 - .../LayerSpike/settings/atoms/baseAtoms.ts | 6 - .../LayerSpike/settings/atoms/derivedAtoms.ts | 31 -- .../modules/LayerSpike/settings/settings.tsx | 259 ----------- frontend/src/modules/LayerSpike/view/view.tsx | 176 ------- frontend/src/modules/registerAllModules.ts | 4 +- 83 files changed, 397 insertions(+), 2692 deletions(-) delete mode 100644 frontend/src/modules/2DViewer/layers/FaultPolygonLayer.ts delete mode 100644 frontend/src/modules/2DViewer/layers/LayerFactory.ts rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/LayerManager.ts (100%) delete mode 100644 frontend/src/modules/2DViewer/layers/PolygonLayer.ts rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/PublishSubscribeHandler.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/SettingsGroup.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/SharedSetting.ts (100%) delete mode 100644 frontend/src/modules/2DViewer/layers/SurfaceLayer.ts rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/View.ts (100%) delete mode 100644 frontend/src/modules/2DViewer/layers/WellboreLayer.ts rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/components/GroupComponent.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/components/LayerComponent.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/components/SettingComponent.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/components/SharedSettingComponent.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/components/editNameComponent.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/components/layersActions.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/components/removeButtonComponent.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/components/utils.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/components/visibilityToggleComponent.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/delegates/GroupDelegate.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/delegates/ItemDelegate.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/delegates/LayerDelegate.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/delegates/SettingDelegate.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/delegates/SettingsContextDelegate.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/View.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesContext.ts (95%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesLayer.ts (92%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/DrilledWellTrajectoriesLayer/types.ts (78%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceContext.ts (96%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceLayer.ts (93%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/ObservedSurfaceLayer/types.ts (80%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/RealizationGridLayer/RealizationGridContext.ts (97%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/RealizationGridLayer/RealizationGridLayer.ts (95%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/RealizationGridLayer/types.ts (84%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsContext.ts (96%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsLayer.ts (89%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/RealizationPolygonsLayer/types.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceContext.ts (97%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceLayer.ts (91%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/RealizationSurfaceLayer/types.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceContext.ts (99%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer.ts (93%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/layers/StatisticalSurfaceLayer/types.ts (88%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/DrilledWellbores.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/Ensemble.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/GridAttribute.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/GridLayer.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/GridName.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/PolygonsAttribute.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/PolygonsName.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/Realization.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/Sensitivity.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/StatisticFunction.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/SurfaceAttribute.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/SurfaceName.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/implementations/settings/TimeOrInterval.tsx (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/interfaces.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/queryConstants.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/layers/settingsTypes.ts (100%) delete mode 100644 frontend/src/modules/2DViewer/layers/types.ts delete mode 100644 frontend/src/modules/2DViewer/settings/components/ensembleStageSelect.tsx delete mode 100644 frontend/src/modules/2DViewer/settings/components/layerSettings/faultPolygonLayer.tsx delete mode 100644 frontend/src/modules/2DViewer/settings/components/layerSettings/polygonLayer.tsx delete mode 100644 frontend/src/modules/2DViewer/settings/components/layerSettings/surfaceLayer.tsx delete mode 100644 frontend/src/modules/2DViewer/settings/components/layerSettings/utils.ts delete mode 100644 frontend/src/modules/2DViewer/settings/components/layerSettings/wellboreLayer.tsx rename frontend/src/modules/{LayerSpike => 2DViewer}/types.ts (100%) rename frontend/src/modules/{LayerSpike => 2DViewer}/view/layerFactory.ts (100%) delete mode 100644 frontend/src/modules/LayerSpike/interfaces.ts delete mode 100644 frontend/src/modules/LayerSpike/loadModule.tsx delete mode 100644 frontend/src/modules/LayerSpike/registerModule.ts delete mode 100644 frontend/src/modules/LayerSpike/settings/atoms/baseAtoms.ts delete mode 100644 frontend/src/modules/LayerSpike/settings/atoms/derivedAtoms.ts delete mode 100644 frontend/src/modules/LayerSpike/settings/settings.tsx delete mode 100644 frontend/src/modules/LayerSpike/view/view.tsx diff --git a/frontend/src/modules/2DViewer/interfaces.ts b/frontend/src/modules/2DViewer/interfaces.ts index f7c233450..2c846f904 100644 --- a/frontend/src/modules/2DViewer/interfaces.ts +++ b/frontend/src/modules/2DViewer/interfaces.ts @@ -1,10 +1,10 @@ import { InterfaceInitialization } from "@framework/UniDirectionalModuleComponentsInterface"; -import { LayerManager } from "@modules_shared/layers/LayerManager"; -import { layerManagerAtom } from "./settings/atoms/derivedAtoms"; +import { LayerManager } from "./layers/LayerManager"; +import { layerManagerAtom } from "./settings/atoms/baseAtoms"; export type SettingsToViewInterface = { - layerManager: LayerManager; + layerManager: LayerManager | null; }; export type Interfaces = { diff --git a/frontend/src/modules/2DViewer/layers/FaultPolygonLayer.ts b/frontend/src/modules/2DViewer/layers/FaultPolygonLayer.ts deleted file mode 100644 index 8a739e86b..000000000 --- a/frontend/src/modules/2DViewer/layers/FaultPolygonLayer.ts +++ /dev/null @@ -1,129 +0,0 @@ -import { PolygonData_api } from "@api"; -import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { defaultColorPalettes } from "@framework/utils/colorPalettes"; -import { ColorSet } from "@lib/utils/ColorSet"; -import { BaseItem } from "@modules/_shared/layers/BaseItem"; -import { BaseLayer, BoundingBox, LayerTopic } from "@modules/_shared/layers/BaseLayer"; -import { QueryClient } from "@tanstack/query-core"; - -import { isEqual } from "lodash"; - -const STALE_TIME = 60 * 1000; -const CACHE_TIME = 60 * 1000; - -export type FaultPolygonLayerSettings = { - ensembleIdent: EnsembleIdent | null; - realizationNum: number | null; - polygonName: string | null; - attribute: string | null; -}; - -export class FaultPolygonLayer extends BaseLayer { - private _colorSet: ColorSet; - - constructor(name: string, parent: BaseItem) { - const defaultSettings = { - ensembleIdent: null, - realizationNum: null, - polyline: { - polylineUtmXy: [], - actualSectionLengths: [], - }, - polygonName: null, - attribute: null, - }; - super(name, defaultSettings, parent); - - this._colorSet = new ColorSet(defaultColorPalettes[0]); - } - - getColorSet(): ColorSet { - return this._colorSet; - } - - setColorSet(colorSet: ColorSet): void { - this._colorSet = colorSet; - this.notifySubscribers(LayerTopic.DATA); - } - - private makeBoundingBox(): void { - if (!this._data) { - return; - } - - const minX = Number.MAX_VALUE; - const maxX = Number.MIN_VALUE; - const minY = Number.MAX_VALUE; - const maxY = Number.MIN_VALUE; - - super.setBoundingBox({ - x: [minX, maxX], - y: [minY, maxY], - z: [0, 0], - }); - } - - getBoundingBox(): BoundingBox | null { - const bbox = super.getBoundingBox(); - if (bbox) { - return bbox; - } - - this.makeBoundingBox(); - return super.getBoundingBox(); - } - - protected areSettingsValid(): boolean { - return ( - this._settings.ensembleIdent !== null && - this._settings.attribute !== null && - this._settings.polygonName !== null && - this._settings.realizationNum !== null - ); - } - - protected doSettingsChangesRequireDataRefetch( - prevSettings: FaultPolygonLayerSettings, - newSettings: FaultPolygonLayerSettings - ): boolean { - return ( - !isEqual(prevSettings.polygonName, newSettings.polygonName) || - prevSettings.attribute !== newSettings.attribute || - prevSettings.realizationNum !== newSettings.realizationNum || - !isEqual(prevSettings.ensembleIdent, newSettings.ensembleIdent) - ); - } - - protected async fetchData(queryClient: QueryClient): Promise { - // super.setBoundingBox(null); - - const queryKey = [ - "getPolygonsData", - this._settings.ensembleIdent?.getCaseUuid() ?? "", - this._settings.ensembleIdent?.getEnsembleName() ?? "", - this._settings.realizationNum ?? 0, - this._settings.polygonName ?? "", - this._settings.attribute ?? "", - ]; - this.registerQueryKey(queryKey); - - return queryClient.fetchQuery({ - queryKey, - queryFn: () => - apiService.polygons.getPolygonsData( - this._settings.ensembleIdent?.getCaseUuid() ?? "", - this._settings.ensembleIdent?.getEnsembleName() ?? "", - this._settings.realizationNum ?? 0, - this._settings.polygonName ?? "", - this._settings.attribute ?? "" - ), - staleTime: STALE_TIME, - gcTime: CACHE_TIME, - }); - } -} - -export function isFaultPolygonLayer(layer: BaseLayer): layer is FaultPolygonLayer { - return layer instanceof FaultPolygonLayer; -} diff --git a/frontend/src/modules/2DViewer/layers/LayerFactory.ts b/frontend/src/modules/2DViewer/layers/LayerFactory.ts deleted file mode 100644 index 4a9bf4b8f..000000000 --- a/frontend/src/modules/2DViewer/layers/LayerFactory.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { LayerManager } from "@modules/_shared/layers/LayerManager"; - -import { FaultPolygonLayer } from "./FaultPolygonLayer"; -import { PolygonLayer } from "./PolygonLayer"; -import { SurfaceLayer } from "./SurfaceLayer"; -import { WellboreLayer } from "./WellboreLayer"; -import { LayerType } from "./types"; - -export class LayerFactory { - static makeLayer(layerType: LayerType, layerManager: LayerManager) { - switch (layerType) { - case LayerType.SURFACE: - return new SurfaceLayer("Surface", layerManager.getMainGroup()); - case LayerType.WELLBORE_SMDA: - return new WellboreLayer("Wells (Drilled)", layerManager.getMainGroup()); - case LayerType.FAULT_POLYGON: - return new FaultPolygonLayer("FaultPolygons", layerManager.getMainGroup()); - case LayerType.POLYGON: - return new PolygonLayer("Field Outline", layerManager.getMainGroup()); - default: - throw new Error("Unknown layer type"); - } - } -} diff --git a/frontend/src/modules/LayerSpike/layers/LayerManager.ts b/frontend/src/modules/2DViewer/layers/LayerManager.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/LayerManager.ts rename to frontend/src/modules/2DViewer/layers/LayerManager.ts diff --git a/frontend/src/modules/2DViewer/layers/PolygonLayer.ts b/frontend/src/modules/2DViewer/layers/PolygonLayer.ts deleted file mode 100644 index d3f30a8f3..000000000 --- a/frontend/src/modules/2DViewer/layers/PolygonLayer.ts +++ /dev/null @@ -1,116 +0,0 @@ -import { PolygonData_api } from "@api"; -import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { BaseItem } from "@modules/_shared/layers/BaseItem"; -import { BaseLayer, BoundingBox } from "@modules/_shared/layers/BaseLayer"; -import { QueryClient } from "@tanstack/query-core"; - -import { isEqual } from "lodash"; - -const STALE_TIME = 60 * 1000; -const CACHE_TIME = 60 * 1000; - -export type PolygonLayerSettings = { - ensembleIdent: EnsembleIdent | null; - realizationNum: number | null; - polygonName: string | null; - attribute: string | null; - color: string; -}; - -export class PolygonLayer extends BaseLayer { - constructor(name: string, parent: BaseItem) { - const defaultSettings = { - ensembleIdent: null, - realizationNum: null, - polyline: { - polylineUtmXy: [], - actualSectionLengths: [], - }, - polygonName: null, - attribute: null, - color: "#FF0000", - }; - super(name, defaultSettings, parent); - } - - private makeBoundingBox(): void { - if (!this._data) { - return; - } - - const minX = Number.MAX_VALUE; - const maxX = Number.MIN_VALUE; - const minY = Number.MAX_VALUE; - const maxY = Number.MIN_VALUE; - - super.setBoundingBox({ - x: [minX, maxX], - y: [minY, maxY], - z: [0, 0], - }); - } - - getBoundingBox(): BoundingBox | null { - const bbox = super.getBoundingBox(); - if (bbox) { - return bbox; - } - - this.makeBoundingBox(); - return super.getBoundingBox(); - } - - protected areSettingsValid(): boolean { - return ( - this._settings.ensembleIdent !== null && - this._settings.attribute !== null && - this._settings.polygonName !== null && - this._settings.realizationNum !== null - ); - } - - protected doSettingsChangesRequireDataRefetch( - prevSettings: PolygonLayerSettings, - newSettings: PolygonLayerSettings - ): boolean { - return ( - !isEqual(prevSettings.polygonName, newSettings.polygonName) || - prevSettings.attribute !== newSettings.attribute || - prevSettings.realizationNum !== newSettings.realizationNum || - !isEqual(prevSettings.ensembleIdent, newSettings.ensembleIdent) - ); - } - - protected async fetchData(queryClient: QueryClient): Promise { - // super.setBoundingBox(null); - - const queryKey = [ - "getPolygonsData", - this._settings.ensembleIdent?.getCaseUuid() ?? "", - this._settings.ensembleIdent?.getEnsembleName() ?? "", - this._settings.realizationNum ?? 0, - this._settings.polygonName ?? "", - this._settings.attribute ?? "", - ]; - this.registerQueryKey(queryKey); - - return queryClient.fetchQuery({ - queryKey, - queryFn: () => - apiService.polygons.getPolygonsData( - this._settings.ensembleIdent?.getCaseUuid() ?? "", - this._settings.ensembleIdent?.getEnsembleName() ?? "", - this._settings.realizationNum ?? 0, - this._settings.polygonName ?? "", - this._settings.attribute ?? "" - ), - staleTime: STALE_TIME, - gcTime: CACHE_TIME, - }); - } -} - -export function isPolygonLayer(layer: BaseLayer): layer is PolygonLayer { - return layer instanceof PolygonLayer; -} diff --git a/frontend/src/modules/LayerSpike/layers/PublishSubscribeHandler.ts b/frontend/src/modules/2DViewer/layers/PublishSubscribeHandler.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/PublishSubscribeHandler.ts rename to frontend/src/modules/2DViewer/layers/PublishSubscribeHandler.ts diff --git a/frontend/src/modules/LayerSpike/layers/SettingsGroup.ts b/frontend/src/modules/2DViewer/layers/SettingsGroup.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/SettingsGroup.ts rename to frontend/src/modules/2DViewer/layers/SettingsGroup.ts diff --git a/frontend/src/modules/LayerSpike/layers/SharedSetting.ts b/frontend/src/modules/2DViewer/layers/SharedSetting.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/SharedSetting.ts rename to frontend/src/modules/2DViewer/layers/SharedSetting.ts diff --git a/frontend/src/modules/2DViewer/layers/SurfaceLayer.ts b/frontend/src/modules/2DViewer/layers/SurfaceLayer.ts deleted file mode 100644 index d3d913a7a..000000000 --- a/frontend/src/modules/2DViewer/layers/SurfaceLayer.ts +++ /dev/null @@ -1,159 +0,0 @@ -import { SurfaceStatisticFunction_api } from "@api"; -import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { defaultColorPalettes } from "@framework/utils/colorPalettes"; -import { ColorSet } from "@lib/utils/ColorSet"; -import { FullSurfaceAddress, SurfaceAddressBuilder } from "@modules/_shared/Surface"; -import { SurfaceDataFloat_trans, transformSurfaceData } from "@modules/_shared/Surface/queryDataTransforms"; -import { encodeSurfAddrStr } from "@modules/_shared/Surface/surfaceAddress"; -import { BaseItem } from "@modules/_shared/layers/BaseItem"; -import { BaseLayer, BoundingBox, LayerTopic } from "@modules/_shared/layers/BaseLayer"; -import { QueryClient } from "@tanstack/query-core"; - -import { isEqual } from "lodash"; -import { SurfaceDataPng } from "src/api/models/SurfaceDataPng"; - -import { EnsembleStageType } from "../settings/components/ensembleStageSelect"; - -const STALE_TIME = 60 * 1000; -const CACHE_TIME = 60 * 1000; - -export type SurfaceLayerSettings = { - ensembleIdent: EnsembleIdent | null; - ensembleStage: EnsembleStageType; - statisticFunction: SurfaceStatisticFunction_api; - realizationNum: number | null; - surfaceName: string | null; - attribute: string | null; -}; - -export class SurfaceLayer extends BaseLayer { - private _colorSet: ColorSet; - - constructor(name: string, parent: BaseItem) { - const defaultSettings = { - ensembleIdent: null, - realizationNum: null, - statisticFunction: SurfaceStatisticFunction_api.MEAN, - surfaceName: null, - ensembleStage: EnsembleStageType.Realization, - attribute: null, - extensionLength: 0, - resolution: 1, - }; - super(name, defaultSettings, parent); - - this._colorSet = new ColorSet(defaultColorPalettes[0]); - } - - getColorSet(): ColorSet { - return this._colorSet; - } - - setColorSet(colorSet: ColorSet): void { - this._colorSet = colorSet; - this.notifySubscribers(LayerTopic.DATA); - } - - private makeBoundingBox(): void { - if (!this._data) { - return; - } - - const minX = Number.MAX_VALUE; - const maxX = Number.MIN_VALUE; - const minY = Number.MAX_VALUE; - const maxY = Number.MIN_VALUE; - - super.setBoundingBox({ - x: [minX, maxX], - y: [minY, maxY], - z: [0, 0], - }); - } - - getBoundingBox(): BoundingBox | null { - const bbox = super.getBoundingBox(); - if (bbox) { - return bbox; - } - - this.makeBoundingBox(); - return super.getBoundingBox(); - } - - protected areSettingsValid(): boolean { - return ( - this._settings.ensembleIdent !== null && - this._settings.attribute !== null && - this._settings.surfaceName !== null && - this._settings.realizationNum !== null - ); - } - - protected doSettingsChangesRequireDataRefetch( - prevSettings: SurfaceLayerSettings, - newSettings: SurfaceLayerSettings - ): boolean { - return ( - prevSettings.surfaceName !== newSettings.surfaceName || - prevSettings.attribute !== newSettings.attribute || - prevSettings.realizationNum !== newSettings.realizationNum || - prevSettings.ensembleStage !== newSettings.ensembleStage || - prevSettings.statisticFunction !== newSettings.statisticFunction || - !isEqual(prevSettings.ensembleIdent, newSettings.ensembleIdent) - ); - } - - protected async fetchData(queryClient: QueryClient): Promise { - super.setBoundingBox(null); - - let surfaceAddress: FullSurfaceAddress | null = null; - const addrBuilder = new SurfaceAddressBuilder(); - - if (this._settings.ensembleIdent && this._settings.surfaceName && this._settings.attribute) { - addrBuilder.withEnsembleIdent(this._settings.ensembleIdent); - addrBuilder.withName(this._settings.surfaceName); - addrBuilder.withAttribute(this._settings.attribute); - - if ( - this._settings.ensembleStage === EnsembleStageType.Realization && - this._settings.realizationNum !== null - ) { - addrBuilder.withRealization(this._settings.realizationNum); - surfaceAddress = addrBuilder.buildRealizationAddress(); - } - if (this._settings.ensembleStage === EnsembleStageType.Statistics && this._settings.statisticFunction) { - addrBuilder.withStatisticFunction(this._settings.statisticFunction); - // TODO: Add realization filter - surfaceAddress = addrBuilder.buildStatisticalAddress(); - } - if (this._settings.ensembleStage === EnsembleStageType.Observation) { - // addrBuilder.withRealization(this._settings.realizationNum); - addrBuilder.withTimeOrInterval("2021-01-01T00:00:00Z"); - surfaceAddress = addrBuilder.buildObservedAddress(); - } - } - - const surfAddrStr = surfaceAddress ? encodeSurfAddrStr(surfaceAddress) : null; - - const queryKey = ["getSurfaceData", surfAddrStr, null, "float"]; - - this.registerQueryKey(queryKey); - - const promise = queryClient - .fetchQuery({ - queryKey, - queryFn: () => apiService.surface.getSurfaceData(surfAddrStr ?? "", "float", null), - staleTime: STALE_TIME, - gcTime: CACHE_TIME, - }) - .then((data) => transformSurfaceData(data)); - - return promise; - } -} - -export function isSurfaceLayer(layer: BaseLayer): layer is SurfaceLayer { - return layer instanceof SurfaceLayer; -} diff --git a/frontend/src/modules/LayerSpike/layers/View.ts b/frontend/src/modules/2DViewer/layers/View.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/View.ts rename to frontend/src/modules/2DViewer/layers/View.ts diff --git a/frontend/src/modules/2DViewer/layers/WellboreLayer.ts b/frontend/src/modules/2DViewer/layers/WellboreLayer.ts deleted file mode 100644 index dac979573..000000000 --- a/frontend/src/modules/2DViewer/layers/WellboreLayer.ts +++ /dev/null @@ -1,111 +0,0 @@ -import { WellboreTrajectory_api } from "@api"; -import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { defaultColorPalettes } from "@framework/utils/colorPalettes"; -import { ColorSet } from "@lib/utils/ColorSet"; -import { SurfaceDataFloat_trans } from "@modules/_shared/Surface/queryDataTransforms"; -import { BaseItem } from "@modules/_shared/layers/BaseItem"; -import { BaseLayer, BoundingBox, LayerTopic } from "@modules/_shared/layers/BaseLayer"; -import { QueryClient } from "@tanstack/query-core"; - -import { isEqual } from "lodash"; -import { SurfaceDataPng } from "src/api/models/SurfaceDataPng"; - -const STALE_TIME = 60 * 1000; -const CACHE_TIME = 60 * 1000; - -export type WellboreLayerSettings = { - wellboreUuids: string[]; - ensembleIdent: EnsembleIdent | null; - fieldIdentifier: string | null; -}; - -export class WellboreLayer extends BaseLayer { - private _colorSet: ColorSet; - - constructor(name: string, parent: BaseItem) { - const defaultSettings = { - wellboreUuids: [], - ensembleIdent: null, - fieldIdentifier: null, - }; - super(name, defaultSettings, parent); - - this._colorSet = new ColorSet(defaultColorPalettes[0]); - } - - getColorSet(): ColorSet { - return this._colorSet; - } - - setColorSet(colorSet: ColorSet): void { - this._colorSet = colorSet; - this.notifySubscribers(LayerTopic.DATA); - } - - private makeBoundingBox(): void { - if (!this._data) { - return; - } - - let minX = Number.MAX_VALUE; - let maxX = Number.MIN_VALUE; - let minY = Number.MAX_VALUE; - let maxY = Number.MIN_VALUE; - - this._data.forEach((trajectory) => { - minX = Math.min(minX, ...trajectory.eastingArr); - maxX = Math.max(maxX, ...trajectory.eastingArr); - minY = Math.min(minY, ...trajectory.northingArr); - maxY = Math.max(maxY, ...trajectory.northingArr); - }); - - super.setBoundingBox({ - x: [minX, maxX], - y: [minY, maxY], - z: [0, 0], - }); - } - - getBoundingBox(): BoundingBox | null { - const bbox = super.getBoundingBox(); - if (bbox) { - return bbox; - } - - this.makeBoundingBox(); - return super.getBoundingBox(); - } - - protected areSettingsValid(): boolean { - return true; - } - - protected doSettingsChangesRequireDataRefetch( - prevSettings: WellboreLayerSettings, - newSettings: WellboreLayerSettings - ): boolean { - return !isEqual(prevSettings.wellboreUuids, newSettings.wellboreUuids); - } - - protected async fetchData(queryClient: QueryClient): Promise { - const promises: Promise[] = []; - - super.setBoundingBox(null); - - const queryKey = ["getWellTrajectories", this._settings.fieldIdentifier]; - this.registerQueryKey(queryKey); - const promise = queryClient.fetchQuery({ - queryKey, - queryFn: () => apiService.well.getFieldWellTrajectories(this._settings.fieldIdentifier ?? ""), - staleTime: STALE_TIME, - gcTime: CACHE_TIME, - }); - - return promise; - } -} - -export function isWellboreLayer(layer: BaseLayer): layer is WellboreLayer { - return layer instanceof WellboreLayer; -} diff --git a/frontend/src/modules/LayerSpike/layers/components/GroupComponent.tsx b/frontend/src/modules/2DViewer/layers/components/GroupComponent.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/components/GroupComponent.tsx rename to frontend/src/modules/2DViewer/layers/components/GroupComponent.tsx diff --git a/frontend/src/modules/LayerSpike/layers/components/LayerComponent.tsx b/frontend/src/modules/2DViewer/layers/components/LayerComponent.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/components/LayerComponent.tsx rename to frontend/src/modules/2DViewer/layers/components/LayerComponent.tsx diff --git a/frontend/src/modules/LayerSpike/layers/components/SettingComponent.tsx b/frontend/src/modules/2DViewer/layers/components/SettingComponent.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/components/SettingComponent.tsx rename to frontend/src/modules/2DViewer/layers/components/SettingComponent.tsx diff --git a/frontend/src/modules/LayerSpike/layers/components/SharedSettingComponent.tsx b/frontend/src/modules/2DViewer/layers/components/SharedSettingComponent.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/components/SharedSettingComponent.tsx rename to frontend/src/modules/2DViewer/layers/components/SharedSettingComponent.tsx diff --git a/frontend/src/modules/LayerSpike/layers/components/editNameComponent.tsx b/frontend/src/modules/2DViewer/layers/components/editNameComponent.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/components/editNameComponent.tsx rename to frontend/src/modules/2DViewer/layers/components/editNameComponent.tsx diff --git a/frontend/src/modules/LayerSpike/layers/components/layersActions.tsx b/frontend/src/modules/2DViewer/layers/components/layersActions.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/components/layersActions.tsx rename to frontend/src/modules/2DViewer/layers/components/layersActions.tsx diff --git a/frontend/src/modules/LayerSpike/layers/components/removeButtonComponent.tsx b/frontend/src/modules/2DViewer/layers/components/removeButtonComponent.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/components/removeButtonComponent.tsx rename to frontend/src/modules/2DViewer/layers/components/removeButtonComponent.tsx diff --git a/frontend/src/modules/LayerSpike/layers/components/utils.tsx b/frontend/src/modules/2DViewer/layers/components/utils.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/components/utils.tsx rename to frontend/src/modules/2DViewer/layers/components/utils.tsx diff --git a/frontend/src/modules/LayerSpike/layers/components/visibilityToggleComponent.tsx b/frontend/src/modules/2DViewer/layers/components/visibilityToggleComponent.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/components/visibilityToggleComponent.tsx rename to frontend/src/modules/2DViewer/layers/components/visibilityToggleComponent.tsx diff --git a/frontend/src/modules/LayerSpike/layers/delegates/GroupDelegate.ts b/frontend/src/modules/2DViewer/layers/delegates/GroupDelegate.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/delegates/GroupDelegate.ts rename to frontend/src/modules/2DViewer/layers/delegates/GroupDelegate.ts diff --git a/frontend/src/modules/LayerSpike/layers/delegates/ItemDelegate.ts b/frontend/src/modules/2DViewer/layers/delegates/ItemDelegate.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/delegates/ItemDelegate.ts rename to frontend/src/modules/2DViewer/layers/delegates/ItemDelegate.ts diff --git a/frontend/src/modules/LayerSpike/layers/delegates/LayerDelegate.ts b/frontend/src/modules/2DViewer/layers/delegates/LayerDelegate.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/delegates/LayerDelegate.ts rename to frontend/src/modules/2DViewer/layers/delegates/LayerDelegate.ts diff --git a/frontend/src/modules/LayerSpike/layers/delegates/SettingDelegate.ts b/frontend/src/modules/2DViewer/layers/delegates/SettingDelegate.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/delegates/SettingDelegate.ts rename to frontend/src/modules/2DViewer/layers/delegates/SettingDelegate.ts diff --git a/frontend/src/modules/LayerSpike/layers/delegates/SettingsContextDelegate.ts b/frontend/src/modules/2DViewer/layers/delegates/SettingsContextDelegate.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/delegates/SettingsContextDelegate.ts rename to frontend/src/modules/2DViewer/layers/delegates/SettingsContextDelegate.ts diff --git a/frontend/src/modules/LayerSpike/layers/implementations/View.ts b/frontend/src/modules/2DViewer/layers/implementations/View.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/View.ts rename to frontend/src/modules/2DViewer/layers/implementations/View.ts diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesContext.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesContext.ts similarity index 95% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesContext.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesContext.ts index 8f3302f47..a8d23d8ee 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesContext.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesContext.ts @@ -1,8 +1,8 @@ import { WellboreHeader_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { SettingsContextDelegate } from "@modules/LayerSpike/layers/delegates/SettingsContextDelegate"; -import { CACHE_TIME, STALE_TIME } from "@modules/LayerSpike/layers/queryConstants"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { SettingsContextDelegate } from "@modules/2DViewer/layers/delegates/SettingsContextDelegate"; +import { CACHE_TIME, STALE_TIME } from "@modules/2DViewer/layers/queryConstants"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; import { isEqual } from "lodash"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesLayer.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesLayer.ts similarity index 92% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesLayer.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesLayer.ts index 86b3d5918..a887bc444 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesLayer.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesLayer.ts @@ -1,8 +1,8 @@ import { WellboreTrajectory_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { ItemDelegate } from "@modules/LayerSpike/layers/delegates/ItemDelegate"; -import { CACHE_TIME, STALE_TIME } from "@modules/LayerSpike/layers/queryConstants"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { ItemDelegate } from "@modules/2DViewer/layers/delegates/ItemDelegate"; +import { CACHE_TIME, STALE_TIME } from "@modules/2DViewer/layers/queryConstants"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; import { QueryClient } from "@tanstack/react-query"; import { isEqual } from "lodash"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/DrilledWellTrajectoriesLayer/types.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/DrilledWellTrajectoriesLayer/types.ts similarity index 78% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/DrilledWellTrajectoriesLayer/types.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/DrilledWellTrajectoriesLayer/types.ts index d47df618f..c684eacfb 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/DrilledWellTrajectoriesLayer/types.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/DrilledWellTrajectoriesLayer/types.ts @@ -1,6 +1,6 @@ import { WellboreHeader_api } from "@api"; import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; export type DrilledWellTrajectoriesSettings = { [SettingType.ENSEMBLE]: EnsembleIdent | null; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceContext.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceContext.ts similarity index 96% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceContext.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceContext.ts index 219df8cef..14751d6e7 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceContext.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceContext.ts @@ -1,8 +1,8 @@ import { SurfaceTimeType_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { SettingsContextDelegate } from "@modules/LayerSpike/layers/delegates/SettingsContextDelegate"; -import { CACHE_TIME, STALE_TIME } from "@modules/LayerSpike/layers/queryConstants"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { SettingsContextDelegate } from "@modules/2DViewer/layers/delegates/SettingsContextDelegate"; +import { CACHE_TIME, STALE_TIME } from "@modules/2DViewer/layers/queryConstants"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; import { isEqual } from "lodash"; import { SurfaceMetaSet } from "src/api/models/SurfaceMetaSet"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceLayer.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceLayer.ts similarity index 93% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceLayer.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceLayer.ts index b85621a35..7c0092b41 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceLayer.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceLayer.ts @@ -1,8 +1,8 @@ import { SurfaceDataPng_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { ItemDelegate } from "@modules/LayerSpike/layers/delegates/ItemDelegate"; -import { CACHE_TIME, STALE_TIME } from "@modules/LayerSpike/layers/queryConstants"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { ItemDelegate } from "@modules/2DViewer/layers/delegates/ItemDelegate"; +import { CACHE_TIME, STALE_TIME } from "@modules/2DViewer/layers/queryConstants"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; import { FullSurfaceAddress, SurfaceAddressBuilder } from "@modules/_shared/Surface"; import { SurfaceDataFloat_trans, transformSurfaceData } from "@modules/_shared/Surface/queryDataTransforms"; import { encodeSurfAddrStr } from "@modules/_shared/Surface/surfaceAddress"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/ObservedSurfaceLayer/types.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/ObservedSurfaceLayer/types.ts similarity index 80% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/ObservedSurfaceLayer/types.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/ObservedSurfaceLayer/types.ts index c1417079c..0c4410305 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/ObservedSurfaceLayer/types.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/ObservedSurfaceLayer/types.ts @@ -1,5 +1,5 @@ import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; export type ObservedSurfaceSettings = { [SettingType.ENSEMBLE]: EnsembleIdent | null; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationGridLayer/RealizationGridContext.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationGridLayer/RealizationGridContext.ts similarity index 97% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationGridLayer/RealizationGridContext.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/RealizationGridLayer/RealizationGridContext.ts index 2084f24b1..fbb905a99 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationGridLayer/RealizationGridContext.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationGridLayer/RealizationGridContext.ts @@ -1,8 +1,8 @@ import { Grid3dInfo_api, Grid3dPropertyInfo_api, SurfaceTimeType_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { SettingsContextDelegate } from "@modules/LayerSpike/layers/delegates/SettingsContextDelegate"; -import { CACHE_TIME, STALE_TIME } from "@modules/LayerSpike/layers/queryConstants"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { SettingsContextDelegate } from "@modules/2DViewer/layers/delegates/SettingsContextDelegate"; +import { CACHE_TIME, STALE_TIME } from "@modules/2DViewer/layers/queryConstants"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; import { isEqual } from "lodash"; import { SurfaceMetaSet } from "src/api/models/SurfaceMetaSet"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationGridLayer/RealizationGridLayer.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationGridLayer/RealizationGridLayer.ts similarity index 95% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationGridLayer/RealizationGridLayer.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/RealizationGridLayer/RealizationGridLayer.ts index 224ca77c5..a6f2b6a13 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationGridLayer/RealizationGridLayer.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationGridLayer/RealizationGridLayer.ts @@ -1,13 +1,13 @@ import { apiService } from "@framework/ApiService"; +import { ItemDelegate } from "@modules/2DViewer/layers/delegates/ItemDelegate"; +import { CACHE_TIME, STALE_TIME } from "@modules/2DViewer/layers/queryConstants"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; import { GridMappedProperty_trans, GridSurface_trans, transformGridMappedProperty, transformGridSurface, } from "@modules/3DViewer/view/queries/queryDataTransforms"; -import { ItemDelegate } from "@modules/LayerSpike/layers/delegates/ItemDelegate"; -import { CACHE_TIME, STALE_TIME } from "@modules/LayerSpike/layers/queryConstants"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; import { QueryClient } from "@tanstack/react-query"; import { isEqual } from "lodash"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationGridLayer/types.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationGridLayer/types.ts similarity index 84% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationGridLayer/types.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/RealizationGridLayer/types.ts index d16af753f..4f482dd0c 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationGridLayer/types.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationGridLayer/types.ts @@ -1,5 +1,5 @@ import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; export type RealizationGridSettings = { [SettingType.ENSEMBLE]: EnsembleIdent | null; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsContext.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsContext.ts similarity index 96% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsContext.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsContext.ts index 2f4ff874d..19c69570c 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsContext.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsContext.ts @@ -1,8 +1,8 @@ import { PolygonsAttributeType_api, PolygonsMeta_api, SurfaceTimeType_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { SettingsContextDelegate } from "@modules/LayerSpike/layers/delegates/SettingsContextDelegate"; -import { CACHE_TIME, STALE_TIME } from "@modules/LayerSpike/layers/queryConstants"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { SettingsContextDelegate } from "@modules/2DViewer/layers/delegates/SettingsContextDelegate"; +import { CACHE_TIME, STALE_TIME } from "@modules/2DViewer/layers/queryConstants"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; import { isEqual } from "lodash"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsLayer.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsLayer.ts similarity index 89% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsLayer.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsLayer.ts index 647da15ca..441e04559 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsLayer.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsLayer.ts @@ -1,9 +1,9 @@ import { PolygonData_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { ItemDelegate } from "@modules/LayerSpike/layers/delegates/ItemDelegate"; -import { LayerDelegate } from "@modules/LayerSpike/layers/delegates/LayerDelegate"; -import { CACHE_TIME, STALE_TIME } from "@modules/LayerSpike/layers/queryConstants"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { ItemDelegate } from "@modules/2DViewer/layers/delegates/ItemDelegate"; +import { LayerDelegate } from "@modules/2DViewer/layers/delegates/LayerDelegate"; +import { CACHE_TIME, STALE_TIME } from "@modules/2DViewer/layers/queryConstants"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; import { QueryClient } from "@tanstack/react-query"; import { isEqual } from "lodash"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationPolygonsLayer/types.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationPolygonsLayer/types.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationPolygonsLayer/types.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/RealizationPolygonsLayer/types.ts diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceContext.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceContext.ts similarity index 97% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceContext.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceContext.ts index 1bc2d87dc..8b62388d7 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceContext.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceContext.ts @@ -1,8 +1,8 @@ import { SurfaceTimeType_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { SettingsContextDelegate } from "@modules/LayerSpike/layers/delegates/SettingsContextDelegate"; -import { CACHE_TIME, STALE_TIME } from "@modules/LayerSpike/layers/queryConstants"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { SettingsContextDelegate } from "@modules/2DViewer/layers/delegates/SettingsContextDelegate"; +import { CACHE_TIME, STALE_TIME } from "@modules/2DViewer/layers/queryConstants"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; import { isEqual } from "lodash"; import { SurfaceMetaSet } from "src/api/models/SurfaceMetaSet"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceLayer.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceLayer.ts similarity index 91% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceLayer.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceLayer.ts index af8c89a13..9308ddd4c 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceLayer.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceLayer.ts @@ -1,9 +1,9 @@ import { SurfaceDataPng_api, SurfaceTimeType_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { ItemDelegate } from "@modules/LayerSpike/layers/delegates/ItemDelegate"; -import { LayerDelegate } from "@modules/LayerSpike/layers/delegates/LayerDelegate"; -import { CACHE_TIME, STALE_TIME } from "@modules/LayerSpike/layers/queryConstants"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { ItemDelegate } from "@modules/2DViewer/layers/delegates/ItemDelegate"; +import { LayerDelegate } from "@modules/2DViewer/layers/delegates/LayerDelegate"; +import { CACHE_TIME, STALE_TIME } from "@modules/2DViewer/layers/queryConstants"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; import { FullSurfaceAddress, SurfaceAddressBuilder } from "@modules/_shared/Surface"; import { SurfaceDataFloat_trans, transformSurfaceData } from "@modules/_shared/Surface/queryDataTransforms"; import { encodeSurfAddrStr } from "@modules/_shared/Surface/surfaceAddress"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationSurfaceLayer/types.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/RealizationSurfaceLayer/types.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/RealizationSurfaceLayer/types.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/RealizationSurfaceLayer/types.ts diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceContext.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceContext.ts similarity index 99% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceContext.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceContext.ts index c4d82f271..371533cf6 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceContext.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceContext.ts @@ -1,7 +1,7 @@ import { SurfaceTimeType_api } from "@api"; import { apiService } from "@framework/ApiService"; import { Ensemble as FrameworkEnsemble } from "@framework/Ensemble"; -import { CACHE_TIME, STALE_TIME } from "@modules/LayerSpike/layers/queryConstants"; +import { CACHE_TIME, STALE_TIME } from "@modules/2DViewer/layers/queryConstants"; import { isEqual } from "lodash"; import { SurfaceMetaSet } from "src/api/models/SurfaceMetaSet"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer.ts similarity index 93% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer.ts index 653363be0..d1c00ac3c 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer.ts @@ -1,9 +1,9 @@ import { SurfaceDataPng_api, SurfaceTimeType_api } from "@api"; import { apiService } from "@framework/ApiService"; -import { ItemDelegate } from "@modules/LayerSpike/layers/delegates/ItemDelegate"; -import { LayerDelegate } from "@modules/LayerSpike/layers/delegates/LayerDelegate"; -import { CACHE_TIME, STALE_TIME } from "@modules/LayerSpike/layers/queryConstants"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { ItemDelegate } from "@modules/2DViewer/layers/delegates/ItemDelegate"; +import { LayerDelegate } from "@modules/2DViewer/layers/delegates/LayerDelegate"; +import { CACHE_TIME, STALE_TIME } from "@modules/2DViewer/layers/queryConstants"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; import { FullSurfaceAddress, SurfaceAddressBuilder } from "@modules/_shared/Surface"; import { SurfaceDataFloat_trans, transformSurfaceData } from "@modules/_shared/Surface/queryDataTransforms"; import { encodeSurfAddrStr } from "@modules/_shared/Surface/surfaceAddress"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/types.ts b/frontend/src/modules/2DViewer/layers/implementations/layers/StatisticalSurfaceLayer/types.ts similarity index 88% rename from frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/types.ts rename to frontend/src/modules/2DViewer/layers/implementations/layers/StatisticalSurfaceLayer/types.ts index 202d5fc08..adcf166ff 100644 --- a/frontend/src/modules/LayerSpike/layers/implementations/layers/StatisticalSurfaceLayer/types.ts +++ b/frontend/src/modules/2DViewer/layers/implementations/layers/StatisticalSurfaceLayer/types.ts @@ -1,6 +1,6 @@ import { SurfaceStatisticFunction_api } from "@api"; import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { SettingType } from "@modules/LayerSpike/layers/settingsTypes"; +import { SettingType } from "@modules/2DViewer/layers/settingsTypes"; import { SensitivityNameCasePair } from "../../settings/Sensitivity"; diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/DrilledWellbores.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/DrilledWellbores.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/DrilledWellbores.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/DrilledWellbores.tsx diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/Ensemble.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/Ensemble.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/Ensemble.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/Ensemble.tsx diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/GridAttribute.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/GridAttribute.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/GridAttribute.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/GridAttribute.tsx diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/GridLayer.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/GridLayer.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/GridLayer.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/GridLayer.tsx diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/GridName.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/GridName.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/GridName.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/GridName.tsx diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/PolygonsAttribute.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/PolygonsAttribute.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/PolygonsAttribute.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/PolygonsAttribute.tsx diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/PolygonsName.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/PolygonsName.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/PolygonsName.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/PolygonsName.tsx diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/Realization.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/Realization.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/Realization.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/Realization.tsx diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/Sensitivity.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/Sensitivity.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/Sensitivity.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/Sensitivity.tsx diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/StatisticFunction.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/StatisticFunction.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/StatisticFunction.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/StatisticFunction.tsx diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/SurfaceAttribute.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/SurfaceAttribute.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/SurfaceAttribute.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/SurfaceAttribute.tsx diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/SurfaceName.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/SurfaceName.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/SurfaceName.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/SurfaceName.tsx diff --git a/frontend/src/modules/LayerSpike/layers/implementations/settings/TimeOrInterval.tsx b/frontend/src/modules/2DViewer/layers/implementations/settings/TimeOrInterval.tsx similarity index 100% rename from frontend/src/modules/LayerSpike/layers/implementations/settings/TimeOrInterval.tsx rename to frontend/src/modules/2DViewer/layers/implementations/settings/TimeOrInterval.tsx diff --git a/frontend/src/modules/LayerSpike/layers/interfaces.ts b/frontend/src/modules/2DViewer/layers/interfaces.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/interfaces.ts rename to frontend/src/modules/2DViewer/layers/interfaces.ts diff --git a/frontend/src/modules/LayerSpike/layers/queryConstants.ts b/frontend/src/modules/2DViewer/layers/queryConstants.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/queryConstants.ts rename to frontend/src/modules/2DViewer/layers/queryConstants.ts diff --git a/frontend/src/modules/LayerSpike/layers/settingsTypes.ts b/frontend/src/modules/2DViewer/layers/settingsTypes.ts similarity index 100% rename from frontend/src/modules/LayerSpike/layers/settingsTypes.ts rename to frontend/src/modules/2DViewer/layers/settingsTypes.ts diff --git a/frontend/src/modules/2DViewer/layers/types.ts b/frontend/src/modules/2DViewer/layers/types.ts deleted file mode 100644 index 465dcf37b..000000000 --- a/frontend/src/modules/2DViewer/layers/types.ts +++ /dev/null @@ -1,13 +0,0 @@ -export enum LayerType { - SURFACE = "surface", - WELLBORE_SMDA = "wellbore_drilled", - FAULT_POLYGON = "fault_polygon", - POLYGON = "polygon", -} - -export const LAYER_TYPE_TO_STRING_MAPPING = { - [LayerType.SURFACE]: "Surface", - [LayerType.WELLBORE_SMDA]: "Wells (Drilled)", - [LayerType.FAULT_POLYGON]: "Fault Polygons", - [LayerType.POLYGON]: "Polygons", -}; diff --git a/frontend/src/modules/2DViewer/loadModule.tsx b/frontend/src/modules/2DViewer/loadModule.tsx index 5b15739f3..dfcfa27de 100644 --- a/frontend/src/modules/2DViewer/loadModule.tsx +++ b/frontend/src/modules/2DViewer/loadModule.tsx @@ -5,7 +5,9 @@ import { MODULE_NAME } from "./registerModule"; import { Settings } from "./settings/settings"; import { View } from "./view/view"; -const module = ModuleRegistry.initModule(MODULE_NAME, { settingsToViewInterfaceInitialization }); +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 5f0b9d195..65f008ddf 100644 --- a/frontend/src/modules/2DViewer/registerModule.ts +++ b/frontend/src/modules/2DViewer/registerModule.ts @@ -3,7 +3,7 @@ import { ModuleRegistry } from "@framework/ModuleRegistry"; import { Interfaces } from "./interfaces"; -export const MODULE_NAME = "2DViewer"; +export const MODULE_NAME: string = "2DViewer"; ModuleRegistry.registerModule({ moduleName: MODULE_NAME, diff --git a/frontend/src/modules/2DViewer/settings/atoms/baseAtoms.ts b/frontend/src/modules/2DViewer/settings/atoms/baseAtoms.ts index 13a34963d..1e084f7b1 100644 --- a/frontend/src/modules/2DViewer/settings/atoms/baseAtoms.ts +++ b/frontend/src/modules/2DViewer/settings/atoms/baseAtoms.ts @@ -1,3 +1,6 @@ +import { LayerManager } from "@modules/2DViewer/layers/LayerManager"; + import { atom } from "jotai"; export const userSelectedFieldIdentifierAtom = atom(null); +export const layerManagerAtom = atom(null); diff --git a/frontend/src/modules/2DViewer/settings/atoms/derivedAtoms.ts b/frontend/src/modules/2DViewer/settings/atoms/derivedAtoms.ts index 349ee5b22..7d4115816 100644 --- a/frontend/src/modules/2DViewer/settings/atoms/derivedAtoms.ts +++ b/frontend/src/modules/2DViewer/settings/atoms/derivedAtoms.ts @@ -1,9 +1,7 @@ import { EnsembleSet } from "@framework/EnsembleSet"; import { EnsembleSetAtom } from "@framework/GlobalAtoms"; -import { LayerManager } from "@modules/_shared/layers/LayerManager"; import { atom } from "jotai"; -import { queryClientAtom } from "jotai-tanstack-query"; import { userSelectedFieldIdentifierAtom } from "./baseAtoms"; @@ -31,11 +29,3 @@ export const filteredEnsembleSetAtom = atom((get) => { return new EnsembleSet(ensembleSet.getEnsembleArr().filter((el) => el.getFieldIdentifier() === fieldIdentifier)); }); - -export const layerManagerAtom = atom((get) => { - const layerManager = new LayerManager(); - const queryClient = get(queryClientAtom); - layerManager.setQueryClient(queryClient); - - return layerManager; -}); diff --git a/frontend/src/modules/2DViewer/settings/components/ensembleStageSelect.tsx b/frontend/src/modules/2DViewer/settings/components/ensembleStageSelect.tsx deleted file mode 100644 index b9e682a3f..000000000 --- a/frontend/src/modules/2DViewer/settings/components/ensembleStageSelect.tsx +++ /dev/null @@ -1,241 +0,0 @@ -import React from "react"; - -import { SurfaceStatisticFunction_api } from "@api"; -import { Ensemble } from "@framework/Ensemble"; -import { EnsembleSensitivities } from "@framework/EnsembleSensitivities"; -import { Dropdown } from "@lib/components/Dropdown"; -import { useValidState } from "@lib/hooks/useValidState"; - -export enum EnsembleStageType { - Statistics = "Statistics", - Realization = "Realization", - Observation = "Observation", -} -export type EnsembleStatisticStage = { - ensembleStage: EnsembleStageType.Statistics; - statisticFunction: SurfaceStatisticFunction_api; - realizationNums: number[]; -}; - -export type EnsembleRealizationStage = { - ensembleStage: EnsembleStageType.Realization; - realizationNum: number | null; -}; -export type EnsembleObservationStage = { - ensembleStage: EnsembleStageType.Observation; - realizationNum: number | null; // The observation might be tied to a realization (e.g., depth converted) -}; - -export type EnsembleStage = EnsembleStatisticStage | EnsembleRealizationStage | EnsembleObservationStage; - -enum StageDetails { - Realization = "Realization", - MEAN = "Mean", - STD = "Stddev", - P10 = "P10", - P90 = "P90", - Observation = "Observation", -} - -export type EnsembleStageSelectProps = { - ensemble: Ensemble | null; - stageType: EnsembleStageType | null; - availableRealizationNums: number[]; - realizationNum: number | null; - statisticFunction: SurfaceStatisticFunction_api; - disableRealizationPicker?: boolean; - onChange(stage: EnsembleStage): void; -}; - -export const EnsembleStageSelect: React.FC = (props) => { - const ensembleSensitivities = props.ensemble?.getSensitivities() ?? null; - const [stageDetails, setStageDetails] = useValidState({ - initialState: getStageDetails(props.stageType || EnsembleStageType.Realization, props.statisticFunction), - validStates: Object.values(StageDetails), - }); - const [realizationNum, setRealizationNum] = useValidState({ - initialState: props.realizationNum, - validStates: props.availableRealizationNums, - }); - const [realizationNumsStatistics, setRealizationNumsStatistics] = React.useState([]); - - const realizationOptions = props.availableRealizationNums.map((num) => ({ - label: num.toString(), - value: num.toString(), - })); - const StageDetailOptions = Object.values(StageDetails).map((val: StageDetails) => { - return { value: val, label: val }; - }); - - function handleRealizationNumChange(realNum: string) { - setRealizationNum(parseInt(realNum)); - } - React.useEffect(() => { - if ( - ensembleSensitivities && - !realizationNumsStatistics.length && - stageDetails !== StageDetails.Realization && - stageDetails !== StageDetails.Observation - ) { - return; - } - const stage = handleStageChange(stageDetails, realizationNumsStatistics, realizationNum); - - props.onChange(stage); - }, [stageDetails, realizationNum, realizationNumsStatistics]); - - return ( -
-
- setStageDetails(stage as StageDetails)} - /> -
- {stageDetails === StageDetails.Realization && ( -
- -
- )} - <> - {stageDetails !== StageDetails.Realization && - stageDetails !== StageDetails.Observation && - ensembleSensitivities && ( - - )} - - {props.stageType === EnsembleStageType.Observation &&
} -
- ); -}; - -type SensitivitySelectProps = { - sensitivities: EnsembleSensitivities; - realizationNums: number[]; - onChange(realizationNums: number[]): void; -}; -export const SensitivitySelect: React.FC = (props) => { - const [selectedSensitivtyName, setSelectedSensitivtyName] = useValidState({ - initialState: null, - validStates: props.sensitivities.getSensitivityNames(), - }); - - const sensitivityNameOptions = props.sensitivities - .getSensitivityNames() - .map((name) => ({ label: name, value: name })); - function getSensitivityCases(sensitivityName: string): string[] { - return props.sensitivities.getCaseNamesForSensitivity(sensitivityName); - } - - const [selectedSensitivityCase, setSelectedSensitivityCase] = useValidState({ - initialState: null, - validStates: selectedSensitivtyName ? getSensitivityCases(selectedSensitivtyName) : [], - }); - - const sensitivityCaseOptions = (sensitivityName: string | null) => { - if (sensitivityName) { - return getSensitivityCases(sensitivityName).map((name) => ({ label: name, value: name })); - } - return []; - }; - if (selectedSensitivtyName && selectedSensitivityCase) { - const sensitivityCase = props.sensitivities.getCaseByName(selectedSensitivtyName, selectedSensitivityCase); - if (sensitivityCase) { - props.onChange(sensitivityCase.realizations); - } - } - return ( - <> - - - - ); -}; - -function handleStageChange( - stage: string, - realizationNumsStatistics: number[], - realizationNum: number | null -): EnsembleStage { - if (stage == StageDetails.MEAN) { - return { - ensembleStage: EnsembleStageType.Statistics, - statisticFunction: SurfaceStatisticFunction_api.MEAN, - realizationNums: realizationNumsStatistics ?? [], - }; - } - if (stage == StageDetails.STD) { - return { - ensembleStage: EnsembleStageType.Statistics, - statisticFunction: SurfaceStatisticFunction_api.STD, - realizationNums: realizationNumsStatistics ?? [], - }; - } - if (stage == StageDetails.P10) { - return { - ensembleStage: EnsembleStageType.Statistics, - statisticFunction: SurfaceStatisticFunction_api.P10, - realizationNums: realizationNumsStatistics ?? [], - }; - } - if (stage == StageDetails.P90) { - return { - ensembleStage: EnsembleStageType.Statistics, - statisticFunction: SurfaceStatisticFunction_api.P90, - realizationNums: realizationNumsStatistics ?? [], - }; - } - if (stage == StageDetails.Observation) { - return { - ensembleStage: EnsembleStageType.Observation, - realizationNum: realizationNum ?? 0, - }; - } - - return { - ensembleStage: EnsembleStageType.Realization, - realizationNum: realizationNum ?? 0, - }; -} -function getStageDetails(stage: EnsembleStageType, statisticFunction: SurfaceStatisticFunction_api): StageDetails { - if (stage === EnsembleStageType.Realization) { - return StageDetails.Realization; - } - if (stage === EnsembleStageType.Statistics) { - if (statisticFunction === SurfaceStatisticFunction_api.MEAN) { - return StageDetails.MEAN; - } - if (statisticFunction === SurfaceStatisticFunction_api.STD) { - return StageDetails.STD; - } - if (statisticFunction === SurfaceStatisticFunction_api.P10) { - return StageDetails.P10; - } - if (statisticFunction === SurfaceStatisticFunction_api.P90) { - return StageDetails.P90; - } - } - if (stage === EnsembleStageType.Observation) { - return StageDetails.Observation; - } - return StageDetails.Realization; -} diff --git a/frontend/src/modules/2DViewer/settings/components/layerSettings/faultPolygonLayer.tsx b/frontend/src/modules/2DViewer/settings/components/layerSettings/faultPolygonLayer.tsx deleted file mode 100644 index e40fd4086..000000000 --- a/frontend/src/modules/2DViewer/settings/components/layerSettings/faultPolygonLayer.tsx +++ /dev/null @@ -1,230 +0,0 @@ -import React from "react"; - -import { PolygonsAttributeType_api, PolygonsMeta_api } from "@api"; -import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { EnsembleSet } from "@framework/EnsembleSet"; -import { WorkbenchSession, useEnsembleRealizationFilterFunc } from "@framework/WorkbenchSession"; -import { WorkbenchSettings } from "@framework/WorkbenchSettings"; -import { EnsembleDropdown } from "@framework/components/EnsembleDropdown"; -import { Dropdown, DropdownOption } from "@lib/components/Dropdown"; -import { PendingWrapper } from "@lib/components/PendingWrapper"; -import { FaultPolygonLayer, FaultPolygonLayerSettings } from "@modules/2DViewer/layers/FaultPolygonLayer"; -import { useLayerSettings } from "@modules/_shared/layers/BaseLayer"; -import { UseQueryResult, useQuery } from "@tanstack/react-query"; - -import { cloneDeep, isEqual } from "lodash"; - -import { fixupSetting } from "./utils"; - -export type FaultPolygonLayerSettingsComponentProps = { - layer: FaultPolygonLayer; - ensembleSet: EnsembleSet; - workbenchSession: WorkbenchSession; - workbenchSettings: WorkbenchSettings; -}; -const faultPolygonAttributeTypes = [PolygonsAttributeType_api.FAULT_LINES, PolygonsAttributeType_api.DEPTH]; - -export function FaultPolygonLayerSettingsComponent(props: FaultPolygonLayerSettingsComponentProps): React.ReactNode { - // useLayerManagerTopicValue(props.layer.getLayerManager(), LayerManagerTopic.SETTINGS_CHANGED); - const settings = useLayerSettings(props.layer); - const [newSettings, setNewSettings] = React.useState(cloneDeep(settings)); - const [prevSettings, setPrevSettings] = React.useState(cloneDeep(settings)); - const overridenSettingsKeys = props.layer.getOverridenSettingsKeys(); - - if (!isEqual(settings, prevSettings)) { - setPrevSettings(settings); - setNewSettings(settings); - } - - const ensembleFilterFunc = useEnsembleRealizationFilterFunc(props.workbenchSession); - - const usePolygonsDirectoryQuery = usePolygonsMetadataQuery( - newSettings.ensembleIdent?.getCaseUuid(), - newSettings.ensembleIdent?.getEnsembleName() - ); - - const fixupEnsembleIdent = fixupSetting( - "ensembleIdent", - props.ensembleSet.getEnsembleArr().map((el) => el.getIdent()), - newSettings - ); - if (!isEqual(fixupEnsembleIdent, newSettings.ensembleIdent)) { - setNewSettings((prev) => ({ ...prev, ensembleIdent: fixupEnsembleIdent })); - } - - if (fixupEnsembleIdent) { - const fixupRealizationNum = fixupSetting("realizationNum", ensembleFilterFunc(fixupEnsembleIdent), newSettings); - if (!isEqual(fixupRealizationNum, newSettings.realizationNum)) { - setNewSettings((prev) => ({ ...prev, realizationNum: fixupRealizationNum })); - } - } - - const availableAttributes: string[] = []; - const availablePolygonNames: string[] = []; - - if (usePolygonsDirectoryQuery.data) { - availableAttributes.push( - ...Array.from( - new Set( - usePolygonsDirectoryQuery.data - .filter((el) => faultPolygonAttributeTypes.includes(el.attribute_type)) - .map((el) => el.attribute_name) - ) - ) - ); - - const fixupAttribute = fixupSetting("attribute", availableAttributes, newSettings); - if (!isEqual(fixupAttribute, newSettings.attribute)) { - setNewSettings((prev) => ({ ...prev, attribute: fixupAttribute })); - } - } - - if (usePolygonsDirectoryQuery.data && newSettings.attribute) { - availablePolygonNames.push( - ...Array.from( - new Set( - usePolygonsDirectoryQuery.data - .filter((el) => el.attribute_name === newSettings.attribute) - .map((el) => el.name) - ) - ) - ); - - const fixupPolygonName = fixupSetting("polygonName", availablePolygonNames, newSettings); - if (!isEqual(fixupPolygonName, newSettings.polygonName)) { - setNewSettings((prev) => ({ ...prev, polygonName: fixupPolygonName })); - } - - props.layer.maybeRefetchData(); - } - - React.useEffect( - function propagateSettingsChange() { - props.layer.maybeUpdateSettings(cloneDeep(newSettings)); - }, - [newSettings, props.layer] - ); - - React.useEffect( - function maybeRefetchData() { - props.layer.setIsSuspended(usePolygonsDirectoryQuery.isFetching); - if (!usePolygonsDirectoryQuery.isFetching) { - props.layer.maybeRefetchData(); - } - }, - [usePolygonsDirectoryQuery.isFetching, props.layer, newSettings] - ); - - function handleEnsembleChange(ensembleIdent: EnsembleIdent | null) { - setNewSettings((prev) => ({ ...prev, ensembleIdent })); - } - - function handleRealizationChange(realizationNum: string) { - setNewSettings((prev) => ({ ...prev, realizationNum: parseInt(realizationNum) })); - } - - function handleAttributeChange(attribute: string) { - setNewSettings((prev) => ({ ...prev, attribute })); - } - - function handlePolygonNameChange(polygonName: string) { - setNewSettings((prev) => ({ ...prev, polygonName })); - } - - const availableRealizations: number[] = []; - if (fixupEnsembleIdent) { - availableRealizations.push(...ensembleFilterFunc(fixupEnsembleIdent)); - } - - return ( -
-
-
Ensemble
-
- -
-
-
-
Realization
-
- -
-
-
-
Attribute
-
- - - -
-
-
-
Name
-
- - - -
-
-
- ); -} - -function makeRealizationOptions(realizations: readonly number[]): DropdownOption[] { - return realizations.map((realization) => ({ label: realization.toString(), value: realization.toString() })); -} - -function makeAttributeOptions(attributes: string[]): DropdownOption[] { - return attributes.map((attr) => ({ label: attr, value: attr })); -} - -function makePolygonNamesOptions(polygonNames: string[]): DropdownOption[] { - return polygonNames.map((polygonName) => ({ label: polygonName, value: polygonName })); -} - -const STALE_TIME = 60 * 1000; -const CACHE_TIME = 60 * 1000; - -export function usePolygonsMetadataQuery( - caseUuid: string | undefined, - ensembleName: string | undefined -): UseQueryResult { - return useQuery({ - queryKey: ["getPolygonsDirectory", caseUuid, ensembleName], - queryFn: () => apiService.polygons.getPolygonsDirectory(caseUuid ?? "", ensembleName ?? ""), - staleTime: STALE_TIME, - gcTime: CACHE_TIME, - enabled: Boolean(caseUuid && ensembleName), - }); -} diff --git a/frontend/src/modules/2DViewer/settings/components/layerSettings/polygonLayer.tsx b/frontend/src/modules/2DViewer/settings/components/layerSettings/polygonLayer.tsx deleted file mode 100644 index c0c423b2d..000000000 --- a/frontend/src/modules/2DViewer/settings/components/layerSettings/polygonLayer.tsx +++ /dev/null @@ -1,240 +0,0 @@ -import React from "react"; - -import { PolygonsAttributeType_api, PolygonsMeta_api } from "@api"; -import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { EnsembleSet } from "@framework/EnsembleSet"; -import { WorkbenchSession, useEnsembleRealizationFilterFunc } from "@framework/WorkbenchSession"; -import { WorkbenchSettings } from "@framework/WorkbenchSettings"; -import { EnsembleDropdown } from "@framework/components/EnsembleDropdown"; -import { ColorSelect } from "@lib/components/ColorSelect"; -import { Dropdown, DropdownOption } from "@lib/components/Dropdown"; -import { PendingWrapper } from "@lib/components/PendingWrapper"; -import { PolygonLayer, PolygonLayerSettings } from "@modules/2DViewer/layers/PolygonLayer"; -import { useLayerSettings } from "@modules/_shared/layers/BaseLayer"; -import { UseQueryResult, useQuery } from "@tanstack/react-query"; - -import { cloneDeep, isEqual } from "lodash"; - -import { fixupSetting } from "./utils"; - -export type PolygonLayerSettingsComponentProps = { - layer: PolygonLayer; - ensembleSet: EnsembleSet; - workbenchSession: WorkbenchSession; - workbenchSettings: WorkbenchSettings; -}; -const faultPolygonAttributeTypes = [PolygonsAttributeType_api.FAULT_LINES, PolygonsAttributeType_api.DEPTH]; - -export function PolygonLayerSettingsComponent(props: PolygonLayerSettingsComponentProps): React.ReactNode { - //useLayerManagerTopicValue(props.layer.getLayerManager(), LayerManagerTopic.SETTINGS_CHANGED); - const settings = useLayerSettings(props.layer); - const [newSettings, setNewSettings] = React.useState(cloneDeep(settings)); - const [prevSettings, setPrevSettings] = React.useState(cloneDeep(settings)); - const overridenSettingsKeys = props.layer.getOverridenSettingsKeys(); - - if (!isEqual(settings, prevSettings)) { - setPrevSettings(settings); - setNewSettings(settings); - } - - const ensembleFilterFunc = useEnsembleRealizationFilterFunc(props.workbenchSession); - - const usePolygonsDirectoryQuery = usePolygonsMetadataQuery( - newSettings.ensembleIdent?.getCaseUuid(), - newSettings.ensembleIdent?.getEnsembleName() - ); - - const fixupEnsembleIdent = fixupSetting( - "ensembleIdent", - props.ensembleSet.getEnsembleArr().map((el) => el.getIdent()), - newSettings - ); - if (!isEqual(fixupEnsembleIdent, newSettings.ensembleIdent)) { - setNewSettings((prev) => ({ ...prev, ensembleIdent: fixupEnsembleIdent })); - } - - if (fixupEnsembleIdent) { - const fixupRealizationNum = fixupSetting("realizationNum", ensembleFilterFunc(fixupEnsembleIdent), newSettings); - if (!isEqual(fixupRealizationNum, newSettings.realizationNum)) { - setNewSettings((prev) => ({ ...prev, realizationNum: fixupRealizationNum })); - } - } - - const availableAttributes: string[] = []; - const availablePolygonNames: string[] = []; - - if (usePolygonsDirectoryQuery.data) { - availableAttributes.push( - ...Array.from( - new Set( - usePolygonsDirectoryQuery.data - .filter((el) => !faultPolygonAttributeTypes.includes(el.attribute_type)) - .map((el) => el.attribute_name) - ) - ) - ); - - const fixupAttribute = fixupSetting("attribute", availableAttributes, newSettings); - if (!isEqual(fixupAttribute, newSettings.attribute)) { - setNewSettings((prev) => ({ ...prev, attribute: fixupAttribute })); - } - } - - if (usePolygonsDirectoryQuery.data && newSettings.attribute) { - availablePolygonNames.push( - ...Array.from( - new Set( - usePolygonsDirectoryQuery.data - .filter((el) => el.attribute_name === newSettings.attribute) - .map((el) => el.name) - ) - ) - ); - - const fixupPolygonName = fixupSetting("polygonName", availablePolygonNames, newSettings); - if (!isEqual(fixupPolygonName, newSettings.polygonName)) { - setNewSettings((prev) => ({ ...prev, polygonName: fixupPolygonName })); - } - - props.layer.maybeRefetchData(); - } - - React.useEffect( - function propagateSettingsChange() { - props.layer.maybeUpdateSettings(cloneDeep(newSettings)); - }, - [newSettings, props.layer] - ); - - React.useEffect( - function maybeRefetchData() { - props.layer.setIsSuspended(usePolygonsDirectoryQuery.isFetching); - if (!usePolygonsDirectoryQuery.isFetching) { - props.layer.maybeRefetchData(); - } - }, - [usePolygonsDirectoryQuery.isFetching, props.layer, newSettings] - ); - - function handleEnsembleChange(ensembleIdent: EnsembleIdent | null) { - setNewSettings((prev) => ({ ...prev, ensembleIdent })); - } - - function handleRealizationChange(realizationNum: string) { - setNewSettings((prev) => ({ ...prev, realizationNum: parseInt(realizationNum) })); - } - - function handleAttributeChange(attribute: string) { - setNewSettings((prev) => ({ ...prev, attribute })); - } - - function handlePolygonNameChange(polygonName: string) { - setNewSettings((prev) => ({ ...prev, polygonName })); - } - function handleColorChange(color: string) { - setNewSettings((prev) => ({ ...prev, color })); - } - - const availableRealizations: number[] = []; - if (fixupEnsembleIdent) { - availableRealizations.push(...ensembleFilterFunc(fixupEnsembleIdent)); - } - - return ( -
-
-
Ensemble
-
- -
-
-
-
Realization
-
- -
-
-
-
Attribute
-
- - - -
-
-
-
Name
-
- - - -
-
-
-
Color set
-
- -
-
-
- ); -} - -function makeRealizationOptions(realizations: readonly number[]): DropdownOption[] { - return realizations.map((realization) => ({ label: realization.toString(), value: realization.toString() })); -} - -function makeAttributeOptions(attributes: string[]): DropdownOption[] { - return attributes.map((attr) => ({ label: attr, value: attr })); -} - -function makePolygonNamesOptions(polygonNames: string[]): DropdownOption[] { - return polygonNames.map((polygonName) => ({ label: polygonName, value: polygonName })); -} - -const STALE_TIME = 60 * 1000; -const CACHE_TIME = 60 * 1000; - -export function usePolygonsMetadataQuery( - caseUuid: string | undefined, - ensembleName: string | undefined -): UseQueryResult { - return useQuery({ - queryKey: ["getPolygonsDirectory", caseUuid, ensembleName], - queryFn: () => apiService.polygons.getPolygonsDirectory(caseUuid ?? "", ensembleName ?? ""), - staleTime: STALE_TIME, - gcTime: CACHE_TIME, - enabled: Boolean(caseUuid && ensembleName), - }); -} diff --git a/frontend/src/modules/2DViewer/settings/components/layerSettings/surfaceLayer.tsx b/frontend/src/modules/2DViewer/settings/components/layerSettings/surfaceLayer.tsx deleted file mode 100644 index f8813b79d..000000000 --- a/frontend/src/modules/2DViewer/settings/components/layerSettings/surfaceLayer.tsx +++ /dev/null @@ -1,273 +0,0 @@ -import React from "react"; - -import { SurfaceAttributeType_api, SurfaceMetaSet_api } from "@api"; -import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { EnsembleSet } from "@framework/EnsembleSet"; -import { WorkbenchSession, useEnsembleRealizationFilterFunc } from "@framework/WorkbenchSession"; -import { WorkbenchSettings } from "@framework/WorkbenchSettings"; -import { EnsembleDropdown } from "@framework/components/EnsembleDropdown"; -import { Dropdown, DropdownOption } from "@lib/components/Dropdown"; -import { PendingWrapper } from "@lib/components/PendingWrapper"; -import { SurfaceLayer, SurfaceLayerSettings } from "@modules/2DViewer/layers/SurfaceLayer"; -import { useLayerSettings } from "@modules/_shared/layers/BaseLayer"; -import { UseQueryResult, useQuery } from "@tanstack/react-query"; - -import { cloneDeep, isEqual } from "lodash"; - -import { fixupSetting } from "./utils"; - -import { EnsembleStage, EnsembleStageSelect, EnsembleStageType } from "../ensembleStageSelect"; - -export type SurfaceLayerSettingsComponentProps = { - layer: SurfaceLayer; - ensembleSet: EnsembleSet; - workbenchSession: WorkbenchSession; - workbenchSettings: WorkbenchSettings; -}; - -export function SurfaceLayerSettingsComponent(props: SurfaceLayerSettingsComponentProps): React.ReactNode { - //useLayerManagerTopicValue(props.layer.getLayerManager(), LayerManagerTopic.SETTINGS_CHANGED); - const settings = useLayerSettings(props.layer); - const [newSettings, setNewSettings] = React.useState(cloneDeep(settings)); - const [prevSettings, setPrevSettings] = React.useState(cloneDeep(settings)); - const overridenSettingsKeys = props.layer.getOverridenSettingsKeys(); - - if (!isEqual(settings, prevSettings)) { - setPrevSettings(settings); - setNewSettings(settings); - } - - const ensembleFilterFunc = useEnsembleRealizationFilterFunc(props.workbenchSession); - - const surfaceDirectoryQuery = useRealizationSurfacesMetadataQuery( - newSettings.ensembleIdent?.getCaseUuid(), - newSettings.ensembleIdent?.getEnsembleName() - ); - - const fixupEnsembleIdent = fixupSetting( - "ensembleIdent", - props.ensembleSet.getEnsembleArr().map((el) => el.getIdent()), - newSettings - ); - if (!isEqual(fixupEnsembleIdent, newSettings.ensembleIdent)) { - setNewSettings((prev) => ({ ...prev, ensembleIdent: fixupEnsembleIdent })); - } - - if (fixupEnsembleIdent) { - const fixupRealizationNum = fixupSetting("realizationNum", ensembleFilterFunc(fixupEnsembleIdent), newSettings); - if (!isEqual(fixupRealizationNum, newSettings.realizationNum)) { - setNewSettings((prev) => ({ ...prev, realizationNum: fixupRealizationNum })); - } - } - - const availableAttributes: string[] = []; - const availableSurfaceNames: string[] = []; - - if (surfaceDirectoryQuery.data) { - availableAttributes.push( - ...Array.from( - new Set( - surfaceDirectoryQuery.data.surfaces - .filter((el) => el.attribute_type === SurfaceAttributeType_api.DEPTH) - .map((el) => el.attribute_name) - ) - ) - ); - - const fixupAttribute = fixupSetting("attribute", availableAttributes, newSettings); - if (!isEqual(fixupAttribute, newSettings.attribute)) { - setNewSettings((prev) => ({ ...prev, attribute: fixupAttribute })); - } - } - - if (surfaceDirectoryQuery.data && newSettings.attribute) { - availableSurfaceNames.push( - ...Array.from( - new Set( - surfaceDirectoryQuery.data.surfaces - .filter((el) => el.attribute_name === newSettings.attribute) - .map((el) => el.name) - ) - ) - ); - const fixupSurfaceName = fixupSetting("surfaceName", availableSurfaceNames, newSettings); - if (!isEqual(fixupSurfaceName, newSettings.surfaceName)) { - setNewSettings((prev) => ({ ...prev, surfaceName: fixupSurfaceName })); - } - - props.layer.maybeRefetchData(); - } - - React.useEffect( - function propagateSettingsChange() { - props.layer.maybeUpdateSettings(cloneDeep(newSettings)); - }, - [newSettings, props.layer] - ); - - React.useEffect( - function maybeRefetchData() { - props.layer.setIsSuspended(surfaceDirectoryQuery.isFetching); - if (!surfaceDirectoryQuery.isFetching) { - props.layer.maybeRefetchData(); - } - }, - [surfaceDirectoryQuery.isFetching, props.layer, newSettings] - ); - - function handleEnsembleChange(ensembleIdent: EnsembleIdent | null) { - setNewSettings((prev) => ({ ...prev, ensembleIdent })); - } - - function handleRealizationChange(realizationNum: string) { - setNewSettings((prev) => ({ ...prev, realizationNum: parseInt(realizationNum) })); - } - - function handleAttributeChange(attribute: string) { - setNewSettings((prev) => ({ ...prev, attribute })); - } - - function handleSurfaceNameChange(surfaceName: string) { - setNewSettings((prev) => ({ ...prev, surfaceName })); - } - function handleEnsembleStageChange(ensembleStage: EnsembleStage) { - if (ensembleStage.ensembleStage === EnsembleStageType.Statistics) { - setNewSettings((prev) => ({ - ...prev, - ensembleStage: ensembleStage.ensembleStage, - statisticFunction: ensembleStage.statisticFunction, - })); - } - if (ensembleStage.ensembleStage === EnsembleStageType.Realization) { - setNewSettings((prev) => ({ - ...prev, - ensembleStage: ensembleStage.ensembleStage, - realizationNum: ensembleStage.realizationNum, - })); - } - if (ensembleStage.ensembleStage === EnsembleStageType.Observation) { - setNewSettings((prev) => ({ - ...prev, - ensembleStage: ensembleStage.ensembleStage, - realizationNum: ensembleStage.realizationNum, - })); - } - } - const availableRealizations: number[] = []; - if (fixupEnsembleIdent) { - availableRealizations.push(...ensembleFilterFunc(fixupEnsembleIdent)); - } - - return ( -
-
-
Ensemble
-
- -
-
- -
-
Stage
-
- -
-
- -
-
Attribute
-
- - - -
-
-
-
Surface name
-
- - {" "} - - -
-
-
- ); -} - -function makeRealizationOptions(realizations: readonly number[]): DropdownOption[] { - return realizations.map((realization) => ({ label: realization.toString(), value: realization.toString() })); -} - -function makeAttributeOptions(attributes: string[]): DropdownOption[] { - return attributes.map((attr) => ({ label: attr, value: attr })); -} - -function makeSurfaceNameOptions(surfaceNames: string[]): DropdownOption[] { - return surfaceNames.map((surfaceName) => ({ label: surfaceName, value: surfaceName })); -} - -const STALE_TIME = 60 * 1000; -const CACHE_TIME = 60 * 1000; - -export function useRealizationSurfacesMetadataQuery( - caseUuid: string | undefined, - ensembleName: string | undefined -): UseQueryResult { - return useQuery({ - queryKey: ["getRealizationSurfacesMetadata", caseUuid, ensembleName], - queryFn: () => apiService.surface.getRealizationSurfacesMetadata(caseUuid ?? "", ensembleName ?? ""), - staleTime: STALE_TIME, - gcTime: CACHE_TIME, - enabled: Boolean(caseUuid && ensembleName), - }); -} - -function fixupSurfaceNamesSetting(currentSurfaceNames: string[], validSurfaceNames: string[]): string[] { - if (validSurfaceNames.length === 0) { - return currentSurfaceNames; - } - - let adjustedSurfaceNames = currentSurfaceNames.filter((el) => validSurfaceNames.includes(el)); - - if (adjustedSurfaceNames.length === 0) { - adjustedSurfaceNames = [validSurfaceNames[0]]; - } - - return adjustedSurfaceNames; -} diff --git a/frontend/src/modules/2DViewer/settings/components/layerSettings/utils.ts b/frontend/src/modules/2DViewer/settings/components/layerSettings/utils.ts deleted file mode 100644 index 40867d96e..000000000 --- a/frontend/src/modules/2DViewer/settings/components/layerSettings/utils.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { LayerSettings } from "@modules/_shared/layers/BaseLayer"; - -import { isEqual } from "lodash"; - -export function fixupSetting( - setting: TKey, - validOptions: readonly TSettings[TKey][], - settings: TSettings -): TSettings[TKey] { - if (validOptions.length === 0) { - return settings[setting]; - } - - if (!validOptions.some((el) => isEqual(el, settings[setting])) || settings[setting] === null) { - return validOptions[0]; - } - - return settings[setting]; -} diff --git a/frontend/src/modules/2DViewer/settings/components/layerSettings/wellboreLayer.tsx b/frontend/src/modules/2DViewer/settings/components/layerSettings/wellboreLayer.tsx deleted file mode 100644 index ae43b14a2..000000000 --- a/frontend/src/modules/2DViewer/settings/components/layerSettings/wellboreLayer.tsx +++ /dev/null @@ -1,128 +0,0 @@ -import React from "react"; - -import { SurfaceAttributeType_api, SurfaceMetaSet_api, WellboreHeader_api } from "@api"; -import { apiService } from "@framework/ApiService"; -import { EnsembleIdent } from "@framework/EnsembleIdent"; -import { EnsembleSet } from "@framework/EnsembleSet"; -import { WorkbenchSession, useEnsembleRealizationFilterFunc } from "@framework/WorkbenchSession"; -import { WorkbenchSettings } from "@framework/WorkbenchSettings"; -import { EnsembleDropdown } from "@framework/components/EnsembleDropdown"; -import { Dropdown, DropdownOption } from "@lib/components/Dropdown"; -import { PendingWrapper } from "@lib/components/PendingWrapper"; -import { Select } from "@lib/components/Select"; -import { WellboreLayer } from "@modules/2DViewer/layers/WellboreLayer"; -import { WellboreLayerSettings } from "@modules/2DViewer/layers/WellboreLayer"; -import { WellboreSelector } from "@modules/3DViewer/settings/components/wellboreSelector"; -import { useLayerSettings } from "@modules/_shared/layers/BaseLayer"; -import { UseQueryResult, useQuery } from "@tanstack/react-query"; - -import { cloneDeep, isEqual } from "lodash"; - -import { fixupSetting } from "./utils"; - -export type WellboreLayerSettingsComponentProps = { - layer: WellboreLayer; - ensembleSet: EnsembleSet; - workbenchSession: WorkbenchSession; - workbenchSettings: WorkbenchSettings; -}; - -export function WellboreLayerSettingsComponent(props: WellboreLayerSettingsComponentProps): React.ReactNode { - const settings = useLayerSettings(props.layer); - const [newSettings, setNewSettings] = React.useState(cloneDeep(settings)); - const [prevSettings, setPrevSettings] = React.useState(cloneDeep(settings)); - - if (!isEqual(settings, prevSettings)) { - setPrevSettings(settings); - setNewSettings(settings); - } - - let fieldIdentifier: string | null = null; - if (newSettings.ensembleIdent) { - const ensemble = props.ensembleSet.findEnsemble(newSettings.ensembleIdent); - if (ensemble) { - fieldIdentifier = ensemble.getFieldIdentifier(); - } - } - const fixupEnsembleIdent = fixupSetting( - "ensembleIdent", - props.ensembleSet.getEnsembleArr().map((el) => el.getIdent()), - newSettings - ); - if (!isEqual(fixupEnsembleIdent, newSettings.ensembleIdent)) { - setNewSettings((prev) => ({ ...prev, ensembleIdent: fixupEnsembleIdent })); - } - - if (fieldIdentifier !== newSettings.fieldIdentifier) { - setNewSettings((prev) => ({ ...prev, fieldIdentifier: fieldIdentifier })); - } - const drilledWellboreHeadersDirectoryQuery = useDrilledWellboreHeadersQuery(fieldIdentifier); - - const availableWellboreHeaders: WellboreHeader_api[] = drilledWellboreHeadersDirectoryQuery.data - ? drilledWellboreHeadersDirectoryQuery.data - : []; - const availableUuids: string[] = availableWellboreHeaders.map((header) => header.wellboreUuid); - - const fixupUuids = fixupWellboreUuids(availableUuids, newSettings.wellboreUuids); - if (!isEqual(fixupUuids, newSettings.wellboreUuids)) { - setNewSettings((prev) => ({ ...prev, wellboreUuids: fixupUuids })); - } - - React.useEffect( - function propagateSettingsChange() { - props.layer.maybeUpdateSettings(cloneDeep(newSettings)); - }, - [newSettings, props.layer] - ); - - React.useEffect( - function maybeRefetchData() { - props.layer.setIsSuspended(drilledWellboreHeadersDirectoryQuery.isFetching); - if (!drilledWellboreHeadersDirectoryQuery.isFetching) { - props.layer.maybeRefetchData(); - } - }, - [drilledWellboreHeadersDirectoryQuery.isFetching, props.layer, newSettings] - ); - - function handleUiidsChange(wellboreUuids: string[]) { - setNewSettings((prev) => ({ ...prev, wellboreUuids })); - } - - return ( -
- -
- ); -} - -const STALE_TIME = 60 * 1000; -const CACHE_TIME = 60 * 1000; - -export function useDrilledWellboreHeadersQuery(fieldIdentifier: string | null): UseQueryResult { - return useQuery({ - queryKey: ["getDrilledWellboreHeaders", fieldIdentifier], - queryFn: () => apiService.well.getDrilledWellboreHeaders(fieldIdentifier || ""), - staleTime: STALE_TIME, - gcTime: CACHE_TIME, - enabled: Boolean(fieldIdentifier), - }); -} - -function fixupWellboreUuids(currentUuids: string[], validUuids: string[]): string[] { - if (validUuids.length === 0) { - return []; - } - - let adjustedUuids = currentUuids.filter((el) => validUuids.includes(el)); - - if (adjustedUuids.length === 0) { - adjustedUuids = [validUuids[0]]; - } - - return adjustedUuids; -} diff --git a/frontend/src/modules/2DViewer/settings/settings.tsx b/frontend/src/modules/2DViewer/settings/settings.tsx index bbaa879c7..388f39b1d 100644 --- a/frontend/src/modules/2DViewer/settings/settings.tsx +++ b/frontend/src/modules/2DViewer/settings/settings.tsx @@ -1,205 +1,259 @@ import React from "react"; -import { EnsembleSet } from "@framework/EnsembleSet"; import { ModuleSettingsProps } from "@framework/Module"; -import { WorkbenchSession, useEnsembleSet } from "@framework/WorkbenchSession"; -import { WorkbenchSettings } from "@framework/WorkbenchSettings"; -import { FieldDropdown } from "@framework/components/FieldDropdown"; -import { CollapsibleGroup } from "@lib/components/CollapsibleGroup"; -import { Menu } from "@lib/components/Menu"; -import { MenuDivider } from "@lib/components/MenuDivider"; -import { MenuHeading } from "@lib/components/MenuHeading"; -import { MenuItem } from "@lib/components/MenuItem"; -import { LayersPanel } from "@modules/_shared/components/Layers"; -import { BaseLayer } from "@modules/_shared/layers/BaseLayer"; -import { LayerGroup } from "@modules/_shared/layers/LayerGroup"; -import { LayerSettingFactory } from "@modules/_shared/layers/settings/LayerSettingFactory"; -import { SETTING_TYPE_TO_STRING_MAPPING, SettingType } from "@modules/_shared/layers/settings/SettingTypes"; -import { Dropdown, MenuButton } from "@mui/base"; -import { Add, ArrowDropDown, GridView } from "@mui/icons-material"; - -import { useAtomValue, useSetAtom } from "jotai"; - -import { userSelectedFieldIdentifierAtom } from "./atoms/baseAtoms"; -import { filteredEnsembleSetAtom, layerManagerAtom, selectedFieldIdentifierAtom } from "./atoms/derivedAtoms"; -import { FaultPolygonLayerSettingsComponent } from "./components/layerSettings/faultPolygonLayer"; -import { PolygonLayerSettingsComponent } from "./components/layerSettings/polygonLayer"; -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"; - -export function Settings(props: ModuleSettingsProps): React.ReactNode { - const ensembleSet = useEnsembleSet(props.workbenchSession); - - const selectedFieldIdentifier = useAtomValue(selectedFieldIdentifierAtom); - const setSelectedFieldIdentifier = useSetAtom(userSelectedFieldIdentifierAtom); - - const filteredEnsembleSet = useAtomValue(filteredEnsembleSetAtom); - - const layerManager = useAtomValue(layerManagerAtom); - - function handleFieldIdentifierChange(fieldIdentifier: string | null) { - setSelectedFieldIdentifier(fieldIdentifier); - } +import { IsMoveAllowedArgs, SortableList } from "@lib/components/SortableList"; +import { Add } from "@mui/icons-material"; +import { useQueryClient } from "@tanstack/react-query"; + +import { useSetAtom } from "jotai"; + +import { layerManagerAtom } from "./atoms/baseAtoms"; + +import { LayerManager } from "../layers/LayerManager"; +import { usePublishSubscribeTopicValue } from "../layers/PublishSubscribeHandler"; +import { SharedSetting } from "../layers/SharedSetting"; +import { View } from "../layers/View"; +import { LayersActionGroup, LayersActions } from "../layers/components/layersActions"; +import { makeComponent } from "../layers/components/utils"; +import { GroupBaseTopic } from "../layers/delegates/GroupDelegate"; +import { DrilledWellTrajectoriesLayer } from "../layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesLayer"; +import { ObservedSurfaceLayer } from "../layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceLayer"; +import { RealizationGridLayer } from "../layers/implementations/layers/RealizationGridLayer/RealizationGridLayer"; +import { RealizationPolygonsLayer } from "../layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsLayer"; +import { RealizationSurfaceLayer } from "../layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceLayer"; +import { StatisticalSurfaceLayer } from "../layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer"; +import { Ensemble } from "../layers/implementations/settings/Ensemble"; +import { Realization } from "../layers/implementations/settings/Realization"; +import { SurfaceName } from "../layers/implementations/settings/SurfaceName"; +import { Group, Item, instanceofGroup } from "../layers/interfaces"; + +export function Settings(props: ModuleSettingsProps): React.ReactNode { + const queryClient = useQueryClient(); + const layerManager = React.useRef( + new LayerManager(props.workbenchSession, props.workbenchSettings, queryClient) + ); + + const colorSet = props.workbenchSettings.useColorSet(); + + const groupDelegate = layerManager.current.getGroupDelegate(); + const items = usePublishSubscribeTopicValue(groupDelegate, GroupBaseTopic.CHILDREN); + + const setLayerManager = useSetAtom(layerManagerAtom); - function handleAddLayer(layerType: LayerType) { - const layer = LayerFactory.makeLayer(layerType, layerManager); - layer.setQueryClient(layerManager.getQueryClient()); - layerManager.getMainGroup().prependItem(layer); + React.useEffect( + function onMountEffect() { + setLayerManager(layerManager.current); + }, + [setLayerManager] + ); + + function handleLayerAction(identifier: string, group?: Group) { + let groupDelegate = layerManager.current.getGroupDelegate(); + if (group) { + groupDelegate = group.getGroupDelegate(); + } + + switch (identifier) { + case "view": + groupDelegate.appendChild(new View("New View", colorSet.getNextColor())); + return; + case "observed_surface": + groupDelegate.appendChild(new ObservedSurfaceLayer()); + return; + case "statistical_surface": + groupDelegate.appendChild(new StatisticalSurfaceLayer()); + return; + case "realization_surface": + groupDelegate.appendChild(new RealizationSurfaceLayer()); + return; + case "realization_polygons": + groupDelegate.appendChild(new RealizationPolygonsLayer()); + return; + case "drilled_wellbores": + groupDelegate.appendChild(new DrilledWellTrajectoriesLayer()); + return; + case "realization_grid": + groupDelegate.appendChild(new RealizationGridLayer()); + return; + case "ensemble": + groupDelegate.prependChild(new SharedSetting(new Ensemble())); + return; + case "realization": + groupDelegate.prependChild(new SharedSetting(new Realization())); + return; + case "surface_name": + groupDelegate.prependChild(new SharedSetting(new SurfaceName())); + return; + } } - function handleAddView() { - layerManager.getMainGroup().prependItem(new LayerGroup("View", layerManager.getMainGroup())); + function checkIfItemMoveAllowed(args: IsMoveAllowedArgs): boolean { + const movedItem = groupDelegate.findDescendantById(args.movedItemId); + if (!movedItem) { + return false; + } + + const destinationItem = args.destinationId + ? groupDelegate.findDescendantById(args.destinationId) + : layerManager.current; + + if (!destinationItem || !instanceofGroup(destinationItem)) { + return false; + } + + const numSharedSettings = + destinationItem.getGroupDelegate().findChildren((item) => { + return item instanceof SharedSetting; + }).length ?? 0; + + if (!(movedItem instanceof SharedSetting)) { + if (args.position < numSharedSettings) { + return false; + } + } else { + if (args.originId === args.destinationId) { + if (args.position >= numSharedSettings) { + return false; + } + } else { + if (args.position > numSharedSettings) { + return false; + } + } + } + + return true; } - function handleAddSetting(settingType: SettingType) { - const setting = LayerSettingFactory.makeSetting(settingType); - layerManager.getMainGroup().prependItem(setting); + function handleItemMoved( + movedItemId: string, + originId: string | null, + destinationId: string | null, + position: number + ) { + const movedItem = groupDelegate.findDescendantById(movedItemId); + if (!movedItem) { + return; + } + + let origin = layerManager.current.getGroupDelegate(); + if (originId) { + const candidate = groupDelegate.findDescendantById(originId); + if (candidate && instanceofGroup(candidate)) { + origin = candidate.getGroupDelegate(); + } + } + + let destination = layerManager.current.getGroupDelegate(); + if (destinationId) { + const candidate = groupDelegate.findDescendantById(destinationId); + if (candidate && instanceofGroup(candidate)) { + destination = candidate.getGroupDelegate(); + } + } + + if (origin === destination) { + origin.moveChild(movedItem, position); + return; + } + + origin.removeChild(movedItem); + destination.insertChild(movedItem, position); } return ( -
- - - +
- - } - groupIcon={} - /> +
+
+
Layers
+ +
+
+ + Click on to add a layer. +
+ } + > + {items.map((item: Item) => makeComponent(item, VIEW_ACTIONS, handleLayerAction))} + +
+
); } -type LayersPanelActionsProps = { - layerTypeToStringMapping: Record; - settingTypeToStringMapping: Record; - onAddView: () => void; - onAddLayer: (layerType: TLayerType) => void; - onAddSetting: (settingType: TSettingType) => void; -}; - -function LayersPanelActions( - props: LayersPanelActionsProps -): React.ReactNode { - return ( - - -
- - Add - -
-
- - - - View - - - Layers - {Object.keys(props.layerTypeToStringMapping).map((layerType, index) => { - return ( - props.onAddLayer(layerType as TLayerType)} - > - {props.layerTypeToStringMapping[layerType as TLayerType]} - - ); - })} - - Settings - {Object.keys(props.settingTypeToStringMapping).map((settingType, index) => { - return ( - props.onAddSetting(settingType as TSettingType)} - > - {props.settingTypeToStringMapping[settingType as TSettingType]} - - ); - })} - -
- ); -} +const LAYER_ACTIONS: LayersActionGroup[] = [ + { + label: "View", + children: [ + { + identifier: "view", + label: "Add View", + }, + ], + }, + { + label: "Layers", + children: [ + { + label: "Surfaces", + children: [ + { + identifier: "observed_surface", + label: "Observed Surface", + }, + { + identifier: "statistical_surface", + label: "Statistical Surface", + }, + { + identifier: "realization_surface", + label: "Realization Surface", + }, + ], + }, + { + label: "Others", + children: [ + { + identifier: "realization_polygons", + label: "Realization Polygons", + }, + { + identifier: "drilled_wellbores", + label: "Drilled Wellbore Trajectories", + }, + { + identifier: "realization_grid", + label: "Realization Grid", + }, + ], + }, + ], + }, + { + label: "Shared Settings", + children: [ + { + identifier: "ensemble", + label: "Ensemble", + }, + { + identifier: "realization", + label: "Realization", + }, + { + identifier: "surface_name", + label: "Surface Name", + }, + ], + }, +]; -function makeSettingsContainer( - layer: BaseLayer, - ensembleSet: EnsembleSet, - workbenchSession: WorkbenchSession, - workbenchSettings: WorkbenchSettings -): React.ReactNode { - if (isSurfaceLayer(layer)) { - return ( - - ); - } - if (isWellboreLayer(layer)) { - return ( - - ); - } - if (isFaultPolygonLayer(layer)) { - return ( - - ); - } - if (isPolygonLayer(layer)) { - return ( - - ); - } - return null; -} +const VIEW_ACTIONS: LayersActionGroup[] = LAYER_ACTIONS.filter((group) => group.label !== "View"); diff --git a/frontend/src/modules/LayerSpike/types.ts b/frontend/src/modules/2DViewer/types.ts similarity index 100% rename from frontend/src/modules/LayerSpike/types.ts rename to frontend/src/modules/2DViewer/types.ts diff --git a/frontend/src/modules/LayerSpike/view/layerFactory.ts b/frontend/src/modules/2DViewer/view/layerFactory.ts similarity index 100% rename from frontend/src/modules/LayerSpike/view/layerFactory.ts rename to frontend/src/modules/2DViewer/view/layerFactory.ts diff --git a/frontend/src/modules/2DViewer/view/view.tsx b/frontend/src/modules/2DViewer/view/view.tsx index 53a04de3d..6640c645f 100644 --- a/frontend/src/modules/2DViewer/view/view.tsx +++ b/frontend/src/modules/2DViewer/view/view.tsx @@ -1,146 +1,57 @@ import React from "react"; -import { PolygonData_api, WellboreTrajectory_api } from "@api"; -import { Layer } from "@deck.gl/core/typed"; -import { View as DeckGlView } from "@deck.gl/core/typed"; -import { GeoJsonLayer } from "@deck.gl/layers/typed"; +import { View as DeckGlView, Layer } from "@deck.gl/core/typed"; import { ModuleViewProps } from "@framework/Module"; -import { useViewStatusWriter } from "@framework/StatusWriter"; -import { wellTrajectoryToGeojson } from "@modules/SubsurfaceMap/_utils/subsurfaceMap"; -import { SurfaceDataFloat_trans } from "@modules/_shared/Surface/queryDataTransforms"; -import { BaseLayer, LayerStatus, useLayers, useLayersStatuses } from "@modules/_shared/layers/BaseLayer"; -import { LayerGroup } from "@modules/_shared/layers/LayerGroup"; -import { LayerManagerTopic, useLayerManagerTopicValue } from "@modules/_shared/layers/LayerManager"; +import { useQueryClient } from "@tanstack/react-query"; import { ViewportType } from "@webviz/subsurface-viewer"; import SubsurfaceViewer, { ViewsType } from "@webviz/subsurface-viewer/dist/SubsurfaceViewer"; -import { Axes2DLayer, MapLayer, WellsLayer } from "@webviz/subsurface-viewer/dist/layers"; +import { Axes2DLayer } from "@webviz/subsurface-viewer/dist/layers"; -import { Rgb, parse } from "culori"; -import { isEqual } from "lodash"; +import { makeLayer } from "./layerFactory"; 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 { LayerManager, LayerManagerTopic } from "../layers/LayerManager"; +import { usePublishSubscribeTopicValue } from "../layers/PublishSubscribeHandler"; +import { View as ViewGroup } from "../layers/View"; +import { GroupBaseTopic, GroupDelegate } from "../layers/delegates/GroupDelegate"; +import { Item, LayerStatus, instanceofGroup, instanceofLayer } from "../layers/interfaces"; export function View(props: ModuleViewProps): React.ReactNode { - const statusWriter = useViewStatusWriter(props.viewContext); + const queryClient = useQueryClient(); const layerManager = props.viewContext.useSettingsToViewInterfaceValue("layerManager"); - const allItems = useLayerManagerTopicValue(layerManager, LayerManagerTopic.ITEMS_CHANGED); - const mainGroup = layerManager.getMainGroup(); - - const [prevLayerItems, setPrevLayerItems] = React.useState[]>([]); - - const currentLayerItems = allItems.filter((item) => item instanceof BaseLayer) as BaseLayer[]; - if (!isEqual(currentLayerItems, prevLayerItems)) { - setPrevLayerItems(currentLayerItems); - } - - const layers = useLayers(prevLayerItems); - const layersStatuses = useLayersStatuses(layers); - - statusWriter.setLoading(layersStatuses.some((status) => status.status === LayerStatus.LOADING)); - - const groupLayersMap: Map = new Map(); - const globalLayers: Layer[] = []; - - const items = allItems.filter((item) => item instanceof BaseLayer || item instanceof LayerGroup) as ( - | BaseLayer - | LayerGroup - )[]; - - for (const item of mainGroup.getItems()) { - if (!(item instanceof BaseLayer) && !(item instanceof LayerGroup)) { - continue; - } - if (!item.getIsVisible()) { - continue; - } - if (item instanceof BaseLayer) { - const data = item.getData(); - if (data) { - if (item instanceof SurfaceLayer) { - if ("valuesFloat32Arr" in data) { - const mapLayer = createMapFloatLayer(data, item.getId()); - globalLayers.push(mapLayer); - } - } - - if (item instanceof WellboreLayer) { - const uuids = item.getSettings().wellboreUuids; - const trajectories = data.filter((wellTrajectory: WellboreTrajectory_api) => - uuids.includes(wellTrajectory.wellboreUuid) - ); - const WellsLayer = createWellsLayer(trajectories, item.getId()); - globalLayers.push(WellsLayer); - } - if (item instanceof FaultPolygonLayer) { - const faultPolygonLayer = createFaultPolygonsLayer(data, item.getId()); - globalLayers.push(faultPolygonLayer); - } - if (item instanceof PolygonLayer) { - const polygonLayer = createPolygonsLayer(data, item.getId(), item.getSettings().color); - globalLayers.push(polygonLayer); - } - } - } else if (item instanceof LayerGroup) { - const layers = item.getItems(); - const groupLayers: Layer[] = []; - for (const layer of layers) { - if (!(layer instanceof BaseLayer)) { - continue; - } - if (!layer.getIsVisible()) { - continue; - } - const data = layer.getData(); - if (data) { - if (layer instanceof SurfaceLayer) { - if ("valuesFloat32Arr" in data) { - const mapLayer = createMapFloatLayer(data, layer.getId()); - groupLayers.push(mapLayer); - } - } - - if (layer instanceof WellboreLayer) { - const uuids = layer.getSettings().wellboreUuids; + const items: Item[] = usePublishSubscribeTopicValue( + layerManager?.getGroupDelegate() || new GroupDelegate(null), + GroupBaseTopic.CHILDREN + ); - const trajectories = data.filter((wellTrajectory: WellboreTrajectory_api) => - uuids.includes(wellTrajectory.wellboreUuid) - ); - const WellsLayer = createWellsLayer(trajectories, layer.getId()); - groupLayers.push(WellsLayer); - } + usePublishSubscribeTopicValue( + layerManager ?? new LayerManager(props.workbenchSession, props.workbenchSettings, queryClient), + LayerManagerTopic.LAYER_DATA_REVISION + ); - if (layer instanceof FaultPolygonLayer) { - const faultPolygonLayer = createFaultPolygonsLayer(data, layer.getId()); - groupLayers.push(faultPolygonLayer); - } - if (layer instanceof PolygonLayer) { - const polygonLayer = createPolygonsLayer(data, layer.getId(), layer.getSettings().color); - groupLayers.push(polygonLayer); - } - } - } - groupLayersMap.set(item.getName(), groupLayers); - } - } + const results = extractGroupsAndLayers(items); - const numCols = Math.ceil(Math.sqrt(groupLayersMap.size)); - const numRows = Math.ceil(groupLayersMap.size / numCols); + const numCols = Math.ceil(Math.sqrt(results.groupLayersMap.size)); + const numRows = Math.ceil(results.groupLayersMap.size / numCols); const viewports: ViewportType[] = []; const viewerLayers: Layer[] = []; const viewportAnnotations: React.ReactNode[] = []; - for (const [group, layers] of groupLayersMap) { + + const views: ViewsType = { + layout: [numRows, numCols], + viewports: viewports, + showLabel: true, + }; + + for (const [group, layers] of results.groupLayersMap) { viewports.push({ id: group, - name: group, + name: results.groupMeta.get(group)?.name ?? group, isSync: true, layerIds: [ ...layers.map((layer) => (layer as unknown as Layer).id), - ...globalLayers.map((layer) => layer.id), + ...results.globalLayers.map((layer) => layer.id), "axes", ], }); @@ -149,11 +60,17 @@ export function View(props: ModuleViewProps): React.ReactNode { // eslint-disable-next-line @typescript-eslint/ban-ts-comment /* @ts-expect-error */ -
{group}
+
+
+
{results.groupMeta.get(group)?.name ?? group}
+
); } - viewerLayers.push(...globalLayers); + viewerLayers.push(...results.globalLayers.toReversed()); viewerLayers.push( new Axes2DLayer({ id: "axes", @@ -162,11 +79,6 @@ export function View(props: ModuleViewProps): React.ReactNode { }) ); - const views: ViewsType = { - layout: [numRows, numCols], - viewports: viewports, - showLabel: true, - }; return (
): React.ReactNode { ); } -function createMapFloatLayer(layerData: SurfaceDataFloat_trans, id: string): MapLayer { - return new MapLayer({ - id: id, - meshData: layerData.valuesFloat32Arr, - typedArraySupport: true, - frame: { - origin: [layerData.surface_def.origin_utm_x, layerData.surface_def.origin_utm_y], - count: [layerData.surface_def.npoints_x, layerData.surface_def.npoints_y], - increment: [layerData.surface_def.inc_x, layerData.surface_def.inc_y], - rotDeg: layerData.surface_def.rot_deg, - }, - contours: [0, 100], - isContoursDepth: true, - gridLines: false, - material: true, - smoothShading: true, - colorMapName: "Physics", - parameters: { - depthTest: false, - }, - depthTest: false, - }); -} +export type GroupMeta = { + name: string; + color: string | null; +}; -function createWellsLayer(wellbores: WellboreTrajectory_api[], id: string): WellsLayer { - const features: Record[] = wellbores.map((wellTrajectory: WellboreTrajectory_api) => { - return wellTrajectoryToGeojson(wellTrajectory); - }); - const featureCollection: Record = { - type: "FeatureCollection", - unit: "m", - features: features, - }; - return new WellsLayer({ - id: id, - data: featureCollection, - refine: false, - lineStyle: { width: 4, color: [128, 128, 128] }, - wellHeadStyle: { size: 1 }, - pickable: true, - autoHighlight: true, - opacity: 1, - outline: false, - lineWidthScale: 1, - pointRadiusScale: 1, - // outline: true, - logRadius: 10, - logCurves: true, - visible: true, - wellNameVisible: false, - wellNameAtTop: false, - wellNameSize: 14, - wellNameColor: [0, 0, 0, 255], - selectedWell: "@@#editedData.selectedWells", // used to get data from deckgl layer - depthTest: false, - ZIncreasingDownwards: true, - simplifiedRendering: false, - }); -} +function extractGroupsAndLayers(items: Item[]): { + groupLayersMap: Map; + groupMeta: Map; + globalLayers: Layer[]; +} { + const groupLayersMap: Map = new Map(); + const groupMeta: Map = new Map(); + const globalLayers: Layer[] = []; -function createFaultPolygonsLayer(polygonsData: PolygonData_api[], id: string): GeoJsonLayer { - const features: Record[] = polygonsData.map((polygon) => { - return surfacePolygonsToGeojson(polygon); - }); - const data: Record = { - type: "FeatureCollection", - unit: "m", - features: features, - }; - return new GeoJsonLayer({ - id: id, - data: data, - opacity: 0.5, - parameters: { - depthTest: false, - }, - depthTest: false, - pickable: true, - }); -} -function createPolygonsLayer(polygonsData: PolygonData_api[], id: string, hexColor: string): GeoJsonLayer { - const features: Record[] = polygonsData.map((polygon) => { - return surfacePolygonsToGeojson(polygon); - }); - const data: Record = { - type: "FeatureCollection", - unit: "m", - features: features, - }; - const rgbColor = parse(hexColor) as Rgb; - let rgbArr: [number, number, number] | undefined; - if (rgbColor && "r" in rgbColor && "g" in rgbColor && "b" in rgbColor) { - rgbArr = [rgbColor.r * 255, rgbColor.g * 255, rgbColor.b * 255]; + for (const item of items) { + if (!item.getItemDelegate().isVisible()) { + continue; + } + + if (instanceofLayer(item)) { + if (item.getLayerDelegate().getStatus() !== LayerStatus.SUCCESS) { + continue; + } + + const layer = makeLayer(item); + if (!layer) { + continue; + } + + globalLayers.push(layer); + } + if (instanceofGroup(item)) { + if (item instanceof ViewGroup) { + groupMeta.set(item.getItemDelegate().getId(), { + name: item.getItemDelegate().getName(), + color: item.getGroupDelegate().getColor(), + }); + + const children = recursivelyExtractLayers(item.getGroupDelegate().getChildren()); + groupLayersMap.set(item.getItemDelegate().getId(), children); + } + } } - return new GeoJsonLayer({ - id: id, - data: data, - opacity: 1, - getLineWidth: 40, - getLineColor: rgbArr, - filled: false, - parameters: { - depthTest: false, - }, - depthTest: false, - pickable: true, - }); -} -function surfacePolygonsToGeojson(surfacePolygon: PolygonData_api): Record { - const data: Record = { - type: "Feature", - geometry: { - type: "Polygon", - coordinates: [zipCoords(surfacePolygon.x_arr, surfacePolygon.y_arr, surfacePolygon.z_arr)], - }, - properties: { name: surfacePolygon.poly_id, color: [0, 0, 0, 255] }, - }; - return data; + + return { groupLayersMap, groupMeta, globalLayers }; } -function zipCoords(x_arr: number[], y_arr: number[], z_arr: number[]): number[][] { - const coords: number[][] = []; - for (let i = 0; i < x_arr.length; i++) { - coords.push([x_arr[i], y_arr[i], -z_arr[i]]); +function recursivelyExtractLayers(items: Item[]): Layer[] { + const layers: Layer[] = []; + + for (const item of items) { + if (!item.getItemDelegate().isVisible()) { + continue; + } + + if (instanceofLayer(item)) { + const layer = makeLayer(item); + if (!layer) { + continue; + } + + layers.push(layer); + } + if (instanceofGroup(item)) { + if (item instanceof ViewGroup) { + continue; + } + layers.push(...recursivelyExtractLayers(item.getGroupDelegate().getChildren())); + } } - return coords; + return layers.reverse(); } diff --git a/frontend/src/modules/LayerSpike/interfaces.ts b/frontend/src/modules/LayerSpike/interfaces.ts deleted file mode 100644 index 2c846f904..000000000 --- a/frontend/src/modules/LayerSpike/interfaces.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { InterfaceInitialization } from "@framework/UniDirectionalModuleComponentsInterface"; - -import { LayerManager } from "./layers/LayerManager"; -import { layerManagerAtom } from "./settings/atoms/baseAtoms"; - -export type SettingsToViewInterface = { - layerManager: LayerManager | null; -}; - -export type Interfaces = { - settingsToView: SettingsToViewInterface; -}; - -export const settingsToViewInterfaceInitialization: InterfaceInitialization = { - layerManager: (get) => { - return get(layerManagerAtom); - }, -}; diff --git a/frontend/src/modules/LayerSpike/loadModule.tsx b/frontend/src/modules/LayerSpike/loadModule.tsx deleted file mode 100644 index dfcfa27de..000000000 --- a/frontend/src/modules/LayerSpike/loadModule.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { ModuleRegistry } from "@framework/ModuleRegistry"; - -import { Interfaces, settingsToViewInterfaceInitialization } from "./interfaces"; -import { MODULE_NAME } from "./registerModule"; -import { Settings } from "./settings/settings"; -import { View } from "./view/view"; - -const module = ModuleRegistry.initModule(MODULE_NAME, { - settingsToViewInterfaceInitialization, -}); - -module.settingsFC = Settings; -module.viewFC = View; diff --git a/frontend/src/modules/LayerSpike/registerModule.ts b/frontend/src/modules/LayerSpike/registerModule.ts deleted file mode 100644 index 1923115e8..000000000 --- a/frontend/src/modules/LayerSpike/registerModule.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ModuleCategory, ModuleDevState } from "@framework/Module"; -import { ModuleRegistry } from "@framework/ModuleRegistry"; - -import { Interfaces } from "./interfaces"; - -export const MODULE_NAME: string = "LayerSpike"; - -ModuleRegistry.registerModule({ - moduleName: MODULE_NAME, - category: ModuleCategory.DEBUG, - devState: ModuleDevState.DEV, - defaultTitle: "Layer Spike", -}); diff --git a/frontend/src/modules/LayerSpike/settings/atoms/baseAtoms.ts b/frontend/src/modules/LayerSpike/settings/atoms/baseAtoms.ts deleted file mode 100644 index a4c394b9b..000000000 --- a/frontend/src/modules/LayerSpike/settings/atoms/baseAtoms.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { LayerManager } from "@modules/LayerSpike/layers/LayerManager"; - -import { atom } from "jotai"; - -export const userSelectedFieldIdentifierAtom = atom(null); -export const layerManagerAtom = atom(null); diff --git a/frontend/src/modules/LayerSpike/settings/atoms/derivedAtoms.ts b/frontend/src/modules/LayerSpike/settings/atoms/derivedAtoms.ts deleted file mode 100644 index 7d4115816..000000000 --- a/frontend/src/modules/LayerSpike/settings/atoms/derivedAtoms.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { EnsembleSet } from "@framework/EnsembleSet"; -import { EnsembleSetAtom } from "@framework/GlobalAtoms"; - -import { atom } from "jotai"; - -import { userSelectedFieldIdentifierAtom } from "./baseAtoms"; - -export const selectedFieldIdentifierAtom = atom((get) => { - const ensembleSet = get(EnsembleSetAtom); - const userSelectedField = get(userSelectedFieldIdentifierAtom); - - if ( - !userSelectedField || - !ensembleSet.getEnsembleArr().some((ens) => ens.getFieldIdentifier() === userSelectedField) - ) { - return ensembleSet.getEnsembleArr().at(0)?.getFieldIdentifier() ?? null; - } - - return userSelectedField; -}); - -export const filteredEnsembleSetAtom = atom((get) => { - const ensembleSet = get(EnsembleSetAtom); - const fieldIdentifier = get(userSelectedFieldIdentifierAtom); - - if (fieldIdentifier === null) { - return ensembleSet; - } - - return new EnsembleSet(ensembleSet.getEnsembleArr().filter((el) => el.getFieldIdentifier() === fieldIdentifier)); -}); diff --git a/frontend/src/modules/LayerSpike/settings/settings.tsx b/frontend/src/modules/LayerSpike/settings/settings.tsx deleted file mode 100644 index 388f39b1d..000000000 --- a/frontend/src/modules/LayerSpike/settings/settings.tsx +++ /dev/null @@ -1,259 +0,0 @@ -import React from "react"; - -import { ModuleSettingsProps } from "@framework/Module"; -import { IsMoveAllowedArgs, SortableList } from "@lib/components/SortableList"; -import { Add } from "@mui/icons-material"; -import { useQueryClient } from "@tanstack/react-query"; - -import { useSetAtom } from "jotai"; - -import { layerManagerAtom } from "./atoms/baseAtoms"; - -import { LayerManager } from "../layers/LayerManager"; -import { usePublishSubscribeTopicValue } from "../layers/PublishSubscribeHandler"; -import { SharedSetting } from "../layers/SharedSetting"; -import { View } from "../layers/View"; -import { LayersActionGroup, LayersActions } from "../layers/components/layersActions"; -import { makeComponent } from "../layers/components/utils"; -import { GroupBaseTopic } from "../layers/delegates/GroupDelegate"; -import { DrilledWellTrajectoriesLayer } from "../layers/implementations/layers/DrilledWellTrajectoriesLayer/DrilledWellTrajectoriesLayer"; -import { ObservedSurfaceLayer } from "../layers/implementations/layers/ObservedSurfaceLayer/ObservedSurfaceLayer"; -import { RealizationGridLayer } from "../layers/implementations/layers/RealizationGridLayer/RealizationGridLayer"; -import { RealizationPolygonsLayer } from "../layers/implementations/layers/RealizationPolygonsLayer/RealizationPolygonsLayer"; -import { RealizationSurfaceLayer } from "../layers/implementations/layers/RealizationSurfaceLayer/RealizationSurfaceLayer"; -import { StatisticalSurfaceLayer } from "../layers/implementations/layers/StatisticalSurfaceLayer/StatisticalSurfaceLayer"; -import { Ensemble } from "../layers/implementations/settings/Ensemble"; -import { Realization } from "../layers/implementations/settings/Realization"; -import { SurfaceName } from "../layers/implementations/settings/SurfaceName"; -import { Group, Item, instanceofGroup } from "../layers/interfaces"; - -export function Settings(props: ModuleSettingsProps): React.ReactNode { - const queryClient = useQueryClient(); - const layerManager = React.useRef( - new LayerManager(props.workbenchSession, props.workbenchSettings, queryClient) - ); - - const colorSet = props.workbenchSettings.useColorSet(); - - const groupDelegate = layerManager.current.getGroupDelegate(); - const items = usePublishSubscribeTopicValue(groupDelegate, GroupBaseTopic.CHILDREN); - - const setLayerManager = useSetAtom(layerManagerAtom); - - React.useEffect( - function onMountEffect() { - setLayerManager(layerManager.current); - }, - [setLayerManager] - ); - - function handleLayerAction(identifier: string, group?: Group) { - let groupDelegate = layerManager.current.getGroupDelegate(); - if (group) { - groupDelegate = group.getGroupDelegate(); - } - - switch (identifier) { - case "view": - groupDelegate.appendChild(new View("New View", colorSet.getNextColor())); - return; - case "observed_surface": - groupDelegate.appendChild(new ObservedSurfaceLayer()); - return; - case "statistical_surface": - groupDelegate.appendChild(new StatisticalSurfaceLayer()); - return; - case "realization_surface": - groupDelegate.appendChild(new RealizationSurfaceLayer()); - return; - case "realization_polygons": - groupDelegate.appendChild(new RealizationPolygonsLayer()); - return; - case "drilled_wellbores": - groupDelegate.appendChild(new DrilledWellTrajectoriesLayer()); - return; - case "realization_grid": - groupDelegate.appendChild(new RealizationGridLayer()); - return; - case "ensemble": - groupDelegate.prependChild(new SharedSetting(new Ensemble())); - return; - case "realization": - groupDelegate.prependChild(new SharedSetting(new Realization())); - return; - case "surface_name": - groupDelegate.prependChild(new SharedSetting(new SurfaceName())); - return; - } - } - - function checkIfItemMoveAllowed(args: IsMoveAllowedArgs): boolean { - const movedItem = groupDelegate.findDescendantById(args.movedItemId); - if (!movedItem) { - return false; - } - - const destinationItem = args.destinationId - ? groupDelegate.findDescendantById(args.destinationId) - : layerManager.current; - - if (!destinationItem || !instanceofGroup(destinationItem)) { - return false; - } - - const numSharedSettings = - destinationItem.getGroupDelegate().findChildren((item) => { - return item instanceof SharedSetting; - }).length ?? 0; - - if (!(movedItem instanceof SharedSetting)) { - if (args.position < numSharedSettings) { - return false; - } - } else { - if (args.originId === args.destinationId) { - if (args.position >= numSharedSettings) { - return false; - } - } else { - if (args.position > numSharedSettings) { - return false; - } - } - } - - return true; - } - - function handleItemMoved( - movedItemId: string, - originId: string | null, - destinationId: string | null, - position: number - ) { - const movedItem = groupDelegate.findDescendantById(movedItemId); - if (!movedItem) { - return; - } - - let origin = layerManager.current.getGroupDelegate(); - if (originId) { - const candidate = groupDelegate.findDescendantById(originId); - if (candidate && instanceofGroup(candidate)) { - origin = candidate.getGroupDelegate(); - } - } - - let destination = layerManager.current.getGroupDelegate(); - if (destinationId) { - const candidate = groupDelegate.findDescendantById(destinationId); - if (candidate && instanceofGroup(candidate)) { - destination = candidate.getGroupDelegate(); - } - } - - if (origin === destination) { - origin.moveChild(movedItem, position); - return; - } - - origin.removeChild(movedItem); - destination.insertChild(movedItem, position); - } - - return ( -
-
-
-
-
Layers
- -
-
- - Click on to add a layer. -
- } - > - {items.map((item: Item) => makeComponent(item, VIEW_ACTIONS, handleLayerAction))} - -
-
-
-
- ); -} - -const LAYER_ACTIONS: LayersActionGroup[] = [ - { - label: "View", - children: [ - { - identifier: "view", - label: "Add View", - }, - ], - }, - { - label: "Layers", - children: [ - { - label: "Surfaces", - children: [ - { - identifier: "observed_surface", - label: "Observed Surface", - }, - { - identifier: "statistical_surface", - label: "Statistical Surface", - }, - { - identifier: "realization_surface", - label: "Realization Surface", - }, - ], - }, - { - label: "Others", - children: [ - { - identifier: "realization_polygons", - label: "Realization Polygons", - }, - { - identifier: "drilled_wellbores", - label: "Drilled Wellbore Trajectories", - }, - { - identifier: "realization_grid", - label: "Realization Grid", - }, - ], - }, - ], - }, - { - label: "Shared Settings", - children: [ - { - identifier: "ensemble", - label: "Ensemble", - }, - { - identifier: "realization", - label: "Realization", - }, - { - identifier: "surface_name", - label: "Surface Name", - }, - ], - }, -]; - -const VIEW_ACTIONS: LayersActionGroup[] = LAYER_ACTIONS.filter((group) => group.label !== "View"); diff --git a/frontend/src/modules/LayerSpike/view/view.tsx b/frontend/src/modules/LayerSpike/view/view.tsx deleted file mode 100644 index 6640c645f..000000000 --- a/frontend/src/modules/LayerSpike/view/view.tsx +++ /dev/null @@ -1,176 +0,0 @@ -import React from "react"; - -import { View as DeckGlView, Layer } from "@deck.gl/core/typed"; -import { ModuleViewProps } from "@framework/Module"; -import { useQueryClient } from "@tanstack/react-query"; -import { ViewportType } from "@webviz/subsurface-viewer"; -import SubsurfaceViewer, { ViewsType } from "@webviz/subsurface-viewer/dist/SubsurfaceViewer"; -import { Axes2DLayer } from "@webviz/subsurface-viewer/dist/layers"; - -import { makeLayer } from "./layerFactory"; - -import { Interfaces } from "../interfaces"; -import { LayerManager, LayerManagerTopic } from "../layers/LayerManager"; -import { usePublishSubscribeTopicValue } from "../layers/PublishSubscribeHandler"; -import { View as ViewGroup } from "../layers/View"; -import { GroupBaseTopic, GroupDelegate } from "../layers/delegates/GroupDelegate"; -import { Item, LayerStatus, instanceofGroup, instanceofLayer } from "../layers/interfaces"; - -export function View(props: ModuleViewProps): React.ReactNode { - const queryClient = useQueryClient(); - const layerManager = props.viewContext.useSettingsToViewInterfaceValue("layerManager"); - const items: Item[] = usePublishSubscribeTopicValue( - layerManager?.getGroupDelegate() || new GroupDelegate(null), - GroupBaseTopic.CHILDREN - ); - - usePublishSubscribeTopicValue( - layerManager ?? new LayerManager(props.workbenchSession, props.workbenchSettings, queryClient), - LayerManagerTopic.LAYER_DATA_REVISION - ); - - const results = extractGroupsAndLayers(items); - - const numCols = Math.ceil(Math.sqrt(results.groupLayersMap.size)); - const numRows = Math.ceil(results.groupLayersMap.size / numCols); - - const viewports: ViewportType[] = []; - const viewerLayers: Layer[] = []; - const viewportAnnotations: React.ReactNode[] = []; - - const views: ViewsType = { - layout: [numRows, numCols], - viewports: viewports, - showLabel: true, - }; - - for (const [group, layers] of results.groupLayersMap) { - viewports.push({ - id: group, - name: results.groupMeta.get(group)?.name ?? group, - isSync: true, - layerIds: [ - ...layers.map((layer) => (layer as unknown as Layer).id), - ...results.globalLayers.map((layer) => layer.id), - "axes", - ], - }); - viewerLayers.push(...layers); - viewportAnnotations.push( - // eslint-disable-next-line @typescript-eslint/ban-ts-comment - /* @ts-expect-error */ - -
-
-
{results.groupMeta.get(group)?.name ?? group}
-
- - ); - } - viewerLayers.push(...results.globalLayers.toReversed()); - viewerLayers.push( - new Axes2DLayer({ - id: "axes", - axisColor: [80, 80, 80], - backgroundColor: [250, 250, 250], - }) - ); - - return ( -
- - {viewportAnnotations} - -
- ); -} - -export type GroupMeta = { - name: string; - color: string | null; -}; - -function extractGroupsAndLayers(items: Item[]): { - groupLayersMap: Map; - groupMeta: Map; - globalLayers: Layer[]; -} { - const groupLayersMap: Map = new Map(); - const groupMeta: Map = new Map(); - const globalLayers: Layer[] = []; - - for (const item of items) { - if (!item.getItemDelegate().isVisible()) { - continue; - } - - if (instanceofLayer(item)) { - if (item.getLayerDelegate().getStatus() !== LayerStatus.SUCCESS) { - continue; - } - - const layer = makeLayer(item); - if (!layer) { - continue; - } - - globalLayers.push(layer); - } - if (instanceofGroup(item)) { - if (item instanceof ViewGroup) { - groupMeta.set(item.getItemDelegate().getId(), { - name: item.getItemDelegate().getName(), - color: item.getGroupDelegate().getColor(), - }); - - const children = recursivelyExtractLayers(item.getGroupDelegate().getChildren()); - groupLayersMap.set(item.getItemDelegate().getId(), children); - } - } - } - - return { groupLayersMap, groupMeta, globalLayers }; -} - -function recursivelyExtractLayers(items: Item[]): Layer[] { - const layers: Layer[] = []; - - for (const item of items) { - if (!item.getItemDelegate().isVisible()) { - continue; - } - - if (instanceofLayer(item)) { - const layer = makeLayer(item); - if (!layer) { - continue; - } - - layers.push(layer); - } - if (instanceofGroup(item)) { - if (item instanceof ViewGroup) { - continue; - } - layers.push(...recursivelyExtractLayers(item.getGroupDelegate().getChildren())); - } - } - - return layers.reverse(); -} diff --git a/frontend/src/modules/registerAllModules.ts b/frontend/src/modules/registerAllModules.ts index ec450f509..cab88b9c0 100644 --- a/frontend/src/modules/registerAllModules.ts +++ b/frontend/src/modules/registerAllModules.ts @@ -15,13 +15,11 @@ import "./SimulationTimeSeries/registerModule"; import "./SimulationTimeSeriesSensitivity/registerModule"; import "./SubsurfaceMap/registerModule"; import "./TornadoChart/registerModule"; -import "./WellCompletions/registerModule"; import "./Vfp/registerModule"; - +import "./WellCompletions/registerModule"; if (isDevMode()) { await import("./MyModule/registerModule"); await import("./MyModule2/registerModule"); await import("./DbgWorkbenchSpy/registerModule"); - await import("./LayerSpike/registerModule"); }