Example #1
0
class ControlsWidget(QWidget):
    def __init__(self, parent=None):
        QWidget.__init__(self)
        self.tfPlot = TransferFunctionPlot()

        self.modelCombo = QComboBox()
        self.modelCombo.addItems(AvailableModels)
        self.quantityCombo = QComboBox()
        self.quantityCombo.addItems(['Impedance', 'Admittance'])

        self.fMinSb = QDoubleSpinBox()
        self.fMinSb.setRange(0.1, 1E6)
        self.fMaxSb = QDoubleSpinBox()
        self.fMaxSb.setRange(10, 1E6)
        self.fMinSb.setKeyboardTracking(False)
        self.fMaxSb.setKeyboardTracking(False)
        self.fMinSb.valueChanged.connect(self.fMinSb.setMinimum)
        self.fMaxSb.valueChanged.connect(self.fMaxSb.setMaximum)
        self.fMinSb.setValue(1)
        self.fMaxSb.setValue(250E3)

        self.shuntSb = QDoubleSpinBox()
        self.shuntSb.setDecimals(4)
        self.shuntSb.setKeyboardTracking(False)
        self.shuntSb.setRange(0.010, 10)
        self.shuntSb.setSuffix(u' m\u03A9')
        self.shuntSb.setValue(0.257)

        l = QFormLayout()
        l.addRow('Model', self.modelCombo)
        l.addRow('Quantity', self.quantityCombo)
        l.addRow('f (min)', self.fMinSb)
        l.addRow('f (max)', self.fMaxSb)
        l.addRow('Shunt resistance', self.shuntSb)
        self.setLayout(l)
Example #2
0
    def __init__(self, vpoints: Sequence[VPoint], vlinks: Sequence[VLink],
                 path: _Paths, slider_path: _SliderPaths, monochrome: bool,
                 parent: QWidget):
        super(AnimateDialog, self).__init__(parent)
        self.setWindowTitle("Vector Animation")
        self.setWindowFlags(self.windowFlags() | Qt.WindowMaximizeButtonHint
                            & ~Qt.WindowContextHelpButtonHint)
        self.setMinimumSize(800, 600)
        self.setModal(True)
        main_layout = QVBoxLayout(self)
        self.canvas = _DynamicCanvas(vpoints, vlinks, path, slider_path, self)
        self.canvas.set_monochrome_mode(monochrome)
        self.canvas.update_pos.connect(self.__set_pos)
        layout = QHBoxLayout(self)
        pt_option = QComboBox(self)
        pt_option.addItems([f"P{p}" for p in range(len(vpoints))])
        layout.addWidget(pt_option)
        value_label = QLabel(self)

        @Slot(int)
        def show_values(ind: int):
            vel, vel_deg = self.canvas.get_vel(ind)
            acc, acc_deg = self.canvas.get_acc(ind)
            value_label.setText(
                f"Velocity: {vel:.04f} ({vel_deg:.04f}deg) | "
                f"Acceleration: {acc:.04f} ({acc_deg:.04f}deg)")

        pt_option.currentIndexChanged.connect(show_values)
        layout.addWidget(value_label)
        self.pos_label = QLabel(self)
        layout.addItem(
            QSpacerItem(40, 20, QSizePolicy.Expanding, QSizePolicy.Minimum))
        layout.addWidget(self.pos_label)
        main_layout.addLayout(layout)
        main_layout.addWidget(self.canvas)
        layout = QHBoxLayout(self)
        self.play = QPushButton(QIcon(QPixmap(":/icons/play.png")), "", self)
        self.play.setCheckable(True)
        self.play.clicked.connect(self.__play)
        layout.addWidget(self.play)
        self.slider = QSlider(Qt.Horizontal, self)
        self.slider.setMaximum(max(len(p) for p in path) - 1)
        self.slider.valueChanged.connect(self.canvas.set_index)
        layout.addWidget(self.slider)
        layout.addWidget(QLabel("Total times:", self))
        factor = QDoubleSpinBox(self)
        factor.valueChanged.connect(self.canvas.set_factor)
        factor.setSuffix('s')
        factor.setRange(0.01, 999999)
        factor.setValue(10)
        layout.addWidget(factor)
        main_layout.addLayout(layout)
        self.timer = QTimer()
        self.timer.setInterval(10)
        self.timer.timeout.connect(self.__move_ind)
