Ejemplo n.º 1
0
 def selectAllOutputs(self):
     table = self.outputTable
     for row in range(table.rowCount()):
         if gh.getCellText(table, row, 0) != 'graph.error':
             gh.setCellChecked(table, row, 0, check=True)
Ejemplo n.º 2
0
 def selectNoInputs(self):
     table = self.inputTable
     for row in range(table.rowCount()):
         gh.setCellChecked(table, row, 0, check=False)
Ejemplo n.º 3
0
    def refreshContents(self):
        '''
            Update the contents of the surrogate for to reflect the
            current state of the foqus session.
        '''
        self.ivGeneralButton1.hide()
        self.ivGeneralButton2.hide()
        self.ovGeneralButton1.hide()
        self.ovGeneralButton2.hide()
        self.dataBrowser.refreshContents()
        inputNames = self.dat.flowsheet.input.compoundNames()
        self.dat.flowsheet.markConnectedInputs()
        delList = []
        for i in range(len(inputNames)):
            if self.dat.flowsheet.input.get(inputNames[i]).con == True:
                delList.append(inputNames[i])
        for n in delList:
            inputNames.remove(n)
        outputNames = self.dat.flowsheet.output.compoundNames()
        if self.dat.surrogateCurrent is not None:
            i = self.toolSelectBox.findText(self.dat.surrogateCurrent)
            if i >= 0:
                self.blockapply = True
                self.toolSelectBox.setCurrentIndex(i)
                self.blockapply = False
        tool = self.toolSelectBox.currentText()
        if tool == '':
            return
        pg = self.dat.surrogateMethods.plugins[tool].\
            surrogateMethod(self.dat)
        pg.loadFromSession()
        pg.updateOptions()

        for i, btn in enumerate(pg.inputVarButtons):
            # this is because I am beeing lazy there are two
            # preexisting buttons
            if i == 0:
                self.ivGeneralButton1.setText(btn[0])
                self.ivGeneralButton1.show()
            elif i == 1:
                self.ivGeneralButton2.setText(btn[0])
                self.ivGeneralButton2.show()

        for i, btn in enumerate(pg.outputVarButtons):
            if i == 0:
                self.ovGeneralButton1.setText(btn[0])
                self.ovGeneralButton1.show()
            elif i == 1:
                self.ovGeneralButton2.setText(btn[0])
                self.ovGeneralButton2.show()

        for i in range(self.optTable[tool].rowCount()):
            oname = gh.getCellText(self.optTable[tool], i, 0)
            if oname in pg.options:
                if pg.options[oname].dtype == bool:
                    gh.setCellChecked(self.optTable[tool], i, 1,
                                      pg.options[oname].value)
                elif len(pg.options[oname].validValues) > 0:
                    gh.cellPulldownSetItemsJSON(self.optTable[tool], i, 1,
                                                pg.options[oname].validValues)
                    gh.cellPulldownSetJSON(self.optTable[tool], i, 1,
                                           pg.options[oname].value)
                else:
                    gh.setCellJSON(self.optTable[tool], i, 1,
                                   pg.options[oname].value)
        self.inputTable.setRowCount(0)
        self.inputTable.setColumnCount(3 + len(pg.inputCols))
        for i, item in enumerate(pg.inputCols):
            gh.setColHeaderIntem(self.inputTable, i + 3, item[0])
        self.outputTable.setRowCount(0)
        self.outputTable.setColumnCount(1 + len(pg.outputCols))
        for i, item in enumerate(pg.outputCols):
            gh.setColHeaderIntem(self.outputTable, i + 1, item[0])
        self.inputTable.setRowCount(len(inputNames))
        self.outputTable.setRowCount(len(outputNames))
        self.inputCols = gh.colIndexes(self.inputTable)
        self.outputCols = gh.colIndexes(self.outputTable)
        for i in range(len(inputNames)):
            var = self.dat.flowsheet.input.get(inputNames[i])
            gh.setTableItem(self.inputTable,
                            row=i,
                            col=self.inputCols['Name'],
                            text=inputNames[i],
                            check=inputNames[i] in pg.input,
                            editable=False)
            gh.setTableItem(self.inputTable,
                            row=i,
                            col=self.inputCols['Max'],
                            text=var.max,
                            jsonEnc=True)
            gh.setTableItem(self.inputTable,
                            row=i,
                            col=self.inputCols['Min'],
                            text=var.min,
                            jsonEnc=True)
            for item in pg.inputCols:
                val = pg.getInputVarOption(item[0], inputNames[i])
                gh.setTableItem(self.inputTable,
                                row=i,
                                col=self.inputCols[item[0]],
                                text=val,
                                jsonEnc=True)
        for i in range(len(outputNames)):
            var = self.dat.flowsheet.output.get(outputNames[i])
            gh.setTableItem(self.outputTable,
                            row=i,
                            col=self.outputCols['Name'],
                            text=outputNames[i],
                            check=outputNames[i] in pg.output,
                            editable=False)
            for item in pg.outputCols:
                val = pg.getOutputVarOption(item[0], outputNames[i])
                gh.setTableItem(self.outputTable,
                                row=i,
                                col=self.outputCols[item[0]],
                                text=val,
                                jsonEnc=True)
        self.inputTable.resizeColumnsToContents()
        self.outputTable.resizeColumnsToContents()