]> sigrok.org Git - pulseview.git/commitdiff
AnalogSignal: Use Q_OBJECT and implement vdiv selector in dialog
authorSoeren Apel <redacted>
Thu, 7 Apr 2016 20:03:17 +0000 (22:03 +0200)
committerSoeren Apel <redacted>
Thu, 7 Apr 2016 20:03:17 +0000 (22:03 +0200)
CMakeLists.txt
pv/view/analogsignal.cpp
pv/view/analogsignal.hpp

index 55274e8cb34c7b7555edc7ffecb03e33d2b9c32f..a3b41205e2d447fc20a7527479b655bb3ad983af 100644 (file)
@@ -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
index b92792d7f6e630f431f8c14430a20bcec89ea3f5..1b4e32080e6107ea41041e37795333489d589fa5 100644 (file)
@@ -26,6 +26,8 @@
 #include <limits>
 
 #include <QApplication>
+#include <QFormLayout>
+#include <QSpinBox>
 
 #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> 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
index 7fdddf2d16880678f222c845fd306b2ee4ce4e31..07de4eb436541cbc281a22d3df85dbcf7e84fa4a 100644 (file)
@@ -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<sigrok::Channel> 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<pv::data::Analog> data_;