1 | """ |
---|
2 | Allows users to change the range of the current graph |
---|
3 | """ |
---|
4 | from PyQt5 import QtCore |
---|
5 | from PyQt5 import QtGui |
---|
6 | from PyQt5 import QtWidgets |
---|
7 | |
---|
8 | # Local UI |
---|
9 | from sas.qtgui.UI import main_resources_rc |
---|
10 | from sas.qtgui.Plotting.UI.SetGraphRangeUI import Ui_setGraphRangeUI |
---|
11 | |
---|
12 | class SetGraphRange(QtWidgets.QDialog, Ui_setGraphRangeUI): |
---|
13 | def __init__(self, parent=None, x_range=(0.0, 0.0), y_range=(0.0, 0.0)): |
---|
14 | super(SetGraphRange, self).__init__() |
---|
15 | |
---|
16 | self.setupUi(self) |
---|
17 | assert(isinstance(x_range, tuple)) |
---|
18 | assert(isinstance(y_range, tuple)) |
---|
19 | |
---|
20 | self.txtXmin.setValidator(QtGui.QDoubleValidator()) |
---|
21 | self.txtXmax.setValidator(QtGui.QDoubleValidator()) |
---|
22 | self.txtYmin.setValidator(QtGui.QDoubleValidator()) |
---|
23 | self.txtYmax.setValidator(QtGui.QDoubleValidator()) |
---|
24 | |
---|
25 | self.txtXmin.setText(str(x_range[0])) |
---|
26 | self.txtXmax.setText(str(x_range[1])) |
---|
27 | self.txtYmin.setText(str(y_range[0])) |
---|
28 | self.txtYmax.setText(str(y_range[1])) |
---|
29 | |
---|
30 | def xrange(self): |
---|
31 | """ |
---|
32 | Return a tuple with line edit content of (xmin, xmax) |
---|
33 | """ |
---|
34 | return (float(self.txtXmin.text()), |
---|
35 | float(self.txtXmax.text())) |
---|
36 | |
---|
37 | def yrange(self): |
---|
38 | """ |
---|
39 | Return a tuple with line edit content of (ymin, ymax) |
---|
40 | """ |
---|
41 | return (float(self.txtYmin.text()), |
---|
42 | float(self.txtYmax.text())) |
---|