sciapp / gr

GR framework: a graphics library for visualisation applications
Other
329 stars 54 forks source link

User-defined colormap ignored #139

Closed michele-brambilla closed 3 years ago

michele-brambilla commented 3 years ago

GR does not accept a colormap provided by the user. The file attached (gr_color.txt is actually a python script) is a slight modification of pygrwidgetqt5_ex gr_colors.txt

The first two images are the expected colormaps, but the script displays the latter (in both cases)

expected_1 expected_2 result
FlorianRhiem commented 3 years ago

Hey @michele-brambilla,

thank you for the bug report! There are two regions of color indices used for colormaps, a smaller one between 8 and 79 and a larger one between 1000 and 1255. gr_setcolormapfromrgb sets the region of 1000 to 1255, but fails to set the internal variables correctly to use this region. A proper fix for this will be in the development branch of GR shortly.

A quick workaround until you can use the fixed version is to set a colormap with an index above 100 first, as the region of indices between 1000 and 1255 will be used that way. In your example, you could for example call:

gr.setcolormap(103)

## User defined colormap
gr.setcolormapfromrgb(cmap)

and you should get the following result: gks

michele-brambilla commented 3 years ago

@FlorianRhiem I confirm the workaround works, thanks!

FlorianRhiem commented 3 years ago

The fix for gr_setcolormapfromrgb in 490e40062b38d172cf40c44915758882f39c20c0 has been merged and gr_volume and gr3_createsurfacemesh have been fixed to use the correct color index range in 6737acfae5c1115a712599f909d70268271ed1f9, so this issue should be fixed in the develop/latest builds and in the next release.

Thank you again for reporting this!