def RGB2HEX(RGB):
     
     HEX = []
     for i in range(len(RGB)):
         col = Colour(str(RGB[i]).split(","))
         col.create()
         HEX.append(col.getHexRGB())
         
     return HEX
    def create(self):
    
        info = "Input data:\n"

        try:
            self.nodProfiles, self.proProfiles = fh.readI2S(self.ui.lineEditInputProfiles.text())
            info += " - Profiles:\t\t\t{0}\n".format(len(self.proProfiles))
        except:
            QMessageBox.critical(self.widget, "Error", "Not able to load profiles file!\nCheck filename or content!")
            return
        try:
            self.nodReach = fh.readI2S(self.ui.lineEditInputReach.text())[0]
            info += " - Reach nodes:\t\t{0}\n".format(len(self.nodReach))
        except:
            QMessageBox.critical(self.widget, "Error", "Not able to load reach file!\nCheck filename or content!")
            return
        try:
            rows = self.ui.tableWidget.rowCount()
            for row in range(rows):
                self.ui.tableWidget.item(row, 0).text()
                self.ui.tableWidget.item(row, 1).text()
                str(self.ui.tableWidget.item(row, 2).text()).split(",")[2]
            info += " - Water surface results:\t{0}\n".format(rows)
        except:
            QMessageBox.critical(self.widget, "Error", "Check filename, surface name and colour!")
            return            
                
        self.proArranged, self.reachStation, self.profileStation, direction = po.determineFlowDirection(self.nodReach, self.nodProfiles, self.proProfiles)

        info += "\nFlow direction:\n"
        for pID_Arranged in direction:
            info += ' - Profile {0}:\t{1}\n'.format(pID_Arranged, direction[pID_Arranged])


        # create bottom cross sections
        try:
            bottom = fh.readT3StoShapely(self.ui.lineEditInputBottom.text())
            bottomCrossSections = self.getCrossSections(bottom)
        except:
            QMessageBox.critical(self.widget, "Error", "Not able to interpolate bottom profile!")
            return
        
        
        # create water surface cross sections
        try:        
            rows = self.ui.tableWidget.rowCount()
            wsCrossSections = {}
            colRGB = {}
            if rows > 0:
                for row in range(rows):
                    filename = self.ui.tableWidget.item(row, 0).text()
                    name = self.ui.tableWidget.item(row, 1).text()
                    watersurface = fh.readT3StoShapely(filename)
                    wsCrossSections[name] = self.getCrossSections(watersurface)
                    col = Colour(str(self.ui.tableWidget.item(row, 2).text()).split(","))
                    col.create()
                    colRGB[name] = col.getRGB()
        except:
            QMessageBox.critical(self.widget, "Error", "Not able to interpolate water surface profiles!")
            return
        
        scale = self.ui.spinBoxScale.value()
        superelevation = self.ui.doubleSpinBoxSuperelevation.value()
        
        info += "\nOutput data:\n"
        
        if self.ui.checkBoxOutputProfiles.isChecked():             
            try:        
                cs = ProfileWriter(self.ui.lineEditOutputProfiles.text(),\
                    bottomCrossSections,
                    self.reachStation,
                    self.profileStation,
                    scale,
                    superelevation,
                    self.settings,
                    self.ui.lineEditInputReachName.text())

                cs.drawBottom()
                cs.drawWaterSurface(wsCrossSections, colRGB)
                cs.saveDXF()

                info += " - DXF file written to {0}.\n".format(self.ui.lineEditOutputProfiles.text())
            except:
                info += " - ERROR: Not able to write profiles!\n"

        QMessageBox.information(self.widget, "Module ProfilesDXF", info)