1 | from PyQt4 import QtGui |
---|
2 | |
---|
3 | import sas.sasview |
---|
4 | |
---|
5 | from sas.qtgui.UI.ScalePropertiesUI import Ui_scalePropertiesUI |
---|
6 | |
---|
7 | x_values = ["x", "x^(2)", "x^(4)", "ln(x)", "log10(x)", "log10(x^(4))"] |
---|
8 | y_values = ["y", "1/y", "ln(y)", "y^(2)", "y*x^(2)", "y*x^(4)", "1/sqrt(y)", |
---|
9 | "log10(y)", "ln(y*x)", "ln(y*x^(2))", "ln(y*x^(4))", "log10(y*x^(4))"] |
---|
10 | view_values = ["--", "Linear y vs x", "Guinier lny vs x^(2)", |
---|
11 | "XS Guinier ln(y*x) vs x^(2)", "Porod y*x^(4) vs x^(4)", "Kratky y*x^(2) vs x"] |
---|
12 | view_to_xy = { |
---|
13 | view_values[0]: [None, None], # custom |
---|
14 | view_values[1]: [0, 0], # linear |
---|
15 | view_values[2]: [1, 2], # Guinier |
---|
16 | view_values[3]: [1, 8], # XS Guinier |
---|
17 | view_values[4]: [2, 5], # Porod |
---|
18 | view_values[5]: [0, 4], # Kratky |
---|
19 | } |
---|
20 | class ScaleProperties(QtGui.QDialog, Ui_scalePropertiesUI): |
---|
21 | def __init__(self, parent=None): |
---|
22 | super(ScaleProperties, self).__init__(parent) |
---|
23 | self.setupUi(self) |
---|
24 | |
---|
25 | # Set up comboboxes |
---|
26 | self.cbX.addItems(x_values) |
---|
27 | self.cbY.addItems(y_values) |
---|
28 | self.cbView.addItems(view_values) |
---|
29 | # Resize the dialog only AFTER the boxes are populated |
---|
30 | self.setFixedSize(self.minimumSizeHint()) |
---|
31 | |
---|
32 | # Connect combobox index change to a custom method |
---|
33 | self.cbView.currentIndexChanged.connect(self.viewIndexChanged) |
---|
34 | self.cbX.currentIndexChanged.connect(self.xyIndexChanged) |
---|
35 | self.cbY.currentIndexChanged.connect(self.xyIndexChanged) |
---|
36 | |
---|
37 | def getValues(self): |
---|
38 | """ |
---|
39 | Return current values from comboboxes |
---|
40 | """ |
---|
41 | return self.cbX.currentText(), self.cbY.currentText() |
---|
42 | |
---|
43 | def viewIndexChanged(self, index): |
---|
44 | """ |
---|
45 | Update X and Y labels based on the "View" index |
---|
46 | """ |
---|
47 | if index > 0: |
---|
48 | # Disable signals so xyIndexChanged() doesn't get called |
---|
49 | self.cbX.blockSignals(True) |
---|
50 | self.cbY.blockSignals(True) |
---|
51 | |
---|
52 | # Update the sub-controls |
---|
53 | self.cbX.setCurrentIndex(view_to_xy[view_values[index]][0]) |
---|
54 | self.cbY.setCurrentIndex(view_to_xy[view_values[index]][1]) |
---|
55 | # Re-enable the signals |
---|
56 | |
---|
57 | self.cbX.blockSignals(False) |
---|
58 | self.cbY.blockSignals(False) |
---|
59 | |
---|
60 | def xyIndexChanged(self, index): |
---|
61 | """ |
---|
62 | Update View label based on the "X" and "Y" index |
---|
63 | """ |
---|
64 | self.cbView.setCurrentIndex(0) |
---|