Skip to content
Snippets Groups Projects
Commit 29593b21 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

LutLabel names are converted to lower case, to make comparisons

easier. The original name is still accessible via a new 'displayName'
method.
parent 3f29d49f
No related branches found
No related tags found
No related merge requests found
...@@ -763,6 +763,12 @@ class LutLabel(object): ...@@ -763,6 +763,12 @@ class LutLabel(object):
instances. instances.
.. note:: When a ``LutLabel`` is created, the specified name is converted
to lower case. This is done to make comparisons easier. The
original name is still accessible through the :meth:`displayName`
method.
.. note:: ``LutLabel`` instances are only intended to be created by .. note:: ``LutLabel`` instances are only intended to be created by
:class:`LookupTable` instances. They are intended to be used :class:`LookupTable` instances. They are intended to be used
externally, however. externally, however.
...@@ -785,14 +791,15 @@ class LutLabel(object): ...@@ -785,14 +791,15 @@ class LutLabel(object):
""" """
if value is None: raise ValueError('LutLabel value cannot be None') if value is None: raise ValueError('LutLabel value cannot be None')
if name is None: name = 'label' if name is None: name = 'Label'
if colour is None: colour = (0, 0, 0) if colour is None: colour = (0, 0, 0)
if enabled is None: enabled = True if enabled is None: enabled = True
self.__value = value self.__value = value
self.__name = name self.__displayName = name
self.__colour = colour self.__name = name.lower()
self.__enabled = enabled self.__colour = colour
self.__enabled = enabled
def value(self): def value(self):
...@@ -804,6 +811,11 @@ class LutLabel(object): ...@@ -804,6 +811,11 @@ class LutLabel(object):
"""Returns the name of this ``LutLabel``. """ """Returns the name of this ``LutLabel``. """
return self.__name return self.__name
def displayName(self):
"""Returns the display name of this ``LutLabel``. """
return self.__displayName
def colour(self): def colour(self):
"""Returns the colour of this ``LutLabel``. """ """Returns the colour of this ``LutLabel``. """
...@@ -873,7 +885,9 @@ class LookupTable(props.HasProperties): ...@@ -873,7 +885,9 @@ class LookupTable(props.HasProperties):
removed via the meth:`delete` method. removed via the meth:`delete` method.
.. note:: All label names are converted to lower case. .. note:: All label names are converted to lower case internally, but the
name that is initially specified is still available - see the
:class:`LutLabel` class documentation.
.. warning:: Do not directly modify the :attr:`labels` list. If you do, .. warning:: Do not directly modify the :attr:`labels` list. If you do,
it will be your fault when things break. Use the :meth:`set` it will be your fault when things break. Use the :meth:`set`
...@@ -1029,7 +1043,7 @@ class LookupTable(props.HasProperties): ...@@ -1029,7 +1043,7 @@ class LookupTable(props.HasProperties):
# Create a new LutLabel instance with the # Create a new LutLabel instance with the
# new, existing, or default label settings # new, existing, or default label settings
name = kwargs.get('name', label.name()).lower() name = kwargs.get('name', label.displayName())
colour = kwargs.get('colour', label.colour()) colour = kwargs.get('colour', label.colour())
enabled = kwargs.get('enabled', label.enabled()) enabled = kwargs.get('enabled', label.enabled())
label = LutLabel(value, name, colour, enabled) label = LutLabel(value, name, colour, enabled)
...@@ -1099,7 +1113,7 @@ class LookupTable(props.HasProperties): ...@@ -1099,7 +1113,7 @@ class LookupTable(props.HasProperties):
for label in self.labels: for label in self.labels:
value = label.value() value = label.value()
colour = label.colour() colour = label.colour()
name = label.name() name = label.displayName()
tkns = [value, colour[0], colour[1], colour[2], name] tkns = [value, colour[0], colour[1], colour[2], name]
line = ' '.join(map(str, tkns)) line = ' '.join(map(str, tkns))
......
...@@ -225,7 +225,7 @@ class LookupTablePanel(fslpanel.FSLEyesPanel): ...@@ -225,7 +225,7 @@ class LookupTablePanel(fslpanel.FSLEyesPanel):
for i, label in enumerate(lut.labels): for i, label in enumerate(lut.labels):
self.__labelList.Append(label.name()) self.__labelList.Append(label.displayName())
widget = LabelWidget(self, lut, label.value()) widget = LabelWidget(self, lut, label.value())
self.__labelList.SetItemWidget(i, widget) self.__labelList.SetItemWidget(i, widget)
...@@ -342,7 +342,7 @@ class LookupTablePanel(fslpanel.FSLEyesPanel): ...@@ -342,7 +342,7 @@ class LookupTablePanel(fslpanel.FSLEyesPanel):
for label in self.__selectedLut.labels: for label in self.__selectedLut.labels:
lut.set(label.value(), lut.set(label.value(),
name=label.name(), name=label.displayName(),
colour=label.colour(), colour=label.colour(),
enabled=label.enabled()) enabled=label.enabled())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment