2 * This file is part of the PulseView project.
4 * Copyright (C) 2017 Soeren Apel <soeren@apelpie.net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 #include "logicsegment.hpp"
22 #include "decodesignal.hpp"
23 #include "signaldata.hpp"
25 #include <pv/binding/decoder.hpp>
26 #include <pv/data/decode/decoder.hpp>
27 #include <pv/data/decoderstack.hpp>
28 #include <pv/session.hpp>
30 using std::make_shared;
31 using std::shared_ptr;
32 using pv::data::decode::Decoder;
37 DecodeSignal::DecodeSignal(shared_ptr<pv::data::DecoderStack> decoder_stack) :
38 SignalBase(nullptr, SignalBase::DecodeChannel),
39 decoder_stack_(decoder_stack)
41 set_name(QString::fromUtf8(decoder_stack_->stack().front()->decoder()->name));
43 connect(decoder_stack_.get(), SIGNAL(new_annotations()),
44 this, SLOT(on_new_annotations()));
47 DecodeSignal::~DecodeSignal()
51 bool DecodeSignal::is_decode_signal() const
56 shared_ptr<pv::data::DecoderStack> DecodeSignal::decoder_stack() const
58 return decoder_stack_;
61 void DecodeSignal::stack_decoder(srd_decoder *decoder)
64 assert(decoder_stack);
65 decoder_stack_->push(make_shared<data::decode::Decoder>(decoder));
66 decoder_stack_->begin_decode();
69 void DecodeSignal::remove_decoder(int index)
71 decoder_stack_->remove(index);
72 decoder_stack_->begin_decode();
75 bool DecodeSignal::toggle_decoder_visibility(int index)
77 const list< shared_ptr<Decoder> > stack(decoder_stack_->stack());
79 auto iter = stack.cbegin();
80 for (int i = 0; i < index; i++, iter++)
81 assert(iter != stack.end());
83 shared_ptr<Decoder> dec = *iter;
85 // Toggle decoder visibility
88 state = !dec->shown();
95 void DecodeSignal::on_new_annotations()
97 // Forward the signal to the frontend