@cornerstonejs/core 4.0.0-beta.3 → 4.0.0-beta.4

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 (75) hide show
  1. package/dist/esm/RenderingEngine/BaseRenderingEngine.d.ts +55 -0
  2. package/dist/esm/RenderingEngine/BaseRenderingEngine.js +355 -0
  3. package/dist/esm/RenderingEngine/BaseVolumeViewport.d.ts +34 -5
  4. package/dist/esm/RenderingEngine/BaseVolumeViewport.js +179 -17
  5. package/dist/esm/RenderingEngine/ContextPoolRenderingEngine.d.ts +28 -0
  6. package/dist/esm/RenderingEngine/ContextPoolRenderingEngine.js +313 -0
  7. package/dist/esm/RenderingEngine/RenderingEngine.d.ts +7 -39
  8. package/dist/esm/RenderingEngine/RenderingEngine.js +42 -613
  9. package/dist/esm/RenderingEngine/StackViewport.d.ts +6 -3
  10. package/dist/esm/RenderingEngine/StackViewport.js +92 -8
  11. package/dist/esm/RenderingEngine/TiledRenderingEngine.d.ts +24 -0
  12. package/dist/esm/RenderingEngine/TiledRenderingEngine.js +287 -0
  13. package/dist/esm/RenderingEngine/VideoViewport.js +1 -1
  14. package/dist/esm/RenderingEngine/Viewport.d.ts +2 -1
  15. package/dist/esm/RenderingEngine/Viewport.js +38 -1
  16. package/dist/esm/RenderingEngine/VolumeViewport3D.d.ts +1 -0
  17. package/dist/esm/RenderingEngine/VolumeViewport3D.js +24 -1
  18. package/dist/esm/RenderingEngine/WSIViewport.js +4 -7
  19. package/dist/esm/RenderingEngine/WebGLContextPool.d.ts +17 -0
  20. package/dist/esm/RenderingEngine/WebGLContextPool.js +45 -0
  21. package/dist/esm/RenderingEngine/helpers/createVolumeMapper.js +3 -1
  22. package/dist/esm/RenderingEngine/helpers/isContextPoolRenderingEngine.d.ts +1 -0
  23. package/dist/esm/RenderingEngine/helpers/isContextPoolRenderingEngine.js +7 -0
  24. package/dist/esm/RenderingEngine/helpers/stats/StatsOverlay.d.ts +28 -0
  25. package/dist/esm/RenderingEngine/helpers/stats/StatsOverlay.js +137 -0
  26. package/dist/esm/RenderingEngine/helpers/stats/StatsPanel.d.ts +24 -0
  27. package/dist/esm/RenderingEngine/helpers/stats/StatsPanel.js +101 -0
  28. package/dist/esm/RenderingEngine/helpers/stats/constants.d.ts +44 -0
  29. package/dist/esm/RenderingEngine/helpers/stats/constants.js +36 -0
  30. package/dist/esm/RenderingEngine/helpers/stats/enums.d.ts +6 -0
  31. package/dist/esm/RenderingEngine/helpers/stats/enums.js +7 -0
  32. package/dist/esm/RenderingEngine/helpers/stats/index.d.ts +2 -0
  33. package/dist/esm/RenderingEngine/helpers/stats/index.js +2 -0
  34. package/dist/esm/RenderingEngine/helpers/stats/types.d.ts +22 -0
  35. package/dist/esm/RenderingEngine/helpers/stats/types.js +0 -0
  36. package/dist/esm/RenderingEngine/index.d.ts +4 -1
  37. package/dist/esm/RenderingEngine/index.js +4 -1
  38. package/dist/esm/cache/cache.js +0 -1
  39. package/dist/esm/cache/classes/BaseStreamingImageVolume.d.ts +2 -0
  40. package/dist/esm/cache/classes/BaseStreamingImageVolume.js +8 -0
  41. package/dist/esm/cache/classes/StreamingDynamicImageVolume.d.ts +1 -0
  42. package/dist/esm/enums/RenderingEngineModeEnum.d.ts +5 -0
  43. package/dist/esm/enums/RenderingEngineModeEnum.js +6 -0
  44. package/dist/esm/enums/index.d.ts +2 -1
  45. package/dist/esm/enums/index.js +2 -1
  46. package/dist/esm/index.d.ts +2 -2
  47. package/dist/esm/index.js +2 -2
  48. package/dist/esm/init.js +12 -0
  49. package/dist/esm/loaders/volumeLoader.js +2 -2
  50. package/dist/esm/types/Cornerstone3DConfig.d.ts +16 -7
  51. package/dist/esm/types/IRenderingEngine.d.ts +1 -1
  52. package/dist/esm/types/IViewport.d.ts +9 -2
  53. package/dist/esm/types/OrientationVectors.d.ts +1 -1
  54. package/dist/esm/types/RenderingEngineMode.d.ts +2 -0
  55. package/dist/esm/types/RenderingEngineMode.js +0 -0
  56. package/dist/esm/types/ViewportProperties.d.ts +1 -0
  57. package/dist/esm/types/VtkOffscreenMultiRenderWindow.d.ts +37 -0
  58. package/dist/esm/types/VtkOffscreenMultiRenderWindow.js +5 -0
  59. package/dist/esm/types/index.d.ts +3 -1
  60. package/dist/esm/utilities/asArray.d.ts +1 -0
  61. package/dist/esm/utilities/asArray.js +6 -0
  62. package/dist/esm/utilities/colormap.js +4 -2
  63. package/dist/esm/utilities/getPixelSpacingInformation.js +4 -1
  64. package/dist/esm/utilities/historyMemo/index.d.ts +10 -1
  65. package/dist/esm/utilities/historyMemo/index.js +62 -20
  66. package/dist/esm/utilities/index.d.ts +3 -1
  67. package/dist/esm/utilities/index.js +3 -1
  68. package/dist/esm/utilities/isEqual.d.ts +5 -5
  69. package/dist/esm/utilities/isEqual.js +5 -5
  70. package/dist/esm/utilities/renderToCanvasGPU.js +2 -2
  71. package/dist/esm/utilities/updatePlaneRestriction.d.ts +2 -0
  72. package/dist/esm/utilities/updatePlaneRestriction.js +41 -0
  73. package/dist/esm/version.d.ts +1 -1
  74. package/dist/esm/version.js +1 -1
  75. package/package.json +3 -3
