source: sasview/src/sas/qtgui/Plotting/ScaleProperties.py @ 9c0ce68

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalc
Last change on this file since 9c0ce68 was 4992ff2, checked in by Piotr Rozyczko <rozyczko@…>, 7 years ago

Initial, in-progress version. Not really working atm. SASVIEW-787

  • Property mode set to 100644
File size: 2.8 KB
RevLine 
[4992ff2]1from PyQt5 import QtCore
2from PyQt5 import QtGui
3from PyQt5 import QtWidgets
[ef01be4]4
5import sas.sasview
[cd2cc745]6from sas.qtgui.UI import main_resources_rc
[ef01be4]7
[cd2cc745]8from sas.qtgui.UI import main_resources_rc
[83eb5208]9from sas.qtgui.Plotting.UI.ScalePropertiesUI import Ui_scalePropertiesUI
[ef01be4]10
11x_values = ["x", "x^(2)", "x^(4)", "ln(x)", "log10(x)", "log10(x^(4))"]
12y_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))"]
14view_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"]
16view_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}
[4992ff2]24class ScaleProperties(QtWidgets.QDialog, Ui_scalePropertiesUI):
[3b7b218]25    def __init__(self, parent=None, init_scale_x='x', init_scale_y='y'):
[ef01be4]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
[3b7b218]36        # Set up the initial values for x and y.
37        # This avoids keeping a QModel instance here.
38        if init_scale_x in x_values and init_scale_y in y_values:
39            self.cbX.setCurrentIndex(x_values.index(init_scale_x))
40            self.cbY.setCurrentIndex(y_values.index(init_scale_y))
41
[ef01be4]42        # Connect combobox index change to a custom method
43        self.cbView.currentIndexChanged.connect(self.viewIndexChanged)
[6d05e1d]44        self.cbX.currentIndexChanged.connect(self.xyIndexChanged)
45        self.cbY.currentIndexChanged.connect(self.xyIndexChanged)
[ef01be4]46
47    def getValues(self):
48        """
49        Return current values from comboboxes
50        """
[fed94a2]51        return str(self.cbX.currentText()), str(self.cbY.currentText())
[ef01be4]52
53    def viewIndexChanged(self, index):
54        """
55        Update X and Y labels based on the "View" index
56        """
57        if index > 0:
[6d05e1d]58            # Disable signals so xyIndexChanged() doesn't get called
59            self.cbX.blockSignals(True)
60            self.cbY.blockSignals(True)
61
62            # Update the sub-controls
[ef01be4]63            self.cbX.setCurrentIndex(view_to_xy[view_values[index]][0])
64            self.cbY.setCurrentIndex(view_to_xy[view_values[index]][1])
[6d05e1d]65            # Re-enable the signals
66
67            self.cbX.blockSignals(False)
68            self.cbY.blockSignals(False)
69
70    def xyIndexChanged(self, index):
71        """
72        Update View label based on the "X" and "Y" index
73        """
74        self.cbView.setCurrentIndex(0)
Note: See TracBrowser for help on using the repository browser.