X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fviews%2Ftrace%2Fanalogsignal.cpp;h=e26b203a2d197aa1161c3d63752ebf0ea3dcdfc9;hb=cbb50547a69f8a10dd05e8cf8d03fdd679e4442f;hp=c52379534166e1b6bfd37ab35271b99a3241c912;hpb=1573bf16ba50d1c023ad3a9ce596f0ab6eaeacff;p=pulseview.git diff --git a/pv/views/trace/analogsignal.cpp b/pv/views/trace/analogsignal.cpp index c523795..e26b203 100644 --- a/pv/views/trace/analogsignal.cpp +++ b/pv/views/trace/analogsignal.cpp @@ -89,7 +89,6 @@ AnalogSignal::AnalogSignal( Signal(session, base), scale_index_(4), // 20 per div scale_index_drag_offset_(0), - div_height_(3 * QFontMetrics(QApplication::font()).height()), pos_vdivs_(1), neg_vdivs_(1), resolution_(0), @@ -103,6 +102,9 @@ AnalogSignal::AnalogSignal( connect(analog_data, SIGNAL(samples_added(QObject*, uint64_t, uint64_t)), this, SLOT(on_samples_added())); + GlobalSettings gs; + div_height_ = gs.value(GlobalSettings::Key_View_DefaultDivHeight).toInt(); + base_->set_colour(SignalColours[base_->index() % countof(SignalColours)]); update_scale(); } @@ -120,6 +122,7 @@ void AnalogSignal::save_settings(QSettings &settings) const settings.setValue("conversion_type", conversion_type_); settings.setValue("display_type", display_type_); settings.setValue("autoranging", autoranging_); + settings.setValue("div_height", div_height_); } void AnalogSignal::restore_settings(QSettings &settings) @@ -145,6 +148,17 @@ void AnalogSignal::restore_settings(QSettings &settings) if (settings.contains("autoranging")) autoranging_ = settings.value("autoranging").toBool(); + + if (settings.contains("div_height")) { + const int old_height = div_height_; + div_height_ = settings.value("div_height").toInt(); + + if ((div_height_ != old_height) && 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); + } + } } pair AnalogSignal::v_extents() const @@ -341,16 +355,16 @@ void AnalogSignal::paint_trace(QPainter &p, int64_t sample_count = min(points_count, TracePaintBlockSize); int64_t block_sample = 0; - const float *sample_block = segment->get_samples(start, start + sample_count); + float *sample_block = new float[TracePaintBlockSize]; + segment->get_samples(start, start + sample_count, sample_block); const int w = 2; for (int64_t sample = start; sample != end; sample++, block_sample++) { if (block_sample == TracePaintBlockSize) { block_sample = 0; - delete[] sample_block; sample_count = min(points_count - sample, TracePaintBlockSize); - sample_block = segment->get_samples(sample, sample + sample_count); + segment->get_samples(sample, sample + sample_count, sample_block); } const float x = (sample / samples_per_pixel - @@ -665,7 +679,7 @@ void AnalogSignal::populate_popup_form(QWidget *parent, QFormLayout *form) QFormLayout *const layout = new QFormLayout; - // Add the number of vdivs + // Add div-related settings pvdiv_sb_ = new QSpinBox(parent); pvdiv_sb_->setRange(0, MaximumVDivs); pvdiv_sb_->setValue(pos_vdivs_); @@ -680,6 +694,15 @@ void AnalogSignal::populate_popup_form(QWidget *parent, QFormLayout *form) this, SLOT(on_neg_vdivs_changed(int))); layout->addRow(tr("Number of neg vertical divs"), nvdiv_sb_); + div_height_sb_ = new QSpinBox(parent); + div_height_sb_->setRange(20, 1000); + div_height_sb_->setSingleStep(5); + div_height_sb_->setSuffix(tr(" pixels")); + div_height_sb_->setValue(div_height_); + connect(div_height_sb_, SIGNAL(valueChanged(int)), + this, SLOT(on_div_height_changed(int))); + layout->addRow(tr("Div height"), div_height_sb_); + // Add the vertical resolution resolution_cb_ = new QComboBox(parent); @@ -720,7 +743,7 @@ void AnalogSignal::populate_popup_form(QWidget *parent, QFormLayout *form) cur_idx = conversion_cb_->findData(QVariant(conversion_type_)); conversion_cb_->setCurrentIndex(cur_idx); -// layout->addRow(tr("Conversion"), conversion_cb_); + layout->addRow(tr("Conversion"), conversion_cb_); connect(conversion_cb_, SIGNAL(currentIndexChanged(int)), this, SLOT(on_conversion_changed(int))); @@ -735,7 +758,7 @@ void AnalogSignal::populate_popup_form(QWidget *parent, QFormLayout *form) cur_idx = display_type_cb_->findData(QVariant(display_type_)); display_type_cb_->setCurrentIndex(cur_idx); -// layout->addRow(tr("Traces to show:"), display_type_cb_); + layout->addRow(tr("Traces to show:"), display_type_cb_); connect(display_type_cb_, SIGNAL(currentIndexChanged(int)), this, SLOT(on_display_type_changed(int))); @@ -810,6 +833,18 @@ void AnalogSignal::on_neg_vdivs_changed(int vdivs) } } +void AnalogSignal::on_div_height_changed(int height) +{ + div_height_ = height; + update_scale(); + + 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_resolution_changed(int index) { scale_index_ = resolution_cb_->itemData(index).toInt();