Merge pull request #837 from scseeman/color_map_widget_options

add option to set other field variables in ColorMapWidget
This commit is contained in:
Luke Campagnola 2019-03-08 12:55:23 -08:00 committed by GitHub
commit 229f650adf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -60,11 +60,21 @@ class ColorMapParameter(ptree.types.GroupParameter):
self.sigColorMapChanged.emit(self)
def addNew(self, name):
mode = self.fields[name].get('mode', 'range')
fieldSpec = self.fields[name]
mode = fieldSpec.get('mode', 'range')
if mode == 'range':
item = RangeColorMapItem(name, self.fields[name])
elif mode == 'enum':
item = EnumColorMapItem(name, self.fields[name])
defaults = fieldSpec.get('defaults', {})
for k, v in defaults.items():
if k == 'colormap':
item.setValue(v)
else:
item[k] = v
self.addChild(item)
return item
@ -90,6 +100,11 @@ class ColorMapParameter(ptree.types.GroupParameter):
values List of unique values for which the user may assign a
color when mode=='enum'. Optionally may specify a dict
instead {value: name}.
defaults Dict of default values to apply to color map items when
they are created. Valid keys are 'colormap' to provide
a default color map, or otherwise they a string or tuple
indicating the parameter to be set, such as 'Operation' or
('Channels..', 'Red').
============== ============================================================
"""
self.fields = OrderedDict(fields)
@ -138,7 +153,6 @@ class ColorMapParameter(ptree.types.GroupParameter):
elif op == 'Set':
colors[mask] = colors2[mask]
colors = np.clip(colors, 0, 1)
if mode == 'byte':
colors = (colors * 255).astype(np.ubyte)