]> sigrok.org Git - pulseview.git/blobdiff - pv/view/signal.cpp
Implement "use coloured background" functionality
[pulseview.git] / pv / view / signal.cpp
index ecf74f08c0fc8528c94b099de5e280902891f2b6..09a6da8f17a3d7b9b2377cfa0dc1a251e454edde 100644 (file)
@@ -21,7 +21,7 @@
 #include <extdef.h>
 
 #include <assert.h>
-#include <math.h>
+#include <cmath>
 
 #include <QApplication>
 #include <QFormLayout>
 #include <QLineEdit>
 #include <QMenu>
 
-#include <libsigrok/libsigrok.hpp>
+#include <libsigrokcxx/libsigrokcxx.hpp>
 
 #include "signal.hpp"
 #include "view.hpp"
 
 using std::shared_ptr;
+using std::make_shared;
 
 using sigrok::Channel;
 
@@ -47,8 +48,8 @@ const char *const ChannelNames[] = {
        "IN",
        "OUT",
        "RST",
-       "Tx",
-       "Rx",
+       "TX",
+       "RX",
        "EN",
        "SCLK",
        "MOSI",
@@ -60,10 +61,12 @@ const char *const ChannelNames[] = {
 
 Signal::Signal(pv::Session &session,
        std::shared_ptr<sigrok::Channel> channel) :
-       Trace(channel->name().c_str()),
+       Trace(QString::fromUtf8(channel->name().c_str())),
        session_(session),
        channel_(channel),
-       name_widget_(NULL),
+       scale_handle_(make_shared<SignalScaleHandle>(*this)),
+       items_({scale_handle_}),
+       name_widget_(nullptr),
        updating_name_widget_(false)
 {
        assert(channel_);
@@ -78,7 +81,7 @@ void Signal::set_name(QString name)
 
        // Store the channel name in sigrok::Channel so that it
        // will end up in the .sr file upon save.
-       channel_->set_name(name.toStdString());
+       channel_->set_name(name.toUtf8().constData());
 }
 
 bool Signal::enabled() const
@@ -99,17 +102,27 @@ shared_ptr<Channel> Signal::channel() const
        return channel_;
 }
 
-void Signal::populate_popup_form(QWidget *parent, QFormLayout *form)
+const ViewItemOwner::item_list& Signal::child_items() const
 {
-       int index;
+       return items_;
+}
 
+void Signal::paint_back(QPainter &p, const ViewItemPaintParams &pp)
+{
+       if (channel_->enabled())
+               Trace::paint_back(p, pp);
+}
+
+void Signal::populate_popup_form(QWidget *parent, QFormLayout *form)
+{
        name_widget_ = new QComboBox(parent);
        name_widget_->setEditable(true);
+       name_widget_->setCompleter(0);
 
-       for(unsigned int i = 0; i < countof(ChannelNames); i++)
+       for (unsigned int i = 0; i < countof(ChannelNames); i++)
                name_widget_->insertItem(i, ChannelNames[i]);
 
-       index = name_widget_->findText(name_, Qt::MatchExactly);
+       const int index = name_widget_->findText(name_, Qt::MatchExactly);
 
        if (index == -1) {
                name_widget_->insertItem(0, name_);