Skip to content

Commit

Permalink
Merge branch 'v0.27.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivmartel committed Sep 23, 2020
2 parents 103fbbf + 57c4653 commit 2ecc808
Show file tree
Hide file tree
Showing 9 changed files with 150 additions and 36 deletions.
91 changes: 74 additions & 17 deletions dist/dwv.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! dwv 0.27.0 2020-03-11 00:16:31 */
/*! dwv 0.27.1 2020-09-24 00:08:40 */
// Inspired from umdjs
// See https://github.com/umdjs/umd/blob/master/templates/returnExports.js
(function (root, factory) {
Expand Down Expand Up @@ -342,7 +342,7 @@ dwv.App = function ()
// remove the height of other elements of the container div
var kids = parent.children;
for (var i = 0; i < kids.length; ++i) {
if (kids[i].className !== "layerContainer") {
if (!kids[i].classList.contains("layerContainer")) {
var styles = window.getComputedStyle(kids[i]);
// offsetHeight does not include margin
var margin = parseFloat(styles.getPropertyValue('margin-top'), 10) +
Expand Down Expand Up @@ -3580,7 +3580,7 @@ dwv.dicom = dwv.dicom || {};
* Get the version of the library.
* @return {String} The version of the library.
*/
dwv.getVersion = function () { return "0.27.0"; };
dwv.getVersion = function () { return "0.27.1"; };

/**
* Clean string: trim and remove ending.
Expand Down Expand Up @@ -11618,18 +11618,17 @@ dwv.image.DicomBufferToView = function ()
}
};

// setup the decoder if not done already
if (!pixelDecoder){
pixelDecoder = new dwv.image.PixelBufferDecoder(
algoName, numberOfFrames);
// callbacks
// pixelDecoder.ondecodestart: nothing to do
pixelDecoder.ondecodeditem = onDecodedFrame;
pixelDecoder.ondecoded = self.onload;
pixelDecoder.ondecodeend = self.onloadend;
pixelDecoder.onerror = self.onerror;
pixelDecoder.onabort = self.onabort;
}
// setup the decoder (one decoder per convert)
// TODO check if it is ok to create a worker pool per file...
pixelDecoder = new dwv.image.PixelBufferDecoder(
algoName, numberOfFrames);
// callbacks
// pixelDecoder.ondecodestart: nothing to do
pixelDecoder.ondecodeditem = onDecodedFrame;
pixelDecoder.ondecoded = self.onload;
pixelDecoder.ondecodeend = self.onloadend;
pixelDecoder.onerror = self.onerror;
pixelDecoder.onabort = self.onabort;

// launch decode
for (var f = 0; f < numberOfFrames; ++f) {
Expand Down Expand Up @@ -12532,12 +12531,22 @@ dwv.image.Image = function(geometry, buffer, numberOfFrames, imageUids)
* @type Number
*/
var planarConfiguration = 0;

/**
* Check if the input element is not null.
* @param {Object} element The element to test.
* @returns True if the input is not null.
*/
var isNotNull = function (element) {
return element !== null;
};

/**
* Number of components.
* @private
* @type Number
*/
var numberOfComponents = buffer[0].length / (
var numberOfComponents = buffer.find(isNotNull).length / (
geometry.getSize().getTotalSize() );
/**
* Meta information.
Expand Down Expand Up @@ -15802,7 +15811,7 @@ dwv.io.MemoryLoader = function ()
var foundLoader = false;
for (var l = 0; l < loaders.length; ++l) {
loader = loaders[l];
if (loader.canLoadFile({name: dataElement.filename})) {
if (loader.canLoadUrl(dataElement.filename)) {
foundLoader = true;
// load options
loader.setOptions({
Expand Down Expand Up @@ -23668,6 +23677,54 @@ dwv.env.check = function()
window.Float64Array = window.Float32Array;
}

// array Find
// https://tc39.github.io/ecma262/#sec-array.prototype.find
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, 'find', {
value: function(predicate) {
// 1. Let O be ? ToObject(this value).
if (this == null) {
throw new TypeError('"this" is null or not defined');
}

var o = Object(this);

// 2. Let len be ? ToLength(? Get(O, "length")).
var len = o.length >>> 0;

// 3. If IsCallable(predicate) is false, throw a TypeError exception.
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}

// 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
var thisArg = arguments[1];

// 5. Let k be 0.
var k = 0;

// 6. Repeat, while k < len
while (k < len) {
// a. Let Pk be ! ToString(k).
// b. Let kValue be ? Get(O, Pk).
// c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
// d. If testResult is true, return kValue.
var kValue = o[k];
if (predicate.call(thisArg, kValue, k, o)) {
return kValue;
}
// e. Increase k by 1.
k++;
}

// 7. Return undefined.
return undefined;
},
configurable: true,
writable: true
});
}

// check string startsWith
if ( !String.prototype.startsWith ) {
String.prototype.startsWith = function (search, pos) {
Expand Down
4 changes: 2 additions & 2 deletions dist/dwv.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dwv",
"version": "0.27.0",
"version": "0.27.1",
"description": "DICOM Web Viewer.",
"keywords": [
"DICOM",
Expand Down
2 changes: 1 addition & 1 deletion src/app/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ dwv.App = function ()
// remove the height of other elements of the container div
var kids = parent.children;
for (var i = 0; i < kids.length; ++i) {
if (kids[i].className !== "layerContainer") {
if (!kids[i].classList.contains("layerContainer")) {
var styles = window.getComputedStyle(kids[i]);
// offsetHeight does not include margin
var margin = parseFloat(styles.getPropertyValue('margin-top'), 10) +
Expand Down
2 changes: 1 addition & 1 deletion src/dicom/dicomParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ dwv.dicom = dwv.dicom || {};
* Get the version of the library.
* @return {String} The version of the library.
*/
dwv.getVersion = function () { return "0.27.0"; };
dwv.getVersion = function () { return "0.27.1"; };

/**
* Clean string: trim and remove ending.
Expand Down
23 changes: 11 additions & 12 deletions src/image/dicomBufferToView.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,18 +144,17 @@ dwv.image.DicomBufferToView = function ()
}
};

// setup the decoder if not done already
if (!pixelDecoder){
pixelDecoder = new dwv.image.PixelBufferDecoder(
algoName, numberOfFrames);
// callbacks
// pixelDecoder.ondecodestart: nothing to do
pixelDecoder.ondecodeditem = onDecodedFrame;
pixelDecoder.ondecoded = self.onload;
pixelDecoder.ondecodeend = self.onloadend;
pixelDecoder.onerror = self.onerror;
pixelDecoder.onabort = self.onabort;
}
// setup the decoder (one decoder per convert)
// TODO check if it is ok to create a worker pool per file...
pixelDecoder = new dwv.image.PixelBufferDecoder(
algoName, numberOfFrames);
// callbacks
// pixelDecoder.ondecodestart: nothing to do
pixelDecoder.ondecodeditem = onDecodedFrame;
pixelDecoder.ondecoded = self.onload;
pixelDecoder.ondecodeend = self.onloadend;
pixelDecoder.onerror = self.onerror;
pixelDecoder.onabort = self.onabort;

// launch decode
for (var f = 0; f < numberOfFrames; ++f) {
Expand Down
12 changes: 11 additions & 1 deletion src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,22 @@ dwv.image.Image = function(geometry, buffer, numberOfFrames, imageUids)
* @type Number
*/
var planarConfiguration = 0;

/**
* Check if the input element is not null.
* @param {Object} element The element to test.
* @returns True if the input is not null.
*/
var isNotNull = function (element) {
return element !== null;
};

/**
* Number of components.
* @private
* @type Number
*/
var numberOfComponents = buffer[0].length / (
var numberOfComponents = buffer.find(isNotNull).length / (
geometry.getSize().getTotalSize() );
/**
* Meta information.
Expand Down
2 changes: 1 addition & 1 deletion src/io/memoryLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ dwv.io.MemoryLoader = function ()
var foundLoader = false;
for (var l = 0; l < loaders.length; ++l) {
loader = loaders[l];
if (loader.canLoadFile({name: dataElement.filename})) {
if (loader.canLoadUrl(dataElement.filename)) {
foundLoader = true;
// load options
loader.setOptions({
Expand Down
48 changes: 48 additions & 0 deletions src/utils/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,54 @@ dwv.env.check = function()
window.Float64Array = window.Float32Array;
}

// array Find
// https://tc39.github.io/ecma262/#sec-array.prototype.find
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, 'find', {
value: function(predicate) {
// 1. Let O be ? ToObject(this value).
if (this == null) {
throw new TypeError('"this" is null or not defined');
}

var o = Object(this);

// 2. Let len be ? ToLength(? Get(O, "length")).
var len = o.length >>> 0;

// 3. If IsCallable(predicate) is false, throw a TypeError exception.
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}

// 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
var thisArg = arguments[1];

// 5. Let k be 0.
var k = 0;

// 6. Repeat, while k < len
while (k < len) {
// a. Let Pk be ! ToString(k).
// b. Let kValue be ? Get(O, Pk).
// c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
// d. If testResult is true, return kValue.
var kValue = o[k];
if (predicate.call(thisArg, kValue, k, o)) {
return kValue;
}
// e. Increase k by 1.
k++;
}

// 7. Return undefined.
return undefined;
},
configurable: true,
writable: true
});
}

// check string startsWith
if ( !String.prototype.startsWith ) {
String.prototype.startsWith = function (search, pos) {
Expand Down

0 comments on commit 2ecc808

Please sign in to comment.