@webviz/well-log-viewer 0.0.1-alpha.1 → 0.0.1-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SyncLogViewer.js +3 -4
- package/dist/SyncLogViewer.js.map +1 -1
- package/dist/components/WellLogView.js +5 -5
- package/dist/components/WellLogView.js.map +1 -1
- package/dist/demo/example-data/welllog_template_2.json +167 -167
- package/dist/demo/example-data/wellpick_colors.json +1 -1
- package/dist/demo/example-data/wellpicks.json +179 -179
- package/package.json +32 -5
- package/dist/Intro.stories.mdx +0 -59
- package/dist/package.json +0 -21
- package/src/Intro.stories.mdx +0 -59
- package/src/MapAndWellLogViewer.stories.jsx +0 -147
- package/src/MapAndWellLogViewer.test.tsx +0 -26
- package/src/MapAndWellLogViewer.tsx +0 -473
- package/src/SyncLogViewer.stories.jsx +0 -361
- package/src/SyncLogViewer.test.tsx +0 -41
- package/src/SyncLogViewer.tsx +0 -1188
- package/src/WellLogViewer.png +0 -0
- package/src/WellLogViewer.stories.jsx +0 -169
- package/src/WellLogViewer.test.tsx +0 -53
- package/src/WellLogViewer.tsx +0 -439
- package/src/WellLogViewer_performance.test.tsx +0 -78
- package/src/__snapshots__/MapAndWellLogViewer.test.tsx.snap +0 -365
- package/src/__snapshots__/SyncLogViewer.test.tsx.snap +0 -510
- package/src/__snapshots__/WellLogViewer.test.tsx.snap +0 -552
- package/src/components/AxisSelector.test.tsx +0 -50
- package/src/components/AxisSelector.tsx +0 -49
- package/src/components/ColorTableTypes.ts +0 -9
- package/src/components/InfoPanel.test.tsx +0 -58
- package/src/components/InfoPanel.tsx +0 -144
- package/src/components/InfoTypes.ts +0 -17
- package/src/components/LocalMenus.tsx +0 -336
- package/src/components/PlotDialog.tsx +0 -419
- package/src/components/Scroller.stories.jsx +0 -80
- package/src/components/Scroller.test.tsx +0 -22
- package/src/components/Scroller.tsx +0 -173
- package/src/components/TrackDialog.tsx +0 -217
- package/src/components/WellLogSpacer.tsx +0 -483
- package/src/components/WellLogTemplateTypes.ts +0 -65
- package/src/components/WellLogTypes.ts +0 -53
- package/src/components/WellLogView.stories.jsx +0 -84
- package/src/components/WellLogView.test.tsx +0 -52
- package/src/components/WellLogView.tsx +0 -2063
- package/src/components/WellLogViewWithScroller.stories.jsx +0 -69
- package/src/components/WellLogViewWithScroller.test.tsx +0 -47
- package/src/components/WellLogViewWithScroller.tsx +0 -179
- package/src/components/ZoomSlider.stories.jsx +0 -52
- package/src/components/ZoomSlider.test.tsx +0 -28
- package/src/components/ZoomSlider.tsx +0 -86
- package/src/components/__snapshots__/AxisSelector.test.tsx.snap +0 -28
- package/src/components/__snapshots__/InfoPanel.test.tsx.snap +0 -103
- package/src/components/__snapshots__/Scroller.test.tsx.snap +0 -13
- package/src/components/__snapshots__/WellLogView.test.tsx.snap +0 -54
- package/src/components/__snapshots__/WellLogViewWithScroller.test.tsx.snap +0 -270
- package/src/components/__snapshots__/ZoomSlider.test.tsx.snap +0 -50
- package/src/components/styles.scss +0 -106
- package/src/custom.d.ts +0 -13
- package/src/demo/example-data/volve_logs.json +0 -689617
- package/src/demo/example-data/welllog_template_2.json +0 -196
- package/src/demo/example-data/wellpick_colors.json +0 -156
- package/src/demo/example-data/wellpicks.json +0 -186
- package/src/index.ts +0 -8
- package/src/utils/axes.ts +0 -26
- package/src/utils/color-table.ts +0 -153
- package/src/utils/deepcopy.ts +0 -3
- package/src/utils/edit-track.tsx +0 -40
- package/src/utils/fill-info.ts +0 -224
- package/src/utils/gradientfill-plot-legend.ts +0 -177
- package/src/utils/gradientfill-plot.ts +0 -203
- package/src/utils/graph/factory.ts +0 -15
- package/src/utils/legend/common.ts +0 -153
- package/src/utils/log-viewer.ts +0 -209
- package/src/utils/minmax.ts +0 -126
- package/src/utils/pattern.tsx +0 -50
- package/src/utils/stack/stack-legend.ts +0 -100
- package/src/utils/tracks.ts +0 -1559
- package/tsconfig.json +0 -8
package/src/utils/tracks.ts
DELETED
|
@@ -1,1559 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Track,
|
|
3
|
-
ScaleTrack,
|
|
4
|
-
DualScaleTrack,
|
|
5
|
-
GraphTrack,
|
|
6
|
-
StackedTrack,
|
|
7
|
-
} from "@equinor/videx-wellog";
|
|
8
|
-
|
|
9
|
-
import { TrackOptions } from "@equinor/videx-wellog/dist/tracks/interfaces";
|
|
10
|
-
import { GraphTrackOptions } from "@equinor/videx-wellog/dist/tracks/graph/interfaces";
|
|
11
|
-
import { StackedTrackOptions } from "@equinor/videx-wellog/dist/tracks/stack/interfaces";
|
|
12
|
-
import { AreaData } from "@equinor/videx-wellog/dist/tracks/stack/interfaces";
|
|
13
|
-
|
|
14
|
-
import { LegendInfo } from "@equinor/videx-wellog/dist/plots/legend/interfaces";
|
|
15
|
-
|
|
16
|
-
import { DifferentialPlotOptions } from "@equinor/videx-wellog/dist/plots/interfaces";
|
|
17
|
-
import { GradientFillPlotOptions } from "./gradientfill-plot";
|
|
18
|
-
export interface ExtPlotOptions
|
|
19
|
-
extends GradientFillPlotOptions /*|DifferentialPlotOptions|AreaPlotOptions*/ {
|
|
20
|
-
legendInfo: () => LegendInfo;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
import WellLogView from "../components/WellLogView";
|
|
24
|
-
|
|
25
|
-
import { PlotConfig } from "@equinor/videx-wellog/dist/tracks/graph/interfaces";
|
|
26
|
-
import { PlotFactory } from "@equinor/videx-wellog/dist/tracks/graph/interfaces";
|
|
27
|
-
import { graphLegendConfig, scaleLegendConfig } from "@equinor/videx-wellog";
|
|
28
|
-
import { stackLegendConfig } from "./stack/stack-legend";
|
|
29
|
-
import { getInterpolatedColor } from "./color-table";
|
|
30
|
-
|
|
31
|
-
// missed! import { createScale } from "@equinor/videx-wellog/dist/tracks/graph/interfaces";
|
|
32
|
-
import { createScale } from "./graph/factory";
|
|
33
|
-
|
|
34
|
-
import {
|
|
35
|
-
TemplatePlotTypes,
|
|
36
|
-
TemplatePlotProps,
|
|
37
|
-
TemplateTrack,
|
|
38
|
-
TemplatePlot,
|
|
39
|
-
TemplateStyle,
|
|
40
|
-
} from "../components/WellLogTemplateTypes";
|
|
41
|
-
import {
|
|
42
|
-
WellLog,
|
|
43
|
-
WellLogCurve,
|
|
44
|
-
WellLogDataRow,
|
|
45
|
-
WellLogMetadataDiscrete,
|
|
46
|
-
WellLogMetadataDiscreteObjects,
|
|
47
|
-
} from "../components/WellLogTypes";
|
|
48
|
-
|
|
49
|
-
import {
|
|
50
|
-
checkMinMaxValue,
|
|
51
|
-
checkMinMax,
|
|
52
|
-
roundMinMax,
|
|
53
|
-
roundLogMinMax,
|
|
54
|
-
} from "./minmax";
|
|
55
|
-
|
|
56
|
-
import { updateLegendRows } from "./log-viewer";
|
|
57
|
-
|
|
58
|
-
import { deepCopy } from "./deepcopy";
|
|
59
|
-
|
|
60
|
-
export function indexOfElementByName(array: Named[], name: string): number {
|
|
61
|
-
if (array && name) {
|
|
62
|
-
const nameUpper = name.toUpperCase();
|
|
63
|
-
let i = 0;
|
|
64
|
-
for (const element of array) {
|
|
65
|
-
if (element.name && element.name.toUpperCase() == nameUpper) {
|
|
66
|
-
return i;
|
|
67
|
-
}
|
|
68
|
-
i++;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
return -1;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
function indexOfElementByNames(array: Named[], names: string[]): number {
|
|
75
|
-
if (array && names) {
|
|
76
|
-
/* names should be already in upper case */
|
|
77
|
-
let i = 0;
|
|
78
|
-
for (const element of array) {
|
|
79
|
-
if (element.name && names.indexOf(element.name.toUpperCase()) >= 0)
|
|
80
|
-
return i;
|
|
81
|
-
i++;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return -1;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function elementByKeyName<T>(meta: Record<string, T>, name: string): T | null {
|
|
88
|
-
name = name.toUpperCase();
|
|
89
|
-
for (const key in meta) {
|
|
90
|
-
if (key.toUpperCase() === name)
|
|
91
|
-
// search case insensitive!
|
|
92
|
-
return meta[key];
|
|
93
|
-
}
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const __colors = [
|
|
98
|
-
"red",
|
|
99
|
-
"blue",
|
|
100
|
-
"orange",
|
|
101
|
-
"green",
|
|
102
|
-
"red",
|
|
103
|
-
"magenta",
|
|
104
|
-
"gray",
|
|
105
|
-
"brown",
|
|
106
|
-
];
|
|
107
|
-
let __iPlotColor = 0;
|
|
108
|
-
function generateColor(): string {
|
|
109
|
-
return __colors[__iPlotColor++ % __colors.length];
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/*
|
|
113
|
-
* `LinePlot` - linear line graph
|
|
114
|
-
* `LineStepPlot` - linear stepladder graph
|
|
115
|
-
* `AreaPlot` - area graph
|
|
116
|
-
* `DotPlot` - discrete points graph
|
|
117
|
-
* `DifferentialPlot` - differential graph, for correlation of two data series.
|
|
118
|
-
*/
|
|
119
|
-
const defPlotType = "line";
|
|
120
|
-
|
|
121
|
-
class PlotData {
|
|
122
|
-
minmax: [number, number];
|
|
123
|
-
minmaxPrimaryAxis: [number, number];
|
|
124
|
-
data: [number | null, number | string | null][];
|
|
125
|
-
|
|
126
|
-
constructor() {
|
|
127
|
-
this.minmax = [Number.POSITIVE_INFINITY, Number.NEGATIVE_INFINITY];
|
|
128
|
-
this.minmaxPrimaryAxis = [
|
|
129
|
-
Number.POSITIVE_INFINITY,
|
|
130
|
-
Number.NEGATIVE_INFINITY,
|
|
131
|
-
];
|
|
132
|
-
this.data = [];
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
function preparePlotData(
|
|
137
|
-
data: WellLogDataRow[],
|
|
138
|
-
iCurve: number,
|
|
139
|
-
iPrimaryAxis: number
|
|
140
|
-
): PlotData {
|
|
141
|
-
const plot = new PlotData();
|
|
142
|
-
let i = 0;
|
|
143
|
-
for (const row of data) {
|
|
144
|
-
let value = row[iCurve];
|
|
145
|
-
if (typeof value == "number") checkMinMaxValue(plot.minmax, value);
|
|
146
|
-
const primary: number =
|
|
147
|
-
iPrimaryAxis >= 0 ? (row[iPrimaryAxis] as number) : i++;
|
|
148
|
-
if (primary == null)
|
|
149
|
-
// videx library do not like such data
|
|
150
|
-
value = null; // force a gap in the graph
|
|
151
|
-
checkMinMaxValue(plot.minmaxPrimaryAxis, primary);
|
|
152
|
-
plot.data.push([primary, value]);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return plot;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function shortDescription(description: string): string {
|
|
159
|
-
// sometimes description contains the track number
|
|
160
|
-
//"0 Depth",
|
|
161
|
-
//"1 BVW:CPI:rC:0001:v1",
|
|
162
|
-
//"02 DRAW DOWN PRESSURE",
|
|
163
|
-
if ("0" <= description[0] && description[0] <= "9") {
|
|
164
|
-
if (description[1] == " ") return description.substring(2);
|
|
165
|
-
else if ("0" <= description[1] && description[2] <= "9")
|
|
166
|
-
if (description[2] == " ") return description.substring(3);
|
|
167
|
-
}
|
|
168
|
-
return description;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function makeTrackHeader(
|
|
172
|
-
welllog: WellLog,
|
|
173
|
-
templateTrack: TemplateTrack
|
|
174
|
-
): string {
|
|
175
|
-
if (templateTrack.title) return templateTrack.title;
|
|
176
|
-
|
|
177
|
-
const templatePlots = templateTrack.plots;
|
|
178
|
-
if (templatePlots && templatePlots[0]) {
|
|
179
|
-
const curves = welllog.curves;
|
|
180
|
-
// get the first curve name
|
|
181
|
-
const templatePlot = templatePlots[0];
|
|
182
|
-
const iCurve = indexOfElementByName(curves, templatePlot.name);
|
|
183
|
-
if (iCurve < 0)
|
|
184
|
-
// something went wrong
|
|
185
|
-
return templatePlot.name;
|
|
186
|
-
const curve = curves[iCurve];
|
|
187
|
-
return curve.description
|
|
188
|
-
? shortDescription(curve.description)
|
|
189
|
-
: curve.name;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return "";
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
class TracksInfo {
|
|
196
|
-
tracks: Track[];
|
|
197
|
-
minmaxPrimaryAxis: [number, number];
|
|
198
|
-
minmaxSecondaryAxis: [number, number];
|
|
199
|
-
primaries: Float32Array; // 32 bits should be enough
|
|
200
|
-
secondaries: Float32Array;
|
|
201
|
-
|
|
202
|
-
constructor() {
|
|
203
|
-
this.tracks = [];
|
|
204
|
-
this.minmaxPrimaryAxis = [
|
|
205
|
-
Number.POSITIVE_INFINITY,
|
|
206
|
-
Number.NEGATIVE_INFINITY,
|
|
207
|
-
];
|
|
208
|
-
this.minmaxSecondaryAxis = [
|
|
209
|
-
Number.POSITIVE_INFINITY,
|
|
210
|
-
Number.NEGATIVE_INFINITY,
|
|
211
|
-
];
|
|
212
|
-
|
|
213
|
-
this.primaries = new Float32Array(0);
|
|
214
|
-
this.secondaries = new Float32Array(0);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
type Named = {
|
|
219
|
-
name: string;
|
|
220
|
-
};
|
|
221
|
-
|
|
222
|
-
export function getAvailableAxes(
|
|
223
|
-
welllog: WellLog | undefined,
|
|
224
|
-
axisMnemos: Record<string, string[]>
|
|
225
|
-
): string[] {
|
|
226
|
-
const result: string[] = [];
|
|
227
|
-
if (welllog) {
|
|
228
|
-
const curves = welllog.curves;
|
|
229
|
-
for (const key in axisMnemos) {
|
|
230
|
-
const i = indexOfElementByNames(curves, axisMnemos[key]);
|
|
231
|
-
if (i >= 0) result.push(key);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return result;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
import {
|
|
238
|
-
Plot,
|
|
239
|
-
LinePlot,
|
|
240
|
-
AreaPlot,
|
|
241
|
-
DotPlot,
|
|
242
|
-
DifferentialPlot,
|
|
243
|
-
LineStepPlot,
|
|
244
|
-
} from "@equinor/videx-wellog";
|
|
245
|
-
import GradientFillPlot from "../utils/gradientfill-plot";
|
|
246
|
-
export function getPlotType(plot: Plot): TemplatePlotTypes {
|
|
247
|
-
if (plot instanceof GradientFillPlot) return "gradientfill";
|
|
248
|
-
if (plot instanceof LinePlot) return "line";
|
|
249
|
-
if (plot instanceof AreaPlot) return "area";
|
|
250
|
-
if (plot instanceof DotPlot) return "dot";
|
|
251
|
-
if (plot instanceof DifferentialPlot) return "differential";
|
|
252
|
-
if (plot instanceof LineStepPlot) return "linestep";
|
|
253
|
-
return "";
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function isValidPlotType(plotType: string): boolean {
|
|
257
|
-
return (
|
|
258
|
-
[
|
|
259
|
-
"line",
|
|
260
|
-
"linestep",
|
|
261
|
-
"dot",
|
|
262
|
-
"area",
|
|
263
|
-
"differential",
|
|
264
|
-
"gradientfill",
|
|
265
|
-
|
|
266
|
-
"stacked",
|
|
267
|
-
].indexOf(plotType) >= 0
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
function getTemplatePlotProps(
|
|
272
|
-
templatePlot: TemplatePlot,
|
|
273
|
-
templateStyles?: TemplateStyle[]
|
|
274
|
-
): TemplatePlotProps {
|
|
275
|
-
const iStyle =
|
|
276
|
-
templatePlot.style && templateStyles
|
|
277
|
-
? indexOfElementByName(templateStyles, templatePlot.style)
|
|
278
|
-
: -1;
|
|
279
|
-
const options =
|
|
280
|
-
iStyle >= 0 && templateStyles
|
|
281
|
-
? { ...templateStyles[iStyle], ...templatePlot }
|
|
282
|
-
: { ...templatePlot };
|
|
283
|
-
if (!options.type) options.type = defPlotType;
|
|
284
|
-
if (!isValidPlotType(options.type)) {
|
|
285
|
-
console.error(
|
|
286
|
-
"unknown plot type '" +
|
|
287
|
-
options.type +
|
|
288
|
-
"': use default type '" +
|
|
289
|
-
defPlotType +
|
|
290
|
-
"'"
|
|
291
|
-
);
|
|
292
|
-
options.type = defPlotType;
|
|
293
|
-
}
|
|
294
|
-
if (options.type !== "stacked") {
|
|
295
|
-
if (!options.color) options.color = generateColor();
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
if (options.type === "area") {
|
|
299
|
-
if (!options.fill) {
|
|
300
|
-
//options.fill = generateColor();
|
|
301
|
-
options.fillOpacity = 0.0;
|
|
302
|
-
}
|
|
303
|
-
} else if (options.type === "gradientfill") {
|
|
304
|
-
if (!options.colorTable) {
|
|
305
|
-
//options.fill = generateColor();
|
|
306
|
-
options.fillOpacity = 0.0;
|
|
307
|
-
}
|
|
308
|
-
} else if (options.type === "differential") {
|
|
309
|
-
// "differential" plot
|
|
310
|
-
if (!options.fill) options.fill = generateColor();
|
|
311
|
-
if (!options.color2) options.color2 = generateColor();
|
|
312
|
-
if (!options.fill2) options.fill2 = generateColor();
|
|
313
|
-
}
|
|
314
|
-
return options;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
class __dataAccessor {
|
|
318
|
-
iData: number;
|
|
319
|
-
|
|
320
|
-
constructor(iData: number) {
|
|
321
|
-
this.iData = iData;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
dataAccessor(d: number[][]): number[] {
|
|
325
|
-
return d[this.iData];
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
function makeDataAccessor(iData: number) {
|
|
329
|
-
const _dataAccessor = new __dataAccessor(iData);
|
|
330
|
-
return _dataAccessor.dataAccessor.bind(_dataAccessor);
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
class __dataAccessor2 {
|
|
334
|
-
iData: number;
|
|
335
|
-
iData2: number;
|
|
336
|
-
|
|
337
|
-
constructor(iData: number, iData2: number) {
|
|
338
|
-
this.iData = iData;
|
|
339
|
-
this.iData2 = iData2;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
dataAccessor(d: number[][]): [number[], number[]] {
|
|
343
|
-
return [d[this.iData], d[this.iData2]];
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
function makeDataAccessor2(iData: number, iData2: number) {
|
|
347
|
-
const _dataAccessor = new __dataAccessor2(iData, iData2);
|
|
348
|
-
return _dataAccessor.dataAccessor.bind(_dataAccessor);
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
import { ColorTable } from "../components/ColorTableTypes";
|
|
352
|
-
|
|
353
|
-
const defColorTable: ColorTable = {
|
|
354
|
-
name: "not found",
|
|
355
|
-
discrete: false,
|
|
356
|
-
colors: [
|
|
357
|
-
[0.0, 1.0, 0.0, 0.0],
|
|
358
|
-
[0.5, 0.5, 0.0, 0.0],
|
|
359
|
-
[1.0, 1.0, 0.0, 0.0],
|
|
360
|
-
],
|
|
361
|
-
};
|
|
362
|
-
|
|
363
|
-
function getColorTable(
|
|
364
|
-
id: string | undefined,
|
|
365
|
-
colorTables?: ColorTable[]
|
|
366
|
-
): ColorTable | undefined {
|
|
367
|
-
if (id && typeof id !== "string") {
|
|
368
|
-
console.log("colorTable id='" + id + "' is not string");
|
|
369
|
-
return defColorTable;
|
|
370
|
-
}
|
|
371
|
-
if (id && colorTables) {
|
|
372
|
-
for (let i = 0; i < colorTables.length; i++) {
|
|
373
|
-
if (colorTables[i].name == id) return colorTables[i];
|
|
374
|
-
}
|
|
375
|
-
console.error(
|
|
376
|
-
"colorTable id='" + id + "' is not found in getColorTable()"
|
|
377
|
-
);
|
|
378
|
-
return defColorTable;
|
|
379
|
-
}
|
|
380
|
-
if (id && !colorTables)
|
|
381
|
-
console.log("colorTables is not given in getColorTable()");
|
|
382
|
-
return undefined; //defColorTable;
|
|
383
|
-
}
|
|
384
|
-
|
|
385
|
-
function getPlotOptions(
|
|
386
|
-
templatePlotProps: TemplatePlotProps,
|
|
387
|
-
trackScale: string | undefined, // track scale
|
|
388
|
-
minmax: [number, number],
|
|
389
|
-
curve: WellLogCurve,
|
|
390
|
-
iPlot: number,
|
|
391
|
-
curve2: WellLogCurve | undefined, //"differential" plot
|
|
392
|
-
iPlot2: number, //"differential" plot
|
|
393
|
-
colorTables?: ColorTable[] //"gradientfill" plot
|
|
394
|
-
): ExtPlotOptions {
|
|
395
|
-
const scale = templatePlotProps.scale || trackScale || "linear"; //"linear" or "log"
|
|
396
|
-
const domain = (
|
|
397
|
-
scale === "log" ||
|
|
398
|
-
(templatePlotProps.type === "gradientfill" &&
|
|
399
|
-
templatePlotProps.colorScale === "log")
|
|
400
|
-
? roundLogMinMax
|
|
401
|
-
: roundMinMax
|
|
402
|
-
)(minmax);
|
|
403
|
-
|
|
404
|
-
const options: ExtPlotOptions = {
|
|
405
|
-
dataAccessor: curve2
|
|
406
|
-
? makeDataAccessor2(iPlot, iPlot2)
|
|
407
|
-
: makeDataAccessor(iPlot),
|
|
408
|
-
|
|
409
|
-
scale: scale,
|
|
410
|
-
domain: templatePlotProps.domain || domain,
|
|
411
|
-
|
|
412
|
-
color: templatePlotProps.color,
|
|
413
|
-
inverseColor: templatePlotProps.inverseColor,
|
|
414
|
-
|
|
415
|
-
fill: templatePlotProps.fill, // for 'area'!
|
|
416
|
-
fillOpacity: templatePlotProps.fillOpacity
|
|
417
|
-
? templatePlotProps.fillOpacity
|
|
418
|
-
: 0.25, // for 'area' and 'gradientfill'!
|
|
419
|
-
useMinAsBase: true, // for 'area' and 'gradientfill'!
|
|
420
|
-
|
|
421
|
-
//GradientFillPlotOptions
|
|
422
|
-
colorTable: getColorTable(templatePlotProps.colorTable, colorTables),
|
|
423
|
-
inverseColorTable: getColorTable(
|
|
424
|
-
templatePlotProps.inverseColorTable,
|
|
425
|
-
colorTables
|
|
426
|
-
),
|
|
427
|
-
colorScale: templatePlotProps.colorScale,
|
|
428
|
-
inverseColorScale: templatePlotProps.inverseColorScale,
|
|
429
|
-
|
|
430
|
-
legendInfo: () => ({
|
|
431
|
-
label: curve.name,
|
|
432
|
-
unit: curve.unit ? curve.unit : "",
|
|
433
|
-
|
|
434
|
-
// DifferentialPlotLegendInfo,
|
|
435
|
-
serie1: {
|
|
436
|
-
show: true,
|
|
437
|
-
label: curve.name,
|
|
438
|
-
unit: curve.unit ? curve.unit : "",
|
|
439
|
-
},
|
|
440
|
-
serie2: {
|
|
441
|
-
show: true,
|
|
442
|
-
label: curve2 ? curve2.name : "",
|
|
443
|
-
unit: curve2 && curve2.unit ? curve2.unit : "",
|
|
444
|
-
},
|
|
445
|
-
}),
|
|
446
|
-
};
|
|
447
|
-
|
|
448
|
-
(options as DifferentialPlotOptions).serie1 = {
|
|
449
|
-
scale: scale, //"linear" or "log"
|
|
450
|
-
domain: domain,
|
|
451
|
-
color: templatePlotProps.color,
|
|
452
|
-
fill: templatePlotProps.fill,
|
|
453
|
-
};
|
|
454
|
-
(options as DifferentialPlotOptions).serie2 = {
|
|
455
|
-
// ? =scale2, =domain2 ?
|
|
456
|
-
scale: scale,
|
|
457
|
-
domain: domain,
|
|
458
|
-
color: templatePlotProps.color2,
|
|
459
|
-
fill: templatePlotProps.fill2,
|
|
460
|
-
};
|
|
461
|
-
|
|
462
|
-
return options;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
function getPlotConfig(
|
|
466
|
-
id: string | number,
|
|
467
|
-
templatePlotProps: TemplatePlotProps,
|
|
468
|
-
trackScale: string | undefined, // track scale
|
|
469
|
-
minmax: [number, number],
|
|
470
|
-
curve: WellLogCurve,
|
|
471
|
-
iPlot: number,
|
|
472
|
-
curve2: WellLogCurve | undefined,
|
|
473
|
-
iPlot2: number,
|
|
474
|
-
colorTables?: ColorTable[]
|
|
475
|
-
): PlotConfig {
|
|
476
|
-
return {
|
|
477
|
-
id: id,
|
|
478
|
-
type: templatePlotProps.type,
|
|
479
|
-
options: getPlotOptions(
|
|
480
|
-
templatePlotProps,
|
|
481
|
-
trackScale,
|
|
482
|
-
minmax,
|
|
483
|
-
curve,
|
|
484
|
-
iPlot,
|
|
485
|
-
curve2,
|
|
486
|
-
iPlot2,
|
|
487
|
-
colorTables
|
|
488
|
-
),
|
|
489
|
-
};
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
import { Domain } from "@equinor/videx-wellog/dist/common/interfaces";
|
|
493
|
-
/**
|
|
494
|
-
* Update Graph-Track Scale according to the first plot
|
|
495
|
-
*/
|
|
496
|
-
function updateGraphTrackScale(track: GraphTrack): void {
|
|
497
|
-
const track_options = track.options as TrackOptionsEx;
|
|
498
|
-
const templateTrack = track_options.__template;
|
|
499
|
-
if (templateTrack) {
|
|
500
|
-
if (templateTrack.plots.length) {
|
|
501
|
-
const plotTemplate = templateTrack.plots[0];
|
|
502
|
-
track.options.scale = plotTemplate.scale;
|
|
503
|
-
track.options.domain = plotTemplate.domain;
|
|
504
|
-
|
|
505
|
-
if (!track.options.label) track.options.label = plotTemplate.name;
|
|
506
|
-
}
|
|
507
|
-
if (track_options.__template.scale) {
|
|
508
|
-
track.options.scale = track_options.__template.scale;
|
|
509
|
-
}
|
|
510
|
-
if (!track.options.scale) track.options.scale = "linear";
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
if (track.plots.length) {
|
|
514
|
-
const plot = track.plots[0];
|
|
515
|
-
track.options.domain = plot.options.domain as Domain;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
if (!track.options.domain) {
|
|
519
|
-
// could be on reguired track with missed data
|
|
520
|
-
console.log("Empty track.options.domain!");
|
|
521
|
-
track.options.domain =
|
|
522
|
-
track.options.scale === "log" ? [1, 100] : [0, 100];
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
if (track.options.scale === "log" && track.options.domain) {
|
|
526
|
-
if (track.options.domain[0] < 0) {
|
|
527
|
-
// could not show negative data!
|
|
528
|
-
console.error(
|
|
529
|
-
"wrong data range for logarithm scale " + track.options.domain
|
|
530
|
-
);
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
|
|
534
|
-
if (!track.options.scale) throw Error("Invalid track.options.scale!");
|
|
535
|
-
track.trackScale = createScale(track.options.scale, track.options.domain);
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
/**
|
|
539
|
-
* Update Stacked-Track Scale according to the first plot
|
|
540
|
-
*/
|
|
541
|
-
function updateStackedTrackScale(track: StackedTrack): void {
|
|
542
|
-
const track_options = track.options as TrackOptionsEx;
|
|
543
|
-
const templateTrack = track_options.__template;
|
|
544
|
-
if (templateTrack) {
|
|
545
|
-
if (templateTrack.plots.length) {
|
|
546
|
-
const plotTemplate = templateTrack.plots[0];
|
|
547
|
-
//track.options.scale = plotTemplate.scale;
|
|
548
|
-
//track.options.domain = plotTemplate.domain;
|
|
549
|
-
|
|
550
|
-
if (!track.options.label) track.options.label = plotTemplate.name;
|
|
551
|
-
}
|
|
552
|
-
//if (track_options.__template.scale) {
|
|
553
|
-
//track.options.scale = track_options.__template.scale;
|
|
554
|
-
//}
|
|
555
|
-
//if (!track.options.scale) track.options.scale = "linear";
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
//if (track.plots.length) {
|
|
559
|
-
// const plot = track.plots[0];
|
|
560
|
-
// track.options.domain = plot.options.domain;
|
|
561
|
-
//}
|
|
562
|
-
|
|
563
|
-
//if (!track.options.domain) {
|
|
564
|
-
// // could be on reguired track with missed data
|
|
565
|
-
// console.log("Empty track.options.domain!");
|
|
566
|
-
// track.options.domain =
|
|
567
|
-
// track.options.scale === "log" ? [1, 100] : [0, 100];
|
|
568
|
-
//}
|
|
569
|
-
|
|
570
|
-
//if (!track.options.scale) throw Error("Invalid track.options.scale!");
|
|
571
|
-
//track.trackScale = createScale(track.options.scale, track.options.domain);
|
|
572
|
-
track.xscale;
|
|
573
|
-
}
|
|
574
|
-
|
|
575
|
-
function addGraphTrackPlot(
|
|
576
|
-
wellLogView: WellLogView,
|
|
577
|
-
track: GraphTrack,
|
|
578
|
-
templatePlot: TemplatePlot
|
|
579
|
-
): [number, number] {
|
|
580
|
-
const templateTrack = getTrackTemplate(track);
|
|
581
|
-
const minmaxPrimaryAxis: [number, number] = [
|
|
582
|
-
Number.POSITIVE_INFINITY,
|
|
583
|
-
Number.NEGATIVE_INFINITY,
|
|
584
|
-
];
|
|
585
|
-
|
|
586
|
-
const axes = wellLogView.getAxesInfo();
|
|
587
|
-
const plotFactory = track.options.plotFactory;
|
|
588
|
-
const welllog = wellLogView.props.welllog;
|
|
589
|
-
if (plotFactory && welllog) {
|
|
590
|
-
const data = welllog.data;
|
|
591
|
-
const curves = welllog.curves;
|
|
592
|
-
|
|
593
|
-
const iPrimaryAxis = !axes.mnemos
|
|
594
|
-
? -1
|
|
595
|
-
: indexOfElementByNames(curves, axes.mnemos[axes.primaryAxis]);
|
|
596
|
-
|
|
597
|
-
const iCurve = indexOfElementByName(curves, templatePlot.name);
|
|
598
|
-
if (iCurve < 0) console.log("iCurve < 0");
|
|
599
|
-
const curve = curves[iCurve];
|
|
600
|
-
|
|
601
|
-
const dimensions =
|
|
602
|
-
curve.dimensions === undefined ? 1 : curve.dimensions;
|
|
603
|
-
if (dimensions !== 1) console.log("curve.dimensions !== 1");
|
|
604
|
-
if (curve.valueType === "string")
|
|
605
|
-
console.log('curve.valueType === "string"');
|
|
606
|
-
|
|
607
|
-
const plotData = preparePlotData(data, iCurve, iPrimaryAxis);
|
|
608
|
-
checkMinMax(minmaxPrimaryAxis, plotData.minmaxPrimaryAxis);
|
|
609
|
-
const minmax: [number, number] = [
|
|
610
|
-
plotData.minmax[0],
|
|
611
|
-
plotData.minmax[1],
|
|
612
|
-
];
|
|
613
|
-
|
|
614
|
-
const plotDatas = track.options.data;
|
|
615
|
-
const plots = track.plots;
|
|
616
|
-
|
|
617
|
-
const colorTables = wellLogView.props.colorTables;
|
|
618
|
-
|
|
619
|
-
let iCurve2 = -1;
|
|
620
|
-
let curve2: WellLogCurve | undefined = undefined;
|
|
621
|
-
let plotData2: PlotData | undefined = undefined;
|
|
622
|
-
if (templatePlot.type === "differential") {
|
|
623
|
-
iCurve2 = templatePlot.name2
|
|
624
|
-
? indexOfElementByName(curves, templatePlot.name2)
|
|
625
|
-
: -1;
|
|
626
|
-
curve2 = iCurve2 >= 0 ? curves[iCurve2] : undefined;
|
|
627
|
-
plotData2 = preparePlotData(data, iCurve2, iPrimaryAxis);
|
|
628
|
-
if (!curve2)
|
|
629
|
-
console.error(
|
|
630
|
-
"templatePlot.name2 '" + templatePlot.name2 + "' not found"
|
|
631
|
-
);
|
|
632
|
-
checkMinMax(minmaxPrimaryAxis, plotData2.minmaxPrimaryAxis);
|
|
633
|
-
checkMinMax(minmax, plotData2.minmax);
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
// Make full props
|
|
637
|
-
const templatePlotProps = getTemplatePlotProps(
|
|
638
|
-
templatePlot,
|
|
639
|
-
/*templateStyles*/ []
|
|
640
|
-
);
|
|
641
|
-
const p = getPlotConfig(
|
|
642
|
-
iCurve,
|
|
643
|
-
templatePlotProps,
|
|
644
|
-
templateTrack.scale,
|
|
645
|
-
minmax,
|
|
646
|
-
curve,
|
|
647
|
-
plotDatas.length,
|
|
648
|
-
curve2,
|
|
649
|
-
plotDatas.length + 1,
|
|
650
|
-
colorTables
|
|
651
|
-
);
|
|
652
|
-
|
|
653
|
-
plotDatas.push(plotData.data);
|
|
654
|
-
if (plotData2) {
|
|
655
|
-
plotDatas.push(plotData2.data);
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
// GraphTrack
|
|
659
|
-
const createPlot = plotFactory[p.type];
|
|
660
|
-
if (!createPlot)
|
|
661
|
-
throw Error(`No factory function for creating '${p.type}'-plot!`);
|
|
662
|
-
|
|
663
|
-
const plot = createPlot(p, track.trackScale);
|
|
664
|
-
if (plot) {
|
|
665
|
-
plots.push(plot);
|
|
666
|
-
templateTrack.plots.push(templatePlot);
|
|
667
|
-
updateGraphTrackScale(track);
|
|
668
|
-
track.prepareData();
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
return minmaxPrimaryAxis;
|
|
672
|
-
}
|
|
673
|
-
|
|
674
|
-
function editGraphTrackPlot(
|
|
675
|
-
wellLogView: WellLogView,
|
|
676
|
-
track: GraphTrack,
|
|
677
|
-
plot: Plot,
|
|
678
|
-
templatePlot: TemplatePlot
|
|
679
|
-
): [number, number] {
|
|
680
|
-
const templateTrack = getTrackTemplate(track);
|
|
681
|
-
const minmaxPrimaryAxis: [number, number] = [
|
|
682
|
-
Number.POSITIVE_INFINITY,
|
|
683
|
-
Number.NEGATIVE_INFINITY,
|
|
684
|
-
];
|
|
685
|
-
|
|
686
|
-
const axes = wellLogView.getAxesInfo();
|
|
687
|
-
const plotFactory = track.options.plotFactory;
|
|
688
|
-
const welllog = wellLogView.props.welllog;
|
|
689
|
-
if (plotFactory && welllog) {
|
|
690
|
-
const data = welllog.data;
|
|
691
|
-
const curves = welllog.curves;
|
|
692
|
-
|
|
693
|
-
const iPrimaryAxis = !axes.mnemos
|
|
694
|
-
? -1
|
|
695
|
-
: indexOfElementByNames(curves, axes.mnemos[axes.primaryAxis]);
|
|
696
|
-
|
|
697
|
-
const iCurve = indexOfElementByName(curves, templatePlot.name);
|
|
698
|
-
if (iCurve < 0) console.log("iCurve < 0");
|
|
699
|
-
const curve = curves[iCurve];
|
|
700
|
-
|
|
701
|
-
const dimensions =
|
|
702
|
-
curve.dimensions === undefined ? 1 : curve.dimensions;
|
|
703
|
-
if (dimensions !== 1) console.log("curve.dimensions !== 1");
|
|
704
|
-
if (curve.valueType === "string")
|
|
705
|
-
console.log('curve.valueType === "string"');
|
|
706
|
-
|
|
707
|
-
const plotData = preparePlotData(data, iCurve, iPrimaryAxis);
|
|
708
|
-
checkMinMax(minmaxPrimaryAxis, plotData.minmaxPrimaryAxis);
|
|
709
|
-
const minmax: [number, number] = [
|
|
710
|
-
plotData.minmax[0],
|
|
711
|
-
plotData.minmax[1],
|
|
712
|
-
];
|
|
713
|
-
|
|
714
|
-
const plotDatas = track.options.data;
|
|
715
|
-
const plots = track.plots;
|
|
716
|
-
|
|
717
|
-
const colorTables = wellLogView.props.colorTables;
|
|
718
|
-
|
|
719
|
-
let iCurve2 = -1;
|
|
720
|
-
let curve2: WellLogCurve | undefined = undefined;
|
|
721
|
-
let plotData2: PlotData | undefined = undefined;
|
|
722
|
-
if (templatePlot.type === "differential") {
|
|
723
|
-
iCurve2 = templatePlot.name2
|
|
724
|
-
? indexOfElementByName(curves, templatePlot.name2)
|
|
725
|
-
: -1;
|
|
726
|
-
curve2 = iCurve2 >= 0 ? curves[iCurve2] : undefined;
|
|
727
|
-
if (!curve2)
|
|
728
|
-
console.error(
|
|
729
|
-
"templatePlot.name2 '" + templatePlot.name2 + "' not found"
|
|
730
|
-
);
|
|
731
|
-
plotData2 = preparePlotData(data, iCurve2, iPrimaryAxis);
|
|
732
|
-
checkMinMax(minmaxPrimaryAxis, plotData2.minmaxPrimaryAxis);
|
|
733
|
-
checkMinMax(minmax, plotData2.minmax);
|
|
734
|
-
}
|
|
735
|
-
|
|
736
|
-
// Make full props
|
|
737
|
-
const templatePlotProps = getTemplatePlotProps(
|
|
738
|
-
templatePlot,
|
|
739
|
-
/*templateStyles*/ []
|
|
740
|
-
);
|
|
741
|
-
const p = getPlotConfig(
|
|
742
|
-
iCurve,
|
|
743
|
-
templatePlotProps,
|
|
744
|
-
templateTrack.scale,
|
|
745
|
-
minmax,
|
|
746
|
-
curve,
|
|
747
|
-
plotDatas.length,
|
|
748
|
-
curve2,
|
|
749
|
-
plotDatas.length + 1,
|
|
750
|
-
colorTables
|
|
751
|
-
);
|
|
752
|
-
|
|
753
|
-
plotDatas.push(plotData.data);
|
|
754
|
-
if (plotData2) {
|
|
755
|
-
plotDatas.push(plotData2.data);
|
|
756
|
-
}
|
|
757
|
-
|
|
758
|
-
// GraphTrack
|
|
759
|
-
const createPlot = plotFactory[p.type];
|
|
760
|
-
if (!createPlot)
|
|
761
|
-
throw Error(`No factory function for creating '${p.type}'-plot!`);
|
|
762
|
-
|
|
763
|
-
const iPlot = plots.indexOf(plot);
|
|
764
|
-
if (iPlot < 0) {
|
|
765
|
-
console.error("Error!", "Edited plot not found!");
|
|
766
|
-
} else {
|
|
767
|
-
const plotNew = createPlot(p, track.trackScale);
|
|
768
|
-
if (plotNew) {
|
|
769
|
-
plots[iPlot] = plotNew; // replace plot
|
|
770
|
-
templateTrack.plots[iPlot] = templatePlot;
|
|
771
|
-
updateGraphTrackScale(track);
|
|
772
|
-
track.prepareData();
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
return minmaxPrimaryAxis;
|
|
777
|
-
}
|
|
778
|
-
|
|
779
|
-
export function addOrEditGraphTrackPlot(
|
|
780
|
-
wellLogView: WellLogView,
|
|
781
|
-
track: GraphTrack,
|
|
782
|
-
plot: Plot | null,
|
|
783
|
-
templatePlot: TemplatePlot
|
|
784
|
-
): void {
|
|
785
|
-
const minmaxPrimaryAxis = plot
|
|
786
|
-
? editGraphTrackPlot(wellLogView, track, plot, templatePlot)
|
|
787
|
-
: addGraphTrackPlot(wellLogView, track, templatePlot);
|
|
788
|
-
|
|
789
|
-
if (wellLogView.logController) {
|
|
790
|
-
{
|
|
791
|
-
const baseDomain =
|
|
792
|
-
wellLogView.logController.scaleHandler.baseDomain();
|
|
793
|
-
// update base domain to take into account new plot data range
|
|
794
|
-
if (baseDomain[0] > minmaxPrimaryAxis[0])
|
|
795
|
-
baseDomain[0] = minmaxPrimaryAxis[0];
|
|
796
|
-
if (baseDomain[1] < minmaxPrimaryAxis[1])
|
|
797
|
-
baseDomain[1] = minmaxPrimaryAxis[1];
|
|
798
|
-
wellLogView.logController.rescale();
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
updateLegendRows(wellLogView.logController);
|
|
802
|
-
wellLogView.logController.updateTracks();
|
|
803
|
-
}
|
|
804
|
-
}
|
|
805
|
-
|
|
806
|
-
function _removeGraphTrackPlot(track: GraphTrack, _plot: Plot): number {
|
|
807
|
-
const template = getTrackTemplate(track);
|
|
808
|
-
|
|
809
|
-
const plots = track.plots;
|
|
810
|
-
|
|
811
|
-
let index = 0;
|
|
812
|
-
for (const plot of plots) {
|
|
813
|
-
if (plot === _plot) {
|
|
814
|
-
plots.splice(index, 1);
|
|
815
|
-
template.plots.splice(index, 1);
|
|
816
|
-
break;
|
|
817
|
-
}
|
|
818
|
-
index++;
|
|
819
|
-
}
|
|
820
|
-
return index;
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
export function removeGraphTrackPlot(
|
|
824
|
-
wellLogView: WellLogView,
|
|
825
|
-
track: GraphTrack,
|
|
826
|
-
plot: Plot
|
|
827
|
-
): void {
|
|
828
|
-
_removeGraphTrackPlot(track, plot);
|
|
829
|
-
updateGraphTrackScale(track);
|
|
830
|
-
|
|
831
|
-
if (wellLogView.logController) {
|
|
832
|
-
updateLegendRows(wellLogView.logController);
|
|
833
|
-
wellLogView.logController.updateTracks();
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
track.prepareData();
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
function newDualScaleTrack(
|
|
840
|
-
mode: number,
|
|
841
|
-
title: string,
|
|
842
|
-
abbr?: string | null,
|
|
843
|
-
units?: string | null
|
|
844
|
-
): DualScaleTrack {
|
|
845
|
-
return new DualScaleTrack(undefined as unknown as number, {
|
|
846
|
-
mode: mode,
|
|
847
|
-
maxWidth: 50,
|
|
848
|
-
width: 2,
|
|
849
|
-
label: title,
|
|
850
|
-
abbr: abbr ? abbr : title,
|
|
851
|
-
units: units ? units : "",
|
|
852
|
-
legendConfig: scaleLegendConfig,
|
|
853
|
-
});
|
|
854
|
-
}
|
|
855
|
-
|
|
856
|
-
function newScaleTrack(
|
|
857
|
-
title: string,
|
|
858
|
-
abbr?: string | null,
|
|
859
|
-
units?: string | null
|
|
860
|
-
): ScaleTrack {
|
|
861
|
-
return new ScaleTrack(undefined as unknown as number, {
|
|
862
|
-
maxWidth: 50,
|
|
863
|
-
width: 2,
|
|
864
|
-
label: title,
|
|
865
|
-
abbr: abbr ? abbr : title,
|
|
866
|
-
units: units ? units : "",
|
|
867
|
-
legendConfig: scaleLegendConfig,
|
|
868
|
-
});
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
//////////////////
|
|
872
|
-
interface DiscreteMeta {
|
|
873
|
-
iCode: number;
|
|
874
|
-
iColor: number;
|
|
875
|
-
objects: WellLogMetadataDiscreteObjects;
|
|
876
|
-
}
|
|
877
|
-
|
|
878
|
-
let iStringToNum = 0;
|
|
879
|
-
const mapStringToNum = new Map();
|
|
880
|
-
|
|
881
|
-
export function getDiscreteColorAndName(
|
|
882
|
-
value: number | string | null,
|
|
883
|
-
colorTable: ColorTable | undefined,
|
|
884
|
-
meta?: DiscreteMeta | null
|
|
885
|
-
): { color: number[]; name: string } {
|
|
886
|
-
let color: number[];
|
|
887
|
-
let name: string;
|
|
888
|
-
if (value == null) value = Number.NaN;
|
|
889
|
-
if (meta) {
|
|
890
|
-
// use discrete metadata from WellLog JSON file
|
|
891
|
-
const { objects, iColor, iCode } = meta;
|
|
892
|
-
let object: [] | undefined = undefined;
|
|
893
|
-
if (typeof value == "string") {
|
|
894
|
-
// value is key
|
|
895
|
-
name = value;
|
|
896
|
-
object = objects[value];
|
|
897
|
-
} else {
|
|
898
|
-
// usual discrete log
|
|
899
|
-
name = value.toString();
|
|
900
|
-
for (const t in objects) {
|
|
901
|
-
const obj = objects[t];
|
|
902
|
-
if (value === obj[iCode]) {
|
|
903
|
-
// value is code
|
|
904
|
-
name = t;
|
|
905
|
-
object = obj;
|
|
906
|
-
break;
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
/*if(object)*/ {
|
|
911
|
-
if (colorTable) {
|
|
912
|
-
// get color from the table
|
|
913
|
-
color = getInterpolatedColor(
|
|
914
|
-
colorTable,
|
|
915
|
-
!object
|
|
916
|
-
? Number.NaN
|
|
917
|
-
: // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
918
|
-
parseFloat((object[iCode] as any).toString()) // parseInt for discrete log
|
|
919
|
-
);
|
|
920
|
-
} else {
|
|
921
|
-
// get color from the meta (obsolete?)
|
|
922
|
-
color = object ? object[iColor] : [255, 25, 25];
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
} else {
|
|
926
|
-
name = value.toString();
|
|
927
|
-
if (colorTable) {
|
|
928
|
-
// get color from the table
|
|
929
|
-
if (typeof value == "string") {
|
|
930
|
-
let v: number;
|
|
931
|
-
if (mapStringToNum.has(value)) {
|
|
932
|
-
v = mapStringToNum.get(value);
|
|
933
|
-
} else {
|
|
934
|
-
mapStringToNum.set(value, iStringToNum);
|
|
935
|
-
v = iStringToNum;
|
|
936
|
-
iStringToNum++;
|
|
937
|
-
}
|
|
938
|
-
color = getInterpolatedColor(colorTable, v);
|
|
939
|
-
} else {
|
|
940
|
-
color = getInterpolatedColor(
|
|
941
|
-
colorTable,
|
|
942
|
-
parseInt(value.toString())
|
|
943
|
-
);
|
|
944
|
-
}
|
|
945
|
-
} else {
|
|
946
|
-
// get default color
|
|
947
|
-
color = [224, 224, 224];
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
return { color, name };
|
|
951
|
-
}
|
|
952
|
-
|
|
953
|
-
function createAreaData(
|
|
954
|
-
from: number,
|
|
955
|
-
to: number,
|
|
956
|
-
value: number | string,
|
|
957
|
-
colorTable: ColorTable | undefined,
|
|
958
|
-
meta?: DiscreteMeta | null
|
|
959
|
-
): AreaData | null {
|
|
960
|
-
const { color, name } = getDiscreteColorAndName(value, colorTable, meta);
|
|
961
|
-
return {
|
|
962
|
-
from: from,
|
|
963
|
-
to: to,
|
|
964
|
-
name: name,
|
|
965
|
-
color: {
|
|
966
|
-
r: color[0],
|
|
967
|
-
g: color[1],
|
|
968
|
-
b: color[2],
|
|
969
|
-
//, a: color[3]!==undefined? color[3]: 1.0
|
|
970
|
-
},
|
|
971
|
-
};
|
|
972
|
-
}
|
|
973
|
-
|
|
974
|
-
async function createStackData(
|
|
975
|
-
data: [number | null, number | string | null][],
|
|
976
|
-
colorTable: ColorTable | undefined,
|
|
977
|
-
meta: DiscreteMeta | undefined | null
|
|
978
|
-
) {
|
|
979
|
-
const arr: AreaData[] = new Array<AreaData>();
|
|
980
|
-
let prev: [number | null, string | number | null] | null = null;
|
|
981
|
-
let area: AreaData | null = null;
|
|
982
|
-
for (const p of data) {
|
|
983
|
-
let boundary = p[0];
|
|
984
|
-
if (boundary === null) {
|
|
985
|
-
// do the same work as at the end of data
|
|
986
|
-
if (area) {
|
|
987
|
-
// store the area
|
|
988
|
-
arr.push(area);
|
|
989
|
-
area = null;
|
|
990
|
-
}
|
|
991
|
-
continue;
|
|
992
|
-
}
|
|
993
|
-
if (prev) {
|
|
994
|
-
/* move area boundary to the middle of the last interval
|
|
995
|
-
const d = boundary - prev[0];
|
|
996
|
-
boundary = prev[0] + d * 0.5;
|
|
997
|
-
*/
|
|
998
|
-
// move area boundary to the beginnig of the last interval
|
|
999
|
-
boundary = prev[0];
|
|
1000
|
-
if (boundary === null) continue;
|
|
1001
|
-
}
|
|
1002
|
-
// extend current area
|
|
1003
|
-
if (area) area.to = boundary; // null is already processed
|
|
1004
|
-
|
|
1005
|
-
const value = p[1]; // current value
|
|
1006
|
-
if (prev) {
|
|
1007
|
-
if (value !== prev[1]) {
|
|
1008
|
-
// new value encountered
|
|
1009
|
-
if (area) {
|
|
1010
|
-
// store the area
|
|
1011
|
-
arr.push(area);
|
|
1012
|
-
area = null; // wait for a new non-null value
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
if (!area && value !== null && value !== undefined && p[0] !== null) {
|
|
1017
|
-
// new value is not null
|
|
1018
|
-
// create new interval colored and labeled for the value
|
|
1019
|
-
area = createAreaData(boundary, p[0], value, colorTable, meta);
|
|
1020
|
-
}
|
|
1021
|
-
prev = p;
|
|
1022
|
-
}
|
|
1023
|
-
if (area)
|
|
1024
|
-
// store the area
|
|
1025
|
-
arr.push(area);
|
|
1026
|
-
return arr;
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
function newStackedTrack(options: StackedTrackOptions): StackedTrack {
|
|
1030
|
-
return new StackedTrack(undefined as unknown as number, options);
|
|
1031
|
-
}
|
|
1032
|
-
|
|
1033
|
-
export function getDiscreteMeta(
|
|
1034
|
-
welllog: WellLog,
|
|
1035
|
-
name: string
|
|
1036
|
-
): DiscreteMeta | null {
|
|
1037
|
-
const meta = welllog.metadata_discrete;
|
|
1038
|
-
if (meta) {
|
|
1039
|
-
// File has metadata for discrete log
|
|
1040
|
-
//const table=meta[name.toUpperCase()]; // search case insensitive!
|
|
1041
|
-
const table: WellLogMetadataDiscrete | null = elementByKeyName(
|
|
1042
|
-
meta,
|
|
1043
|
-
name
|
|
1044
|
-
);
|
|
1045
|
-
if (table) {
|
|
1046
|
-
// there is a metadata for given log name
|
|
1047
|
-
const attributes = table.attributes; // ["color", "code"]
|
|
1048
|
-
if (attributes) {
|
|
1049
|
-
const iCode = attributes.indexOf("code");
|
|
1050
|
-
const iColor = attributes.indexOf("color");
|
|
1051
|
-
if (iColor >= 0 && iCode >= 0)
|
|
1052
|
-
// all values are OK
|
|
1053
|
-
return {
|
|
1054
|
-
iCode: iCode,
|
|
1055
|
-
iColor: iColor,
|
|
1056
|
-
objects: table.objects, // [attr1,attr2] ,
|
|
1057
|
-
};
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
return null; // something went wrong
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
import { createPlotType } from "@equinor/videx-wellog";
|
|
1065
|
-
import { defaultPlotFactory } from "@equinor/videx-wellog";
|
|
1066
|
-
|
|
1067
|
-
const plotFactory: PlotFactory = {
|
|
1068
|
-
...defaultPlotFactory,
|
|
1069
|
-
gradientfill: createPlotType(GradientFillPlot),
|
|
1070
|
-
};
|
|
1071
|
-
|
|
1072
|
-
const defaultOptions: GraphTrackOptions = {
|
|
1073
|
-
plotFactory: plotFactory,
|
|
1074
|
-
legendConfig: graphLegendConfig,
|
|
1075
|
-
};
|
|
1076
|
-
|
|
1077
|
-
export interface TrackOptionsEx extends TrackOptions {
|
|
1078
|
-
__template: TemplateTrack;
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
export function getTrackTemplate(track: Track): TemplateTrack {
|
|
1082
|
-
const options = track.options as TrackOptionsEx;
|
|
1083
|
-
if (options.__template) return options.__template;
|
|
1084
|
-
else {
|
|
1085
|
-
console.error("No __template given in track!");
|
|
1086
|
-
const options = (track as GraphTrack).options;
|
|
1087
|
-
return {
|
|
1088
|
-
title: options.label ? options.label : "",
|
|
1089
|
-
scale: options.scale === "log" ? "log" : "linear",
|
|
1090
|
-
//domain: options.domain,
|
|
1091
|
-
plots: [],
|
|
1092
|
-
};
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
|
|
1096
|
-
export function newGraphTrack(
|
|
1097
|
-
/* should contains
|
|
1098
|
-
title: string,
|
|
1099
|
-
data: [number, number][][],
|
|
1100
|
-
plots: PlotConfig[]
|
|
1101
|
-
*/
|
|
1102
|
-
options: GraphTrackOptions
|
|
1103
|
-
): GraphTrack {
|
|
1104
|
-
return new GraphTrack(undefined as unknown as number, {
|
|
1105
|
-
...defaultOptions,
|
|
1106
|
-
...options,
|
|
1107
|
-
});
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
export function isScaleTrack(track: Track): boolean {
|
|
1111
|
-
if (track instanceof ScaleTrack) return true;
|
|
1112
|
-
if (track instanceof DualScaleTrack) return true;
|
|
1113
|
-
return false;
|
|
1114
|
-
}
|
|
1115
|
-
export function getScaleTrackNum(tracks: Track[]): number {
|
|
1116
|
-
let n = 0;
|
|
1117
|
-
for (const track of tracks) {
|
|
1118
|
-
if (isScaleTrack(track)) n++;
|
|
1119
|
-
}
|
|
1120
|
-
return n;
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
export interface AxesInfo {
|
|
1124
|
-
primaryAxis: string;
|
|
1125
|
-
secondaryAxis: string;
|
|
1126
|
-
titles: Record<string, string>; // language dependent strings
|
|
1127
|
-
mnemos: Record<string, string[]>;
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
function addScaleTracks(
|
|
1131
|
-
info: TracksInfo,
|
|
1132
|
-
axes: AxesInfo,
|
|
1133
|
-
curves: WellLogCurve[],
|
|
1134
|
-
data: WellLogDataRow[],
|
|
1135
|
-
iPrimaryAxis: number
|
|
1136
|
-
): void {
|
|
1137
|
-
const titlePrimaryAxis = axes.titles
|
|
1138
|
-
? axes.titles[axes.primaryAxis]
|
|
1139
|
-
: axes.primaryAxis;
|
|
1140
|
-
const curvePrimaryAxis = curves[iPrimaryAxis];
|
|
1141
|
-
const iSecondaryAxis = !axes.mnemos
|
|
1142
|
-
? -1
|
|
1143
|
-
: indexOfElementByNames(curves, axes.mnemos[axes.secondaryAxis]);
|
|
1144
|
-
|
|
1145
|
-
if (iSecondaryAxis >= 0) {
|
|
1146
|
-
info.tracks.push(
|
|
1147
|
-
newDualScaleTrack(
|
|
1148
|
-
0,
|
|
1149
|
-
titlePrimaryAxis,
|
|
1150
|
-
curvePrimaryAxis.name,
|
|
1151
|
-
curvePrimaryAxis.unit
|
|
1152
|
-
)
|
|
1153
|
-
);
|
|
1154
|
-
|
|
1155
|
-
const titleSecondaryAxis = axes.titles
|
|
1156
|
-
? axes.titles[axes.secondaryAxis]
|
|
1157
|
-
: axes.secondaryAxis;
|
|
1158
|
-
const curveSecondaryAxis = curves[iSecondaryAxis];
|
|
1159
|
-
info.tracks.push(
|
|
1160
|
-
newDualScaleTrack(
|
|
1161
|
-
1,
|
|
1162
|
-
titleSecondaryAxis,
|
|
1163
|
-
curveSecondaryAxis.name,
|
|
1164
|
-
curveSecondaryAxis.unit
|
|
1165
|
-
)
|
|
1166
|
-
);
|
|
1167
|
-
|
|
1168
|
-
info.primaries = new Float32Array(data.length); // 32 bits should be enough
|
|
1169
|
-
info.secondaries = new Float32Array(data.length);
|
|
1170
|
-
{
|
|
1171
|
-
let count = 0;
|
|
1172
|
-
for (const row of data) {
|
|
1173
|
-
const secondary: number = row[iSecondaryAxis] as number;
|
|
1174
|
-
checkMinMaxValue(info.minmaxSecondaryAxis, secondary);
|
|
1175
|
-
|
|
1176
|
-
if (secondary !== null) {
|
|
1177
|
-
const primary: number = row[iPrimaryAxis] as number;
|
|
1178
|
-
if (primary !== null) {
|
|
1179
|
-
info.secondaries[count] = secondary;
|
|
1180
|
-
info.primaries[count] = primary;
|
|
1181
|
-
count++;
|
|
1182
|
-
}
|
|
1183
|
-
}
|
|
1184
|
-
}
|
|
1185
|
-
if (count < info.primaries.length) {
|
|
1186
|
-
// resize arrays to actual size used
|
|
1187
|
-
info.primaries = info.primaries.subarray(0, count);
|
|
1188
|
-
info.secondaries = info.secondaries.subarray(0, count);
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
} else {
|
|
1192
|
-
info.tracks.push(
|
|
1193
|
-
newScaleTrack(
|
|
1194
|
-
titlePrimaryAxis,
|
|
1195
|
-
curvePrimaryAxis.name,
|
|
1196
|
-
curvePrimaryAxis.unit
|
|
1197
|
-
)
|
|
1198
|
-
);
|
|
1199
|
-
}
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
function addGraphTrack(
|
|
1203
|
-
info: TracksInfo,
|
|
1204
|
-
welllog: WellLog,
|
|
1205
|
-
curves: WellLogCurve[],
|
|
1206
|
-
data: WellLogDataRow[],
|
|
1207
|
-
iPrimaryAxis: number,
|
|
1208
|
-
templateTrack: TemplateTrack,
|
|
1209
|
-
templateStyles?: TemplateStyle[],
|
|
1210
|
-
colorTables?: ColorTable[]
|
|
1211
|
-
): void {
|
|
1212
|
-
const plotDatas: [number | null, number | string | null][][] = [];
|
|
1213
|
-
const plots: PlotConfig[] = [];
|
|
1214
|
-
if (templateTrack.plots)
|
|
1215
|
-
for (const templatePlot of templateTrack.plots) {
|
|
1216
|
-
// see also addGraphTrackPlot(wellLogView, track, templatePlot);
|
|
1217
|
-
|
|
1218
|
-
const iCurve = indexOfElementByName(curves, templatePlot.name);
|
|
1219
|
-
if (iCurve < 0) continue; // curve not found
|
|
1220
|
-
const curve = curves[iCurve];
|
|
1221
|
-
|
|
1222
|
-
const dimensions =
|
|
1223
|
-
curve.dimensions === undefined ? 1 : curve.dimensions;
|
|
1224
|
-
if (dimensions !== 1) continue;
|
|
1225
|
-
if (curve.valueType === "string") continue;
|
|
1226
|
-
|
|
1227
|
-
const plotData = preparePlotData(data, iCurve, iPrimaryAxis);
|
|
1228
|
-
checkMinMax(info.minmaxPrimaryAxis, plotData.minmaxPrimaryAxis);
|
|
1229
|
-
const minmax: [number, number] = [
|
|
1230
|
-
plotData.minmax[0],
|
|
1231
|
-
plotData.minmax[1],
|
|
1232
|
-
];
|
|
1233
|
-
|
|
1234
|
-
let iCurve2 = -1;
|
|
1235
|
-
let curve2: WellLogCurve | undefined = undefined;
|
|
1236
|
-
let plotData2: PlotData | undefined = undefined;
|
|
1237
|
-
if (templatePlot.type === "differential") {
|
|
1238
|
-
iCurve2 = templatePlot.name2
|
|
1239
|
-
? indexOfElementByName(curves, templatePlot.name2)
|
|
1240
|
-
: -1;
|
|
1241
|
-
curve2 = iCurve2 >= 0 ? curves[iCurve2] : undefined;
|
|
1242
|
-
plotData2 = preparePlotData(data, iCurve2, iPrimaryAxis);
|
|
1243
|
-
checkMinMax(
|
|
1244
|
-
info.minmaxPrimaryAxis,
|
|
1245
|
-
plotData2.minmaxPrimaryAxis
|
|
1246
|
-
);
|
|
1247
|
-
checkMinMax(minmax, plotData2.minmax);
|
|
1248
|
-
}
|
|
1249
|
-
|
|
1250
|
-
// make full props
|
|
1251
|
-
const templatePlotProps = getTemplatePlotProps(
|
|
1252
|
-
templatePlot,
|
|
1253
|
-
templateStyles
|
|
1254
|
-
);
|
|
1255
|
-
const p = getPlotConfig(
|
|
1256
|
-
iCurve,
|
|
1257
|
-
templatePlotProps,
|
|
1258
|
-
templateTrack.scale,
|
|
1259
|
-
minmax,
|
|
1260
|
-
curve,
|
|
1261
|
-
plotDatas.length,
|
|
1262
|
-
curve2,
|
|
1263
|
-
plotDatas.length + 1,
|
|
1264
|
-
colorTables
|
|
1265
|
-
);
|
|
1266
|
-
|
|
1267
|
-
plotDatas.push(plotData.data);
|
|
1268
|
-
if (plotData2) {
|
|
1269
|
-
plotDatas.push(plotData2.data);
|
|
1270
|
-
}
|
|
1271
|
-
|
|
1272
|
-
plots.push(p);
|
|
1273
|
-
}
|
|
1274
|
-
if (plots.length || templateTrack.required) {
|
|
1275
|
-
const label = makeTrackHeader(welllog, templateTrack);
|
|
1276
|
-
const options: GraphTrackOptions = {
|
|
1277
|
-
data: plotDatas,
|
|
1278
|
-
plots: plots,
|
|
1279
|
-
};
|
|
1280
|
-
setGraphTrackOptionFromTemplate(options, templateTrack);
|
|
1281
|
-
options.label = label;
|
|
1282
|
-
|
|
1283
|
-
const track = newGraphTrack(options);
|
|
1284
|
-
updateGraphTrackScale(track);
|
|
1285
|
-
info.tracks.push(track);
|
|
1286
|
-
}
|
|
1287
|
-
}
|
|
1288
|
-
function addStackedTrack(
|
|
1289
|
-
info: TracksInfo,
|
|
1290
|
-
welllog: WellLog,
|
|
1291
|
-
curves: WellLogCurve[],
|
|
1292
|
-
data: WellLogDataRow[],
|
|
1293
|
-
iPrimaryAxis: number,
|
|
1294
|
-
templateTrack: TemplateTrack,
|
|
1295
|
-
templateStyles?: TemplateStyle[],
|
|
1296
|
-
colorTables?: ColorTable[]
|
|
1297
|
-
): void {
|
|
1298
|
-
const templatePlot = templateTrack.plots[0];
|
|
1299
|
-
const name = templatePlot.name;
|
|
1300
|
-
|
|
1301
|
-
const iCurve = indexOfElementByName(curves, name);
|
|
1302
|
-
if (iCurve < 0) return; // curve not found
|
|
1303
|
-
const curve = curves[iCurve];
|
|
1304
|
-
|
|
1305
|
-
const dimensions = curve.dimensions === undefined ? 1 : curve.dimensions;
|
|
1306
|
-
if (dimensions !== 1) return;
|
|
1307
|
-
|
|
1308
|
-
const plotData = preparePlotData(data, iCurve, iPrimaryAxis);
|
|
1309
|
-
checkMinMax(info.minmaxPrimaryAxis, plotData.minmaxPrimaryAxis);
|
|
1310
|
-
|
|
1311
|
-
// make full props
|
|
1312
|
-
const templatePlotProps = getTemplatePlotProps(
|
|
1313
|
-
templatePlot,
|
|
1314
|
-
templateStyles
|
|
1315
|
-
);
|
|
1316
|
-
const templateTrackFullPlot: TemplateTrack = deepCopy(templateTrack);
|
|
1317
|
-
const label = makeTrackHeader(welllog, templateTrack);
|
|
1318
|
-
|
|
1319
|
-
templateTrackFullPlot.title = label;
|
|
1320
|
-
templateTrackFullPlot.plots[0].type = templatePlotProps.type;
|
|
1321
|
-
|
|
1322
|
-
// curve.valueType === "integer", "string"
|
|
1323
|
-
const logColor = templatePlotProps.colorTable;
|
|
1324
|
-
let colorTable: ColorTable | undefined = undefined;
|
|
1325
|
-
if (logColor) {
|
|
1326
|
-
if (colorTables) {
|
|
1327
|
-
colorTable = colorTables.find(
|
|
1328
|
-
(colorTable) => colorTable.name == logColor
|
|
1329
|
-
);
|
|
1330
|
-
if (!colorTable)
|
|
1331
|
-
console.error("Missed '" + logColor + "' color table");
|
|
1332
|
-
} else {
|
|
1333
|
-
console.error(
|
|
1334
|
-
"No color tables file given for '" + logColor + "' color table"
|
|
1335
|
-
);
|
|
1336
|
-
}
|
|
1337
|
-
} else {
|
|
1338
|
-
console.error("No color table given in template plot props");
|
|
1339
|
-
}
|
|
1340
|
-
const meta = getDiscreteMeta(welllog, name);
|
|
1341
|
-
if (!meta && curve.valueType == "integer")
|
|
1342
|
-
console.log(
|
|
1343
|
-
"Discrete meta information for '" +
|
|
1344
|
-
name +
|
|
1345
|
-
"' not found. Use default"
|
|
1346
|
-
);
|
|
1347
|
-
|
|
1348
|
-
const showLines = true;
|
|
1349
|
-
const options: StackedTrackOptions = {
|
|
1350
|
-
abbr: name, // name of the only plot
|
|
1351
|
-
legendConfig: stackLegendConfig,
|
|
1352
|
-
data: createStackData.bind(null, plotData.data, colorTable, meta),
|
|
1353
|
-
showLabels: true,
|
|
1354
|
-
showLines: showLines,
|
|
1355
|
-
};
|
|
1356
|
-
setStackedTrackOptionFromTemplate(options, templateTrackFullPlot);
|
|
1357
|
-
const track = newStackedTrack(options);
|
|
1358
|
-
updateStackedTrackScale(track);
|
|
1359
|
-
info.tracks.push(track);
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
function isStackedTemplateTrack(
|
|
1363
|
-
templateTrack: TemplateTrack,
|
|
1364
|
-
templateStyles?: TemplateStyle[]
|
|
1365
|
-
) {
|
|
1366
|
-
if (!templateTrack.plots) return false;
|
|
1367
|
-
const templatePlot = templateTrack.plots[0];
|
|
1368
|
-
if (!templatePlot) return false;
|
|
1369
|
-
const templatePlotProps = getTemplatePlotProps(
|
|
1370
|
-
templatePlot,
|
|
1371
|
-
templateStyles
|
|
1372
|
-
);
|
|
1373
|
-
return templatePlotProps.type === "stacked";
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
|
-
export function createTracks(
|
|
1377
|
-
welllog: WellLog | undefined,
|
|
1378
|
-
axes: AxesInfo,
|
|
1379
|
-
templateTracks: TemplateTrack[], // Part of JSON
|
|
1380
|
-
templateStyles?: TemplateStyle[], // Part of JSON
|
|
1381
|
-
colorTables?: ColorTable[] // JSON
|
|
1382
|
-
): TracksInfo {
|
|
1383
|
-
const info = new TracksInfo();
|
|
1384
|
-
if (welllog) {
|
|
1385
|
-
const data = welllog.data;
|
|
1386
|
-
const curves = welllog.curves;
|
|
1387
|
-
|
|
1388
|
-
const iPrimaryAxis = !axes.mnemos
|
|
1389
|
-
? -1
|
|
1390
|
-
: indexOfElementByNames(curves, axes.mnemos[axes.primaryAxis]);
|
|
1391
|
-
if (iPrimaryAxis >= 0)
|
|
1392
|
-
// scale tracks are needed
|
|
1393
|
-
addScaleTracks(info, axes, curves, data, iPrimaryAxis);
|
|
1394
|
-
|
|
1395
|
-
if (templateTracks) {
|
|
1396
|
-
for (const templateTrack of templateTracks) {
|
|
1397
|
-
if (isStackedTemplateTrack(templateTrack, templateStyles)) {
|
|
1398
|
-
addStackedTrack(
|
|
1399
|
-
info,
|
|
1400
|
-
welllog,
|
|
1401
|
-
curves,
|
|
1402
|
-
data,
|
|
1403
|
-
iPrimaryAxis,
|
|
1404
|
-
templateTrack,
|
|
1405
|
-
templateStyles,
|
|
1406
|
-
colorTables
|
|
1407
|
-
);
|
|
1408
|
-
} else {
|
|
1409
|
-
addGraphTrack(
|
|
1410
|
-
info,
|
|
1411
|
-
welllog,
|
|
1412
|
-
curves,
|
|
1413
|
-
data,
|
|
1414
|
-
iPrimaryAxis,
|
|
1415
|
-
templateTrack,
|
|
1416
|
-
templateStyles,
|
|
1417
|
-
colorTables
|
|
1418
|
-
);
|
|
1419
|
-
}
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
|
-
|
|
1424
|
-
return info;
|
|
1425
|
-
}
|
|
1426
|
-
|
|
1427
|
-
function addTrack(
|
|
1428
|
-
wellLogView: WellLogView,
|
|
1429
|
-
trackNew: Track,
|
|
1430
|
-
trackCurrent: Track,
|
|
1431
|
-
bAfter: boolean
|
|
1432
|
-
): void {
|
|
1433
|
-
if (wellLogView.logController) {
|
|
1434
|
-
let order = 0;
|
|
1435
|
-
for (const track of wellLogView.logController.tracks) {
|
|
1436
|
-
track.order = order++;
|
|
1437
|
-
if (trackCurrent == track) {
|
|
1438
|
-
if (bAfter) {
|
|
1439
|
-
// add after
|
|
1440
|
-
trackNew.order = order++;
|
|
1441
|
-
} else {
|
|
1442
|
-
// insert before current
|
|
1443
|
-
trackNew.order = track.order;
|
|
1444
|
-
track.order = order++;
|
|
1445
|
-
}
|
|
1446
|
-
}
|
|
1447
|
-
}
|
|
1448
|
-
|
|
1449
|
-
wellLogView.logController.addTrack(trackNew);
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
|
|
1453
|
-
function setGraphTrackOptionFromTemplate(
|
|
1454
|
-
options: GraphTrackOptions,
|
|
1455
|
-
templateTrack: TemplateTrack
|
|
1456
|
-
): void {
|
|
1457
|
-
options.label = templateTrack.title;
|
|
1458
|
-
{
|
|
1459
|
-
if (templateTrack.scale) options.scale = templateTrack.scale;
|
|
1460
|
-
else delete options.scale;
|
|
1461
|
-
}
|
|
1462
|
-
//if (force || templateTrack.domain) options.domain = templateTrack.domain;
|
|
1463
|
-
|
|
1464
|
-
(options as TrackOptionsEx).__template = JSON.parse(
|
|
1465
|
-
JSON.stringify(templateTrack)
|
|
1466
|
-
);
|
|
1467
|
-
}
|
|
1468
|
-
function setStackedTrackOptionFromTemplate(
|
|
1469
|
-
options: StackedTrackOptions,
|
|
1470
|
-
templateTrack: TemplateTrack
|
|
1471
|
-
): void {
|
|
1472
|
-
options.label = templateTrack.title;
|
|
1473
|
-
|
|
1474
|
-
(options as TrackOptionsEx).__template = deepCopy(templateTrack);
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
export function addOrEditGraphTrack(
|
|
1478
|
-
wellLogView: WellLogView,
|
|
1479
|
-
track: GraphTrack | null,
|
|
1480
|
-
templateTrack: TemplateTrack,
|
|
1481
|
-
trackCurrent: Track,
|
|
1482
|
-
bAfter: boolean
|
|
1483
|
-
): GraphTrack {
|
|
1484
|
-
if (track) {
|
|
1485
|
-
// edit existing track
|
|
1486
|
-
setGraphTrackOptionFromTemplate(track.options, templateTrack);
|
|
1487
|
-
updateGraphTrackScale(track);
|
|
1488
|
-
} else {
|
|
1489
|
-
const options: GraphTrackOptions = {
|
|
1490
|
-
plots: [],
|
|
1491
|
-
data: [],
|
|
1492
|
-
};
|
|
1493
|
-
setGraphTrackOptionFromTemplate(options, templateTrack);
|
|
1494
|
-
track = newGraphTrack(options);
|
|
1495
|
-
addTrack(wellLogView, track, trackCurrent, bAfter);
|
|
1496
|
-
}
|
|
1497
|
-
if (wellLogView.logController) wellLogView.logController.updateTracks();
|
|
1498
|
-
return track;
|
|
1499
|
-
}
|
|
1500
|
-
|
|
1501
|
-
export function addOrEditStackedTrack(
|
|
1502
|
-
wellLogView: WellLogView,
|
|
1503
|
-
track: StackedTrack | null,
|
|
1504
|
-
templateTrack: TemplateTrack,
|
|
1505
|
-
trackCurrent: Track,
|
|
1506
|
-
bAfter: boolean
|
|
1507
|
-
): StackedTrack | null {
|
|
1508
|
-
const welllog = wellLogView.props.welllog;
|
|
1509
|
-
const templatePlot = templateTrack.plots[0];
|
|
1510
|
-
if (!welllog || !templatePlot) return null;
|
|
1511
|
-
const name = templatePlot.name;
|
|
1512
|
-
const colorTable = wellLogView.props.colorTables[0];
|
|
1513
|
-
const meta = getDiscreteMeta(welllog, name);
|
|
1514
|
-
const data = welllog.data;
|
|
1515
|
-
const curves = welllog.curves;
|
|
1516
|
-
const iCurve = indexOfElementByName(curves, templatePlot.name);
|
|
1517
|
-
const axes = wellLogView.getAxesInfo();
|
|
1518
|
-
const iPrimaryAxis = indexOfElementByNames(
|
|
1519
|
-
curves,
|
|
1520
|
-
axes.mnemos[axes.primaryAxis]
|
|
1521
|
-
);
|
|
1522
|
-
const plotData = preparePlotData(data, iCurve, iPrimaryAxis);
|
|
1523
|
-
if (track) {
|
|
1524
|
-
// edit existing track
|
|
1525
|
-
track.options.abbr = name; // name of the only plot
|
|
1526
|
-
track.options.data = createStackData.bind(
|
|
1527
|
-
null,
|
|
1528
|
-
plotData.data,
|
|
1529
|
-
colorTable,
|
|
1530
|
-
meta
|
|
1531
|
-
);
|
|
1532
|
-
track.data = track.options.data;
|
|
1533
|
-
setStackedTrackOptionFromTemplate(track.options, templateTrack);
|
|
1534
|
-
updateStackedTrackScale(track);
|
|
1535
|
-
if (wellLogView.logController) wellLogView.logController.refresh();
|
|
1536
|
-
} else {
|
|
1537
|
-
const showLines = true;
|
|
1538
|
-
const options: StackedTrackOptions = {
|
|
1539
|
-
abbr: name, // name of the only plot
|
|
1540
|
-
data: createStackData.bind(null, plotData.data, colorTable, meta),
|
|
1541
|
-
legendConfig: stackLegendConfig,
|
|
1542
|
-
showLabels: true,
|
|
1543
|
-
showLines: showLines,
|
|
1544
|
-
};
|
|
1545
|
-
setStackedTrackOptionFromTemplate(options, templateTrack);
|
|
1546
|
-
track = newStackedTrack(options);
|
|
1547
|
-
addTrack(wellLogView, track, trackCurrent, bAfter);
|
|
1548
|
-
}
|
|
1549
|
-
if (wellLogView.logController) wellLogView.logController.updateTracks();
|
|
1550
|
-
return track;
|
|
1551
|
-
}
|
|
1552
|
-
|
|
1553
|
-
export function hasDifferentialPlot(track: GraphTrack): boolean {
|
|
1554
|
-
for (const plot of track.plots) {
|
|
1555
|
-
const type = getPlotType(plot);
|
|
1556
|
-
if (type === "differential") return true;
|
|
1557
|
-
}
|
|
1558
|
-
return false;
|
|
1559
|
-
}
|