]> sigrok.org Git - pulseview.git/commitdiff
DecodeSignal: Use better colors and names for decoder output signals
authorSoeren Apel <redacted>
Wed, 25 Mar 2020 21:08:46 +0000 (22:08 +0100)
committerSoeren Apel <redacted>
Sat, 13 Feb 2021 21:37:41 +0000 (22:37 +0100)
pv/data/decodesignal.cpp
pv/data/decodesignal.hpp
pv/data/signalbase.hpp

index 24059f9e3af0d83bfa53f08e5bba7f92e5477ce0..4be9fb2fef1f733dfe7fc6307549c86dd691d88f 100644 (file)
@@ -68,6 +68,20 @@ DecodeSignal::~DecodeSignal()
        reset_decode(true);
 }
 
+void DecodeSignal::set_name(QString name)
+{
+       SignalBase::set_name(name);
+
+       update_output_signals();
+}
+
+void DecodeSignal::set_color(QColor color)
+{
+       SignalBase::set_color(color);
+
+       update_output_signals();
+}
+
 const vector< shared_ptr<Decoder> >& DecodeSignal::decoder_stack() const
 {
        return stack_;
@@ -397,7 +411,6 @@ void DecodeSignal::update_output_signals()
                                        shared_ptr<data::SignalBase> signal =
                                                make_shared<data::SignalBase>(nullptr, LogicChannel);
                                        signal->set_internal_name(logic_ch.id);
-                                       signal->set_name(logic_ch.id);
                                        signal->set_index(index);
                                        signal->set_data(logic_data);
                                        output_signals_.push_back(signal);
@@ -413,9 +426,12 @@ void DecodeSignal::update_output_signals()
                }
        }
 
-       // TODO Delete signals that no longer have a corresponding decoder (also from session)
+       for (shared_ptr<SignalBase> s : output_signals_) {
+               s->set_name(s->internal_name() + " (" + name() + ")");
+               s->set_color(color());
+       }
+
        // TODO Assert that all sample rates are the same as the session's
-       // TODO Set colors to the same as the decoder's background color
 }
 
 void DecodeSignal::set_initial_pin_state(const uint16_t channel_id, const int init_state)
index f02f0921eba142809a2e096794c0f8128af3ed44..333e953b2d63e66c415b403092ad48cc2975b0f5 100644 (file)
@@ -103,6 +103,16 @@ public:
        DecodeSignal(pv::Session &session);
        virtual ~DecodeSignal();
 
+       /**
+        * Sets the name of the signal.
+        */
+       virtual void set_name(QString name);
+
+       /**
+        * Set the color of the signal.
+        */
+       virtual void set_color(QColor color);
+
        bool is_decode_signal() const;
        const vector< shared_ptr<Decoder> >& decoder_stack() const;
 
index c3d0bed11a6e9863305f7cef9f54b866c4cb55a7..19f8143dc77e3499a92ecb0d17fb07fe411605be 100644 (file)
@@ -219,7 +219,7 @@ public:
        /**
         * Set the color of the signal.
         */
-       void set_color(QColor color);
+       virtual void set_color(QColor color);
 
        /**
         * Get the background color of the signal.