@@ -8,11 +8,8 @@ import { getOrCreateCanvas } from './helpers';
8
8
  import { EPSILON } from '../constants';
9
9
  import triggerEvent from '../utilities/triggerEvent';
10
10
  import { peerImport } from '../init';
11
- import { pointInShapeCallback } from '../utilities/pointInShapeCallback';
12
11
  import microscopyViewportCss from '../constants/microscopyViewportCss';
13
12
  let WSIUtilFunctions = null;
14
- const _map = Symbol.for('map');
15
- const affineSymbol = Symbol.for('affine');
16
13
  const EVENT_POSTRENDER = 'postrender';
17
14
  class WSIViewport extends Viewport {
18
15
  constructor(props) {
@@ -324,7 +321,7 @@ class WSIViewport extends Viewport {
324
321
  if (!WSIUtilFunctions) {
325
322
  return;
326
323
  }
327
- const affine = this.viewer[affineSymbol];
324
+ const affine = this.viewer.getAffine();
328
325
  const pixelCoords = WSIUtilFunctions.applyInverseTransform({
329
326
  coordinate: [point[0], point[1]],
330
327
  affine,
@@ -337,7 +334,7 @@ class WSIViewport extends Viewport {
337
334
  }
338
335
  const sliceCoords = WSIUtilFunctions.applyTransform({
339
336
  coordinate: [point[0], point[1]],
340
- affine: this.viewer[affineSymbol],
337
+ affine: this.viewer.getAffine(),
341
338
  });
342
339
  return [sliceCoords[0], sliceCoords[1], 0];
343
340
  }
@@ -420,7 +417,7 @@ class WSIViewport extends Viewport {
420
417
  this.metadata = this.getImageDataMetadata();
421
418
  viewer.deactivateDragPanInteraction();
422
419
  this.viewer = viewer;
423
- this.map = viewer[_map];
420
+ this.map = viewer.getMap();
424
421
  this.map.on(EVENT_POSTRENDER, this.postrender);
425
422
  this.resize();
426
423
  this.microscopyElement.innerText = '';
@@ -445,7 +442,7 @@ class WSIViewport extends Viewport {
445
442
  if (!this.viewer) {
446
443
  return;
447
444
  }
448
- const map = this.viewer[_map];
445
+ const map = this.viewer.getMap();
449
446
  const anyWindow = window;
450
447
  anyWindow.map = map;
451
448
  anyWindow.viewer = this.viewer;
@@ -0,0 +1,17 @@
1
+ import type { VtkOffscreenMultiRenderWindow } from '../types';
2
+ declare class WebGLContextPool {
3
+ private contexts;
4
+ private offScreenCanvasContainers;
5
+ private viewportToContext;
6
+ constructor(count: number);
7
+ getContextByIndex(index: number): {
8
+ context: VtkOffscreenMultiRenderWindow;
9
+ container: HTMLDivElement;
10
+ } | null;
11
+ assignViewportToContext(viewportId: string, contextIndex: number): void;
12
+ getContextIndexForViewport(viewportId: string): number | undefined;
13
+ getAllContexts(): VtkOffscreenMultiRenderWindow[];
14
+ getContextCount(): number;
15
+ destroy(): void;
16
+ }
17
+ export default WebGLContextPool;
@@ -0,0 +1,45 @@
1
+ import { vtkOffscreenMultiRenderWindow } from './vtkClasses';
2
+ class WebGLContextPool {
3
+ constructor(count) {
4
+ this.contexts = [];
5
+ this.offScreenCanvasContainers = [];
6
+ this.viewportToContext = new Map();
7
+ for (let i = 0; i < count; i++) {
8
+ const offscreenMultiRenderWindow = vtkOffscreenMultiRenderWindow.newInstance();
9
+ const container = document.createElement('div');
10
+ offscreenMultiRenderWindow.setContainer(container);
11
+ this.contexts.push(offscreenMultiRenderWindow);
12
+ this.offScreenCanvasContainers.push(container);
13
+ }
14
+ }
15
+ getContextByIndex(index) {
16
+ if (index >= 0 && index < this.contexts.length) {
17
+ return {
18
+ context: this.contexts[index],
19
+ container: this.offScreenCanvasContainers[index],
20
+ };
21
+ }
22
+ return null;
23
+ }
24
+ assignViewportToContext(viewportId, contextIndex) {
25
+ this.viewportToContext.set(viewportId, contextIndex);
26
+ }
27
+ getContextIndexForViewport(viewportId) {
28
+ return this.viewportToContext.get(viewportId);
29
+ }
30
+ getAllContexts() {
31
+ return this.contexts;
32
+ }
33
+ getContextCount() {
34
+ return this.contexts.length;
35
+ }
36
+ destroy() {
37
+ this.contexts.forEach((context) => {
38
+ context.delete();
39
+ });
40
+ this.contexts = [];
41
+ this.offScreenCanvasContainers = [];
42
+ this.viewportToContext.clear();
43
+ }
44
+ }
45
+ export default WebGLContextPool;
@@ -9,7 +9,9 @@ export default function createVolumeMapper(imageData, vtkOpenGLTexture) {
9
9
  }
10
10
  volumeMapper.setInputData(imageData);
11
11
  const spacing = imageData.getSpacing();
12
- const sampleDistance = (spacing[0] + spacing[1] + spacing[2]) / 6;
12
+ const sampleDistanceMultiplier = getConfiguration().rendering?.volumeRendering?.sampleDistanceMultiplier ||
13
+ 1;
14
+ const sampleDistance = (sampleDistanceMultiplier * (spacing[0] + spacing[1] + spacing[2])) / 6;
13
15
  volumeMapper.setMaximumSamplesPerRay(4000);
14
16
  volumeMapper.setSampleDistance(sampleDistance);
15
17
  volumeMapper.setScalarTexture(vtkOpenGLTexture);
@@ -0,0 +1 @@
1
+ export declare function isContextPoolRenderingEngine(): boolean;
@@ -0,0 +1,7 @@
1
+ import { getConfiguration } from '../../init';
2
+ import { RenderingEngineModeEnum } from '../../enums';
3
+ export function isContextPoolRenderingEngine() {
4
+ const config = getConfiguration();
5
+ return (config?.rendering?.renderingEngineMode ===
6
+ RenderingEngineModeEnum.ContextPool);
7
+ }
@@ -0,0 +1,28 @@
1
+ import type { StatsInstance } from './types';
2
+ export declare class StatsOverlay implements StatsInstance {
3
+ private static instance;
4
+ dom: HTMLDivElement | null;
5
+ private currentMode;
6
+ private startTime;
7
+ private lastUpdateTime;
8
+ private frameCount;
9
+ private panels;
10
+ private animationFrameId;
11
+ private isSetup;
12
+ private constructor();
13
+ static getInstance(): StatsOverlay;
14
+ setup(): void;
15
+ cleanup(): void;
16
+ showPanel(panelType: number): void;
17
+ update(): void;
18
+ private createOverlayElement;
19
+ private applyOverlayStyles;
20
+ private handleClick;
21
+ private initializePanels;
22
+ private isMemoryAvailable;
23
+ private addPanel;
24
+ private startLoop;
25
+ private stopLoop;
26
+ private updateStats;
27
+ private updateMemoryPanel;
28
+ }
@@ -0,0 +1,137 @@
1
+ import { StatsPanel } from './StatsPanel';
2
+ import { PanelType } from './enums';
3
+ import { STATS_CONFIG, PANEL_CONFIGS, CONVERSION } from './constants';
4
+ export class StatsOverlay {
5
+ static { this.instance = null; }
6
+ constructor() {
7
+ this.dom = null;
8
+ this.currentMode = 0;
9
+ this.startTime = 0;
10
+ this.lastUpdateTime = 0;
11
+ this.frameCount = 0;
12
+ this.panels = new Map();
13
+ this.animationFrameId = null;
14
+ this.isSetup = false;
15
+ }
16
+ static getInstance() {
17
+ if (!StatsOverlay.instance) {
18
+ StatsOverlay.instance = new StatsOverlay();
19
+ }
20
+ return StatsOverlay.instance;
21
+ }
22
+ setup() {
23
+ if (this.isSetup) {
24
+ return;
25
+ }
26
+ try {
27
+ this.dom = this.createOverlayElement();
28
+ this.startTime = performance.now();
29
+ this.lastUpdateTime = this.startTime;
30
+ this.initializePanels();
31
+ this.showPanel(PanelType.FPS);
32
+ this.applyOverlayStyles();
33
+ document.body.appendChild(this.dom);
34
+ this.startLoop();
35
+ this.isSetup = true;
36
+ }
37
+ catch (error) {
38
+ console.warn('Failed to setup stats overlay:', error);
39
+ }
40
+ }
41
+ cleanup() {
42
+ this.stopLoop();
43
+ if (this.dom && this.dom.parentNode) {
44
+ this.dom.parentNode.removeChild(this.dom);
45
+ }
46
+ this.dom = null;
47
+ this.panels.clear();
48
+ this.isSetup = false;
49
+ }
50
+ showPanel(panelType) {
51
+ const children = Array.from(this.dom.children);
52
+ children.forEach((child, index) => {
53
+ child.style.display = index === panelType ? 'block' : 'none';
54
+ });
55
+ this.currentMode = panelType;
56
+ }
57
+ update() {
58
+ this.startTime = this.updateStats();
59
+ }
60
+ createOverlayElement() {
61
+ const element = document.createElement('div');
62
+ element.addEventListener('click', this.handleClick.bind(this), false);
63
+ return element;
64
+ }
65
+ applyOverlayStyles() {
66
+ Object.assign(this.dom.style, STATS_CONFIG.OVERLAY_STYLES);
67
+ }
68
+ handleClick(event) {
69
+ event.preventDefault();
70
+ const panelCount = this.dom.children.length;
71
+ this.showPanel((this.currentMode + 1) % panelCount);
72
+ }
73
+ initializePanels() {
74
+ const fpsPanel = new StatsPanel(PANEL_CONFIGS[PanelType.FPS].name, PANEL_CONFIGS[PanelType.FPS].foregroundColor, PANEL_CONFIGS[PanelType.FPS].backgroundColor);
75
+ this.addPanel(PanelType.FPS, fpsPanel);
76
+ const msPanel = new StatsPanel(PANEL_CONFIGS[PanelType.MS].name, PANEL_CONFIGS[PanelType.MS].foregroundColor, PANEL_CONFIGS[PanelType.MS].backgroundColor);
77
+ this.addPanel(PanelType.MS, msPanel);
78
+ if (this.isMemoryAvailable()) {
79
+ const memPanel = new StatsPanel(PANEL_CONFIGS[PanelType.MEMORY].name, PANEL_CONFIGS[PanelType.MEMORY].foregroundColor, PANEL_CONFIGS[PanelType.MEMORY].backgroundColor);
80
+ this.addPanel(PanelType.MEMORY, memPanel);
81
+ }
82
+ }
83
+ isMemoryAvailable() {
84
+ const perf = performance;
85
+ return perf.memory !== undefined;
86
+ }
87
+ addPanel(type, panel) {
88
+ this.dom.appendChild(panel.dom);
89
+ this.panels.set(type, panel);
90
+ }
91
+ startLoop() {
92
+ const loop = () => {
93
+ this.update();
94
+ this.animationFrameId = requestAnimationFrame(loop);
95
+ };
96
+ this.animationFrameId = requestAnimationFrame(loop);
97
+ }
98
+ stopLoop() {
99
+ if (this.animationFrameId !== null) {
100
+ cancelAnimationFrame(this.animationFrameId);
101
+ this.animationFrameId = null;
102
+ }
103
+ }
104
+ updateStats() {
105
+ this.frameCount++;
106
+ const currentTime = performance.now();
107
+ const deltaTime = currentTime - this.startTime;
108
+ const msPanel = this.panels.get(PanelType.MS);
109
+ if (msPanel) {
110
+ msPanel.update(deltaTime, STATS_CONFIG.MAX_MS_VALUE);
111
+ }
112
+ if (currentTime >= this.lastUpdateTime + STATS_CONFIG.UPDATE_INTERVAL) {
113
+ const fps = (this.frameCount * CONVERSION.MS_PER_SECOND) /
114
+ (currentTime - this.lastUpdateTime);
115
+ const fpsPanel = this.panels.get(PanelType.FPS);
116
+ if (fpsPanel) {
117
+ fpsPanel.update(fps, STATS_CONFIG.MAX_FPS_VALUE);
118
+ }
119
+ this.lastUpdateTime = currentTime;
120
+ this.frameCount = 0;
121
+ this.updateMemoryPanel();
122
+ }
123
+ return currentTime;
124
+ }
125
+ updateMemoryPanel() {
126
+ const memPanel = this.panels.get(PanelType.MEMORY);
127
+ if (!memPanel) {
128
+ return;
129
+ }
130
+ const perf = performance;
131
+ if (perf.memory) {
132
+ const memoryMB = perf.memory.usedJSHeapSize / CONVERSION.BYTES_TO_MB;
133
+ const maxMemoryMB = perf.memory.jsHeapSizeLimit / CONVERSION.BYTES_TO_MB;
134
+ memPanel.update(memoryMB, maxMemoryMB);
135
+ }
136
+ }
137
+ }
@@ -0,0 +1,24 @@
1
+ import type { Panel } from './types';
2
+ export declare class StatsPanel implements Panel {
3
+ dom: HTMLCanvasElement;
4
+ private context;
5
+ private minValue;
6
+ private maxValue;
7
+ private readonly name;
8
+ private readonly foregroundColor;
9
+ private readonly backgroundColor;
10
+ private readonly devicePixelRatio;
11
+ private readonly dimensions;
12
+ constructor(name: string, foregroundColor: string, backgroundColor: string);
13
+ update(value: number, maxValue: number): void;
14
+ private calculateDimensions;
15
+ private createCanvas;
16
+ private initializeContext;
17
+ private drawInitialPanel;
18
+ private updateMinMax;
19
+ private clearTextArea;
20
+ private drawText;
21
+ private formatText;
22
+ private scrollGraph;
23
+ private drawNewValue;
24
+ }
@@ -0,0 +1,101 @@
1
+ import { PANEL_CONFIG } from './constants';
2
+ export class StatsPanel {
3
+ constructor(name, foregroundColor, backgroundColor) {
4
+ this.minValue = Infinity;
5
+ this.maxValue = 0;
6
+ this.name = name;
7
+ this.foregroundColor = foregroundColor;
8
+ this.backgroundColor = backgroundColor;
9
+ this.devicePixelRatio = Math.round(window.devicePixelRatio || 1);
10
+ this.dimensions = this.calculateDimensions();
11
+ this.dom = this.createCanvas();
12
+ this.context = this.initializeContext();
13
+ this.drawInitialPanel();
14
+ }
15
+ update(value, maxValue) {
16
+ this.updateMinMax(value);
17
+ this.clearTextArea();
18
+ this.drawText(value);
19
+ this.scrollGraph();
20
+ this.drawNewValue(value, maxValue);
21
+ }
22
+ calculateDimensions() {
23
+ const pr = this.devicePixelRatio;
24
+ return {
25
+ width: PANEL_CONFIG.WIDTH * pr,
26
+ height: PANEL_CONFIG.HEIGHT * pr,
27
+ textX: PANEL_CONFIG.TEXT_PADDING * pr,
28
+ textY: PANEL_CONFIG.TEXT_Y_OFFSET * pr,
29
+ graphX: PANEL_CONFIG.TEXT_PADDING * pr,
30
+ graphY: PANEL_CONFIG.GRAPH_Y_OFFSET * pr,
31
+ graphWidth: PANEL_CONFIG.GRAPH_WIDTH * pr,
32
+ graphHeight: PANEL_CONFIG.GRAPH_HEIGHT * pr,
33
+ };
34
+ }
35
+ createCanvas() {
36
+ const canvas = document.createElement('canvas');
37
+ canvas.width = this.dimensions.width;
38
+ canvas.height = this.dimensions.height;
39
+ canvas.style.cssText = `width:${PANEL_CONFIG.WIDTH}px;height:${PANEL_CONFIG.HEIGHT}px`;
40
+ return canvas;
41
+ }
42
+ initializeContext() {
43
+ const ctx = this.dom.getContext('2d');
44
+ if (!ctx) {
45
+ throw new Error('Failed to get 2D context');
46
+ }
47
+ ctx.font = `bold ${PANEL_CONFIG.FONT_SIZE * this.devicePixelRatio}px ${PANEL_CONFIG.FONT_FAMILY}`;
48
+ ctx.textBaseline = 'top';
49
+ return ctx;
50
+ }
51
+ drawInitialPanel() {
52
+ const { width, height, textX, textY, graphX, graphY, graphWidth, graphHeight, } = this.dimensions;
53
+ this.context.fillStyle = this.backgroundColor;
54
+ this.context.fillRect(0, 0, width, height);
55
+ this.context.fillStyle = this.foregroundColor;
56
+ this.context.fillText(this.name, textX, textY);
57
+ this.context.fillRect(graphX, graphY, graphWidth, graphHeight);
58
+ this.context.fillStyle = this.backgroundColor;
59
+ this.context.globalAlpha = PANEL_CONFIG.GRAPH_ALPHA;
60
+ this.context.fillRect(graphX, graphY, graphWidth, graphHeight);
61
+ this.context.globalAlpha = 1;
62
+ }
63
+ updateMinMax(value) {
64
+ this.minValue = Math.min(this.minValue, value);
65
+ this.maxValue = Math.max(this.maxValue, value);
66
+ }
67
+ clearTextArea() {
68
+ const { width, graphY } = this.dimensions;
69
+ this.context.fillStyle = this.backgroundColor;
70
+ this.context.fillRect(0, 0, width, graphY);
71
+ }
72
+ drawText(value) {
73
+ const { textX, textY } = this.dimensions;
74
+ const text = this.formatText(value);
75
+ this.context.fillStyle = this.foregroundColor;
76
+ this.context.fillText(text, textX, textY);
77
+ }
78
+ formatText(value) {
79
+ const roundedValue = Math.round(value);
80
+ const roundedMin = Math.round(this.minValue);
81
+ const roundedMax = Math.round(this.maxValue);
82
+ return `${roundedValue} ${this.name} (${roundedMin}-${roundedMax})`;
83
+ }
84
+ scrollGraph() {
85
+ const { graphX, graphY, graphWidth, graphHeight } = this.dimensions;
86
+ const pr = this.devicePixelRatio;
87
+ this.context.drawImage(this.dom, graphX + pr, graphY, graphWidth - pr, graphHeight, graphX, graphY, graphWidth - pr, graphHeight);
88
+ }
89
+ drawNewValue(value, maxValue) {
90
+ const { graphX, graphY, graphWidth, graphHeight } = this.dimensions;
91
+ const pr = this.devicePixelRatio;
92
+ const x = graphX + graphWidth - pr;
93
+ this.context.fillStyle = this.foregroundColor;
94
+ this.context.fillRect(x, graphY, pr, graphHeight);
95
+ const normalizedHeight = Math.round((1 - value / maxValue) * graphHeight);
96
+ this.context.fillStyle = this.backgroundColor;
97
+ this.context.globalAlpha = PANEL_CONFIG.GRAPH_ALPHA;
98
+ this.context.fillRect(x, graphY, pr, normalizedHeight);
99
+ this.context.globalAlpha = 1;
100
+ }
101
+ }
@@ -0,0 +1,44 @@
1
+ declare const PANEL_CONFIG: {
2
+ readonly WIDTH: 160;
3
+ readonly HEIGHT: 96;
4
+ readonly TEXT_PADDING: 3;
5
+ readonly TEXT_Y_OFFSET: 2;
6
+ readonly GRAPH_Y_OFFSET: 15;
7
+ readonly GRAPH_WIDTH: 150;
8
+ readonly GRAPH_HEIGHT: 70;
9
+ readonly FONT_SIZE: 9;
10
+ readonly FONT_FAMILY: "Helvetica,Arial,sans-serif";
11
+ readonly GRAPH_ALPHA: 0.9;
12
+ };
13
+ declare const STATS_CONFIG: {
14
+ readonly UPDATE_INTERVAL: 1000;
15
+ readonly MAX_MS_VALUE: 200;
16
+ readonly MAX_FPS_VALUE: 300;
17
+ readonly OVERLAY_STYLES: {
18
+ readonly position: "fixed";
19
+ readonly top: "0px";
20
+ readonly right: "0px";
21
+ readonly left: "auto";
22
+ readonly zIndex: "9999";
23
+ readonly cursor: "pointer";
24
+ readonly opacity: "0.9";
25
+ };
26
+ };
27
+ declare const CONVERSION: {
28
+ readonly BYTES_TO_MB: 1048576;
29
+ readonly MS_PER_SECOND: 1000;
30
+ };
31
+ declare const PANEL_CONFIGS: readonly [{
32
+ readonly name: "FPS";
33
+ readonly foregroundColor: "#0ff";
34
+ readonly backgroundColor: "#002";
35
+ }, {
36
+ readonly name: "MS";
37
+ readonly foregroundColor: "#0f0";
38
+ readonly backgroundColor: "#020";
39
+ }, {
40
+ readonly name: "MB";
41
+ readonly foregroundColor: "#f08";
42
+ readonly backgroundColor: "#201";
43
+ }];
44
+ export { PANEL_CONFIG, STATS_CONFIG, CONVERSION, PANEL_CONFIGS };
@@ -0,0 +1,36 @@
1
+ const PANEL_CONFIG = {
2
+ WIDTH: 160,
3
+ HEIGHT: 96,
4
+ TEXT_PADDING: 3,
5
+ TEXT_Y_OFFSET: 2,
6
+ GRAPH_Y_OFFSET: 15,
7
+ GRAPH_WIDTH: 150,
8
+ GRAPH_HEIGHT: 70,
9
+ FONT_SIZE: 9,
10
+ FONT_FAMILY: 'Helvetica,Arial,sans-serif',
11
+ GRAPH_ALPHA: 0.9,
12
+ };
13
+ const STATS_CONFIG = {
14
+ UPDATE_INTERVAL: 1000,
15
+ MAX_MS_VALUE: 200,
16
+ MAX_FPS_VALUE: 300,
17
+ OVERLAY_STYLES: {
18
+ position: 'fixed',
19
+ top: '0px',
20
+ right: '0px',
21
+ left: 'auto',
22
+ zIndex: '9999',
23
+ cursor: 'pointer',
24
+ opacity: '0.9',
25
+ },
26
+ };
27
+ const CONVERSION = {
28
+ BYTES_TO_MB: 1048576,
29
+ MS_PER_SECOND: 1000,
30
+ };
31
+ const PANEL_CONFIGS = [
32
+ { name: 'FPS', foregroundColor: '#0ff', backgroundColor: '#002' },
33
+ { name: 'MS', foregroundColor: '#0f0', backgroundColor: '#020' },
34
+ { name: 'MB', foregroundColor: '#f08', backgroundColor: '#201' },
35
+ ];
36
+ export { PANEL_CONFIG, STATS_CONFIG, CONVERSION, PANEL_CONFIGS };
@@ -0,0 +1,6 @@
1
+ declare enum PanelType {
2
+ FPS = 0,
3
+ MS = 1,
4
+ MEMORY = 2
5
+ }
6
+ export { PanelType };
@@ -0,0 +1,7 @@
1
+ var PanelType;
2
+ (function (PanelType) {
3
+ PanelType[PanelType["FPS"] = 0] = "FPS";
4
+ PanelType[PanelType["MS"] = 1] = "MS";
5
+ PanelType[PanelType["MEMORY"] = 2] = "MEMORY";
6
+ })(PanelType || (PanelType = {}));
7
+ export { PanelType };
@@ -0,0 +1,2 @@
1
+ import { StatsOverlay as Class } from './StatsOverlay';
2
+ export declare const StatsOverlay: Class;
@@ -0,0 +1,2 @@
1
+ import { StatsOverlay as Class } from './StatsOverlay';
2
+ export const StatsOverlay = Class.getInstance();
@@ -0,0 +1,22 @@
1
+ interface Panel {
2
+ dom: HTMLCanvasElement;
3
+ update: (value: number, maxValue: number) => void;
4
+ }
5
+ interface StatsInstance {
6
+ dom: HTMLDivElement;
7
+ showPanel: (id: number) => void;
8
+ update: () => void;
9
+ destroy?: () => void;
10
+ }
11
+ interface PerformanceWithMemory extends Performance {
12
+ memory?: {
13
+ usedJSHeapSize: number;
14
+ jsHeapSizeLimit: number;
15
+ };
16
+ }
17
+ interface PanelConfig {
18
+ name: string;
19
+ foregroundColor: string;
20
+ backgroundColor: string;
21
+ }
22
+ export type { Panel, StatsInstance, PerformanceWithMemory, PanelConfig };
@@ -1,8 +1,11 @@
1
1
  import RenderingEngine from './RenderingEngine';
2
+ import BaseRenderingEngine from './BaseRenderingEngine';
3
+ import TiledRenderingEngine from './TiledRenderingEngine';
4
+ import ContextPoolRenderingEngine from './ContextPoolRenderingEngine';
2
5
  import getRenderingEngine from './getRenderingEngine';
3
6
  import VolumeViewport from './VolumeViewport';
4
7
  import StackViewport from './StackViewport';
5
8
  import VolumeViewport3D from './VolumeViewport3D';
6
9
  export * from './helpers';
7
- export { getRenderingEngine, RenderingEngine, VolumeViewport, VolumeViewport3D, StackViewport, };
10
+ export { getRenderingEngine, RenderingEngine, BaseRenderingEngine, TiledRenderingEngine, ContextPoolRenderingEngine, VolumeViewport, VolumeViewport3D, StackViewport, };
8
11
  export default RenderingEngine;
@@ -1,8 +1,11 @@
1
1
  import RenderingEngine from './RenderingEngine';
2
+ import BaseRenderingEngine from './BaseRenderingEngine';
3
+ import TiledRenderingEngine from './TiledRenderingEngine';
4
+ import ContextPoolRenderingEngine from './ContextPoolRenderingEngine';
2
5
  import getRenderingEngine from './getRenderingEngine';
3
6
  import VolumeViewport from './VolumeViewport';
4
7
  import StackViewport from './StackViewport';
5
8
  import VolumeViewport3D from './VolumeViewport3D';
6
9
  export * from './helpers';
7
- export { getRenderingEngine, RenderingEngine, VolumeViewport, VolumeViewport3D, StackViewport, };
10
+ export { getRenderingEngine, RenderingEngine, BaseRenderingEngine, TiledRenderingEngine, ContextPoolRenderingEngine, VolumeViewport, VolumeViewport3D, StackViewport, };
8
11
  export default RenderingEngine;
@@ -421,7 +421,6 @@ class Cache {
421
421
  sizeInBytes: 0,
422
422
  };
423
423
  this._imageCache.set(imageId, cachedImage);
424
- this._imageCache.set(imageId, cachedImage);
425
424
  return imageLoadObject.promise
426
425
  .then((image) => {
427
426
  try {
@@ -44,6 +44,7 @@ export default class BaseStreamingImageVolume extends ImageVolume implements IIm
44
44
  imageIdIndex: number;
45
45
  volumeId: string;
46
46
  };
47
+ retrieveOptions: any;
47
48
  };
48
49
  callLoadImage(imageId: any, imageIdIndex: any, options: any): any;
49
50
  protected getImageIdsRequests(imageIds: string[], priorityDefault: number): {
@@ -69,6 +70,7 @@ export default class BaseStreamingImageVolume extends ImageVolume implements IIm
69
70
  imageIdIndex: number;
70
71
  volumeId: string;
71
72
  };
73
+ retrieveOptions: any;
72
74
  };
73
75
  priority: number;
74
76
  requestType: RequestType;
@@ -248,6 +248,7 @@ export default class BaseStreamingImageVolume extends ImageVolume {
248
248
  imageIdIndex,
249
249
  volumeId: this.volumeId,
250
250
  },
251
+ retrieveOptions: undefined,
251
252
  };
252
253
  }
253
254
  callLoadImage(imageId, imageIdIndex, options) {
@@ -281,6 +282,13 @@ export default class BaseStreamingImageVolume extends ImageVolume {
281
282
  const requestType = requestTypeDefault;
282
283
  const priority = priorityDefault;
283
284
  const options = this.getLoaderImageOptions(imageId);
285
+ const { retrieveOptions = {} } = metaData.get(imageRetrieveMetadataProvider.IMAGE_RETRIEVE_CONFIGURATION, imageId, 'volume') || {};
286
+ options.retrieveOptions = {
287
+ ...options.retrieveOptions,
288
+ ...(retrieveOptions.default ||
289
+ Object.values(retrieveOptions)?.[0] ||
290
+ {}),
291
+ };
284
292
  return {
285
293
  callLoadImage: this.callLoadImage.bind(this),
286
294
  imageId,
@@ -48,6 +48,7 @@ export default class StreamingDynamicImageVolume extends BaseStreamingImageVolum
48
48
  imageIdIndex: number;
49
49
  volumeId: string;
50
50
  };
51
+ retrieveOptions: any;
51
52
  };
52
53
  priority: number;
53
54
  requestType: import("../../enums").RequestType;
@@ -0,0 +1,5 @@
1
+ declare enum RenderingEngineModeEnum {
2
+ Tiled = "tiled",
3
+ ContextPool = "contextPool"
4
+ }
5
+ export default RenderingEngineModeEnum;
@@ -0,0 +1,6 @@
1
+ var RenderingEngineModeEnum;
2
+ (function (RenderingEngineModeEnum) {
3
+ RenderingEngineModeEnum["Tiled"] = "tiled";
4
+ RenderingEngineModeEnum["ContextPool"] = "contextPool";
5
+ })(RenderingEngineModeEnum || (RenderingEngineModeEnum = {}));
6
+ export default RenderingEngineModeEnum;
@@ -16,4 +16,5 @@ import * as VideoEnums from './VideoEnums';
16
16
  import MetadataModules from './MetadataModules';
17
17
  import { GenerateImageType } from './GenerateImageType';
18
18
  import VoxelManagerEnum from './VoxelManagerEnum';
19
- export { Events, BlendModes, CalibrationTypes, InterpolationType, RequestType, ViewportType, OrientationAxis, GeometryType, ContourType, MeshType, VOILUTFunctionType, DynamicOperatorType, ViewportStatus, VideoEnums, MetadataModules, ImageQualityStatus, VoxelManagerEnum, GenerateImageType, };
19
+ import RenderingEngineModeEnum from './RenderingEngineModeEnum';
20
+ export { Events, BlendModes, CalibrationTypes, InterpolationType, RequestType, ViewportType, OrientationAxis, GeometryType, ContourType, MeshType, VOILUTFunctionType, DynamicOperatorType, ViewportStatus, VideoEnums, MetadataModules, ImageQualityStatus, VoxelManagerEnum, GenerateImageType, RenderingEngineModeEnum, };