dwv 0.37.0-beta.2 → 0.37.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 (91) hide show
  1. package/dev/bench/bench.html +94 -0
  2. package/dev/bench/bench.js +316 -0
  3. package/dev/bench/benchFunctionRunner.js +83 -0
  4. package/dev/bench/dataRunner.js +171 -0
  5. package/dev/bench/gui.js +184 -0
  6. package/dev/bench/listen.js +70 -0
  7. package/dev/bench/parsers/dwv-current.html +45 -0
  8. package/dev/bench/parsers/dwv-previous.html +45 -0
  9. package/dev/dicom/binaryPixGenerator.js +108 -0
  10. package/dev/dicom/dicomGenerator.js +215 -0
  11. package/dev/dicom/filePixGenerator.js +96 -0
  12. package/dev/dicom/gradSquarePixGenerator.js +107 -0
  13. package/dev/dicom/mprPixGenerator.js +247 -0
  14. package/dev/dicom/pages/anonymiser.html +86 -0
  15. package/dev/dicom/pages/anonymiser.js +154 -0
  16. package/dev/dicom/pages/generator.html +92 -0
  17. package/dev/dicom/pages/generator.js +329 -0
  18. package/dev/dicom/pages/synthetic-data.html +19 -0
  19. package/dev/dicom/pages/synthetic-data.js +164 -0
  20. package/dev/dicom/squarePixGenerator.js +233 -0
  21. package/dev/favicon.ico +0 -0
  22. package/dev/image/pages/colourmaps.html +16 -0
  23. package/dev/image/pages/colourmaps.js +65 -0
  24. package/dev/index.html +37 -0
  25. package/dev/pacs/dcmweb.html +80 -0
  26. package/dev/pacs/dcmweb.js +577 -0
  27. package/dev/pacs/images/acute_leukemia.png +0 -0
  28. package/dev/pacs/images/babymri-dcmdir.png +0 -0
  29. package/dev/pacs/images/babymri-rect.png +0 -0
  30. package/dev/pacs/images/babymri-zip.png +0 -0
  31. package/dev/pacs/images/babymri.png +0 -0
  32. package/dev/pacs/images/brainmri-png.png +0 -0
  33. package/dev/pacs/images/brainpet-jpg.png +0 -0
  34. package/dev/pacs/images/cerebrix.png +0 -0
  35. package/dev/pacs/images/goudurix.png +0 -0
  36. package/dev/pacs/images/multiframe-test1.png +0 -0
  37. package/dev/pacs/images/toutatix.png +0 -0
  38. package/dev/pacs/images/us.png +0 -0
  39. package/dev/pacs/index.html +97 -0
  40. package/dev/pacs/index.js +287 -0
  41. package/dev/pacs/overlays.js +51 -0
  42. package/dev/pacs/viewer.html +401 -0
  43. package/dev/pacs/viewer.js +1275 -0
  44. package/dev/pacs/viewer.rendertest.js +96 -0
  45. package/dev/pacs/viewer.ui.annot.js +607 -0
  46. package/dev/pacs/viewer.ui.brush.js +181 -0
  47. package/dev/pacs/viewer.ui.datatable.js +674 -0
  48. package/dev/pacs/viewer.ui.draw.js +141 -0
  49. package/dev/pacs/viewer.ui.icons.js +88 -0
  50. package/dev/pacs/viewer.ui.js +198 -0
  51. package/dev/pacs/viewer.ui.segment.js +1263 -0
  52. package/dev/visual/appgui.js +125 -0
  53. package/dev/visual/images/dicompyler-ct.0.jpg +0 -0
  54. package/dev/visual/images/gdcm-CR-MONO1-10-chest.jpg +0 -0
  55. package/dev/visual/images/gdcm-CT-MONO2-8-abdo.jpg +0 -0
  56. package/dev/visual/images/gdcm-US-RGB-8-epicard.jpg +0 -0
  57. package/dev/visual/images/gdcm-US-RGB-8-esopecho.jpg +0 -0
  58. package/dev/visual/images/leadtools-8BitsJpegLossyGrayScale.jpg +0 -0
  59. package/dev/visual/images/leadtools-flowers-16-mono2-rle.jpg +0 -0
  60. package/dev/visual/images/leadtools-flowers-8-mono2-rle.jpg +0 -0
  61. package/dev/visual/images/nema-ct1_j2ki.jpg +0 -0
  62. package/dev/visual/images/nema-ct1_jpll.jpg +0 -0
  63. package/dev/visual/images/nema-mr1_jply.jpg +0 -0
  64. package/dev/visual/images/nema-nm1_j2kr.jpg +0 -0
  65. package/dev/visual/images/nema-nm1_jpll.jpg +0 -0
  66. package/dev/visual/images/nema-nm1_jply.jpg +0 -0
  67. package/dev/visual/images/nema-us1_j2ki.jpg +0 -0
  68. package/dev/visual/images/nema-vl2_j2kr.jpg +0 -0
  69. package/dev/visual/images/osirix-cerebrix.jpg +0 -0
  70. package/dev/visual/images/osirix-goudurix.jpg +0 -0
  71. package/dev/visual/images/osirix-toutatix-100.jpg +0 -0
  72. package/dev/visual/index-jpeg.js +104 -0
  73. package/dev/visual/index-jpeg2000.js +103 -0
  74. package/dev/visual/index-rle.js +70 -0
  75. package/dev/visual/index.html +20 -0
  76. package/dev/visual/index.js +123 -0
  77. package/dev/visual/style.css +37 -0
  78. package/dist/assets/workers/jpeg2000.worker.min.js +1 -1
  79. package/dist/assets/workers/jpeg2000.worker.min.js.map +1 -1
  80. package/dist/assets/workers/jpegbaseline.worker.min.js +1 -1
  81. package/dist/assets/workers/jpegbaseline.worker.min.js.map +1 -1
  82. package/dist/assets/workers/labeling.worker.min.js +1 -1
  83. package/dist/assets/workers/labeling.worker.min.js.map +1 -1
  84. package/dist/assets/workers/resampling.worker.min.js +1 -1
  85. package/dist/assets/workers/resampling.worker.min.js.map +1 -1
  86. package/dist/dwv.d.ts +1355 -415
  87. package/dist/dwv.min.js +1 -1
  88. package/dist/dwv.min.js.map +1 -1
  89. package/dist/dwv.node.min.js +1 -1
  90. package/dist/dwv.node.min.js.map +1 -1
  91. package/package.json +20 -20
