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