Skip to content

Commit fe0d1f8

Browse files
authored
feat: unify exposed types naming to colormap (#2584)
Both colormap and colorMap naming scheme are present, bringing some confusion. Moving to single notation: colormap. Exposed part: exported API types Rename: - exposed types Old types are exported as deprecated Occurrence count, after and before the PR | | colormap | colorMap | |--|--|--| |Published Code (a)| 618 results in 40 files<br>~547~ results in ~38~ files | 143 results in 28 files<br>~209~ results in ~33~ files | |Full Code (b)| 767 results in 60 files<br>~674~ results in ~57~ files | 267 results in 49 files<br>~355~ results in ~54~ files | |Overall (c)| 783 results in 66 files<br>~692~ results in ~64~ files | 293 results in 58 files<br>~381~ results in ~63~ files | PR for #2581
1 parent d9e3ff4 commit fe0d1f8

32 files changed

+94
-90
lines changed

typescript/packages/subsurface-viewer/src/components/ColorLegend.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import {
1010
} from "@emerson-eps/color-tables";
1111

1212
import type { ExtendedLegendLayer } from "../layers/utils/layerTools";
13-
import type { ColorMapFunctionType } from "../layers/utils/colormapTools";
13+
import type { ColormapFunctionType } from "../layers/utils/colormapTools";
1414

1515
interface LegendBaseData {
1616
title: string;
1717
colorName: string;
1818
discrete: boolean;
19-
colorMapFunction?: ColorMapFunctionType;
19+
colorMapFunction?: ColormapFunctionType;
2020
}
2121
export interface DiscreteLegendDataType extends LegendBaseData {
2222
metadata: Record<string, [Color, number]>;

typescript/packages/subsurface-viewer/src/layers/colormap/colormapLayer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type {
1515
} from "../utils/layerTools";
1616
import { type DeckGLLayerContext, getModelMatrix } from "../utils/layerTools";
1717
import {
18-
type ColorMapFunctionType,
18+
type ColormapFunctionType,
1919
getImageData,
2020
} from "../utils/colormapTools";
2121
import { decodeRGB, type ValueDecoder } from "../utils/propertyMapTools";
@@ -49,7 +49,7 @@ export interface ColormapLayerProps
4949
// Optional function property.
5050
// If defined this function will override the color map.
5151
// Takes a value in the range [0,1] and returns a color.
52-
colorMapFunction?: ColorMapFunctionType;
52+
colorMapFunction?: ColormapFunctionType;
5353

5454
// Min and max property values.
5555
valueRange: [number, number];

typescript/packages/subsurface-viewer/src/layers/grid3d/grid3dLayer.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type {
1515
ExtendedLayerProps,
1616
ReportBoundingBoxAction,
1717
} from "../utils/layerTools";
18-
import type { ColorMapFunctionType } from "../utils/colormapTools";
18+
import type { ColormapFunctionType } from "../utils/colormapTools";
1919

2020
import config from "../../SubsurfaceConfig.json";
2121
import { findConfig } from "../../utils/configTools";
@@ -232,7 +232,7 @@ export interface Grid3DLayerProps extends ExtendedLayerProps {
232232
* E.g. [255, 0, 0] for constant red cells.
233233
* Can be defined as Uint8Array containing [R, G, B] triplets in [0, 255] range each.
234234
*/
235-
colorMapFunction?: ColorMapFunctionType | Uint8Array;
235+
colorMapFunction?: ColormapFunctionType | Uint8Array;
236236

237237
/**
238238
* Value in propertiesData indicating that the property is undefined.
@@ -473,7 +473,7 @@ export default class Grid3DLayer extends CompositeLayer<Grid3DLayerProps> {
473473
}
474474

475475
private isColormapFunctionConstantColor(
476-
colorFunc: Uint8Array | ColorMapFunctionType | undefined
476+
colorFunc: Uint8Array | ColormapFunctionType | undefined
477477
): colorFunc is Uint8Array {
478478
return (
479479
(Array.isArray(colorFunc) || colorFunc instanceof Uint8Array) &&

typescript/packages/subsurface-viewer/src/layers/grid3d/privateGrid3dLayer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import type {
2323
} from "../utils/layerTools";
2424
import { createPropertyData } from "../utils/layerTools";
2525
import {
26-
type ColorMapFunctionType,
26+
type ColormapFunctionType,
2727
createColormapTexture,
2828
} from "../utils/colormapTools";
2929
import linearFragmentShader from "./nodeProperty.fs.glsl";
@@ -51,7 +51,7 @@ export interface PrivateLayerProps extends ExtendedLayerProps {
5151
colormapClampColor: Color | undefined | boolean;
5252
undefinedPropertyValue: number;
5353
undefinedPropertyColor: [number, number, number];
54-
colormapFunction?: ColorMapFunctionType;
54+
colormapFunction?: ColormapFunctionType;
5555
coloringMode: TGrid3DColoringMode.Property;
5656
gridLines: boolean;
5757
propertyValueRange: [number, number];

typescript/packages/subsurface-viewer/src/layers/map/mapLayer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import type {
1616
ExtendedLayerProps,
1717
} from "../utils/layerTools";
1818
import { getModelMatrix } from "../utils/layerTools";
19-
import type { ColorMapFunctionType } from "../utils/colormapTools";
19+
import type { ColormapFunctionType } from "../utils/colormapTools";
2020
import config from "../../SubsurfaceConfig.json";
2121
import { findConfig } from "../../utils/configTools";
2222
import { loadFloat32Data } from "../../utils/serialize";
@@ -175,7 +175,7 @@ export interface MapLayerProps extends ExtendedLayerProps {
175175
* May also be set as constant color:
176176
* E.g. [255, 0, 0] for constant red surface.
177177
*/
178-
colorMapFunction?: ColorMapFunctionType;
178+
colorMapFunction?: ColormapFunctionType;
179179

180180
/** Surface material properties.
181181
* material: true = default material, coloring depends on surface orientation and lighting.

typescript/packages/subsurface-viewer/src/layers/map/privateMapLayer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import type {
2424
} from "../utils/layerTools";
2525
import { createPropertyData } from "../utils/layerTools";
2626
import {
27-
type ColorMapFunctionType,
27+
type ColormapFunctionType,
2828
getImageData,
2929
} from "../utils/colormapTools";
3030

@@ -46,7 +46,7 @@ export interface PrivateMapLayerProps extends ExtendedLayerProps {
4646
colormapName: string;
4747
colormapRange: [number, number];
4848
colormapClampColor: Color | undefined | boolean;
49-
colormapFunction?: ColorMapFunctionType;
49+
colormapFunction?: ColormapFunctionType;
5050
propertyValueRange: [number, number];
5151
smoothShading: boolean;
5252
depthTest: boolean;

typescript/packages/subsurface-viewer/src/layers/utils/colormapTools.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ import { createDefaultContinuousColorScale } from "@emerson-eps/color-tables/dis
1212
import type { DeckGLLayerContext } from "./layerTools";
1313

1414
/** Type of functions returning a color from a value in the [0,1] range. */
15-
export type ColorMapFunctionType = ReturnType<typeof createColormapFunction>;
16-
/** @deprecated Use ColorMapFunctionType instead. */
17-
export type colorMapFunctionType = ColorMapFunctionType;
15+
export type ColormapFunctionType = ReturnType<typeof createColormapFunction>;
16+
/** @deprecated Use ColormapFunctionType instead. */
17+
export type colorMapFunctionType = ColormapFunctionType;
18+
/** @deprecated Use ColormapFunctionType instead. */
19+
export type ColorMapFunctionType = ColormapFunctionType;
1820

1921
export interface IColormapHints {
2022
discreteData: boolean;
@@ -40,16 +42,16 @@ export interface ColorTableDef extends ColorTableProps {
4042
colorTables: colorTablesArray;
4143
}
4244

43-
export type ColormapProps = ColorMapFunctionType | Uint8Array | ColorTableProps;
45+
export type ColormapProps = ColormapFunctionType | Uint8Array | ColorTableProps;
4446

4547
/**
4648
* Represents the possible types that can be used as colormap properties.
4749
*
48-
* - `ColorMapFunctionType`: A function converting a value to a color.
50+
* - `ColormapFunctionType`: A function converting a value to a color.
4951
* - `Uint8Array`: A typed array containing color data.
5052
* - `ColorTableDef`: An object representing a color table.
5153
*/
52-
export type TColormapDef = ColorMapFunctionType | Uint8Array | ColorTableDef;
54+
export type TColormapDef = ColormapFunctionType | Uint8Array | ColorTableDef;
5355

5456
/**
5557
* Creates an array of colors as RGB triplets in range [0, 1] using the colormap definition.
@@ -66,7 +68,7 @@ export function getImageData(
6668
type funcType = (x: number) => Color;
6769

6870
if (colormapDef instanceof Uint8Array) {
69-
// If colorMapProps is a Uint8Array, return it directly
71+
// If colormapProps is a Uint8Array, return it directly
7072
return colormapDef;
7173
}
7274

typescript/packages/subsurface-viewer/src/layers/wells/wellsLayer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ import {
3232
getLayersById,
3333
isDrawingEnabled,
3434
} from "../utils/layerTools";
35-
import type { ColorMapFunctionType } from "../utils/colormapTools";
35+
import type { ColormapFunctionType } from "../utils/colormapTools";
3636

3737
import type {
3838
ContinuousLegendDataType,
@@ -110,7 +110,7 @@ export interface WellsLayerProps extends ExtendedLayerProps {
110110
*/
111111
refine: boolean | number;
112112
wellHeadStyle: WellHeadStyleAccessor;
113-
colorMappingFunction: ColorMapFunctionType;
113+
colorMappingFunction: ColormapFunctionType;
114114
lineStyle: LineStyleAccessor;
115115

116116
/**

typescript/packages/subsurface-viewer/src/storybook/layers/MapLayer.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { ViewFooter } from "../../components/ViewFooter";
1515
import AxesLayer from "../../layers/axes/axesLayer";
1616
import MapLayer from "../../layers/map/mapLayer";
1717
import NorthArrow3DLayer from "../../layers/northarrow/northArrow3DLayer";
18-
import type { ColorMapFunctionType } from "../../layers/utils/colormapTools";
18+
import type { ColormapFunctionType } from "../../layers/utils/colormapTools";
1919

2020
import {
2121
default2DViews,
@@ -501,7 +501,7 @@ const TypedArrayInputComponent: React.FC<{
501501
material: true,
502502
ZIncreasingDownwards: false,
503503
contours: [0, 5],
504-
colorMapFunction: nearestColormap as ColorMapFunctionType,
504+
colorMapFunction: nearestColormap as ColormapFunctionType,
505505
},
506506
{
507507
"@@type": "AxesLayer",

typescript/packages/well-log-viewer/src/Storybook/examples/MapAndWellLogViewer.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,16 @@ import wellLogsJson from "../../../../../../example-data/volve_logs.json";
3434
import templateJson from "../../../../../../example-data/welllog_template_2.json";
3535
import colorTables from "../../../../../../example-data/wellpick_colors.json";
3636
import wellPicks from "../../../../../../example-data/wellpicks.json";
37-
import type { ColorMapFunction } from "../../utils/color-function";
37+
import type { ColormapFunction } from "../../utils/color-function";
3838
import { indexOfElementByName, isEqualRanges } from "../../utils/arrays";
3939
import { getDiscreteMeta } from "../../utils/well-log";
4040

4141
const wellLogs = wellLogsJson as unknown as WellLogSet[];
4242
const template = templateJson as unknown as Template;
4343

44-
const exampleColormapFunctions: ColorMapFunction[] = [
44+
const exampleColormapFunctions: ColormapFunction[] = [
4545
// copy color tables and add some color functions
46-
...(colorTables as ColorMapFunction[]),
46+
...(colorTables as ColormapFunction[]),
4747
{
4848
name: "Grey scale",
4949
func: (v: number) => [v * 255, v * 255, v * 255],

0 commit comments

Comments
 (0)