Пример #1
0
 def acceleration_unit_change(self):
     if get_text(self.comboBox) == 'g':
         self.tableWidget.setHorizontalHeaderLabels(
             ['Time (s)', 'Acceleration (g)'])
     elif get_text(self.comboBox) == 'm/s²':
         self.tableWidget.setHorizontalHeaderLabels(
             ['Time (s)', 'Acceleration (m/s²)'])
Пример #2
0
    def plot_excitation(self):
        flag = self.check_table()
        if flag:
            return
        t = []
        a = []
        for i in range(self.tableWidget.rowCount()):
            x = float(get_text(self.tableWidget.item(i, 0)))
            y = float(get_text(self.tableWidget.item(i, 1)))
            t.append(x)
            a.append(y)

        t = np.array(t)
        a = np.array(a)

        if get_text(self.comboBox) == 'g':
            self.widget.excitationCanvas.plot_excitation(t, a, 'g')
        elif get_text(self.comboBox) == 'm/s²':
            self.widget.excitationCanvas.plot_excitation(t, a)
Пример #3
0
 def check_cell(self, row, column):
     try:
         float(get_text(self.tableWidget.item(row, column)))
     except Exception:
         error01_title = "Error 01"
         error01_msg = "Table item has non-float value."
         QMessageBox.warning(self, error01_title, error01_msg,
                             QMessageBox.Ok)
         return True
     else:
         return False
Пример #4
0
    def save_file(self):
        if self.fileName is None:
            self.save_file_as()
        else:
            self.check_table()
            if get_text(self.comboBox) == 'g':
                unit = 'unit: g\n'
            elif get_text(self.comboBox) == 'm/s²':
                unit = 'unit: m/s2\n'

            rows = '{}\n'.format(self.tableWidget.rowCount())

            with open(self.fileName, 'w') as file:
                file.write(unit)
                file.write(rows)
                for i in range(self.tableWidget.rowCount()):
                    file.write('{}, '.format(
                        get_text(self.tableWidget.item(i, 0))))
                    file.write('{}\n'.format(
                        get_text(self.tableWidget.item(i, 1))))