Accessing the vtkVolumeController color map

I’m using vtk.js in a React application.
I would like to control the color map natively; i.e. have a custom dropdown with color map options then pass those to the vtkVolumeController when I call the setupContent method on the controller.

I am able to do that, but if the user uses the dropdown inside the vtkVolumeController then I’m not sure how to grab that value once it changes so I can use it elsewhere.

I figure my options are either:
A) Listen for the change in vtkVolumeController and save that.
B) Remove the vtkVolumeController’s color map selection all together so the user never encounters this error.

Are either of these options possible?

Just to be sure, are you talking about @kitware/vtk.js or react-vtk-js?

Rereading it seems you are in plain vtk.js which means you probably want to wrap vtkVolumeController inside react by building it yourself using its internal components and skipping the drop down. (kind of doing B’)

You’re correct, I’m using @kitware/vtk.js.

Okay, thanks. I’m assuming I should use the source code for this, just sort of take what I need and leave out what I don’t? Any issues I should look out for while doing this?

Thanks again.

Yes you should embed vtkPiecewiseGaussianWidget inside some react component and manage the rest of the interaction on your own. I don’t see any issue doing so.

Doing it in plain JS (no framework) is a pain, but if we want vtk.js to be framework free we don’t have much choice. So we don’t provide much freedom to tune things up especially knowing that it would be trivial to implement it using any framework out there. :wink:

1 Like

Great, thank you Sebastien!

1 Like