@@ -0,0 +1,181 @@
1
+ import {getControlDiv} from './viewer.ui.js';
2
+
3
+ /**
4
+ * @import {App} from '../../src/app/application.js';
5
+ */
6
+
7
+ /**
8
+ * Brush tool UI.
9
+ */
10
+ export class BrushToolUI {
11
+
12
+ /**
13
+ * The associated application.
14
+ *
15
+ * @type {App}
16
+ */
17
+ #app;
18
+
19
+ /**
20
+ * @param {App} app The associated application.
21
+ */
22
+ constructor(app, /*toolConfig*/) {
23
+ this.#app = app;
24
+ }
25
+
26
+ /**
27
+ * Bind app to ui.
28
+ */
29
+ registerListeners() {
30
+ // listen to brush size event (via shortcut)
31
+ this.#app.addEventListener('brushsizechange', this.#onBrushSizeChange);
32
+ };
33
+
34
+ /**
35
+ * Get the value of the tool UI.
36
+ *
37
+ * @returns {object|undefined} The value.
38
+ */
39
+ getValue() {
40
+ return undefined;
41
+ };
42
+
43
+ /**
44
+ * Get the HTML element of the tool UI.
45
+ *
46
+ * @returns {HTMLElement|undefined} The element.
47
+ */
48
+ getHtml() {
49
+ // list of segmentations
50
+ const res = document.createElement('ul');
51
+ res.id = 'toolFeatures';
52
+ res.className = 'toolFeatures';
53
+
54
+ // brush size input
55
+ const sizeCallback = (size) => {
56
+ this.#app.setToolFeatures({brushSize: size});
57
+ //this.updateBrushCursorSize(size);
58
+ };
59
+ // set default size
60
+ const defaultCursorSize = 10;
61
+ this.#app.setToolFeatures({brushSize: defaultCursorSize});
62
+ // append range
63
+ const controlDiv = getControlDiv(
64
+ 'brush-size',
65
+ 'Brush size',
66
+ 1,
67
+ 20,
68
+ defaultCursorSize,
69
+ sizeCallback,
70
+ undefined,
71
+ 1
72
+ );
73
+ res.appendChild(controlDiv);
74
+
75
+ // if no segmentations, use default
76
+ if (!document.getElementById('segmentation-list')) {
77
+ const features = {
78
+ brushMode: 'add',
79
+ selectedSegmentNumber: 1,
80
+ createMask: true
81
+ };
82
+ console.log('set tool features [add-default]', features);
83
+ this.#app.setToolFeatures(features);
84
+ }
85
+
86
+ return res;
87
+ };
88
+
89
+ /**
90
+ * Handle brush size change event.
91
+ *
92
+ * @param {CustomEvent} event The change event.
93
+ */
94
+ #onBrushSizeChange(event) {
95
+ const newValue = event.detail.value;
96
+ const controlRange = document.getElementById('brush-size-range');
97
+ const controlValue = document.getElementById('brush-size-number');
98
+ if (controlRange && controlValue) {
99
+ controlRange.value = newValue;
100
+ controlValue.value = newValue;
101
+ }
102
+ }
103
+
104
+ /**
105
+ * Update the brush cursor size.
106
+ *
107
+ * @param {number} _brushSize The new size.
108
+ */
109
+ // #updateBrushCursorSize(_brushSize) {
110
+ // const stgCtrl = this.#app.getStageController();
111
+ // const lg = stgCtrl.getActiveLayerGroup();
112
+ // if (typeof lg === 'undefined') {
113
+ // throw new Error('No active layer group for brush cursor');
114
+ // }
115
+ // const vl = lg.getActiveViewLayer();
116
+ // if (typeof vl === 'undefined') {
117
+ // throw new Error('No active view layer for brush cursor');
118
+ // }
119
+ // const scale = vl.getScale();
120
+ // const spacing = vl.getViewController().get2DSpacing();
121
+
122
+ // const width = 2 * brushSize * Math.abs(scale.x) / spacing.x;
123
+ // const height = 2 * brushSize * Math.abs(scale.y) / spacing.y;
124
+
125
+ // const cursorDiv = document.getElementById('brushCursor');
126
+ // cursorDiv.style.width = Math.round(width) + 'px';
127
+ // cursorDiv.style.height = Math.round(height) + 'px';
128
+ // }
129
+
130
+ /**
131
+ * Add the brush cursor to the dom.
132
+ */
133
+ // #addBrushCursor() {
134
+ // // cursor div
135
+ // const cursorDiv = document.createElement('div');
136
+ // cursorDiv.id = 'brushCursor';
137
+ // document.body.prepend(cursorDiv);
138
+
139
+ // // default size
140
+ // const cursorRange = document.getElementById('brush-size-range');
141
+ // this.#updateBrushCursorSize(parseInt(cursorRange.value, 10));
142
+
143
+ // // update position on mouse move
144
+ // window.addEventListener('mousemove', updateBrushCursorPos);
145
+ // }
146
+
147
+ }; // BrushToolUI
148
+
149
+ /**
150
+ * Update the brush cursor on mouse move.
151
+ *
152
+ * @param event The mouse move event.
153
+ */
154
+ // function updateBrushCursorPos(event) {
155
+ // const cursorDiv = document.getElementById('brushCursor');
156
+ // // calculate shape half sizes
157
+ // const width = cursorDiv.clientWidth;
158
+ // const left = cursorDiv.offsetLeft + (cursorDiv.offsetWidth - width);
159
+ // const halfX = left + width / 2;
160
+ // const height = cursorDiv.clientHeight;
161
+ // const top = cursorDiv.offsetTop + (cursorDiv.offsetHeight - height);
162
+ // const halfY = top + height / 2;
163
+ // // new cursor position
164
+ // const mouseX = event.clientX - halfX;
165
+ // const mouseY = event.clientY - halfY;
166
+ // cursorDiv.style.translate = `${mouseX}px ${mouseY}px`;
167
+ // }
168
+
169
+ /**
170
+ * Remove the brush cursor from the dom.
171
+ */
172
+ // function removeBrushCursor() {
173
+ // // remove div
174
+ // const cursorDiv = document.getElementById('brushCursor');
175
+ // if (cursorDiv) {
176
+ // cursorDiv.remove();
177
+ // }
178
+
179
+ // // stop listening on mouse move
180
+ // window.removeEventListener('mousemove', updateBrushCursorPos);
181
+ // }