+ QFormLayout *const layout = new QFormLayout;
+
+ // Add the number of vdivs
+ pvdiv_sb_ = new QSpinBox(parent);
+ pvdiv_sb_->setRange(0, MaximumVDivs);
+ pvdiv_sb_->setValue(pos_vdivs_);
+ connect(pvdiv_sb_, SIGNAL(valueChanged(int)),
+ this, SLOT(on_pos_vdivs_changed(int)));
+ layout->addRow(tr("Number of pos vertical divs"), pvdiv_sb_);
+
+ nvdiv_sb_ = new QSpinBox(parent);
+ nvdiv_sb_->setRange(0, MaximumVDivs);
+ nvdiv_sb_->setValue(neg_vdivs_);
+ connect(nvdiv_sb_, SIGNAL(valueChanged(int)),
+ this, SLOT(on_neg_vdivs_changed(int)));
+ layout->addRow(tr("Number of neg vertical divs"), nvdiv_sb_);
+
+ // Add the vertical resolution
+ resolution_cb_ = new QComboBox(parent);
+
+ for (int i = MinScaleIndex; i < MaxScaleIndex; i++) {
+ const QString label = QString("%1").arg(get_resolution(i));
+ resolution_cb_->insertItem(0, label, QVariant(i));
+ }
+
+ int cur_idx = resolution_cb_->findData(QVariant(scale_index_));
+ resolution_cb_->setCurrentIndex(cur_idx);
+
+ connect(resolution_cb_, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(on_resolution_changed(int)));
+
+ QGridLayout *const vdiv_layout = new QGridLayout;
+ QLabel *const vdiv_unit = new QLabel(tr("V/div"));
+ vdiv_layout->addWidget(resolution_cb_, 0, 0);
+ vdiv_layout->addWidget(vdiv_unit, 0, 1);
+
+ layout->addRow(tr("Vertical resolution"), vdiv_layout);
+
+ // Add the autoranging checkbox
+ QCheckBox* autoranging_cb = new QCheckBox();
+ autoranging_cb->setCheckState(autoranging_ ? Qt::Checked : Qt::Unchecked);
+
+ connect(autoranging_cb, SIGNAL(stateChanged(int)),
+ this, SLOT(on_autoranging_changed(int)));
+
+ layout->addRow(tr("Autoranging"), autoranging_cb);
+
+ // Add the conversion type dropdown
+ conversion_cb_ = new QComboBox();
+
+ conversion_cb_->addItem("none", data::SignalBase::NoConversion);
+ conversion_cb_->addItem("to logic via threshold", data::SignalBase::A2LConversionByTreshold);
+ conversion_cb_->addItem("to logic via schmitt-trigger", data::SignalBase::A2LConversionBySchmittTrigger);
+
+ cur_idx = conversion_cb_->findData(QVariant(conversion_type_));
+ conversion_cb_->setCurrentIndex(cur_idx);
+
+// layout->addRow(tr("Conversion"), conversion_cb_);
+
+ connect(conversion_cb_, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(on_conversion_changed(int)));
+
+ // Add the display type dropdown
+ display_type_cb_ = new QComboBox();
+
+ display_type_cb_->addItem(tr("Analog"), DisplayAnalog);
+ display_type_cb_->addItem(tr("Converted"), DisplayConverted);
+ display_type_cb_->addItem(tr("Both"), DisplayBoth);
+
+ cur_idx = display_type_cb_->findData(QVariant(display_type_));
+ display_type_cb_->setCurrentIndex(cur_idx);
+
+// layout->addRow(tr("Traces to show:"), display_type_cb_);
+
+ connect(display_type_cb_, SIGNAL(currentIndexChanged(int)),
+ this, SLOT(on_display_type_changed(int)));
+
+ form->addRow(layout);
+}
+
+void AnalogSignal::on_samples_added()
+{
+ perform_autoranging(false, false);
+}
+
+void AnalogSignal::on_pos_vdivs_changed(int vdivs)
+{
+ if (vdivs == pos_vdivs_)
+ return;
+
+ pos_vdivs_ = vdivs;
+
+ // There has to be at least one div, positive or negative
+ if ((neg_vdivs_ == 0) && (pos_vdivs_ == 0)) {
+ pos_vdivs_ = 1;
+ if (pvdiv_sb_)
+ pvdiv_sb_->setValue(pos_vdivs_);
+ }
+
+ if (autoranging_) {
+ perform_autoranging(true, true);
+
+ // It could be that a positive or negative div was added, so update
+ if (pvdiv_sb_) {
+ pvdiv_sb_->setValue(pos_vdivs_);
+ nvdiv_sb_->setValue(neg_vdivs_);
+ }
+ }
+
+ if (owner_) {
+ // Call order is important, otherwise the lazy event handler won't work
+ owner_->extents_changed(false, true);
+ owner_->row_item_appearance_changed(false, true);
+ }
+}
+
+void AnalogSignal::on_neg_vdivs_changed(int vdivs)
+{
+ if (vdivs == neg_vdivs_)
+ return;
+
+ neg_vdivs_ = vdivs;
+
+ // There has to be at least one div, positive or negative
+ if ((neg_vdivs_ == 0) && (pos_vdivs_ == 0)) {
+ pos_vdivs_ = 1;
+ if (pvdiv_sb_)
+ pvdiv_sb_->setValue(pos_vdivs_);
+ }
+
+ if (autoranging_) {
+ perform_autoranging(true, true);
+
+ // It could be that a positive or negative div was added, so update
+ if (pvdiv_sb_) {
+ pvdiv_sb_->setValue(pos_vdivs_);
+ nvdiv_sb_->setValue(neg_vdivs_);
+ }
+ }
+
+ if (owner_) {
+ // Call order is important, otherwise the lazy event handler won't work
+ owner_->extents_changed(false, true);
+ owner_->row_item_appearance_changed(false, true);
+ }