@niivue/niivue 0.43.7 → 0.44.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/build/index.d.ts +14 -1
- package/build/index.js +121 -26
- package/build/index.js.map +1 -1
- package/build/index.min.js +1 -1
- package/dist/index.d.ts +14 -1
- package/dist/index.js +121 -26
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/niivue.umd.js +25 -25
- package/package.json +1 -1
- package/src/index.html +5 -1
- package/src/niivue/index.ts +139 -27
- package/src/nvdocument.ts +10 -0
- package/src/nvimage/utils.ts +2 -0
package/build/index.d.ts
CHANGED
|
@@ -211,6 +211,7 @@ type ImageFromUrlOptions = {
|
|
|
211
211
|
useQFormNotSForm?: boolean;
|
|
212
212
|
alphaThreshold?: boolean;
|
|
213
213
|
colormapNegative?: string;
|
|
214
|
+
colorMapNegative?: string;
|
|
214
215
|
cal_minNeg?: number;
|
|
215
216
|
cal_maxNeg?: number;
|
|
216
217
|
colorbarVisible?: boolean;
|
|
@@ -558,6 +559,11 @@ declare enum SLICE_TYPE {
|
|
|
558
559
|
MULTIPLANAR = 3,
|
|
559
560
|
RENDER = 4
|
|
560
561
|
}
|
|
562
|
+
declare enum SHOW_RENDER {
|
|
563
|
+
NEVER = 0,
|
|
564
|
+
ALWAYS = 1,
|
|
565
|
+
AUTO = 2
|
|
566
|
+
}
|
|
561
567
|
/**
|
|
562
568
|
* Multi-planar layout
|
|
563
569
|
* @ignore
|
|
@@ -613,6 +619,7 @@ type NVConfigOptions = {
|
|
|
613
619
|
isOrientCube: boolean;
|
|
614
620
|
multiplanarPadPixels: number;
|
|
615
621
|
multiplanarForceRender: boolean;
|
|
622
|
+
multiplanarShowRender: SHOW_RENDER;
|
|
616
623
|
isRadiologicalConvention: boolean;
|
|
617
624
|
meshThicknessOn2D: number | string;
|
|
618
625
|
dragMode: DRAG_MODE;
|
|
@@ -2059,6 +2066,7 @@ declare class Niivue {
|
|
|
2059
2066
|
* @see {@link https://niivue.github.io/niivue/features/document.3d.html | live demo usage}
|
|
2060
2067
|
*/
|
|
2061
2068
|
addVolumeFromUrl(imageOptions: ImageFromUrlOptions): Promise<NVImage>;
|
|
2069
|
+
addVolumesFromUrl(imageOptionsArray: ImageFromUrlOptions[]): Promise<NVImage[]>;
|
|
2062
2070
|
/**
|
|
2063
2071
|
* Find media by url
|
|
2064
2072
|
*/
|
|
@@ -2572,6 +2580,11 @@ declare class Niivue {
|
|
|
2572
2580
|
* @see {@link https://niivue.github.io/niivue/features/multiuser.meshes.html | live demo usage}
|
|
2573
2581
|
*/
|
|
2574
2582
|
addMeshFromUrl(meshOptions: LoadFromUrlParams): Promise<NVMesh>;
|
|
2583
|
+
/**
|
|
2584
|
+
* Add mesh and notify subscribers
|
|
2585
|
+
* @see {@link https://niivue.github.io/niivue/features/multiuser.meshes.html | live demo usage}
|
|
2586
|
+
*/
|
|
2587
|
+
addMeshesFromUrl(meshOptions: LoadFromUrlParams[]): Promise<NVMesh[]>;
|
|
2575
2588
|
/**
|
|
2576
2589
|
* load an array of meshes
|
|
2577
2590
|
* @param meshList - the array of objects to load. each object must have a resolvable "url" property at a minimum
|
|
@@ -2996,4 +3009,4 @@ declare class Niivue {
|
|
|
2996
3009
|
set gl(gl: WebGL2RenderingContext | null);
|
|
2997
3010
|
}
|
|
2998
3011
|
|
|
2999
|
-
export { type Connectome, type ConnectomeOptions, DEFAULT_OPTIONS, DRAG_MODE, type DocumentData, type DragReleaseParams, type ExportDocumentData, INITIAL_SCENE_DATA, LabelLineTerminator, LabelTextAlignment, type LegacyConnectome, type LegacyNodes, MULTIPLANAR_TYPE, type NVConfigOptions, type NVConnectomeEdge, type NVConnectomeNode, NVController, NVDocument, NVImage, NVImageFromUrlOptions, NVLabel3D, NVLabel3DStyle, NVMesh, NVMeshFromUrlOptions, NVMeshLayerDefaults, NVMeshLoaders, NVUtilities, type NiftiHeader, type NiiVueLocation, type NiiVueLocationValue, Niivue, type Point, SLICE_TYPE, type Scene, type Volume, cmapper, ColorTables as colortables };
|
|
3012
|
+
export { type Connectome, type ConnectomeOptions, DEFAULT_OPTIONS, DRAG_MODE, type DocumentData, type DragReleaseParams, type ExportDocumentData, INITIAL_SCENE_DATA, LabelLineTerminator, LabelTextAlignment, type LegacyConnectome, type LegacyNodes, MULTIPLANAR_TYPE, type NVConfigOptions, type NVConnectomeEdge, type NVConnectomeNode, NVController, NVDocument, NVImage, NVImageFromUrlOptions, NVLabel3D, NVLabel3DStyle, NVMesh, NVMeshFromUrlOptions, NVMeshLayerDefaults, NVMeshLoaders, NVUtilities, type NiftiHeader, type NiiVueLocation, type NiiVueLocationValue, Niivue, type Point, SHOW_RENDER, SLICE_TYPE, type Scene, type Volume, cmapper, ColorTables as colortables };
|
package/build/index.js
CHANGED
|
@@ -13,7 +13,7 @@ var __publicField = (obj, key, value) => {
|
|
|
13
13
|
import { mat4 as mat46, vec2, vec3 as vec311, vec4 as vec48 } from "gl-matrix";
|
|
14
14
|
|
|
15
15
|
// package.json
|
|
16
|
-
var version = "0.
|
|
16
|
+
var version = "0.44.0";
|
|
17
17
|
|
|
18
18
|
// src/logger.ts
|
|
19
19
|
var _Log = class _Log {
|
|
@@ -21929,6 +21929,12 @@ var SLICE_TYPE = /* @__PURE__ */ ((SLICE_TYPE2) => {
|
|
|
21929
21929
|
SLICE_TYPE2[SLICE_TYPE2["RENDER"] = 4] = "RENDER";
|
|
21930
21930
|
return SLICE_TYPE2;
|
|
21931
21931
|
})(SLICE_TYPE || {});
|
|
21932
|
+
var SHOW_RENDER = /* @__PURE__ */ ((SHOW_RENDER2) => {
|
|
21933
|
+
SHOW_RENDER2[SHOW_RENDER2["NEVER"] = 0] = "NEVER";
|
|
21934
|
+
SHOW_RENDER2[SHOW_RENDER2["ALWAYS"] = 1] = "ALWAYS";
|
|
21935
|
+
SHOW_RENDER2[SHOW_RENDER2["AUTO"] = 2] = "AUTO";
|
|
21936
|
+
return SHOW_RENDER2;
|
|
21937
|
+
})(SHOW_RENDER || {});
|
|
21932
21938
|
var MULTIPLANAR_TYPE = /* @__PURE__ */ ((MULTIPLANAR_TYPE2) => {
|
|
21933
21939
|
MULTIPLANAR_TYPE2[MULTIPLANAR_TYPE2["AUTO"] = 0] = "AUTO";
|
|
21934
21940
|
MULTIPLANAR_TYPE2[MULTIPLANAR_TYPE2["COLUMN"] = 1] = "COLUMN";
|
|
@@ -21975,7 +21981,10 @@ var DEFAULT_OPTIONS = {
|
|
|
21975
21981
|
isColorbar: false,
|
|
21976
21982
|
isOrientCube: false,
|
|
21977
21983
|
multiplanarPadPixels: 0,
|
|
21984
|
+
// @deprecated
|
|
21978
21985
|
multiplanarForceRender: false,
|
|
21986
|
+
multiplanarShowRender: 2 /* AUTO */,
|
|
21987
|
+
// auto is the same behaviour as multiplanarForceRender: false
|
|
21979
21988
|
isRadiologicalConvention: false,
|
|
21980
21989
|
meshThicknessOn2D: Infinity,
|
|
21981
21990
|
dragMode: 1 /* contrast */,
|
|
@@ -24997,6 +25006,39 @@ var Niivue = class _Niivue {
|
|
|
24997
25006
|
this.addVolume(volume);
|
|
24998
25007
|
return volume;
|
|
24999
25008
|
}
|
|
25009
|
+
async addVolumesFromUrl(imageOptionsArray) {
|
|
25010
|
+
const promises = imageOptionsArray.map(async (imageItem) => {
|
|
25011
|
+
const imageOptions = {
|
|
25012
|
+
url: imageItem.url,
|
|
25013
|
+
headers: imageItem.headers,
|
|
25014
|
+
name: imageItem.name,
|
|
25015
|
+
colormap: imageItem.colormap ? imageItem.colormap : imageItem.colorMap,
|
|
25016
|
+
colormapNegative: imageItem.colormapNegative ? imageItem.colormapNegative : imageItem.colorMapNegative,
|
|
25017
|
+
opacity: imageItem.opacity,
|
|
25018
|
+
urlImgData: imageItem.urlImgData,
|
|
25019
|
+
cal_min: imageItem.cal_min,
|
|
25020
|
+
cal_max: imageItem.cal_max,
|
|
25021
|
+
trustCalMinMax: this.opts.trustCalMinMax,
|
|
25022
|
+
isManifest: imageItem.isManifest,
|
|
25023
|
+
frame4D: imageItem.frame4D,
|
|
25024
|
+
limitFrames4D: imageItem.limitFrames4D || this.opts.limitFrames4D,
|
|
25025
|
+
colorbarVisible: imageItem.colorbarVisible
|
|
25026
|
+
};
|
|
25027
|
+
const volume = await NVImage.loadFromUrl(imageOptions);
|
|
25028
|
+
this.document.addImageOptions(volume, imageOptions);
|
|
25029
|
+
volume.onColormapChange = this.onColormapChange;
|
|
25030
|
+
this.mediaUrlMap.set(volume, imageOptions.url);
|
|
25031
|
+
if (this.onVolumeAddedFromUrl) {
|
|
25032
|
+
this.onVolumeAddedFromUrl(imageOptions, volume);
|
|
25033
|
+
}
|
|
25034
|
+
return volume;
|
|
25035
|
+
});
|
|
25036
|
+
const volumes = await Promise.all(promises);
|
|
25037
|
+
for (let i = 0; i < volumes.length; i++) {
|
|
25038
|
+
this.addVolume(volumes[i]);
|
|
25039
|
+
}
|
|
25040
|
+
return volumes;
|
|
25041
|
+
}
|
|
25000
25042
|
/**
|
|
25001
25043
|
* Find media by url
|
|
25002
25044
|
*/
|
|
@@ -26775,28 +26817,27 @@ var Niivue = class _Niivue {
|
|
|
26775
26817
|
this.volumes = [];
|
|
26776
26818
|
this.gl.clearColor(0, 0, 0, 1);
|
|
26777
26819
|
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
|
26778
|
-
|
|
26779
|
-
|
|
26780
|
-
|
|
26781
|
-
}
|
|
26782
|
-
const imageOptions = {
|
|
26783
|
-
url: volumeList[i].url,
|
|
26784
|
-
headers: volumeList[i].headers,
|
|
26785
|
-
name: volumeList[i].name,
|
|
26786
|
-
colormap: volumeList[i].colormap,
|
|
26787
|
-
colormapNegative: volumeList[i].colormapNegative,
|
|
26788
|
-
opacity: volumeList[i].opacity,
|
|
26789
|
-
urlImgData: volumeList[i].urlImgData,
|
|
26790
|
-
cal_min: volumeList[i].cal_min,
|
|
26791
|
-
cal_max: volumeList[i].cal_max,
|
|
26792
|
-
trustCalMinMax: this.opts.trustCalMinMax,
|
|
26793
|
-
isManifest: volumeList[i].isManifest,
|
|
26794
|
-
frame4D: volumeList[i].frame4D,
|
|
26795
|
-
limitFrames4D: volumeList[i].limitFrames4D || this.opts.limitFrames4D,
|
|
26796
|
-
colorbarVisible: volumeList[i].colorbarVisible
|
|
26797
|
-
};
|
|
26798
|
-
await this.addVolumeFromUrl(imageOptions);
|
|
26820
|
+
if (volumeList.length > 1) {
|
|
26821
|
+
await this.addVolumesFromUrl(volumeList);
|
|
26822
|
+
return this;
|
|
26799
26823
|
}
|
|
26824
|
+
const imageOptions = {
|
|
26825
|
+
url: volumeList[0].url,
|
|
26826
|
+
headers: volumeList[0].headers,
|
|
26827
|
+
name: volumeList[0].name,
|
|
26828
|
+
colormap: volumeList[0].colormap ? volumeList[0].colormap : volumeList[0].colorMap,
|
|
26829
|
+
colormapNegative: volumeList[0].colormapNegative ? volumeList[0].colormapNegative : volumeList[0].colorMapNegative,
|
|
26830
|
+
opacity: volumeList[0].opacity,
|
|
26831
|
+
urlImgData: volumeList[0].urlImgData,
|
|
26832
|
+
cal_min: volumeList[0].cal_min,
|
|
26833
|
+
cal_max: volumeList[0].cal_max,
|
|
26834
|
+
trustCalMinMax: this.opts.trustCalMinMax,
|
|
26835
|
+
isManifest: volumeList[0].isManifest,
|
|
26836
|
+
frame4D: volumeList[0].frame4D,
|
|
26837
|
+
limitFrames4D: volumeList[0].limitFrames4D || this.opts.limitFrames4D,
|
|
26838
|
+
colorbarVisible: volumeList[0].colorbarVisible
|
|
26839
|
+
};
|
|
26840
|
+
await this.addVolumeFromUrl(imageOptions);
|
|
26800
26841
|
return this;
|
|
26801
26842
|
}
|
|
26802
26843
|
/**
|
|
@@ -26820,6 +26861,32 @@ var Niivue = class _Niivue {
|
|
|
26820
26861
|
this.addMesh(mesh);
|
|
26821
26862
|
return mesh;
|
|
26822
26863
|
}
|
|
26864
|
+
/**
|
|
26865
|
+
* Add mesh and notify subscribers
|
|
26866
|
+
* @see {@link https://niivue.github.io/niivue/features/multiuser.meshes.html | live demo usage}
|
|
26867
|
+
*/
|
|
26868
|
+
async addMeshesFromUrl(meshOptions) {
|
|
26869
|
+
const promises = meshOptions.map(async (meshItem) => {
|
|
26870
|
+
const ext = this.getFileExt(meshItem.url);
|
|
26871
|
+
if (ext === "JCON" || ext === "JSON") {
|
|
26872
|
+
const response = await fetch(meshItem.url, {});
|
|
26873
|
+
const json = await response.json();
|
|
26874
|
+
const mesh2 = this.loadConnectomeAsMesh(json);
|
|
26875
|
+
this.mediaUrlMap.set(mesh2, meshItem.url);
|
|
26876
|
+
this.onMeshAddedFromUrl(meshItem, mesh2);
|
|
26877
|
+
return mesh2;
|
|
26878
|
+
}
|
|
26879
|
+
const mesh = await NVMesh2.loadFromUrl({ ...meshItem, gl: this.gl });
|
|
26880
|
+
this.mediaUrlMap.set(mesh, meshItem.url);
|
|
26881
|
+
this.onMeshAddedFromUrl(meshItem, mesh);
|
|
26882
|
+
return mesh;
|
|
26883
|
+
});
|
|
26884
|
+
const meshes = await Promise.all(promises);
|
|
26885
|
+
for (let i = 0; i < meshes.length; i++) {
|
|
26886
|
+
this.addMesh(meshes[i]);
|
|
26887
|
+
}
|
|
26888
|
+
return meshes;
|
|
26889
|
+
}
|
|
26823
26890
|
/**
|
|
26824
26891
|
* load an array of meshes
|
|
26825
26892
|
* @param meshList - the array of objects to load. each object must have a resolvable "url" property at a minimum
|
|
@@ -26841,9 +26908,13 @@ var Niivue = class _Niivue {
|
|
|
26841
26908
|
this.meshes = [];
|
|
26842
26909
|
this.gl.clearColor(0, 0, 0, 1);
|
|
26843
26910
|
this.gl.clear(this.gl.COLOR_BUFFER_BIT);
|
|
26844
|
-
|
|
26845
|
-
await this.
|
|
26911
|
+
if (meshList.length > 1) {
|
|
26912
|
+
await this.addMeshesFromUrl(meshList);
|
|
26913
|
+
this.updateGLVolume();
|
|
26914
|
+
this.drawScene();
|
|
26915
|
+
return this;
|
|
26846
26916
|
}
|
|
26917
|
+
await this.addMeshFromUrl(meshList[0]);
|
|
26847
26918
|
this.updateGLVolume();
|
|
26848
26919
|
this.drawScene();
|
|
26849
26920
|
return this;
|
|
@@ -30104,6 +30175,9 @@ var Niivue = class _Niivue {
|
|
|
30104
30175
|
width = bulletMargin + longestTextLength;
|
|
30105
30176
|
width += horizontalMargin * 2;
|
|
30106
30177
|
}
|
|
30178
|
+
if (width >= this.gl.canvas.width) {
|
|
30179
|
+
return 0;
|
|
30180
|
+
}
|
|
30107
30181
|
return width;
|
|
30108
30182
|
}
|
|
30109
30183
|
getLegendPanelHeight() {
|
|
@@ -32390,6 +32464,20 @@ var Niivue = class _Niivue {
|
|
|
32390
32464
|
} else if (this.opts.sliceType === 2 /* SAGITTAL */) {
|
|
32391
32465
|
this.draw2D([0, 0, 0, 0], 2);
|
|
32392
32466
|
} else {
|
|
32467
|
+
let isShowRender = false;
|
|
32468
|
+
if (this.opts.multiplanarForceRender) {
|
|
32469
|
+
isShowRender = true;
|
|
32470
|
+
if (this.opts.multiplanarForceRender) {
|
|
32471
|
+
this.opts.multiplanarShowRender = 1 /* ALWAYS */;
|
|
32472
|
+
} else {
|
|
32473
|
+
this.opts.multiplanarShowRender = 2 /* AUTO */;
|
|
32474
|
+
}
|
|
32475
|
+
delete this.opts.multiplanarForceRender;
|
|
32476
|
+
} else {
|
|
32477
|
+
if (this.opts.multiplanarShowRender === 1 /* ALWAYS */) {
|
|
32478
|
+
isShowRender = true;
|
|
32479
|
+
}
|
|
32480
|
+
}
|
|
32393
32481
|
const isDrawPenDown = isFinite(this.drawPenLocation[0]) && this.opts.drawingEnabled;
|
|
32394
32482
|
const { volScale } = this.sliceScale();
|
|
32395
32483
|
if (typeof this.opts.multiplanarPadPixels !== "number") {
|
|
@@ -32431,7 +32519,7 @@ var Niivue = class _Niivue {
|
|
|
32431
32519
|
}
|
|
32432
32520
|
if (isDrawColumn) {
|
|
32433
32521
|
let ltwh = ltwh1x3;
|
|
32434
|
-
if (this.opts.
|
|
32522
|
+
if (isShowRender || this.opts.multiplanarShowRender === 2 /* AUTO */ && ltwh1x4[4] >= ltwh1x3[4]) {
|
|
32435
32523
|
ltwh = ltwh1x4;
|
|
32436
32524
|
} else {
|
|
32437
32525
|
isDraw3D = false;
|
|
@@ -32448,7 +32536,7 @@ var Niivue = class _Niivue {
|
|
|
32448
32536
|
}
|
|
32449
32537
|
} else if (isDrawRow) {
|
|
32450
32538
|
let ltwh = ltwh3x1;
|
|
32451
|
-
if (this.opts.
|
|
32539
|
+
if (isShowRender || this.opts.multiplanarShowRender === 2 /* AUTO */ && ltwh4x1[4] >= ltwh3x1[4]) {
|
|
32452
32540
|
ltwh = ltwh4x1;
|
|
32453
32541
|
} else {
|
|
32454
32542
|
isDraw3D = false;
|
|
@@ -32463,6 +32551,12 @@ var Niivue = class _Niivue {
|
|
|
32463
32551
|
this.draw3D([ltwh[0] + sX + sX + sY + pad * 3, ltwh[1], ltwh[3], ltwh[3]]);
|
|
32464
32552
|
}
|
|
32465
32553
|
} else if (isDrawGrid) {
|
|
32554
|
+
if (!isShowRender) {
|
|
32555
|
+
isDraw3D = false;
|
|
32556
|
+
}
|
|
32557
|
+
if (this.opts.multiplanarShowRender === 2 /* AUTO */) {
|
|
32558
|
+
isDraw3D = true;
|
|
32559
|
+
}
|
|
32466
32560
|
const ltwh = ltwh2x2;
|
|
32467
32561
|
const sX = volScale[0] * ltwh[4];
|
|
32468
32562
|
const sY = volScale[1] * ltwh[4];
|
|
@@ -32587,6 +32681,7 @@ export {
|
|
|
32587
32681
|
NVMeshLoaders,
|
|
32588
32682
|
NVUtilities,
|
|
32589
32683
|
Niivue,
|
|
32684
|
+
SHOW_RENDER,
|
|
32590
32685
|
SLICE_TYPE,
|
|
32591
32686
|
cmapper,
|
|
32592
32687
|
ColorTables as colortables
|