from PyQt5 import QtCore, QtGui, QtWidgets
from mplwidget import MplWidget
from rangeslider import QRangeSlider


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(1430, 986)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(MainWindow.sizePolicy().hasHeightForWidth())
        MainWindow.setSizePolicy(sizePolicy)
        MainWindow.setMaximumSize(QtCore.QSize(16777215, 16777215))
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setEnabled(True)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
        self.centralwidget.setSizePolicy(sizePolicy)
        self.centralwidget.setObjectName("centralwidget")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.centralwidget)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.plotarea = MplWidget(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.plotarea.sizePolicy().hasHeightForWidth())
        self.plotarea.setSizePolicy(sizePolicy)
        self.plotarea.setObjectName("plotarea")
        self.horizontalLayout.addWidget(self.plotarea)
        self.gridLayout = QtWidgets.QGridLayout()
        self.gridLayout.setObjectName("gridLayout")
        self.transXFixBox = QtWidgets.QCheckBox(self.centralwidget)
        self.transXFixBox.setObjectName("transXFixBox")
        self.gridLayout.addWidget(self.transXFixBox, 11, 3, 1, 1)
        self.datasetCombo = QtWidgets.QComboBox(self.centralwidget)
        self.datasetCombo.setObjectName("datasetCombo")
        self.gridLayout.addWidget(self.datasetCombo, 4, 0, 1, 1)
        self.inputfileLabel = QtWidgets.QLabel(self.centralwidget)
        self.inputfileLabel.setObjectName("inputfileLabel")
        self.gridLayout.addWidget(self.inputfileLabel, 1, 1, 1, 6)
        self.rotYFixBox = QtWidgets.QCheckBox(self.centralwidget)
        self.rotYFixBox.setObjectName("rotYFixBox")
        self.gridLayout.addWidget(self.rotYFixBox, 12, 1, 1, 1)
        self.removeBackgroundBox = QtWidgets.QCheckBox(self.centralwidget)
        self.removeBackgroundBox.setChecked(True)
        self.removeBackgroundBox.setObjectName("removeBackgroundBox")
        self.gridLayout.addWidget(self.removeBackgroundBox, 4, 2, 1, 1)
        self.rotZFixBox = QtWidgets.QCheckBox(self.centralwidget)
        self.rotZFixBox.setObjectName("rotZFixBox")
        self.gridLayout.addWidget(self.rotZFixBox, 13, 1, 1, 1)
        self.transYFixBox = QtWidgets.QCheckBox(self.centralwidget)
        self.transYFixBox.setObjectName("transYFixBox")
        self.gridLayout.addWidget(self.transYFixBox, 12, 3, 1, 1)
        self.rotXFixBox = QtWidgets.QCheckBox(self.centralwidget)
        self.rotXFixBox.setObjectName("rotXFixBox")
        self.gridLayout.addWidget(self.rotXFixBox, 11, 1, 1, 1)
        self.latticeFixBox = QtWidgets.QCheckBox(self.centralwidget)
        self.latticeFixBox.setObjectName("latticeFixBox")
        self.gridLayout.addWidget(self.latticeFixBox, 11, 5, 1, 1)
        self.transZFixBox = QtWidgets.QCheckBox(self.centralwidget)
        self.transZFixBox.setObjectName("transZFixBox")
        self.gridLayout.addWidget(self.transZFixBox, 13, 3, 1, 1)
        self.angleZSpin = QtWidgets.QDoubleSpinBox(self.centralwidget)
        self.angleZSpin.setWrapping(True)
        self.angleZSpin.setMinimum(-190.0)
        self.angleZSpin.setMaximum(190.0)
        self.angleZSpin.setSingleStep(0.1)
        self.angleZSpin.setProperty("value", 45.0)
        self.angleZSpin.setObjectName("angleZSpin")
        self.gridLayout.addWidget(self.angleZSpin, 13, 0, 1, 1)
        self.progressBar = QtWidgets.QProgressBar(self.centralwidget)
        self.progressBar.setProperty("value", 24)
        self.progressBar.setObjectName("progressBar")
        self.gridLayout.addWidget(self.progressBar, 17, 0, 1, 7)
        self.latticeSpin = QtWidgets.QDoubleSpinBox(self.centralwidget)
        self.latticeSpin.setMaximum(20.0)
        self.latticeSpin.setSingleStep(0.1)
        self.latticeSpin.setProperty("value", 5.65)
        self.latticeSpin.setObjectName("latticeSpin")
        self.gridLayout.addWidget(self.latticeSpin, 11, 4, 1, 1)
        self.reflexList = QtWidgets.QListWidget(self.centralwidget)
        self.reflexList.setSelectionMode(QtWidgets.QAbstractItemView.MultiSelection)
        self.reflexList.setObjectName("reflexList")
        self.gridLayout.addWidget(self.reflexList, 8, 0, 1, 7)
        self.transYSpin = QtWidgets.QDoubleSpinBox(self.centralwidget)
        self.transYSpin.setWrapping(True)
        self.transYSpin.setDecimals(0)
        self.transYSpin.setMinimum(-1000.0)
        self.transYSpin.setMaximum(10000.0)
        self.transYSpin.setSingleStep(1.0)
        self.transYSpin.setObjectName("transYSpin")
        self.gridLayout.addWidget(self.transYSpin, 12, 2, 1, 1)
        self.transXSpin = QtWidgets.QDoubleSpinBox(self.centralwidget)
        self.transXSpin.setWrapping(True)
        self.transXSpin.setDecimals(0)
        self.transXSpin.setMinimum(-1000.0)
        self.transXSpin.setMaximum(10000.0)
        self.transXSpin.setSingleStep(1.0)
        self.transXSpin.setObjectName("transXSpin")
        self.gridLayout.addWidget(self.transXSpin, 11, 2, 1, 1)
        self.angleYSpin = QtWidgets.QDoubleSpinBox(self.centralwidget)
        self.angleYSpin.setWrapping(True)
        self.angleYSpin.setMinimum(-190.0)
        self.angleYSpin.setMaximum(190.0)
        self.angleYSpin.setSingleStep(0.1)
        self.angleYSpin.setObjectName("angleYSpin")
        self.gridLayout.addWidget(self.angleYSpin, 12, 0, 1, 1)
        self.label = QtWidgets.QLabel(self.centralwidget)
        self.label.setObjectName("label")
        self.gridLayout.addWidget(self.label, 10, 0, 1, 1)
        self.clearButton = QtWidgets.QPushButton(self.centralwidget)
        self.clearButton.setObjectName("clearButton")
        self.gridLayout.addWidget(self.clearButton, 15, 6, 1, 1)
        self.transZSpin = QtWidgets.QDoubleSpinBox(self.centralwidget)
        self.transZSpin.setWrapping(True)
        self.transZSpin.setDecimals(0)
        self.transZSpin.setMinimum(-1000.0)
        self.transZSpin.setMaximum(10000.0)
        self.transZSpin.setSingleStep(1.0)
        self.transZSpin.setProperty("value", 2800.0)
        self.transZSpin.setObjectName("transZSpin")
        self.gridLayout.addWidget(self.transZSpin, 13, 2, 1, 1)
        self.saveButton = QtWidgets.QPushButton(self.centralwidget)
        self.saveButton.setObjectName("saveButton")
        self.gridLayout.addWidget(self.saveButton, 15, 4, 1, 1)
        self.label_5 = QtWidgets.QLabel(self.centralwidget)
        self.label_5.setObjectName("label_5")
        self.gridLayout.addWidget(self.label_5, 7, 0, 1, 1)
        self.loadButton = QtWidgets.QPushButton(self.centralwidget)
        self.loadButton.setObjectName("loadButton")
        self.gridLayout.addWidget(self.loadButton, 1, 0, 1, 1)
        self.label_7 = QtWidgets.QLabel(self.centralwidget)
        self.label_7.setObjectName("label_7")
        self.gridLayout.addWidget(self.label_7, 0, 0, 1, 1)
        self.label_10 = QtWidgets.QLabel(self.centralwidget)
        self.label_10.setObjectName("label_10")
        self.gridLayout.addWidget(self.label_10, 3, 2, 1, 1)
        self.thresholdSlider = QtWidgets.QSlider(self.centralwidget)
        self.thresholdSlider.setMaximum(99)
        self.thresholdSlider.setSliderPosition(5)
        self.thresholdSlider.setOrientation(QtCore.Qt.Horizontal)
        self.thresholdSlider.setObjectName("thresholdSlider")
        self.gridLayout.addWidget(self.thresholdSlider, 4, 4, 1, 1)
        self.peakButton = QtWidgets.QPushButton(self.centralwidget)
        self.peakButton.setObjectName("peakButton")
        self.gridLayout.addWidget(self.peakButton, 4, 6, 1, 1)
        spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.gridLayout.addItem(spacerItem, 2, 2, 1, 1)
        self.label_6 = QtWidgets.QLabel(self.centralwidget)
        self.label_6.setObjectName("label_6")
        self.gridLayout.addWidget(self.label_6, 3, 4, 1, 1)
        self.label_9 = QtWidgets.QLabel(self.centralwidget)
        self.label_9.setObjectName("label_9")
        self.gridLayout.addWidget(self.label_9, 3, 0, 1, 1)
        spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.gridLayout.addItem(spacerItem1, 14, 2, 1, 1)
        self.label_4 = QtWidgets.QLabel(self.centralwidget)
        self.label_4.setObjectName("label_4")
        self.gridLayout.addWidget(self.label_4, 10, 6, 1, 1)
        self.energySpin = QtWidgets.QDoubleSpinBox(self.centralwidget)
        self.energySpin.setDecimals(2)
        self.energySpin.setMaximum(20.0)
        self.energySpin.setSingleStep(0.1)
        self.energySpin.setProperty("value", 9.25)
        self.energySpin.setObjectName("energySpin")
        self.gridLayout.addWidget(self.energySpin, 11, 6, 1, 1)
        self.label_2 = QtWidgets.QLabel(self.centralwidget)
        self.label_2.setObjectName("label_2")
        self.gridLayout.addWidget(self.label_2, 10, 2, 1, 1)
        self.fitButton = QtWidgets.QPushButton(self.centralwidget)
        self.fitButton.setObjectName("fitButton")
        self.gridLayout.addWidget(self.fitButton, 15, 2, 1, 1)
        spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.gridLayout.addItem(spacerItem2, 9, 0, 1, 1)
        self.plotButton = QtWidgets.QPushButton(self.centralwidget)
        self.plotButton.setObjectName("plotButton")
        self.gridLayout.addWidget(self.plotButton, 15, 0, 1, 1)
        spacerItem3 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        self.gridLayout.addItem(spacerItem3, 6, 2, 1, 1)
        self.angleXSpin = QtWidgets.QDoubleSpinBox(self.centralwidget)
        self.angleXSpin.setWrapping(True)
        self.angleXSpin.setMinimum(-190.0)
        self.angleXSpin.setMaximum(190.0)
        self.angleXSpin.setSingleStep(0.1)
        self.angleXSpin.setObjectName("angleXSpin")
        self.gridLayout.addWidget(self.angleXSpin, 11, 0, 1, 1)
        self.label_3 = QtWidgets.QLabel(self.centralwidget)
        self.label_3.setObjectName("label_3")
        self.gridLayout.addWidget(self.label_3, 10, 4, 1, 1)
        self.rangeSlider = QRangeSlider(self.centralwidget)
        self.rangeSlider.setBaseSize(QtCore.QSize(0, 0))
        self.rangeSlider.setObjectName("rangeSlider")
        self.gridLayout.addWidget(self.rangeSlider, 5, 2, 1, 2)
        self.label_8 = QtWidgets.QLabel(self.centralwidget)
        self.label_8.setObjectName("label_8")
        self.gridLayout.addWidget(self.label_8, 5, 0, 1, 1)
        self.horizontalLayout.addLayout(self.gridLayout)
        self.horizontalLayout.setStretch(0, 1)
        self.horizontalLayout_2.addLayout(self.horizontalLayout)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 1430, 22))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Kossel"))
        self.transXFixBox.setText(_translate("MainWindow", "Fix"))
        self.inputfileLabel.setText(_translate("MainWindow", "No file selected"))
        self.rotYFixBox.setText(_translate("MainWindow", "Fix"))
        self.removeBackgroundBox.setText(_translate("MainWindow", "remove"))
        self.rotZFixBox.setText(_translate("MainWindow", "Fix"))
        self.transYFixBox.setText(_translate("MainWindow", "Fix"))
        self.rotXFixBox.setText(_translate("MainWindow", "Fix"))
        self.latticeFixBox.setText(_translate("MainWindow", "Fix"))
        self.transZFixBox.setText(_translate("MainWindow", "Fix"))
        self.angleZSpin.setSuffix(_translate("MainWindow", "°"))
        self.latticeSpin.setSuffix(_translate("MainWindow", "A"))
        self.transYSpin.setSuffix(_translate("MainWindow", "px"))
        self.transXSpin.setSuffix(_translate("MainWindow", "px"))
        self.angleYSpin.setSuffix(_translate("MainWindow", "°"))
        self.label.setText(_translate("MainWindow", "Euler angles"))
        self.clearButton.setText(_translate("MainWindow", "Clear"))
        self.transZSpin.setSuffix(_translate("MainWindow", "px"))
        self.saveButton.setText(_translate("MainWindow", "Save"))
        self.label_5.setText(_translate("MainWindow", "Reflexes"))
        self.loadButton.setText(_translate("MainWindow", "Load"))
        self.label_7.setText(_translate("MainWindow", "Inputfile"))
        self.label_10.setText(_translate("MainWindow", "Background"))
        self.peakButton.setText(_translate("MainWindow", "Find Peaks"))
        self.label_6.setText(_translate("MainWindow", "Peak Threshold"))
        self.label_9.setText(_translate("MainWindow", "Dataset"))
        self.label_4.setText(_translate("MainWindow", "Energy"))
        self.energySpin.setSuffix(_translate("MainWindow", "keV"))
        self.label_2.setText(_translate("MainWindow", "Translation"))
        self.fitButton.setText(_translate("MainWindow", "Fit"))
        self.plotButton.setText(_translate("MainWindow", "Plot"))
        self.angleXSpin.setSuffix(_translate("MainWindow", "°"))
        self.label_3.setText(_translate("MainWindow", "Lattice Contant"))
        self.label_8.setText(_translate("MainWindow", "Display Range"))
