From: Soeren Apel Date: Thu, 7 Apr 2016 20:03:17 +0000 (+0200) Subject: AnalogSignal: Use Q_OBJECT and implement vdiv selector in dialog X-Git-Tag: pulseview-0.4.0~316 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4cffac16f3fb0ced3450c7df9c02b2d35bcd01e1;p=pulseview.git AnalogSignal: Use Q_OBJECT and implement vdiv selector in dialog --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 55274e8c..a3b41205 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -244,6 +244,7 @@ set(pulseview_HEADERS pv/prop/property.hpp pv/prop/string.hpp pv/toolbars/mainbar.hpp + pv/view/analogsignal.hpp pv/view/cursor.hpp pv/view/flag.hpp pv/view/header.hpp diff --git a/pv/view/analogsignal.cpp b/pv/view/analogsignal.cpp index b92792d7..1b4e3208 100644 --- a/pv/view/analogsignal.cpp +++ b/pv/view/analogsignal.cpp @@ -26,6 +26,8 @@ #include #include +#include +#include #include "analogsignal.hpp" #include "pv/data/analog.hpp" @@ -57,6 +59,8 @@ const QColor AnalogSignal::GridMinorColor = QColor(0xD0, 0xD0, 0xD0); const float AnalogSignal::EnvelopeThreshold = 256.0f; +const int AnalogSignal::MaximumVDivs = 10; + AnalogSignal::AnalogSignal( pv::Session &session, shared_ptr channel, @@ -274,5 +278,28 @@ void AnalogSignal::update_scale() scale_ = div_height_ / resolution_; } +void AnalogSignal::populate_popup_form(QWidget *parent, QFormLayout *form) +{ + // Add the standard options + Signal::populate_popup_form(parent, form); + + // Add the vdiv settings + QSpinBox *vdiv_sb = new QSpinBox(parent); + vdiv_sb->setRange(1, MaximumVDivs); + vdiv_sb->setValue(vdivs_); + connect(vdiv_sb, SIGNAL(valueChanged(int)), + this, SLOT(on_vdivs_changed(int))); + form->addRow(tr("Number of vertical divs"), vdiv_sb); +} + +void AnalogSignal::on_vdivs_changed(int vdivs) +{ + vdivs_ = vdivs; + + if (owner_) + owner_->extents_changed(false, true); +} + + } // namespace view } // namespace pv diff --git a/pv/view/analogsignal.hpp b/pv/view/analogsignal.hpp index 7fdddf2d..07de4eb4 100644 --- a/pv/view/analogsignal.hpp +++ b/pv/view/analogsignal.hpp @@ -36,12 +36,16 @@ namespace view { class AnalogSignal : public Signal { + Q_OBJECT + private: static const QColor SignalColours[4]; static const QColor GridMajorColor, GridMinorColor; static const float EnvelopeThreshold; + static const int MaximumVDivs; + public: AnalogSignal(pv::Session &session, std::shared_ptr channel, @@ -107,6 +111,12 @@ private: */ void update_scale(); +protected: + void populate_popup_form(QWidget *parent, QFormLayout *form); + +private Q_SLOTS: + void on_vdivs_changed(int vdivs); + private: std::shared_ptr data_;