diff options
Diffstat (limited to 'silx/gui/plot3d/_model/items.py')
-rw-r--r-- | silx/gui/plot3d/_model/items.py | 75 |
1 files changed, 73 insertions, 2 deletions
diff --git a/silx/gui/plot3d/_model/items.py b/silx/gui/plot3d/_model/items.py index 7f3921a..be51663 100644 --- a/silx/gui/plot3d/_model/items.py +++ b/silx/gui/plot3d/_model/items.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2017-2019 European Synchrotron Radiation Facility +# Copyright (c) 2017-2020 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -693,7 +693,7 @@ class _ColormapBaseProxyRow(ProxyRow): """ item = self.item() if item is not None and self._colormap is not None: - return self._colormap.getColormapRange(item._getDataRange()) + return self._colormap.getColormapRange(item) else: return 1, 100 # Fallback @@ -829,6 +829,55 @@ class _ColormapBoundRow(_ColormapBaseProxyRow): return super(_ColormapBoundRow, self).setData(column, value, role) +class _ColormapGammaRow(_ColormapBaseProxyRow): + """ProxyRow for colormap gamma normalization parameter + + :param ColormapMixIn item: The item to handle + :param str name: Name of the raw + """ + + def __init__(self, item): + _ColormapBaseProxyRow.__init__( + self, + item, + name="Gamma", + fget=self._getGammaNormalizationParameter, + fset=self._setGammaNormalizationParameter) + + self.setToolTip('Colormap gamma correction parameter:\n' + 'Only meaningful for gamma normalization.') + + def _getGammaNormalizationParameter(self): + """Proxy for :meth:`Colormap.getGammaNormalizationParameter`""" + if self._colormap is not None: + return self._colormap.getGammaNormalizationParameter() + else: + return 0.0 + + def _setGammaNormalizationParameter(self, gamma): + """Proxy for :meth:`Colormap.setGammaNormalizationParameter`""" + if self._colormap is not None: + return self._colormap.setGammaNormalizationParameter(gamma) + + def _getNormalization(self): + """Proxy for :meth:`Colormap.getNormalization`""" + if self._colormap is not None: + return self._colormap.getNormalization() + else: + return '' + + def flags(self, column): + if column in (0, 1): + if self._getNormalization() == 'gamma': + flags = qt.Qt.ItemIsEditable | qt.Qt.ItemIsEnabled + else: + flags = qt.Qt.NoItemFlags # Disabled if not gamma correction + return flags + + else: # Never event + return super(_ColormapGammaRow, self).flags(column) + + class ColormapRow(_ColormapBaseProxyRow): """Represents :class:`ColormapMixIn` property. @@ -862,6 +911,16 @@ class ColormapRow(_ColormapBaseProxyRow): notify=self._sigColormapChanged, editorHint=norms)) + self.addRow(_ColormapGammaRow(item)) + + modes = [mode.title() for mode in self._colormap.AUTOSCALE_MODES] + self.addRow(ProxyRow( + name='Autoscale Mode', + fget=self._getAutoscaleMode, + fset=self._setAutoscaleMode, + notify=self._sigColormapChanged, + editorHint=modes)) + self.addRow(_ColormapBoundRow(item, name='Min.', index=0)) self.addRow(_ColormapBoundRow(item, name='Max.', index=1)) @@ -908,6 +967,18 @@ class ColormapRow(_ColormapBaseProxyRow): if self._colormap is not None: return self._colormap.setNormalization(normalization.lower()) + def _getAutoscaleMode(self): + """Proxy for :meth:`Colormap.getAutoscaleMode`""" + if self._colormap is not None: + return self._colormap.getAutoscaleMode().title() + else: + return '' + + def _setAutoscaleMode(self, mode): + """Proxy for :meth:`Colormap.setAutoscaleMode`""" + if self._colormap is not None: + return self._colormap.setAutoscaleMode(mode.lower()) + def _updateColormapImage(self, *args, **kwargs): """Notify colormap update to update the image in the tree""" if self._colormapImage is not None: |