Example #3
0
 def createEditor(self, parent, options, index):
     self.update = True
     node = index.internalPointer()
     if isinstance(node, JsonItem):
         if node.type in ('float', 'int'):
             editor = QDoubleSpinBox(parent)
             editor.setSuffix(node.unit or "")
             editor.setRange(node.min or -sys.maxsize,
                             node.max or sys.maxsize)
             editor.setGeometry(options.rect)
             editor.setDecimals(node.decimals or 0)
             editor.show()
             return editor
         else:
             return super().createEditor(parent, options, index)
Example #4
0
    def setupParameters(self, model):
        pBias = model.biasParameters()
        pSpecific = model.modelSpecificParameters()
        parameters = pBias + pSpecific
        self.setRowCount(len(parameters))
        self.siScale = {}
        self.rowMap = {}
        for row, parameter in enumerate(parameters):
            name, latex, unit, siScale, minimum, maximum, text = parameter
            guessSb = QDoubleSpinBox()
            if len(unit):
                guessSb.setSuffix(' %s' % unit)
            guessSb.setMinimum(minimum)
            guessSb.setMaximum(maximum)
            guessSb.setKeyboardTracking(False)
            item = QTableWidgetItem(name)
            item.setFlags(Qt.ItemIsUserCheckable | Qt.ItemIsEditable
                          | Qt.ItemIsEnabled)
            item.setCheckState(Qt.Checked)
            item.setToolTip(text)
            self.setItem(row, 0, item)
            self.setCellWidget(row, 1, guessSb)
            minSb = QDoubleSpinBox()
            maxSb = QDoubleSpinBox()
            minSb.setMinimum(minimum)
            minSb.setMaximum(maximum)
            minSb.setValue(minimum)
            maxSb.setMinimum(minimum)
            maxSb.setMaximum(maximum)
            maxSb.setValue(maximum)
            minSb.setKeyboardTracking(False)
            maxSb.setKeyboardTracking(False)

            maxSb.valueChanged.connect(minSb.setMaximum)
            maxSb.valueChanged.connect(guessSb.setMaximum)
            minSb.valueChanged.connect(maxSb.setMinimum)
            minSb.valueChanged.connect(guessSb.setMinimum)
            self.setCellWidget(row, 2, minSb)
            self.setCellWidget(row, 3, maxSb)
            guessSb.valueChanged.connect(self.parameterGuessChanged)
            self.siScale[name] = siScale
            self.rowMap[name] = row
Example #5
0
class CropDialog(QDialog):
    def __init__(self, parent, start, stop):
        super().__init__(parent)
        self.setWindowTitle("Crop data")
        vbox = QVBoxLayout(self)
        grid = QGridLayout()
        self.start_checkbox = QCheckBox("Start time:")
        self.start_checkbox.setChecked(True)
        self.start_checkbox.stateChanged.connect(self.toggle_start)
        grid.addWidget(self.start_checkbox, 0, 0)
        self._start = QDoubleSpinBox()
        self._start.setMaximum(999999)
        self._start.setValue(start)
        self._start.setDecimals(2)
        self._start.setSuffix(" s")
        grid.addWidget(self._start, 0, 1)

        self.stop_checkbox = QCheckBox("Stop time:")
        self.stop_checkbox.setChecked(True)
        self.stop_checkbox.stateChanged.connect(self.toggle_stop)
        grid.addWidget(self.stop_checkbox, 1, 0)
        self._stop = QDoubleSpinBox()
        self._stop.setMaximum(999999)
        self._stop.setValue(stop)
        self._stop.setDecimals(2)
        self._stop.setSuffix(" s")
        grid.addWidget(self._stop, 1, 1)
        vbox.addLayout(grid)
        buttonbox = QDialogButtonBox(QDialogButtonBox.Ok
                                     | QDialogButtonBox.Cancel)
        vbox.addWidget(buttonbox)
        buttonbox.accepted.connect(self.accept)
        buttonbox.rejected.connect(self.reject)
        vbox.setSizeConstraint(QVBoxLayout.SetFixedSize)

    @property
    def start(self):
        if self.start_checkbox.isChecked():
            return self._start.value()
        else:
            return None

    @property
    def stop(self):
        if self.stop_checkbox.isChecked():
            return self._stop.value()
        else:
            return None

    @Slot()
    def toggle_start(self):
        if self.start_checkbox.isChecked():
            self._start.setEnabled(True)
        else:
            self._start.setEnabled(False)

    @Slot()
    def toggle_stop(self):
        if self.stop_checkbox.isChecked():
            self._stop.setEnabled(True)
        else:
            self._stop.setEnabled(False)
