File tree 5 files changed +24
-11
lines changed
5 files changed +24
-11
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
2
2
import vtkActor2D , {
3
3
IActor2DInitialValues ,
4
4
} from '@kitware/vtk.js/Rendering/Core/Actor2D' ;
5
+ import { IColorMapPreset } from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps' ;
5
6
import { ICoordinateInitialValues } from '@kitware/vtk.js/Rendering/Core/Coordinate' ;
6
7
import { Coordinate } from '@kitware/vtk.js/Rendering/Core/Coordinate/Constants' ;
7
8
import vtkMapper2D , {
@@ -55,9 +56,9 @@ export interface Geometry2DRepresentationProps extends PropsWithChildren {
55
56
property ?: IProperty2DInitialValues ;
56
57
57
58
/**
58
- * Preset name for the lookup table color map
59
+ * Preset name for the lookup table color map or user provided color map preset
59
60
*/
60
- colorMapPreset ?: string ;
61
+ colorMapPreset ?: string | IColorMapPreset ;
61
62
62
63
/**
63
64
* Data range use for the colorMap
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import vtkPolyData from '@kitware/vtk.js/Common/DataModel/PolyData';
2
2
import vtkActor , {
3
3
IActorInitialValues ,
4
4
} from '@kitware/vtk.js/Rendering/Core/Actor' ;
5
+ import { IColorMapPreset } from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps' ;
5
6
import vtkMapper , {
6
7
IMapperInitialValues ,
7
8
} from '@kitware/vtk.js/Rendering/Core/Mapper' ;
@@ -52,9 +53,9 @@ export interface GeometryRepresentationProps extends PropsWithChildren {
52
53
property ?: IPropertyInitialValues ;
53
54
54
55
/**
55
- * Preset name for the lookup table color map
56
+ * Preset name for the lookup table color map or user provided color map preset
56
57
*/
57
- colorMapPreset ?: string ;
58
+ colorMapPreset ?: string | IColorMapPreset ;
58
59
59
60
/**
60
61
* Data range use for the colorMap
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import AbstractImageMapper, {
4
4
vtkAbstractImageMapper ,
5
5
} from '@kitware/vtk.js/Rendering/Core/AbstractImageMapper' ;
6
6
import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction' ;
7
+ import { IColorMapPreset } from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps' ;
7
8
import vtkImageArrayMapper from '@kitware/vtk.js/Rendering/Core/ImageArrayMapper' ;
8
9
import vtkImageMapper , {
9
10
IImageMapperInitialValues ,
@@ -64,9 +65,9 @@ export interface SliceRepresentationProps extends PropsWithChildren {
64
65
property ?: IImagePropertyInitialValues ;
65
66
66
67
/**
67
- * Preset name for the lookup table color map
68
+ * Preset name for the lookup table color map or user provided color map preset
68
69
*/
69
- colorMapPreset ?: string ;
70
+ colorMapPreset ?: string | IColorMapPreset ;
70
71
71
72
/**
72
73
* Data range use for the colorMap
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import vtkDataArray from '@kitware/vtk.js/Common/Core/DataArray';
2
2
import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData' ;
3
3
import vtkPiecewiseFunction from '@kitware/vtk.js/Common/DataModel/PiecewiseFunction' ;
4
4
import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction' ;
5
+ import { IColorMapPreset } from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps' ;
5
6
import vtkVolume , {
6
7
IVolumeInitialValues ,
7
8
} from '@kitware/vtk.js/Rendering/Core/Volume' ;
@@ -63,9 +64,9 @@ export interface VolumeRepresentationProps extends PropsWithChildren {
63
64
property ?: IVolumePropertyInitialValues ;
64
65
65
66
/**
66
- * Preset name for the lookup table color map
67
+ * Preset name for the lookup table color map or user provided color map preset
67
68
*/
68
- colorMapPreset ?: string ;
69
+ colorMapPreset ?: string | IColorMapPreset ;
69
70
70
71
/**
71
72
* Data range use for the colorMap
Original file line number Diff line number Diff line change 1
1
import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction' ;
2
- import vtkColorMaps from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps' ;
2
+ import vtkColorMaps , {
3
+ IColorMapPreset ,
4
+ } from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps' ;
3
5
import { Vector2 } from '@kitware/vtk.js/types' ;
4
6
import { compareVector2 } from '../../utils/comparators' ;
5
7
import deletionRegistry from '../../utils/DeletionRegistry' ;
@@ -9,7 +11,7 @@ import useGetterRef from '../../utils/useGetterRef';
9
11
import useUnmount from '../../utils/useUnmount' ;
10
12
11
13
export default function useColorTransferFunction (
12
- presetName : string ,
14
+ colorMapPreset : string | IColorMapPreset ,
13
15
range : Vector2 ,
14
16
trackModified : BooleanAccumulator
15
17
) {
@@ -19,11 +21,18 @@ export default function useColorTransferFunction(
19
21
return func ;
20
22
} ) ;
21
23
24
+ const isPassedInPresetName = typeof colorMapPreset === 'string' ;
25
+ const presetName = isPassedInPresetName
26
+ ? colorMapPreset
27
+ : colorMapPreset . Name ;
28
+
22
29
useComparableEffect (
23
30
( ) => {
24
31
if ( ! presetName || ! range ) return ;
25
32
const lut = getLUT ( ) ;
26
- const preset = vtkColorMaps . getPresetByName ( presetName ) ;
33
+ const preset = isPassedInPresetName
34
+ ? vtkColorMaps . getPresetByName ( presetName )
35
+ : colorMapPreset ;
27
36
lut . applyColorMap ( preset ) ;
28
37
lut . setMappingRange ( range [ 0 ] , range [ 1 ] ) ;
29
38
lut . updateRange ( ) ;
You can’t perform that action at this time.
0 commit comments