@cornerstonejs/core 5.15.2 → 5.16.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.
Files changed (44) hide show
  1. package/dist/esm/RenderingEngine/ECGViewport.d.ts +4 -2
  2. package/dist/esm/RenderingEngine/ECGViewport.js +43 -37
  3. package/dist/esm/RenderingEngine/GenericViewport/ECG/CanvasECGRenderPath.d.ts +1 -5
  4. package/dist/esm/RenderingEngine/GenericViewport/ECG/CanvasECGRenderPath.js +30 -87
  5. package/dist/esm/RenderingEngine/GenericViewport/ECG/DefaultECGDataProvider.d.ts +3 -1
  6. package/dist/esm/RenderingEngine/GenericViewport/ECG/DefaultECGDataProvider.js +5 -3
  7. package/dist/esm/RenderingEngine/GenericViewport/ECG/ECGResolvedView.d.ts +39 -3
  8. package/dist/esm/RenderingEngine/GenericViewport/ECG/ECGResolvedView.js +156 -30
  9. package/dist/esm/RenderingEngine/GenericViewport/ECG/ECGViewport.d.ts +21 -8
  10. package/dist/esm/RenderingEngine/GenericViewport/ECG/ECGViewport.js +147 -54
  11. package/dist/esm/RenderingEngine/GenericViewport/ECG/ECGViewportLegacyAdapter.d.ts +9 -3
  12. package/dist/esm/RenderingEngine/GenericViewport/ECG/ECGViewportLegacyAdapter.js +105 -16
  13. package/dist/esm/RenderingEngine/GenericViewport/ECG/ECGViewportTypes.d.ts +47 -22
  14. package/dist/esm/RenderingEngine/GenericViewport/ECG/ecgDrawing.d.ts +29 -0
  15. package/dist/esm/RenderingEngine/GenericViewport/ECG/ecgDrawing.js +167 -0
  16. package/dist/esm/RenderingEngine/GenericViewport/ECG/ecgGeometry.d.ts +53 -0
  17. package/dist/esm/RenderingEngine/GenericViewport/ECG/ecgGeometry.js +127 -0
  18. package/dist/esm/RenderingEngine/GenericViewport/ECG/ecgProjectionSnapshot.js +13 -7
  19. package/dist/esm/RenderingEngine/GenericViewport/ECG/ecgTraceLayouts.d.ts +40 -0
  20. package/dist/esm/RenderingEngine/GenericViewport/ECG/ecgTraceLayouts.js +175 -0
  21. package/dist/esm/RenderingEngine/GenericViewport/ECG/ecgViewportCamera.d.ts +6 -3
  22. package/dist/esm/RenderingEngine/GenericViewport/ECG/ecgViewportCamera.js +21 -0
  23. package/dist/esm/RenderingEngine/GenericViewport/ECG/ecgWaveform.d.ts +54 -0
  24. package/dist/esm/RenderingEngine/GenericViewport/ECG/ecgWaveform.js +95 -0
  25. package/dist/esm/RenderingEngine/GenericViewport/ECG/index.d.ts +3 -1
  26. package/dist/esm/RenderingEngine/GenericViewport/ECG/index.js +2 -0
  27. package/dist/esm/RenderingEngine/GenericViewport/GenericViewport.js +2 -0
  28. package/dist/esm/RenderingEngine/GenericViewport/Planar/PlanarViewport.js +0 -2
  29. package/dist/esm/RenderingEngine/GenericViewport/genericViewportDisplaySetAccess.d.ts +5 -1
  30. package/dist/esm/RenderingEngine/GenericViewport/genericViewportDisplaySetAccess.js +41 -2
  31. package/dist/esm/RenderingEngine/GenericViewport/index.d.ts +2 -2
  32. package/dist/esm/RenderingEngine/GenericViewport/index.js +1 -1
  33. package/dist/esm/index.d.ts +10 -4
  34. package/dist/esm/index.js +8 -2
  35. package/dist/esm/types/ECGViewportProperties.d.ts +6 -0
  36. package/dist/esm/types/ViewportInputOptions.d.ts +2 -0
  37. package/dist/esm/utilities/index.d.ts +2 -1
  38. package/dist/esm/utilities/index.js +2 -1
  39. package/dist/esm/utilities/scroll.js +5 -0
  40. package/dist/esm/utilities/viewportCapabilities.d.ts +5 -0
  41. package/dist/esm/utilities/viewportCapabilities.js +4 -0
  42. package/dist/esm/version.d.ts +1 -1
  43. package/dist/esm/version.js +1 -1
  44. package/package.json +5 -5
