@equinor/esv-intersection 3.0.11 → 3.1.0
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 +47 -0
- package/dist/components/axis.d.ts.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/constants.d.ts +12 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/control/ExtendedCurveInterpolator.d.ts +1 -0
- package/dist/control/ExtendedCurveInterpolator.d.ts.map +1 -0
- package/dist/control/IntersectionReferenceSystem.d.ts +93 -0
- package/dist/control/IntersectionReferenceSystem.d.ts.map +1 -0
- package/dist/control/LayerManager.d.ts +77 -0
- package/dist/control/LayerManager.d.ts.map +1 -0
- package/dist/control/MainController.d.ts +155 -0
- package/dist/control/MainController.d.ts.map +1 -0
- package/dist/control/ZoomPanHandler.d.ts +160 -0
- package/dist/control/ZoomPanHandler.d.ts.map +1 -0
- package/dist/control/index.d.ts +6 -0
- package/dist/control/index.d.ts.map +1 -0
- package/dist/control/interfaces.d.ts +37 -0
- package/dist/control/interfaces.d.ts.map +1 -0
- package/dist/control/overlay.d.ts +21 -0
- package/dist/control/overlay.d.ts.map +1 -0
- package/dist/datautils/colortable.d.ts +2 -0
- package/dist/datautils/colortable.d.ts.map +1 -0
- package/dist/datautils/findsample.d.ts +3 -0
- package/dist/datautils/findsample.d.ts.map +1 -0
- package/dist/datautils/index.d.ts +7 -0
- package/dist/datautils/index.d.ts.map +1 -0
- package/dist/datautils/interfaces.d.ts +64 -0
- package/dist/datautils/interfaces.d.ts.map +1 -0
- package/dist/datautils/picks.d.ts +75 -0
- package/dist/datautils/picks.d.ts.map +1 -0
- package/dist/datautils/schematicShapeGenerator.d.ts +60 -0
- package/dist/datautils/schematicShapeGenerator.d.ts.map +1 -0
- package/dist/datautils/seismicimage.d.ts +46 -0
- package/dist/datautils/seismicimage.d.ts.map +1 -0
- package/dist/datautils/surfacedata.d.ts +11 -0
- package/dist/datautils/surfacedata.d.ts.map +1 -0
- package/dist/datautils/trajectory.d.ts +15 -0
- package/dist/datautils/trajectory.d.ts.map +1 -0
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +608 -589
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/interfaces.d.ts +1 -0
- package/dist/interfaces.d.ts.map +1 -0
- package/dist/layers/CalloutCanvasLayer.d.ts +72 -0
- package/dist/layers/CalloutCanvasLayer.d.ts.map +1 -0
- package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts +22 -0
- package/dist/layers/CustomDisplayObjects/ComplexRope.d.ts.map +1 -0
- package/dist/layers/CustomDisplayObjects/ComplexRopeGeometry.d.ts +24 -0
- package/dist/layers/CustomDisplayObjects/ComplexRopeGeometry.d.ts.map +1 -0
- package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts +21 -0
- package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRope.d.ts.map +1 -0
- package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts +27 -0
- package/dist/layers/CustomDisplayObjects/FixedWidthSimpleRopeGeometry.d.ts.map +1 -0
- package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts +18 -0
- package/dist/layers/CustomDisplayObjects/UniformTextureStretchRope.d.ts.map +1 -0
- package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts +25 -0
- package/dist/layers/CustomDisplayObjects/UniformTextureStretchRopeGeometry.d.ts.map +1 -0
- package/dist/layers/GeomodelCanvasLayer.d.ts +29 -0
- package/dist/layers/GeomodelCanvasLayer.d.ts.map +1 -0
- package/dist/layers/GeomodelLabelsLayer.d.ts +50 -0
- package/dist/layers/GeomodelLabelsLayer.d.ts.map +1 -0
- package/dist/layers/GeomodelLayerV2.d.ts +13 -0
- package/dist/layers/GeomodelLayerV2.d.ts.map +1 -0
- package/dist/layers/GridLayer.d.ts +30 -0
- package/dist/layers/GridLayer.d.ts.map +1 -0
- package/dist/layers/ImageCanvasLayer.d.ts +21 -0
- package/dist/layers/ImageCanvasLayer.d.ts.map +1 -0
- package/dist/layers/ReferenceLineLayer.d.ts +29 -0
- package/dist/layers/ReferenceLineLayer.d.ts.map +1 -0
- package/dist/layers/SchematicLayer.d.ts +114 -0
- package/dist/layers/SchematicLayer.d.ts.map +1 -0
- package/dist/layers/SeismicCanvasLayer.d.ts +19 -0
- package/dist/layers/SeismicCanvasLayer.d.ts.map +1 -0
- package/dist/layers/WellborePathLayer.d.ts +18 -0
- package/dist/layers/WellborePathLayer.d.ts.map +1 -0
- package/dist/layers/base/CanvasLayer.d.ts +20 -0
- package/dist/layers/base/CanvasLayer.d.ts.map +1 -0
- package/dist/layers/base/HTMLLayer.d.ts +14 -0
- package/dist/layers/base/HTMLLayer.d.ts.map +1 -0
- package/dist/layers/base/Layer.d.ts +70 -0
- package/dist/layers/base/Layer.d.ts.map +1 -0
- package/dist/layers/base/PixiLayer.d.ts +33 -0
- package/dist/layers/base/PixiLayer.d.ts.map +1 -0
- package/dist/layers/base/SVGLayer.d.ts +14 -0
- package/dist/layers/base/SVGLayer.d.ts.map +1 -0
- package/dist/layers/base/index.d.ts +6 -0
- package/dist/layers/base/index.d.ts.map +1 -0
- package/dist/layers/index.d.ts +17 -0
- package/dist/layers/index.d.ts.map +1 -0
- package/dist/layers/schematicInterfaces.d.ts +210 -0
- package/dist/layers/schematicInterfaces.d.ts.map +1 -0
- package/dist/utils/arc-length.d.ts +1 -0
- package/dist/utils/arc-length.d.ts.map +1 -0
- package/dist/utils/binary-search.d.ts +1 -0
- package/dist/utils/binary-search.d.ts.map +1 -0
- package/dist/utils/color.d.ts +6 -0
- package/dist/utils/color.d.ts.map +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/root-finder.d.ts +1 -0
- package/dist/utils/root-finder.d.ts.map +1 -0
- package/dist/utils/text.d.ts +15 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/vectorUtils.d.ts +16 -0
- package/dist/utils/vectorUtils.d.ts.map +1 -0
- package/dist/vendor/pixi-dashed-line/index.d.ts +57 -0
- package/dist/vendor/pixi-dashed-line/index.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/layers/CalloutCanvasLayer.ts +98 -3
|
@@ -13,6 +13,15 @@ const DEFAULT_OFFSET_MIN = 20;
|
|
|
13
13
|
const DEFAULT_OFFSET_MAX = 120;
|
|
14
14
|
const DEFAULT_OFFSET_FACTOR = 19;
|
|
15
15
|
|
|
16
|
+
const DEFAULT_BACKGROUND_COLOR = 'rgba(0, 0, 0, 0.5)';
|
|
17
|
+
const DEFAULT_BACKGROUND_PADDING = 5;
|
|
18
|
+
const DEFAULT_BACKGROUND_BORDER_RADIUS = 5;
|
|
19
|
+
|
|
20
|
+
/** Input returned if present, defaultValue used as fallback. */
|
|
21
|
+
function getValueOrDefault<T>(input: T | null | undefined, defaultValue: T): T {
|
|
22
|
+
return input === null || input === undefined ? defaultValue : input;
|
|
23
|
+
}
|
|
24
|
+
|
|
16
25
|
const Location = {
|
|
17
26
|
topleft: 'topleft',
|
|
18
27
|
topright: 'topright',
|
|
@@ -44,6 +53,10 @@ export interface CalloutOptions<T extends Annotation[]> extends LayerOptions<T>
|
|
|
44
53
|
offsetMin?: number;
|
|
45
54
|
offsetMax?: number;
|
|
46
55
|
offsetFactor?: number;
|
|
56
|
+
fontColor?: string;
|
|
57
|
+
backgroundColor?: string;
|
|
58
|
+
backgroundPadding?: number;
|
|
59
|
+
backgroundBorderRadius?: number;
|
|
47
60
|
}
|
|
48
61
|
|
|
49
62
|
export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
|
|
@@ -58,6 +71,13 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
|
|
|
58
71
|
offsetMax: number;
|
|
59
72
|
offsetFactor: number;
|
|
60
73
|
|
|
74
|
+
fontColor: string | undefined;
|
|
75
|
+
|
|
76
|
+
backgroundActive: boolean;
|
|
77
|
+
backgroundColor: string;
|
|
78
|
+
backgroundPadding: number;
|
|
79
|
+
backgroundBorderRadius: number;
|
|
80
|
+
|
|
61
81
|
constructor(id?: string, options?: CalloutOptions<T>) {
|
|
62
82
|
super(id, options);
|
|
63
83
|
this.minFontSize = options?.minFontSize || DEFAULT_MIN_FONT_SIZE;
|
|
@@ -66,6 +86,20 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
|
|
|
66
86
|
this.offsetMin = options?.offsetMin || DEFAULT_OFFSET_MIN;
|
|
67
87
|
this.offsetMax = options?.offsetMax || DEFAULT_OFFSET_MAX;
|
|
68
88
|
this.offsetFactor = options?.offsetFactor || DEFAULT_OFFSET_FACTOR;
|
|
89
|
+
|
|
90
|
+
this.fontColor = options?.fontColor;
|
|
91
|
+
|
|
92
|
+
// Set background as active if 'backgroundColor' is defined
|
|
93
|
+
if (options?.backgroundColor) {
|
|
94
|
+
this.backgroundActive = true;
|
|
95
|
+
this.backgroundColor = options.backgroundColor;
|
|
96
|
+
} else {
|
|
97
|
+
this.backgroundActive = false;
|
|
98
|
+
this.backgroundColor = DEFAULT_BACKGROUND_COLOR;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
this.backgroundPadding = options?.backgroundPadding || DEFAULT_BACKGROUND_PADDING;
|
|
102
|
+
this.backgroundBorderRadius = getValueOrDefault(options?.backgroundBorderRadius, DEFAULT_BACKGROUND_BORDER_RADIUS);
|
|
69
103
|
}
|
|
70
104
|
|
|
71
105
|
setGroupFilter(filter: string[]): void {
|
|
@@ -131,6 +165,50 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
|
|
|
131
165
|
});
|
|
132
166
|
}
|
|
133
167
|
|
|
168
|
+
private renderBackground(title: string, label: string, x: number, y: number, fontSize: number): void {
|
|
169
|
+
const { ctx } = this;
|
|
170
|
+
|
|
171
|
+
if (ctx == null) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const padding = this.backgroundPadding;
|
|
176
|
+
const borderRadius = this.backgroundBorderRadius;
|
|
177
|
+
|
|
178
|
+
const titleWidth = this.measureTextWidth(title, fontSize, 'arial', 'bold');
|
|
179
|
+
const labelWidth = this.measureTextWidth(label, fontSize);
|
|
180
|
+
|
|
181
|
+
// Determine width and height of annotation
|
|
182
|
+
const width = Math.max(titleWidth, labelWidth) + padding * 2;
|
|
183
|
+
const height = (fontSize + padding) * 2;
|
|
184
|
+
|
|
185
|
+
const xMin = x - padding;
|
|
186
|
+
const yMin = y - 2 * fontSize - padding;
|
|
187
|
+
|
|
188
|
+
ctx.fillStyle = this.backgroundColor;
|
|
189
|
+
|
|
190
|
+
if (borderRadius > 0) {
|
|
191
|
+
const xMax = xMin + width;
|
|
192
|
+
const yMax = yMin + height;
|
|
193
|
+
|
|
194
|
+
// Draw rounded rect
|
|
195
|
+
ctx.beginPath();
|
|
196
|
+
ctx.moveTo(xMin + borderRadius, yMin); // Top left
|
|
197
|
+
ctx.lineTo(xMax - borderRadius, yMin);
|
|
198
|
+
ctx.quadraticCurveTo(xMax, yMin, xMax, yMin + borderRadius); // Top right corner
|
|
199
|
+
ctx.lineTo(xMax, yMax - borderRadius);
|
|
200
|
+
ctx.quadraticCurveTo(xMax, yMax, xMax - borderRadius, yMax); // Bottom right corner
|
|
201
|
+
ctx.lineTo(xMin + borderRadius, yMax);
|
|
202
|
+
ctx.quadraticCurveTo(xMin, yMax, xMin, yMax - borderRadius); // Bottom left corner
|
|
203
|
+
ctx.lineTo(xMin, yMin + borderRadius);
|
|
204
|
+
ctx.quadraticCurveTo(xMin, yMin, xMin + borderRadius, yMin); // Top left corner
|
|
205
|
+
ctx.fill();
|
|
206
|
+
} else {
|
|
207
|
+
// Draw rect if no border radius
|
|
208
|
+
ctx.fillRect(xMin, yMin, width, height);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
134
212
|
private renderAnnotation = (title: string, label: string, x: number, y: number, fontSize: number, color: string): void => {
|
|
135
213
|
this.renderText(title, x, y - fontSize, fontSize, color, 'arial', 'bold');
|
|
136
214
|
this.renderText(label, x, y, fontSize, color);
|
|
@@ -140,15 +218,27 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
|
|
|
140
218
|
const { ctx } = this;
|
|
141
219
|
if (ctx != null) {
|
|
142
220
|
ctx.font = `${fontStyle} ${fontSize}px ${font}`;
|
|
143
|
-
ctx.fillStyle = color;
|
|
221
|
+
ctx.fillStyle = this.fontColor || color;
|
|
144
222
|
ctx.fillText(title, x, y);
|
|
145
223
|
}
|
|
146
224
|
}
|
|
147
225
|
|
|
148
|
-
private
|
|
226
|
+
private measureTextWidth(title: string, fontSize: number, font = 'arial', fontStyle = 'normal'): number {
|
|
227
|
+
const { ctx } = this;
|
|
228
|
+
|
|
229
|
+
if (ctx == null) {
|
|
230
|
+
return 0;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
ctx.font = `${fontStyle} ${fontSize}px ${font}`;
|
|
234
|
+
return ctx.measureText(title).width;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
private renderPoint(x: number, y: number, color: string, radius = 3): void {
|
|
149
238
|
const { ctx } = this;
|
|
150
239
|
|
|
151
240
|
if (ctx != null) {
|
|
241
|
+
ctx.fillStyle = color;
|
|
152
242
|
ctx.beginPath();
|
|
153
243
|
ctx.moveTo(x, y);
|
|
154
244
|
ctx.arc(x, y, radius, 0, Math.PI * 2);
|
|
@@ -162,8 +252,13 @@ export class CalloutCanvasLayer<T extends Annotation[]> extends CanvasLayer<T> {
|
|
|
162
252
|
const { height, width, x: dotX, y: dotY } = boundingBox;
|
|
163
253
|
|
|
164
254
|
const placeLeft = location === Location.topright || location === Location.bottomright;
|
|
255
|
+
|
|
256
|
+
if (this.backgroundActive) {
|
|
257
|
+
this.renderBackground(title, label, x, y, height);
|
|
258
|
+
}
|
|
259
|
+
|
|
165
260
|
this.renderAnnotation(title, label, x, y, height, color);
|
|
166
|
-
this.renderPoint(dotX, dotY);
|
|
261
|
+
this.renderPoint(dotX, dotY, color);
|
|
167
262
|
this.renderLine(x, y, width, dotX, dotY, color, placeLeft);
|
|
168
263
|
}
|
|
169
264
|
|