@equinor/esv-intersection 4.0.0 → 4.1.1
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/components/axis.d.ts.map +1 -1
- package/dist/control/ExtendedCurveInterpolator.d.ts.map +1 -1
- package/dist/control/IntersectionReferenceSystem.d.ts.map +1 -1
- package/dist/control/LayerManager.d.ts.map +1 -1
- package/dist/control/MainController.d.ts.map +1 -1
- package/dist/control/ZoomPanHandler.d.ts.map +1 -1
- package/dist/control/overlay.d.ts.map +1 -1
- package/dist/datautils/colortable.d.ts.map +1 -1
- package/dist/datautils/findsample.d.ts.map +1 -1
- package/dist/datautils/picks.d.ts.map +1 -1
- package/dist/datautils/schematicShapeGenerator.d.ts +5 -5
- package/dist/datautils/schematicShapeGenerator.d.ts.map +1 -1
- package/dist/datautils/seismicimage.d.ts.map +1 -1
- package/dist/datautils/surfacedata.d.ts.map +1 -1
- package/dist/datautils/trajectory.d.ts.map +1 -1
- package/dist/index.cjs +1 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +2168 -1290
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +1 -14
- package/dist/index.umd.js.map +1 -1
- package/dist/layers/CalloutCanvasLayer.d.ts.map +1 -1
- package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts.map +1 -1
- package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts.map +1 -1
- package/dist/layers/GeomodelCanvasLayer.d.ts.map +1 -1
- package/dist/layers/GeomodelLabelsLayer.d.ts.map +1 -1
- package/dist/layers/GeomodelLayerV2.d.ts.map +1 -1
- package/dist/layers/GridLayer.d.ts.map +1 -1
- package/dist/layers/ImageCanvasLayer.d.ts.map +1 -1
- package/dist/layers/ReferenceLineLayer.d.ts.map +1 -1
- package/dist/layers/SchematicLayer.d.ts.map +1 -1
- package/dist/layers/WellborePathLayer.d.ts.map +1 -1
- package/dist/layers/base/CanvasLayer.d.ts.map +1 -1
- package/dist/layers/base/HTMLLayer.d.ts.map +1 -1
- package/dist/layers/base/Layer.d.ts.map +1 -1
- package/dist/layers/base/PixiLayer.d.ts.map +1 -1
- package/dist/layers/base/SVGLayer.d.ts.map +1 -1
- package/dist/layers/schematicInterfaces.d.ts.map +1 -1
- package/dist/utils/arc-length.d.ts.map +1 -1
- package/dist/utils/root-finder.d.ts.map +1 -1
- package/dist/utils/text.d.ts.map +1 -1
- package/dist/utils/vectorUtils.d.ts.map +1 -1
- package/dist/vendor/pixi-dashed-line/index.d.ts.map +1 -1
- package/package.json +15 -17
- package/src/components/axis.ts +40 -10
- package/src/control/ExtendedCurveInterpolator.ts +47 -9
- package/src/control/IntersectionReferenceSystem.ts +110 -30
- package/src/control/LayerManager.ts +76 -24
- package/src/control/MainController.ts +37 -8
- package/src/control/ZoomPanHandler.ts +76 -14
- package/src/control/overlay.ts +18 -6
- package/src/datautils/colortable.ts +7 -2
- package/src/datautils/findsample.ts +12 -2
- package/src/datautils/picks.ts +66 -18
- package/src/datautils/schematicShapeGenerator.ts +570 -146
- package/src/datautils/seismicimage.ts +36 -10
- package/src/datautils/surfacedata.ts +119 -40
- package/src/datautils/trajectory.ts +56 -17
- package/src/layers/CalloutCanvasLayer.ts +129 -26
- package/src/layers/CustomDisplayObjects/ComplexRope.ts +2 -1
- package/src/layers/CustomDisplayObjects/ComplexRopeGeometry.ts +5 -5
- package/src/layers/CustomDisplayObjects/UniformTextureStretchRope.ts +6 -2
- package/src/layers/GeomodelCanvasLayer.ts +10 -3
- package/src/layers/GeomodelLabelsLayer.ts +212 -87
- package/src/layers/GeomodelLayerV2.ts +8 -3
- package/src/layers/GridLayer.ts +14 -3
- package/src/layers/ImageCanvasLayer.ts +17 -3
- package/src/layers/ReferenceLineLayer.ts +31 -9
- package/src/layers/SchematicLayer.ts +499 -150
- package/src/layers/WellborePathLayer.ts +22 -7
- package/src/layers/base/CanvasLayer.ts +18 -4
- package/src/layers/base/HTMLLayer.ts +11 -3
- package/src/layers/base/Layer.ts +10 -2
- package/src/layers/base/PixiLayer.ts +27 -7
- package/src/layers/base/SVGLayer.ts +13 -3
- package/src/layers/schematicInterfaces.ts +16 -6
- package/src/utils/arc-length.ts +31 -5
- package/src/utils/root-finder.ts +32 -4
- package/src/utils/text.ts +34 -7
- package/src/utils/vectorUtils.ts +23 -6
- package/src/vendor/pixi-dashed-line/index.ts +66 -13
|
@@ -3,7 +3,12 @@ import { clamp } from '@equinor/videx-math';
|
|
|
3
3
|
|
|
4
4
|
import { CanvasLayer } from './base/CanvasLayer';
|
|
5
5
|
import { OnUpdateEvent, OnRescaleEvent, OnMountEvent } from '../interfaces';
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
SurfaceArea,
|
|
8
|
+
SurfaceLine,
|
|
9
|
+
findSampleAtPos,
|
|
10
|
+
SurfaceData,
|
|
11
|
+
} from '../datautils';
|
|
7
12
|
import { SURFACE_LINE_WIDTH } from '../constants';
|
|
8
13
|
import { LayerOptions } from './base/Layer';
|
|
9
14
|
|
|
@@ -14,7 +19,9 @@ const DEFAULT_TEXT_COLOR = 'black';
|
|
|
14
19
|
const DEFAULT_FONT = 'Arial';
|
|
15
20
|
const MAX_FONT_SIZE_IN_WORLD_COORDINATES = 70;
|
|
16
21
|
|
|
17
|
-
export interface GeomodelLayerLabelsOptions<
|
|
22
|
+
export interface GeomodelLayerLabelsOptions<
|
|
23
|
+
T extends SurfaceData,
|
|
24
|
+
> extends LayerOptions<T> {
|
|
18
25
|
margins?: number;
|
|
19
26
|
minFontSize?: number;
|
|
20
27
|
maxFontSize?: number;
|
|
@@ -42,10 +49,12 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
42
49
|
constructor(id?: string, options?: GeomodelLayerLabelsOptions<T>) {
|
|
43
50
|
super(id, options);
|
|
44
51
|
this.render = this.render.bind(this);
|
|
45
|
-
this.getMarginsInWorldCoordinates =
|
|
52
|
+
this.getMarginsInWorldCoordinates =
|
|
53
|
+
this.getMarginsInWorldCoordinates.bind(this);
|
|
46
54
|
this.getSurfacesAreaEdges = this.getSurfacesAreaEdges.bind(this);
|
|
47
55
|
this.updateXFlipped = this.updateXFlipped.bind(this);
|
|
48
|
-
this.generateSurfacesWithAvgDepth =
|
|
56
|
+
this.generateSurfacesWithAvgDepth =
|
|
57
|
+
this.generateSurfacesWithAvgDepth.bind(this);
|
|
49
58
|
}
|
|
50
59
|
|
|
51
60
|
override get options(): GeomodelLayerLabelsOptions<T> {
|
|
@@ -59,35 +68,38 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
59
68
|
|
|
60
69
|
generateSurfacesWithAvgDepth(): void {
|
|
61
70
|
const areas = this.data?.areas ?? [];
|
|
62
|
-
this.areasWithAvgTopDepth = areas.reduce(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
71
|
+
this.areasWithAvgTopDepth = areas.reduce(
|
|
72
|
+
(acc: SurfaceAreaWithAvgTopDepth[], area: SurfaceArea) => {
|
|
73
|
+
// Filter surfaces without label
|
|
74
|
+
if (!area.label) {
|
|
75
|
+
return acc;
|
|
76
|
+
}
|
|
77
|
+
const sumAndCount = area.data.reduce(
|
|
78
|
+
(a: { sum: number; count: number }, d: number[]) => {
|
|
79
|
+
if (d[1] != null) {
|
|
80
|
+
a.sum += d[1];
|
|
81
|
+
a.count++;
|
|
82
|
+
}
|
|
83
|
+
return a;
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
sum: 0,
|
|
87
|
+
count: 0,
|
|
88
|
+
},
|
|
89
|
+
);
|
|
90
|
+
if (sumAndCount.count === 0) {
|
|
91
|
+
return acc;
|
|
92
|
+
}
|
|
93
|
+
const avgTopDepth = sumAndCount.sum / sumAndCount.count;
|
|
94
|
+
|
|
95
|
+
acc.push({
|
|
96
|
+
...area,
|
|
97
|
+
avgTopDepth,
|
|
98
|
+
});
|
|
81
99
|
return acc;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
acc.push({
|
|
86
|
-
...area,
|
|
87
|
-
avgTopDepth,
|
|
88
|
-
});
|
|
89
|
-
return acc;
|
|
90
|
-
}, []);
|
|
100
|
+
},
|
|
101
|
+
[],
|
|
102
|
+
);
|
|
91
103
|
}
|
|
92
104
|
|
|
93
105
|
override onMount(event: OnMountEvent): void {
|
|
@@ -128,36 +140,57 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
128
140
|
}
|
|
129
141
|
|
|
130
142
|
drawAreaLabels(): void {
|
|
131
|
-
this.areasWithAvgTopDepth.forEach(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
143
|
+
this.areasWithAvgTopDepth.forEach(
|
|
144
|
+
(
|
|
145
|
+
s: SurfaceAreaWithAvgTopDepth,
|
|
146
|
+
i: number,
|
|
147
|
+
array: SurfaceAreaWithAvgTopDepth[],
|
|
148
|
+
) => {
|
|
149
|
+
const topmostSurfaceNotDrawnYet = array.reduce(
|
|
150
|
+
(
|
|
151
|
+
acc: SurfaceAreaWithAvgTopDepth | null,
|
|
152
|
+
v,
|
|
153
|
+
index,
|
|
154
|
+
): SurfaceAreaWithAvgTopDepth | null => {
|
|
155
|
+
if (index > i) {
|
|
156
|
+
if (acc == null) {
|
|
157
|
+
acc = v;
|
|
158
|
+
} else {
|
|
159
|
+
if (v.avgTopDepth < acc.avgTopDepth) {
|
|
160
|
+
acc = v;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
139
163
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
164
|
+
return acc;
|
|
165
|
+
},
|
|
166
|
+
null,
|
|
167
|
+
);
|
|
144
168
|
|
|
145
|
-
|
|
146
|
-
|
|
169
|
+
this.drawAreaLabel(s, topmostSurfaceNotDrawnYet, array, i);
|
|
170
|
+
},
|
|
171
|
+
);
|
|
147
172
|
}
|
|
148
173
|
|
|
149
174
|
drawLineLabels(): void {
|
|
150
|
-
this.data?.lines
|
|
175
|
+
this.data?.lines
|
|
176
|
+
.filter((surfaceLine: SurfaceLine) => surfaceLine.label)
|
|
177
|
+
.forEach((surfaceLine: SurfaceLine) => this.drawLineLabel(surfaceLine));
|
|
151
178
|
}
|
|
152
179
|
|
|
153
|
-
drawAreaLabel = (
|
|
180
|
+
drawAreaLabel = (
|
|
181
|
+
surfaceArea: SurfaceArea,
|
|
182
|
+
nextSurfaceArea: SurfaceArea | null,
|
|
183
|
+
surfaces: SurfaceArea[],
|
|
184
|
+
i: number,
|
|
185
|
+
): void => {
|
|
154
186
|
const { data } = surfaceArea;
|
|
155
187
|
const { ctx, maxFontSizeInWorldCoordinates, isXFlipped } = this;
|
|
156
188
|
const { xScale, yScale, xRatio, yRatio, zFactor } = this.rescaleEvent!;
|
|
157
189
|
if (ctx == null) return;
|
|
158
190
|
|
|
159
191
|
let isLabelsOnLeftSide = this.checkDrawLabelsOnLeftSide();
|
|
160
|
-
const margins =
|
|
192
|
+
const margins =
|
|
193
|
+
(this.options.margins || this.defaultMargins) * (isXFlipped ? -1 : 1);
|
|
161
194
|
const marginsInWorldCoords = margins / xRatio;
|
|
162
195
|
const minFontSize = this.options.minFontSize || this.defaultMinFontSize;
|
|
163
196
|
const maxFontSize = this.options.maxFontSize || this.defaultMaxFontSize;
|
|
@@ -172,7 +205,8 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
172
205
|
|
|
173
206
|
const leftEdge = xScale.invert(xScale.range()[0]!) + marginsInWorldCoords;
|
|
174
207
|
const rightEdge = xScale.invert(xScale.range()[1]!) - marginsInWorldCoords;
|
|
175
|
-
const [surfaceAreaLeftEdge, surfaceAreaRightEdge] =
|
|
208
|
+
const [surfaceAreaLeftEdge, surfaceAreaRightEdge] =
|
|
209
|
+
this.getSurfacesAreaEdges() as [number, number];
|
|
176
210
|
|
|
177
211
|
// Get label metrics
|
|
178
212
|
ctx.save();
|
|
@@ -182,13 +216,23 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
182
216
|
|
|
183
217
|
// Check if label will fit horizontally
|
|
184
218
|
if (isLabelsOnLeftSide) {
|
|
185
|
-
const labelRightEdge =
|
|
186
|
-
|
|
219
|
+
const labelRightEdge =
|
|
220
|
+
leftEdge +
|
|
221
|
+
(isXFlipped ? -labelLengthInWorldCoords : labelLengthInWorldCoords);
|
|
222
|
+
if (
|
|
223
|
+
(!isXFlipped && labelRightEdge > surfaceAreaRightEdge) ||
|
|
224
|
+
(isXFlipped && labelRightEdge < surfaceAreaRightEdge)
|
|
225
|
+
) {
|
|
187
226
|
isLabelsOnLeftSide = false;
|
|
188
227
|
}
|
|
189
228
|
} else {
|
|
190
|
-
const labelLeftEdge =
|
|
191
|
-
|
|
229
|
+
const labelLeftEdge =
|
|
230
|
+
rightEdge +
|
|
231
|
+
(isXFlipped ? labelLengthInWorldCoords : -labelLengthInWorldCoords);
|
|
232
|
+
if (
|
|
233
|
+
(!isXFlipped && labelLeftEdge < surfaceAreaLeftEdge) ||
|
|
234
|
+
(isXFlipped && labelLeftEdge > surfaceAreaLeftEdge)
|
|
235
|
+
) {
|
|
192
236
|
isLabelsOnLeftSide = true;
|
|
193
237
|
}
|
|
194
238
|
}
|
|
@@ -197,9 +241,13 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
197
241
|
let startPos: number;
|
|
198
242
|
const portionOfLabelLengthUsedForPosCalc = 0.07;
|
|
199
243
|
if (isLabelsOnLeftSide) {
|
|
200
|
-
startPos = isXFlipped
|
|
244
|
+
startPos = isXFlipped
|
|
245
|
+
? Math.min(surfaceAreaLeftEdge, leftEdge)
|
|
246
|
+
: Math.max(surfaceAreaLeftEdge, leftEdge);
|
|
201
247
|
} else {
|
|
202
|
-
startPos = isXFlipped
|
|
248
|
+
startPos = isXFlipped
|
|
249
|
+
? Math.max(surfaceAreaRightEdge, rightEdge)
|
|
250
|
+
: Math.min(surfaceAreaRightEdge, rightEdge);
|
|
203
251
|
}
|
|
204
252
|
|
|
205
253
|
const topEdge = yScale.invert(yScale.range()[0]!);
|
|
@@ -209,18 +257,31 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
209
257
|
const dirSteps = 5;
|
|
210
258
|
const posSteps = 3;
|
|
211
259
|
const posStep =
|
|
212
|
-
portionOfLabelLengthUsedForPosCalc *
|
|
213
|
-
|
|
260
|
+
portionOfLabelLengthUsedForPosCalc *
|
|
261
|
+
(labelLengthInWorldCoords / posSteps) *
|
|
262
|
+
(isLabelsOnLeftSide ? 1 : -1) *
|
|
263
|
+
(isXFlipped ? -1 : 1);
|
|
264
|
+
const dirStep =
|
|
265
|
+
(labelLengthInWorldCoords / dirSteps) *
|
|
266
|
+
(isLabelsOnLeftSide ? 1 : -1) *
|
|
267
|
+
(isXFlipped ? -1 : 1);
|
|
214
268
|
|
|
215
269
|
// Sample points from top and calculate position
|
|
216
|
-
const topData = data.map(
|
|
217
|
-
const topPos = this.calcPos(
|
|
270
|
+
const topData = data.map(d => [d[0]!, d[1]!]);
|
|
271
|
+
const topPos = this.calcPos(
|
|
272
|
+
topData,
|
|
273
|
+
startPos,
|
|
274
|
+
posSteps,
|
|
275
|
+
posStep,
|
|
276
|
+
topEdge,
|
|
277
|
+
bottomEdge,
|
|
278
|
+
);
|
|
218
279
|
if (!topPos) {
|
|
219
280
|
return;
|
|
220
281
|
}
|
|
221
282
|
|
|
222
283
|
// Sample points from bottom and calculate position
|
|
223
|
-
const bottomData = data.map(
|
|
284
|
+
const bottomData = data.map(d => [d[0]!, d[2]!]);
|
|
224
285
|
let bottomPos = this.calcPos(
|
|
225
286
|
bottomData,
|
|
226
287
|
startPos,
|
|
@@ -228,7 +289,7 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
228
289
|
posStep,
|
|
229
290
|
topEdge,
|
|
230
291
|
bottomEdge,
|
|
231
|
-
nextSurfaceArea?.data.map(
|
|
292
|
+
nextSurfaceArea?.data.map(d => [d[0]!, d[1]!]) ?? [],
|
|
232
293
|
surfaces,
|
|
233
294
|
i,
|
|
234
295
|
);
|
|
@@ -250,7 +311,8 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
250
311
|
labelLengthInWorldCoords = labelMetrics.width / xRatio;
|
|
251
312
|
}
|
|
252
313
|
// Sample points from top and bottom and calculate direction vector
|
|
253
|
-
const initialDirVec =
|
|
314
|
+
const initialDirVec =
|
|
315
|
+
isLabelsOnLeftSide !== isXFlipped ? Vector2.right : Vector2.left;
|
|
254
316
|
const areaDir = this.calcAreaDir(
|
|
255
317
|
topData,
|
|
256
318
|
bottomData,
|
|
@@ -263,7 +325,7 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
263
325
|
0,
|
|
264
326
|
Math.PI / 4,
|
|
265
327
|
4,
|
|
266
|
-
nextSurfaceArea?.data.map(
|
|
328
|
+
nextSurfaceArea?.data.map(d => [d[0]!, d[1]!]) ?? [],
|
|
267
329
|
surfaces,
|
|
268
330
|
i,
|
|
269
331
|
);
|
|
@@ -304,24 +366,37 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
304
366
|
|
|
305
367
|
const leftEdge = xScale.invert(xScale.range()[0]!) + marginsInWorldCoords;
|
|
306
368
|
const rightEdge = xScale.invert(xScale.range()[1]!) - marginsInWorldCoords;
|
|
307
|
-
const [surfaceAreaLeftEdge, surfaceAreaRightEdge] =
|
|
369
|
+
const [surfaceAreaLeftEdge, surfaceAreaRightEdge] =
|
|
370
|
+
this.getSurfacesAreaEdges() as [number, number];
|
|
308
371
|
|
|
309
372
|
// Find edge where to draw
|
|
310
373
|
let startPos: number;
|
|
311
374
|
const steps = 5;
|
|
312
375
|
if (isLabelsOnLeftSide) {
|
|
313
|
-
startPos = isXFlipped
|
|
376
|
+
startPos = isXFlipped
|
|
377
|
+
? Math.max(surfaceAreaRightEdge, rightEdge)
|
|
378
|
+
: Math.min(surfaceAreaRightEdge, rightEdge);
|
|
314
379
|
} else {
|
|
315
|
-
startPos = isXFlipped
|
|
380
|
+
startPos = isXFlipped
|
|
381
|
+
? Math.min(surfaceAreaLeftEdge, leftEdge)
|
|
382
|
+
: Math.max(surfaceAreaLeftEdge, leftEdge);
|
|
316
383
|
}
|
|
317
384
|
|
|
318
385
|
// Calculate where to sample points
|
|
319
|
-
const step =
|
|
386
|
+
const step =
|
|
387
|
+
(labelLengthInWorldCoords / steps) * (isLabelsOnLeftSide ? -1 : 1);
|
|
320
388
|
|
|
321
389
|
// Sample points and calculate position and direction vector
|
|
322
390
|
const { data } = s;
|
|
323
391
|
const pos = this.calcPos(data, startPos, steps, step);
|
|
324
|
-
const dir = this.calcLineDir(
|
|
392
|
+
const dir = this.calcLineDir(
|
|
393
|
+
data,
|
|
394
|
+
startPos,
|
|
395
|
+
steps,
|
|
396
|
+
step,
|
|
397
|
+
zFactor,
|
|
398
|
+
isLabelsOnLeftSide ? Vector2.left : Vector2.right,
|
|
399
|
+
);
|
|
325
400
|
if (!pos || !dir) {
|
|
326
401
|
return;
|
|
327
402
|
}
|
|
@@ -329,7 +404,8 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
329
404
|
// Calculate position and direction for label
|
|
330
405
|
const textX = startPos;
|
|
331
406
|
const textY = pos.y - SURFACE_LINE_WIDTH - fontSizeInWorldCoords / 2;
|
|
332
|
-
const textDir =
|
|
407
|
+
const textDir =
|
|
408
|
+
Vector2.angleRight(dir) - (isLabelsOnLeftSide ? Math.PI : 0);
|
|
333
409
|
|
|
334
410
|
// Draw label
|
|
335
411
|
if (ctx) {
|
|
@@ -371,7 +447,14 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
371
447
|
const x = offset + i * step;
|
|
372
448
|
const y = findSampleAtPos(data, x, topLimit, bottomLimit);
|
|
373
449
|
if (y) {
|
|
374
|
-
const alternativeY = this.getAlternativeYValueIfAvailable(
|
|
450
|
+
const alternativeY = this.getAlternativeYValueIfAvailable(
|
|
451
|
+
x,
|
|
452
|
+
topLimit,
|
|
453
|
+
bottomLimit,
|
|
454
|
+
alternativeSurfaceData,
|
|
455
|
+
surfaces,
|
|
456
|
+
currentSurfaceIndex,
|
|
457
|
+
);
|
|
375
458
|
// Use topmost of value from current surface and alternative surface
|
|
376
459
|
const usedY = alternativeY ? Math.min(y, alternativeY) : y;
|
|
377
460
|
pos.add(x, usedY);
|
|
@@ -398,13 +481,23 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
398
481
|
return null;
|
|
399
482
|
}
|
|
400
483
|
// Find sample from passed in surface data
|
|
401
|
-
let altY = findSampleAtPos(
|
|
484
|
+
let altY = findSampleAtPos(
|
|
485
|
+
alternativeSurfaceData,
|
|
486
|
+
x,
|
|
487
|
+
topLimit,
|
|
488
|
+
bottomLimit,
|
|
489
|
+
);
|
|
402
490
|
if (altY == null && surfaces && currentSurfaceIndex != null) {
|
|
403
491
|
//Find topmost surface after current which gives us data
|
|
404
492
|
let si = currentSurfaceIndex + 1;
|
|
405
493
|
while (altY == null && si < surfaces.length) {
|
|
406
494
|
const altSurface = surfaces[si++];
|
|
407
|
-
altY = findSampleAtPos(
|
|
495
|
+
altY = findSampleAtPos(
|
|
496
|
+
altSurface?.data.map((d: number[]) => [d[0]!, d[1]!]) ?? [],
|
|
497
|
+
x,
|
|
498
|
+
topLimit,
|
|
499
|
+
bottomLimit,
|
|
500
|
+
);
|
|
408
501
|
}
|
|
409
502
|
}
|
|
410
503
|
return altY;
|
|
@@ -464,7 +557,8 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
464
557
|
for (let i = 0; i <= count; i++) {
|
|
465
558
|
const x = offset + i * step;
|
|
466
559
|
const topY = findSampleAtPos(top, x, topLimit, bottomLimit);
|
|
467
|
-
const bottomY =
|
|
560
|
+
const bottomY =
|
|
561
|
+
findSampleAtPos(bottom, x, topLimit, bottomLimit) || bottomLimit;
|
|
468
562
|
// Find position of next surface in case it's higher than current base
|
|
469
563
|
const alternativeBottomY = this.getAlternativeYValueIfAvailable(
|
|
470
564
|
x,
|
|
@@ -475,7 +569,9 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
475
569
|
currentSurfaceIndex,
|
|
476
570
|
);
|
|
477
571
|
// Use topmost of value from current surface and alternative surface
|
|
478
|
-
const usedBottomY = alternativeBottomY
|
|
572
|
+
const usedBottomY = alternativeBottomY
|
|
573
|
+
? Math.min(bottomY, alternativeBottomY)
|
|
574
|
+
: bottomY;
|
|
479
575
|
if (i === 0) {
|
|
480
576
|
if (topY === null) {
|
|
481
577
|
return Vector2.angleRight(initalVector);
|
|
@@ -514,7 +610,9 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
514
610
|
|
|
515
611
|
getMarginsInWorldCoordinates(): number {
|
|
516
612
|
const { xRatio } = this.rescaleEvent!;
|
|
517
|
-
const margins =
|
|
613
|
+
const margins =
|
|
614
|
+
(this.options.margins || this.defaultMargins) *
|
|
615
|
+
(this.isXFlipped ? -1 : 1);
|
|
518
616
|
const marginsInWorldCoords = margins / xRatio;
|
|
519
617
|
return marginsInWorldCoords;
|
|
520
618
|
}
|
|
@@ -559,8 +657,12 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
559
657
|
const maxX = Math.max(...endPoints);
|
|
560
658
|
const marginsInWorldCoords = this.getMarginsInWorldCoordinates();
|
|
561
659
|
const { isXFlipped } = this;
|
|
562
|
-
const surfaceAreaLeftEdge = isXFlipped
|
|
563
|
-
|
|
660
|
+
const surfaceAreaLeftEdge = isXFlipped
|
|
661
|
+
? maxX + marginsInWorldCoords
|
|
662
|
+
: minX + marginsInWorldCoords;
|
|
663
|
+
const surfaceAreaRightEdge = isXFlipped
|
|
664
|
+
? minX - marginsInWorldCoords
|
|
665
|
+
: maxX - marginsInWorldCoords;
|
|
564
666
|
return [surfaceAreaLeftEdge, surfaceAreaRightEdge];
|
|
565
667
|
}
|
|
566
668
|
|
|
@@ -576,13 +678,23 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
576
678
|
const [dx1, dx2] = xScale.domain() as [number, number];
|
|
577
679
|
const [dy1, dy2] = yScale.domain() as [number, number];
|
|
578
680
|
|
|
579
|
-
let top = referenceSystem.interpolators.curtain.getIntersects(
|
|
681
|
+
let top = referenceSystem.interpolators.curtain.getIntersects(
|
|
682
|
+
dy1,
|
|
683
|
+
1,
|
|
684
|
+
0,
|
|
685
|
+
) as number[][];
|
|
580
686
|
if (top.length === 0) {
|
|
581
687
|
top = [referenceSystem.interpolators.curtain.getPointAt(0.0) as number[]];
|
|
582
688
|
}
|
|
583
|
-
let bottom = referenceSystem.interpolators.curtain.getIntersects(
|
|
689
|
+
let bottom = referenceSystem.interpolators.curtain.getIntersects(
|
|
690
|
+
dy2,
|
|
691
|
+
1,
|
|
692
|
+
0,
|
|
693
|
+
) as number[][];
|
|
584
694
|
if (bottom.length === 0) {
|
|
585
|
-
bottom = [
|
|
695
|
+
bottom = [
|
|
696
|
+
referenceSystem.interpolators.curtain.getPointAt(1.0) as number[],
|
|
697
|
+
];
|
|
586
698
|
}
|
|
587
699
|
|
|
588
700
|
const maxX = Math.max(top[0]?.[0]!, bottom[0]?.[0]!);
|
|
@@ -597,20 +709,33 @@ export class GeomodelLabelsLayer<T extends SurfaceData> extends CanvasLayer<T> {
|
|
|
597
709
|
const screenLeftEdge = dx1 + margin;
|
|
598
710
|
const screenRightEdge = dx2 - margin;
|
|
599
711
|
|
|
600
|
-
const [surfaceAreaLeftEdge, surfaceAreaRightEdge] =
|
|
712
|
+
const [surfaceAreaLeftEdge, surfaceAreaRightEdge] =
|
|
713
|
+
this.getSurfacesAreaEdges() as [number, number];
|
|
601
714
|
|
|
602
|
-
const leftLimit = isXFlipped
|
|
603
|
-
|
|
715
|
+
const leftLimit = isXFlipped
|
|
716
|
+
? Math.min(screenLeftEdge, surfaceAreaLeftEdge)
|
|
717
|
+
: Math.max(screenLeftEdge, surfaceAreaLeftEdge);
|
|
718
|
+
const rightLimit = isXFlipped
|
|
719
|
+
? Math.max(screenRightEdge, surfaceAreaRightEdge)
|
|
720
|
+
: Math.min(screenRightEdge, surfaceAreaRightEdge);
|
|
604
721
|
|
|
605
|
-
const spaceOnLeftSide = Math.max(
|
|
606
|
-
|
|
722
|
+
const spaceOnLeftSide = Math.max(
|
|
723
|
+
isXFlipped ? leftLimit - wbBBox.left : wbBBox.left - leftLimit,
|
|
724
|
+
0,
|
|
725
|
+
);
|
|
726
|
+
const spaceOnRightSide = Math.max(
|
|
727
|
+
isXFlipped ? wbBBox.right - rightLimit : rightLimit - wbBBox.right,
|
|
728
|
+
0,
|
|
729
|
+
);
|
|
607
730
|
|
|
608
731
|
const spaceOnLeftSideInScreenCoordinates = spaceOnLeftSide * xRatio;
|
|
609
732
|
const spaceOnRightSideInScreenCoordinates = spaceOnRightSide * xRatio;
|
|
610
733
|
const isLabelsOnLeftSide =
|
|
611
734
|
spaceOnLeftSide > spaceOnRightSide ||
|
|
612
735
|
spaceOnLeftSideInScreenCoordinates > t ||
|
|
613
|
-
(spaceOnLeftSideInScreenCoordinates < t &&
|
|
736
|
+
(spaceOnLeftSideInScreenCoordinates < t &&
|
|
737
|
+
spaceOnRightSideInScreenCoordinates < t &&
|
|
738
|
+
isXFlipped) ||
|
|
614
739
|
bottom[0]?.[1]! < dy1;
|
|
615
740
|
|
|
616
741
|
return isLabelsOnLeftSide;
|
|
@@ -36,8 +36,8 @@ export class GeomodelLayerV2<T extends SurfaceData> extends PixiLayer<T> {
|
|
|
36
36
|
return;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
data.areas.forEach(
|
|
40
|
-
data.lines.forEach(
|
|
39
|
+
data.areas.forEach(a => this.generateAreaPolygon(a));
|
|
40
|
+
data.lines.forEach(l => this.generateSurfaceLine(l));
|
|
41
41
|
|
|
42
42
|
this.isPreRendered = true;
|
|
43
43
|
}
|
|
@@ -89,7 +89,12 @@ export class GeomodelLayerV2<T extends SurfaceData> extends PixiLayer<T> {
|
|
|
89
89
|
const { data: d } = s;
|
|
90
90
|
|
|
91
91
|
const alignment = 0.5;
|
|
92
|
-
g.setStrokeStyle({
|
|
92
|
+
g.setStrokeStyle({
|
|
93
|
+
width: SURFACE_LINE_WIDTH,
|
|
94
|
+
color: s.color as number,
|
|
95
|
+
alpha: 1,
|
|
96
|
+
alignment,
|
|
97
|
+
});
|
|
93
98
|
|
|
94
99
|
let penDown = false;
|
|
95
100
|
for (let i = 0; i < d.length; i++) {
|
package/src/layers/GridLayer.ts
CHANGED
|
@@ -53,7 +53,8 @@ export class GridLayer<T> extends CanvasLayer<T> {
|
|
|
53
53
|
|
|
54
54
|
render(event: OnRescaleEvent | OnGridLayerUpdateEvent<T>): void {
|
|
55
55
|
const { ctx } = this;
|
|
56
|
-
const { minorWidth, minorColor, majorWidth, majorColor } = this
|
|
56
|
+
const { minorWidth, minorColor, majorWidth, majorColor } = this
|
|
57
|
+
.options as GridLayerOptions<T>;
|
|
57
58
|
|
|
58
59
|
if (!ctx) {
|
|
59
60
|
return;
|
|
@@ -98,7 +99,12 @@ export class GridLayer<T> extends CanvasLayer<T> {
|
|
|
98
99
|
ctx.restore();
|
|
99
100
|
}
|
|
100
101
|
|
|
101
|
-
private renderTicksX(
|
|
102
|
+
private renderTicksX(
|
|
103
|
+
xscale: ScaleLinear<number, number, never>,
|
|
104
|
+
xticks: number[],
|
|
105
|
+
ry1: number,
|
|
106
|
+
ry2: number,
|
|
107
|
+
): void {
|
|
102
108
|
xticks.forEach((tx: number) => {
|
|
103
109
|
const x = xscale(tx);
|
|
104
110
|
if (this.ctx != null) {
|
|
@@ -110,7 +116,12 @@ export class GridLayer<T> extends CanvasLayer<T> {
|
|
|
110
116
|
});
|
|
111
117
|
}
|
|
112
118
|
|
|
113
|
-
private renderTicksY(
|
|
119
|
+
private renderTicksY(
|
|
120
|
+
yscale: ScaleLinear<number, number, never>,
|
|
121
|
+
yticks: number[],
|
|
122
|
+
rx1: number,
|
|
123
|
+
rx2: number,
|
|
124
|
+
): void {
|
|
114
125
|
yticks.forEach((ty: number) => {
|
|
115
126
|
const y = yscale(ty);
|
|
116
127
|
if (this.ctx != null) {
|
|
@@ -12,7 +12,8 @@ export interface OnImageLayerUpdateEvent<T> extends OnUpdateEvent<T> {
|
|
|
12
12
|
y?: number;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
export type OnImageLayerRescaleEvent<T> = OnImageLayerUpdateEvent<T> &
|
|
15
|
+
export type OnImageLayerRescaleEvent<T> = OnImageLayerUpdateEvent<T> &
|
|
16
|
+
OnRescaleEvent;
|
|
16
17
|
|
|
17
18
|
export class ImageLayer<T> extends CanvasLayer<T> {
|
|
18
19
|
img: HTMLImageElement | undefined;
|
|
@@ -51,10 +52,23 @@ export class ImageLayer<T> extends CanvasLayer<T> {
|
|
|
51
52
|
this.img.onload = (): void => {
|
|
52
53
|
this.isLoading = false;
|
|
53
54
|
// An extra undefined check should happen here as the execution doesn't happen synchronously
|
|
54
|
-
this.img != null &&
|
|
55
|
+
this.img != null &&
|
|
56
|
+
this.ctx?.drawImage(
|
|
57
|
+
this.img,
|
|
58
|
+
xScale(x || 0),
|
|
59
|
+
yScale(y || 0),
|
|
60
|
+
calcWidth,
|
|
61
|
+
calcHeight,
|
|
62
|
+
);
|
|
55
63
|
};
|
|
56
64
|
} else {
|
|
57
|
-
this.ctx?.drawImage(
|
|
65
|
+
this.ctx?.drawImage(
|
|
66
|
+
this.img,
|
|
67
|
+
xScale(x || 0),
|
|
68
|
+
yScale(y || 0),
|
|
69
|
+
calcWidth,
|
|
70
|
+
calcHeight,
|
|
71
|
+
);
|
|
58
72
|
}
|
|
59
73
|
}
|
|
60
74
|
}
|