Merge pull request #837 from scseeman/color_map_widget_options
add option to set other field variables in ColorMapWidget
This commit is contained in:
commit
229f650adf
@ -60,11 +60,21 @@ class ColorMapParameter(ptree.types.GroupParameter):
|
|||||||
self.sigColorMapChanged.emit(self)
|
self.sigColorMapChanged.emit(self)
|
||||||
|
|
||||||
def addNew(self, name):
|
def addNew(self, name):
|
||||||
mode = self.fields[name].get('mode', 'range')
|
fieldSpec = self.fields[name]
|
||||||
|
|
||||||
|
mode = fieldSpec.get('mode', 'range')
|
||||||
if mode == 'range':
|
if mode == 'range':
|
||||||
item = RangeColorMapItem(name, self.fields[name])
|
item = RangeColorMapItem(name, self.fields[name])
|
||||||
elif mode == 'enum':
|
elif mode == 'enum':
|
||||||
item = EnumColorMapItem(name, self.fields[name])
|
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)
|
self.addChild(item)
|
||||||
return item
|
return item
|
||||||
|
|
||||||
@ -90,6 +100,11 @@ class ColorMapParameter(ptree.types.GroupParameter):
|
|||||||
values List of unique values for which the user may assign a
|
values List of unique values for which the user may assign a
|
||||||
color when mode=='enum'. Optionally may specify a dict
|
color when mode=='enum'. Optionally may specify a dict
|
||||||
instead {value: name}.
|
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)
|
self.fields = OrderedDict(fields)
|
||||||
@ -138,7 +153,6 @@ class ColorMapParameter(ptree.types.GroupParameter):
|
|||||||
elif op == 'Set':
|
elif op == 'Set':
|
||||||
colors[mask] = colors2[mask]
|
colors[mask] = colors2[mask]
|
||||||
|
|
||||||
|
|
||||||
colors = np.clip(colors, 0, 1)
|
colors = np.clip(colors, 0, 1)
|
||||||
if mode == 'byte':
|
if mode == 'byte':
|
||||||
colors = (colors * 255).astype(np.ubyte)
|
colors = (colors * 255).astype(np.ubyte)
|
||||||
|
Loading…
Reference in New Issue
Block a user