dwv 0.31.0-beta.20 → 0.31.0-beta.22
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/dwv.js +178 -30
- package/dist/dwv.min.js +2 -2
- package/locales/de/translation.json +2 -1
- package/locales/en/translation.json +2 -1
- package/locales/es/translation.json +2 -1
- package/locales/fr/translation.json +2 -1
- package/locales/it/translation.json +2 -1
- package/locales/jp/translation.json +2 -1
- package/locales/ro/translation.json +2 -1
- package/locales/ru/translation.json +2 -1
- package/locales/zh/translation.json +2 -1
- package/package.json +3 -3
package/dist/dwv.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! dwv 0.31.0-beta.
|
|
1
|
+
/*! dwv 0.31.0-beta.22 2023-01-18 18:57:53 */
|
|
2
2
|
// Inspired from umdjs
|
|
3
3
|
// See https://github.com/umdjs/umd/blob/master/templates/returnExports.js
|
|
4
4
|
(function (root, factory) {
|
|
@@ -311,6 +311,17 @@ dwv.App = function () {
|
|
|
311
311
|
return stage.getViewLayersByDataIndex(index);
|
|
312
312
|
};
|
|
313
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Get the draw layers associated to a data index.
|
|
316
|
+
* The layer are available after the first loaded item.
|
|
317
|
+
*
|
|
318
|
+
* @param {number} index The data index.
|
|
319
|
+
* @returns {Array} The layers.
|
|
320
|
+
*/
|
|
321
|
+
this.getDrawLayersByDataIndex = function (index) {
|
|
322
|
+
return stage.getDrawLayersByDataIndex(index);
|
|
323
|
+
};
|
|
324
|
+
|
|
314
325
|
/**
|
|
315
326
|
* Get a layer group by div id.
|
|
316
327
|
* The layer is available after the first loaded item.
|
|
@@ -617,7 +628,6 @@ dwv.App = function () {
|
|
|
617
628
|
*/
|
|
618
629
|
this.fitToContainer = function () {
|
|
619
630
|
stage.syncLayerGroupScale();
|
|
620
|
-
|
|
621
631
|
};
|
|
622
632
|
|
|
623
633
|
/**
|
|
@@ -851,6 +861,16 @@ dwv.App = function () {
|
|
|
851
861
|
stage.getActiveLayerGroup().getActiveDrawLayer().getDrawController();
|
|
852
862
|
drawController.updateDraw(drawDetails);
|
|
853
863
|
};
|
|
864
|
+
/**
|
|
865
|
+
* Delete a draw.
|
|
866
|
+
*
|
|
867
|
+
* @param {object} drawDetails Details of the drawing to check.
|
|
868
|
+
*/
|
|
869
|
+
this.deleteDraw = function (drawDetails) {
|
|
870
|
+
var drawController =
|
|
871
|
+
stage.getActiveLayerGroup().getActiveDrawLayer().getDrawController();
|
|
872
|
+
drawController.deleteDraw(drawDetails, fireEvent, this.addToUndoStack);
|
|
873
|
+
};
|
|
854
874
|
/**
|
|
855
875
|
* Delete all Draws from all layers.
|
|
856
876
|
*/
|
|
@@ -1069,6 +1089,23 @@ dwv.App = function () {
|
|
|
1069
1089
|
undoStack.redo();
|
|
1070
1090
|
};
|
|
1071
1091
|
|
|
1092
|
+
/**
|
|
1093
|
+
* Get the undo stack size.
|
|
1094
|
+
*
|
|
1095
|
+
* @returns {number} The size of the stack.
|
|
1096
|
+
*/
|
|
1097
|
+
this.getStackSize = function () {
|
|
1098
|
+
return undoStack.getStackSize();
|
|
1099
|
+
};
|
|
1100
|
+
|
|
1101
|
+
/**
|
|
1102
|
+
* Get the current undo stack index.
|
|
1103
|
+
*
|
|
1104
|
+
* @returns {number} The stack index.
|
|
1105
|
+
*/
|
|
1106
|
+
this.getCurrentStackIndex = function () {
|
|
1107
|
+
return undoStack.getCurrentStackIndex();
|
|
1108
|
+
};
|
|
1072
1109
|
|
|
1073
1110
|
// Private Methods -----------------------------------------------------------
|
|
1074
1111
|
|
|
@@ -2116,6 +2153,30 @@ dwv.ctrl.DrawController = function (konvaLayer) {
|
|
|
2116
2153
|
exeCallback(delcmd);
|
|
2117
2154
|
};
|
|
2118
2155
|
|
|
2156
|
+
/**
|
|
2157
|
+
* Delete a Draw from the stage.
|
|
2158
|
+
*
|
|
2159
|
+
* @param {object} drawDetails Details of the group to update.
|
|
2160
|
+
* @param {object} cmdCallback The DeleteCommand callback.
|
|
2161
|
+
* @param {object} exeCallback The callback to call once the
|
|
2162
|
+
* DeleteCommand has been executed.
|
|
2163
|
+
* @returns {boolean} False if the group cannot be found.
|
|
2164
|
+
*/
|
|
2165
|
+
this.deleteDraw = function (drawDetails, cmdCallback, exeCallback) {
|
|
2166
|
+
// get the group
|
|
2167
|
+
var group = konvaLayer.findOne('#' + drawDetails.id);
|
|
2168
|
+
if (typeof group === 'undefined') {
|
|
2169
|
+
dwv.logger.warn(
|
|
2170
|
+
'[deleteDraw] Cannot find node with id: ' + drawDetails.id
|
|
2171
|
+
);
|
|
2172
|
+
return false;
|
|
2173
|
+
}
|
|
2174
|
+
// delete
|
|
2175
|
+
this.deleteDrawGroup(group, cmdCallback, exeCallback);
|
|
2176
|
+
|
|
2177
|
+
return true;
|
|
2178
|
+
};
|
|
2179
|
+
|
|
2119
2180
|
/**
|
|
2120
2181
|
* Delete all Draws from the stage.
|
|
2121
2182
|
*
|
|
@@ -4695,7 +4756,7 @@ dwv.dicom = dwv.dicom || {};
|
|
|
4695
4756
|
* @returns {string} The version of the library.
|
|
4696
4757
|
*/
|
|
4697
4758
|
dwv.getVersion = function () {
|
|
4698
|
-
return '0.31.0-beta.
|
|
4759
|
+
return '0.31.0-beta.22';
|
|
4699
4760
|
};
|
|
4700
4761
|
|
|
4701
4762
|
/**
|
|
@@ -14004,23 +14065,19 @@ dwv.gui.LayerGroup = function (containerDiv) {
|
|
|
14004
14065
|
var p2D = vc.getPlanePositionFromPosition(position);
|
|
14005
14066
|
var displayPos = layer0.planePosToDisplay(p2D.x, p2D.y);
|
|
14006
14067
|
|
|
14007
|
-
// 10px offset
|
|
14008
|
-
// TODO: find why...
|
|
14009
|
-
var offY = 10;
|
|
14010
|
-
|
|
14011
14068
|
var lineH = document.createElement('hr');
|
|
14012
14069
|
lineH.id = self.getDivId() + '-scroll-crosshair-horizontal';
|
|
14013
14070
|
lineH.className = 'horizontal';
|
|
14014
14071
|
lineH.style.width = containerDiv.offsetWidth + 'px';
|
|
14015
14072
|
lineH.style.left = '0px';
|
|
14016
|
-
lineH.style.top =
|
|
14073
|
+
lineH.style.top = displayPos.y + 'px';
|
|
14017
14074
|
|
|
14018
14075
|
var lineV = document.createElement('hr');
|
|
14019
14076
|
lineV.id = self.getDivId() + '-scroll-crosshair-vertical';
|
|
14020
14077
|
lineV.className = 'vertical';
|
|
14021
14078
|
lineV.style.width = containerDiv.offsetHeight + 'px';
|
|
14022
14079
|
lineV.style.left = (displayPos.x) + 'px';
|
|
14023
|
-
lineV.style.top =
|
|
14080
|
+
lineV.style.top = '0px';
|
|
14024
14081
|
|
|
14025
14082
|
containerDiv.appendChild(lineH);
|
|
14026
14083
|
containerDiv.appendChild(lineV);
|
|
@@ -14176,6 +14233,11 @@ dwv.gui.LayerGroup = function (containerDiv) {
|
|
|
14176
14233
|
for (var j = 0; j < layers.length; ++j) {
|
|
14177
14234
|
layers[j].fitToContainer(scaleIn, containerSize, fitOffset);
|
|
14178
14235
|
}
|
|
14236
|
+
|
|
14237
|
+
// update crosshair
|
|
14238
|
+
if (showCrosshair) {
|
|
14239
|
+
showCrosshairDiv();
|
|
14240
|
+
}
|
|
14179
14241
|
};
|
|
14180
14242
|
|
|
14181
14243
|
/**
|
|
@@ -14547,6 +14609,20 @@ dwv.gui.Stage = function () {
|
|
|
14547
14609
|
return res;
|
|
14548
14610
|
};
|
|
14549
14611
|
|
|
14612
|
+
/**
|
|
14613
|
+
* Get the draw layers associated to a data index.
|
|
14614
|
+
*
|
|
14615
|
+
* @param {number} index The data index.
|
|
14616
|
+
* @returns {Array} The layers.
|
|
14617
|
+
*/
|
|
14618
|
+
this.getDrawLayersByDataIndex = function (index) {
|
|
14619
|
+
var res = [];
|
|
14620
|
+
for (var i = 0; i < layerGroups.length; ++i) {
|
|
14621
|
+
res = res.concat(layerGroups[i].getDrawLayersByDataIndex(index));
|
|
14622
|
+
}
|
|
14623
|
+
return res;
|
|
14624
|
+
};
|
|
14625
|
+
|
|
14550
14626
|
/**
|
|
14551
14627
|
* Add a layer group to the list.
|
|
14552
14628
|
*
|
|
@@ -15741,8 +15817,8 @@ dwv.gui.ViewLayer = function (containerDiv) {
|
|
|
15741
15817
|
if (viewOffset.x !== newViewOffset.x || viewOffset.y !== newViewOffset.y) {
|
|
15742
15818
|
viewOffset = newViewOffset;
|
|
15743
15819
|
offset = {
|
|
15744
|
-
x: viewOffset.x + baseOffset.x + zoomOffset.x,
|
|
15745
|
-
y: viewOffset.y + baseOffset.y + zoomOffset.y
|
|
15820
|
+
x: viewOffset.x + baseOffset.x + zoomOffset.x + flipOffset.x,
|
|
15821
|
+
y: viewOffset.y + baseOffset.y + zoomOffset.y + flipOffset.y
|
|
15746
15822
|
};
|
|
15747
15823
|
// update draw flag
|
|
15748
15824
|
needsDraw = true;
|
|
@@ -19743,6 +19819,42 @@ dwv.image.getVariableRegionSliceIterator = function (
|
|
|
19743
19819
|
1, offsetRegions);
|
|
19744
19820
|
};
|
|
19745
19821
|
|
|
19822
|
+
/**
|
|
19823
|
+
* Get a colour iterator. The input array defines the colours and
|
|
19824
|
+
* their start index.
|
|
19825
|
+
*
|
|
19826
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
|
|
19827
|
+
* @param {Array} colours An array of {index, colour} pairs.
|
|
19828
|
+
* @param {number} end The end of the range (excluded).
|
|
19829
|
+
* @returns {object} An iterator folowing the iterator and iterable protocol.
|
|
19830
|
+
*/
|
|
19831
|
+
dwv.image.colourRange = function (colours, end) {
|
|
19832
|
+
var nextIndex = 0;
|
|
19833
|
+
var nextColourIndex = 0;
|
|
19834
|
+
// result
|
|
19835
|
+
return {
|
|
19836
|
+
next: function () {
|
|
19837
|
+
if (nextIndex < end) {
|
|
19838
|
+
if (nextColourIndex + 1 < colours.length &&
|
|
19839
|
+
nextIndex >= colours[nextColourIndex + 1].index) {
|
|
19840
|
+
++nextColourIndex;
|
|
19841
|
+
}
|
|
19842
|
+
var result = {
|
|
19843
|
+
value: colours[nextColourIndex].colour,
|
|
19844
|
+
done: false,
|
|
19845
|
+
index: nextIndex
|
|
19846
|
+
};
|
|
19847
|
+
++nextIndex;
|
|
19848
|
+
return result;
|
|
19849
|
+
}
|
|
19850
|
+
return {
|
|
19851
|
+
done: true,
|
|
19852
|
+
index: end
|
|
19853
|
+
};
|
|
19854
|
+
}
|
|
19855
|
+
};
|
|
19856
|
+
};
|
|
19857
|
+
|
|
19746
19858
|
// namespaces
|
|
19747
19859
|
var dwv = dwv || {};
|
|
19748
19860
|
dwv.image = dwv.image || {};
|
|
@@ -20726,6 +20838,22 @@ dwv.image.MaskFactory.prototype.create = function (
|
|
|
20726
20838
|
var tmpGeometry = new dwv.image.Geometry(
|
|
20727
20839
|
frameOrigins[0], size, newSpacing, orientationMatrix);
|
|
20728
20840
|
|
|
20841
|
+
// origin distance test
|
|
20842
|
+
var isNotSmall = function (value) {
|
|
20843
|
+
var res = value > dwv.math.REAL_WORLD_EPSILON;
|
|
20844
|
+
if (res) {
|
|
20845
|
+
// try larger epsilon
|
|
20846
|
+
res = value > dwv.math.REAL_WORLD_EPSILON * 10;
|
|
20847
|
+
if (!res) {
|
|
20848
|
+
// warn if epsilon < value < epsilon * 10
|
|
20849
|
+
dwv.logger.warn(
|
|
20850
|
+
'Using larger real world epsilon in SEG pos pat adding'
|
|
20851
|
+
);
|
|
20852
|
+
}
|
|
20853
|
+
}
|
|
20854
|
+
return res;
|
|
20855
|
+
};
|
|
20856
|
+
|
|
20729
20857
|
// add possibly missing posPats
|
|
20730
20858
|
var posPats = [];
|
|
20731
20859
|
posPats.push(framePosPats[0]);
|
|
@@ -20737,8 +20865,9 @@ dwv.image.MaskFactory.prototype.create = function (
|
|
|
20737
20865
|
var frameOrigin = frameOrigins[g];
|
|
20738
20866
|
// check if more pos pats are needed
|
|
20739
20867
|
var dist = frameOrigin.getDistance(point);
|
|
20868
|
+
var distPrevious = dist;
|
|
20740
20869
|
// TODO: good threshold?
|
|
20741
|
-
while (dist
|
|
20870
|
+
while (isNotSmall(dist)) {
|
|
20742
20871
|
dwv.logger.debug('Adding intermediate pos pats for DICOM seg at ' +
|
|
20743
20872
|
point.toString());
|
|
20744
20873
|
posPats.push([point.getX(), point.getY(), point.getZ()]);
|
|
@@ -20746,6 +20875,10 @@ dwv.image.MaskFactory.prototype.create = function (
|
|
|
20746
20875
|
index = new dwv.math.Index([0, 0, sliceIndex]);
|
|
20747
20876
|
point = tmpGeometry.indexToWorld(index).get3D();
|
|
20748
20877
|
dist = frameOrigin.getDistance(point);
|
|
20878
|
+
if (dist > distPrevious) {
|
|
20879
|
+
throw new Error(
|
|
20880
|
+
'Test distance is increasing when adding intermediate pos pats');
|
|
20881
|
+
}
|
|
20749
20882
|
}
|
|
20750
20883
|
// add frame pos pat
|
|
20751
20884
|
posPats.push(framePosPats[g]);
|
|
@@ -26722,17 +26855,23 @@ dwv.math.getEllipseIndices = function (center, radius, dir) {
|
|
|
26722
26855
|
values[dj] = jmax;
|
|
26723
26856
|
indices.push(new dwv.math.Index(values.slice()));
|
|
26724
26857
|
// right - bottom
|
|
26725
|
-
|
|
26726
|
-
|
|
26858
|
+
if (jmin !== jmax) {
|
|
26859
|
+
values[dj] = jmin;
|
|
26860
|
+
indices.push(new dwv.math.Index(values.slice()));
|
|
26861
|
+
}
|
|
26727
26862
|
|
|
26728
26863
|
// left
|
|
26729
|
-
|
|
26730
|
-
|
|
26731
|
-
|
|
26732
|
-
|
|
26733
|
-
|
|
26734
|
-
|
|
26735
|
-
|
|
26864
|
+
if (imin !== imax) {
|
|
26865
|
+
values[di] = imin;
|
|
26866
|
+
// left - top
|
|
26867
|
+
values[dj] = jmax;
|
|
26868
|
+
indices.push(new dwv.math.Index(values.slice()));
|
|
26869
|
+
// left - bottom
|
|
26870
|
+
if (jmin !== jmax) {
|
|
26871
|
+
values[dj] = jmin;
|
|
26872
|
+
indices.push(new dwv.math.Index(values.slice()));
|
|
26873
|
+
}
|
|
26874
|
+
}
|
|
26736
26875
|
}
|
|
26737
26876
|
}
|
|
26738
26877
|
return indices;
|
|
@@ -35581,15 +35720,6 @@ dwv.tool.UndoStack = function () {
|
|
|
35581
35720
|
*/
|
|
35582
35721
|
var stack = [];
|
|
35583
35722
|
|
|
35584
|
-
/**
|
|
35585
|
-
* Get the stack.
|
|
35586
|
-
*
|
|
35587
|
-
* @returns {Array} The list of stored commands.
|
|
35588
|
-
*/
|
|
35589
|
-
this.getStack = function () {
|
|
35590
|
-
return stack;
|
|
35591
|
-
};
|
|
35592
|
-
|
|
35593
35723
|
/**
|
|
35594
35724
|
* Current command index.
|
|
35595
35725
|
*
|
|
@@ -35606,6 +35736,24 @@ dwv.tool.UndoStack = function () {
|
|
|
35606
35736
|
*/
|
|
35607
35737
|
var listenerHandler = new dwv.utils.ListenerHandler();
|
|
35608
35738
|
|
|
35739
|
+
/**
|
|
35740
|
+
* Get the stack size.
|
|
35741
|
+
*
|
|
35742
|
+
* @returns {number} The size of the stack.
|
|
35743
|
+
*/
|
|
35744
|
+
this.getStackSize = function () {
|
|
35745
|
+
return stack.length;
|
|
35746
|
+
};
|
|
35747
|
+
|
|
35748
|
+
/**
|
|
35749
|
+
* Get the current stack index.
|
|
35750
|
+
*
|
|
35751
|
+
* @returns {number} The stack index.
|
|
35752
|
+
*/
|
|
35753
|
+
this.getCurrentStackIndex = function () {
|
|
35754
|
+
return curCmdIndex;
|
|
35755
|
+
};
|
|
35756
|
+
|
|
35609
35757
|
/**
|
|
35610
35758
|
* Add a command to the stack.
|
|
35611
35759
|
*
|