Implementing Discrete Color Map mode for control points
In ParaView it would be nice to have a discrete color map mode, where instead of having continuous interval between color point of the color map, we coudl have discontinuous color map, like this :
This is something that is already supported by VTK thanks to the sharpness and midpoint parameters, and the image I generated come from a quick implementation I made here !4520 (closed)
There is two limitations with this implementation :
1) Last Point
The color associated with the last point is not used and generate a small graphical artifact. It can be seen on my screenshot on the very right of the color map editor, there is a red band. This is due to the way to midpoint works. The artifact could probably be removed , but it doesn't remove the fact that the last point is not used, which would not exactly be what we would expect. Let's take a look a the presets for examples :
The color map with more than 4 point looks ok, and the missing last color does not matter much, but for 2 or 3 point color map, doesn't look as good. "Cool to Warm" (default in pv) became more of a "Cool to ambient temperature" with only two colors, and XRay, which has only two points, looks completelly broken.
One way to fix that could be to add another last point to duplicate the last color, but we need to figure out where to do that.
When adding a new point in an interval, a user expect the color to be between the two colors of the interval. But in the current implementation, that is not the case as vtkColorTransferControlPointsItem would simply use
colorMap->GetColor(x) to get the new color, and this calls obviously takes sharpness and midpoint into account.
I've fixed it by switching the sharpness and midpoint just before getting the color, but still it is quite a convoluted implementation.
What are your thoughts on this ? I think we need to limit changes to vtkColorTransferFunction as it is a widely used class but this may implies not so evident implementation.