Commit 89c16d94 authored by Thomas Vincent's avatar Thomas Vincent

Simpler Roi sliders widget + right aligned

parent d43887a8
......@@ -47,8 +47,11 @@ from ...io.FitH5 import BackgroundTypes
_logger = logging.getLogger(__name__)
class Roi3DSelectorWidget(Qt.QWidget):
"""Widget displaying three RoiAxisWidgets, one for each axis."""
class Roi3DSelectorWidget(GroupBox):
"""Widget displaying three RoiAxisWidgets, one for each axis.
:param parent:
"""
sigRoiChanged = Qt.Signal(object)
"""Signal emitted when one of the slider is moved.
......@@ -57,38 +60,24 @@ class Roi3DSelectorWidget(Qt.QWidget):
a tuple of three SliderState instances, one for each axis.
"""
sigRoiToggled = Qt.Signal(bool)
"""Signal emitted when the QGroupWidget is toggled on/off. """
def __init__(self, *args, **kwargs):
super(Roi3DSelectorWidget, self).__init__(*args, **kwargs)
self.setContentsMargins(0, 0, 0, 0)
def __init__(self, parent=None):
super(Roi3DSelectorWidget, self).__init__('Roi', parent=parent)
self.setCheckable(True)
self.setChecked(False)
layout = Qt.QVBoxLayout(self)
self.__grpBox = grpBox = GroupBox('Roi')
grpBox.setCheckable(True)
grpBox.setChecked(False)
grpBox.toggled.connect(self.sigRoiToggled)
grpLayout = Qt.QVBoxLayout(grpBox)
self.__roiWidgets = (
RoiAxisWidget(''), RoiAxisWidget(''), RoiAxisWidget(''))
for widget in self.__roiWidgets:
grpLayout.addWidget(widget)
layout.addWidget(widget)
layout.setAlignment(widget, Qt.Qt.AlignRight)
widget.sigSliderMoved.connect(self.__slotSliderMoved)
layout.addWidget(grpBox)
def __slotSliderMoved(self, _):
"""Slot called each time a slider moves."""
self.sigRoiChanged.emit(
[widget.getSliderState() for widget in self.roiAxisWidgets()])
def isActive(self):
return self.__grpBox.isChecked()
def sliders(self):
"""Returns all ROI widgets sliders
......@@ -240,7 +229,7 @@ class FitWidget(Qt.QWidget):
self.__progBar.setValue(0)
fitType = self.__fitTypeCb.itemData(self.__fitTypeCb.currentIndex())
if self.roiWidget().isActive():
if self.roiWidget().isChecked():
roiIndices = [slider.getPositions()
for slider in self.roiWidget().sliders()]
......
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