pos_vdivs_(1),
neg_vdivs_(1),
resolution_(0),
- display_type_(DisplayBoth),
+ display_type_(DisplayAnalog),
autoranging_(true)
{
axis_pen_ = AxisPen;
result["neg_vdivs"] = neg_vdivs_;
result["scale_index"] = scale_index_;
result["display_type"] = display_type_;
- result["autoranging"] = pos_vdivs_;
+ result["autoranging"] = autoranging_;
result["div_height"] = div_height_;
return result;
div_height_ = settings["div_height"].toInt();
update_logic_level_offsets();
+ update_scale();
if ((div_height_ != old_height) && owner_) {
// Call order is important, otherwise the lazy event handler won't work
{
const int ph = pos_vdivs_ * div_height_;
const int nh = neg_vdivs_ * div_height_;
+
return make_pair(-ph, nh);
}
}
}
+ const bool showing_logic = (display_type_ == DisplayConverted) || (display_type_ == DisplayBoth);
+
// If there is still no positive div when we need it, add one
// (this can happen when pos_vdivs==neg_vdivs==0)
- if ((max > 0) && (pos_vdivs_ == 0)) {
+ if (((max > 0) && (pos_vdivs_ == 0)) || showing_logic) {
pos_vdivs_ = 1;
owner_->extents_changed(false, true);
}
// If there is still no negative div when we need it, add one
// (this can happen when pos_vdivs was 0 or 1 when trying to split)
- if ((min < 0) && (neg_vdivs_ == 0)) {
+ if (((min < 0) && (neg_vdivs_ == 0)) || showing_logic) {
neg_vdivs_ = 1;
owner_->extents_changed(false, true);
}
pvdiv_sb_ = new QSpinBox(parent);
pvdiv_sb_->setRange(0, MaximumVDivs);
pvdiv_sb_->setValue(pos_vdivs_);
+ pvdiv_sb_->setEnabled(!autoranging_);
connect(pvdiv_sb_, SIGNAL(valueChanged(int)),
this, SLOT(on_pos_vdivs_changed(int)));
form->addRow(tr("Number of pos vertical divs"), pvdiv_sb_);
nvdiv_sb_ = new QSpinBox(parent);
nvdiv_sb_->setRange(0, MaximumVDivs);
nvdiv_sb_->setValue(neg_vdivs_);
+ nvdiv_sb_->setEnabled(!autoranging_);
connect(nvdiv_sb_, SIGNAL(valueChanged(int)),
this, SLOT(on_neg_vdivs_changed(int)));
form->addRow(tr("Number of neg vertical divs"), nvdiv_sb_);
// Add the vertical resolution
resolution_cb_ = new QComboBox(parent);
+ resolution_cb_->setEnabled(!autoranging_);
for (int i = MinScaleIndex; i < MaxScaleIndex; i++) {
const QString label = QString("%1").arg(get_resolution(i));
{
autoranging_ = (state == Qt::Checked);
+ if (pvdiv_sb_)
+ pvdiv_sb_->setEnabled(!autoranging_);
+ if (nvdiv_sb_)
+ nvdiv_sb_->setEnabled(!autoranging_);
+ if (resolution_cb_)
+ resolution_cb_->setEnabled(!autoranging_);
+
if (autoranging_)
perform_autoranging(false, true);
base_->set_conversion_type(conv_type);
update_conversion_widgets();
+ if (conv_type == SignalBase::ConversionType::NoConversion)
+ on_display_type_changed(DisplayType::DisplayAnalog);
+ else
+ on_display_type_changed(DisplayType::DisplayBoth);
+
if (owner_)
owner_->row_item_appearance_changed(false, true);
}
// https://txt2re.com/index-c++.php3?s=0.1V&1&-13
QString re1 = "([+-]?\\d*[\\.,]?\\d*)"; // Float value
QString re2 = "([a-zA-Z]*)"; // SI unit
- QRegExp regex(re1 + re2);
-
const QString text = conv_threshold_cb_->currentText();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ QRegularExpression regex(re1 + re2);
+ if (!regex.match(text).hasMatch())
+ return; // String doesn't match the regex
+
+ QStringList tokens = regex.match(text).capturedTexts();
+#else
+ QRegExp regex(re1 + re2);
if (!regex.exactMatch(text))
return; // String doesn't match the regex
QStringList tokens = regex.capturedTexts();
+#endif
// For now, we simply assume that the unit is volt without modifiers
const double thr = tokens.at(1).toDouble();
QString re3 = "\\/"; // Forward slash, not captured
QString re4 = "([+-]?\\d*[\\.,]?\\d*)"; // Float value
QString re5 = "([a-zA-Z]*)"; // SI unit
+ const QString text = conv_threshold_cb_->currentText();
+#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
+ QRegularExpression regex(re1 + re2 + re3 + re4 + re5);
+
+ if (!regex.match(text).hasMatch())
+ return; // String doesn't match the regex
+
+ QStringList tokens = regex.match(text).capturedTexts();
+#else
QRegExp regex(re1 + re2 + re3 + re4 + re5);
- const QString text = conv_threshold_cb_->currentText();
if (!regex.exactMatch(text))
return; // String doesn't match the regex
QStringList tokens = regex.capturedTexts();
+#endif
// For now, we simply assume that the unit is volt without modifiers
const double low_thr = tokens.at(1).toDouble();
void AnalogSignal::on_display_type_changed(int index)
{
+ const bool prev_showing_logic = (display_type_ == DisplayConverted) || (display_type_ == DisplayBoth);
+
display_type_ = (DisplayType)(display_type_cb_->itemData(index).toInt());
+ const bool showing_logic = (display_type_ == DisplayConverted) || (display_type_ == DisplayBoth);
+
+ // If we show a logic trace, make sure we have at least one div for each
+ // polarity as that's where we paint it
+ if (showing_logic && !prev_showing_logic) {
+ if (pos_vdivs_ == 0)
+ on_pos_vdivs_changed(1);
+ if (neg_vdivs_ == 0)
+ on_neg_vdivs_changed(1);
+ }
+
if (owner_)
owner_->row_item_appearance_changed(false, true);
}