from PyQt import QtGui, QtCore
from qgis.core import *
from qgis.gui import *

class Ui_RUSLE_slope(object):
    def setupUi(self, RUSLE_slope):
        
        # create main window
        RUSLE_slope.setWindowModality(QtCore.Qt.ApplicationModal)
        RUSLE_slope.resize(300,200)  
        
        # input file contour line 
        # create gridLayout
        self.gridLayout1 = QGridLayout(RUSLE_slope)
        self.gridLayout1.setObjectName("gridLayout1")
        # create label in gridLayout 
        self.label_contour = QLabel(RUSLE_slope)
        self.label_contour.setObjectName("label_contour")
        # define label (QWidget, row, column, QtAlignement)
        self.gridLayout1.addWidget(self.label_contour,0,0,1,1)
        # create select button to input file
        self.selectButton_contour = QPushButton(RUSLE_slope)
        self.selectButton_contour.setObjectName("selectButton_contour")
        self.gridLayout1.addWidget(self.selectButton_contour,0,2,1,1)
        self.inputLayerCombo_contour = QComboBox(RUSLE_slope)
        self.inputLayerCombo_contour.setObjectName("inputLayerCombo_contour")
        self.gridLayout1.addWidget(self.inputLayerCombo_contour, 0,1,1,1)
        
        # input mask file
        # create label in gridLayout 
        self.label_mask = QLabel(RUSLE_slope)
        self.label_mask.setObjectName("label_mask")
        # define label (QWidget, row, column, QtAlignement)
        self.gridLayout1.addWidget(self.label_mask,1,0,1,1)
        # create select button to input file
        self.selectButton_mask = QPushButton(RUSLE_slope)
        self.selectButton_mask.setObjectName("selectButton_mask")
        self.gridLayout1.addWidget(self.selectButton_mask,1,2,1,1)
        self.inputLayerCombo_mask = QComboBox(RUSLE_slope)
        self.inputLayerCombo_mask.setObjectName("inputLayerCombo_mask")
        self.gridLayout1.addWidget(self.inputLayerCombo_mask, 1,1,1,1)
        # stretch to extend the widget in column 1
        self.gridLayout1.setColumnStretch(1,1)         
        
        # input dem raster
        # create label in gridLayout 
        self.label_dem = QLabel(RUSLE_slope)
        self.label_dem.setObjectName("label_dem")
        # define label (QWidget, row, column, QtAlignement)
        self.gridLayout1.addWidget(self.label_dem,2,0,1,1)
        # create select button to input file
        self.selectButton_dem = QPushButton(RUSLE_slope)
        self.selectButton_dem.setObjectName("selectButton_dem")
        self.gridLayout1.addWidget(self.selectButton_dem,2,2,1,1)
        self.inputLayerCombo_dem = QComboBox(RUSLE_slope)
        self.inputLayerCombo_dem.setObjectName("inputLayerCombo_dem")
        self.gridLayout1.addWidget(self.inputLayerCombo_dem, 2,1,1,1)
        
        # define a groupbox to specify the cell size and attribute
        self.groupBox1 = QGroupBox(RUSLE_slope)
        self.groupBox1.setObjectName("groupBox1")
        self.groupBox1.setTitle("In case of contour")
        self.gridLayout3 = QGridLayout(self.groupBox1)
        self.gridLayout3.setObjectName("gridLayout3")
        self.gridLayout1.addWidget(self.groupBox1, 3,0,1,-1)
        # define attribute "Elevation"
        self.labelAttrib = QLabel(RUSLE_slope)
        self.labelAttrib.setObjectName("labelAttrib")
        self.gridLayout3.addWidget(self.labelAttrib,0,0,-1,1)
        self.lineAttrib = QComboBox(RUSLE_slope)
        self.lineAttrib.setObjectName("lineAttrib")
        self.gridLayout3.addWidget(self.lineAttrib,0,1,-1,1)
        # define pixel size
        self.labelPix = QLabel(RUSLE_slope)
        self.labelPix.setObjectName("labelPix")
        self.gridLayout3.addWidget(self.labelPix, 0,3,-1,1)
        self.linePix = QSpinBox()
        self.linePix.setValue(29)
        self.linePix.stepBy(1)
        self.linePix.setObjectName("linePix")
        self.gridLayout3.addWidget(self.linePix,0,4,-1,1)         

        # output file
        # create label in gridLayout
        self.label_out = QLabel(RUSLE_slope)
        self.label_out.setObjectName("label_out")
        # define label (QWidget, row, column, QtAlignement)
        self.gridLayout1.addWidget(self.label_out,4,0,1,1)
        # create select button to output file
        self.selectButton_out = QPushButton(RUSLE_slope)
        self.selectButton_out.setObjectName("selectButton_out")
        self.gridLayout1.addWidget(self.selectButton_out,4,2,1,1)
        self.inputLayerCombo_out = QLineEdit(RUSLE_slope)
        self.inputLayerCombo_out.setObjectName("inputLayerCombo_out")
        self.gridLayout1.addWidget(self.inputLayerCombo_out, 4,1,1,1)
        # stretch to extend the widget in column 1
        self.gridLayout1.setColumnStretch(1,1)                   
 
    
        # button Ok, Close and Help
        self.buttonBox = QDialogButtonBox(RUSLE_slope)
        self.buttonBox.setStandardButtons(QDialogButtonBox.Cancel|QDialogButtonBox.Help|QDialogButtonBox.Ok)
        self.buttonBox.setObjectName("buttonBox")
        self.gridLayout1.addWidget(self.buttonBox, 5, 1, 1, 1)           
                  
    
        self.retranslateUi(RUSLE_slope)
        self.buttonBox.rejected.connect(RUSLE_slope.close)
            
    def retranslateUi(self, RUSLE_slope):
        RUSLE_slope.setWindowTitle("RUSLE", "RUSLE Topographic")
        self.label_contour.setText('RUSLE', 'Input contour:')   
        self.label_dem.setText('RUSLE', 'Input dem:')   
        self.label_out.setText('RUSLE', 'Output LS:')    
        self.selectButton_contour.setText('RUSLE', 'Browse')
        self.selectButton_dem.setText('RUSLE', 'Browse')
        self.selectButton_out.setText('RUSLE', 'Browse')
        self.label_mask.setText('RUSLE', 'Input mask:')
        self.selectButton_mask.setText('RUSLE', 'Browse')  
        self.labelPix.setText('RUSLE', 'Cell size:')
        self.labelAttrib.setText('RUSLE', 'Attribute:')   
        