﻿id	summary	reporter	owner	description	type	status	priority	milestone	component	version	resolution	keywords	cc	blockedby	blocking	notify_on_close	platform	project
545	Volume API for setting surface colors is not intuitive	tic20@…	Tom Goddard	"Hi all,

I have something strange going on when I try to create multiple volumes (different crystallographic maps) and group them under a single Model: whatever color I initialise them with is ignored, and they just come out the default grey. I don't have a nice compact code example, but the basic flow in pseudocode is:

DEFAULT_SOLID_MAP_COLOR = [0,255,255,153] # Transparent cyan
DEFAULT_DIFF_MAP_COLORS = [[0,255,0,153],[255,0,0,153]]

master_model = Model('map display', session)

for m in map_list:
 data = numpy.empty(dim, numpy.double)
 grid_data = Array_Grid_Data(data, origin, step, cell_angles)
 volume = Volume(grid_data, session)
 fill_volume_data(m, data)
 volume.initialize_thresholds()
 master_model.add([volume])
 if not m.is_difference_map:
   contour_val = [standard_contour] # single value
   volume.set_color(DEFAULT_SOLID_MAP_COLOR)
 else:
   contour_val = [standard_difference_map_contours] # two levels
   volume.set_colors(DEFAULT_DIFF_MAP_COLORS)
 for cv in contour_val:
   volumecommand.volume(session, [volume], level=[[cv]], cap_faces = False)
 volume.show()
session.models.add(master_model)


After this, I have the following results (where I have loaded two normal maps and one difference map):

for v in volumes:
 print(v.colors)

[[  0 255   0 153]
[255   0   0 153]]
[[178 178 178 255]]
[[178 178 178 255]]

So set_colors() has set the correct color values for the (two level) difference map - but both contours are displayed on screen as flat white and solid. Meanwhile, the other two maps have their colours recorded as the default grey, but in the display they're transparent (but still grey). Changing their values from the console, either by set_color()/set_colors() or v.color = [rgba] does not change the displayed colours. Using the direct equality or set_colors() changes the result of print(v.colors), whereas set_color() doesn't.

Cheers,

Tristan

----

Follow-up: I see I have my handling of multiple contour levels mixed up. I'll have a closer read of volumecommand to work that out. In other news, when I use the command-line interface to do:
vol #2.1 level 0.099 color 0,100,0,60 cap_faces False level -0.099 color 100,0,0,60
... it works correctly. I'll have a closer look through the code to see where I'm going wrong.

----

OK, I can set these by following through the logic in volumecommand.level_and_color_settings(), but the behaviour at that higher level still seems rather counter-intuitive."	defect	closed	major		Volume Data		fixed						all	ChimeraX