@@ -1,5 +1,5 @@
1
1
  import type { mat4 } from 'gl-matrix';
2
- import type { Point3, Point2, ICamera, ECGViewportInput, ECGWaveformData, ECGViewportProperties, ViewReferenceSpecifier } from '../types/index.js';
2
+ import type { Point3, Point2, ICamera, ECGViewportInput, ECGWaveformData, ECGViewportProperties, ViewReference, ViewReferenceSpecifier, ViewportContentMode } from '../types/index.js';
3
3
  import { Transform } from './helpers/cpuFallback/rendering/transform.js';
4
4
  import Viewport from './Viewport.js';
5
5
  declare class ECGViewport extends Viewport {
@@ -12,6 +12,7 @@ declare class ECGViewport extends Viewport {
12
12
  private ecgWidth;
13
13
  private ecgHeight;
14
14
  private channelScale;
15
+ private layouts;
15
16
  private ecgCamera;
16
17
  constructor(props: ECGViewportInput);
17
18
  static get useCustomRenderingPipeline(): boolean;
@@ -34,7 +35,6 @@ declare class ECGViewport extends Viewport {
34
35
  height: number;
35
36
  };
36
37
  private computeChannelScale;
37
- private recalculateHeight;
38
38
  private computeChannelLayouts;
39
39
  setProperties(props: ECGViewportProperties): void;
40
40
  getProperties: () => ECGViewportProperties;
@@ -51,6 +51,7 @@ declare class ECGViewport extends Viewport {
51
51
  getNumberOfSlices: () => number;
52
52
  getCurrentImageIdIndex: () => number;
53
53
  getCurrentImageId: () => string | undefined;
54
+ getViewReference(specifier?: ViewReferenceSpecifier): ViewReference;
54
55
  getViewReferenceId(_specifier?: ViewReferenceSpecifier): string;
55
56
  hasImageURI(imageURI: string): boolean;
56
57
  isReferenceViewable(viewRef: {
@@ -58,6 +59,7 @@ declare class ECGViewport extends Viewport {
58
59
  }): boolean;
59
60
  getSliceIndex: () => number;
60
61
  getImageIds: () => string[];
62
+ getCurrentMode: () => ViewportContentMode;
61
63
  scroll: () => void;
62
64
  customRenderViewportToCanvas: () => void;
63
65
  updateCameraClippingPlanesAndRange(): void;
@@ -4,8 +4,10 @@ import triggerEvent from '../utilities/triggerEvent.js';
4
4
  import Viewport from './Viewport.js';
5
5
  import { getOrCreateCanvas } from './helpers/index.js';
6
6
  import { getGenericViewportSourceDataId } from './GenericViewport/genericViewportDisplaySetAccess.js';
7
- import { ECG_CHANNEL_SPACING, computeECGChannelLayouts, computeECGHeight, drawECGGrid, drawECGLabels, drawECGTraces, ECG_RENDERING_COLORS, ECG_SECONDS_WIDTH, getVisibleECGChannelsByFlag, loadECGWaveform, } from '../utilities/ECGUtilities.js';
8
- const ECG_AMPLITUDE_INDEX_SIZE = 65536;
7
+ import { ECG_AMPLITUDE_INDEX_SIZE, ECG_RENDERING_COLORS, ECG_SECONDS_WIDTH, getECGFrameOfReferenceUID, loadECGWaveform, } from './GenericViewport/ECG/ecgWaveform.js';
8
+ import { computeECGTraceGeometry, } from './GenericViewport/ECG/ecgGeometry.js';
9
+ import { resolveECGTraceCells, resolveECGTraceLayout, } from './GenericViewport/ECG/ecgTraceLayouts.js';
10
+ import { drawECGGrid, drawECGLabels, drawECGTraces, } from './GenericViewport/ECG/ecgDrawing.js';
9
11
  class ECGViewport extends Viewport {
10
12
  constructor(props) {
11
13
  super({
@@ -18,6 +20,7 @@ class ECGViewport extends Viewport {
18
20
  this.ecgWidth = 0;
19
21
  this.ecgHeight = 0;
20
22
  this.channelScale = 0;
23
+ this.layouts = [];
21
24
  this.ecgCamera = {
22
25
  panWorld: [0, 0],
23
26
  parallelScale: 1,
@@ -36,7 +39,7 @@ class ECGViewport extends Viewport {
36
39
  return true;
37
40
  };
38
41
  this.getFrameOfReferenceUID = () => {
39
- return `ecg-viewport-${this.id}`;
42
+ return getECGFrameOfReferenceUID(this.imageId) ?? `ecg-viewport-${this.id}`;
40
43
  };
41
44
  this.resize = () => {
42
45
  const canvas = this.canvas;
@@ -47,7 +50,6 @@ class ECGViewport extends Viewport {
47
50
  }
48
51
  if (this.waveformData) {
49
52
  this.computeChannelScale();
50
- this.recalculateHeight();
51
53
  }
52
54
  this.refreshRenderValues();
53
55
  this.renderFrame();
@@ -121,6 +123,9 @@ class ECGViewport extends Viewport {
121
123
  this.getImageIds = () => {
122
124
  return this.imageId ? [this.imageId] : [];
123
125
  };
126
+ this.getCurrentMode = () => {
127
+ return this.waveformData ? 'ecg' : 'empty';
128
+ };
124
129
  this.scroll = () => {
125
130
  };
126
131
  this.customRenderViewportToCanvas = () => {
@@ -190,7 +195,6 @@ class ECGViewport extends Viewport {
190
195
  this.ecgWidth = Math.ceil((this.waveformData.numberOfSamples * ECG_SECONDS_WIDTH) /
191
196
  this.waveformData.samplingFrequency);
192
197
  this.computeChannelScale();
193
- this.recalculateHeight();
194
198
  this.refreshRenderValues();
195
199
  this.renderFrame();
196
200
  }
@@ -204,7 +208,6 @@ class ECGViewport extends Viewport {
204
208
  if (index >= 0 && index < this.channels.length) {
205
209
  this.channels[index].visible = visible;
206
210
  this.computeChannelScale();
207
- this.recalculateHeight();
208
211
  this.refreshRenderValues();
209
212
  this.renderFrame();
210
213
  }
@@ -222,32 +225,32 @@ class ECGViewport extends Viewport {
222
225
  return { width: this.ecgWidth, height: this.ecgHeight };
223
226
  }
224
227
  computeChannelScale() {
225
- const visibleChannels = getVisibleECGChannelsByFlag(this.channels);
226
- if (visibleChannels.length === 0 || this.ecgWidth === 0) {
228
+ if (!this.waveformData || this.ecgWidth === 0) {
227
229
  this.channelScale = 0;
230
+ this.layouts = [];
228
231
  return;
229
232
  }
230
- let maxRange = 1;
231
- for (const channel of visibleChannels) {
232
- const range = channel.max - channel.min;
233
- maxRange = Math.max(maxRange, range);
234
- }
233
+ const { numberOfSamples } = this.waveformData;
235
234
  const canvasAspect = this.canvas.offsetHeight && this.canvas.offsetWidth
236
235
  ? this.canvas.offsetHeight / this.canvas.offsetWidth
237
236
  : 2 / 3;
238
- const targetTotalHeight = this.ecgWidth * canvasAspect;
239
- const totalSpacing = ECG_CHANNEL_SPACING * visibleChannels.length;
240
- const heightPerChannel = (targetTotalHeight - totalSpacing) / visibleChannels.length;
241
- this.channelScale = heightPerChannel / (maxRange * 1.25);
242
- }
243
- recalculateHeight() {
244
- this.ecgHeight = computeECGHeight(getVisibleECGChannelsByFlag(this.channels), this.channelScale);
237
+ const cells = resolveECGTraceCells({
238
+ definition: resolveECGTraceLayout('12x1', { channels: this.channels }),
239
+ channels: this.channels,
240
+ numberOfSamples,
241
+ viewSampleWindow: [0, numberOfSamples],
242
+ });
243
+ const geometry = computeECGTraceGeometry({
244
+ cells,
245
+ ecgWidth: this.ecgWidth,
246
+ targetHeight: this.ecgWidth * canvasAspect,
247
+ });
248
+ this.channelScale = geometry.channelScale;
249
+ this.ecgHeight = geometry.ecgHeight;
250
+ this.layouts = geometry.layouts;
245
251
  }
246
252
  computeChannelLayouts() {
247
- return computeECGChannelLayouts({
248
- visibleChannels: getVisibleECGChannelsByFlag(this.channels),
249
- channelScale: this.channelScale,
250
- });
253
+ return this.layouts;
251
254
  }
252
255
  setProperties(props) {
253
256
  if (props.visibleChannels !== undefined) {
@@ -255,7 +258,6 @@ class ECGViewport extends Viewport {
255
258
  this.channels[i].visible = props.visibleChannels.includes(i);
256
259
  }
257
260
  this.computeChannelScale();
258
- this.recalculateHeight();
259
261
  this.refreshRenderValues();
260
262
  this.renderFrame();
261
263
  }
@@ -265,7 +267,6 @@ class ECGViewport extends Viewport {
265
267
  channel.visible = true;
266
268
  }
267
269
  this.computeChannelScale();
268
- this.recalculateHeight();
269
270
  this.refreshRenderValues();
270
271
  this.renderFrame();
271
272
  }
@@ -314,6 +315,14 @@ class ECGViewport extends Viewport {
314
315
  const panWorld = this.ecgCamera.panWorld;
315
316
  return [panWorld[0], panWorld[1]];
316
317
  }
318
+ getViewReference(specifier = {}) {
319
+ const viewReference = super.getViewReference(specifier);
320
+ const lead = specifier.points?.[0]?.[2];
321
+ if (Number.isFinite(lead)) {
322
+ viewReference.sliceIndex = Math.round(lead);
323
+ }
324
+ return viewReference;
325
+ }
317
326
  getViewReferenceId(_specifier) {
318
327
  return `imageId:${this.imageId}`;
319
328
  }
@@ -333,14 +342,16 @@ class ECGViewport extends Viewport {
333
342
  if (!this.ecgWidth || !this.ecgHeight) {
334
343
  return;
335
344
  }
336
- let worldToCanvasRatio = this.canvas.offsetWidth / this.ecgWidth;
337
- if (this.ecgHeight * worldToCanvasRatio > this.canvas.offsetHeight) {
338
- worldToCanvasRatio = this.canvas.offsetHeight / this.ecgHeight;
345
+ const canvasWidth = this.canvas.offsetWidth || this.canvas.width || this.ecgWidth;
346
+ const canvasHeight = this.canvas.offsetHeight || this.canvas.height || this.ecgHeight;
347
+ let worldToCanvasRatio = canvasWidth / this.ecgWidth;
348
+ if (this.ecgHeight * worldToCanvasRatio > canvasHeight) {
349
+ worldToCanvasRatio = canvasHeight / this.ecgHeight;
339
350
  }
340
351
  const drawWidth = Math.floor(this.ecgWidth * worldToCanvasRatio);
341
352
  const drawHeight = Math.floor(this.ecgHeight * worldToCanvasRatio);
342
- const xOffsetCanvas = (this.canvas.offsetWidth - drawWidth) / 2;
343
- const yOffsetCanvas = (this.canvas.offsetHeight - drawHeight) / 2;
353
+ const xOffsetCanvas = (canvasWidth - drawWidth) / 2;
354
+ const yOffsetCanvas = (canvasHeight - drawHeight) / 2;
344
355
  const xOffsetWorld = xOffsetCanvas / worldToCanvasRatio;
345
356
  const yOffsetWorld = yOffsetCanvas / worldToCanvasRatio;
346
357
  this.ecgCamera.panWorld = [xOffsetWorld, yOffsetWorld];
@@ -378,12 +389,7 @@ class ECGViewport extends Viewport {
378
389
  });
379
390
  }
380
391
  drawTraces(ctx, layouts) {
381
- drawECGTraces({
382
- ctx,
383
- layouts,
384
- ecgWidth: this.ecgWidth,
385
- channelScale: this.channelScale,
386
- });
392
+ drawECGTraces({ ctx, layouts });
387
393
  }
388
394
  drawLabels(ctx, layouts) {
389
395
  drawECGLabels(ctx, layouts, this.getWorldToCanvasRatio());
@@ -2,11 +2,7 @@ import { ViewportType } from '../../../enums/index.js';
2
2
  import type { DataAddOptions, LoadedData, RenderPathAttachment, RenderPathDefinition, RenderPath } from '../ViewportArchitectureTypes.js';
3
3
  import type { ECGCanvasRenderContext, ECGDataPresentation } from './ECGViewportTypes.js';
4
4
  export declare class CanvasECGRenderPath implements RenderPath<ECGCanvasRenderContext> {
5
- addData(ctx: ECGCanvasRenderContext, data: LoadedData, options: DataAddOptions): Promise<RenderPathAttachment<ECGDataPresentation>>;
6
- private updateDataPresentation;
7
- private applyViewState;
8
- private getFrameOfReferenceUID;
9
- private render;
5
+ addData(ctx: ECGCanvasRenderContext, _data: LoadedData, _options: DataAddOptions): Promise<RenderPathAttachment<ECGDataPresentation>>;
10
6
  private removeData;
11
7
  }
12
8
  export declare class CanvasECGPath implements RenderPathDefinition<ECGCanvasRenderContext> {
@@ -1,54 +1,30 @@
1
1
  import { Events as EVENTS, ViewportType } from '../../../enums/index.js';
2
2
  import triggerEvent from '../../../utilities/triggerEvent.js';
3
- import { computeECGChannelLayouts, computeECGRenderMetrics, drawECGGrid, drawECGLabels, drawECGTraces, ensureECGCanvasSize, getVisibleECGChannels, } from '../../../utilities/ECGUtilities.js';
4
- import { resolveECGCanvasMapping } from './ecgViewportCamera.js';
3
+ import { drawECGGrid, drawECGCanvasLabels, drawECGTraces, ensureECGCanvasSize, } from './ecgDrawing.js';
5
4
  export class CanvasECGRenderPath {
6
- async addData(ctx, data, options) {
7
- const waveform = data;
5
+ async addData(ctx, _data, _options) {
8
6
  const rendering = {
9
7
  renderMode: 'signal2d',
10
8
  canvas: ctx.canvas,
11
9
  canvasContext: ctx.canvasContext,
12
- metrics: {
13
- ecgWidth: 1,
14
- ecgHeight: 1,
15
- channelScale: 1,
16
- worldToCanvasRatio: 1,
17
- xOffsetCanvas: 0,
18
- yOffsetCanvas: 0,
19
- },
20
10
  };
21
11
  return {
22
12
  rendering,
23
- updateDataPresentation: (props) => {
24
- this.updateDataPresentation(rendering, props);
13
+ updateDataPresentation: () => {
25
14
  },
26
- applyViewState: (camera) => {
27
- this.applyViewState(rendering, camera);
15
+ applyViewState: () => {
28
16
  },
29
17
  getFrameOfReferenceUID: () => {
30
- return this.getFrameOfReferenceUID(ctx);
18
+ return ctx.getResolvedView()?.getFrameOfReferenceUID();
31
19
  },
32
20
  render: () => {
33
- this.render(ctx, rendering, waveform);
21
+ drawFrame(ctx);
34
22
  },
35
23
  removeData: () => {
36
24
  this.removeData();
37
25
  },
38
26
  };
39
27
  }
40
- updateDataPresentation(rendering, props) {
41
- rendering.currentDataPresentation = props;
42
- }
43
- applyViewState(rendering, camera) {
44
- rendering.currentCamera = camera;
45
- }
46
- getFrameOfReferenceUID(ctx) {
47
- return `ecg-viewport-${ctx.viewportId}`;
48
- }
49
- render(ctx, rendering, waveform) {
50
- drawFrame(ctx, rendering, waveform);
51
- }
52
28
  removeData() {
53
29
  }
54
30
  }
@@ -64,81 +40,48 @@ export class CanvasECGPath {
64
40
  return new CanvasECGRenderPath();
65
41
  }
66
42
  }
67
- function getEffectiveTransform(metrics, camera, canvas) {
68
- const mapping = resolveECGCanvasMapping({
69
- metrics,
70
- camera,
71
- canvas,
72
- });
73
- return {
74
- effectiveRatio: mapping.effectiveRatio,
75
- xOffset: mapping.xOffset,
76
- yOffset: mapping.yOffset,
77
- };
78
- }
79
- function computeTimeWindow(waveform, camera) {
80
- const durationMs = (waveform.numberOfSamples / waveform.samplingFrequency) * 1000;
81
- const startMs = Math.max(0, Math.min(camera.timeRange[0], durationMs));
82
- const requestedEnd = Math.max(startMs + 1, camera.timeRange[1]);
83
- const endMs = Math.max(startMs + 1, Math.min(requestedEnd, durationMs));
84
- const startIndex = Math.max(0, Math.min(waveform.numberOfSamples - 1, Math.floor((startMs / 1000) * waveform.samplingFrequency)));
85
- const endIndex = Math.max(startIndex + 1, Math.min(waveform.numberOfSamples, Math.ceil((endMs / 1000) * waveform.samplingFrequency)));
86
- return {
87
- startMs,
88
- endMs,
89
- startIndex,
90
- endIndex,
91
- };
92
- }
93
- function drawFrame(ecgCtx, ecgRendering, waveform) {
94
- const { canvas, canvasContext, currentCamera, currentDataPresentation } = ecgRendering;
95
- if (!currentCamera) {
43
+ function drawFrame(ecgCtx) {
44
+ const { canvas, canvasContext } = ecgCtx;
45
+ ensureECGCanvasSize(canvas);
46
+ const resolvedView = ecgCtx.getResolvedView();
47
+ if (!resolvedView) {
96
48
  return;
97
49
  }
98
- const visibleChannels = getVisibleECGChannels(waveform.channels, currentDataPresentation?.visibleChannels);
99
- ensureECGCanvasSize(canvas);
100
- const metrics = computeECGRenderMetrics({
101
- canvas,
102
- visibleChannels,
103
- windowMs: Math.max(1, currentCamera.timeRange[1] - currentCamera.timeRange[0]),
104
- valueRange: currentCamera.valueRange,
105
- });
106
- const layouts = computeECGChannelLayouts({
107
- visibleChannels,
108
- channelScale: metrics.channelScale,
109
- });
110
- const timeWindow = computeTimeWindow(waveform, currentCamera);
50
+ const viewState = resolvedView.state.viewState;
51
+ const dataPresentation = resolvedView.state.dataPresentation;
52
+ const metrics = resolvedView.metrics;
53
+ const layouts = resolvedView.channelLayouts;
54
+ const { effectiveRatio, xOffset, yOffset } = resolvedView.canvasTransform;
111
55
  const dpr = window.devicePixelRatio || 1;
112
- ecgRendering.metrics = metrics;
113
- const { effectiveRatio, xOffset, yOffset } = getEffectiveTransform(metrics, currentCamera, canvas);
114
56
  canvasContext.resetTransform();
115
57
  canvasContext.fillStyle = '#000000';
116
58
  canvasContext.fillRect(0, 0, canvas.width, canvas.height);
117
- if (currentDataPresentation?.visible === false) {
59
+ if (dataPresentation?.visible === false) {
118
60
  return;
119
61
  }
120
- canvasContext.globalAlpha = currentDataPresentation?.opacity ?? 1;
62
+ canvasContext.globalAlpha = dataPresentation?.opacity ?? 1;
121
63
  canvasContext.setTransform(effectiveRatio * dpr, 0, 0, effectiveRatio * dpr, xOffset * dpr, yOffset * dpr);
122
- drawECGGrid(canvasContext, metrics, {
123
- showGrid: currentDataPresentation?.showGrid,
124
- });
64
+ drawECGGrid(canvasContext, {
65
+ ...metrics,
66
+ sensitivityMmMv: viewState.sensitivityMmMv,
67
+ showAmplitudeLabels: dataPresentation?.showAmplitudeLabels,
68
+ }, {
69
+ showGrid: dataPresentation?.showGrid,
70
+ bounds: resolvedView.canvasBounds,
71
+ }, layouts);
125
72
  drawECGTraces({
126
73
  ctx: canvasContext,
127
74
  layouts,
128
- ecgWidth: metrics.ecgWidth,
129
- channelScale: metrics.channelScale,
130
- startIndex: timeWindow.startIndex,
131
- endIndex: timeWindow.endIndex,
132
- lineWidth: currentDataPresentation?.lineWidth,
133
- amplitudeScale: currentDataPresentation?.amplitudeScale,
75
+ lineWidth: dataPresentation?.lineWidth,
76
+ amplitudeScale: resolvedView.amplitudeScale,
134
77
  });
135
- drawECGLabels(canvasContext, layouts, metrics.worldToCanvasRatio);
136
78
  canvasContext.resetTransform();
79
+ drawECGCanvasLabels(canvasContext, layouts, resolvedView.canvasTransform, dpr);
137
80
  canvasContext.globalAlpha = 1;
138
81
  triggerEvent(ecgCtx.element, EVENTS.IMAGE_RENDERED, {
139
82
  element: ecgCtx.element,
140
83
  viewportId: ecgCtx.viewportId,
141
84
  renderingEngineId: ecgCtx.renderingEngineId,
142
- rendering: ecgRendering,
85
+ resolvedView,
143
86
  });
144
87
  }
@@ -1,5 +1,7 @@
1
1
  import type { DataProvider, LoadedData } from '../ViewportArchitectureTypes.js';
2
2
  import type { ECGWaveformPayload } from './ECGViewportTypes.js';
3
3
  export declare class DefaultECGDataProvider implements DataProvider {
4
- load(dataId: string): Promise<LoadedData<ECGWaveformPayload>>;
4
+ load(dataId: string, options?: {
5
+ multiplexGroupIndex?: number;
6
+ }): Promise<LoadedData<ECGWaveformPayload>>;
5
7
  }
@@ -1,9 +1,11 @@
1
- import { loadECGWaveform } from '../../../utilities/ECGUtilities.js';
1
+ import { loadECGWaveform } from './ecgWaveform.js';
2
2
  import { getGenericViewportSourceDataId } from '../genericViewportDisplaySetAccess.js';
3
3
  export class DefaultECGDataProvider {
4
- async load(dataId) {
4
+ async load(dataId, options) {
5
5
  const sourceDataId = getGenericViewportSourceDataId(dataId);
6
- const { waveform } = await loadECGWaveform(sourceDataId);
6
+ const { waveform } = await loadECGWaveform(sourceDataId, {
7
+ multiplexGroupIndex: options?.multiplexGroupIndex,
8
+ });
7
9
  return {
8
10
  id: dataId,
9
11
  type: 'ecg',
@@ -1,26 +1,62 @@
1
1
  import type { ICamera, Point2, Point3 } from '../../../types/index.js';
2
+ import { type ECGChannelLayout, type ECGRenderMetrics } from './ecgGeometry.js';
3
+ import { type ECGLeadGroup, type ECGTraceCell } from './ecgTraceLayouts.js';
2
4
  import ResolvedViewportView from '../ResolvedViewportView.js';
3
- import type { ECGViewState, ECGDataPresentation, ECGWaveformPayload, RenderWindowMetrics } from './ECGViewportTypes.js';
5
+ import type { ECGViewState, ECGChannelData, ECGDataPresentation, ECGTraceLayoutDefinition, ECGWaveformPayload } from './ECGViewportTypes.js';
4
6
  type ECGResolvedViewState = {
5
7
  viewState: ECGViewState;
6
8
  canvas: HTMLCanvasElement;
7
9
  dataPresentation?: ECGDataPresentation;
8
10
  frameOfReferenceUID: string;
9
- metrics: RenderWindowMetrics;
10
11
  waveform: ECGWaveformPayload;
11
12
  };
13
+ export type ECGCanvasTransform = {
14
+ effectiveRatio: number;
15
+ xOffset: number;
16
+ yOffset: number;
17
+ };
18
+ type ECGTimeWindow = {
19
+ startMs: number;
20
+ endMs: number;
21
+ startSample: number;
22
+ endSample: number;
23
+ };
12
24
  declare class ECGResolvedView extends ResolvedViewportView<ECGResolvedViewState> {
13
25
  private cachedCanvasMapping?;
26
+ private cachedGeometry?;
27
+ private cachedTimeWindow?;
28
+ private cachedDefinition?;
29
+ private cachedCells?;
14
30
  get zoom(): number;
15
31
  get pan(): Point2;
32
+ get metrics(): ECGRenderMetrics;
33
+ get traceLayoutName(): string | undefined;
34
+ private get traceLayoutContext();
35
+ get traceLayout(): ECGTraceLayoutDefinition;
36
+ get traceCells(): ECGTraceCell<ECGChannelData>[];
37
+ get timeWindow(): ECGTimeWindow;
38
+ get amplitudeScale(): number;
39
+ get channelLayouts(): ECGChannelLayout<ECGChannelData>[];
40
+ get canvasTransform(): ECGCanvasTransform;
41
+ get canvasBounds(): {
42
+ minX: number;
43
+ minY: number;
44
+ maxX: number;
45
+ maxY: number;
46
+ };
47
+ get leadGroup(): ECGLeadGroup;
48
+ findLayoutForZ(z: number): ECGChannelLayout<ECGChannelData> | undefined;
16
49
  canvasToWorld(canvasPos: Point2): Point3;
50
+ private canvasToWorldUnclamped;
17
51
  worldToCanvas(worldPos: Point3): Point2;
18
52
  getFrameOfReferenceUID(): string | undefined;
19
53
  withZoom(zoom: number, canvasPoint?: Point2): ECGResolvedView;
20
54
  withPan(pan: Point2): ECGResolvedView;
21
55
  protected buildICamera(): ICamera;
22
56
  private getCanvasMapping;
23
- private getChannelLayouts;
57
+ private getDistanceToCell;
58
+ private getDrawnScale;
59
+ private getGeometry;
24
60
  private cloneWithViewState;
25
61
  }
26
62
  export type { ECGResolvedViewState };