@cornerstonejs/core 1.2.1 → 1.2.3
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/cjs/RenderingEngine/BaseVolumeViewport.d.ts +1 -0
- package/dist/cjs/RenderingEngine/BaseVolumeViewport.js +27 -13
- package/dist/cjs/RenderingEngine/BaseVolumeViewport.js.map +1 -1
- package/dist/cjs/types/Colormap.d.ts +3 -3
- package/dist/esm/RenderingEngine/BaseVolumeViewport.d.ts +1 -0
- package/dist/esm/RenderingEngine/BaseVolumeViewport.js +27 -13
- package/dist/esm/RenderingEngine/BaseVolumeViewport.js.map +1 -1
- package/dist/esm/types/Colormap.d.ts +3 -3
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/package.json +2 -2
- package/src/RenderingEngine/BaseVolumeViewport.ts +35 -16
- package/src/types/Colormap.ts +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cornerstonejs/core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/umd/index.js",
|
|
6
6
|
"types": "dist/esm/index.d.ts",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"type": "individual",
|
|
45
45
|
"url": "https://ohif.org/donate"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "0fa715f59cc1478092759c0d1d0786a196294c79"
|
|
48
48
|
}
|
|
@@ -244,9 +244,9 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
244
244
|
mapper.setSampleDistance(1.0);
|
|
245
245
|
|
|
246
246
|
const cfun = vtkColorTransferFunction.newInstance();
|
|
247
|
-
let colormapObj = colormapUtils.getColormap(colormap);
|
|
247
|
+
let colormapObj = colormapUtils.getColormap(colormap.name);
|
|
248
248
|
|
|
249
|
-
const { name
|
|
249
|
+
const { name } = colormap;
|
|
250
250
|
|
|
251
251
|
if (!colormapObj) {
|
|
252
252
|
colormapObj = vtkColorMaps.getPresetByName(name);
|
|
@@ -264,20 +264,37 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
264
264
|
cfun.applyColorMap(colormapObj);
|
|
265
265
|
cfun.setMappingRange(range[0], range[1]);
|
|
266
266
|
volumeActor.getProperty().setRGBTransferFunction(0, cfun);
|
|
267
|
+
}
|
|
267
268
|
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
269
|
+
/**
|
|
270
|
+
* Sets the opacity for the volume with the given ID.
|
|
271
|
+
*
|
|
272
|
+
* @param colormap - An object containing opacity that can be a number or an array of OpacityMapping
|
|
273
|
+
* @param volumeId - The ID of the volume to set the opacity for.
|
|
274
|
+
*
|
|
275
|
+
* @returns void
|
|
276
|
+
*/
|
|
277
|
+
private setOpacity(colormap: ColormapPublic, volumeId: string) {
|
|
278
|
+
const applicableVolumeActorInfo = this._getApplicableVolumeActor(volumeId);
|
|
279
|
+
if (!applicableVolumeActorInfo) {
|
|
274
280
|
return;
|
|
275
281
|
}
|
|
282
|
+
const { volumeActor } = applicableVolumeActorInfo;
|
|
283
|
+
const ofun = vtkPiecewiseFunction.newInstance();
|
|
284
|
+
if (typeof colormap.opacity === 'number') {
|
|
285
|
+
const range = volumeActor
|
|
286
|
+
.getProperty()
|
|
287
|
+
.getRGBTransferFunction(0)
|
|
288
|
+
.getRange();
|
|
276
289
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
290
|
+
ofun.addPoint(range[0], colormap.opacity);
|
|
291
|
+
ofun.addPoint(range[1], colormap.opacity);
|
|
292
|
+
} else {
|
|
293
|
+
colormap.opacity.forEach(({ opacity, value }) => {
|
|
294
|
+
ofun.addPoint(value, opacity);
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
volumeActor.getProperty().setScalarOpacity(0, ofun);
|
|
281
298
|
}
|
|
282
299
|
|
|
283
300
|
/**
|
|
@@ -435,9 +452,13 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
435
452
|
): void {
|
|
436
453
|
// Note: colormap should always be done first, since we can then
|
|
437
454
|
// modify the voiRange
|
|
438
|
-
|
|
455
|
+
|
|
456
|
+
if (colormap?.name) {
|
|
439
457
|
this.setColormap(colormap, volumeId, suppressEvents);
|
|
440
458
|
}
|
|
459
|
+
if (colormap?.opacity != null) {
|
|
460
|
+
this.setOpacity(colormap, volumeId);
|
|
461
|
+
}
|
|
441
462
|
|
|
442
463
|
if (voiRange !== undefined) {
|
|
443
464
|
this.setVOI(voiRange, volumeId, suppressEvents);
|
|
@@ -500,8 +521,7 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
500
521
|
const [lower, upper] =
|
|
501
522
|
this.VOILUTFunction === 'SIGMOID'
|
|
502
523
|
? getVoiFromSigmoidRGBTransferFunction(cfun)
|
|
503
|
-
:
|
|
504
|
-
cfun.getRange();
|
|
524
|
+
: cfun.getRange();
|
|
505
525
|
return { volumeId, voiRange: { lower, upper } };
|
|
506
526
|
})
|
|
507
527
|
.filter(Boolean);
|
|
@@ -599,7 +619,6 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
|
|
|
599
619
|
`imageVolume with id: ${firstImageVolume.volumeId} does not exist`
|
|
600
620
|
);
|
|
601
621
|
}
|
|
602
|
-
|
|
603
622
|
const volumeActors = [];
|
|
604
623
|
|
|
605
624
|
await this._isValidVolumeInputArray(
|
package/src/types/Colormap.ts
CHANGED
|
@@ -15,7 +15,8 @@ type OpacityMapping = {
|
|
|
15
15
|
|
|
16
16
|
type ColormapPublic = {
|
|
17
17
|
/** name of the colormap */
|
|
18
|
-
name
|
|
18
|
+
name?: string;
|
|
19
|
+
opacity?: OpacityMapping[] | number;
|
|
19
20
|
/** midpoint mapping between values to opacity if the colormap
|
|
20
21
|
* is getting used for fusion, this is an array of arrays which
|
|
21
22
|
* each array containing 2 values, the first value is the value
|
|
@@ -25,7 +26,6 @@ type ColormapPublic = {
|
|
|
25
26
|
* the points in the middle to be mapped to different opacities
|
|
26
27
|
* instead of a linear mapping from 0 to 1.
|
|
27
28
|
*/
|
|
28
|
-
opacityMapping?: OpacityMapping[];
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export type { ColormapRegistration, ColormapPublic };
|
|
31
|
+
export type { ColormapRegistration, ColormapPublic, OpacityMapping };
|