[3bdbfcc] | 1 | """ |
---|
| 2 | Allows users to modify the box slicer parameters. |
---|
| 3 | """ |
---|
[4992ff2] | 4 | from PyQt5 import QtCore |
---|
| 5 | from PyQt5 import QtGui |
---|
| 6 | from PyQt5 import QtWidgets |
---|
[3bdbfcc] | 7 | |
---|
[d6b8a1d] | 8 | import sas.qtgui.Utilities.GuiUtils as GuiUtils |
---|
| 9 | |
---|
[3bdbfcc] | 10 | # Local UI |
---|
[cd2cc745] | 11 | from sas.qtgui.UI import main_resources_rc |
---|
[83eb5208] | 12 | from sas.qtgui.Plotting.UI.BoxSumUI import Ui_BoxSumUI |
---|
[3bdbfcc] | 13 | |
---|
[4992ff2] | 14 | class BoxSum(QtWidgets.QDialog, Ui_BoxSumUI): |
---|
[3bdbfcc] | 15 | def __init__(self, parent=None, model=None): |
---|
| 16 | super(BoxSum, self).__init__() |
---|
| 17 | |
---|
| 18 | self.setupUi(self) |
---|
| 19 | assert isinstance(model, QtGui.QStandardItemModel) |
---|
| 20 | |
---|
[d6b8a1d] | 21 | self.txtBoxHeight.setValidator(GuiUtils.DoubleValidator()) |
---|
| 22 | self.txtBoxWidth.setValidator(GuiUtils.DoubleValidator()) |
---|
| 23 | self.txtCenterX.setValidator(GuiUtils.DoubleValidator()) |
---|
| 24 | self.txtCenterY.setValidator(GuiUtils.DoubleValidator()) |
---|
[3bdbfcc] | 25 | |
---|
| 26 | self.model = model |
---|
[fbfc488] | 27 | self.mapper = QtWidgets.QDataWidgetMapper() |
---|
[3bdbfcc] | 28 | self.mapper.setModel(self.model) |
---|
| 29 | |
---|
| 30 | # Map model items onto widget controls |
---|
| 31 | self.mapper.addMapping(self.txtBoxHeight, 0) |
---|
| 32 | self.mapper.addMapping(self.txtBoxWidth, 1) |
---|
| 33 | self.mapper.addMapping(self.txtCenterX, 2) |
---|
| 34 | self.mapper.addMapping(self.txtCenterY, 3) |
---|
[fbfc488] | 35 | self.mapper.addMapping(self.lblAvg, 4, b"text") |
---|
| 36 | self.mapper.addMapping(self.lblAvgErr, 5, b"text") |
---|
| 37 | self.mapper.addMapping(self.lblSum, 6, b"text") |
---|
| 38 | self.mapper.addMapping(self.lblSumErr, 7, b"text") |
---|
| 39 | self.mapper.addMapping(self.lblNumPoints, 8, b"text") |
---|
[3bdbfcc] | 40 | |
---|
| 41 | # Populate the widgets with data from the first column |
---|
| 42 | self.mapper.toFirst() |
---|
| 43 | |
---|
| 44 | self.setFixedSize(self.minimumSizeHint()) |
---|
| 45 | |
---|
[fbfc488] | 46 | # Handle the Apply button click |
---|
| 47 | self.buttonBox.button(QtWidgets.QDialogButtonBox.Close).clicked.connect(self.onClose) |
---|
| 48 | |
---|
| 49 | def onClose(self): |
---|
| 50 | """ |
---|
| 51 | close the window containing this panel |
---|
| 52 | """ |
---|
| 53 | self.close() |
---|
| 54 | |
---|