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)
|
||||
|
||||
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)
|
||||
@ -136,8 +151,7 @@ class ColorMapParameter(ptree.types.GroupParameter):
|
||||
c3[:,3:4] = colors[:,3:4] + (1-colors[:,3:4]) * a
|
||||
colors = c3
|
||||
elif op == 'Set':
|
||||
colors[mask] = colors2[mask]
|
||||
|
||||
colors[mask] = colors2[mask]
|
||||
|
||||
colors = np.clip(colors, 0, 1)
|
||||
if mode == 'byte':
|
||||
@ -184,7 +198,7 @@ class RangeColorMapItem(ptree.types.SimpleParameter):
|
||||
dict(name='Enabled', type='bool', value=True),
|
||||
dict(name='NaN', type='color'),
|
||||
])
|
||||
|
||||
|
||||
def map(self, data):
|
||||
data = data[self.fieldName]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user