@niivue/niivue 0.29.0 → 0.30.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.
- package/dist/niivue.es.js +111 -82
- package/dist/niivue.umd.js +21 -21
- package/package.json +1 -1
- package/src/index.html +3 -1
- package/src/niivue.js +7 -4
- package/src/nvimage.js +22 -3
- package/src/shader-srcs.js +1 -1
package/dist/niivue.es.js
CHANGED
|
@@ -1095,7 +1095,7 @@ void main() {
|
|
|
1095
1095
|
//if (aout <= 0.0) return;
|
|
1096
1096
|
//color.rgb = ((ocolor.rgb * ocolor.a) + (color.rgb * color.a * (1.0 - ocolor.a))) / aout;
|
|
1097
1097
|
color.rgb = mix(color.rgb, ocolor.rgb, ocolor.a);
|
|
1098
|
-
color.a = 1.0;
|
|
1098
|
+
//color.a = 1.0;
|
|
1099
1099
|
}`;
|
|
1100
1100
|
var fragRectShader = `#version 300 es
|
|
1101
1101
|
#line 189
|
|
@@ -100009,7 +100009,7 @@ function requireSeries() {
|
|
|
100009
100009
|
var daikon2 = daikon2 || {};
|
|
100010
100010
|
daikon2.CompressionUtils = daikon2.CompressionUtils || (typeof commonjsRequire !== "undefined" ? requireCompressionUtils() : null);
|
|
100011
100011
|
daikon2.Dictionary = daikon2.Dictionary || (typeof commonjsRequire !== "undefined" ? requireDictionary() : null);
|
|
100012
|
-
daikon2.Image = daikon2.Image || (typeof commonjsRequire !== "undefined" ? requireImage() : null);
|
|
100012
|
+
daikon2.Image = daikon2.Image || (typeof commonjsRequire !== "undefined" ? requireImage().default : null);
|
|
100013
100013
|
daikon2.OrderedMapIterator = daikon2.OrderedMapIterator || (typeof commonjsRequire !== "undefined" ? requireIterator() : null);
|
|
100014
100014
|
daikon2.OrderedMap = daikon2.OrderedMap || (typeof commonjsRequire !== "undefined" ? requireOrderedmap() : null);
|
|
100015
100015
|
daikon2.Parser = daikon2.Parser || (typeof commonjsRequire !== "undefined" ? requireParser() : null);
|
|
@@ -106861,7 +106861,12 @@ NVImage.loadFromUrl = async function({
|
|
|
106861
106861
|
throw Error(response.statusText);
|
|
106862
106862
|
}
|
|
106863
106863
|
var re = /(?:\.([^.]+))?$/;
|
|
106864
|
-
let ext =
|
|
106864
|
+
let ext = "";
|
|
106865
|
+
if (name === "") {
|
|
106866
|
+
ext = re.exec(url)[1];
|
|
106867
|
+
} else {
|
|
106868
|
+
ext = re.exec(name)[1];
|
|
106869
|
+
}
|
|
106865
106870
|
if (ext.toUpperCase() === "NHDR")
|
|
106866
106871
|
;
|
|
106867
106872
|
else if (ext.toUpperCase() === "HEAD") {
|
|
@@ -106869,8 +106874,18 @@ NVImage.loadFromUrl = async function({
|
|
|
106869
106874
|
urlImgData = url.substring(0, url.lastIndexOf("HEAD")) + "BRIK";
|
|
106870
106875
|
}
|
|
106871
106876
|
}
|
|
106872
|
-
let urlParts
|
|
106873
|
-
name
|
|
106877
|
+
let urlParts;
|
|
106878
|
+
if (name === "") {
|
|
106879
|
+
try {
|
|
106880
|
+
urlParts = new URL(url).pathname.split("/");
|
|
106881
|
+
} catch (e) {
|
|
106882
|
+
urlParts = url.split("/");
|
|
106883
|
+
}
|
|
106884
|
+
name = urlParts.slice(-1)[0];
|
|
106885
|
+
if (name.indexOf("?") > -1) {
|
|
106886
|
+
name = name.slice(0, name.indexOf("?"));
|
|
106887
|
+
}
|
|
106888
|
+
}
|
|
106874
106889
|
let dataBuffer = await response.arrayBuffer();
|
|
106875
106890
|
let pairedImgData = null;
|
|
106876
106891
|
if (urlImgData.length > 0) {
|
|
@@ -112052,8 +112067,15 @@ const MESH_EXTENSIONS = [
|
|
|
112052
112067
|
"VTK",
|
|
112053
112068
|
"X3D"
|
|
112054
112069
|
];
|
|
112070
|
+
const dragModes = Object.freeze({
|
|
112071
|
+
none: 0,
|
|
112072
|
+
contrast: 1,
|
|
112073
|
+
measurement: 2,
|
|
112074
|
+
pan: 3
|
|
112075
|
+
});
|
|
112055
112076
|
function Niivue(options = {}) {
|
|
112056
112077
|
this.opts = {};
|
|
112078
|
+
this.dragModes = dragModes;
|
|
112057
112079
|
this.defaults = {
|
|
112058
112080
|
textHeight: 0.06,
|
|
112059
112081
|
colorbarHeight: 0.05,
|
|
@@ -112080,8 +112102,7 @@ function Niivue(options = {}) {
|
|
|
112080
112102
|
multiplanarPadPixels: 0,
|
|
112081
112103
|
isRadiologicalConvention: false,
|
|
112082
112104
|
meshThicknessOn2D: Infinity,
|
|
112083
|
-
|
|
112084
|
-
isDragForPanZoom: false,
|
|
112105
|
+
dragMode: dragModes.contrast,
|
|
112085
112106
|
isDepthPickMesh: false,
|
|
112086
112107
|
isCornerOrientationText: false,
|
|
112087
112108
|
sagittalNoseLeft: false,
|
|
@@ -112101,6 +112122,8 @@ function Niivue(options = {}) {
|
|
|
112101
112122
|
},
|
|
112102
112123
|
onImageLoaded: () => {
|
|
112103
112124
|
},
|
|
112125
|
+
onFrameChange: () => {
|
|
112126
|
+
},
|
|
112104
112127
|
onError: () => {
|
|
112105
112128
|
},
|
|
112106
112129
|
onInfo: () => {
|
|
@@ -112422,9 +112445,9 @@ Niivue.prototype.handleMessage = function(msg, sessionCreatedCallback, sessionJo
|
|
|
112422
112445
|
break;
|
|
112423
112446
|
case REMOVE_VOLUME_URL:
|
|
112424
112447
|
{
|
|
112425
|
-
let
|
|
112426
|
-
if (
|
|
112427
|
-
this.removeVolume(
|
|
112448
|
+
let volume2 = this.getMediaByUrl(msg["url"]);
|
|
112449
|
+
if (volume2) {
|
|
112450
|
+
this.removeVolume(volume2, false);
|
|
112428
112451
|
}
|
|
112429
112452
|
}
|
|
112430
112453
|
break;
|
|
@@ -112436,16 +112459,16 @@ Niivue.prototype.handleMessage = function(msg, sessionCreatedCallback, sessionJo
|
|
|
112436
112459
|
}
|
|
112437
112460
|
case SET_4D_VOL_INDEX:
|
|
112438
112461
|
{
|
|
112439
|
-
let
|
|
112440
|
-
if (
|
|
112441
|
-
this.setFrame4D(
|
|
112462
|
+
let volume2 = this.getMediaByUrl(msg["url"]);
|
|
112463
|
+
if (volume2) {
|
|
112464
|
+
this.setFrame4D(volume2.id, msg["index"]);
|
|
112442
112465
|
}
|
|
112443
112466
|
}
|
|
112444
112467
|
break;
|
|
112445
112468
|
case UPDATE_IMAGE_OPTIONS: {
|
|
112446
|
-
let
|
|
112447
|
-
if (
|
|
112448
|
-
|
|
112469
|
+
let volume2 = this.getMediaByUrl(msg["urlImageOptions"].url);
|
|
112470
|
+
if (volume2) {
|
|
112471
|
+
volume2.applyOptionsUpdate(msg["urlImageOptions"]);
|
|
112449
112472
|
this.updateGLVolume();
|
|
112450
112473
|
}
|
|
112451
112474
|
}
|
|
@@ -112533,6 +112556,8 @@ Niivue.prototype.mouseLeftButtonHandler = function(e) {
|
|
|
112533
112556
|
};
|
|
112534
112557
|
Niivue.prototype.mouseRightButtonHandler = function(e) {
|
|
112535
112558
|
let pos = this.getNoPaddingNoBorderCanvasRelativeMousePosition(e, this.gl.canvas);
|
|
112559
|
+
if (this.opts.dragMode === dragModes.none)
|
|
112560
|
+
return;
|
|
112536
112561
|
this.setDragStart(pos.x, pos.y);
|
|
112537
112562
|
if (!this.isDragging)
|
|
112538
112563
|
this.scene.pan2DxyzmmAtMouseDown = this.scene.pan2Dxyzmm.slice();
|
|
@@ -112619,9 +112644,9 @@ Niivue.prototype.mouseUpListener = function() {
|
|
|
112619
112644
|
this.drawPenAxCorSag = -1;
|
|
112620
112645
|
if (this.isDragging) {
|
|
112621
112646
|
this.isDragging = false;
|
|
112622
|
-
if (this.opts.
|
|
112623
|
-
|
|
112624
|
-
if (this.opts.
|
|
112647
|
+
if (this.opts.dragMode === dragModes.contrast)
|
|
112648
|
+
console.log("Poko");
|
|
112649
|
+
if (this.opts.dragMode !== dragModes.contrast)
|
|
112625
112650
|
return;
|
|
112626
112651
|
this.calculateNewRange();
|
|
112627
112652
|
this.refreshLayers(this.volumes[0], 0, this.volumes.length);
|
|
@@ -112675,7 +112700,7 @@ Niivue.prototype.touchEndListener = function(e) {
|
|
|
112675
112700
|
}
|
|
112676
112701
|
if (this.isDragging) {
|
|
112677
112702
|
this.isDragging = false;
|
|
112678
|
-
if (this.opts.
|
|
112703
|
+
if (this.opts.dragMode !== dragModes.contrast)
|
|
112679
112704
|
return;
|
|
112680
112705
|
this.calculateNewRange();
|
|
112681
112706
|
this.refreshLayers(this.volumes[0], 0, this.volumes.length);
|
|
@@ -112900,37 +112925,37 @@ Niivue.prototype.getFileExt = function(fullname, upperCase = true) {
|
|
|
112900
112925
|
return upperCase ? ext : ext.toLowerCase();
|
|
112901
112926
|
};
|
|
112902
112927
|
Niivue.prototype.loadVolumeFromUrl = async function(imageOptions) {
|
|
112903
|
-
let
|
|
112904
|
-
return
|
|
112928
|
+
let volume2 = await NVImage.loadFromUrl(imageOptions);
|
|
112929
|
+
return volume2;
|
|
112905
112930
|
};
|
|
112906
|
-
Niivue.prototype.notifySubscribersOfOptionChange = function(
|
|
112931
|
+
Niivue.prototype.notifySubscribersOfOptionChange = function(volume2) {
|
|
112907
112932
|
if (this.isInSession) {
|
|
112908
|
-
if (this.mediaUrlMap.has(
|
|
112909
|
-
let imageOptions =
|
|
112910
|
-
imageOptions.url = this.mediaUrlMap.get(
|
|
112933
|
+
if (this.mediaUrlMap.has(volume2)) {
|
|
112934
|
+
let imageOptions = volume2.getImageOptions();
|
|
112935
|
+
imageOptions.url = this.mediaUrlMap.get(volume2);
|
|
112911
112936
|
this.serverConnection$.next(new NVMessage(UPDATE_IMAGE_OPTIONS, imageOptions, this.sessionKey));
|
|
112912
112937
|
console.log("update called");
|
|
112913
112938
|
}
|
|
112914
112939
|
}
|
|
112915
112940
|
};
|
|
112916
112941
|
Niivue.prototype.addVolumeFromUrl = async function(imageOptions, notifySubscribers = true) {
|
|
112917
|
-
let
|
|
112918
|
-
this.addVolume(
|
|
112919
|
-
if (!this.mediaUrlMap.has(
|
|
112920
|
-
this.mediaUrlMap.set(
|
|
112942
|
+
let volume2 = await this.loadVolumeFromUrl(imageOptions);
|
|
112943
|
+
this.addVolume(volume2);
|
|
112944
|
+
if (!this.mediaUrlMap.has(volume2) && imageOptions.url) {
|
|
112945
|
+
this.mediaUrlMap.set(volume2, imageOptions.url);
|
|
112921
112946
|
if (this.isInSession && notifySubscribers) {
|
|
112922
112947
|
this.serverConnection$.next(new NVMessage(ADD_VOLUME_URL, imageOptions, this.sessionKey));
|
|
112923
112948
|
}
|
|
112924
112949
|
}
|
|
112925
|
-
return
|
|
112950
|
+
return volume2;
|
|
112926
112951
|
};
|
|
112927
112952
|
Niivue.prototype.getMediaByUrl = function(url) {
|
|
112928
112953
|
return [...this.mediaUrlMap.entries()].filter((v) => v[1] == url).map((v) => v[0]).pop();
|
|
112929
112954
|
};
|
|
112930
112955
|
Niivue.prototype.removeVolumeByUrl = function(url) {
|
|
112931
|
-
let
|
|
112932
|
-
if (
|
|
112933
|
-
this.removeVolume(
|
|
112956
|
+
let volume2 = this.getMediaByUrl(url);
|
|
112957
|
+
if (volume2) {
|
|
112958
|
+
this.removeVolume(volume2);
|
|
112934
112959
|
}
|
|
112935
112960
|
};
|
|
112936
112961
|
Niivue.prototype.readDirectory = function(directory) {
|
|
@@ -112957,13 +112982,13 @@ Niivue.prototype.readDirectory = function(directory) {
|
|
|
112957
112982
|
readEntries();
|
|
112958
112983
|
} else {
|
|
112959
112984
|
let allFileObects = await getFileObjects(allEntiresInDir);
|
|
112960
|
-
let
|
|
112985
|
+
let volume2 = await NVImage.loadFromFile({
|
|
112961
112986
|
file: allFileObects,
|
|
112962
112987
|
name: directory.name,
|
|
112963
112988
|
urlImgData: null,
|
|
112964
112989
|
isDICOMDIR: true
|
|
112965
112990
|
});
|
|
112966
|
-
this.addVolume(
|
|
112991
|
+
this.addVolume(volume2);
|
|
112967
112992
|
}
|
|
112968
112993
|
});
|
|
112969
112994
|
};
|
|
@@ -113036,18 +113061,18 @@ Niivue.prototype.dropListener = async function(e) {
|
|
|
113036
113061
|
entry.file(async (file) => {
|
|
113037
113062
|
if (pairedImageData !== "") {
|
|
113038
113063
|
pairedImageData.file(async (imgfile) => {
|
|
113039
|
-
let
|
|
113064
|
+
let volume2 = await NVImage.loadFromFile({
|
|
113040
113065
|
file,
|
|
113041
113066
|
urlImgData: imgfile
|
|
113042
113067
|
});
|
|
113043
|
-
this.addVolume(
|
|
113068
|
+
this.addVolume(volume2);
|
|
113044
113069
|
});
|
|
113045
113070
|
} else {
|
|
113046
|
-
let
|
|
113071
|
+
let volume2 = await NVImage.loadFromFile({
|
|
113047
113072
|
file,
|
|
113048
113073
|
urlImgData: pairedImageData
|
|
113049
113074
|
});
|
|
113050
|
-
this.addVolume(
|
|
113075
|
+
this.addVolume(volume2);
|
|
113051
113076
|
}
|
|
113052
113077
|
});
|
|
113053
113078
|
} else if (entry.isDirectory) {
|
|
@@ -113091,11 +113116,11 @@ Niivue.prototype.setHighResolutionCapable = function(isHighResolutionCapable) {
|
|
|
113091
113116
|
this.resizeListener();
|
|
113092
113117
|
this.drawScene();
|
|
113093
113118
|
};
|
|
113094
|
-
Niivue.prototype.addVolume = function(
|
|
113095
|
-
this.volumes.push(
|
|
113119
|
+
Niivue.prototype.addVolume = function(volume2) {
|
|
113120
|
+
this.volumes.push(volume2);
|
|
113096
113121
|
let idx = this.volumes.length === 1 ? 0 : this.volumes.length - 1;
|
|
113097
|
-
this.setVolume(
|
|
113098
|
-
this.opts.onImageLoaded(
|
|
113122
|
+
this.setVolume(volume2, idx);
|
|
113123
|
+
this.opts.onImageLoaded(volume2);
|
|
113099
113124
|
};
|
|
113100
113125
|
Niivue.prototype.addMesh = function(mesh) {
|
|
113101
113126
|
this.meshes.push(mesh);
|
|
@@ -113219,15 +113244,15 @@ Niivue.prototype.loadDrawing = async function(fnm) {
|
|
|
113219
113244
|
if (this.drawBitmap)
|
|
113220
113245
|
console.log("Overwriting open drawing!");
|
|
113221
113246
|
this.drawClearAllUndoBitmaps();
|
|
113222
|
-
let
|
|
113223
|
-
let dims =
|
|
113247
|
+
let volume2 = await this.addVolumeFromUrl(new NVImageFromUrlOptions(fnm));
|
|
113248
|
+
let dims = volume2.hdr.dims;
|
|
113224
113249
|
if (dims[1] !== this.back.hdr.dims[1] || dims[2] !== this.back.hdr.dims[2] || dims[3] !== this.back.hdr.dims[3]) {
|
|
113225
113250
|
console.log("drawing dimensions do not match background image");
|
|
113226
113251
|
return false;
|
|
113227
113252
|
}
|
|
113228
|
-
if (
|
|
113253
|
+
if (volume2.img.constructor !== Uint8Array)
|
|
113229
113254
|
console.log("Drawings should be UINT8");
|
|
113230
|
-
let perm =
|
|
113255
|
+
let perm = volume2.permRAS;
|
|
113231
113256
|
let vx = dims[1] * dims[2] * dims[3];
|
|
113232
113257
|
this.drawBitmap = new Uint8Array(vx);
|
|
113233
113258
|
this.drawTexture = this.r8Tex(this.drawTexture, this.gl.TEXTURE7, this.back.dims, true);
|
|
@@ -113269,7 +113294,7 @@ Niivue.prototype.loadDrawing = async function(fnm) {
|
|
|
113269
113294
|
zlut = range(dims[3] - 1, 0, -1);
|
|
113270
113295
|
for (let i2 = 0; i2 < dims[3]; i2++)
|
|
113271
113296
|
zlut[i2] *= instride[2];
|
|
113272
|
-
let inVs =
|
|
113297
|
+
let inVs = volume2.img;
|
|
113273
113298
|
let outVs = this.drawBitmap;
|
|
113274
113299
|
let j = 0;
|
|
113275
113300
|
for (let z = 0; z < dims[3]; z++) {
|
|
@@ -113414,7 +113439,7 @@ Niivue.prototype.getOverlayIndexByID = function(id) {
|
|
|
113414
113439
|
}
|
|
113415
113440
|
return -1;
|
|
113416
113441
|
};
|
|
113417
|
-
Niivue.prototype.setVolume = function(
|
|
113442
|
+
Niivue.prototype.setVolume = function(volume2, toIndex = 0) {
|
|
113418
113443
|
this.volumes.map((v) => {
|
|
113419
113444
|
log.debug(v.name);
|
|
113420
113445
|
});
|
|
@@ -113422,14 +113447,14 @@ Niivue.prototype.setVolume = function(volume, toIndex = 0) {
|
|
|
113422
113447
|
if (toIndex > numberOfLoadedImages) {
|
|
113423
113448
|
return;
|
|
113424
113449
|
}
|
|
113425
|
-
let volIndex = this.getVolumeIndexByID(
|
|
113450
|
+
let volIndex = this.getVolumeIndexByID(volume2.id);
|
|
113426
113451
|
if (toIndex === 0) {
|
|
113427
113452
|
this.volumes.splice(volIndex, 1);
|
|
113428
|
-
this.volumes.unshift(
|
|
113453
|
+
this.volumes.unshift(volume2);
|
|
113429
113454
|
this.back = this.volumes[0];
|
|
113430
113455
|
this.overlays = this.volumes.slice(1);
|
|
113431
113456
|
} else if (toIndex < 0) {
|
|
113432
|
-
this.volumes.splice(this.getVolumeIndexByID(
|
|
113457
|
+
this.volumes.splice(this.getVolumeIndexByID(volume2.id), 1);
|
|
113433
113458
|
this.back = this.volumes[0];
|
|
113434
113459
|
if (this.volumes.length > 1) {
|
|
113435
113460
|
this.overlays = this.volumes.slice(1);
|
|
@@ -113438,7 +113463,7 @@ Niivue.prototype.setVolume = function(volume, toIndex = 0) {
|
|
|
113438
113463
|
}
|
|
113439
113464
|
} else {
|
|
113440
113465
|
this.volumes.splice(volIndex, 1);
|
|
113441
|
-
this.volumes.splice(toIndex, 0,
|
|
113466
|
+
this.volumes.splice(toIndex, 0, volume2);
|
|
113442
113467
|
this.overlays = this.volumes.slice(1);
|
|
113443
113468
|
this.back = this.volumes[0];
|
|
113444
113469
|
}
|
|
@@ -113470,14 +113495,14 @@ Niivue.prototype.setMesh = function(mesh, toIndex = 0) {
|
|
|
113470
113495
|
log.debug(m.name);
|
|
113471
113496
|
});
|
|
113472
113497
|
};
|
|
113473
|
-
Niivue.prototype.removeVolume = function(
|
|
113474
|
-
this.setVolume(
|
|
113475
|
-
if (this.mediaUrlMap.has(
|
|
113476
|
-
let url = this.mediaUrlMap.get(
|
|
113498
|
+
Niivue.prototype.removeVolume = function(volume2, notifySubscribers = true) {
|
|
113499
|
+
this.setVolume(volume2, -1);
|
|
113500
|
+
if (this.mediaUrlMap.has(volume2)) {
|
|
113501
|
+
let url = this.mediaUrlMap.get(volume2);
|
|
113477
113502
|
if (notifySubscribers && this.isInSession) {
|
|
113478
113503
|
this.serverConnection$.next(new NVMessage(REMOVE_VOLUME_URL, url, this.sessionKey));
|
|
113479
113504
|
}
|
|
113480
|
-
this.mediaUrlMap.delete(
|
|
113505
|
+
this.mediaUrlMap.delete(volume2);
|
|
113481
113506
|
}
|
|
113482
113507
|
};
|
|
113483
113508
|
Niivue.prototype.removeVolumeByIndex = function(index) {
|
|
@@ -113508,19 +113533,19 @@ Niivue.prototype.removeMesh = function(mesh, notifySubscribers = true) {
|
|
|
113508
113533
|
}
|
|
113509
113534
|
}
|
|
113510
113535
|
};
|
|
113511
|
-
Niivue.prototype.moveVolumeToBottom = function(
|
|
113512
|
-
this.setVolume(
|
|
113536
|
+
Niivue.prototype.moveVolumeToBottom = function(volume2) {
|
|
113537
|
+
this.setVolume(volume2, 0);
|
|
113513
113538
|
};
|
|
113514
|
-
Niivue.prototype.moveVolumeUp = function(
|
|
113515
|
-
let volIdx = this.getVolumeIndexByID(
|
|
113516
|
-
this.setVolume(
|
|
113539
|
+
Niivue.prototype.moveVolumeUp = function(volume2) {
|
|
113540
|
+
let volIdx = this.getVolumeIndexByID(volume2.id);
|
|
113541
|
+
this.setVolume(volume2, volIdx + 1);
|
|
113517
113542
|
};
|
|
113518
|
-
Niivue.prototype.moveVolumeDown = function(
|
|
113519
|
-
let volIdx = this.getVolumeIndexByID(
|
|
113520
|
-
this.setVolume(
|
|
113543
|
+
Niivue.prototype.moveVolumeDown = function(volume2) {
|
|
113544
|
+
let volIdx = this.getVolumeIndexByID(volume2.id);
|
|
113545
|
+
this.setVolume(volume2, volIdx - 1);
|
|
113521
113546
|
};
|
|
113522
|
-
Niivue.prototype.moveVolumeToTop = function(
|
|
113523
|
-
this.setVolume(
|
|
113547
|
+
Niivue.prototype.moveVolumeToTop = function(volume2) {
|
|
113548
|
+
this.setVolume(volume2, this.volumes.length - 1);
|
|
113524
113549
|
};
|
|
113525
113550
|
Niivue.prototype.mouseDown = function mouseDown(x2, y) {
|
|
113526
113551
|
x2 *= this.scene.dpr;
|
|
@@ -113591,7 +113616,7 @@ Niivue.prototype.setSelectionBoxColor = function(color) {
|
|
|
113591
113616
|
this.opts.selectionBoxColor = color;
|
|
113592
113617
|
};
|
|
113593
113618
|
Niivue.prototype.sliceScroll2D = function(posChange, x2, y, isDelta = true) {
|
|
113594
|
-
if (posChange !== 0 && this.opts.
|
|
113619
|
+
if (posChange !== 0 && this.opts.dragMode === dragModes.pan) {
|
|
113595
113620
|
let zoom = this.scene.pan2Dxyzmm[3] * (1 + 10 * posChange);
|
|
113596
113621
|
zoom = Math.round(zoom * 10) / 10;
|
|
113597
113622
|
this.scene.pan2Dxyzmm[3] = zoom;
|
|
@@ -113623,8 +113648,8 @@ Niivue.prototype.setClipPlaneColor = function(color) {
|
|
|
113623
113648
|
this.gl.uniform4fv(this.renderShader.clipPlaneClrLoc, this.opts.clipPlaneColor);
|
|
113624
113649
|
this.drawScene();
|
|
113625
113650
|
};
|
|
113626
|
-
Niivue.prototype.overlayRGBA = function(
|
|
113627
|
-
let hdr =
|
|
113651
|
+
Niivue.prototype.overlayRGBA = function(volume2) {
|
|
113652
|
+
let hdr = volume2.hdr;
|
|
113628
113653
|
let vox = hdr.dims[1] * hdr.dims[2] * hdr.dims[3];
|
|
113629
113654
|
let imgRGBA = new Uint8ClampedArray(vox * 4);
|
|
113630
113655
|
let radius = 0.2 * Math.min(Math.min(hdr.dims[1], hdr.dims[2]), hdr.dims[3]);
|
|
@@ -113796,9 +113821,9 @@ Niivue.prototype.r16Tex = function(texID, activeID, dims, img16 = []) {
|
|
|
113796
113821
|
this.gl.texSubImage3D(this.gl.TEXTURE_3D, 0, 0, 0, 0, dims[1], dims[2], dims[3], this.gl.RED_INTEGER, this.gl.SHORT, img16);
|
|
113797
113822
|
return texID;
|
|
113798
113823
|
};
|
|
113799
|
-
function img2ras16(
|
|
113800
|
-
let dims =
|
|
113801
|
-
let perm =
|
|
113824
|
+
function img2ras16(volume2) {
|
|
113825
|
+
let dims = volume2.hdr.dims;
|
|
113826
|
+
let perm = volume2.permRAS;
|
|
113802
113827
|
let vx = dims[1] * dims[2] * dims[3];
|
|
113803
113828
|
let img16 = new Int16Array(vx);
|
|
113804
113829
|
let layout = [0, 0, 0];
|
|
@@ -113843,7 +113868,7 @@ function img2ras16(volume) {
|
|
|
113843
113868
|
for (let z = 0; z < dims[3]; z++) {
|
|
113844
113869
|
for (let y = 0; y < dims[2]; y++) {
|
|
113845
113870
|
for (let x2 = 0; x2 < dims[1]; x2++) {
|
|
113846
|
-
img16[xlut[x2] + ylut[y] + zlut[z]] =
|
|
113871
|
+
img16[xlut[x2] + ylut[y] + zlut[z]] = volume2.img[j];
|
|
113847
113872
|
j++;
|
|
113848
113873
|
}
|
|
113849
113874
|
}
|
|
@@ -114940,6 +114965,7 @@ Niivue.prototype.setFrame4D = function(id, frame4D) {
|
|
|
114940
114965
|
let url = this.mediaUrlMap.get(this.volumes[idx]);
|
|
114941
114966
|
this.serverConnection$.next(new NVMessage(SET_4D_VOL_INDEX, new NVMessageSet4DVolumeIndexData(url, frame4D), this.sessionKey));
|
|
114942
114967
|
}
|
|
114968
|
+
this.opts.onFrameChange({ volume, frame4D });
|
|
114943
114969
|
};
|
|
114944
114970
|
Niivue.prototype.getFrame4D = function(id) {
|
|
114945
114971
|
let idx = this.getVolumeIndexByID(id);
|
|
@@ -115060,8 +115086,7 @@ Niivue.prototype.mouseClick = function(x2, y, posChange = 0, isDelta = true) {
|
|
|
115060
115086
|
let pos = [x2 - this.graph.plotLTWH[0], y - this.graph.plotLTWH[1]];
|
|
115061
115087
|
if (pos[0] > 0 && pos[1] > 0 && pos[0] <= this.graph.plotLTWH[2] && pos[1] <= this.graph.plotLTWH[3]) {
|
|
115062
115088
|
let vol = Math.round(pos[0] / this.graph.plotLTWH[2] * (this.volumes[0].nFrame4D - 1));
|
|
115063
|
-
this.volumes[0].
|
|
115064
|
-
this.updateGLVolume();
|
|
115089
|
+
this.setFrame4D(this.volumes[0].id, vol);
|
|
115065
115090
|
return;
|
|
115066
115091
|
}
|
|
115067
115092
|
}
|
|
@@ -115766,6 +115791,8 @@ Niivue.prototype.draw2DMM = function(leftTopWidthHeight, axCorSag, customMM = Na
|
|
|
115766
115791
|
this.sliceMMShader.use(this.gl);
|
|
115767
115792
|
gl.uniform1i(this.sliceMMShader.backgroundMasksOverlaysLoc, this.backgroundMasksOverlays);
|
|
115768
115793
|
gl.uniform1f(this.sliceMMShader.drawOpacityLoc, this.drawOpacity);
|
|
115794
|
+
gl.enable(gl.BLEND);
|
|
115795
|
+
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
115769
115796
|
gl.uniform1f(this.sliceMMShader.opacityLoc, this.volumes[0].opacity);
|
|
115770
115797
|
gl.uniform1i(this.sliceMMShader.axCorSagLoc, axCorSag);
|
|
115771
115798
|
gl.uniform1f(this.sliceMMShader.sliceLoc, sliceFrac);
|
|
@@ -115795,7 +115822,6 @@ Niivue.prototype.draw2DMM = function(leftTopWidthHeight, axCorSag, customMM = Na
|
|
|
115795
115822
|
this.drawSliceOrientationText(leftTopWidthHeight, axCorSag);
|
|
115796
115823
|
this.readyForSync = true;
|
|
115797
115824
|
};
|
|
115798
|
-
Niivue.prototype.drawCro;
|
|
115799
115825
|
Niivue.prototype.draw2DVox = function(leftTopWidthHeight, axCorSag, customMM = NaN) {
|
|
115800
115826
|
let gl = this.gl;
|
|
115801
115827
|
let fovMM = this.screenFieldOfViewMM(axCorSag);
|
|
@@ -115839,6 +115865,8 @@ Niivue.prototype.draw2DVox = function(leftTopWidthHeight, axCorSag, customMM = N
|
|
|
115839
115865
|
isMirrorLR = !isMirrorLR;
|
|
115840
115866
|
this.sliceShader.use(this.gl);
|
|
115841
115867
|
gl.uniform1f(this.sliceShader.drawOpacityLoc, this.drawOpacity);
|
|
115868
|
+
gl.enable(gl.BLEND);
|
|
115869
|
+
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
|
|
115842
115870
|
gl.uniform1f(this.sliceShader.opacityLoc, this.volumes[0].opacity);
|
|
115843
115871
|
gl.uniform1i(this.sliceShader.backgroundMasksOverlaysLoc, this.backgroundMasksOverlays);
|
|
115844
115872
|
gl.uniform1i(this.sliceShader.axCorSagLoc, axCorSag);
|
|
@@ -117020,7 +117048,7 @@ Niivue.prototype.drawScene = function() {
|
|
|
117020
117048
|
if (this.opts.isColorbar)
|
|
117021
117049
|
this.drawColorbar();
|
|
117022
117050
|
if (this.isDragging) {
|
|
117023
|
-
if (this.opts.
|
|
117051
|
+
if (this.opts.dragMode === dragModes.pan) {
|
|
117024
117052
|
this.dragForPanZoom([
|
|
117025
117053
|
this.dragStart[0],
|
|
117026
117054
|
this.dragStart[1],
|
|
@@ -117029,7 +117057,7 @@ Niivue.prototype.drawScene = function() {
|
|
|
117029
117057
|
]);
|
|
117030
117058
|
return;
|
|
117031
117059
|
}
|
|
117032
|
-
if (this.opts.
|
|
117060
|
+
if (this.opts.dragMode === dragModes.measurement) {
|
|
117033
117061
|
this.drawMeasurementTool([
|
|
117034
117062
|
this.dragStart[0],
|
|
117035
117063
|
this.dragStart[1],
|
|
@@ -117038,6 +117066,7 @@ Niivue.prototype.drawScene = function() {
|
|
|
117038
117066
|
]);
|
|
117039
117067
|
return;
|
|
117040
117068
|
}
|
|
117069
|
+
console.log(this.opts.dragMode === dragModes.measurement, ">>", this.opts.dragMode, dragModes.measurement);
|
|
117041
117070
|
if (this.inRenderTile(this.dragStart[0], this.dragStart[1]) >= 0)
|
|
117042
117071
|
return;
|
|
117043
117072
|
let width = Math.abs(this.dragStart[0] - this.dragEnd[0]);
|
|
@@ -117060,4 +117089,4 @@ Niivue.prototype.drawScene = function() {
|
|
|
117060
117089
|
this.readyForSync = true;
|
|
117061
117090
|
return posString;
|
|
117062
117091
|
};
|
|
117063
|
-
export { NVImage, NVImageFromUrlOptions, NVMesh, NVMeshFromUrlOptions, Niivue, colortables };
|
|
117092
|
+
export { NVImage, NVImageFromUrlOptions, NVMesh, NVMeshFromUrlOptions, Niivue, colortables, dragModes };
|