Commit 18a704e1 authored by Thomas Vincent's avatar Thomas Vincent

Use updated RangeSlider to control colormap range

parent 6fd09b01
......@@ -47,7 +47,7 @@ from silx.math.histogram import Histogramnd
from silx.gui.plot.matplotlib import Colormap
from ..widgets.Containers import GroupBox
from ..widgets.RangeSlider import RangeSlider
from ..silx_imports.RangeSlider import RangeSlider
from ..widgets.PointWidget import PointWidget
from ...gui.icons import getQIcon as getKmapIcon
from ..widgets.Input import StyledLineEdit
......@@ -193,8 +193,8 @@ class XsocsPlot2DColorDialog(Qt.QDialog):
grpBox = GroupBox('Range')
grpBoxLayout = Qt.QGridLayout(grpBox)
self.__rngSlider = rngSlider = RangeSlider()
grpBoxLayout.addWidget(rngSlider, 0, 0, 1, 2)
self.__rngSlider = RangeSlider()
grpBoxLayout.addWidget(self.__rngSlider, 0, 0, 1, 2)
self.__filledProfile = filledProfile = ColorFilledProfile()
filledProfile.setFixedHeight(100)
......@@ -218,7 +218,8 @@ class XsocsPlot2DColorDialog(Qt.QDialog):
self.__setupWidgets()
rngSlider.sigSliderMoved.connect(self.__rngSliderMoved)
self.__rngSlider.sigValueChanged.connect(
self.__rangeSliderValueChanged)
def __updateColorMap(self, colormap, minVal, maxVal, nColors):
"""
......@@ -251,20 +252,20 @@ class XsocsPlot2DColorDialog(Qt.QDialog):
self.__setColormapPixmap()
self.__applyColormap()
def __rngSliderMoved(self, event):
"""
Slot for the sliderMoved signal.
:param event:
:return:
def __rangeSliderValueChanged(self, first, second):
"""Slot for the range slider sigValueChanged signal.
:param float first:
:param float second:
"""
blockedMin = self.__minEdit.blockSignals(True)
blockedMax = self.__maxEdit.blockSignals(True)
self.__minEdit.setText('{0:6g}'.format(event.left))
self.__maxEdit.setText('{0:6g}'.format(event.right))
self.__minEdit.setText('{0:6g}'.format(first))
self.__maxEdit.setText('{0:6g}'.format(second))
colormap = self.__colormap
self.__updateColorMap(colormap.colormap,
event.left,
event.right,
first,
second,
colormap.nColors)
self.__minEdit.blockSignals(blockedMin)
self.__maxEdit.blockSignals(blockedMax)
......@@ -277,9 +278,7 @@ class XsocsPlot2DColorDialog(Qt.QDialog):
"""
minVal = float(self.__minEdit.text())
maxVal = float(self.__maxEdit.text())
blocked = self.__rngSlider.blockSignals(True)
self.__rngSlider.setSliderValues(minVal, maxVal)
self.__rngSlider.blockSignals(blocked)
self.__rngSlider.setValues(minVal, maxVal)
colormap = self.__colormap
self.__updateColorMap(colormap.colormap,
minVal,
......@@ -308,21 +307,6 @@ class XsocsPlot2DColorDialog(Qt.QDialog):
"""
return self.__curve
def __setSliderProfile(self):
"""
Draws the histogram profile on the slider.
:return:
"""
histo = self.__histogram
rngSlider = self.__rngSlider
colormap = self.__colormap
pixmap = _arrayToPixmap(histo.histo,
cm.jet,
256)
rngSlider.setSliderPixmap(pixmap)
def __setupWidgets(self):
"""
Initializes the colorbars, histogram, etc...
......@@ -339,16 +323,15 @@ class XsocsPlot2DColorDialog(Qt.QDialog):
return
histo = self.__histogram
rngSlider = self.__rngSlider
colormap = self.__colormap
self.__minEdit.setText('{0:6g}'.format(colormap.minVal))
self.__maxEdit.setText('{0:6g}'.format(colormap.maxVal))
rngSlider.setRange([histo.edges[0][0], histo.edges[0][-1]])
rngSlider.setSliderValues(colormap.minVal, colormap.maxVal)
self.__setSliderProfile()
self.__rngSlider.setRange(histo.edges[0][0], histo.edges[0][-1])
self.__rngSlider.setNumberOfSteps(256)
self.__rngSlider.setValues(colormap.minVal, colormap.maxVal)
self.__rngSlider.setGroovePixmapFromProfile(histo.histo, 'jet')
self.__drawHistogram()
def __drawHistogram(self):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment