File tree Expand file tree Collapse file tree 5 files changed +24
-11
lines changed Expand file tree Collapse file tree 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';
22import vtkActor2D , {
33 IActor2DInitialValues ,
44} from '@kitware/vtk.js/Rendering/Core/Actor2D' ;
5+ import { IColorMapPreset } from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps' ;
56import { ICoordinateInitialValues } from '@kitware/vtk.js/Rendering/Core/Coordinate' ;
67import { Coordinate } from '@kitware/vtk.js/Rendering/Core/Coordinate/Constants' ;
78import vtkMapper2D , {
@@ -55,9 +56,9 @@ export interface Geometry2DRepresentationProps extends PropsWithChildren {
5556 property ?: IProperty2DInitialValues ;
5657
5758 /**
58- * Preset name for the lookup table color map
59+ * Preset name for the lookup table color map or user provided color map preset
5960 */
60- colorMapPreset ?: string ;
61+ colorMapPreset ?: string | IColorMapPreset ;
6162
6263 /**
6364 * 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';
22import vtkActor , {
33 IActorInitialValues ,
44} from '@kitware/vtk.js/Rendering/Core/Actor' ;
5+ import { IColorMapPreset } from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps' ;
56import vtkMapper , {
67 IMapperInitialValues ,
78} from '@kitware/vtk.js/Rendering/Core/Mapper' ;
@@ -52,9 +53,9 @@ export interface GeometryRepresentationProps extends PropsWithChildren {
5253 property ?: IPropertyInitialValues ;
5354
5455 /**
55- * Preset name for the lookup table color map
56+ * Preset name for the lookup table color map or user provided color map preset
5657 */
57- colorMapPreset ?: string ;
58+ colorMapPreset ?: string | IColorMapPreset ;
5859
5960 /**
6061 * Data range use for the colorMap
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import AbstractImageMapper, {
44 vtkAbstractImageMapper ,
55} from '@kitware/vtk.js/Rendering/Core/AbstractImageMapper' ;
66import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction' ;
7+ import { IColorMapPreset } from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps' ;
78import vtkImageArrayMapper from '@kitware/vtk.js/Rendering/Core/ImageArrayMapper' ;
89import vtkImageMapper , {
910 IImageMapperInitialValues ,
@@ -64,9 +65,9 @@ export interface SliceRepresentationProps extends PropsWithChildren {
6465 property ?: IImagePropertyInitialValues ;
6566
6667 /**
67- * Preset name for the lookup table color map
68+ * Preset name for the lookup table color map or user provided color map preset
6869 */
69- colorMapPreset ?: string ;
70+ colorMapPreset ?: string | IColorMapPreset ;
7071
7172 /**
7273 * 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';
22import vtkImageData from '@kitware/vtk.js/Common/DataModel/ImageData' ;
33import vtkPiecewiseFunction from '@kitware/vtk.js/Common/DataModel/PiecewiseFunction' ;
44import vtkColorTransferFunction from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction' ;
5+ import { IColorMapPreset } from '@kitware/vtk.js/Rendering/Core/ColorTransferFunction/ColorMaps' ;
56import vtkVolume , {
67 IVolumeInitialValues ,
78} from '@kitware/vtk.js/Rendering/Core/Volume' ;
@@ -63,9 +64,9 @@ export interface VolumeRepresentationProps extends PropsWithChildren {
6364 property ?: IVolumePropertyInitialValues ;
6465
6566 /**
66- * Preset name for the lookup table color map
67+ * Preset name for the lookup table color map or user provided color map preset
6768 */
68- colorMapPreset ?: string ;
69+ colorMapPreset ?: string | IColorMapPreset ;
6970
7071 /**
7172 * Data range use for the colorMap
Original file line number Diff line number Diff line change 11import 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' ;
35import { Vector2 } from '@kitware/vtk.js/types' ;
46import { compareVector2 } from '../../utils/comparators' ;
57import deletionRegistry from '../../utils/DeletionRegistry' ;
@@ -9,7 +11,7 @@ import useGetterRef from '../../utils/useGetterRef';
911import useUnmount from '../../utils/useUnmount' ;
1012
1113export default function useColorTransferFunction (
12- presetName : string ,
14+ colorMapPreset : string | IColorMapPreset ,
1315 range : Vector2 ,
1416 trackModified : BooleanAccumulator
1517) {
@@ -19,11 +21,18 @@ export default function useColorTransferFunction(
1921 return func ;
2022 } ) ;
2123
24+ const isPassedInPresetName = typeof colorMapPreset === 'string' ;
25+ const presetName = isPassedInPresetName
26+ ? colorMapPreset
27+ : colorMapPreset . Name ;
28+
2229 useComparableEffect (
2330 ( ) => {
2431 if ( ! presetName || ! range ) return ;
2532 const lut = getLUT ( ) ;
26- const preset = vtkColorMaps . getPresetByName ( presetName ) ;
33+ const preset = isPassedInPresetName
34+ ? vtkColorMaps . getPresetByName ( presetName )
35+ : colorMapPreset ;
2736 lut . applyColorMap ( preset ) ;
2837 lut . setMappingRange ( range [ 0 ] , range [ 1 ] ) ;
2938 lut . updateRange ( ) ;
You can’t perform that action at this time.
0 commit comments