From: Soeren Apel Date: Wed, 25 Mar 2020 21:08:46 +0000 (+0100) Subject: DecodeSignal: Use better colors and names for decoder output signals X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=cb6305433dd64ff19f0a3d102f91e0f8f8b64da4;p=pulseview.git DecodeSignal: Use better colors and names for decoder output signals --- diff --git a/pv/data/decodesignal.cpp b/pv/data/decodesignal.cpp index 24059f9e..4be9fb2f 100644 --- a/pv/data/decodesignal.cpp +++ b/pv/data/decodesignal.cpp @@ -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 >& DecodeSignal::decoder_stack() const { return stack_; @@ -397,7 +411,6 @@ void DecodeSignal::update_output_signals() shared_ptr signal = make_shared(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 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) diff --git a/pv/data/decodesignal.hpp b/pv/data/decodesignal.hpp index f02f0921..333e953b 100644 --- a/pv/data/decodesignal.hpp +++ b/pv/data/decodesignal.hpp @@ -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_stack() const; diff --git a/pv/data/signalbase.hpp b/pv/data/signalbase.hpp index c3d0bed1..19f8143d 100644 --- a/pv/data/signalbase.hpp +++ b/pv/data/signalbase.hpp @@ -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.