Skip to content

Commit

Permalink
Added preview images and fixed bug in tables module
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenthoms committed Aug 1, 2024
1 parent b3061c5 commit 239be80
Show file tree
Hide file tree
Showing 9 changed files with 253 additions and 60 deletions.
135 changes: 135 additions & 0 deletions frontend/src/modules/InplaceVolumetricsPlot/preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions frontend/src/modules/InplaceVolumetricsPlot/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { DrawPreviewFunc } from "@framework/Preview";

import previewImg from "./preview.svg";

export const preview: DrawPreviewFunc = function (width: number, height: number) {
return <img src={previewImg} style={{ width, height }} />;
};
2 changes: 2 additions & 0 deletions frontend/src/modules/InplaceVolumetricsPlot/registerModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ModuleRegistry } from "@framework/ModuleRegistry";
import { SyncSettingKey } from "@framework/SyncSettings";

import { channelDefs } from "./channelDefs";
import { preview } from "./preview";
import { SettingsToViewInterface } from "./settingsToViewInterface";

export const MODULE_NAME = "InplaceVolumetricsPlot";
Expand All @@ -16,4 +17,5 @@ ModuleRegistry.registerModule<Record<string, any>, SettingsToViewInterface>({
description,
syncableSettingKeys: [SyncSettingKey.INPLACE_VOLUMETRICS_FILTER],
channelDefinitions: channelDefs,
preview,
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InplaceVolumetricResultName_api } from "@api";
import { InterfaceInitialization } from "@framework/UniDirectionalSettingsToViewInterface";
import { InterfaceInitialization } from "@framework/UniDirectionalModuleComponentsInterface";
import { InplaceVolumetricsFilter } from "@framework/types/inplaceVolumetricsFilter";
import { SourceAndTableIdentifierUnion } from "@modules/_shared/InplaceVolumetrics/types";

Expand All @@ -17,30 +17,26 @@ import {
import { PlotType } from "./typesAndEnums";

export type SettingsToViewInterface = {
derivedStates: {
filter: InplaceVolumetricsFilter;
resultName: InplaceVolumetricResultName_api | null;
resultName2: InplaceVolumetricResultName_api | null;
subplotBy: SourceAndTableIdentifierUnion;
colorBy: SourceAndTableIdentifierUnion;
plotType: PlotType;
};
filter: InplaceVolumetricsFilter;
resultName: InplaceVolumetricResultName_api | null;
resultName2: InplaceVolumetricResultName_api | null;
subplotBy: SourceAndTableIdentifierUnion;
colorBy: SourceAndTableIdentifierUnion;
plotType: PlotType;
};

export const interfaceInitialization: InterfaceInitialization<SettingsToViewInterface> = {
derivedStates: {
filter: (get) => {
return {
ensembleIdents: get(selectedEnsembleIdentsAtom),
tableNames: get(selectedTableNamesAtom),
fluidZones: get(selectedFluidZonesAtom),
identifiersValues: get(selectedIdentifiersValuesAtom),
};
},
resultName: (get) => get(selectedResultNameAtom),
resultName2: (get) => get(selectedResultName2Atom),
subplotBy: (get) => get(selectedSubplotByAtom),
colorBy: (get) => get(selectedColorByAtom),
plotType: (get) => get(userSelectedPlotTypeAtom),
filter: (get) => {
return {
ensembleIdents: get(selectedEnsembleIdentsAtom),
tableNames: get(selectedTableNamesAtom),
fluidZones: get(selectedFluidZonesAtom),
identifiersValues: get(selectedIdentifiersValuesAtom),
};
},
resultName: (get) => get(selectedResultNameAtom),
resultName2: (get) => get(selectedResultName2Atom),
subplotBy: (get) => get(selectedSubplotByAtom),
colorBy: (get) => get(selectedColorByAtom),
plotType: (get) => get(userSelectedPlotTypeAtom),
};
47 changes: 47 additions & 0 deletions frontend/src/modules/InplaceVolumetricsTable/preview.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions frontend/src/modules/InplaceVolumetricsTable/preview.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { DrawPreviewFunc } from "@framework/Preview";

import previewImg from "./preview.svg";

export const preview: DrawPreviewFunc = function (width: number, height: number) {
return <img src={previewImg} style={{ width, height }} />;
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ModuleCategory, ModuleDevState } from "@framework/Module";
import { ModuleRegistry } from "@framework/ModuleRegistry";
import { SyncSettingKey } from "@framework/SyncSettings";

import { preview } from "./preview";
import { SettingsToViewInterface } from "./settingsToViewInterface";

export const MODULE_NAME = "InplaceVolumetricsTable";
Expand All @@ -14,4 +15,5 @@ ModuleRegistry.registerModule<Record<string, any>, SettingsToViewInterface>({
devState: ModuleDevState.DEV,
description,
syncableSettingKeys: [SyncSettingKey.INPLACE_VOLUMETRICS_FILTER],
preview,
});
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InplaceVolumetricResultName_api } from "@api";
import { InterfaceInitialization } from "@framework/UniDirectionalSettingsToViewInterface";
import { InterfaceInitialization } from "@framework/UniDirectionalModuleComponentsInterface";
import { InplaceVolumetricsFilter } from "@framework/types/inplaceVolumetricsFilter";
import { SourceAndTableIdentifierUnion, SourceIdentifier } from "@modules/_shared/InplaceVolumetrics/types";

Expand All @@ -14,29 +14,22 @@ import {
} from "./settings/atoms/derivedAtoms";

export type SettingsToViewInterface = {
derivedStates: {
filter: InplaceVolumetricsFilter;
resultNames: InplaceVolumetricResultName_api[];
accumulationOptions: Omit<
SourceAndTableIdentifierUnion,
SourceIdentifier.ENSEMBLE | SourceIdentifier.TABLE_NAME
>[];
calcMeanAcrossAllRealizations: boolean;
};
filter: InplaceVolumetricsFilter;
resultNames: InplaceVolumetricResultName_api[];
accumulationOptions: Omit<SourceAndTableIdentifierUnion, SourceIdentifier.ENSEMBLE | SourceIdentifier.TABLE_NAME>[];
calcMeanAcrossAllRealizations: boolean;
};

export const interfaceInitialization: InterfaceInitialization<SettingsToViewInterface> = {
derivedStates: {
filter: (get) => {
return {
ensembleIdents: get(selectedEnsembleIdentsAtom),
tableNames: get(selectedTableNamesAtom),
fluidZones: get(selectedFluidZonesAtom),
identifiersValues: get(selectedIdentifiersValuesAtom),
};
},
resultNames: (get) => get(selectedResultNamesAtom),
accumulationOptions: (get) => get(selectedAccumulationOptionsAtom),
calcMeanAcrossAllRealizations: (get) => get(calcMeanAcrossAllRealizationsAtom),
filter: (get) => {
return {
ensembleIdents: get(selectedEnsembleIdentsAtom),
tableNames: get(selectedTableNamesAtom),
fluidZones: get(selectedFluidZonesAtom),
identifiersValues: get(selectedIdentifiersValuesAtom),
};
},
resultNames: (get) => get(selectedResultNamesAtom),
accumulationOptions: (get) => get(selectedAccumulationOptionsAtom),
calcMeanAcrossAllRealizations: (get) => get(calcMeanAcrossAllRealizationsAtom),
};
34 changes: 19 additions & 15 deletions frontend/src/modules/_shared/InplaceVolumetrics/tableUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,33 +46,37 @@ export function makeTableFromApiData(data: InplaceVolumetricsTableData[]): Table
mainColumnsAdded = true;
}

let numAddedRows = 0;
for (const resultColumn of fluidZoneTable.resultColumns) {
for (const value of resultColumn.columnValues) {
columns.get(resultColumn.columnName)?.addRowValue(value);

if (!mainColumnsAdded) {
numAddedRows++;
columns.get("ensemble")?.addRowValue(tableSet.ensembleIdent);
columns.get("table")?.addRowValue(tableSet.tableName);
columns.get("fluid-zone")?.addRowValue(fluidZoneTable.fluidSelectionName);
}
}
mainColumnsAdded = true;
}
const untouchedColumns = Array.from(columns.values()).filter(
(column) =>
!fluidZoneTable.selectorColumns.some(
(selectorColumn) => selectorColumn.columnName === column.getName()
) &&
!fluidZoneTable.resultColumns.some(
(resultColumn) => resultColumn.columnName === column.getName()
) &&
column.getType() !== ColumnType.ENSEMBLE &&
column.getType() !== ColumnType.TABLE &&
column.getType() !== ColumnType.FLUID_ZONE
);
for (const column of untouchedColumns) {
for (let i = 0; i < fluidZoneTable.selectorColumns[0].indices.length; i++) {
column.addRowValue(null);
if (numAddedRows > 0) {
const untouchedColumns = Array.from(columns.values()).filter(
(column) =>
!fluidZoneTable.selectorColumns.some(
(selectorColumn) => selectorColumn.columnName === column.getName()
) &&
!fluidZoneTable.resultColumns.some(
(resultColumn) => resultColumn.columnName === column.getName()
) &&
column.getType() !== ColumnType.ENSEMBLE &&
column.getType() !== ColumnType.TABLE &&
column.getType() !== ColumnType.FLUID_ZONE
);
for (const column of untouchedColumns) {
for (let i = 0; i < numAddedRows; i++) {
column.addRowValue(null);
}
}
}
}
Expand Down

0 comments on commit 239be80

Please sign in to comment.