Esempio n. 1
0
    def btnAddUSEvent(self):
        msg = FrictionLawMessage()
        value = msg.exec_()
        if value != QDialog.Accepted:
            return

        friction_law = msg.getChoice()
        self.data.us_equation = get_US_equation(friction_law)
        new_vars = new_variables_from_US(self.data.header.var_IDs)

        # add US, TAU, DMAX and FROTP to available variables
        offset = self.firstTable.rowCount()
        for i in range(len(new_vars)):
            var = new_vars[i]
            self.firstTable.insertRow(self.firstTable.rowCount())
            id_item = QTableWidgetItem(var.ID().strip())
            name_item = QTableWidgetItem(var.name(self.data.language))
            unit_item = QTableWidgetItem(var.unit())
            self.firstTable.setItem(offset+i, 0, id_item)
            self.firstTable.setItem(offset+i, 1, name_item)
            self.firstTable.setItem(offset+i, 2, unit_item)
            self.firstTable.item(offset+i, 0).setBackground(self.GREEN)  # set new US color to green
            self.firstTable.item(offset+i, 1).setBackground(self.GREEN)
            self.firstTable.item(offset+i, 2).setBackground(self.GREEN)

        # lock the add US button again
        self.btnAddUS.setEnabled(False)

        # unlock add Ws button
        self.btnAddWs.setEnabled(True)
Esempio n. 2
0
    def load(self, options):
        friction_law, vars, names, units = options
        friction_law = int(friction_law)
        if friction_law > -1:
            us_equation = get_US_equation(friction_law)
        else:
            us_equation = None

        if not vars:
            self.state = MultiNode.NOT_CONFIGURED
            return

        selected_vars = []
        selected_vars_names = {}
        for var, name, unit in zip(vars.split(','), names.split(','), units.split(',')):
            selected_vars.append(var)
            selected_vars_names[var] = (bytes(name, SLF_EIT).ljust(16), bytes(unit, SLF_EIT).ljust(16))
        self.options = (us_equation, selected_vars, selected_vars_names)