Exemplo n.º 1
0
class SelectPlottedPoints(QDialog):
    point = pyqtSignal(int)

    def __init__(self, data, min, max, settings, type):
        super(SelectPlottedPoints, self).__init__()
        self.ui = Ui_SelectPlottedPoints()
        self.ui.setupUi(self)
        self.type = type
        self.min = min
        self.y_axis = data[min:max]
        self.x_axis = np.arange(min, min+len(self.y_axis))
        self.ui.x_coordinate.setRange(self.x_axis[0], self.x_axis[-1])
        self.plot = QtCommons.nestWidget(self.ui.plot_widget, QMathPlotWidget())
        self.finished.connect(lambda: self.deleteLater())
        self.ui.smoothing_factor.valueChanged.connect(self.factor_valueChanged)
        self.ui.smoothing_degree.valueChanged.connect(lambda v: self.draw())
        self.ui.smoothing_factor_auto.toggled.connect(lambda v: self.draw())
        self.ui.smoothing_factor_auto.toggled.connect(lambda v: self.ui.smoothing_factor.setEnabled(not v))
        self.restoreGeometry(settings.value('select_plotted_points_geometry', QByteArray()))
        self.finished.connect(lambda: settings.setValue('select_plotted_points_geometry', self.saveGeometry()))
        self.ui.x_coordinate.valueChanged.connect(self.set_point)
        
        QTimer.singleShot(100, self.draw)

    @pyqtSlot(float)
    def factor_valueChanged(self, f):
        self.draw()
        
    def draw(self):
        self.ui.smoothing_degree_value.setText("{}".format(self.ui.smoothing_degree.value()))
        smoothing_factor = self.ui.smoothing_factor.value() if not self.ui.smoothing_factor_auto.isChecked() else None
        spline = UnivariateSpline(self.x_axis, self.y_axis, k=self.ui.smoothing_degree.value(), s=smoothing_factor)
        f_x = spline(self.x_axis)
        self.plot.axes.plot(self.x_axis, self.y_axis, 'o', self.x_axis, f_x, '-')
        value = (f_x.argmin() if self.type == 'minimum' else f_x.argmax()) + self.min
        self.ui.x_coordinate.setValue(value)
        self.set_point(value)
        
    @pyqtSlot(int)
    def set_point(self, point):
        self.x_point = point
        self.point.emit(point)
        self.plot.add_line("x_axis_pick", point, color='r')
        self.plot.figure.canvas.draw()
Exemplo n.º 2
0
    def __init__(self, data, min, max, settings, type):
        super(SelectPlottedPoints, self).__init__()
        self.ui = Ui_SelectPlottedPoints()
        self.ui.setupUi(self)
        self.type = type
        self.min = min
        self.y_axis = data[min:max]
        self.x_axis = np.arange(min, min + len(self.y_axis))
        self.ui.x_coordinate.setRange(self.x_axis[0], self.x_axis[-1])
        self.plot = QtCommons.nestWidget(self.ui.plot_widget,
                                         QMathPlotWidget())
        self.finished.connect(lambda: self.deleteLater())
        self.ui.smoothing_factor.valueChanged.connect(self.factor_valueChanged)
        self.ui.smoothing_degree.valueChanged.connect(lambda v: self.draw())
        self.ui.smoothing_factor_auto.toggled.connect(lambda v: self.draw())
        self.ui.smoothing_factor_auto.toggled.connect(
            lambda v: self.ui.smoothing_factor.setEnabled(not v))
        self.restoreGeometry(
            settings.value('select_plotted_points_geometry', QByteArray()))
        self.finished.connect(lambda: settings.setValue(
            'select_plotted_points_geometry', self.saveGeometry()))
        self.ui.x_coordinate.valueChanged.connect(self.set_point)

        QTimer.singleShot(100, self.draw)
Exemplo n.º 3
0
 def __init__(self, data, min, max, settings, type):
     super(SelectPlottedPoints, self).__init__()
     self.ui = Ui_SelectPlottedPoints()
     self.ui.setupUi(self)
     self.type = type
     self.min = min
     self.y_axis = data[min:max]
     self.x_axis = np.arange(min, min+len(self.y_axis))
     self.ui.x_coordinate.setRange(self.x_axis[0], self.x_axis[-1])
     self.plot = QtCommons.nestWidget(self.ui.plot_widget, QMathPlotWidget())
     self.finished.connect(lambda: self.deleteLater())
     self.ui.smoothing_factor.valueChanged.connect(self.factor_valueChanged)
     self.ui.smoothing_degree.valueChanged.connect(lambda v: self.draw())
     self.ui.smoothing_factor_auto.toggled.connect(lambda v: self.draw())
     self.ui.smoothing_factor_auto.toggled.connect(lambda v: self.ui.smoothing_factor.setEnabled(not v))
     self.restoreGeometry(settings.value('select_plotted_points_geometry', QByteArray()))
     self.finished.connect(lambda: settings.setValue('select_plotted_points_geometry', self.saveGeometry()))
     self.ui.x_coordinate.valueChanged.connect(self.set_point)
     
     QTimer.singleShot(100, self.draw)