Exemplo n.º 1
0
    def update_table_values(self):
        """Update table values."""
        n = len(self._xvalues)
        self.tbl_table.clearContents()
        self.tbl_table.setRowCount(n)

        for i in range(n):
            if self._is_timestamp:
                dt = self._xvalues[i] - self._xvalues[0]
                self.tbl_table.setItem(
                    i, 0,
                    _QTableWidgetItem(self._bottom_axis_format.format(dt)))
            else:
                self.tbl_table.setItem(
                    i, 0,
                    _QTableWidgetItem(
                        self._bottom_axis_format.format(self._xvalues[i])))

            for j, label in enumerate(self._data_labels):
                fmt = self._data_formats[j]
                reading = self._readings[label][i]
                if reading is None:
                    reading = _np.nan
                self.tbl_table.setItem(i, j + 1,
                                       _QTableWidgetItem(fmt.format(reading)))

        vbar = self.tbl_table.verticalScrollBar()
        vbar.setValue(vbar.maximum())
Exemplo n.º 2
0
    def add_last_value_to_table(self):
        """Add the last value read to table."""
        if len(self._xvalues) == 0:
            return

        n = self.tbl_table.rowCount() + 1
        self.tbl_table.setRowCount(n)

        if self._is_timestamp:
            dt = self._xvalues[-1] - self._xvalues[0]
            self.tbl_table.setItem(
                n - 1, 0,
                _QTableWidgetItem(self._bottom_axis_format.format(dt)))
        else:
            self.tbl_table.setItem(
                n - 1, 0,
                _QTableWidgetItem(
                    self._bottom_axis_format.format(self._xvalues[-1])))

        for j, label in enumerate(self._data_labels):
            fmt = self._data_formats[j]
            reading = self._readings[label][-1]
            if reading is None:
                reading = _np.nan
            self.tbl_table.setItem(n - 1, j + 1,
                                   _QTableWidgetItem(fmt.format(reading)))

        vbar = self.tbl_table.verticalScrollBar()
        vbar.setValue(vbar.maximum())
Exemplo n.º 3
0
    def add_rows_to_table(self, data):
        """Add rows to table."""
        if len(self.column_names) == 0:
            return

        self.table.setRowCount(1)

        if len(data) > self.sb_max_number_rows.value():
            tabledata = data[-self.sb_max_number_rows.value()::]
        else:
            tabledata = data

        if len(tabledata) == 0:
            return

        self.sb_initial_id.setValue(int(tabledata[0]['id']))
        self.sb_number_rows.setValue(len(tabledata))
        self.table.setRowCount(len(tabledata) + 1)

        for j, col in enumerate(self.column_names):
            for i, row in enumerate(tabledata):
                item_str = str(row[col])
                if len(item_str) > self._max_str_size:
                    item_str = item_str[:10] + '...'
                item = _QTableWidgetItem(item_str)
                item.setFlags(_Qt.ItemIsSelectable | _Qt.ItemIsEnabled)
                self.table.setItem(i + 1, j, item)
Exemplo n.º 4
0
    def calc_curve_fit(self):
        """Calculate curve fit."""
        try:
            plots = self.get_selected_plots_mag()
            if len(plots) == 0:
                return

            x, y = self.get_x_y()

            func = self.ui.cmb_fitfunction.currentText()
            if func.lower() == 'linear':
                xfit, yfit, param, label = _linear_fit(x, y)
            elif func.lower() in ('polynomial', 'polinomial'):
                order = self.ui.sb_polyorder.value()
                xfit, yfit, param, label = _polynomial_fit(x, y, order)
            elif func.lower() in ('gaussian', 'gaussiana'):
                xfit, yfit, param, label = _gaussian_fit(x, y)
            else:
                xfit = []
                yfit = []
                param = {}
                label = ''

            self.ui.la_fitfunction.setText(label)
            self.ui.tbl_fit.clearContents()
            self.ui.tbl_fit.setRowCount(len(param))
            rcount = 0
            for key, value in param.items():
                self.ui.tbl_fit.setItem(
                    rcount, 0, _QTableWidgetItem(str(key)))
                self.ui.tbl_fit.setItem(
                    rcount, 1, _QTableWidgetItem(str(value)))
                rcount = rcount + 1

            self.update_plot_mag()
            self.ui.pw_graph_mag.plotItem.plot(xfit, yfit, pen=(0, 0, 0))

        except Exception:
            _traceback.print_exc(file=_sys.stdout)
Exemplo n.º 5
0
    def update_table(self):
        """Update table."""
        if self.database_name is None or self.table_name is None:
            return

        self.blockSignals(True)
        self.table.setColumnCount(0)
        self.table.setRowCount(0)

        all_column_names = self.database_collection.db_get_field_names()
        all_data_types = self.database_collection.db_get_field_types()

        self.column_names = []
        self.data_types = []
        for name, dtype in zip(all_column_names, all_data_types):
            if name not in self._hidden_columns:
                self.column_names.append(name)
                self.data_types.append(dtype)

        self.table.setColumnCount(len(self.column_names))
        self.table.setHorizontalHeaderLabels(self.column_names)

        self.table.setRowCount(1)
        for j in range(len(self.column_names)):
            self.table.setItem(0, j, _QTableWidgetItem(''))

        max_rows = self.sb_max_number_rows.value()
        data = self.database_collection.db_search_collection(
            self.column_names, max_nr_lines=max_rows)

        if len(data) > 0:
            min_idn = self.database_collection.db_get_first_id()
            self.sb_initial_id.setMinimum(min_idn)

            max_idn = self.database_collection.db_get_last_id()
            self.sb_initial_id.setMaximum(max_idn)

            self.sb_max_number_rows.setValue(len(data))
            self.data = data[:]
            self.add_rows_to_table(data)
        else:
            self.sb_initial_id.setMinimum(0)
            self.sb_initial_id.setMaximum(0)
            self.sb_max_number_rows.setValue(0)

        self.table.itemChanged.connect(self.filter_changed)
        self.table.itemSelectionChanged.connect(self.select_line)
        self.blockSignals(False)
Exemplo n.º 6
0
 def add_items_to_table(self, text, i, j):
     """Add items to table."""
     item = _QTableWidgetItem(text)
     item.setFlags(_Qt.ItemIsSelectable | _Qt.ItemIsEnabled)
     self.tbl_results.setItem(i, j, item)