Example #6
0
class ERDSDialog(QDialog):
    def __init__(self, parent, t_range, f_range):
        super().__init__(parent)
        self.setWindowTitle("ERDS maps")
        vbox = QVBoxLayout(self)
        grid = QGridLayout()

        grid.addWidget(QLabel("Frequency range:"), 0, 0)
        self._f1 = QDoubleSpinBox()
        self._f1.setRange(*f_range)
        self._f1.setValue(f_range[0])
        self._f1.setDecimals(1)
        self._f1.setSuffix(" Hz")
        grid.addWidget(self._f1, 0, 1)

        self._f2 = QDoubleSpinBox()
        self._f2.setRange(*f_range)
        self._f2.setValue(f_range[1])
        self._f2.setDecimals(1)
        self._f2.setSuffix(" Hz")
        grid.addWidget(self._f2, 0, 2)

        grid.addWidget(QLabel("Step size:"), 1, 0)
        self._step = QDoubleSpinBox()
        self._step.setRange(0.1, 5)
        self._step.setValue(1)
        self._step.setDecimals(1)
        self._step.setSingleStep(0.1)
        self._step.setSuffix(" Hz")
        grid.addWidget(self._step, 1, 1)

        grid.addWidget(QLabel("Time range:"), 2, 0)
        self._t1 = QDoubleSpinBox()
        self._t1.setRange(*t_range)
        self._t1.setValue(t_range[0])
        self._t1.setDecimals(1)
        self._step.setSingleStep(0.1)
        self._t1.setSuffix(" s")
        grid.addWidget(self._t1, 2, 1)

        self._t2 = QDoubleSpinBox()
        self._t2.setRange(*t_range)
        self._t2.setValue(t_range[1])
        self._t2.setDecimals(1)
        self._step.setSingleStep(0.1)
        self._t2.setSuffix(" s")
        grid.addWidget(self._t2, 2, 2)

        grid.addWidget(QLabel("Baseline:"), 3, 0)
        self._b1 = QDoubleSpinBox()
        self._b1.setRange(*t_range)
        self._b1.setValue(t_range[0])
        self._b1.setDecimals(1)
        self._step.setSingleStep(0.1)
        self._b1.setSuffix(" s")
        grid.addWidget(self._b1, 3, 1)

        self._b2 = QDoubleSpinBox()
        self._b2.setRange(*t_range)
        self._b2.setValue(0)
        self._b2.setDecimals(1)
        self._step.setSingleStep(0.1)
        self._b2.setSuffix(" s")
        grid.addWidget(self._b2, 3, 2)

        vbox.addLayout(grid)
        buttonbox = QDialogButtonBox(QDialogButtonBox.Ok
                                     | QDialogButtonBox.Cancel)
        vbox.addWidget(buttonbox)
        buttonbox.accepted.connect(self.accept)
        buttonbox.rejected.connect(self.reject)
        vbox.setSizeConstraint(QVBoxLayout.SetFixedSize)

    @property
    def f1(self):
        return self._f1.value()

    @property
    def f2(self):
        return self._f2.value()

    @property
    def step(self):
        return self._step.value()

    @property
    def t1(self):
        return self._t1.value()

    @property
    def t2(self):
        return self._t2.value()

    @property
    def b1(self):
        return self._b1.value()

    @property
    def b2(self):
        return self._b2.value()