This change is made because tokens prefixed with underscore are reserved.
void Analog::push_snapshot(shared_ptr<AnalogSnapshot> &snapshot)
{
- _snapshots.push_front(snapshot);
+ snapshots_.push_front(snapshot);
}
deque< shared_ptr<AnalogSnapshot> >& Analog::get_snapshots()
{
- return _snapshots;
+ return snapshots_;
}
void Analog::clear()
{
- _snapshots.clear();
+ snapshots_.clear();
}
uint64_t Analog::get_max_sample_count() const
{
uint64_t l = 0;
- for (const std::shared_ptr<AnalogSnapshot> s : _snapshots) {
+ for (const std::shared_ptr<AnalogSnapshot> s : snapshots_) {
assert(s);
l = max(l, s->get_sample_count());
}
uint64_t get_max_sample_count() const;
private:
- std::deque< std::shared_ptr<AnalogSnapshot> > _snapshots;
+ std::deque< std::shared_ptr<AnalogSnapshot> > snapshots_;
};
} // namespace data
{
set_capacity(expected_num_samples);
- lock_guard<recursive_mutex> lock(_mutex);
- memset(_envelope_levels, 0, sizeof(_envelope_levels));
+ lock_guard<recursive_mutex> lock(mutex_);
+ memset(envelope_levels_, 0, sizeof(envelope_levels_));
}
AnalogSnapshot::~AnalogSnapshot()
{
- lock_guard<recursive_mutex> lock(_mutex);
- for (Envelope &e : _envelope_levels)
+ lock_guard<recursive_mutex> lock(mutex_);
+ for (Envelope &e : envelope_levels_)
free(e.samples);
}
void AnalogSnapshot::append_interleaved_samples(const float *data,
size_t sample_count, size_t stride)
{
- assert(_unit_size == sizeof(float));
+ assert(unit_size_ == sizeof(float));
- lock_guard<recursive_mutex> lock(_mutex);
+ lock_guard<recursive_mutex> lock(mutex_);
- _data.resize((_sample_count + sample_count) * sizeof(float));
+ data_.resize((sample_count_ + sample_count) * sizeof(float));
- float *dst = (float*)_data.data() + _sample_count;
+ float *dst = (float*)data_.data() + sample_count_;
const float *dst_end = dst + sample_count;
while (dst != dst_end)
{
data += stride;
}
- _sample_count += sample_count;
+ sample_count_ += sample_count;
// Generate the first mip-map from the data
append_payload_to_envelope_levels();
int64_t start_sample, int64_t end_sample) const
{
assert(start_sample >= 0);
- assert(start_sample < (int64_t)_sample_count);
+ assert(start_sample < (int64_t)sample_count_);
assert(end_sample >= 0);
- assert(end_sample < (int64_t)_sample_count);
+ assert(end_sample < (int64_t)sample_count_);
assert(start_sample <= end_sample);
- lock_guard<recursive_mutex> lock(_mutex);
+ lock_guard<recursive_mutex> lock(mutex_);
float *const data = new float[end_sample - start_sample];
- memcpy(data, (float*)_data.data() + start_sample, sizeof(float) *
+ memcpy(data, (float*)data_.data() + start_sample, sizeof(float) *
(end_sample - start_sample));
return data;
}
assert(start <= end);
assert(min_length > 0);
- lock_guard<recursive_mutex> lock(_mutex);
+ lock_guard<recursive_mutex> lock(mutex_);
const unsigned int min_level = max((int)floorf(logf(min_length) /
LogEnvelopeScaleFactor) - 1, 0);
s.scale = 1 << scale_power;
s.length = end - start;
s.samples = new EnvelopeSample[s.length];
- memcpy(s.samples, _envelope_levels[min_level].samples + start,
+ memcpy(s.samples, envelope_levels_[min_level].samples + start,
s.length * sizeof(EnvelopeSample));
}
void AnalogSnapshot::append_payload_to_envelope_levels()
{
- Envelope &e0 = _envelope_levels[0];
+ Envelope &e0 = envelope_levels_[0];
uint64_t prev_length;
EnvelopeSample *dest_ptr;
// Expand the data buffer to fit the new samples
prev_length = e0.length;
- e0.length = _sample_count / EnvelopeScaleFactor;
+ e0.length = sample_count_ / EnvelopeScaleFactor;
// Break off if there are no new samples to compute
if (e0.length == prev_length)
dest_ptr = e0.samples + prev_length;
// Iterate through the samples to populate the first level mipmap
- const float *const end_src_ptr = (float*)_data.data() +
+ const float *const end_src_ptr = (float*)data_.data() +
e0.length * EnvelopeScaleFactor;
- for (const float *src_ptr = (float*)_data.data() +
+ for (const float *src_ptr = (float*)data_.data() +
prev_length * EnvelopeScaleFactor;
src_ptr < end_src_ptr; src_ptr += EnvelopeScaleFactor)
{
// Compute higher level mipmaps
for (unsigned int level = 1; level < ScaleStepCount; level++)
{
- Envelope &e = _envelope_levels[level];
- const Envelope &el = _envelope_levels[level-1];
+ Envelope &e = envelope_levels_[level];
+ const Envelope &el = envelope_levels_[level-1];
// Expand the data buffer to fit the new samples
prev_length = e.length;
void append_payload_to_envelope_levels();
private:
- struct Envelope _envelope_levels[ScaleStepCount];
+ struct Envelope envelope_levels_[ScaleStepCount];
friend struct AnalogSnapshotTest::Basic;
};
namespace decode {
Annotation::Annotation(const srd_proto_data *const pdata) :
- _start_sample(pdata->start_sample),
- _end_sample(pdata->end_sample)
+ start_sample_(pdata->start_sample),
+ end_sample_(pdata->end_sample)
{
assert(pdata);
const srd_proto_data_annotation *const pda =
(const srd_proto_data_annotation*)pdata->data;
assert(pda);
- _format = pda->ann_class;
+ format_ = pda->ann_class;
const char *const *annotations = (char**)pda->ann_text;
while(*annotations) {
- _annotations.push_back(QString::fromUtf8(*annotations));
+ annotations_.push_back(QString::fromUtf8(*annotations));
annotations++;
}
}
uint64_t Annotation::start_sample() const
{
- return _start_sample;
+ return start_sample_;
}
uint64_t Annotation::end_sample() const
{
- return _end_sample;
+ return end_sample_;
}
int Annotation::format() const
{
- return _format;
+ return format_;
}
const std::vector<QString>& Annotation::annotations() const
{
- return _annotations;
+ return annotations_;
}
} // namespace decode
const std::vector<QString>& annotations() const;
private:
- uint64_t _start_sample;
- uint64_t _end_sample;
- int _format;
- std::vector<QString> _annotations;
+ uint64_t start_sample_;
+ uint64_t end_sample_;
+ int format_;
+ std::vector<QString> annotations_;
};
} // namespace decode
namespace decode {
Decoder::Decoder(const srd_decoder *const dec) :
- _decoder(dec),
- _shown(true)
+ decoder_(dec),
+ shown_(true)
{
}
Decoder::~Decoder()
{
- for (auto i = _options.begin(); i != _options.end(); i++)
+ for (auto i = options_.begin(); i != options_.end(); i++)
g_variant_unref((*i).second);
}
const srd_decoder* Decoder::decoder() const
{
- return _decoder;
+ return decoder_;
}
bool Decoder::shown() const
{
- return _shown;
+ return shown_;
}
void Decoder::show(bool show)
{
- _shown = show;
+ shown_ = show;
}
const map<const srd_channel*, shared_ptr<view::LogicSignal> >&
Decoder::channels() const
{
- return _channels;
+ return channels_;
}
void Decoder::set_channels(std::map<const srd_channel*,
std::shared_ptr<view::LogicSignal> > channels)
{
- _channels = channels;
+ channels_ = channels;
}
const std::map<std::string, GVariant*>& Decoder::options() const
{
- return _options;
+ return options_;
}
void Decoder::set_option(const char *id, GVariant *value)
{
assert(value);
g_variant_ref(value);
- _options[id] = value;
+ options_[id] = value;
}
bool Decoder::have_required_channels() const
{
- for (GSList *l = _decoder->channels; l; l = l->next) {
+ for (GSList *l = decoder_->channels; l; l = l->next) {
const srd_channel *const pdch = (const srd_channel*)l->data;
assert(pdch);
- if (_channels.find(pdch) == _channels.end())
+ if (channels_.find(pdch) == channels_.end())
return false;
}
set< shared_ptr<pv::data::Logic> > Decoder::get_data()
{
set< shared_ptr<pv::data::Logic> > data;
- for(auto i = _channels.cbegin(); i != _channels.cend(); i++) {
+ for(auto i = channels_.cbegin(); i != channels_.cend(); i++) {
shared_ptr<view::LogicSignal> signal((*i).second);
assert(signal);
data.insert(signal->logic_data());
GHashTable *const opt_hash = g_hash_table_new_full(g_str_hash,
g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
- for (auto i = _options.cbegin(); i != _options.cend(); i++)
+ for (auto i = options_.cbegin(); i != options_.cend(); i++)
{
GVariant *const value = (*i).second;
g_variant_ref(value);
}
srd_decoder_inst *const decoder_inst = srd_inst_new(
- session, _decoder->id, opt_hash);
+ session, decoder_->id, opt_hash);
g_hash_table_destroy(opt_hash);
if(!decoder_inst)
GHashTable *const channels = g_hash_table_new_full(g_str_hash,
g_str_equal, g_free, (GDestroyNotify)g_variant_unref);
- for(auto i = _channels.cbegin(); i != _channels.cend(); i++)
+ for(auto i = channels_.cbegin(); i != channels_.cend(); i++)
{
shared_ptr<view::LogicSignal> signal((*i).second);
GVariant *const gvar = g_variant_new_int32(
std::set< std::shared_ptr<pv::data::Logic> > get_data();
private:
- const srd_decoder *const _decoder;
+ const srd_decoder *const decoder_;
- bool _shown;
+ bool shown_;
std::map<const srd_channel*, std::shared_ptr<pv::view::LogicSignal> >
- _channels;
- std::map<std::string, GVariant*> _options;
+ channels_;
+ std::map<std::string, GVariant*> options_;
};
} // namespace decode
namespace decode {
Row::Row() :
- _decoder(NULL),
- _row(NULL)
+ decoder_(NULL),
+ row_(NULL)
{
}
Row::Row(const srd_decoder *decoder, const srd_decoder_annotation_row *row) :
- _decoder(decoder),
- _row(row)
+ decoder_(decoder),
+ row_(row)
{
}
const srd_decoder* Row::decoder() const
{
- return _decoder;
+ return decoder_;
}
const srd_decoder_annotation_row* Row::row() const
{
- return _row;
+ return row_;
}
const QString Row::title() const
{
- if (_decoder && _decoder->name && _row && _row->desc)
+ if (decoder_ && decoder_->name && row_ && row_->desc)
return QString("%1: %2")
- .arg(QString::fromUtf8(_decoder->name))
- .arg(QString::fromUtf8(_row->desc));
- if (_decoder && _decoder->name)
- return QString::fromUtf8(_decoder->name);
- if (_row && _row->desc)
- return QString::fromUtf8(_row->desc);
+ .arg(QString::fromUtf8(decoder_->name))
+ .arg(QString::fromUtf8(row_->desc));
+ if (decoder_ && decoder_->name)
+ return QString::fromUtf8(decoder_->name);
+ if (row_ && row_->desc)
+ return QString::fromUtf8(row_->desc);
return QString();
}
bool Row::operator<(const Row &other) const
{
- return (_decoder < other._decoder) ||
- (_decoder == other._decoder && _row < other._row);
+ return (decoder_ < other.decoder_) ||
+ (decoder_ == other.decoder_ && row_ < other.row_);
}
} // decode
bool operator<(const Row &other) const;
private:
- const srd_decoder *_decoder;
- const srd_decoder_annotation_row *_row;
+ const srd_decoder *decoder_;
+ const srd_decoder_annotation_row *row_;
};
} // decode
uint64_t RowData::get_max_sample() const
{
- if (_annotations.empty())
+ if (annotations_.empty())
return 0;
- return _annotations.back().end_sample();
+ return annotations_.back().end_sample();
}
void RowData::get_annotation_subset(
vector<pv::data::decode::Annotation> &dest,
uint64_t start_sample, uint64_t end_sample) const
{
- for (auto i = _annotations.cbegin(); i != _annotations.cend(); i++)
+ for (auto i = annotations_.cbegin(); i != annotations_.cend(); i++)
if ((*i).end_sample() > start_sample &&
(*i).start_sample() <= end_sample)
dest.push_back(*i);
void RowData::push_annotation(const Annotation &a)
{
- _annotations.push_back(a);
+ annotations_.push_back(a);
}
} // decode
void push_annotation(const Annotation &a);
private:
- std::vector<Annotation> _annotations;
+ std::vector<Annotation> annotations_;
};
}
const int64_t DecoderStack::DecodeChunkLength = 4096;
const unsigned int DecoderStack::DecodeNotifyPeriod = 65536;
-mutex DecoderStack::_global_decode_mutex;
+mutex DecoderStack::global_decode_mutex_;
DecoderStack::DecoderStack(pv::SigSession &session,
const srd_decoder *const dec) :
- _session(session),
- _sample_count(0),
- _frame_complete(false),
- _samples_decoded(0)
+ session_(session),
+ sample_count_(0),
+ frame_complete_(false),
+ samples_decoded_(0)
{
- connect(&_session, SIGNAL(frame_began()),
+ connect(&session_, SIGNAL(frame_began()),
this, SLOT(on_new_frame()));
- connect(&_session, SIGNAL(data_received()),
+ connect(&session_, SIGNAL(data_received()),
this, SLOT(on_data_received()));
- connect(&_session, SIGNAL(frame_ended()),
+ connect(&session_, SIGNAL(frame_ended()),
this, SLOT(on_frame_ended()));
- _stack.push_back(shared_ptr<decode::Decoder>(
+ stack_.push_back(shared_ptr<decode::Decoder>(
new decode::Decoder(dec)));
}
DecoderStack::~DecoderStack()
{
- if (_decode_thread.joinable()) {
- _interrupt = true;
- _input_cond.notify_one();
- _decode_thread.join();
+ if (decode_thread_.joinable()) {
+ interrupt_ = true;
+ input_cond_.notify_one();
+ decode_thread_.join();
}
}
const std::list< std::shared_ptr<decode::Decoder> >&
DecoderStack::stack() const
{
- return _stack;
+ return stack_;
}
void DecoderStack::push(std::shared_ptr<decode::Decoder> decoder)
{
assert(decoder);
- _stack.push_back(decoder);
+ stack_.push_back(decoder);
}
void DecoderStack::remove(int index)
{
assert(index >= 0);
- assert(index < (int)_stack.size());
+ assert(index < (int)stack_.size());
// Find the decoder in the stack
- auto iter = _stack.begin();
+ auto iter = stack_.begin();
for(int i = 0; i < index; i++, iter++)
- assert(iter != _stack.end());
+ assert(iter != stack_.end());
// Delete the element
- _stack.erase(iter);
+ stack_.erase(iter);
}
int64_t DecoderStack::samples_decoded() const
{
- lock_guard<mutex> decode_lock(_output_mutex);
- return _samples_decoded;
+ lock_guard<mutex> decode_lock(output_mutex_);
+ return samples_decoded_;
}
std::vector<Row> DecoderStack::get_visible_rows() const
{
- lock_guard<mutex> lock(_output_mutex);
+ lock_guard<mutex> lock(output_mutex_);
vector<Row> rows;
- for (const shared_ptr<decode::Decoder> &dec : _stack)
+ for (const shared_ptr<decode::Decoder> &dec : stack_)
{
assert(dec);
if (!dec->shown())
const Row &row, uint64_t start_sample,
uint64_t end_sample) const
{
- lock_guard<mutex> lock(_output_mutex);
+ lock_guard<mutex> lock(output_mutex_);
- const auto iter = _rows.find(row);
- if (iter != _rows.end())
+ const auto iter = rows_.find(row);
+ if (iter != rows_.end())
(*iter).second.get_annotation_subset(dest,
start_sample, end_sample);
}
QString DecoderStack::error_message()
{
- lock_guard<mutex> lock(_output_mutex);
- return _error_message;
+ lock_guard<mutex> lock(output_mutex_);
+ return error_message_;
}
void DecoderStack::clear()
{
- _sample_count = 0;
- _frame_complete = false;
- _samples_decoded = 0;
- _error_message = QString();
- _rows.clear();
- _class_rows.clear();
+ sample_count_ = 0;
+ frame_complete_ = false;
+ samples_decoded_ = 0;
+ error_message_ = QString();
+ rows_.clear();
+ class_rows_.clear();
}
void DecoderStack::begin_decode()
shared_ptr<pv::view::LogicSignal> logic_signal;
shared_ptr<pv::data::Logic> data;
- if (_decode_thread.joinable()) {
- _interrupt = true;
- _input_cond.notify_one();
- _decode_thread.join();
+ if (decode_thread_.joinable()) {
+ interrupt_ = true;
+ input_cond_.notify_one();
+ decode_thread_.join();
}
clear();
// Check that all decoders have the required channels
- for (const shared_ptr<decode::Decoder> &dec : _stack)
+ for (const shared_ptr<decode::Decoder> &dec : stack_)
if (!dec->have_required_channels()) {
- _error_message = tr("One or more required channels "
+ error_message_ = tr("One or more required channels "
"have not been specified");
return;
}
// Add classes
- for (const shared_ptr<decode::Decoder> &dec : _stack)
+ for (const shared_ptr<decode::Decoder> &dec : stack_)
{
assert(dec);
const srd_decoder *const decc = dec->decoder();
// Add a row for the decoder if it doesn't have a row list
if (!decc->annotation_rows)
- _rows[Row(decc)] = decode::RowData();
+ rows_[Row(decc)] = decode::RowData();
// Add the decoder rows
for (const GSList *l = decc->annotation_rows; l; l = l->next)
const Row row(decc, ann_row);
// Add a new empty row data object
- _rows[row] = decode::RowData();
+ rows_[row] = decode::RowData();
// Map out all the classes
for (const GSList *ll = ann_row->ann_classes;
ll; ll = ll->next)
- _class_rows[make_pair(decc,
+ class_rows_[make_pair(decc,
GPOINTER_TO_INT(ll->data))] = row;
}
}
// We get the logic data of the first channel in the list.
// This works because we are currently assuming all
// LogicSignals have the same data/snapshot
- for (const shared_ptr<decode::Decoder> &dec : _stack)
+ for (const shared_ptr<decode::Decoder> &dec : stack_)
if (dec && !dec->channels().empty() &&
((logic_signal = (*dec->channels().begin()).second)) &&
((data = logic_signal->logic_data())))
data->get_snapshots();
if (snapshots.empty())
return;
- _snapshot = snapshots.front();
+ snapshot_ = snapshots.front();
// Get the samplerate and start time
- _start_time = data->get_start_time();
- _samplerate = data->samplerate();
- if (_samplerate == 0.0)
- _samplerate = 1.0;
+ start_time_ = data->get_start_time();
+ samplerate_ = data->samplerate();
+ if (samplerate_ == 0.0)
+ samplerate_ = 1.0;
- _interrupt = false;
- _decode_thread = std::thread(&DecoderStack::decode_proc, this);
+ interrupt_ = false;
+ decode_thread_ = std::thread(&DecoderStack::decode_proc, this);
}
uint64_t DecoderStack::get_max_sample_count() const
{
uint64_t max_sample_count = 0;
- for (auto i = _rows.cbegin(); i != _rows.end(); i++)
+ for (auto i = rows_.cbegin(); i != rows_.end(); i++)
max_sample_count = max(max_sample_count,
(*i).second.get_max_sample());
optional<int64_t> DecoderStack::wait_for_data() const
{
- unique_lock<mutex> input_lock(_input_mutex);
- while(!_interrupt && !_frame_complete &&
- _samples_decoded >= _sample_count)
- _input_cond.wait(input_lock);
- return boost::make_optional(!_interrupt &&
- (_samples_decoded < _sample_count || !_frame_complete),
- _sample_count);
+ unique_lock<mutex> input_lock(input_mutex_);
+ while(!interrupt_ && !frame_complete_ &&
+ samples_decoded_ >= sample_count_)
+ input_cond_.wait(input_lock);
+ return boost::make_optional(!interrupt_ &&
+ (samples_decoded_ < sample_count_ || !frame_complete_),
+ sample_count_);
}
void DecoderStack::decode_data(
uint8_t chunk[DecodeChunkLength];
const unsigned int chunk_sample_count =
- DecodeChunkLength / _snapshot->unit_size();
+ DecodeChunkLength / snapshot_->unit_size();
- for (int64_t i = 0; !_interrupt && i < sample_count;
+ for (int64_t i = 0; !interrupt_ && i < sample_count;
i += chunk_sample_count)
{
- lock_guard<mutex> decode_lock(_global_decode_mutex);
+ lock_guard<mutex> decode_lock(global_decode_mutex_);
const int64_t chunk_end = min(
i + chunk_sample_count, sample_count);
- _snapshot->get_samples(chunk, i, chunk_end);
+ snapshot_->get_samples(chunk, i, chunk_end);
if (srd_session_send(session, i, i + sample_count, chunk,
(chunk_end - i) * unit_size) != SRD_OK) {
- _error_message = tr("Decoder reported an error");
+ error_message_ = tr("Decoder reported an error");
break;
}
{
- lock_guard<mutex> lock(_output_mutex);
- _samples_decoded = chunk_end;
+ lock_guard<mutex> lock(output_mutex_);
+ samples_decoded_ = chunk_end;
}
if (i % DecodeNotifyPeriod == 0)
srd_session *session;
srd_decoder_inst *prev_di = NULL;
- assert(_snapshot);
+ assert(snapshot_);
// Create the session
srd_session_new(&session);
assert(session);
// Create the decoders
- const unsigned int unit_size = _snapshot->unit_size();
+ const unsigned int unit_size = snapshot_->unit_size();
- for (const shared_ptr<decode::Decoder> &dec : _stack)
+ for (const shared_ptr<decode::Decoder> &dec : stack_)
{
srd_decoder_inst *const di = dec->create_decoder_inst(session, unit_size);
if (!di)
{
- _error_message = tr("Failed to create decoder instance");
+ error_message_ = tr("Failed to create decoder instance");
srd_session_destroy(session);
return;
}
// Get the intial sample count
{
- unique_lock<mutex> input_lock(_input_mutex);
- sample_count = _sample_count = _snapshot->get_sample_count();
+ unique_lock<mutex> input_lock(input_mutex_);
+ sample_count = sample_count_ = snapshot_->get_sample_count();
}
// Start the session
srd_session_metadata_set(session, SRD_CONF_SAMPLERATE,
- g_variant_new_uint64((uint64_t)_samplerate));
+ g_variant_new_uint64((uint64_t)samplerate_));
srd_pd_output_callback_add(session, SRD_OUTPUT_ANN,
DecoderStack::annotation_callback, this);
do {
decode_data(*sample_count, unit_size, session);
- } while(_error_message.isEmpty() && (sample_count = wait_for_data()));
+ } while(error_message_.isEmpty() && (sample_count = wait_for_data()));
// Destroy the session
srd_session_destroy(session);
DecoderStack *const d = (DecoderStack*)decoder;
assert(d);
- lock_guard<mutex> lock(d->_output_mutex);
+ lock_guard<mutex> lock(d->output_mutex_);
const Annotation a(pdata);
const srd_decoder *const decc = pdata->pdo->di->decoder;
assert(decc);
- auto row_iter = d->_rows.end();
+ auto row_iter = d->rows_.end();
// Try looking up the sub-row of this class
- const auto r = d->_class_rows.find(make_pair(decc, a.format()));
- if (r != d->_class_rows.end())
- row_iter = d->_rows.find((*r).second);
+ const auto r = d->class_rows_.find(make_pair(decc, a.format()));
+ if (r != d->class_rows_.end())
+ row_iter = d->rows_.find((*r).second);
else
{
// Failing that, use the decoder as a key
- row_iter = d->_rows.find(Row(decc));
+ row_iter = d->rows_.find(Row(decc));
}
- assert(row_iter != d->_rows.end());
- if (row_iter == d->_rows.end()) {
+ assert(row_iter != d->rows_.end());
+ if (row_iter == d->rows_.end()) {
qDebug() << "Unexpected annotation: decoder = " << decc <<
", format = " << a.format();
assert(0);
void DecoderStack::on_data_received()
{
{
- unique_lock<mutex> lock(_input_mutex);
- if (_snapshot)
- _sample_count = _snapshot->get_sample_count();
+ unique_lock<mutex> lock(input_mutex_);
+ if (snapshot_)
+ sample_count_ = snapshot_->get_sample_count();
}
- _input_cond.notify_one();
+ input_cond_.notify_one();
}
void DecoderStack::on_frame_ended()
{
{
- unique_lock<mutex> lock(_input_mutex);
- if (_snapshot)
- _frame_complete = true;
+ unique_lock<mutex> lock(input_mutex_);
+ if (snapshot_)
+ frame_complete_ = true;
}
- _input_cond.notify_one();
+ input_cond_.notify_one();
}
} // namespace data
static const unsigned int DecodeNotifyPeriod;
public:
- DecoderStack(pv::SigSession &_session,
+ DecoderStack(pv::SigSession &session_,
const srd_decoder *const decoder);
virtual ~DecoderStack();
void new_decode_data();
private:
- pv::SigSession &_session;
+ pv::SigSession &session_;
/**
* This mutex prevents more than one decode operation occuring
* @todo A proper solution should be implemented to allow multiple
* decode operations.
*/
- static std::mutex _global_decode_mutex;
+ static std::mutex global_decode_mutex_;
- std::list< std::shared_ptr<decode::Decoder> > _stack;
+ std::list< std::shared_ptr<decode::Decoder> > stack_;
- std::shared_ptr<pv::data::LogicSnapshot> _snapshot;
+ std::shared_ptr<pv::data::LogicSnapshot> snapshot_;
- mutable std::mutex _input_mutex;
- mutable std::condition_variable _input_cond;
- int64_t _sample_count;
- bool _frame_complete;
+ mutable std::mutex input_mutex_;
+ mutable std::condition_variable input_cond_;
+ int64_t sample_count_;
+ bool frame_complete_;
- mutable std::mutex _output_mutex;
- int64_t _samples_decoded;
+ mutable std::mutex output_mutex_;
+ int64_t samples_decoded_;
- std::map<const decode::Row, decode::RowData> _rows;
+ std::map<const decode::Row, decode::RowData> rows_;
- std::map<std::pair<const srd_decoder*, int>, decode::Row> _class_rows;
+ std::map<std::pair<const srd_decoder*, int>, decode::Row> class_rows_;
- QString _error_message;
+ QString error_message_;
- std::thread _decode_thread;
- std::atomic<bool> _interrupt;
+ std::thread decode_thread_;
+ std::atomic<bool> interrupt_;
friend struct DecoderStackTest::TwoDecoderStack;
};
Logic::Logic(unsigned int num_channels) :
SignalData(),
- _num_channels(num_channels)
+ num_channels_(num_channels)
{
- assert(_num_channels > 0);
+ assert(num_channels_ > 0);
}
int Logic::get_num_channels() const
{
- return _num_channels;
+ return num_channels_;
}
void Logic::push_snapshot(
shared_ptr<LogicSnapshot> &snapshot)
{
- _snapshots.push_front(snapshot);
+ snapshots_.push_front(snapshot);
}
deque< shared_ptr<LogicSnapshot> >& Logic::get_snapshots()
{
- return _snapshots;
+ return snapshots_;
}
void Logic::clear()
{
- _snapshots.clear();
+ snapshots_.clear();
}
uint64_t Logic::get_max_sample_count() const
{
uint64_t l = 0;
- for (std::shared_ptr<LogicSnapshot> s : _snapshots) {
+ for (std::shared_ptr<LogicSnapshot> s : snapshots_) {
assert(s);
l = max(l, s->get_sample_count());
}
uint64_t get_max_sample_count() const;
private:
- const unsigned int _num_channels;
- std::deque< std::shared_ptr<LogicSnapshot> > _snapshots;
+ const unsigned int num_channels_;
+ std::deque< std::shared_ptr<LogicSnapshot> > snapshots_;
};
} // namespace data
LogicSnapshot::LogicSnapshot(shared_ptr<Logic> logic,
const uint64_t expected_num_samples) :
Snapshot(logic->unit_size()),
- _last_append_sample(0)
+ last_append_sample_(0)
{
set_capacity(expected_num_samples);
- lock_guard<recursive_mutex> lock(_mutex);
- memset(_mip_map, 0, sizeof(_mip_map));
+ lock_guard<recursive_mutex> lock(mutex_);
+ memset(mip_map_, 0, sizeof(mip_map_));
append_payload(logic);
}
LogicSnapshot::~LogicSnapshot()
{
- lock_guard<recursive_mutex> lock(_mutex);
- for (MipMapLevel &l : _mip_map)
+ lock_guard<recursive_mutex> lock(mutex_);
+ for (MipMapLevel &l : mip_map_)
free(l.data);
}
return *(uint64_t*)ptr;
#else
uint64_t value = 0;
- switch(_unit_size) {
+ switch(unit_size_) {
default:
value |= ((uint64_t)ptr[7]) << 56;
/* FALLTHRU */
#ifdef HAVE_UNALIGNED_LITTLE_ENDIAN_ACCESS
*(uint64_t*)ptr = value;
#else
- switch(_unit_size) {
+ switch(unit_size_) {
default:
ptr[7] = value >> 56;
/* FALLTHRU */
void LogicSnapshot::append_payload(shared_ptr<Logic> logic)
{
- assert(_unit_size == logic->unit_size());
- assert((logic->data_length() % _unit_size) == 0);
+ assert(unit_size_ == logic->unit_size());
+ assert((logic->data_length() % unit_size_) == 0);
- lock_guard<recursive_mutex> lock(_mutex);
+ lock_guard<recursive_mutex> lock(mutex_);
append_data(logic->data_pointer(),
- logic->data_length() / _unit_size);
+ logic->data_length() / unit_size_);
// Generate the first mip-map from the data
append_payload_to_mipmap();
{
assert(data);
assert(start_sample >= 0);
- assert(start_sample <= (int64_t)_sample_count);
+ assert(start_sample <= (int64_t)sample_count_);
assert(end_sample >= 0);
- assert(end_sample <= (int64_t)_sample_count);
+ assert(end_sample <= (int64_t)sample_count_);
assert(start_sample <= end_sample);
- lock_guard<recursive_mutex> lock(_mutex);
+ lock_guard<recursive_mutex> lock(mutex_);
- const size_t size = (end_sample - start_sample) * _unit_size;
- memcpy(data, (const uint8_t*)_data.data() + start_sample * _unit_size, size);
+ const size_t size = (end_sample - start_sample) * unit_size_;
+ memcpy(data, (const uint8_t*)data_.data() + start_sample * unit_size_, size);
}
void LogicSnapshot::reallocate_mipmap_level(MipMapLevel &m)
m.data_length = new_data_length;
// Padding is added to allow for the uint64_t write word
- m.data = realloc(m.data, new_data_length * _unit_size +
+ m.data = realloc(m.data, new_data_length * unit_size_ +
sizeof(uint64_t));
}
}
void LogicSnapshot::append_payload_to_mipmap()
{
- MipMapLevel &m0 = _mip_map[0];
+ MipMapLevel &m0 = mip_map_[0];
uint64_t prev_length;
const uint8_t *src_ptr;
uint8_t *dest_ptr;
// Expand the data buffer to fit the new samples
prev_length = m0.length;
- m0.length = _sample_count / MipMapScaleFactor;
+ m0.length = sample_count_ / MipMapScaleFactor;
// Break off if there are no new samples to compute
if (m0.length == prev_length)
reallocate_mipmap_level(m0);
- dest_ptr = (uint8_t*)m0.data + prev_length * _unit_size;
+ dest_ptr = (uint8_t*)m0.data + prev_length * unit_size_;
// Iterate through the samples to populate the first level mipmap
- const uint8_t *const end_src_ptr = (uint8_t*)_data.data() +
- m0.length * _unit_size * MipMapScaleFactor;
- for (src_ptr = (uint8_t*)_data.data() +
- prev_length * _unit_size * MipMapScaleFactor;
+ const uint8_t *const end_src_ptr = (uint8_t*)data_.data() +
+ m0.length * unit_size_ * MipMapScaleFactor;
+ for (src_ptr = (uint8_t*)data_.data() +
+ prev_length * unit_size_ * MipMapScaleFactor;
src_ptr < end_src_ptr;)
{
// Accumulate transitions which have occurred in this sample
while (diff_counter-- > 0)
{
const uint64_t sample = unpack_sample(src_ptr);
- accumulator |= _last_append_sample ^ sample;
- _last_append_sample = sample;
- src_ptr += _unit_size;
+ accumulator |= last_append_sample_ ^ sample;
+ last_append_sample_ = sample;
+ src_ptr += unit_size_;
}
pack_sample(dest_ptr, accumulator);
- dest_ptr += _unit_size;
+ dest_ptr += unit_size_;
}
// Compute higher level mipmaps
for (unsigned int level = 1; level < ScaleStepCount; level++)
{
- MipMapLevel &m = _mip_map[level];
- const MipMapLevel &ml = _mip_map[level-1];
+ MipMapLevel &m = mip_map_[level];
+ const MipMapLevel &ml = mip_map_[level-1];
// Expand the data buffer to fit the new samples
prev_length = m.length;
// Subsample the level lower level
src_ptr = (uint8_t*)ml.data +
- _unit_size * prev_length * MipMapScaleFactor;
+ unit_size_ * prev_length * MipMapScaleFactor;
const uint8_t *const end_dest_ptr =
- (uint8_t*)m.data + _unit_size * m.length;
+ (uint8_t*)m.data + unit_size_ * m.length;
for (dest_ptr = (uint8_t*)m.data +
- _unit_size * prev_length;
+ unit_size_ * prev_length;
dest_ptr < end_dest_ptr;
- dest_ptr += _unit_size)
+ dest_ptr += unit_size_)
{
accumulator = 0;
diff_counter = MipMapScaleFactor;
while (diff_counter-- > 0)
{
accumulator |= unpack_sample(src_ptr);
- src_ptr += _unit_size;
+ src_ptr += unit_size_;
}
pack_sample(dest_ptr, accumulator);
uint64_t LogicSnapshot::get_sample(uint64_t index) const
{
- assert(index < _sample_count);
+ assert(index < sample_count_);
- return unpack_sample((uint8_t*)_data.data() + index * _unit_size);
+ return unpack_sample((uint8_t*)data_.data() + index * unit_size_);
}
void LogicSnapshot::get_subsampled_edges(
assert(sig_index >= 0);
assert(sig_index < 64);
- lock_guard<recursive_mutex> lock(_mutex);
+ lock_guard<recursive_mutex> lock(mutex_);
const uint64_t block_length = (uint64_t)max(min_length, 1.0f);
const unsigned int min_level = max((int)floorf(logf(min_length) /
// We cannot fast-forward if there is no mip-map data at
// at the minimum level.
- fast_forward = (_mip_map[level].data != NULL);
+ fast_forward = (mip_map_[level].data != NULL);
if (min_length < MipMapScaleFactor)
{
// Check if we reached the last block at this
// level, or if there was a change in this block
- if (offset >= _mip_map[level].length ||
+ if (offset >= mip_map_[level].length ||
(get_subsample(level, offset) &
sig_mask))
break;
// higher level mip-map block ascend one
// level
if (level + 1 >= ScaleStepCount ||
- !_mip_map[level + 1].data)
+ !mip_map_[level + 1].data)
break;
level++;
// Zoom in, and slide right until we encounter a change,
// and repeat until we reach min_level
while (1) {
- assert(_mip_map[level].data);
+ assert(mip_map_[level].data);
const int level_scale_power =
(level + 1) * MipMapScalePower;
// Check if we reached the last block at this
// level, or if there was a change in this block
- if (offset >= _mip_map[level].length ||
+ if (offset >= mip_map_[level].length ||
(get_subsample(level, offset) &
sig_mask)) {
// Zoom in unless we reached the minimum
uint64_t LogicSnapshot::get_subsample(int level, uint64_t offset) const
{
assert(level >= 0);
- assert(_mip_map[level].data);
- return unpack_sample((uint8_t*)_mip_map[level].data +
- _unit_size * offset);
+ assert(mip_map_[level].data);
+ return unpack_sample((uint8_t*)mip_map_[level].data +
+ unit_size_ * offset);
}
uint64_t LogicSnapshot::pow2_ceil(uint64_t x, unsigned int power)
static uint64_t pow2_ceil(uint64_t x, unsigned int power);
private:
- struct MipMapLevel _mip_map[ScaleStepCount];
- uint64_t _last_append_sample;
+ struct MipMapLevel mip_map_[ScaleStepCount];
+ uint64_t last_append_sample_;
friend struct LogicSnapshotTest::Pow2;
friend struct LogicSnapshotTest::Basic;
namespace data {
SignalData::SignalData() :
- _start_time(0),
- _samplerate(0)
+ start_time_(0),
+ samplerate_(0)
{
}
double SignalData::samplerate() const
{
- return _samplerate;
+ return samplerate_;
}
void SignalData::set_samplerate(double samplerate)
{
- _samplerate = samplerate;
+ samplerate_ = samplerate;
clear();
}
double SignalData::get_start_time() const
{
- return _start_time;
+ return start_time_;
}
} // namespace data
virtual uint64_t get_max_sample_count() const = 0;
protected:
- double _start_time;
- double _samplerate;
+ double start_time_;
+ double samplerate_;
};
} // namespace data
namespace data {
Snapshot::Snapshot(unsigned int unit_size) :
- _sample_count(0),
- _capacity(0),
- _unit_size(unit_size)
+ sample_count_(0),
+ capacity_(0),
+ unit_size_(unit_size)
{
- lock_guard<recursive_mutex> lock(_mutex);
- assert(_unit_size > 0);
+ lock_guard<recursive_mutex> lock(mutex_);
+ assert(unit_size_ > 0);
}
Snapshot::~Snapshot()
{
- lock_guard<recursive_mutex> lock(_mutex);
+ lock_guard<recursive_mutex> lock(mutex_);
}
uint64_t Snapshot::get_sample_count() const
{
- lock_guard<recursive_mutex> lock(_mutex);
- return _sample_count;
+ lock_guard<recursive_mutex> lock(mutex_);
+ return sample_count_;
}
unsigned int Snapshot::unit_size() const
{
- return _unit_size;
+ return unit_size_;
}
void Snapshot::set_capacity(const uint64_t new_capacity)
{
- lock_guard<recursive_mutex> lock(_mutex);
+ lock_guard<recursive_mutex> lock(mutex_);
- assert(_capacity >= _sample_count);
- if (new_capacity > _capacity) {
- _capacity = new_capacity;
- _data.resize((new_capacity * _unit_size) + sizeof(uint64_t));
+ assert(capacity_ >= sample_count_);
+ if (new_capacity > capacity_) {
+ capacity_ = new_capacity;
+ data_.resize((new_capacity * unit_size_) + sizeof(uint64_t));
}
}
uint64_t Snapshot::capacity() const
{
- lock_guard<recursive_mutex> lock(_mutex);
- return _data.size();
+ lock_guard<recursive_mutex> lock(mutex_);
+ return data_.size();
}
void Snapshot::append_data(void *data, uint64_t samples)
{
- lock_guard<recursive_mutex> lock(_mutex);
+ lock_guard<recursive_mutex> lock(mutex_);
- assert(_capacity >= _sample_count);
+ assert(capacity_ >= sample_count_);
// Ensure there's enough capacity to copy.
- const uint64_t free_space = _capacity - _sample_count;
+ const uint64_t free_space = capacity_ - sample_count_;
if (free_space < samples) {
- set_capacity(_sample_count + samples);
+ set_capacity(sample_count_ + samples);
}
- memcpy((uint8_t*)_data.data() + _sample_count * _unit_size,
- data, samples * _unit_size);
- _sample_count += samples;
+ memcpy((uint8_t*)data_.data() + sample_count_ * unit_size_,
+ data, samples * unit_size_);
+ sample_count_ += samples;
}
} // namespace data
void append_data(void *data, uint64_t samples);
protected:
- mutable std::recursive_mutex _mutex;
- std::vector<uint8_t> _data;
- uint64_t _sample_count;
- uint64_t _capacity;
- unsigned int _unit_size;
+ mutable std::recursive_mutex mutex_;
+ std::vector<uint8_t> data_;
+ uint64_t sample_count_;
+ uint64_t capacity_;
+ unsigned int unit_size_;
};
} // namespace data
namespace pv {
DeviceManager::DeviceManager(shared_ptr<Context> context) :
- _context(context)
+ context_(context)
{
for (auto entry : context->drivers())
driver_scan(entry.second, map<const ConfigKey *, VariantBase>());
shared_ptr<Context> DeviceManager::context()
{
- return _context;
+ return context_;
}
const list< shared_ptr<HardwareDevice> >& DeviceManager::devices() const
{
- return _devices;
+ return devices_;
}
list< shared_ptr<HardwareDevice> > DeviceManager::driver_scan(
// Remove any device instances from this driver from the device
// list. They will not be valid after the scan.
- _devices.remove_if([&](shared_ptr<HardwareDevice> device) {
+ devices_.remove_if([&](shared_ptr<HardwareDevice> device) {
return device->driver() == driver; });
// Do the scan
driver_devices.insert(driver_devices.end(), devices.begin(), devices.end());
// Add the scanned devices to the main list, set display names and sort.
- _devices.insert(_devices.end(), driver_devices.begin(),
+ devices_.insert(devices_.end(), driver_devices.begin(),
driver_devices.end());
- for (shared_ptr<Device> device : _devices)
- _display_names[device] = build_display_name(device);
+ for (shared_ptr<Device> device : devices_)
+ display_names_[device] = build_display_name(device);
- _devices.sort([&](shared_ptr<Device> a, shared_ptr<Device> b)
+ devices_.sort([&](shared_ptr<Device> a, shared_ptr<Device> b)
{ return compare_devices(a, b); });
- // As the display names depend on the complete _devices list,
+ // As the display names depend on the complete devices_ list,
// we need to recompute them. However, there is no need to
- // recomute all names of the _devices list since only the
+ // recomute all names of the devices_ list since only the
// devices that use the given driver can be affected.
for (shared_ptr<Device> device : driver_devices)
- _display_names[device] = build_display_name(device);
+ display_names_[device] = build_display_name(device);
driver_devices.sort([&](shared_ptr<Device> a, shared_ptr<Device> b)
{ return compare_devices(a, b); });
last_resort_dev = NULL;
- for (shared_ptr<HardwareDevice> dev : _devices) {
+ for (shared_ptr<HardwareDevice> dev : devices_) {
assert(dev);
dev_info = get_device_info(dev);
// If we can find another device with the same model/vendor then
// we have at least two such devices and need to distinguish them.
if (hardware_device)
- multiple_dev = any_of(_devices.begin(), _devices.end(),
+ multiple_dev = any_of(devices_.begin(), devices_.end(),
[&](shared_ptr<HardwareDevice> dev) {
return (dev->vendor() == hardware_device->vendor() &&
dev->model() == hardware_device->model()) &&
const std::string DeviceManager::get_display_name(std::shared_ptr<sigrok::Device> dev)
{
- return _display_names[dev];
+ return display_names_[dev];
}
void DeviceManager::update_display_name(std::shared_ptr<sigrok::Device> dev)
{
- _display_names[dev] = build_display_name(dev);
+ display_names_[dev] = build_display_name(dev);
}
bool DeviceManager::compare_devices(shared_ptr<Device> a,
assert(a);
assert(b);
- return _display_names[a].compare(_display_names[b]) < 0;
+ return display_names_[a].compare(display_names_[b]) < 0;
}
} // namespace pv
std::shared_ptr<sigrok::Device> b);
protected:
- std::shared_ptr<sigrok::Context> _context;
- std::list< std::shared_ptr<sigrok::HardwareDevice> > _devices;
- std::map< std::shared_ptr<sigrok::Device>, std::string > _display_names;
+ std::shared_ptr<sigrok::Context> context_;
+ std::list< std::shared_ptr<sigrok::HardwareDevice> > devices_;
+ std::map< std::shared_ptr<sigrok::Device>, std::string > display_names_;
};
} // namespace pv
Connect::Connect(QWidget *parent, pv::DeviceManager &device_manager) :
QDialog(parent),
- _device_manager(device_manager),
- _layout(this),
- _form(this),
- _form_layout(&_form),
- _drivers(&_form),
- _serial_device(&_form),
- _scan_button(tr("Scan for Devices"), this),
- _device_list(this),
- _button_box(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
+ device_manager_(device_manager),
+ layout_(this),
+ form_(this),
+ form_layout_(&form_),
+ drivers_(&form_),
+ serial_device_(&form_),
+ scan_button_(tr("Scan for Devices"), this),
+ device_list_(this),
+ button_box_(QDialogButtonBox::Ok | QDialogButtonBox::Cancel,
Qt::Horizontal, this)
{
setWindowTitle(tr("Connect to Device"));
- connect(&_button_box, SIGNAL(accepted()), this, SLOT(accept()));
- connect(&_button_box, SIGNAL(rejected()), this, SLOT(reject()));
+ connect(&button_box_, SIGNAL(accepted()), this, SLOT(accept()));
+ connect(&button_box_, SIGNAL(rejected()), this, SLOT(reject()));
populate_drivers();
- connect(&_drivers, SIGNAL(activated(int)),
+ connect(&drivers_, SIGNAL(activated(int)),
this, SLOT(device_selected(int)));
- _form.setLayout(&_form_layout);
- _form_layout.addRow(tr("Driver"), &_drivers);
+ form_.setLayout(&form_layout_);
+ form_layout_.addRow(tr("Driver"), &drivers_);
- _form_layout.addRow(tr("Serial Port"), &_serial_device);
+ form_layout_.addRow(tr("Serial Port"), &serial_device_);
unset_connection();
- connect(&_scan_button, SIGNAL(pressed()),
+ connect(&scan_button_, SIGNAL(pressed()),
this, SLOT(scan_pressed()));
- setLayout(&_layout);
- _layout.addWidget(&_form);
- _layout.addWidget(&_scan_button);
- _layout.addWidget(&_device_list);
- _layout.addWidget(&_button_box);
+ setLayout(&layout_);
+ layout_.addWidget(&form_);
+ layout_.addWidget(&scan_button_);
+ layout_.addWidget(&device_list_);
+ layout_.addWidget(&button_box_);
}
shared_ptr<HardwareDevice> Connect::get_selected_device() const
{
- const QListWidgetItem *const item = _device_list.currentItem();
+ const QListWidgetItem *const item = device_list_.currentItem();
if (!item)
return shared_ptr<HardwareDevice>();
void Connect::populate_drivers()
{
- for (auto entry : _device_manager.context()->drivers()) {
+ for (auto entry : device_manager_.context()->drivers()) {
auto name = entry.first;
auto driver = entry.second;
/**
ConfigKey::SAMPLERATE, ConfigKey::DEVICE_OPTIONS);
if (supported_device)
- _drivers.addItem(QString("%1 (%2)").arg(
+ drivers_.addItem(QString("%1 (%2)").arg(
driver->long_name().c_str()).arg(name.c_str()),
qVariantFromValue(driver));
}
void Connect::unset_connection()
{
- _device_list.clear();
- _serial_device.hide();
- _form_layout.labelForField(&_serial_device)->hide();
- _button_box.button(QDialogButtonBox::Ok)->setDisabled(true);
+ device_list_.clear();
+ serial_device_.hide();
+ form_layout_.labelForField(&serial_device_)->hide();
+ button_box_.button(QDialogButtonBox::Ok)->setDisabled(true);
}
void Connect::set_serial_connection()
{
- _serial_device.show();
- _form_layout.labelForField(&_serial_device)->show();
+ serial_device_.show();
+ form_layout_.labelForField(&serial_device_)->show();
}
void Connect::scan_pressed()
{
- _device_list.clear();
+ device_list_.clear();
- const int index = _drivers.currentIndex();
+ const int index = drivers_.currentIndex();
if (index == -1)
return;
shared_ptr<Driver> driver =
- _drivers.itemData(index).value<shared_ptr<Driver>>();
+ drivers_.itemData(index).value<shared_ptr<Driver>>();
assert(driver);
map<const ConfigKey *, VariantBase> drvopts;
- if (_serial_device.isVisible())
+ if (serial_device_.isVisible())
drvopts[ConfigKey::CONN] = Variant<ustring>::create(
- _serial_device.text().toUtf8().constData());
+ serial_device_.text().toUtf8().constData());
list< shared_ptr<HardwareDevice> > devices =
- _device_manager.driver_scan(driver, drvopts);
+ device_manager_.driver_scan(driver, drvopts);
for (shared_ptr<HardwareDevice> device : devices)
{
assert(device);
QString text = QString::fromStdString(
- _device_manager.get_display_name(device));
+ device_manager_.get_display_name(device));
text += QString(" with %1 channels").arg(device->channels().size());
QListWidgetItem *const item = new QListWidgetItem(text,
- &_device_list);
+ &device_list_);
item->setData(Qt::UserRole, qVariantFromValue(device));
- _device_list.addItem(item);
+ device_list_.addItem(item);
}
- _device_list.setCurrentRow(0);
- _button_box.button(QDialogButtonBox::Ok)->setDisabled(_device_list.count() == 0);
+ device_list_.setCurrentRow(0);
+ button_box_.button(QDialogButtonBox::Ok)->setDisabled(device_list_.count() == 0);
}
void Connect::device_selected(int index)
{
shared_ptr<Driver> driver =
- _drivers.itemData(index).value<shared_ptr<Driver>>();
+ drivers_.itemData(index).value<shared_ptr<Driver>>();
unset_connection();
void scan_pressed();
private:
- pv::DeviceManager &_device_manager;
+ pv::DeviceManager &device_manager_;
- QVBoxLayout _layout;
+ QVBoxLayout layout_;
- QWidget _form;
- QFormLayout _form_layout;
+ QWidget form_;
+ QFormLayout form_layout_;
- QComboBox _drivers;
+ QComboBox drivers_;
- QLineEdit _serial_device;
+ QLineEdit serial_device_;
- QPushButton _scan_button;
- QListWidget _device_list;
+ QPushButton scan_button_;
+ QListWidget device_list_;
- QDialogButtonBox _button_box;
+ QDialogButtonBox button_box_;
};
} // namespace dialogs
StoreProgress::StoreProgress(const QString &file_name,
const SigSession &session, QWidget *parent) :
QProgressDialog(tr("Saving..."), tr("Cancel"), 0, 0, parent),
- _session(file_name.toStdString(), session)
+ session_(file_name.toStdString(), session)
{
- connect(&_session, SIGNAL(progress_updated()),
+ connect(&session_, SIGNAL(progress_updated()),
this, SLOT(on_progress_updated()));
}
StoreProgress::~StoreProgress()
{
- _session.wait();
+ session_.wait();
}
void StoreProgress::run()
{
- if (_session.start())
+ if (session_.start())
show();
else
show_error();
{
QMessageBox msg(parentWidget());
msg.setText(tr("Failed to save session."));
- msg.setInformativeText(_session.error());
+ msg.setInformativeText(session_.error());
msg.setStandardButtons(QMessageBox::Ok);
msg.setIcon(QMessageBox::Warning);
msg.exec();
void StoreProgress::closeEvent(QCloseEvent*)
{
- _session.cancel();
+ session_.cancel();
}
void StoreProgress::on_progress_updated()
{
- const std::pair<int, int> p = _session.progress();
+ const std::pair<int, int> p = session_.progress();
assert(p.first <= p.second);
if (p.second) {
setValue(p.first);
setMaximum(p.second);
} else {
- const QString err = _session.error();
+ const QString err = session_.error();
if (!err.isEmpty())
show_error();
close();
void on_progress_updated();
private:
- pv::StoreSession _session;
+ pv::StoreSession session_;
};
} // dialogs
const char *open_file_name,
QWidget *parent) :
QMainWindow(parent),
- _device_manager(device_manager),
- _session(device_manager)
+ device_manager_(device_manager),
+ session_(device_manager)
{
setup_ui();
restore_ui_settings();
setWindowIcon(icon);
// Setup the central widget
- _central_widget = new QWidget(this);
- _vertical_layout = new QVBoxLayout(_central_widget);
- _vertical_layout->setSpacing(6);
- _vertical_layout->setContentsMargins(0, 0, 0, 0);
- setCentralWidget(_central_widget);
+ central_widget_ = new QWidget(this);
+ vertical_layout_ = new QVBoxLayout(central_widget_);
+ vertical_layout_->setSpacing(6);
+ vertical_layout_->setContentsMargins(0, 0, 0, 0);
+ setCentralWidget(central_widget_);
- _view = new pv::view::View(_session, this);
+ view_ = new pv::view::View(session_, this);
- _vertical_layout->addWidget(_view);
+ vertical_layout_->addWidget(view_);
// Setup the menu bar
QMenuBar *const menu_bar = new QMenuBar(this);
QAction *action_view_show_cursors = new QAction(this);
action_view_show_cursors->setCheckable(true);
- action_view_show_cursors->setChecked(_view->cursors_shown());
+ action_view_show_cursors->setChecked(view_->cursors_shown());
action_view_show_cursors->setShortcut(QKeySequence(Qt::Key_C));
action_view_show_cursors->setObjectName(
QString::fromUtf8("actionViewShowCursors"));
addToolBar(toolbar);
// Setup the sampling bar
- _sampling_bar = new toolbars::SamplingBar(_session, this);
+ sampling_bar_ = new toolbars::SamplingBar(session_, this);
// Populate the device list and select the initially selected device
update_device_list();
- connect(_sampling_bar, SIGNAL(run_stop()), this,
+ connect(sampling_bar_, SIGNAL(run_stop()), this,
SLOT(run_stop()));
- addToolBar(_sampling_bar);
+ addToolBar(sampling_bar_);
// Set the title
setWindowTitle(tr("PulseView"));
- // Setup _session events
- connect(&_session, SIGNAL(capture_state_changed(int)), this,
+ // Setup session_ events
+ connect(&session_, SIGNAL(capture_state_changed(int)), this,
SLOT(capture_state_changed(int)));
}
settings.setValue("geometry", saveGeometry());
settings.endGroup();
- if (_session.device()) {
+ if (session_.device()) {
settings.beginGroup("Device");
key_list.push_back("vendor");
key_list.push_back("model");
key_list.push_back("serial_num");
key_list.push_back("connection_id");
- dev_info = _device_manager.get_device_info(
- _session.device());
+ dev_info = device_manager_.get_device_info(
+ session_.device());
for (string key : key_list) {
dev_info.insert(std::make_pair(key, value));
}
- device = _device_manager.find_device_from_info(dev_info);
+ device = device_manager_.find_device_from_info(dev_info);
if (device) {
- _session.set_device(device);
+ session_.set_device(device);
update_device_list();
}
void MainWindow::update_device_list()
{
- assert(_sampling_bar);
+ assert(sampling_bar_);
- shared_ptr<Device> selected_device = _session.device();
+ shared_ptr<Device> selected_device = session_.device();
list< shared_ptr<Device> > devices;
- if (_device_manager.devices().size() == 0)
+ if (device_manager_.devices().size() == 0)
return;
- std::copy(_device_manager.devices().begin(),
- _device_manager.devices().end(), std::back_inserter(devices));
+ std::copy(device_manager_.devices().begin(),
+ device_manager_.devices().end(), std::back_inserter(devices));
if (std::find(devices.begin(), devices.end(), selected_device) ==
devices.end())
for (auto device : devices)
device_list.push_back(make_pair(
- device, _device_manager.get_display_name(device)));
+ device, device_manager_.get_display_name(device)));
- _sampling_bar->set_device_list(device_list, selected_device);
+ sampling_bar_->set_device_list(device_list, selected_device);
}
void MainWindow::closeEvent(QCloseEvent *event)
const QString infoMessage;
try {
- _session.set_file(file_name.toStdString());
+ session_.set_file(file_name.toStdString());
} catch(Error e) {
show_session_error(tr("Failed to load ") + file_name, e.what());
- _session.set_default_device();
+ session_.set_default_device();
update_device_list();
return;
}
update_device_list();
- _session.start_capture([&, errorMessage, infoMessage](QString) {
+ session_.start_capture([&, errorMessage, infoMessage](QString) {
session_error(errorMessage, infoMessage); });
}
using pv::dialogs::StoreProgress;
// Stop any currently running capture session
- _session.stop_capture();
+ session_.stop_capture();
QSettings settings;
const QString dir = settings.value(SettingSaveDirectory).toString();
const QString abs_path = QFileInfo(file_name).absolutePath();
settings.setValue(SettingSaveDirectory, abs_path);
- StoreProgress *dlg = new StoreProgress(file_name, _session, this);
+ StoreProgress *dlg = new StoreProgress(file_name, session_, this);
dlg->run();
}
void MainWindow::on_actionConnect_triggered()
{
// Stop any currently running capture session
- _session.stop_capture();
+ session_.stop_capture();
- dialogs::Connect dlg(this, _device_manager);
+ dialogs::Connect dlg(this, device_manager_);
// If the user selected a device, select it in the device list. Select the
// current device otherwise.
if (dlg.exec())
- _session.set_device(dlg.get_selected_device());
+ session_.set_device(dlg.get_selected_device());
update_device_list();
}
void MainWindow::on_actionViewZoomIn_triggered()
{
- _view->zoom(1);
+ view_->zoom(1);
}
void MainWindow::on_actionViewZoomOut_triggered()
{
- _view->zoom(-1);
+ view_->zoom(-1);
}
void MainWindow::on_actionViewZoomFit_triggered()
{
- _view->zoom_fit();
+ view_->zoom_fit();
}
void MainWindow::on_actionViewZoomOneToOne_triggered()
{
- _view->zoom_one_to_one();
+ view_->zoom_one_to_one();
}
void MainWindow::on_actionViewShowCursors_triggered()
{
- assert(_view);
+ assert(view_);
- const bool show = !_view->cursors_shown();
+ const bool show = !view_->cursors_shown();
if(show)
- _view->centre_cursors();
+ view_->centre_cursors();
- _view->show_cursors(show);
+ view_->show_cursors(show);
}
void MainWindow::on_actionAbout_triggered()
{
- dialogs::About dlg(_device_manager.context(), this);
+ dialogs::About dlg(device_manager_.context(), this);
dlg.exec();
}
{
#ifdef ENABLE_DECODE
assert(decoder);
- _session.add_decoder(decoder);
+ session_.add_decoder(decoder);
#else
(void)decoder;
#endif
void MainWindow::run_stop()
{
- switch(_session.get_capture_state()) {
+ switch(session_.get_capture_state()) {
case SigSession::Stopped:
- _session.start_capture([&](QString message) {
+ session_.start_capture([&](QString message) {
session_error("Capture failed", message); });
break;
case SigSession::AwaitingTrigger:
case SigSession::Running:
- _session.stop_capture();
+ session_.stop_capture();
break;
}
}
void MainWindow::capture_state_changed(int state)
{
- _sampling_bar->set_capture_state((pv::SigSession::capture_state)state);
+ sampling_bar_->set_capture_state((pv::SigSession::capture_state)state);
}
} // namespace pv
*/
static const char *SettingSaveDirectory;
- DeviceManager &_device_manager;
+ DeviceManager &device_manager_;
- SigSession _session;
+ SigSession session_;
- pv::view::View *_view;
+ pv::view::View *view_;
- QWidget *_central_widget;
- QVBoxLayout *_vertical_layout;
+ QWidget *central_widget_;
+ QVBoxLayout *vertical_layout_;
- toolbars::SamplingBar *_sampling_bar;
+ toolbars::SamplingBar *sampling_bar_;
};
} // namespace pv
Channels::Channels(SigSession &session, QWidget *parent) :
Popup(parent),
- _session(session),
- _updating_channels(false),
- _enable_all_channels(tr("Enable All"), this),
- _disable_all_channels(tr("Disable All"), this),
- _check_box_mapper(this)
+ session_(session),
+ updating_channels_(false),
+ enable_all_channels_(tr("Enable All"), this),
+ disable_all_channels_(tr("Disable All"), this),
+ check_box_mapper_(this)
{
// Create the layout
- setLayout(&_layout);
+ setLayout(&layout_);
- shared_ptr<sigrok::Device> device = _session.device();
+ shared_ptr<sigrok::Device> device = session_.device();
assert(device);
// Collect a set of signals
map<shared_ptr<Channel>, shared_ptr<Signal> > signal_map;
- shared_lock<shared_mutex> lock(_session.signals_mutex());
- const vector< shared_ptr<Signal> > &sigs(_session.signals());
+ shared_lock<shared_mutex> lock(session_.signals_mutex());
+ const vector< shared_ptr<Signal> > &sigs(session_.signals());
for (const shared_ptr<Signal> &sig : sigs)
signal_map[sig->channel()] = sig;
populate_group(NULL, global_sigs);
// Create the enable/disable all buttons
- connect(&_enable_all_channels, SIGNAL(clicked()),
+ connect(&enable_all_channels_, SIGNAL(clicked()),
this, SLOT(enable_all_channels()));
- connect(&_disable_all_channels, SIGNAL(clicked()),
+ connect(&disable_all_channels_, SIGNAL(clicked()),
this, SLOT(disable_all_channels()));
- _enable_all_channels.setFlat(true);
- _disable_all_channels.setFlat(true);
+ enable_all_channels_.setFlat(true);
+ disable_all_channels_.setFlat(true);
- _buttons_bar.addWidget(&_enable_all_channels);
- _buttons_bar.addWidget(&_disable_all_channels);
- _buttons_bar.addStretch(1);
+ buttons_bar_.addWidget(&enable_all_channels_);
+ buttons_bar_.addWidget(&disable_all_channels_);
+ buttons_bar_.addStretch(1);
- _layout.addRow(&_buttons_bar);
+ layout_.addRow(&buttons_bar_);
// Connect the check-box signal mapper
- connect(&_check_box_mapper, SIGNAL(mapped(QWidget*)),
+ connect(&check_box_mapper_, SIGNAL(mapped(QWidget*)),
this, SLOT(on_channel_checked(QWidget*)));
}
void Channels::set_all_channels(bool set)
{
- _updating_channels = true;
+ updating_channels_ = true;
for (map<QCheckBox*, shared_ptr<Signal> >::const_iterator i =
- _check_box_signal_map.begin();
- i != _check_box_signal_map.end(); i++)
+ check_box_signal_map_.begin();
+ i != check_box_signal_map_.end(); i++)
{
const shared_ptr<Signal> sig = (*i).second;
assert(sig);
(*i).first->setChecked(set);
}
- _updating_channels = false;
+ updating_channels_ = false;
}
void Channels::populate_group(shared_ptr<ChannelGroup> group,
// Create a title if the group is going to have any content
if ((!sigs.empty() || (binding && !binding->properties().empty())) &&
group)
- _layout.addRow(new QLabel(
+ layout_.addRow(new QLabel(
QString("<h3>%1</h3>").arg(group->name().c_str())));
// Create the channel group grid
QGridLayout *const channel_grid =
create_channel_group_grid(sigs);
- _layout.addRow(channel_grid);
+ layout_.addRow(channel_grid);
// Create the channel group options
if (binding)
{
- binding->add_properties_to_form(&_layout, true);
- _group_bindings.push_back(binding);
+ binding->add_properties_to_form(&layout_, true);
+ group_bindings_.push_back(binding);
}
}
assert(sig);
QCheckBox *const checkbox = new QCheckBox(sig->name());
- _check_box_mapper.setMapping(checkbox, checkbox);
+ check_box_mapper_.setMapping(checkbox, checkbox);
connect(checkbox, SIGNAL(toggled(bool)),
- &_check_box_mapper, SLOT(map()));
+ &check_box_mapper_, SLOT(map()));
grid->addWidget(checkbox, row, col);
- _check_box_signal_map[checkbox] = sig;
+ check_box_signal_map_[checkbox] = sig;
if(++col >= 8)
col = 0, row++;
{
pv::widgets::Popup::showEvent(e);
- _updating_channels = true;
+ updating_channels_ = true;
for (map<QCheckBox*, shared_ptr<Signal> >::const_iterator i =
- _check_box_signal_map.begin();
- i != _check_box_signal_map.end(); i++)
+ check_box_signal_map_.begin();
+ i != check_box_signal_map_.end(); i++)
{
const shared_ptr<Signal> sig = (*i).second;
assert(sig);
(*i).first->setChecked(sig->enabled());
}
- _updating_channels = false;
+ updating_channels_ = false;
}
void Channels::on_channel_checked(QWidget *widget)
{
- if (_updating_channels)
+ if (updating_channels_)
return;
QCheckBox *const check_box = (QCheckBox*)widget;
// Look up the signal of this check-box
map< QCheckBox*, shared_ptr<Signal> >::const_iterator iter =
- _check_box_signal_map.find((QCheckBox*)check_box);
- assert(iter != _check_box_signal_map.end());
+ check_box_signal_map_.find((QCheckBox*)check_box);
+ assert(iter != check_box_signal_map_.end());
const shared_ptr<pv::view::Signal> s = (*iter).second;
assert(s);
Q_OBJECT
public:
- Channels(SigSession &_session, QWidget *parent);
+ Channels(SigSession &session_, QWidget *parent);
private:
void set_all_channels(bool set);
void disable_all_channels();
private:
- pv::SigSession &_session;
+ pv::SigSession &session_;
- QFormLayout _layout;
+ QFormLayout layout_;
- bool _updating_channels;
+ bool updating_channels_;
std::vector< std::shared_ptr<pv::prop::binding::DeviceOptions> >
- _group_bindings;
+ group_bindings_;
std::map< QCheckBox*, std::shared_ptr<pv::view::Signal> >
- _check_box_signal_map;
+ check_box_signal_map_;
- QHBoxLayout _buttons_bar;
- QPushButton _enable_all_channels;
- QPushButton _disable_all_channels;
+ QHBoxLayout buttons_bar_;
+ QPushButton enable_all_channels_;
+ QPushButton disable_all_channels_;
- QSignalMapper _check_box_mapper;
+ QSignalMapper check_box_mapper_;
};
} // popups
DeviceOptions::DeviceOptions(shared_ptr<Device> device, QWidget *parent) :
Popup(parent),
- _device(device),
- _layout(this),
- _binding(device)
+ device_(device),
+ layout_(this),
+ binding_(device)
{
- setLayout(&_layout);
+ setLayout(&layout_);
- _layout.addWidget(_binding.get_property_form(this, true));
+ layout_.addWidget(binding_.get_property_form(this, true));
}
pv::prop::binding::DeviceOptions& DeviceOptions::binding()
{
- return _binding;
+ return binding_;
}
} // namespace popups
pv::prop::binding::DeviceOptions& binding();
private:
- std::shared_ptr<sigrok::Device> _device;
+ std::shared_ptr<sigrok::Device> device_;
- QVBoxLayout _layout;
+ QVBoxLayout layout_;
- pv::prop::binding::DeviceOptions _binding;
+ pv::prop::binding::DeviceOptions binding_;
};
} // namespace popups
const std::vector< std::shared_ptr<Property> >& Binding::properties()
{
- return _properties;
+ return properties_;
}
void Binding::commit()
{
- for (shared_ptr<pv::prop::Property> p : _properties) {
+ for (shared_ptr<pv::prop::Property> p : properties_) {
assert(p);
p->commit();
}
{
assert(layout);
- for (shared_ptr<pv::prop::Property> p : _properties)
+ for (shared_ptr<pv::prop::Property> p : properties_)
{
assert(p);
static QString print_gvariant(Glib::VariantBase gvar);
protected:
- std::vector< std::shared_ptr<Property> > _properties;
+ std::vector< std::shared_ptr<Property> > properties_;
};
} // binding
DecoderOptions::DecoderOptions(
shared_ptr<pv::data::DecoderStack> decoder_stack,
shared_ptr<data::decode::Decoder> decoder) :
- _decoder_stack(decoder_stack),
- _decoder(decoder)
+ decoder_stack_(decoder_stack),
+ decoder_(decoder)
{
- assert(_decoder);
+ assert(decoder_);
- const srd_decoder *const dec = _decoder->decoder();
+ const srd_decoder *const dec = decoder_->decoder();
assert(dec);
for (GSList *l = dec->options; l; l = l->next)
else
continue;
- _properties.push_back(prop);
+ properties_.push_back(prop);
}
}
{
GVariant *val = NULL;
- assert(_decoder);
+ assert(decoder_);
// Get the value from the hash table if it is already present
- const map<string, GVariant*>& options = _decoder->options();
+ const map<string, GVariant*>& options = decoder_->options();
const auto iter = options.find(id);
if (iter != options.end())
val = (*iter).second;
else
{
- assert(_decoder->decoder());
+ assert(decoder_->decoder());
// Get the default value if not
- for (GSList *l = _decoder->decoder()->options; l; l = l->next)
+ for (GSList *l = decoder_->decoder()->options; l; l = l->next)
{
const srd_decoder_option *const opt =
(srd_decoder_option*)l->data;
void DecoderOptions::setter(const char *id, Glib::VariantBase value)
{
- assert(_decoder);
- _decoder->set_option(id, value.gobj());
+ assert(decoder_);
+ decoder_->set_option(id, value.gobj());
- assert(_decoder_stack);
- _decoder_stack->begin_decode();
+ assert(decoder_stack_);
+ decoder_stack_->begin_decode();
}
} // binding
void setter(const char *id, Glib::VariantBase value);
private:
- std::shared_ptr<pv::data::DecoderStack> _decoder_stack;
- std::shared_ptr<pv::data::decode::Decoder> _decoder;
+ std::shared_ptr<pv::data::DecoderStack> decoder_stack_;
+ std::shared_ptr<pv::data::decode::Decoder> decoder_;
};
} // binding
namespace binding {
DeviceOptions::DeviceOptions(shared_ptr<sigrok::Configurable> configurable) :
- _configurable(configurable)
+ configurable_(configurable)
{
assert(configurable);
const QString name = QString::fromStdString(name_str);
const Property::Getter get = [&, key]() {
- return _configurable->config_get(key); };
+ return configurable_->config_get(key); };
const Property::Setter set = [&, key](Glib::VariantBase value) {
- _configurable->config_set(key, value);
+ configurable_->config_set(key, value);
config_changed();
};
void DeviceOptions::bind_bool(const QString &name,
Property::Getter getter, Property::Setter setter)
{
- assert(_configurable);
- _properties.push_back(shared_ptr<Property>(new Bool(
+ assert(configurable_);
+ properties_.push_back(shared_ptr<Property>(new Bool(
name, getter, setter)));
}
Glib::VariantBase gvar;
vector< pair<Glib::VariantBase, QString> > values;
- assert(_configurable);
+ assert(configurable_);
Glib::VariantIter iter(gvar_list);
while ((iter.next_value(gvar)))
values.push_back(make_pair(gvar, printer(gvar)));
- _properties.push_back(shared_ptr<Property>(new Enum(name, values,
+ properties_.push_back(shared_ptr<Property>(new Enum(name, values,
getter, setter)));
}
optional< std::pair<int64_t, int64_t> > range,
Property::Getter getter, Property::Setter setter)
{
- assert(_configurable);
+ assert(configurable_);
- _properties.push_back(shared_ptr<Property>(new Int(name, suffix, range,
+ properties_.push_back(shared_ptr<Property>(new Int(name, suffix, range,
getter, setter)));
}
static QString print_voltage_threshold(Glib::VariantBase gvar);
protected:
- std::shared_ptr<sigrok::Configurable> _configurable;
+ std::shared_ptr<sigrok::Configurable> configurable_;
};
} // binding
Bool::Bool(QString name, Getter getter, Setter setter) :
Property(name, getter, setter),
- _check_box(NULL)
+ check_box_(NULL)
{
}
QWidget* Bool::get_widget(QWidget *parent, bool auto_commit)
{
- if (_check_box)
- return _check_box;
+ if (check_box_)
+ return check_box_;
- if (!_getter)
+ if (!getter_)
return NULL;
- Glib::VariantBase variant = _getter();
+ Glib::VariantBase variant = getter_();
if (!variant.gobj())
return NULL;
bool value = Glib::VariantBase::cast_dynamic<Glib::Variant<bool>>(
variant).get();
- _check_box = new QCheckBox(name(), parent);
- _check_box->setCheckState(value ? Qt::Checked : Qt::Unchecked);
+ check_box_ = new QCheckBox(name(), parent);
+ check_box_->setCheckState(value ? Qt::Checked : Qt::Unchecked);
if (auto_commit)
- connect(_check_box, SIGNAL(stateChanged(int)),
+ connect(check_box_, SIGNAL(stateChanged(int)),
this, SLOT(on_state_changed(int)));
- return _check_box;
+ return check_box_;
}
bool Bool::labeled_widget() const
void Bool::commit()
{
- assert(_setter);
+ assert(setter_);
- if (!_check_box)
+ if (!check_box_)
return;
- _setter(Glib::Variant<bool>::create(
- _check_box->checkState() == Qt::Checked));
+ setter_(Glib::Variant<bool>::create(
+ check_box_->checkState() == Qt::Checked));
}
void Bool::on_state_changed(int)
void on_state_changed(int);
private:
- QCheckBox *_check_box;
+ QCheckBox *check_box_;
};
} // prop
Getter getter,
Setter setter) :
Property(name, getter, setter),
- _decimals(decimals),
- _suffix(suffix),
- _range(range),
- _step(step),
- _spin_box(NULL)
+ decimals_(decimals),
+ suffix_(suffix),
+ range_(range),
+ step_(step),
+ spin_box_(NULL)
{
}
QWidget* Double::get_widget(QWidget *parent, bool auto_commit)
{
- if (_spin_box)
- return _spin_box;
+ if (spin_box_)
+ return spin_box_;
- if (!_getter)
+ if (!getter_)
return NULL;
- Glib::VariantBase variant = _getter();
+ Glib::VariantBase variant = getter_();
if (!variant.gobj())
return NULL;
double value = Glib::VariantBase::cast_dynamic<Glib::Variant<double>>(
variant).get();
- _spin_box = new QDoubleSpinBox(parent);
- _spin_box->setDecimals(_decimals);
- _spin_box->setSuffix(_suffix);
- if (_range)
- _spin_box->setRange(_range->first, _range->second);
- if (_step)
- _spin_box->setSingleStep(*_step);
+ spin_box_ = new QDoubleSpinBox(parent);
+ spin_box_->setDecimals(decimals_);
+ spin_box_->setSuffix(suffix_);
+ if (range_)
+ spin_box_->setRange(range_->first, range_->second);
+ if (step_)
+ spin_box_->setSingleStep(*step_);
- _spin_box->setValue(value);
+ spin_box_->setValue(value);
if (auto_commit)
- connect(_spin_box, SIGNAL(valueChanged(double)),
+ connect(spin_box_, SIGNAL(valueChanged(double)),
this, SLOT(on_value_changed(double)));
- return _spin_box;
+ return spin_box_;
}
void Double::commit()
{
- assert(_setter);
+ assert(setter_);
- if (!_spin_box)
+ if (!spin_box_)
return;
- _setter(Glib::Variant<double>::create(_spin_box->value()));
+ setter_(Glib::Variant<double>::create(spin_box_->value()));
}
void Double::on_value_changed(double)
void on_value_changed(double);
private:
- const int _decimals;
- const QString _suffix;
- const boost::optional< std::pair<double, double> > _range;
- const boost::optional<double> _step;
+ const int decimals_;
+ const QString suffix_;
+ const boost::optional< std::pair<double, double> > range_;
+ const boost::optional<double> step_;
- QDoubleSpinBox *_spin_box;
+ QDoubleSpinBox *spin_box_;
};
} // prop
vector<pair<Glib::VariantBase, QString> > values,
Getter getter, Setter setter) :
Property(name, getter, setter),
- _values(values),
- _selector(NULL)
+ values_(values),
+ selector_(NULL)
{
}
QWidget* Enum::get_widget(QWidget *parent, bool auto_commit)
{
- if (_selector)
- return _selector;
+ if (selector_)
+ return selector_;
- if (!_getter)
+ if (!getter_)
return NULL;
- Glib::VariantBase variant = _getter();
+ Glib::VariantBase variant = getter_();
if (!variant.gobj())
return NULL;
- _selector = new QComboBox(parent);
- for (unsigned int i = 0; i < _values.size(); i++) {
- const pair<Glib::VariantBase, QString> &v = _values[i];
- _selector->addItem(v.second, qVariantFromValue(v.first));
+ selector_ = new QComboBox(parent);
+ for (unsigned int i = 0; i < values_.size(); i++) {
+ const pair<Glib::VariantBase, QString> &v = values_[i];
+ selector_->addItem(v.second, qVariantFromValue(v.first));
if (v.first.equal(variant))
- _selector->setCurrentIndex(i);
+ selector_->setCurrentIndex(i);
}
if (auto_commit)
- connect(_selector, SIGNAL(currentIndexChanged(int)),
+ connect(selector_, SIGNAL(currentIndexChanged(int)),
this, SLOT(on_current_item_changed(int)));
- return _selector;
+ return selector_;
}
void Enum::commit()
{
- assert(_setter);
+ assert(setter_);
- if (!_selector)
+ if (!selector_)
return;
- const int index = _selector->currentIndex();
+ const int index = selector_->currentIndex();
if (index < 0)
return;
- _setter(_selector->itemData(index).value<Glib::VariantBase>());
+ setter_(selector_->itemData(index).value<Glib::VariantBase>());
}
void Enum::on_current_item_changed(int)
void on_current_item_changed(int);
private:
- const std::vector< std::pair<Glib::VariantBase, QString> > _values;
+ const std::vector< std::pair<Glib::VariantBase, QString> > values_;
- QComboBox *_selector;
+ QComboBox *selector_;
};
} // prop
Getter getter,
Setter setter) :
Property(name, getter, setter),
- _suffix(suffix),
- _range(range),
- _spin_box(NULL)
+ suffix_(suffix),
+ range_(range),
+ spin_box_(NULL)
{
}
{
int64_t int_val = 0, range_min = 0, range_max = 0;
- if (_spin_box)
- return _spin_box;
+ if (spin_box_)
+ return spin_box_;
- if (!_getter)
+ if (!getter_)
return NULL;
- _value = _getter();
+ value_ = getter_();
- GVariant *value = _value.gobj();
+ GVariant *value = value_.gobj();
if (!value)
return NULL;
- _spin_box = new QSpinBox(parent);
- _spin_box->setSuffix(_suffix);
+ spin_box_ = new QSpinBox(parent);
+ spin_box_->setSuffix(suffix_);
const GVariantType *const type = g_variant_get_type(value);
assert(type);
range_min = max(range_min, (int64_t)INT_MIN);
range_max = min(range_max, (int64_t)INT_MAX);
- if (_range)
- _spin_box->setRange((int)_range->first, (int)_range->second);
+ if (range_)
+ spin_box_->setRange((int)range_->first, (int)range_->second);
else
- _spin_box->setRange((int)range_min, (int)range_max);
+ spin_box_->setRange((int)range_min, (int)range_max);
- _spin_box->setValue((int)int_val);
+ spin_box_->setValue((int)int_val);
if (auto_commit)
- connect(_spin_box, SIGNAL(valueChanged(int)),
+ connect(spin_box_, SIGNAL(valueChanged(int)),
this, SLOT(on_value_changed(int)));
- return _spin_box;
+ return spin_box_;
}
void Int::commit()
{
- assert(_setter);
+ assert(setter_);
- if (!_spin_box)
+ if (!spin_box_)
return;
GVariant *new_value = NULL;
- const GVariantType *const type = g_variant_get_type(_value.gobj());
+ const GVariantType *const type = g_variant_get_type(value_.gobj());
assert(type);
if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE))
- new_value = g_variant_new_byte(_spin_box->value());
+ new_value = g_variant_new_byte(spin_box_->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16))
- new_value = g_variant_new_int16(_spin_box->value());
+ new_value = g_variant_new_int16(spin_box_->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16))
- new_value = g_variant_new_uint16(_spin_box->value());
+ new_value = g_variant_new_uint16(spin_box_->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32))
- new_value = g_variant_new_int32(_spin_box->value());
+ new_value = g_variant_new_int32(spin_box_->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32))
- new_value = g_variant_new_int32(_spin_box->value());
+ new_value = g_variant_new_int32(spin_box_->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64))
- new_value = g_variant_new_int64(_spin_box->value());
+ new_value = g_variant_new_int64(spin_box_->value());
else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64))
- new_value = g_variant_new_uint64(_spin_box->value());
+ new_value = g_variant_new_uint64(spin_box_->value());
else
{
// Unexpected value type.
assert(new_value);
- _value = Glib::VariantBase(new_value);
+ value_ = Glib::VariantBase(new_value);
- _setter(_value);
+ setter_(value_);
}
void Int::on_value_changed(int)
void on_value_changed(int);
private:
- const QString _suffix;
- const boost::optional< std::pair<int64_t, int64_t> > _range;
+ const QString suffix_;
+ const boost::optional< std::pair<int64_t, int64_t> > range_;
- Glib::VariantBase _value;
- QSpinBox *_spin_box;
+ Glib::VariantBase value_;
+ QSpinBox *spin_box_;
};
} // prop
namespace prop {
Property::Property(QString name, Getter getter, Setter setter) :
- _getter(getter),
- _setter(setter),
- _name(name)
+ getter_(getter),
+ setter_(setter),
+ name_(name)
{
}
const QString& Property::name() const
{
- return _name;
+ return name_;
}
bool Property::labeled_widget() const
virtual void commit() = 0;
protected:
- const Getter _getter;
- const Setter _setter;
+ const Getter getter_;
+ const Setter setter_;
private:
- QString _name;
+ QString name_;
};
} // prop
Getter getter,
Setter setter) :
Property(name, getter, setter),
- _line_edit(NULL)
+ line_edit_(NULL)
{
}
QWidget* String::get_widget(QWidget *parent, bool auto_commit)
{
- if (_line_edit)
- return _line_edit;
+ if (line_edit_)
+ return line_edit_;
- if (!_getter)
+ if (!getter_)
return NULL;
- Glib::VariantBase variant = _getter();
+ Glib::VariantBase variant = getter_();
if (!variant.gobj())
return NULL;
string value = Glib::VariantBase::cast_dynamic<Glib::Variant<ustring>>(
variant).get();
- _line_edit = new QLineEdit(parent);
- _line_edit->setText(QString::fromStdString(value));
+ line_edit_ = new QLineEdit(parent);
+ line_edit_->setText(QString::fromStdString(value));
if (auto_commit)
- connect(_line_edit, SIGNAL(textEdited(const QString&)),
+ connect(line_edit_, SIGNAL(textEdited(const QString&)),
this, SLOT(on_text_edited(const QString&)));
- return _line_edit;
+ return line_edit_;
}
void String::commit()
{
- assert(_setter);
+ assert(setter_);
- if (!_line_edit)
+ if (!line_edit_)
return;
- QByteArray ba = _line_edit->text().toLocal8Bit();
- _setter(Glib::Variant<ustring>::create(ba.data()));
+ QByteArray ba = line_edit_->text().toLocal8Bit();
+ setter_(Glib::Variant<ustring>::create(ba.data()));
}
void String::on_text_edited(const QString&)
void on_text_edited(const QString&);
private:
- QLineEdit *_line_edit;
+ QLineEdit *line_edit_;
};
} // prop
namespace pv {
SigSession::SigSession(DeviceManager &device_manager) :
- _device_manager(device_manager),
- _session(device_manager.context()->create_session()),
- _capture_state(Stopped)
+ device_manager_(device_manager),
+ session_(device_manager.context()->create_session()),
+ capture_state_(Stopped)
{
set_default_device();
}
DeviceManager& SigSession::device_manager()
{
- return _device_manager;
+ return device_manager_;
}
const DeviceManager& SigSession::device_manager() const
{
- return _device_manager;
+ return device_manager_;
}
const shared_ptr<sigrok::Session>& SigSession::session() const
{
- return _session;
+ return session_;
}
shared_ptr<Device> SigSession::device() const
{
- return _device;
+ return device_;
}
void SigSession::set_device(shared_ptr<Device> device)
// Are we setting a session device?
auto session_device = dynamic_pointer_cast<SessionDevice>(device);
// Did we have a session device selected previously?
- auto prev_session_device = dynamic_pointer_cast<SessionDevice>(_device);
+ auto prev_session_device = dynamic_pointer_cast<SessionDevice>(device_);
- if (_device) {
- _session->remove_datafeed_callbacks();
+ if (device_) {
+ session_->remove_datafeed_callbacks();
if (!prev_session_device) {
- _device->close();
- _session->remove_devices();
+ device_->close();
+ session_->remove_devices();
}
}
if (session_device)
- _session = session_device->parent();
+ session_ = session_device->parent();
- _device = device;
- _decode_traces.clear();
+ device_ = device;
+ decode_traces_.clear();
if (device) {
if (!session_device)
{
- _session = _device_manager.context()->create_session();
+ session_ = device_manager_.context()->create_session();
device->open();
- _session->add_device(device);
+ session_->add_device(device);
}
- _session->add_datafeed_callback([=]
+ session_->add_datafeed_callback([=]
(shared_ptr<Device> device, shared_ptr<Packet> packet) {
data_feed_in(device, packet);
});
void SigSession::set_file(const string &name)
{
- _session = _device_manager.context()->load_session(name);
- _device = _session->devices()[0];
- _decode_traces.clear();
- _session->add_datafeed_callback([=]
+ session_ = device_manager_.context()->load_session(name);
+ device_ = session_->devices()[0];
+ decode_traces_.clear();
+ session_->add_datafeed_callback([=]
(shared_ptr<Device> device, shared_ptr<Packet> packet) {
data_feed_in(device, packet);
});
- _device_manager.update_display_name(_device);
- update_signals(_device);
+ device_manager_.update_display_name(device_);
+ update_signals(device_);
}
void SigSession::set_default_device()
{
shared_ptr<HardwareDevice> default_device;
const list< shared_ptr<HardwareDevice> > &devices =
- _device_manager.devices();
+ device_manager_.devices();
if (!devices.empty()) {
// Fall back to the first device in the list.
SigSession::capture_state SigSession::get_capture_state() const
{
- lock_guard<mutex> lock(_sampling_mutex);
- return _capture_state;
+ lock_guard<mutex> lock(sampling_mutex_);
+ return capture_state_;
}
void SigSession::start_capture(function<void (const QString)> error_handler)
stop_capture();
// Check that a device instance has been selected.
- if (!_device) {
+ if (!device_) {
qDebug() << "No device selected";
return;
}
// Check that at least one channel is enabled
- auto channels = _device->channels();
+ auto channels = device_->channels();
bool enabled = std::any_of(channels.begin(), channels.end(),
[](shared_ptr<Channel> channel) { return channel->enabled(); });
}
// Begin the session
- _sampling_thread = std::thread(
- &SigSession::sample_thread_proc, this, _device,
+ sampling_thread_ = std::thread(
+ &SigSession::sample_thread_proc, this, device_,
error_handler);
}
void SigSession::stop_capture()
{
if (get_capture_state() != Stopped)
- _session->stop();
+ session_->stop();
// Check that sampling stopped
- if (_sampling_thread.joinable())
- _sampling_thread.join();
+ if (sampling_thread_.joinable())
+ sampling_thread_.join();
}
set< shared_ptr<data::SignalData> > SigSession::get_data() const
{
- shared_lock<shared_mutex> lock(_signals_mutex);
+ shared_lock<shared_mutex> lock(signals_mutex_);
set< shared_ptr<data::SignalData> > data;
- for (const shared_ptr<view::Signal> sig : _signals) {
+ for (const shared_ptr<view::Signal> sig : signals_) {
assert(sig);
data.insert(sig->data());
}
boost::shared_mutex& SigSession::signals_mutex() const
{
- return _signals_mutex;
+ return signals_mutex_;
}
const vector< shared_ptr<view::Signal> >& SigSession::signals() const
{
- return _signals;
+ return signals_;
}
#ifdef ENABLE_DECODE
try
{
- lock_guard<boost::shared_mutex> lock(_signals_mutex);
+ lock_guard<boost::shared_mutex> lock(signals_mutex_);
// Create the decoder
decoder_stack = shared_ptr<data::DecoderStack>(
// Auto select the initial channels
for (const srd_channel *pdch : all_channels)
- for (shared_ptr<view::Signal> s : _signals)
+ for (shared_ptr<view::Signal> s : signals_)
{
shared_ptr<view::LogicSignal> l =
dynamic_pointer_cast<view::LogicSignal>(s);
// Create the decode signal
shared_ptr<view::DecodeTrace> d(
new view::DecodeTrace(*this, decoder_stack,
- _decode_traces.size()));
- _decode_traces.push_back(d);
+ decode_traces_.size()));
+ decode_traces_.push_back(d);
}
catch(std::runtime_error e)
{
vector< shared_ptr<view::DecodeTrace> > SigSession::get_decode_signals() const
{
- shared_lock<shared_mutex> lock(_signals_mutex);
- return _decode_traces;
+ shared_lock<shared_mutex> lock(signals_mutex_);
+ return decode_traces_;
}
void SigSession::remove_decode_signal(view::DecodeTrace *signal)
{
- for (auto i = _decode_traces.begin(); i != _decode_traces.end(); i++)
+ for (auto i = decode_traces_.begin(); i != decode_traces_.end(); i++)
if ((*i).get() == signal)
{
- _decode_traces.erase(i);
+ decode_traces_.erase(i);
signals_changed();
return;
}
void SigSession::set_capture_state(capture_state state)
{
- lock_guard<mutex> lock(_sampling_mutex);
- const bool changed = _capture_state != state;
- _capture_state = state;
+ lock_guard<mutex> lock(sampling_mutex_);
+ const bool changed = capture_state_ != state;
+ capture_state_ = state;
if(changed)
capture_state_changed(state);
}
void SigSession::update_signals(shared_ptr<Device> device)
{
assert(device);
- assert(_capture_state == Stopped);
+ assert(capture_state_ == Stopped);
// Clear the decode traces
- _decode_traces.clear();
+ decode_traces_.clear();
// Detect what data types we will receive
auto channels = device->channels();
// Create data containers for the logic data snapshots
{
- lock_guard<mutex> data_lock(_data_mutex);
+ lock_guard<mutex> data_lock(data_mutex_);
- _logic_data.reset();
+ logic_data_.reset();
if (logic_channel_count != 0) {
- _logic_data.reset(new data::Logic(
+ logic_data_.reset(new data::Logic(
logic_channel_count));
- assert(_logic_data);
+ assert(logic_data_);
}
}
// Make the Signals list
{
- unique_lock<shared_mutex> lock(_signals_mutex);
+ unique_lock<shared_mutex> lock(signals_mutex_);
- _signals.clear();
+ signals_.clear();
for (auto channel : device->channels()) {
shared_ptr<view::Signal> signal;
case SR_CHANNEL_LOGIC:
signal = shared_ptr<view::Signal>(
new view::LogicSignal(*this, device,
- channel, _logic_data));
+ channel, logic_data_));
break;
case SR_CHANNEL_ANALOG:
}
assert(signal);
- _signals.push_back(signal);
+ signals_.push_back(signal);
}
}
shared_ptr<view::Signal> SigSession::signal_from_channel(
shared_ptr<Channel> channel) const
{
- lock_guard<boost::shared_mutex> lock(_signals_mutex);
- for (shared_ptr<view::Signal> sig : _signals) {
+ lock_guard<boost::shared_mutex> lock(signals_mutex_);
+ for (shared_ptr<view::Signal> sig : signals_) {
assert(sig);
if (sig->channel() == channel)
return sig;
read_sample_rate(device);
try {
- _session->start();
+ session_->start();
} catch(Error e) {
error_handler(e.what());
return;
}
- set_capture_state(_session->trigger() ?
+ set_capture_state(session_->trigger() ?
AwaitingTrigger : Running);
- _session->run();
+ session_->run();
set_capture_state(Stopped);
// Confirm that SR_DF_END was received
- if (_cur_logic_snapshot)
+ if (cur_logic_snapshot_)
{
qDebug("SR_DF_END was not received.");
assert(0);
void SigSession::feed_in_frame_begin()
{
- if (_cur_logic_snapshot || !_cur_analog_snapshots.empty())
+ if (cur_logic_snapshot_ || !cur_analog_snapshots_.empty())
frame_began();
}
void SigSession::feed_in_logic(shared_ptr<Logic> logic)
{
- lock_guard<mutex> lock(_data_mutex);
+ lock_guard<mutex> lock(data_mutex_);
- if (!_logic_data)
+ if (!logic_data_)
{
qDebug() << "Unexpected logic packet";
return;
}
- if (!_cur_logic_snapshot)
+ if (!cur_logic_snapshot_)
{
// This could be the first packet after a trigger
set_capture_state(Running);
uint64_t sample_limit;
try {
sample_limit = VariantBase::cast_dynamic<Variant<guint64>>(
- _device->config_get(ConfigKey::LIMIT_SAMPLES)).get();
+ device_->config_get(ConfigKey::LIMIT_SAMPLES)).get();
} catch (Error) {
sample_limit = 0;
}
// Create a new data snapshot
- _cur_logic_snapshot = shared_ptr<data::LogicSnapshot>(
+ cur_logic_snapshot_ = shared_ptr<data::LogicSnapshot>(
new data::LogicSnapshot(logic, sample_limit));
- _logic_data->push_snapshot(_cur_logic_snapshot);
+ logic_data_->push_snapshot(cur_logic_snapshot_);
// @todo Putting this here means that only listeners querying
// for logic will be notified. Currently the only user of
else
{
// Append to the existing data snapshot
- _cur_logic_snapshot->append_payload(logic);
+ cur_logic_snapshot_->append_payload(logic);
}
data_received();
void SigSession::feed_in_analog(shared_ptr<Analog> analog)
{
- lock_guard<mutex> lock(_data_mutex);
+ lock_guard<mutex> lock(data_mutex_);
const vector<shared_ptr<Channel>> channels = analog->channels();
const unsigned int channel_count = channels.size();
// Try to get the snapshot of the channel
const map< shared_ptr<Channel>, shared_ptr<data::AnalogSnapshot> >::
- iterator iter = _cur_analog_snapshots.find(channel);
- if (iter != _cur_analog_snapshots.end())
+ iterator iter = cur_analog_snapshots_.find(channel);
+ if (iter != cur_analog_snapshots_.end())
snapshot = (*iter).second;
else
{
uint64_t sample_limit;
try {
sample_limit = VariantBase::cast_dynamic<Variant<guint64>>(
- _device->config_get(ConfigKey::LIMIT_SAMPLES)).get();
+ device_->config_get(ConfigKey::LIMIT_SAMPLES)).get();
} catch (Error) {
sample_limit = 0;
}
// Create a snapshot, keep it in the maps of channels
snapshot = shared_ptr<data::AnalogSnapshot>(
new data::AnalogSnapshot(sample_limit));
- _cur_analog_snapshots[channel] = snapshot;
+ cur_analog_snapshots_[channel] = snapshot;
// Find the annalog data associated with the channel
shared_ptr<view::AnalogSignal> sig =
case SR_DF_END:
{
{
- lock_guard<mutex> lock(_data_mutex);
- _cur_logic_snapshot.reset();
- _cur_analog_snapshots.clear();
+ lock_guard<mutex> lock(data_mutex_);
+ cur_logic_snapshot_.reset();
+ cur_analog_snapshots_.clear();
}
frame_ended();
break;
std::shared_ptr<sigrok::Packet> packet);
private:
- DeviceManager &_device_manager;
- std::shared_ptr<sigrok::Session> _session;
+ DeviceManager &device_manager_;
+ std::shared_ptr<sigrok::Session> session_;
/**
* The device instance that will be used in the next capture session.
*/
- std::shared_ptr<sigrok::Device> _device;
+ std::shared_ptr<sigrok::Device> device_;
- std::vector< std::shared_ptr<view::DecodeTrace> > _decode_traces;
+ std::vector< std::shared_ptr<view::DecodeTrace> > decode_traces_;
- mutable std::mutex _sampling_mutex;
- capture_state _capture_state;
+ mutable std::mutex sampling_mutex_;
+ capture_state capture_state_;
- mutable boost::shared_mutex _signals_mutex;
- std::vector< std::shared_ptr<view::Signal> > _signals;
+ mutable boost::shared_mutex signals_mutex_;
+ std::vector< std::shared_ptr<view::Signal> > signals_;
- mutable std::mutex _data_mutex;
- std::shared_ptr<data::Logic> _logic_data;
- std::shared_ptr<data::LogicSnapshot> _cur_logic_snapshot;
+ mutable std::mutex data_mutex_;
+ std::shared_ptr<data::Logic> logic_data_;
+ std::shared_ptr<data::LogicSnapshot> cur_logic_snapshot_;
std::map< std::shared_ptr<sigrok::Channel>, std::shared_ptr<data::AnalogSnapshot> >
- _cur_analog_snapshots;
+ cur_analog_snapshots_;
- std::thread _sampling_thread;
+ std::thread sampling_thread_;
Q_SIGNALS:
void capture_state_changed(int state);
StoreSession::StoreSession(const std::string &file_name,
const SigSession &session) :
- _file_name(file_name),
- _session(session),
- _interrupt(false),
- _units_stored(0),
- _unit_count(0)
+ file_name_(file_name),
+ session_(session),
+ interrupt_(false),
+ units_stored_(0),
+ unit_count_(0)
{
}
pair<int, int> StoreSession::progress() const
{
- return make_pair(_units_stored.load(), _unit_count.load());
+ return make_pair(units_stored_.load(), unit_count_.load());
}
const QString& StoreSession::error() const
{
- lock_guard<mutex> lock(_mutex);
- return _error;
+ lock_guard<mutex> lock(mutex_);
+ return error_;
}
bool StoreSession::start()
{
set< shared_ptr<data::SignalData> > data_set =
- _session.get_data();
+ session_.get_data();
- shared_lock<shared_mutex> lock(_session.signals_mutex());
- const vector< shared_ptr<view::Signal> > &sigs(_session.signals());
+ shared_lock<shared_mutex> lock(session_.signals_mutex());
+ const vector< shared_ptr<view::Signal> > &sigs(session_.signals());
// Check we have logic data
if (data_set.empty() || sigs.empty()) {
- _error = tr("No data to save.");
+ error_ = tr("No data to save.");
return false;
}
if (data_set.size() > 1) {
- _error = tr("PulseView currently only has support for "
+ error_ = tr("PulseView currently only has support for "
"storing a single data stream.");
return false;
}
// Get the logic data
shared_ptr<data::Logic> data;
if (!(data = dynamic_pointer_cast<data::Logic>(*data_set.begin()))) {
- _error = tr("PulseView currently only has support for "
+ error_ = tr("PulseView currently only has support for "
"storing a logic data.");
return false;
}
data->get_snapshots();
if (snapshots.empty()) {
- _error = tr("No snapshots to save.");
+ error_ = tr("No snapshots to save.");
return false;
}
// Begin storing
try {
- auto context = _session.session()->context();
+ auto context = session_.session()->context();
auto output_format = context->output_formats()["srzip"];
- auto device = _session.device();
- _output = output_format->create_output(device,
+ auto device = session_.device();
+ output_ = output_format->create_output(device,
{{"filename",
- Glib::Variant<Glib::ustring>::create(_file_name)}});
+ Glib::Variant<Glib::ustring>::create(file_name_)}});
auto meta = context->create_meta_packet(
{{ConfigKey::SAMPLERATE,
Glib::Variant<guint64>::create(data->samplerate())}});
- _output->receive(meta);
+ output_->receive(meta);
} catch (Error error) {
- _error = tr("Error while saving.");
+ error_ = tr("Error while saving.");
return false;
}
- _thread = std::thread(&StoreSession::store_proc, this, snapshot);
+ thread_ = std::thread(&StoreSession::store_proc, this, snapshot);
return true;
}
void StoreSession::wait()
{
- if (_thread.joinable())
- _thread.join();
+ if (thread_.joinable())
+ thread_.join();
}
void StoreSession::cancel()
{
- _interrupt = true;
+ interrupt_ = true;
}
void StoreSession::store_proc(shared_ptr<data::LogicSnapshot> snapshot)
while ((sample_count >> progress_scale) > INT_MAX)
progress_scale ++;
- _unit_count = sample_count >> progress_scale;
+ unit_count_ = sample_count >> progress_scale;
const unsigned int samples_per_block = BlockSize / unit_size;
- while (!_interrupt && start_sample < sample_count)
+ while (!interrupt_ && start_sample < sample_count)
{
progress_updated();
size_t length = end_sample - start_sample;
try {
- auto context = _session.session()->context();
+ auto context = session_.session()->context();
auto logic = context->create_logic_packet(data, length, unit_size);
- _output->receive(logic);
+ output_->receive(logic);
} catch (Error error) {
- _error = tr("Error while saving.");
+ error_ = tr("Error while saving.");
break;
}
start_sample = end_sample;
- _units_stored = start_sample >> progress_scale;
+ units_stored_ = start_sample >> progress_scale;
}
progress_updated();
- _output.reset();
+ output_.reset();
delete[] data;
}
void progress_updated();
private:
- const std::string _file_name;
- const SigSession &_session;
+ const std::string file_name_;
+ const SigSession &session_;
- std::shared_ptr<sigrok::Output> _output;
+ std::shared_ptr<sigrok::Output> output_;
- std::thread _thread;
+ std::thread thread_;
- std::atomic<bool> _interrupt;
+ std::atomic<bool> interrupt_;
- std::atomic<int> _units_stored, _unit_count;
+ std::atomic<int> units_stored_, unit_count_;
- mutable std::mutex _mutex;
- QString _error;
+ mutable std::mutex mutex_;
+ QString error_;
};
} // pv
SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
QToolBar("Sampling Bar", parent),
- _session(session),
- _device_selector(this),
- _updating_device_selector(false),
- _configure_button(this),
- _configure_button_action(NULL),
- _channels_button(this),
- _sample_count(" samples", this),
- _sample_rate("Hz", this),
- _updating_sample_rate(false),
- _updating_sample_count(false),
- _sample_count_supported(false),
- _icon_red(":/icons/status-red.svg"),
- _icon_green(":/icons/status-green.svg"),
- _icon_grey(":/icons/status-grey.svg"),
- _run_stop_button(this)
+ session_(session),
+ device_selector_(this),
+ updating_device_selector_(false),
+ configure_button_(this),
+ configure_button_action_(NULL),
+ channels_button_(this),
+ sample_count_(" samples", this),
+ sample_rate_("Hz", this),
+ updating_sample_rate_(false),
+ updating_sample_count_(false),
+ sample_count_supported_(false),
+ icon_red_(":/icons/status-red.svg"),
+ icon_green_(":/icons/status-green.svg"),
+ icon_grey_(":/icons/status-grey.svg"),
+ run_stop_button_(this)
{
setObjectName(QString::fromUtf8("SamplingBar"));
- connect(&_run_stop_button, SIGNAL(clicked()),
+ connect(&run_stop_button_, SIGNAL(clicked()),
this, SLOT(on_run_stop()));
- connect(&_device_selector, SIGNAL(currentIndexChanged (int)),
+ connect(&device_selector_, SIGNAL(currentIndexChanged (int)),
this, SLOT(on_device_selected()));
- connect(&_sample_count, SIGNAL(value_changed()),
+ connect(&sample_count_, SIGNAL(value_changed()),
this, SLOT(on_sample_count_changed()));
- connect(&_sample_rate, SIGNAL(value_changed()),
+ connect(&sample_rate_, SIGNAL(value_changed()),
this, SLOT(on_sample_rate_changed()));
- _sample_count.show_min_max_step(0, UINT64_MAX, 1);
+ sample_count_.show_min_max_step(0, UINT64_MAX, 1);
set_capture_state(pv::SigSession::Stopped);
- _configure_button.setIcon(QIcon::fromTheme("configure",
+ configure_button_.setIcon(QIcon::fromTheme("configure",
QIcon(":/icons/configure.png")));
- _channels_button.setIcon(QIcon::fromTheme("channels",
+ channels_button_.setIcon(QIcon::fromTheme("channels",
QIcon(":/icons/channels.svg")));
- _run_stop_button.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
+ run_stop_button_.setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
- addWidget(&_device_selector);
- _configure_button_action = addWidget(&_configure_button);
- addWidget(&_channels_button);
- addWidget(&_sample_count);
- addWidget(&_sample_rate);
+ addWidget(&device_selector_);
+ configure_button_action_ = addWidget(&configure_button_);
+ addWidget(&channels_button_);
+ addWidget(&sample_count_);
+ addWidget(&sample_rate_);
- addWidget(&_run_stop_button);
+ addWidget(&run_stop_button_);
- _sample_count.installEventFilter(this);
- _sample_rate.installEventFilter(this);
+ sample_count_.installEventFilter(this);
+ sample_rate_.installEventFilter(this);
}
void SamplingBar::set_device_list(
assert(selected);
- _updating_device_selector = true;
+ updating_device_selector_ = true;
- _device_selector.clear();
+ device_selector_.clear();
for (auto entry : devices) {
auto device = entry.first;
assert(device);
if (selected == device)
- selected_index = _device_selector.count();
+ selected_index = device_selector_.count();
- _device_selector.addItem(display_name.c_str(),
+ device_selector_.addItem(display_name.c_str(),
qVariantFromValue(device));
}
// The selected device should have been in the list
assert(selected_index != -1);
- _device_selector.setCurrentIndex(selected_index);
+ device_selector_.setCurrentIndex(selected_index);
update_device_config_widgets();
- _updating_device_selector = false;
+ updating_device_selector_ = false;
}
shared_ptr<Device> SamplingBar::get_selected_device() const
{
- const int index = _device_selector.currentIndex();
+ const int index = device_selector_.currentIndex();
if (index < 0)
return shared_ptr<Device>();
- return _device_selector.itemData(index).value<shared_ptr<Device>>();
+ return device_selector_.itemData(index).value<shared_ptr<Device>>();
}
void SamplingBar::set_capture_state(pv::SigSession::capture_state state)
{
- const QIcon *icons[] = {&_icon_grey, &_icon_red, &_icon_green};
- _run_stop_button.setIcon(*icons[state]);
- _run_stop_button.setText((state == pv::SigSession::Stopped) ?
+ const QIcon *icons[] = {&icon_grey_, &icon_red_, &icon_green_};
+ run_stop_button_.setIcon(*icons[state]);
+ run_stop_button_.setText((state == pv::SigSession::Stopped) ?
tr("Run") : tr("Stop"));
- _run_stop_button.setShortcut(QKeySequence(Qt::Key_Space));
+ run_stop_button_.setShortcut(QKeySequence(Qt::Key_Space));
}
void SamplingBar::update_sample_rate_selector()
const uint64_t *elements = NULL;
gsize num_elements;
- if (_updating_sample_rate)
+ if (updating_sample_rate_)
return;
const shared_ptr<Device> device = get_selected_device();
if (!device)
return;
- assert(!_updating_sample_rate);
- _updating_sample_rate = true;
+ assert(!updating_sample_rate_);
+ updating_sample_rate_ = true;
try {
gvar_dict = device->config_list(ConfigKey::SAMPLERATE);
} catch (Error error) {
- _sample_rate.show_none();
- _updating_sample_rate = false;
+ sample_rate_.show_none();
+ updating_sample_rate_ = false;
return;
}
assert(step > 0);
if (step == 1)
- _sample_rate.show_125_list(min, max);
+ sample_rate_.show_125_list(min, max);
else
{
// When the step is not 1, we cam't make a 1-2-5-10
// list of sample rates, because we may not be able to
// make round numbers. Therefore in this case, show a
// spin box.
- _sample_rate.show_min_max_step(min, max, step);
+ sample_rate_.show_min_max_step(min, max, step);
}
}
else if ((gvar_list = g_variant_lookup_value(gvar_dict.gobj(),
{
elements = (const uint64_t *)g_variant_get_fixed_array(
gvar_list, &num_elements, sizeof(uint64_t));
- _sample_rate.show_list(elements, num_elements);
+ sample_rate_.show_list(elements, num_elements);
g_variant_unref(gvar_list);
}
- _updating_sample_rate = false;
+ updating_sample_rate_ = false;
update_sample_rate_selector_value();
}
void SamplingBar::update_sample_rate_selector_value()
{
- if (_updating_sample_rate)
+ if (updating_sample_rate_)
return;
const shared_ptr<Device> device = get_selected_device();
auto gvar = device->config_get(ConfigKey::SAMPLERATE);
uint64_t samplerate =
Glib::VariantBase::cast_dynamic<Glib::Variant<guint64>>(gvar).get();
- assert(!_updating_sample_rate);
- _updating_sample_rate = true;
- _sample_rate.set_value(samplerate);
- _updating_sample_rate = false;
+ assert(!updating_sample_rate_);
+ updating_sample_rate_ = true;
+ sample_rate_.set_value(samplerate);
+ updating_sample_rate_ = false;
} catch (Error error) {
qDebug() << "WARNING: Failed to get value of sample rate";
return;
void SamplingBar::update_sample_count_selector()
{
- if (_updating_sample_count)
+ if (updating_sample_count_)
return;
const shared_ptr<Device> device = get_selected_device();
if (!device)
return;
- assert(!_updating_sample_count);
- _updating_sample_count = true;
+ assert(!updating_sample_count_);
+ updating_sample_count_ = true;
- if (_sample_count_supported)
+ if (sample_count_supported_)
{
- uint64_t sample_count = _sample_count.value();
+ uint64_t sample_count = sample_count_.value();
uint64_t min_sample_count = 0;
uint64_t max_sample_count = MaxSampleCount;
min_sample_count = min(max(min_sample_count, MinSampleCount),
max_sample_count);
- _sample_count.show_125_list(
+ sample_count_.show_125_list(
min_sample_count, max_sample_count);
try {
max_sample_count);
} catch (Error error) {}
- _sample_count.set_value(sample_count);
+ sample_count_.set_value(sample_count);
}
else
- _sample_count.show_none();
+ sample_count_.show_none();
- _updating_sample_count = false;
+ updating_sample_count_ = false;
}
void SamplingBar::update_device_config_widgets()
// Update the configure popup
DeviceOptions *const opts = new DeviceOptions(device, this);
- _configure_button_action->setVisible(
+ configure_button_action_->setVisible(
!opts->binding().properties().empty());
- _configure_button.set_popup(opts);
+ configure_button_.set_popup(opts);
// Update the channels popup
- Channels *const channels = new Channels(_session, this);
- _channels_button.set_popup(channels);
+ Channels *const channels = new Channels(session_, this);
+ channels_button_.set_popup(channels);
// Update supported options.
- _sample_count_supported = false;
+ sample_count_supported_ = false;
try {
for (auto entry : device->config_keys(ConfigKey::DEVICE_OPTIONS))
switch (key->id()) {
case SR_CONF_LIMIT_SAMPLES:
if (capabilities.count(Capability::SET))
- _sample_count_supported = true;
+ sample_count_supported_ = true;
break;
case SR_CONF_LIMIT_FRAMES:
if (capabilities.count(Capability::SET))
{
uint64_t sample_count = 0;
- if (_updating_sample_count)
+ if (updating_sample_count_)
return;
const shared_ptr<Device> device = get_selected_device();
if (!device)
return;
- sample_count = _sample_count.value();
+ sample_count = sample_count_.value();
// Set the sample count
- assert(!_updating_sample_count);
- _updating_sample_count = true;
- if (_sample_count_supported)
+ assert(!updating_sample_count_);
+ updating_sample_count_ = true;
+ if (sample_count_supported_)
{
try {
device->config_set(ConfigKey::LIMIT_SAMPLES,
return;
}
}
- _updating_sample_count = false;
+ updating_sample_count_ = false;
}
void SamplingBar::commit_sample_rate()
{
uint64_t sample_rate = 0;
- if (_updating_sample_rate)
+ if (updating_sample_rate_)
return;
const shared_ptr<Device> device = get_selected_device();
if (!device)
return;
- sample_rate = _sample_rate.value();
+ sample_rate = sample_rate_.value();
if (sample_rate == 0)
return;
// Set the samplerate
- assert(!_updating_sample_rate);
- _updating_sample_rate = true;
+ assert(!updating_sample_rate_);
+ updating_sample_rate_ = true;
try {
device->config_set(ConfigKey::SAMPLERATE,
Glib::Variant<guint64>::create(sample_rate));
qDebug() << "Failed to configure samplerate.";
return;
}
- _updating_sample_rate = false;
+ updating_sample_rate_ = false;
}
void SamplingBar::on_device_selected()
{
- if (_updating_device_selector)
+ if (updating_device_selector_)
return;
shared_ptr<Device> device = get_selected_device();
if (!device)
return;
- _session.set_device(device);
+ session_.set_device(device);
update_device_config_widgets();
}
bool SamplingBar::eventFilter(QObject *watched, QEvent *event)
{
- if ((watched == &_sample_count || watched == &_sample_rate) &&
+ if ((watched == &sample_count_ || watched == &sample_rate_) &&
(event->type() == QEvent::ToolTip)) {
- double sec = (double)_sample_count.value() / _sample_rate.value();
+ double sec = (double)sample_count_.value() / sample_rate_.value();
QHelpEvent *help_event = static_cast<QHelpEvent*>(event);
QString str = tr("Total sampling time: %1").arg(pv::util::format_second(sec));
bool eventFilter(QObject *watched, QEvent *event);
private:
- SigSession &_session;
+ SigSession &session_;
- QComboBox _device_selector;
- bool _updating_device_selector;
+ QComboBox device_selector_;
+ bool updating_device_selector_;
- pv::widgets::PopupToolButton _configure_button;
- QAction *_configure_button_action;
+ pv::widgets::PopupToolButton configure_button_;
+ QAction *configure_button_action_;
- pv::widgets::PopupToolButton _channels_button;
+ pv::widgets::PopupToolButton channels_button_;
- pv::widgets::SweepTimingWidget _sample_count;
- pv::widgets::SweepTimingWidget _sample_rate;
- bool _updating_sample_rate;
- bool _updating_sample_count;
+ pv::widgets::SweepTimingWidget sample_count_;
+ pv::widgets::SweepTimingWidget sample_rate_;
+ bool updating_sample_rate_;
+ bool updating_sample_count_;
- bool _sample_count_supported;
+ bool sample_count_supported_;
- QIcon _icon_red;
- QIcon _icon_green;
- QIcon _icon_grey;
- QToolButton _run_stop_button;
+ QIcon icon_red_;
+ QIcon icon_green_;
+ QIcon icon_grey_;
+ QToolButton run_stop_button_;
};
} // namespace toolbars
shared_ptr<Channel> channel,
shared_ptr<data::Analog> data) :
Signal(session, channel),
- _data(data),
- _scale(1.0f)
+ data_(data),
+ scale_(1.0f)
{
- _colour = SignalColours[_channel->index() % countof(SignalColours)];
+ colour_ = SignalColours[channel_->index() % countof(SignalColours)];
}
AnalogSignal::~AnalogSignal()
shared_ptr<pv::data::SignalData> AnalogSignal::data() const
{
- return _data;
+ return data_;
}
shared_ptr<pv::data::Analog> AnalogSignal::analog_data() const
{
- return _data;
+ return data_;
}
void AnalogSignal::set_scale(float scale)
{
- _scale = scale;
+ scale_ = scale;
}
std::pair<int, int> AnalogSignal::v_extents() const
void AnalogSignal::paint_back(QPainter &p, int left, int right)
{
- if (_channel->enabled())
+ if (channel_->enabled())
paint_axis(p, get_visual_y(), left, right);
}
void AnalogSignal::paint_mid(QPainter &p, int left, int right)
{
- assert(_data);
+ assert(data_);
assert(right >= left);
- assert(_owner);
+ assert(owner_);
const int y = get_visual_y();
- const View *const view = _owner->view();
+ const View *const view = owner_->view();
assert(view);
const double scale = view->scale();
const double offset = view->offset();
- if (!_channel->enabled())
+ if (!channel_->enabled())
return;
const deque< shared_ptr<pv::data::AnalogSnapshot> > &snapshots =
- _data->get_snapshots();
+ data_->get_snapshots();
if (snapshots.empty())
return;
snapshots.front();
const double pixels_offset = offset / scale;
- const double samplerate = _data->samplerate();
- const double start_time = _data->get_start_time();
+ const double samplerate = data_->samplerate();
+ const double start_time = data_->get_start_time();
const int64_t last_sample = snapshot->get_sample_count() - 1;
const double samples_per_pixel = samplerate * scale;
const double start = samplerate * (offset - start_time);
const float *const samples = snapshot->get_samples(start, end);
assert(samples);
- p.setPen(_colour);
+ p.setPen(colour_);
QPointF *points = new QPointF[sample_count];
QPointF *point = points;
const float x = (sample / samples_per_pixel -
pixels_offset) + left;
*point++ = QPointF(x,
- y - samples[sample - start] * _scale);
+ y - samples[sample - start] * scale_);
}
p.drawPolyline(points, point - points);
return;
p.setPen(QPen(Qt::NoPen));
- p.setBrush(_colour);
+ p.setBrush(colour_);
QRectF *const rects = new QRectF[e.length];
QRectF *rect = rects;
// We overlap this sample with the next so that vertical
// gaps do not appear during steep rising or falling edges
- const float b = y - max(s->max, (s+1)->min) * _scale;
- const float t = y - min(s->min, (s+1)->max) * _scale;
+ const float b = y - max(s->max, (s+1)->min) * scale_;
+ const float t = y - min(s->min, (s+1)->max) * scale_;
float h = b - t;
if(h >= 0.0f && h <= 1.0f)
const double pixels_offset, const double samples_per_pixel);
private:
- std::shared_ptr<pv::data::Analog> _data;
- float _scale;
+ std::shared_ptr<pv::data::Analog> data_;
+ float scale_;
};
} // namespace view
const shared_ptr<Cursor> other(get_other_cursor());
assert(other);
- const float x = (_time - _view.offset()) / _view.scale();
+ const float x = (time_ - view_.offset()) / view_.scale();
const QSizeF label_size(
- _text_size.width() + View::LabelPadding.width() * 2,
- _text_size.height() + View::LabelPadding.height() * 2);
+ text_size_.width() + View::LabelPadding.width() * 2,
+ text_size_.height() + View::LabelPadding.height() * 2);
const float top = rect.height() - label_size.height() -
Cursor::Offset - Cursor::ArrowSize - 0.5f;
const float height = label_size.height();
- if (_time > other->time())
+ if (time_ > other->time())
return QRectF(x, top, label_size.width(), height);
else
return QRectF(x - label_size.width(), top,
QPointF(r.right() - 1, rect.bottom() - 1),
};
- const QPointF *const points = (_time > other->time()) ?
+ const QPointF *const points = (time_ > other->time()) ?
left_points : right_points;
- const QPointF *const highlight_points = (_time > other->time()) ?
+ const QPointF *const highlight_points = (time_ > other->time()) ?
left_highlight_points : right_highlight_points;
if (selected()) {
p.setPen(TextColour);
p.drawText(r, Qt::AlignCenter | Qt::AlignVCenter,
- pv::util::format_time(_time, prefix, 2));
+ pv::util::format_time(time_, prefix, 2));
}
void Cursor::compute_text_size(QPainter &p, unsigned int prefix)
{
- _text_size = p.boundingRect(QRectF(), 0,
- pv::util::format_time(_time, prefix, 2)).size();
+ text_size_ = p.boundingRect(QRectF(), 0,
+ pv::util::format_time(time_, prefix, 2)).size();
}
shared_ptr<Cursor> Cursor::get_other_cursor() const
{
- const CursorPair &cursors = _view.cursors();
+ const CursorPair &cursors = view_.cursors();
return (cursors.first().get() == this) ?
cursors.second() : cursors.first();
}
std::shared_ptr<Cursor> get_other_cursor() const;
private:
- QSizeF _text_size;
+ QSizeF text_size_;
};
} // namespace view
CursorHeader::CursorHeader(View &parent) :
MarginWidget(parent),
- _dragging(false),
- _textHeight(calculateTextHeight())
+ dragging_(false),
+ textHeight_(calculateTextHeight())
{
setMouseTracking(true);
}
QSize CursorHeader::sizeHint() const
{
- return QSize(0, _textHeight + Padding + BaselineOffset);
+ return QSize(0, textHeight_ + Padding + BaselineOffset);
}
void CursorHeader::clear_selection()
{
- CursorPair &cursors = _view.cursors();
+ CursorPair &cursors = view_.cursors();
cursors.first()->select(false);
cursors.second()->select(false);
update();
p.setRenderHint(QPainter::Antialiasing);
unsigned int prefix = pv::view::Ruler::calculate_tick_spacing(
- p, _view.scale(), _view.offset()).second;
+ p, view_.scale(), view_.offset()).second;
// Draw the cursors
- if (_view.cursors_shown()) {
+ if (view_.cursors_shown()) {
// The cursor labels are not drawn with the arrows exactly on the
// bottom line of the widget, because then the selection shadow
// would be clipped away.
const QRect r = rect().adjusted(0, 0, 0, -BaselineOffset);
- _view.cursors().draw_markers(p, r, prefix);
+ view_.cursors().draw_markers(p, r, prefix);
}
}
if (!(e->buttons() & Qt::LeftButton))
return;
- if ((e->pos() - _mouse_down_point).manhattanLength() <
+ if ((e->pos() - mouse_down_point_).manhattanLength() <
QApplication::startDragDistance())
return;
- _dragging = true;
+ dragging_ = true;
- if (shared_ptr<TimeMarker> m = _grabbed_marker.lock())
- m->set_time(_view.offset() +
- ((double)e->x() + 0.5) * _view.scale());
+ if (shared_ptr<TimeMarker> m = grabbed_marker_.lock())
+ m->set_time(view_.offset() +
+ ((double)e->x() + 0.5) * view_.scale());
}
void CursorHeader::mousePressEvent(QMouseEvent *e)
{
if (e->buttons() & Qt::LeftButton) {
- _mouse_down_point = e->pos();
+ mouse_down_point_ = e->pos();
- _grabbed_marker.reset();
+ grabbed_marker_.reset();
clear_selection();
- if (_view.cursors_shown()) {
- CursorPair &cursors = _view.cursors();
+ if (view_.cursors_shown()) {
+ CursorPair &cursors = view_.cursors();
if (cursors.first()->get_label_rect(
rect()).contains(e->pos()))
- _grabbed_marker = cursors.first();
+ grabbed_marker_ = cursors.first();
else if (cursors.second()->get_label_rect(
rect()).contains(e->pos()))
- _grabbed_marker = cursors.second();
+ grabbed_marker_ = cursors.second();
}
- if (shared_ptr<TimeMarker> m = _grabbed_marker.lock())
+ if (shared_ptr<TimeMarker> m = grabbed_marker_.lock())
m->select();
selection_changed();
{
using pv::widgets::Popup;
- if (!_dragging)
- if (shared_ptr<TimeMarker> m = _grabbed_marker.lock()) {
- Popup *const p = m->create_popup(&_view);
+ if (!dragging_)
+ if (shared_ptr<TimeMarker> m = grabbed_marker_.lock()) {
+ Popup *const p = m->create_popup(&view_);
const QPoint arrpos(m->get_x(), height() - BaselineOffset);
p->set_position(mapToGlobal(arrpos), Popup::Bottom);
p->show();
}
- _dragging = false;
- _grabbed_marker.reset();
+ dragging_ = false;
+ grabbed_marker_.reset();
}
} // namespace view
int calculateTextHeight();
- std::weak_ptr<TimeMarker> _grabbed_marker;
- QPoint _mouse_down_point;
- bool _dragging;
- const int _textHeight;
+ std::weak_ptr<TimeMarker> grabbed_marker_;
+ QPoint mouse_down_point_;
+ bool dragging_;
+ const int textHeight_;
};
} // namespace view
const int CursorPair::DeltaPadding = 8;
CursorPair::CursorPair(View &view) :
- _first(new Cursor(view, 0.0)),
- _second(new Cursor(view, 1.0)),
- _view(view)
+ first_(new Cursor(view, 0.0)),
+ second_(new Cursor(view, 1.0)),
+ view_(view)
{
}
shared_ptr<Cursor> CursorPair::first() const
{
- return _first;
+ return first_;
}
shared_ptr<Cursor> CursorPair::second() const
{
- return _second;
+ return second_;
}
QRectF CursorPair::get_label_rect(const QRect &rect) const
{
const QSizeF label_size(
- _text_size.width() + View::LabelPadding.width() * 2,
- _text_size.height() + View::LabelPadding.height() * 2);
+ text_size_.width() + View::LabelPadding.width() * 2,
+ text_size_.height() + View::LabelPadding.height() * 2);
const pair<float, float> offsets(get_cursor_offsets());
const pair<float, float> normal_offsets(
(offsets.first < offsets.second) ? offsets :
void CursorPair::draw_markers(QPainter &p,
const QRect &rect, unsigned int prefix)
{
- assert(_first);
- assert(_second);
+ assert(first_);
+ assert(second_);
compute_text_size(p, prefix);
QRectF delta_rect(get_label_rect(rect));
const int radius = delta_rect.height() / 2;
const QRectF text_rect(delta_rect.intersected(
rect).adjusted(radius, 0, -radius, 0));
- if(text_rect.width() >= _text_size.width())
+ if(text_rect.width() >= text_size_.width())
{
const int highlight_radius = delta_rect.height() / 2 - 2;
p.setPen(Cursor::TextColour);
p.drawText(text_rect, Qt::AlignCenter | Qt::AlignVCenter,
- pv::util::format_time(_second->time() - _first->time(), prefix, 2));
+ pv::util::format_time(second_->time() - first_->time(), prefix, 2));
}
// Paint the cursor markers
- _first->paint_label(p, rect, prefix);
- _second->paint_label(p, rect, prefix);
+ first_->paint_label(p, rect, prefix);
+ second_->paint_label(p, rect, prefix);
}
void CursorPair::draw_viewport_background(QPainter &p,
void CursorPair::draw_viewport_foreground(QPainter &p,
const QRect &rect)
{
- assert(_first);
- assert(_second);
+ assert(first_);
+ assert(second_);
- _first->paint(p, rect);
- _second->paint(p, rect);
+ first_->paint(p, rect);
+ second_->paint(p, rect);
}
void CursorPair::compute_text_size(QPainter &p, unsigned int prefix)
{
- assert(_first);
- assert(_second);
+ assert(first_);
+ assert(second_);
- _text_size = p.boundingRect(QRectF(), 0, pv::util::format_time(
- _second->time() - _first->time(), prefix, 2)).size();
+ text_size_ = p.boundingRect(QRectF(), 0, pv::util::format_time(
+ second_->time() - first_->time(), prefix, 2)).size();
}
pair<float, float> CursorPair::get_cursor_offsets() const
{
- assert(_first);
- assert(_second);
+ assert(first_);
+ assert(second_);
return pair<float, float>(
- (_first->time() - _view.offset()) / _view.scale(),
- (_second->time() - _view.offset()) / _view.scale());
+ (first_->time() - view_.offset()) / view_.scale(),
+ (second_->time() - view_.offset()) / view_.scale());
}
} // namespace view
std::pair<float, float> get_cursor_offsets() const;
private:
- std::shared_ptr<Cursor> _first, _second;
- const View &_view;
+ std::shared_ptr<Cursor> first_, second_;
+ const View &view_;
- QSizeF _text_size;
+ QSizeF text_size_;
};
} // namespace view
std::shared_ptr<pv::data::DecoderStack> decoder_stack, int index) :
Trace(QString::fromUtf8(
decoder_stack->stack().front()->decoder()->name)),
- _session(session),
- _decoder_stack(decoder_stack),
- _text_height(0),
- _row_height(0),
- _delete_mapper(this),
- _show_hide_mapper(this)
+ session_(session),
+ decoder_stack_(decoder_stack),
+ text_height_(0),
+ row_height_(0),
+ delete_mapper_(this),
+ show_hide_mapper_(this)
{
- assert(_decoder_stack);
+ assert(decoder_stack_);
- _colour = DecodeColours[index % countof(DecodeColours)];
+ colour_ = DecodeColours[index % countof(DecodeColours)];
- connect(_decoder_stack.get(), SIGNAL(new_decode_data()),
+ connect(decoder_stack_.get(), SIGNAL(new_decode_data()),
this, SLOT(on_new_decode_data()));
- connect(&_delete_mapper, SIGNAL(mapped(int)),
+ connect(&delete_mapper_, SIGNAL(mapped(int)),
this, SLOT(on_delete_decoder(int)));
- connect(&_show_hide_mapper, SIGNAL(mapped(int)),
+ connect(&show_hide_mapper_, SIGNAL(mapped(int)),
this, SLOT(on_show_hide_decoder(int)));
}
const std::shared_ptr<pv::data::DecoderStack>& DecodeTrace::decoder() const
{
- return _decoder_stack;
+ return decoder_stack_;
}
pair<int, int> DecodeTrace::v_extents() const
using namespace pv::data::decode;
QFontMetrics m(QApplication::font());
- _text_height = m.boundingRect(QRect(), 0, "Tg").height();
- _row_height = (_text_height * 6) / 4;
- const int annotation_height = (_text_height * 5) / 4;
+ text_height_ = m.boundingRect(QRect(), 0, "Tg").height();
+ row_height_ = (text_height_ * 6) / 4;
+ const int annotation_height = (text_height_ * 5) / 4;
- assert(_decoder_stack);
- const QString err = _decoder_stack->error_message();
+ assert(decoder_stack_);
+ const QString err = decoder_stack_->error_message();
if (!err.isEmpty())
{
draw_unresolved_period(p, annotation_height, left, right);
int y = get_visual_y();
pair<uint64_t, uint64_t> sample_range = get_sample_range(left, right);
- assert(_decoder_stack);
- const vector<Row> rows(_decoder_stack->get_visible_rows());
+ assert(decoder_stack_);
+ const vector<Row> rows(decoder_stack_->get_visible_rows());
- _visible_rows.clear();
+ visible_rows_.clear();
for (size_t i = 0; i < rows.size(); i++)
{
const Row &row = rows[i];
base_colour >>= 16;
vector<Annotation> annotations;
- _decoder_stack->get_annotation_subset(annotations, row,
+ decoder_stack_->get_annotation_subset(annotations, row,
sample_range.first, sample_range.second);
if (!annotations.empty()) {
for (const Annotation &a : annotations)
draw_annotation(a, p, get_text_colour(),
annotation_height, left, right, y,
base_colour);
- y += _row_height;
+ y += row_height_;
- _visible_rows.push_back(rows[i]);
+ visible_rows_.push_back(rows[i]);
}
}
(void)right;
- assert(_row_height);
+ assert(row_height_);
- for (size_t i = 0; i < _visible_rows.size(); i++)
+ for (size_t i = 0; i < visible_rows_.size(); i++)
{
- const int y = i * _row_height + get_visual_y();
+ const int y = i * row_height_ + get_visual_y();
p.setPen(QPen(Qt::NoPen));
p.setBrush(QApplication::palette().brush(QPalette::WindowText));
p.drawPolygon(points, countof(points));
}
- const QRect r(left + ArrowSize * 2, y - _row_height / 2,
- right - left, _row_height);
- const QString h(_visible_rows[i].title());
+ const QRect r(left + ArrowSize * 2, y - row_height_ / 2,
+ right - left, row_height_);
+ const QString h(visible_rows_[i].title());
const int f = Qt::AlignLeft | Qt::AlignVCenter |
Qt::TextDontClip;
assert(form);
assert(parent);
- assert(_decoder_stack);
+ assert(decoder_stack_);
// Add the standard options
Trace::populate_popup_form(parent, form);
// Add the decoder options
- _bindings.clear();
- _channel_selectors.clear();
- _decoder_forms.clear();
+ bindings_.clear();
+ channel_selectors_.clear();
+ decoder_forms_.clear();
- const list< shared_ptr<Decoder> >& stack = _decoder_stack->stack();
+ const list< shared_ptr<Decoder> >& stack = decoder_stack_->stack();
if (stack.empty())
{
double samples_per_pixel, pixels_offset;
- assert(_decoder_stack);
+ assert(decoder_stack_);
shared_ptr<Logic> data;
shared_ptr<LogicSignal> logic_signal;
- const list< shared_ptr<Decoder> > &stack = _decoder_stack->stack();
+ const list< shared_ptr<Decoder> > &stack = decoder_stack_->stack();
// We get the logic data of the first channel in the list.
// This works because we are currently assuming all
if (sample_count == 0)
return;
- const int64_t samples_decoded = _decoder_stack->samples_decoded();
+ const int64_t samples_decoded = decoder_stack_->samples_decoded();
if (sample_count == samples_decoded)
return;
pair<double, double> DecodeTrace::get_pixels_offset_samples_per_pixel() const
{
- assert(_owner);
- assert(_decoder_stack);
+ assert(owner_);
+ assert(decoder_stack_);
- const View *view = _owner->view();
+ const View *view = owner_->view();
assert(view);
const double scale = view->scale();
assert(scale > 0);
const double pixels_offset =
- (view->offset() - _decoder_stack->get_start_time()) / scale;
+ (view->offset() - decoder_stack_->get_start_time()) / scale;
- double samplerate = _decoder_stack->samplerate();
+ double samplerate = decoder_stack_->samplerate();
// Show sample rate as 1Hz when it is unknown
if (samplerate == 0.0)
int DecodeTrace::get_row_at_point(const QPoint &point)
{
- if (!_row_height)
+ if (!row_height_)
return -1;
- const int row = (point.y() - get_visual_y() + _row_height / 2) /
- _row_height;
- if (row < 0 || row >= (int)_visible_rows.size())
+ const int row = (point.y() - get_visual_y() + row_height_ / 2) /
+ row_height_;
+ if (row < 0 || row >= (int)visible_rows_.size())
return -1;
return row;
vector<pv::data::decode::Annotation> annotations;
- assert(_decoder_stack);
- _decoder_stack->get_annotation_subset(annotations, _visible_rows[row],
+ assert(decoder_stack_);
+ decoder_stack_->get_annotation_subset(annotations, visible_rows_[row],
sample_range.first, sample_range.second);
return (annotations.empty()) ?
void DecodeTrace::hover_point_changed()
{
- assert(_owner);
+ assert(owner_);
- const View *const view = _owner->view();
+ const View *const view = owner_->view();
assert(view);
QPoint hp = view->hover_point();
QString ann = get_annotation_at_point(hp);
assert(view);
- assert(_row_height);
+ assert(row_height_);
if (ann.isEmpty()) {
hide_hover_annotation();
// decode trace, not below.
hp.setX(hp.x() - (text_size.width() / 2) - padding);
- hp.setY(get_visual_y() - (_row_height / 2) +
- (hover_row * _row_height) -
- _row_height - text_size.height());
+ hp.setY(get_visual_y() - (row_height_ / 2) +
+ (hover_row * row_height_) -
+ row_height_ - text_size.height());
QToolTip::showText(view->viewport()->mapToGlobal(hp), ann);
}
QString::fromUtf8(decoder->name));
group->set_decoder_visible(dec->shown());
- _delete_mapper.setMapping(group, index);
- connect(group, SIGNAL(delete_decoder()), &_delete_mapper, SLOT(map()));
+ delete_mapper_.setMapping(group, index);
+ connect(group, SIGNAL(delete_decoder()), &delete_mapper_, SLOT(map()));
- _show_hide_mapper.setMapping(group, index);
+ show_hide_mapper_.setMapping(group, index);
connect(group, SIGNAL(show_hide_decoder()),
- &_show_hide_mapper, SLOT(map()));
+ &show_hide_mapper_, SLOT(map()));
QFormLayout *const decoder_form = new QFormLayout;
group->add_layout(decoder_form);
.arg(QString::fromUtf8(pdch->desc)), combo);
const ChannelSelector s = {combo, dec, pdch};
- _channel_selectors.push_back(s);
+ channel_selectors_.push_back(s);
}
// Add the optional channels
.arg(QString::fromUtf8(pdch->desc)), combo);
const ChannelSelector s = {combo, dec, pdch};
- _channel_selectors.push_back(s);
+ channel_selectors_.push_back(s);
}
// Add the options
shared_ptr<prop::binding::DecoderOptions> binding(
- new prop::binding::DecoderOptions(_decoder_stack, dec));
+ new prop::binding::DecoderOptions(decoder_stack_, dec));
binding->add_properties_to_form(decoder_form, true);
- _bindings.push_back(binding);
+ bindings_.push_back(binding);
form->addRow(group);
- _decoder_forms.push_back(group);
+ decoder_forms_.push_back(group);
}
QComboBox* DecodeTrace::create_channel_selector(
{
assert(dec);
- shared_lock<shared_mutex> lock(_session.signals_mutex());
- const vector< shared_ptr<Signal> > &sigs(_session.signals());
+ shared_lock<shared_mutex> lock(session_.signals_mutex());
+ const vector< shared_ptr<Signal> > &sigs(session_.signals());
- assert(_decoder_stack);
+ assert(decoder_stack_);
const auto channel_iter = dec->channels().find(pdch);
QComboBox *selector = new QComboBox(parent);
map<const srd_channel*, shared_ptr<LogicSignal> > channel_map;
- shared_lock<shared_mutex> lock(_session.signals_mutex());
- const vector< shared_ptr<Signal> > &sigs(_session.signals());
+ shared_lock<shared_mutex> lock(session_.signals_mutex());
+ const vector< shared_ptr<Signal> > &sigs(session_.signals());
- for (const ChannelSelector &s : _channel_selectors)
+ for (const ChannelSelector &s : channel_selectors_)
{
- if(s._decoder != dec)
+ if(s.decoder_ != dec)
break;
const LogicSignal *const selection =
- (LogicSignal*)s._combo->itemData(
- s._combo->currentIndex()).value<void*>();
+ (LogicSignal*)s.combo_->itemData(
+ s.combo_->currentIndex()).value<void*>();
for (shared_ptr<Signal> sig : sigs)
if(sig.get() == selection) {
- channel_map[s._pdch] =
+ channel_map[s.pdch_] =
dynamic_pointer_cast<LogicSignal>(sig);
break;
}
void DecodeTrace::commit_channels()
{
- assert(_decoder_stack);
- for (shared_ptr<data::decode::Decoder> dec : _decoder_stack->stack())
+ assert(decoder_stack_);
+ for (shared_ptr<data::decode::Decoder> dec : decoder_stack_->stack())
commit_decoder_channels(dec);
- _decoder_stack->begin_decode();
+ decoder_stack_->begin_decode();
}
void DecodeTrace::on_new_decode_data()
{
- if (_owner)
- _owner->appearance_changed(false, true);
+ if (owner_)
+ owner_->appearance_changed(false, true);
}
void DecodeTrace::delete_pressed()
void DecodeTrace::on_delete()
{
- _session.remove_decode_signal(this);
+ session_.remove_decode_signal(this);
}
void DecodeTrace::on_channel_selected(int)
void DecodeTrace::on_stack_decoder(srd_decoder *decoder)
{
assert(decoder);
- assert(_decoder_stack);
- _decoder_stack->push(shared_ptr<data::decode::Decoder>(
+ assert(decoder_stack_);
+ decoder_stack_->push(shared_ptr<data::decode::Decoder>(
new data::decode::Decoder(decoder)));
- _decoder_stack->begin_decode();
+ decoder_stack_->begin_decode();
create_popup_form();
}
void DecodeTrace::on_delete_decoder(int index)
{
- _decoder_stack->remove(index);
+ decoder_stack_->remove(index);
// Update the popup
create_popup_form();
- _decoder_stack->begin_decode();
+ decoder_stack_->begin_decode();
}
void DecodeTrace::on_show_hide_decoder(int index)
{
using pv::data::decode::Decoder;
- const list< shared_ptr<Decoder> > stack(_decoder_stack->stack());
+ const list< shared_ptr<Decoder> > stack(decoder_stack_->stack());
// Find the decoder in the stack
auto iter = stack.cbegin();
const bool show = !dec->shown();
dec->show(show);
- assert(index < (int)_decoder_forms.size());
- _decoder_forms[index]->set_decoder_visible(show);
+ assert(index < (int)decoder_forms_.size());
+ decoder_forms_[index]->set_decoder_visible(show);
- if (_owner)
- _owner->appearance_changed(false, true);
+ if (owner_)
+ owner_->appearance_changed(false, true);
}
} // namespace view
private:
struct ChannelSelector
{
- const QComboBox *_combo;
- const std::shared_ptr<pv::data::decode::Decoder> _decoder;
- const srd_channel *_pdch;
+ const QComboBox *combo_;
+ const std::shared_ptr<pv::data::decode::Decoder> decoder_;
+ const srd_channel *pdch_;
};
private:
void on_show_hide_decoder(int index);
private:
- pv::SigSession &_session;
- std::shared_ptr<pv::data::DecoderStack> _decoder_stack;
+ pv::SigSession &session_;
+ std::shared_ptr<pv::data::DecoderStack> decoder_stack_;
- uint64_t _decode_start, _decode_end;
+ uint64_t decode_start_, decode_end_;
std::list< std::shared_ptr<pv::prop::binding::DecoderOptions> >
- _bindings;
+ bindings_;
- std::list<ChannelSelector> _channel_selectors;
- std::vector<pv::widgets::DecoderGroupBox*> _decoder_forms;
+ std::list<ChannelSelector> channel_selectors_;
+ std::vector<pv::widgets::DecoderGroupBox*> decoder_forms_;
- std::vector<data::decode::Row> _visible_rows;
- int _text_height, _row_height;
+ std::vector<data::decode::Row> visible_rows_;
+ int text_height_, row_height_;
- QSignalMapper _delete_mapper, _show_hide_mapper;
+ QSignalMapper delete_mapper_, show_hide_mapper_;
};
} // namespace view
Header::Header(View &parent) :
MarginWidget(parent),
- _dragging(false)
+ dragging_(false)
{
setFocusPolicy(Qt::ClickFocus);
setMouseTracking(true);
- connect(&_view, SIGNAL(signals_moved()),
+ connect(&view_, SIGNAL(signals_moved()),
this, SLOT(on_signals_moved()));
}
QSize Header::sizeHint() const
{
QRectF max_rect(-Padding, 0, Padding, 0);
- for (auto &i : _view)
+ for (auto &i : view_)
if (i->enabled())
max_rect = max_rect.united(i->label_rect(0));
return QSize(max_rect.width() + Padding + BaselineOffset, 0);
shared_ptr<RowItem> Header::get_mouse_over_row_item(const QPoint &pt)
{
const int w = width() - BaselineOffset;
- for (auto &i : _view)
+ for (auto &i : view_)
if (i->enabled() && i->label_rect(w).contains(pt))
return i;
return shared_ptr<RowItem>();
void Header::clear_selection()
{
- for (auto &i : _view)
+ for (auto &i : view_)
i->select(false);
update();
}
{
using pv::widgets::Popup;
- Popup *const p = item->create_popup(&_view);
+ Popup *const p = item->create_popup(&view_);
if (!p)
return;
const int w = width() - BaselineOffset;
vector< shared_ptr<RowItem> > row_items(
- _view.begin(), _view.end());
+ view_.begin(), view_.end());
stable_sort(row_items.begin(), row_items.end(),
[](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
{
assert(r);
- const bool highlight = !_dragging &&
- r->label_rect(w).contains(_mouse_point);
+ const bool highlight = !dragging_ &&
+ r->label_rect(w).contains(mouse_point_);
r->paint_label(painter, w, highlight);
}
QApplication::keyboardModifiers() & Qt::ControlModifier;
// Clear selection if control is not pressed and this item is unselected
- if ((!_mouse_down_item || !_mouse_down_item->selected()) &&
+ if ((!mouse_down_item_ || !mouse_down_item_->selected()) &&
!ctrl_pressed)
- for (shared_ptr<RowItem> r : _view)
+ for (shared_ptr<RowItem> r : view_)
r->select(false);
// Set the signal selection state if the item has been clicked
- if (_mouse_down_item) {
+ if (mouse_down_item_) {
if (ctrl_pressed)
- _mouse_down_item->select(!_mouse_down_item->selected());
+ mouse_down_item_->select(!mouse_down_item_->selected());
else
- _mouse_down_item->select(true);
+ mouse_down_item_->select(true);
}
// Save the offsets of any signals which will be dragged
- for (const shared_ptr<RowItem> r : _view)
+ for (const shared_ptr<RowItem> r : view_)
if (r->selected())
r->drag();
{
assert(event);
- _mouse_down_point = event->pos();
- _mouse_down_item = get_mouse_over_row_item(event->pos());
+ mouse_down_point_ = event->pos();
+ mouse_down_item_ = get_mouse_over_row_item(event->pos());
if (event->button() & Qt::LeftButton)
mouseLeftPressEvent(event);
const shared_ptr<RowItem> mouse_over =
get_mouse_over_row_item(event->pos());
- for (auto &r : _view)
+ for (auto &r : view_)
r->drag_release();
- if (_dragging)
- _view.restack_all_row_items();
+ if (dragging_)
+ view_.restack_all_row_items();
else
{
if (!ctrl_pressed) {
- for (shared_ptr<RowItem> r : _view)
- if (_mouse_down_item != r)
+ for (shared_ptr<RowItem> r : view_)
+ if (mouse_down_item_ != r)
r->select(false);
- if (_mouse_down_item)
- show_popup(_mouse_down_item);
+ if (mouse_down_item_)
+ show_popup(mouse_down_item_);
}
}
- _dragging = false;
+ dragging_ = false;
}
void Header::mouseReleaseEvent(QMouseEvent *event)
if (event->button() & Qt::LeftButton)
mouseLeftReleaseEvent(event);
- _mouse_down_item = nullptr;
+ mouse_down_item_ = nullptr;
}
void Header::mouseMoveEvent(QMouseEvent *event)
{
assert(event);
- _mouse_point = event->pos();
+ mouse_point_ = event->pos();
if (!(event->buttons() & Qt::LeftButton))
return;
- if ((event->pos() - _mouse_down_point).manhattanLength() <
+ if ((event->pos() - mouse_down_point_).manhattanLength() <
QApplication::startDragDistance())
return;
// Check all the drag items share a common owner
RowItemOwner *item_owner = nullptr;
- for (shared_ptr<RowItem> r : _view)
+ for (shared_ptr<RowItem> r : view_)
if (r->dragging()) {
if (!item_owner)
item_owner = r->owner();
return;
// Do the drag
- _dragging = true;
+ dragging_ = true;
- const int delta = event->pos().y() - _mouse_down_point.y();
+ const int delta = event->pos().y() - mouse_down_point_.y();
- for (std::shared_ptr<RowItem> r : _view)
+ for (std::shared_ptr<RowItem> r : view_)
if (r->dragging()) {
r->force_to_v_offset(r->drag_point().y() + delta);
void Header::leaveEvent(QEvent*)
{
- _mouse_point = QPoint(-1, -1);
+ mouse_point_ = QPoint(-1, -1);
update();
}
void Header::contextMenuEvent(QContextMenuEvent *event)
{
- const shared_ptr<RowItem> r = get_mouse_over_row_item(_mouse_point);
+ const shared_ptr<RowItem> r = get_mouse_over_row_item(mouse_point_);
if (!r)
return;
if (!menu)
menu = new QMenu(this);
- if (std::count_if(_view.begin(), _view.end(), item_selected) > 1)
+ if (std::count_if(view_.begin(), view_.end(), item_selected) > 1)
{
menu->addSeparator();
if (e->key() == Qt::Key_Delete)
{
- for (const shared_ptr<RowItem> r : _view)
+ for (const shared_ptr<RowItem> r : view_)
if (r->selected())
r->delete_pressed();
}
void Header::on_group()
{
vector< shared_ptr<RowItem> > selected_items(
- make_filter_iterator(item_selected, _view.begin(), _view.end()),
- make_filter_iterator(item_selected, _view.end(), _view.end()));
+ make_filter_iterator(item_selected, view_.begin(), view_.end()),
+ make_filter_iterator(item_selected, view_.end(), view_.end()));
stable_sort(selected_items.begin(), selected_items.end(),
[](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
return a->visual_v_offset() < b->visual_v_offset(); });
shared_ptr<TraceGroup> group(new TraceGroup());
shared_ptr<RowItem> focus_item(
- _mouse_down_item ? _mouse_down_item : selected_items.front());
+ mouse_down_item_ ? mouse_down_item_ : selected_items.front());
assert(focus_item);
assert(focus_item->owner());
bool restart;
do {
restart = false;
- for (const shared_ptr<RowItem> r : _view) {
+ for (const shared_ptr<RowItem> r : view_) {
const shared_ptr<TraceGroup> tg =
dynamic_pointer_cast<TraceGroup>(r);
if (tg && tg->selected()) {
void signals_moved();
private:
- QPoint _mouse_point;
- QPoint _mouse_down_point;
- std::shared_ptr<RowItem> _mouse_down_item;
- bool _dragging;
+ QPoint mouse_point_;
+ QPoint mouse_down_point_;
+ std::shared_ptr<RowItem> mouse_down_item_;
+ bool dragging_;
};
} // namespace view
shared_ptr<Channel> channel,
shared_ptr<data::Logic> data) :
Signal(session, channel),
- _device(device),
- _data(data),
- _trigger_none(NULL),
- _trigger_rising(NULL),
- _trigger_high(NULL),
- _trigger_falling(NULL),
- _trigger_low(NULL),
- _trigger_change(NULL)
+ device_(device),
+ data_(data),
+ trigger_none_(NULL),
+ trigger_rising_(NULL),
+ trigger_high_(NULL),
+ trigger_falling_(NULL),
+ trigger_low_(NULL),
+ trigger_change_(NULL)
{
shared_ptr<Trigger> trigger;
- _colour = SignalColours[channel->index() % countof(SignalColours)];
+ colour_ = SignalColours[channel->index() % countof(SignalColours)];
/* Populate this channel's trigger setting with whatever we
* find in the current session trigger, if anything. */
- _trigger_match = nullptr;
- if ((trigger = _session.session()->trigger()))
+ trigger_match_ = nullptr;
+ if ((trigger = session_.session()->trigger()))
for (auto stage : trigger->stages())
for (auto match : stage->matches())
- if (match->channel() == _channel)
- _trigger_match = match->type();
+ if (match->channel() == channel_)
+ trigger_match_ = match->type();
}
LogicSignal::~LogicSignal()
shared_ptr<pv::data::SignalData> LogicSignal::data() const
{
- return _data;
+ return data_;
}
shared_ptr<pv::data::Logic> LogicSignal::logic_data() const
{
- return _data;
+ return data_;
}
std::pair<int, int> LogicSignal::v_extents() const
void LogicSignal::paint_back(QPainter &p, int left, int right)
{
- if (_channel->enabled())
+ if (channel_->enabled())
paint_axis(p, get_visual_y(), left, right);
}
vector< pair<int64_t, bool> > edges;
- assert(_channel);
- assert(_data);
+ assert(channel_);
+ assert(data_);
assert(right >= left);
- assert(_owner);
+ assert(owner_);
const int y = get_visual_y();
- const View *const view = _owner->view();
+ const View *const view = owner_->view();
assert(view);
const double scale = view->scale();
const double offset = view->offset();
- if (!_channel->enabled())
+ if (!channel_->enabled())
return;
const float high_offset = y - SignalHeight + 0.5f;
const float low_offset = y + 0.5f;
const deque< shared_ptr<pv::data::LogicSnapshot> > &snapshots =
- _data->get_snapshots();
+ data_->get_snapshots();
if (snapshots.empty())
return;
const shared_ptr<pv::data::LogicSnapshot> &snapshot =
snapshots.front();
- double samplerate = _data->samplerate();
+ double samplerate = data_->samplerate();
// Show sample rate as 1Hz when it is unknown
if (samplerate == 0.0)
samplerate = 1.0;
const double pixels_offset = offset / scale;
- const double start_time = _data->get_start_time();
+ const double start_time = data_->get_start_time();
const int64_t last_sample = snapshot->get_sample_count() - 1;
const double samples_per_pixel = samplerate * scale;
const double start = samplerate * (offset - start_time);
snapshot->get_subsampled_edges(edges,
min(max((int64_t)floor(start), (int64_t)0), last_sample),
min(max((int64_t)ceil(end), (int64_t)0), last_sample),
- samples_per_pixel / Oversampling, _channel->index());
+ samples_per_pixel / Oversampling, channel_->index());
assert(edges.size() >= 2);
// Paint the edges
void LogicSignal::init_trigger_actions(QWidget *parent)
{
- _trigger_none = new QAction(QIcon(":/icons/trigger-none.svg"),
+ trigger_none_ = new QAction(QIcon(":/icons/trigger-none.svg"),
tr("No trigger"), parent);
- _trigger_none->setCheckable(true);
- connect(_trigger_none, SIGNAL(triggered()), this, SLOT(on_trigger()));
+ trigger_none_->setCheckable(true);
+ connect(trigger_none_, SIGNAL(triggered()), this, SLOT(on_trigger()));
- _trigger_rising = new QAction(QIcon(":/icons/trigger-rising.svg"),
+ trigger_rising_ = new QAction(QIcon(":/icons/trigger-rising.svg"),
tr("Trigger on rising edge"), parent);
- _trigger_rising->setCheckable(true);
- connect(_trigger_rising, SIGNAL(triggered()), this, SLOT(on_trigger()));
+ trigger_rising_->setCheckable(true);
+ connect(trigger_rising_, SIGNAL(triggered()), this, SLOT(on_trigger()));
- _trigger_high = new QAction(QIcon(":/icons/trigger-high.svg"),
+ trigger_high_ = new QAction(QIcon(":/icons/trigger-high.svg"),
tr("Trigger on high level"), parent);
- _trigger_high->setCheckable(true);
- connect(_trigger_high, SIGNAL(triggered()), this, SLOT(on_trigger()));
+ trigger_high_->setCheckable(true);
+ connect(trigger_high_, SIGNAL(triggered()), this, SLOT(on_trigger()));
- _trigger_falling = new QAction(QIcon(":/icons/trigger-falling.svg"),
+ trigger_falling_ = new QAction(QIcon(":/icons/trigger-falling.svg"),
tr("Trigger on falling edge"), parent);
- _trigger_falling->setCheckable(true);
- connect(_trigger_falling, SIGNAL(triggered()), this, SLOT(on_trigger()));
+ trigger_falling_->setCheckable(true);
+ connect(trigger_falling_, SIGNAL(triggered()), this, SLOT(on_trigger()));
- _trigger_low = new QAction(QIcon(":/icons/trigger-low.svg"),
+ trigger_low_ = new QAction(QIcon(":/icons/trigger-low.svg"),
tr("Trigger on low level"), parent);
- _trigger_low->setCheckable(true);
- connect(_trigger_low, SIGNAL(triggered()), this, SLOT(on_trigger()));
+ trigger_low_->setCheckable(true);
+ connect(trigger_low_, SIGNAL(triggered()), this, SLOT(on_trigger()));
- _trigger_change = new QAction(QIcon(":/icons/trigger-change.svg"),
+ trigger_change_ = new QAction(QIcon(":/icons/trigger-change.svg"),
tr("Trigger on rising or falling edge"), parent);
- _trigger_change->setCheckable(true);
- connect(_trigger_change, SIGNAL(triggered()), this, SLOT(on_trigger()));
+ trigger_change_->setCheckable(true);
+ connect(trigger_change_, SIGNAL(triggered()), this, SLOT(on_trigger()));
}
QAction* LogicSignal::match_action(const TriggerMatchType *type)
{
QAction *action;
- action = _trigger_none;
+ action = trigger_none_;
if (type) {
switch (type->id()) {
case SR_TRIGGER_ZERO:
- action = _trigger_low;
+ action = trigger_low_;
break;
case SR_TRIGGER_ONE:
- action = _trigger_high;
+ action = trigger_high_;
break;
case SR_TRIGGER_RISING:
- action = _trigger_rising;
+ action = trigger_rising_;
break;
case SR_TRIGGER_FALLING:
- action = _trigger_falling;
+ action = trigger_falling_;
break;
case SR_TRIGGER_EDGE:
- action = _trigger_change;
+ action = trigger_change_;
break;
default:
assert(0);
const TriggerMatchType *LogicSignal::action_match(QAction *action)
{
- if (action == _trigger_low)
+ if (action == trigger_low_)
return TriggerMatchType::ZERO;
- else if (action == _trigger_high)
+ else if (action == trigger_high_)
return TriggerMatchType::ONE;
- else if (action == _trigger_rising)
+ else if (action == trigger_rising_)
return TriggerMatchType::RISING;
- else if (action == _trigger_falling)
+ else if (action == trigger_falling_)
return TriggerMatchType::FALLING;
- else if (action == _trigger_change)
+ else if (action == trigger_change_)
return TriggerMatchType::EDGE;
else
return nullptr;
Signal::populate_popup_form(parent, form);
try {
- gvar = _device->config_list(ConfigKey::TRIGGER_MATCH);
+ gvar = device_->config_list(ConfigKey::TRIGGER_MATCH);
} catch (Error e) {
return;
}
- _trigger_bar = new QToolBar(parent);
- init_trigger_actions(_trigger_bar);
- _trigger_bar->addAction(_trigger_none);
- _trigger_none->setChecked(!_trigger_match);
+ trigger_bar_ = new QToolBar(parent);
+ init_trigger_actions(trigger_bar_);
+ trigger_bar_->addAction(trigger_none_);
+ trigger_none_->setChecked(!trigger_match_);
trig_types =
Glib::VariantBase::cast_dynamic<Glib::Variant<vector<int32_t>>>(
gvar).get();
for (auto type_id : trig_types) {
auto type = TriggerMatchType::get(type_id);
- _trigger_bar->addAction(match_action(type));
- match_action(type)->setChecked(_trigger_match == type);
+ trigger_bar_->addAction(match_action(type));
+ match_action(type)->setChecked(trigger_match_ == type);
}
- form->addRow(tr("Trigger"), _trigger_bar);
+ form->addRow(tr("Trigger"), trigger_bar_);
}
void LogicSignal::modify_trigger()
{
- auto trigger = _session.session()->trigger();
- auto new_trigger = _session.device_manager().context()->create_trigger("pulseview");
+ auto trigger = session_.session()->trigger();
+ auto new_trigger = session_.device_manager().context()->create_trigger("pulseview");
if (trigger) {
for (auto stage : trigger->stages()) {
const auto &matches = stage->matches();
if (std::none_of(begin(matches), end(matches),
[&](shared_ptr<TriggerMatch> match) {
- return match->channel() != _channel; }))
+ return match->channel() != channel_; }))
continue;
auto new_stage = new_trigger->add_stage();
for (auto match : stage->matches()) {
- if (match->channel() == _channel)
+ if (match->channel() == channel_)
continue;
new_stage->add_match(match->channel(), match->type());
}
}
}
- if (_trigger_match)
- new_trigger->add_stage()->add_match(_channel, _trigger_match);
+ if (trigger_match_)
+ new_trigger->add_stage()->add_match(channel_, trigger_match_);
- _session.session()->set_trigger(
+ session_.session()->set_trigger(
new_trigger->stages().empty() ? nullptr : new_trigger);
}
{
QAction *action;
- match_action(_trigger_match)->setChecked(false);
+ match_action(trigger_match_)->setChecked(false);
action = (QAction *)sender();
action->setChecked(true);
- _trigger_match = action_match(action);
+ trigger_match_ = action_match(action);
modify_trigger();
}
void on_trigger();
private:
- std::shared_ptr<sigrok::Device> _device;
- std::shared_ptr<pv::data::Logic> _data;
-
- const sigrok::TriggerMatchType *_trigger_match;
- QToolBar *_trigger_bar;
- QAction *_trigger_none;
- QAction *_trigger_rising;
- QAction *_trigger_high;
- QAction *_trigger_falling;
- QAction *_trigger_low;
- QAction *_trigger_change;
+ std::shared_ptr<sigrok::Device> device_;
+ std::shared_ptr<pv::data::Logic> data_;
+
+ const sigrok::TriggerMatchType *trigger_match_;
+ QToolBar *trigger_bar_;
+ QAction *trigger_none_;
+ QAction *trigger_rising_;
+ QAction *trigger_high_;
+ QAction *trigger_falling_;
+ QAction *trigger_low_;
+ QAction *trigger_change_;
};
} // namespace view
MarginWidget::MarginWidget(View &parent) :
QWidget(&parent),
- _view(parent)
+ view_(parent)
{
setAttribute(Qt::WA_NoSystemBackground, true);
}
void selection_changed();
protected:
- pv::view::View &_view;
+ pv::view::View &view_;
};
} // namespace view
namespace view {
RowItem::RowItem() :
- _owner(NULL),
- _layout_v_offset(0),
- _visual_v_offset(0),
- _v_offset_animation(this, "visual_v_offset")
+ owner_(NULL),
+ layout_v_offset_(0),
+ visual_v_offset_(0),
+ v_offset_animation_(this, "visual_v_offset")
{
}
int RowItem::layout_v_offset() const
{
- return _layout_v_offset;
+ return layout_v_offset_;
}
void RowItem::set_layout_v_offset(int v_offset)
{
- if (_layout_v_offset == v_offset)
+ if (layout_v_offset_ == v_offset)
return;
- _layout_v_offset = v_offset;
+ layout_v_offset_ = v_offset;
- if (_owner)
- _owner->extents_changed(false, true);
+ if (owner_)
+ owner_->extents_changed(false, true);
}
int RowItem::visual_v_offset() const
{
- return _visual_v_offset;
+ return visual_v_offset_;
}
void RowItem::set_visual_v_offset(int v_offset)
{
- _visual_v_offset = v_offset;
+ visual_v_offset_ = v_offset;
- if (_owner)
- _owner->appearance_changed(true, true);
+ if (owner_)
+ owner_->appearance_changed(true, true);
}
void RowItem::force_to_v_offset(int v_offset)
{
- _v_offset_animation.stop();
- _layout_v_offset = _visual_v_offset = v_offset;
+ v_offset_animation_.stop();
+ layout_v_offset_ = visual_v_offset_ = v_offset;
}
void RowItem::animate_to_layout_v_offset()
{
- if (_visual_v_offset == _layout_v_offset ||
- (_v_offset_animation.endValue() == _layout_v_offset &&
- _v_offset_animation.state() == QAbstractAnimation::Running))
+ if (visual_v_offset_ == layout_v_offset_ ||
+ (v_offset_animation_.endValue() == layout_v_offset_ &&
+ v_offset_animation_.state() == QAbstractAnimation::Running))
return;
- _v_offset_animation.setDuration(100);
- _v_offset_animation.setStartValue(_visual_v_offset);
- _v_offset_animation.setEndValue(_layout_v_offset);
- _v_offset_animation.setEasingCurve(QEasingCurve::OutQuad);
- _v_offset_animation.start();
+ v_offset_animation_.setDuration(100);
+ v_offset_animation_.setStartValue(visual_v_offset_);
+ v_offset_animation_.setEndValue(layout_v_offset_);
+ v_offset_animation_.setEasingCurve(QEasingCurve::OutQuad);
+ v_offset_animation_.start();
}
RowItemOwner* RowItem::owner() const
{
- return _owner;
+ return owner_;
}
void RowItem::set_owner(RowItemOwner *owner)
{
- assert(_owner || owner);
- _v_offset_animation.stop();
+ assert(owner_ || owner);
+ v_offset_animation_.stop();
- if (_owner) {
- const int owner_offset = _owner->owner_visual_v_offset();
- _layout_v_offset += owner_offset;
- _visual_v_offset += owner_offset;
+ if (owner_) {
+ const int owner_offset = owner_->owner_visual_v_offset();
+ layout_v_offset_ += owner_offset;
+ visual_v_offset_ += owner_offset;
}
- _owner = owner;
+ owner_ = owner;
- if (_owner) {
- const int owner_offset = _owner->owner_visual_v_offset();
- _layout_v_offset -= owner_offset;
- _visual_v_offset -= owner_offset;
+ if (owner_) {
+ const int owner_offset = owner_->owner_visual_v_offset();
+ layout_v_offset_ -= owner_offset;
+ visual_v_offset_ -= owner_offset;
}
}
int RowItem::get_visual_y() const
{
- assert(_owner);
- return _visual_v_offset + _owner->owner_visual_v_offset();
+ assert(owner_);
+ return visual_v_offset_ + owner_->owner_visual_v_offset();
}
QPoint RowItem::point() const
virtual void hover_point_changed();
protected:
- pv::view::RowItemOwner *_owner;
+ pv::view::RowItemOwner *owner_;
- int _layout_v_offset;
- int _visual_v_offset;
+ int layout_v_offset_;
+ int visual_v_offset_;
private:
- QPropertyAnimation _v_offset_animation;
+ QPropertyAnimation v_offset_animation_;
};
} // namespace view
public:
RowItemIterator(Owner *owner) :
- _owner(owner),
- _lock(owner->session().signals_mutex()) {}
+ owner_(owner),
+ lock_(owner->session().signals_mutex()) {}
RowItemIterator(Owner *owner, child_iterator iter) :
- _owner(owner),
- _lock(owner->session().signals_mutex()) {
+ owner_(owner),
+ lock_(owner->session().signals_mutex()) {
assert(owner);
if (iter != owner->child_items().end())
- _iter_stack.push(iter);
+ iter_stack_.push(iter);
}
RowItemIterator(const RowItemIterator<Owner, Item> &o) :
- _owner(o._owner),
- _lock(*o._lock.mutex()),
- _iter_stack(o._iter_stack) {}
+ owner_(o.owner_),
+ lock_(*o.lock_.mutex()),
+ iter_stack_(o.iter_stack_) {}
reference operator*() const {
- return *_iter_stack.top();
+ return *iter_stack_.top();
}
reference operator->() const {
using std::dynamic_pointer_cast;
using std::shared_ptr;
- assert(_owner);
- assert(!_iter_stack.empty());
+ assert(owner_);
+ assert(!iter_stack_.empty());
shared_ptr<Owner> owner(dynamic_pointer_cast<Owner>(
- *_iter_stack.top()));
+ *iter_stack_.top()));
if (owner && !owner->child_items().empty()) {
- _owner = owner.get();
- _iter_stack.push(owner->child_items().begin());
+ owner_ = owner.get();
+ iter_stack_.push(owner->child_items().begin());
} else {
- ++_iter_stack.top();
- while (_owner && _iter_stack.top() ==
- _owner->child_items().end()) {
- _iter_stack.pop();
- _owner = _iter_stack.empty() ? nullptr :
- (*_iter_stack.top()++)->owner();
+ ++iter_stack_.top();
+ while (owner_ && iter_stack_.top() ==
+ owner_->child_items().end()) {
+ iter_stack_.pop();
+ owner_ = iter_stack_.empty() ? nullptr :
+ (*iter_stack_.top()++)->owner();
}
}
}
bool operator==(const RowItemIterator &o) const {
- return (_iter_stack.empty() && o._iter_stack.empty()) ||
- (_owner == o._owner &&
- _iter_stack.size() == o._iter_stack.size() &&
+ return (iter_stack_.empty() && o.iter_stack_.empty()) ||
+ (owner_ == o.owner_ &&
+ iter_stack_.size() == o.iter_stack_.size() &&
std::equal(
- _owner->child_items().cbegin(),
- _owner->child_items().cend(),
- o._owner->child_items().cbegin()));
+ owner_->child_items().cbegin(),
+ owner_->child_items().cend(),
+ o.owner_->child_items().cbegin()));
}
bool operator!=(const RowItemIterator &o) const {
}
void swap(RowItemIterator<Owner, Item>& other) {
- swap(_owner, other._owner);
- swap(_iter_stack, other._iter_stack);
+ swap(owner_, other.owner_);
+ swap(iter_stack_, other.iter_stack_);
}
private:
- Owner *_owner;
- boost::shared_lock<boost::shared_mutex> _lock;
- std::stack<child_iterator> _iter_stack;
+ Owner *owner_;
+ boost::shared_lock<boost::shared_mutex> lock_;
+ std::stack<child_iterator> iter_stack_;
};
template<class Owner, class Item>
vector< shared_ptr<RowItem> >& RowItemOwner::child_items()
{
- return _items;
+ return items_;
}
const vector< shared_ptr<RowItem> >& RowItemOwner::child_items() const
{
- return _items;
+ return items_;
}
void RowItemOwner::clear_child_items()
{
- for (auto &i : _items) {
+ for (auto &i : items_) {
assert(i->owner() == this);
i->set_owner(nullptr);
}
- _items.clear();
+ items_.clear();
}
void RowItemOwner::add_child_item(std::shared_ptr<RowItem> item)
{
assert(!item->owner());
item->set_owner(this);
- _items.push_back(item);
+ items_.push_back(item);
extents_changed(true, true);
}
{
assert(item->owner() == this);
item->set_owner(nullptr);
- auto iter = std::find(_items.begin(), _items.end(), item);
- assert(iter != _items.end());
- _items.erase(iter);
+ auto iter = std::find(items_.begin(), items_.end(), item);
+ assert(iter != items_.end());
+ items_.erase(iter);
extents_changed(true, true);
}
RowItemOwner::iterator RowItemOwner::begin()
{
- return iterator(this, _items.begin());
+ return iterator(this, items_.begin());
}
RowItemOwner::iterator RowItemOwner::end()
RowItemOwner::const_iterator RowItemOwner::begin() const
{
- return const_iterator(this, _items.cbegin());
+ return const_iterator(this, items_.cbegin());
}
RowItemOwner::const_iterator RowItemOwner::end() const
virtual void extents_changed(bool horz, bool vert) = 0;
private:
- item_list _items;
+ item_list items_;
};
} // view
{
setMouseTracking(true);
- connect(&_view, SIGNAL(hover_point_changed()),
+ connect(&view_, SIGNAL(hover_point_changed()),
this, SLOT(hover_point_changed()));
}
p.setRenderHint(QPainter::Antialiasing);
std::pair<double, unsigned int> spacing =
- calculate_tick_spacing(p, _view.scale(), _view.offset());
+ calculate_tick_spacing(p, view_.scale(), view_.offset());
double tick_period = spacing.first;
unsigned int prefix = spacing.second;
const double minor_tick_period = tick_period / MinorTickSubdivision;
const double first_major_division =
- floor(_view.offset() / tick_period);
+ floor(view_.offset() / tick_period);
const double first_minor_division =
- ceil(_view.offset() / minor_tick_period);
+ ceil(view_.offset() / minor_tick_period);
const double t0 = first_major_division * tick_period;
int division = (int)round(first_minor_division -
do {
const double t = t0 + division * minor_tick_period;
- x = (t - _view.offset()) / _view.scale();
+ x = (t - view_.offset()) / view_.scale();
if (division % MinorTickSubdivision == 0)
{
void Ruler::draw_hover_mark(QPainter &p)
{
- const int x = _view.hover_point().x();
+ const int x = view_.hover_point().x();
if (x == -1)
return;
const int SelectableItem::HighlightRadius = 6;
SelectableItem::SelectableItem() :
- _context_parent(NULL),
- _selected(false),
- _drag_point(INT_MIN, INT_MIN)
+ context_parent_(NULL),
+ selected_(false),
+ drag_point_(INT_MIN, INT_MIN)
{
}
bool SelectableItem::selected() const
{
- return _selected;
+ return selected_;
}
void SelectableItem::select(bool select)
{
- _selected = select;
+ selected_ = select;
}
bool SelectableItem::dragging() const
{
- return _drag_point.x() != INT_MIN && _drag_point.y() != INT_MIN;
+ return drag_point_.x() != INT_MIN && drag_point_.y() != INT_MIN;
}
QPoint SelectableItem::drag_point() const
{
- return _drag_point;
+ return drag_point_;
}
void SelectableItem::drag()
{
- _drag_point = point();
+ drag_point_ = point();
}
void SelectableItem::drag_release()
{
- _drag_point = QPoint(INT_MIN, INT_MIN);
+ drag_point_ = QPoint(INT_MIN, INT_MIN);
}
QMenu* SelectableItem::create_context_menu(QWidget *parent)
{
- _context_parent = parent;
+ context_parent_ = parent;
return new QMenu(parent);
}
static QPen highlight_pen();
protected:
- QWidget *_context_parent;
+ QWidget *context_parent_;
private:
- bool _selected;
- QPoint _drag_point;
+ bool selected_;
+ QPoint drag_point_;
};
} // namespace view
Signal::Signal(pv::SigSession &session,
std::shared_ptr<sigrok::Channel> channel) :
Trace(channel->name().c_str()),
- _session(session),
- _channel(channel),
- _name_widget(NULL),
- _updating_name_widget(false)
+ session_(session),
+ channel_(channel),
+ name_widget_(NULL),
+ updating_name_widget_(false)
{
- assert(_channel);
+ assert(channel_);
}
void Signal::set_name(QString name)
{
Trace::set_name(name);
- _updating_name_widget = true;
- _name_widget->setEditText(name);
- _updating_name_widget = false;
+ updating_name_widget_ = true;
+ name_widget_->setEditText(name);
+ updating_name_widget_ = false;
}
bool Signal::enabled() const
{
- return _channel->enabled();
+ return channel_->enabled();
}
void Signal::enable(bool enable)
{
- _channel->set_enabled(enable);
+ channel_->set_enabled(enable);
- if (_owner)
- _owner->extents_changed(true, true);
+ if (owner_)
+ owner_->extents_changed(true, true);
}
shared_ptr<Channel> Signal::channel() const
{
- return _channel;
+ return channel_;
}
void Signal::populate_popup_form(QWidget *parent, QFormLayout *form)
{
int index;
- _name_widget = new QComboBox(parent);
- _name_widget->setEditable(true);
+ name_widget_ = new QComboBox(parent);
+ name_widget_->setEditable(true);
for(unsigned int i = 0; i < countof(ChannelNames); i++)
- _name_widget->insertItem(i, ChannelNames[i]);
+ name_widget_->insertItem(i, ChannelNames[i]);
- index = _name_widget->findText(_name, Qt::MatchExactly);
+ index = name_widget_->findText(name_, Qt::MatchExactly);
if (index == -1) {
- _name_widget->insertItem(0, _name);
- _name_widget->setCurrentIndex(0);
+ name_widget_->insertItem(0, name_);
+ name_widget_->setCurrentIndex(0);
} else {
- _name_widget->setCurrentIndex(index);
+ name_widget_->setCurrentIndex(index);
}
- connect(_name_widget, SIGNAL(editTextChanged(const QString&)),
+ connect(name_widget_, SIGNAL(editTextChanged(const QString&)),
this, SLOT(on_text_changed(const QString&)));
- form->addRow(tr("Name"), _name_widget);
+ form->addRow(tr("Name"), name_widget_);
add_colour_option(parent, form);
}
void on_disable();
protected:
- pv::SigSession &_session;
- std::shared_ptr<sigrok::Channel> _channel;
+ pv::SigSession &session_;
+ std::shared_ptr<sigrok::Channel> channel_;
- QComboBox *_name_widget;
- bool _updating_name_widget;
+ QComboBox *name_widget_;
+ bool updating_name_widget_;
};
} // namespace view
namespace view {
TimeMarker::TimeMarker(View &view, const QColor &colour, double time) :
- _view(view),
- _colour(colour),
- _time(time),
- _value_action(NULL),
- _value_widget(NULL),
- _updating_value_widget(false)
+ view_(view),
+ colour_(colour),
+ time_(time),
+ value_action_(NULL),
+ value_widget_(NULL),
+ updating_value_widget_(false)
{
}
double TimeMarker::time() const
{
- return _time;
+ return time_;
}
float TimeMarker::get_x() const
{
- return (_time - _view.offset()) / _view.scale();
+ return (time_ - view_.offset()) / view_.scale();
}
QPoint TimeMarker::point() const
void TimeMarker::set_time(double time)
{
- _time = time;
+ time_ = time;
- if (_value_widget) {
- _updating_value_widget = true;
- _value_widget->setValue(time);
- _updating_value_widget = false;
+ if (value_widget_) {
+ updating_value_widget_ = true;
+ value_widget_->setValue(time);
+ updating_value_widget_ = false;
}
time_changed();
void TimeMarker::paint(QPainter &p, const QRect &rect)
{
const float x = get_x();
- p.setPen(_colour);
+ p.setPen(colour_);
p.drawLine(QPointF(x, rect.top()), QPointF(x, rect.bottom()));
}
QFormLayout *const form = new QFormLayout(popup);
popup->setLayout(form);
- _value_widget = new QDoubleSpinBox(parent);
- _value_widget->setDecimals(9);
- _value_widget->setSuffix("s");
- _value_widget->setSingleStep(1e-6);
- _value_widget->setValue(_time);
+ value_widget_ = new QDoubleSpinBox(parent);
+ value_widget_->setDecimals(9);
+ value_widget_->setSuffix("s");
+ value_widget_->setSingleStep(1e-6);
+ value_widget_->setValue(time_);
- connect(_value_widget, SIGNAL(valueChanged(double)),
+ connect(value_widget_, SIGNAL(valueChanged(double)),
this, SLOT(on_value_changed(double)));
- form->addRow(tr("Time"), _value_widget);
+ form->addRow(tr("Time"), value_widget_);
return popup;
}
void TimeMarker::on_value_changed(double value)
{
- if (!_updating_value_widget) {
- _time = value;
+ if (!updating_value_widget_) {
+ time_ = value;
time_changed();
}
}
void time_changed();
protected:
- View &_view;
- const QColor &_colour;
+ View &view_;
+ const QColor &colour_;
- double _time;
+ double time_;
- QSizeF _text_size;
+ QSizeF text_size_;
- QWidgetAction *_value_action;
- QDoubleSpinBox *_value_widget;
- bool _updating_value_widget;
+ QWidgetAction *value_action_;
+ QDoubleSpinBox *value_widget_;
+ bool updating_value_widget_;
};
} // namespace view
const int Trace::LabelHitPadding = 2;
Trace::Trace(QString name) :
- _name(name),
- _popup(NULL),
- _popup_form(NULL)
+ name_(name),
+ popup_(NULL),
+ popup_form_(NULL)
{
}
QString Trace::name() const
{
- return _name;
+ return name_;
}
void Trace::set_name(QString name)
{
- _name = name;
+ name_ = name;
}
QColor Trace::colour() const
{
- return _colour;
+ return colour_;
}
void Trace::set_colour(QColor colour)
{
- _colour = colour;
+ colour_ = colour;
}
void Trace::paint_label(QPainter &p, int right, bool hover)
{
const int y = get_visual_y();
- p.setBrush(_colour);
+ p.setBrush(colour_);
if (!enabled())
return;
}
p.setPen(Qt::transparent);
- p.setBrush(hover ? _colour.lighter() : _colour);
+ p.setBrush(hover ? colour_.lighter() : colour_);
p.drawPolygon(points, countof(points));
- p.setPen(_colour.lighter());
+ p.setPen(colour_.lighter());
p.setBrush(Qt::transparent);
p.drawPolygon(highlight_points, countof(highlight_points));
- p.setPen(_colour.darker());
+ p.setPen(colour_.darker());
p.setBrush(Qt::transparent);
p.drawPolygon(points, countof(points));
p.setFont(QApplication::font());
p.drawText(QRectF(r.x(), r.y(),
r.width() - label_arrow_length, r.height()),
- Qt::AlignCenter | Qt::AlignVCenter, _name);
+ Qt::AlignCenter | Qt::AlignVCenter, name_);
}
QMenu* Trace::create_context_menu(QWidget *parent)
{
using pv::widgets::Popup;
- _popup = new Popup(parent);
+ popup_ = new Popup(parent);
create_popup_form();
- connect(_popup, SIGNAL(closed()),
+ connect(popup_, SIGNAL(closed()),
this, SLOT(on_popup_closed()));
- return _popup;
+ return popup_;
}
QRectF Trace::label_rect(int right) const
QFontMetrics m(QApplication::font());
const QSize text_size(
- m.boundingRect(QRect(), 0, _name).width(),
+ m.boundingRect(QRect(), 0, name_).width(),
m.boundingRect(QRect(), 0, "Tg").height());
const QSizeF label_size(
text_size.width() + View::LabelPadding.width() * 2,
QColor Trace::get_text_colour() const
{
- return (_colour.lightness() > 64) ? Qt::black : Qt::white;
+ return (colour_.lightness() > 64) ? Qt::black : Qt::white;
}
void Trace::paint_axis(QPainter &p, int y, int left, int right)
ColourButton *const colour_button = new ColourButton(
TracePalette::Rows, TracePalette::Cols, parent);
colour_button->set_palette(TracePalette::Colours);
- colour_button->set_colour(_colour);
+ colour_button->set_colour(colour_);
connect(colour_button, SIGNAL(selected(const QColor&)),
this, SLOT(on_colour_changed(const QColor&)));
// Transfer the layout and the child widgets to a temporary widget
// which then goes out of scope destroying the layout and all the child
// widgets.
- if (_popup_form)
- QWidget().setLayout(_popup_form);
+ if (popup_form_)
+ QWidget().setLayout(popup_form_);
// Repopulate the popup
- _popup_form = new QFormLayout(_popup);
- _popup->setLayout(_popup_form);
- populate_popup_form(_popup, _popup_form);
+ popup_form_ = new QFormLayout(popup_);
+ popup_->setLayout(popup_form_);
+ populate_popup_form(popup_, popup_form_);
}
void Trace::populate_popup_form(QWidget *parent, QFormLayout *form)
{
QLineEdit *const name_edit = new QLineEdit(parent);
- name_edit->setText(_name);
+ name_edit->setText(name_);
connect(name_edit, SIGNAL(textChanged(const QString&)),
this, SLOT(on_text_changed(const QString&)));
form->addRow(tr("Name"), name_edit);
void Trace::on_popup_closed()
{
- _popup = NULL;
- _popup_form = NULL;
+ popup_ = NULL;
+ popup_form_ = NULL;
}
void Trace::on_text_changed(const QString &text)
{
set_name(text);
- if (_owner)
- _owner->extents_changed(true, false);
+ if (owner_)
+ owner_->extents_changed(true, false);
}
void Trace::on_colour_changed(const QColor &colour)
{
set_colour(colour);
- if (_owner)
- _owner->appearance_changed(true, false);
+ if (owner_)
+ owner_->appearance_changed(true, false);
}
} // namespace view
void on_popup_closed();
protected:
- QString _name;
- QColor _colour;
+ QString name_;
+ QColor colour_;
private:
- pv::widgets::Popup *_popup;
- QFormLayout *_popup_form;
+ pv::widgets::Popup *popup_;
+ QFormLayout *popup_form_;
};
} // namespace view
TraceGroup::~TraceGroup()
{
- _owner = nullptr;
+ owner_ = nullptr;
clear_child_items();
}
pv::SigSession& TraceGroup::session()
{
- assert(_owner);
- return _owner->session();
+ assert(owner_);
+ return owner_->session();
}
const pv::SigSession& TraceGroup::session() const
{
- assert(_owner);
- return _owner->session();
+ assert(owner_);
+ return owner_->session();
}
pv::view::View* TraceGroup::view()
{
- assert(_owner);
- return _owner->view();
+ assert(owner_);
+ return owner_->view();
}
const pv::view::View* TraceGroup::view() const
{
- assert(_owner);
- return _owner->view();
+ assert(owner_);
+ return owner_->view();
}
pair<int, int> TraceGroup::v_extents() const
int TraceGroup::owner_visual_v_offset() const
{
- return _owner ? visual_v_offset() + _owner->owner_visual_v_offset() : 0;
+ return owner_ ? visual_v_offset() + owner_->owner_visual_v_offset() : 0;
}
void TraceGroup::restack_items()
unsigned int TraceGroup::depth() const
{
- return _owner ? _owner->depth() + 1 : 0;
+ return owner_ ? owner_->depth() + 1 : 0;
}
void TraceGroup::ungroup()
clear_child_items();
for (shared_ptr<RowItem> r : items)
- _owner->add_child_item(r);
+ owner_->add_child_item(r);
- _owner->remove_child_item(shared_from_this());
+ owner_->remove_child_item(shared_from_this());
}
void TraceGroup::on_ungroup()
void TraceGroup::appearance_changed(bool label, bool content)
{
- if (_owner)
- _owner->appearance_changed(label, content);
+ if (owner_)
+ owner_->appearance_changed(label, content);
}
void TraceGroup::extents_changed(bool horz, bool vert)
{
- if (_owner)
- _owner->extents_changed(horz, vert);
+ if (owner_)
+ owner_->extents_changed(horz, vert);
}
} // namespace view
View::View(SigSession &session, QWidget *parent) :
QAbstractScrollArea(parent),
- _session(session),
- _viewport(new Viewport(*this)),
- _ruler(new Ruler(*this)),
- _cursorheader(new CursorHeader(*this)),
- _header(new Header(*this)),
- _scale(1e-6),
- _offset(0),
- _v_offset(0),
- _updating_scroll(false),
- _show_cursors(false),
- _cursors(*this),
- _hover_point(-1, -1)
+ session_(session),
+ viewport_(new Viewport(*this)),
+ ruler_(new Ruler(*this)),
+ cursorheader_(new CursorHeader(*this)),
+ header_(new Header(*this)),
+ scale_(1e-6),
+ offset_(0),
+ v_offset_(0),
+ updating_scroll_(false),
+ show_cursors_(false),
+ cursors_(*this),
+ hover_point_(-1, -1)
{
connect(horizontalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(h_scroll_value_changed(int)));
connect(verticalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(v_scroll_value_changed(int)));
- connect(&_session, SIGNAL(signals_changed()),
+ connect(&session_, SIGNAL(signals_changed()),
this, SLOT(signals_changed()));
- connect(&_session, SIGNAL(capture_state_changed(int)),
+ connect(&session_, SIGNAL(capture_state_changed(int)),
this, SLOT(data_updated()));
- connect(&_session, SIGNAL(data_received()),
+ connect(&session_, SIGNAL(data_received()),
this, SLOT(data_updated()));
- connect(&_session, SIGNAL(frame_ended()),
+ connect(&session_, SIGNAL(frame_ended()),
this, SLOT(data_updated()));
- connect(_cursors.first().get(), SIGNAL(time_changed()),
+ connect(cursors_.first().get(), SIGNAL(time_changed()),
this, SLOT(marker_time_changed()));
- connect(_cursors.second().get(), SIGNAL(time_changed()),
+ connect(cursors_.second().get(), SIGNAL(time_changed()),
this, SLOT(marker_time_changed()));
- connect(_header, SIGNAL(signals_moved()),
+ connect(header_, SIGNAL(signals_moved()),
this, SLOT(on_signals_moved()));
- connect(_header, SIGNAL(selection_changed()),
- _cursorheader, SLOT(clear_selection()));
- connect(_cursorheader, SIGNAL(selection_changed()),
- _header, SLOT(clear_selection()));
+ connect(header_, SIGNAL(selection_changed()),
+ cursorheader_, SLOT(clear_selection()));
+ connect(cursorheader_, SIGNAL(selection_changed()),
+ header_, SLOT(clear_selection()));
- connect(_header, SIGNAL(selection_changed()),
+ connect(header_, SIGNAL(selection_changed()),
this, SIGNAL(selection_changed()));
- connect(_cursorheader, SIGNAL(selection_changed()),
+ connect(cursorheader_, SIGNAL(selection_changed()),
this, SIGNAL(selection_changed()));
connect(this, SIGNAL(hover_point_changed()),
this, SLOT(on_hover_point_changed()));
- connect(&_lazy_event_handler, SIGNAL(timeout()),
+ connect(&lazy_event_handler_, SIGNAL(timeout()),
this, SLOT(process_sticky_events()));
- _lazy_event_handler.setSingleShot(true);
+ lazy_event_handler_.setSingleShot(true);
- setViewport(_viewport);
+ setViewport(viewport_);
- _viewport->installEventFilter(this);
- _ruler->installEventFilter(this);
- _cursorheader->installEventFilter(this);
- _header->installEventFilter(this);
+ viewport_->installEventFilter(this);
+ ruler_->installEventFilter(this);
+ cursorheader_->installEventFilter(this);
+ header_->installEventFilter(this);
// Trigger the initial event manually. The default device has signals
// which were created before this object came into being
signals_changed();
// make sure the transparent widgets are on the top
- _cursorheader->raise();
- _header->raise();
+ cursorheader_->raise();
+ header_->raise();
}
SigSession& View::session()
{
- return _session;
+ return session_;
}
const SigSession& View::session() const
{
- return _session;
+ return session_;
}
View* View::view()
Viewport* View::viewport()
{
- return _viewport;
+ return viewport_;
}
const Viewport* View::viewport() const
{
- return _viewport;
+ return viewport_;
}
double View::scale() const
{
- return _scale;
+ return scale_;
}
double View::offset() const
{
- return _offset;
+ return offset_;
}
int View::owner_visual_v_offset() const
{
- return -_v_offset;
+ return -v_offset_;
}
unsigned int View::depth() const
void View::zoom(double steps)
{
- zoom(steps, _viewport->width() / 2);
+ zoom(steps, viewport_->width() / 2);
}
void View::zoom(double steps, int offset)
{
- set_zoom(_scale * pow(3.0/2.0, -steps), offset);
+ set_zoom(scale_ * pow(3.0/2.0, -steps), offset);
}
void View::zoom_fit()
if (delta < 1e-12)
return;
- assert(_viewport);
- const int w = _viewport->width();
+ assert(viewport_);
+ const int w = viewport_->width();
if (w <= 0)
return;
if (samplerate == 0.0)
return;
- assert(_viewport);
- const int w = _viewport->width();
+ assert(viewport_);
+ const int w = viewport_->width();
if (w <= 0)
return;
void View::set_scale_offset(double scale, double offset)
{
- _scale = scale;
- _offset = offset;
+ scale_ = scale;
+ offset_ = offset;
update_scroll();
- _ruler->update();
- _cursorheader->update();
- _viewport->update();
+ ruler_->update();
+ cursorheader_->update();
+ viewport_->update();
scale_offset_changed();
}
bool View::cursors_shown() const
{
- return _show_cursors;
+ return show_cursors_;
}
void View::show_cursors(bool show)
{
- _show_cursors = show;
- _cursorheader->update();
- _viewport->update();
+ show_cursors_ = show;
+ cursorheader_->update();
+ viewport_->update();
}
void View::centre_cursors()
{
- const double time_width = _scale * _viewport->width();
- _cursors.first()->set_time(_offset + time_width * 0.4);
- _cursors.second()->set_time(_offset + time_width * 0.6);
- _cursorheader->update();
- _viewport->update();
+ const double time_width = scale_ * viewport_->width();
+ cursors_.first()->set_time(offset_ + time_width * 0.4);
+ cursors_.second()->set_time(offset_ + time_width * 0.6);
+ cursorheader_->update();
+ viewport_->update();
}
CursorPair& View::cursors()
{
- return _cursors;
+ return cursors_;
}
const CursorPair& View::cursors() const
{
- return _cursors;
+ return cursors_;
}
const QPoint& View::hover_point() const
{
- return _hover_point;
+ return hover_point_;
}
void View::update_viewport()
{
- assert(_viewport);
- _viewport->update();
- _header->update();
+ assert(viewport_);
+ viewport_->update();
+ header_->update();
}
void View::restack_all_row_items()
void View::get_scroll_layout(double &length, double &offset) const
{
const pair<double, double> extents = get_time_extents();
- length = (extents.second - extents.first) / _scale;
- offset = _offset / _scale;
+ length = (extents.second - extents.first) / scale_;
+ offset = offset_ / scale_;
}
void View::set_zoom(double scale, int offset)
{
- const double cursor_offset = _offset + _scale * offset;
+ const double cursor_offset = offset_ + scale_ * offset;
const double new_scale = max(min(scale, MaxScale), MinScale);
const double new_offset = cursor_offset - new_scale * offset;
set_scale_offset(new_scale, new_offset);
void View::update_scroll()
{
- assert(_viewport);
+ assert(viewport_);
- const QSize areaSize = _viewport->size();
+ const QSize areaSize = viewport_->size();
// Set the horizontal scroll bar
double length = 0, offset = 0;
horizontalScrollBar()->setPageStep(areaSize.width() / 2);
- _updating_scroll = true;
+ updating_scroll_ = true;
if (length < MaxScrollValue) {
horizontalScrollBar()->setRange(0, length);
} else {
horizontalScrollBar()->setRange(0, MaxScrollValue);
horizontalScrollBar()->setSliderPosition(
- _offset * MaxScrollValue / (_scale * length));
+ offset_ * MaxScrollValue / (scale_ * length));
}
- _updating_scroll = false;
+ updating_scroll_ = false;
// Set the vertical scrollbar
verticalScrollBar()->setPageStep(areaSize.height());
void View::update_layout()
{
setViewportMargins(
- _header->sizeHint().width() - pv::view::Header::BaselineOffset,
- _ruler->sizeHint().height(), 0, 0);
- _ruler->setGeometry(_viewport->x(), 0,
- _viewport->width(), _viewport->y());
- _cursorheader->setGeometry(
- _viewport->x(),
- _ruler->sizeHint().height() - _cursorheader->sizeHint().height() / 2,
- _viewport->width(), _cursorheader->sizeHint().height());
- _header->setGeometry(0, _viewport->y(),
- _header->sizeHint().width(), _viewport->height());
+ header_->sizeHint().width() - pv::view::Header::BaselineOffset,
+ ruler_->sizeHint().height(), 0, 0);
+ ruler_->setGeometry(viewport_->x(), 0,
+ viewport_->width(), viewport_->y());
+ cursorheader_->setGeometry(
+ viewport_->x(),
+ ruler_->sizeHint().height() - cursorheader_->sizeHint().height() / 2,
+ viewport_->width(), cursorheader_->sizeHint().height());
+ header_->setGeometry(0, viewport_->y(),
+ header_->sizeHint().width(), viewport_->height());
update_scroll();
}
if (type == QEvent::MouseMove) {
const QMouseEvent *const mouse_event = (QMouseEvent*)event;
- if (object == _viewport)
- _hover_point = mouse_event->pos();
- else if (object == _ruler || object == _cursorheader)
- _hover_point = QPoint(mouse_event->x(), 0);
- else if (object == _header)
- _hover_point = QPoint(0, mouse_event->y());
+ if (object == viewport_)
+ hover_point_ = mouse_event->pos();
+ else if (object == ruler_ || object == cursorheader_)
+ hover_point_ = QPoint(mouse_event->x(), 0);
+ else if (object == header_)
+ hover_point_ = QPoint(0, mouse_event->y());
else
- _hover_point = QPoint(-1, -1);
+ hover_point_ = QPoint(-1, -1);
hover_point_changed();
} else if (type == QEvent::Leave) {
- _hover_point = QPoint(-1, -1);
+ hover_point_ = QPoint(-1, -1);
hover_point_changed();
}
void View::appearance_changed(bool label, bool content)
{
if (label)
- _header->update();
+ header_->update();
if (content)
- _viewport->update();
+ viewport_->update();
}
void View::extents_changed(bool horz, bool vert)
{
- _sticky_events |=
+ sticky_events_ |=
(horz ? SelectableItemHExtentsChanged : 0) |
(vert ? SelectableItemVExtentsChanged : 0);
- _lazy_event_handler.start();
+ lazy_event_handler_.start();
}
void View::h_scroll_value_changed(int value)
{
- if (_updating_scroll)
+ if (updating_scroll_)
return;
const int range = horizontalScrollBar()->maximum();
if (range < MaxScrollValue)
- _offset = _scale * value;
+ offset_ = scale_ * value;
else {
double length = 0, offset;
get_scroll_layout(length, offset);
- _offset = _scale * length * value / MaxScrollValue;
+ offset_ = scale_ * length * value / MaxScrollValue;
}
- _ruler->update();
- _cursorheader->update();
- _viewport->update();
+ ruler_->update();
+ cursorheader_->update();
+ viewport_->update();
}
void View::v_scroll_value_changed(int value)
{
- _v_offset = value;
- _header->update();
- _viewport->update();
+ v_offset_ = value;
+ header_->update();
+ viewport_->update();
}
void View::signals_changed()
// Populate the traces
clear_child_items();
- shared_ptr<sigrok::Device> device = _session.device();
+ shared_ptr<sigrok::Device> device = session_.device();
assert(device);
// Collect a set of signals
unordered_map<shared_ptr<sigrok::Channel>, shared_ptr<Signal> >
signal_map;
- shared_lock<shared_mutex> lock(_session.signals_mutex());
- const vector< shared_ptr<Signal> > &sigs(_session.signals());
+ shared_lock<shared_mutex> lock(session_.signals_mutex());
+ const vector< shared_ptr<Signal> > &sigs(session_.signals());
for (const shared_ptr<Signal> &sig : sigs)
signal_map[sig->channel()] = sig;
update_scroll();
// Repaint the view
- _viewport->update();
+ viewport_->update();
}
void View::marker_time_changed()
{
- _cursorheader->update();
- _viewport->update();
+ cursorheader_->update();
+ viewport_->update();
}
void View::on_signals_moved()
void View::process_sticky_events()
{
- if (_sticky_events & SelectableItemHExtentsChanged)
+ if (sticky_events_ & SelectableItemHExtentsChanged)
update_layout();
- if (_sticky_events & SelectableItemVExtentsChanged)
+ if (sticky_events_ & SelectableItemVExtentsChanged)
restack_all_row_items();
// Clear the sticky events
- _sticky_events = 0;
+ sticky_events_ = 0;
}
void View::on_hover_point_changed()
void on_hover_point_changed();
private:
- SigSession &_session;
+ SigSession &session_;
- Viewport *_viewport;
- Ruler *_ruler;
- CursorHeader *_cursorheader;
- Header *_header;
+ Viewport *viewport_;
+ Ruler *ruler_;
+ CursorHeader *cursorheader_;
+ Header *header_;
/// The view time scale in seconds per pixel.
- double _scale;
+ double scale_;
/// The view time offset in seconds.
- double _offset;
+ double offset_;
- int _v_offset;
- bool _updating_scroll;
+ int v_offset_;
+ bool updating_scroll_;
- bool _show_cursors;
- CursorPair _cursors;
+ bool show_cursors_;
+ CursorPair cursors_;
- QPoint _hover_point;
+ QPoint hover_point_;
- unsigned int _sticky_events;
- QTimer _lazy_event_handler;
+ unsigned int sticky_events_;
+ QTimer lazy_event_handler_;
};
} // namespace view
Viewport::Viewport(View &parent) :
QWidget(&parent),
- _view(parent),
- _mouse_down_valid(false),
- _pinch_zoom_active(false)
+ view_(parent),
+ mouse_down_valid_(false),
+ pinch_zoom_active_(false)
{
setAttribute(Qt::WA_AcceptTouchEvents, true);
setAutoFillBackground(true);
setBackgroundRole(QPalette::Base);
- connect(&_view, SIGNAL(signals_moved()),
+ connect(&view_, SIGNAL(signals_moved()),
this, SLOT(on_signals_moved()));
}
void Viewport::paintEvent(QPaintEvent*)
{
- vector< shared_ptr<RowItem> > row_items(_view.begin(), _view.end());
+ vector< shared_ptr<RowItem> > row_items(view_.begin(), view_.end());
stable_sort(row_items.begin(), row_items.end(),
[](const shared_ptr<RowItem> &a, const shared_ptr<RowItem> &b) {
return a->visual_v_offset() < b->visual_v_offset(); });
QPainter p(this);
p.setRenderHint(QPainter::Antialiasing);
- if (_view.cursors_shown())
- _view.cursors().draw_viewport_background(p, rect());
+ if (view_.cursors_shown())
+ view_.cursors().draw_viewport_background(p, rect());
// Plot the signal
for (const shared_ptr<RowItem> r : row_items)
for (const shared_ptr<RowItem> r : row_items)
r->paint_fore(p, 0, width());
- if (_view.cursors_shown())
- _view.cursors().draw_viewport_foreground(p, rect());
+ if (view_.cursors_shown())
+ view_.cursors().draw_viewport_foreground(p, rect());
p.end();
}
assert(event);
if (event->button() == Qt::LeftButton) {
- _mouse_down_point = event->pos();
- _mouse_down_offset = _view.offset();
- _mouse_down_valid = true;
+ mouse_down_point_ = event->pos();
+ mouse_down_offset_ = view_.offset();
+ mouse_down_valid_ = true;
}
}
assert(event);
if (event->button() == Qt::LeftButton)
- _mouse_down_valid = false;
+ mouse_down_valid_ = false;
}
void Viewport::mouseMoveEvent(QMouseEvent *event)
assert(event);
if (event->buttons() & Qt::LeftButton) {
- if (!_mouse_down_valid) {
- _mouse_down_point = event->pos();
- _mouse_down_offset = _view.offset();
- _mouse_down_valid = true;
+ if (!mouse_down_valid_) {
+ mouse_down_point_ = event->pos();
+ mouse_down_offset_ = view_.offset();
+ mouse_down_valid_ = true;
}
- _view.set_scale_offset(_view.scale(),
- _mouse_down_offset +
- (_mouse_down_point - event->pos()).x() *
- _view.scale());
+ view_.set_scale_offset(view_.scale(),
+ mouse_down_offset_ +
+ (mouse_down_point_ - event->pos()).x() *
+ view_.scale());
}
}
assert(event);
if (event->buttons() & Qt::LeftButton)
- _view.zoom(2.0, event->x());
+ view_.zoom(2.0, event->x());
else if (event->buttons() & Qt::RightButton)
- _view.zoom(-2.0, event->x());
+ view_.zoom(-2.0, event->x());
}
void Viewport::wheelEvent(QWheelEvent *event)
if (event->orientation() == Qt::Vertical) {
// Vertical scrolling is interpreted as zooming in/out
- _view.zoom(event->delta() / 120, event->x());
+ view_.zoom(event->delta() / 120, event->x());
} else if (event->orientation() == Qt::Horizontal) {
// Horizontal scrolling is interpreted as moving left/right
- _view.set_scale_offset(_view.scale(),
- event->delta() * _view.scale()
- + _view.offset());
+ view_.set_scale_offset(view_.scale(),
+ event->delta() * view_.scale()
+ + view_.offset());
}
}
QList<QTouchEvent::TouchPoint> touchPoints = event->touchPoints();
if (touchPoints.count() != 2) {
- _pinch_zoom_active = false;
+ pinch_zoom_active_ = false;
return false;
}
const QTouchEvent::TouchPoint &touchPoint0 = touchPoints.first();
const QTouchEvent::TouchPoint &touchPoint1 = touchPoints.last();
- if (!_pinch_zoom_active ||
+ if (!pinch_zoom_active_ ||
(event->touchPointStates() & Qt::TouchPointPressed)) {
- _pinch_offset0 = _view.offset() + _view.scale() * touchPoint0.pos().x();
- _pinch_offset1 = _view.offset() + _view.scale() * touchPoint1.pos().x();
- _pinch_zoom_active = true;
+ pinch_offset0_ = view_.offset() + view_.scale() * touchPoint0.pos().x();
+ pinch_offset1_ = view_.offset() + view_.scale() * touchPoint1.pos().x();
+ pinch_zoom_active_ = true;
}
double w = touchPoint1.pos().x() - touchPoint0.pos().x();
if (abs(w) >= 1.0) {
- double scale = (_pinch_offset1 - _pinch_offset0) / w;
+ double scale = (pinch_offset1_ - pinch_offset0_) / w;
if (scale < 0)
scale = -scale;
- double offset = _pinch_offset0 - touchPoint0.pos().x() * scale;
+ double offset = pinch_offset0_ - touchPoint0.pos().x() * scale;
if (scale > 0)
- _view.set_scale_offset(scale, offset);
+ view_.set_scale_offset(scale, offset);
}
if (event->touchPointStates() & Qt::TouchPointReleased) {
- _pinch_zoom_active = false;
+ pinch_zoom_active_ = false;
if (touchPoint0.state() & Qt::TouchPointReleased) {
// Primary touch released
- _mouse_down_valid = false;
+ mouse_down_valid_ = false;
} else {
// Update the mouse down fields so that continued
// dragging with the primary touch will work correctly
- _mouse_down_point = touchPoint0.pos().toPoint();
- _mouse_down_offset = _view.offset();
- _mouse_down_valid = true;
+ mouse_down_point_ = touchPoint0.pos().toPoint();
+ mouse_down_offset_ = view_.offset();
+ mouse_down_valid_ = true;
}
}
void on_signals_moved();
private:
- View &_view;
+ View &view_;
- QPoint _mouse_down_point;
- double _mouse_down_offset;
- bool _mouse_down_valid;
+ QPoint mouse_down_point_;
+ double mouse_down_offset_;
+ bool mouse_down_valid_;
- double _pinch_offset0;
- double _pinch_offset1;
- bool _pinch_zoom_active;
+ double pinch_offset0_;
+ double pinch_offset1_;
+ bool pinch_zoom_active_;
};
} // namespace view
ColourButton::ColourButton(int rows, int cols, QWidget *parent) :
QPushButton("", parent),
- _popup(rows, cols, this)
+ popup_(rows, cols, this)
{
connect(this, SIGNAL(clicked(bool)), this, SLOT(on_clicked(bool)));
- connect(&_popup, SIGNAL(selected(int, int)),
+ connect(&popup_, SIGNAL(selected(int, int)),
this, SLOT(on_selected(int, int)));
}
ColourPopup& ColourButton::popup()
{
- return _popup;
+ return popup_;
}
const QColor& ColourButton::colour() const
{
- return _cur_colour;
+ return cur_colour_;
}
void ColourButton::set_colour(QColor colour)
{
- _cur_colour = colour;
+ cur_colour_ = colour;
- const unsigned int rows = _popup.well_array().numRows();
- const unsigned int cols = _popup.well_array().numCols();
+ const unsigned int rows = popup_.well_array().numRows();
+ const unsigned int cols = popup_.well_array().numCols();
for (unsigned int r = 0; r < rows; r++)
for (unsigned int c = 0; c < cols; c++)
- if (_popup.well_array().cellBrush(r, c).color() ==
+ if (popup_.well_array().cellBrush(r, c).color() ==
colour)
{
- _popup.well_array().setSelected(r, c);
- _popup.well_array().setCurrent(r, c);
+ popup_.well_array().setSelected(r, c);
+ popup_.well_array().setCurrent(r, c);
return;
}
}
{
assert(palette);
- const unsigned int rows = _popup.well_array().numRows();
- const unsigned int cols = _popup.well_array().numCols();
+ const unsigned int rows = popup_.well_array().numRows();
+ const unsigned int cols = popup_.well_array().numCols();
for (unsigned int r = 0; r < rows; r++)
for (unsigned int c = 0; c < cols; c++)
- _popup.well_array().setCellBrush(r, c,
+ popup_.well_array().setCellBrush(r, c,
QBrush(palette[r * cols + c]));
}
void ColourButton::on_clicked(bool)
{
- _popup.set_position(mapToGlobal(rect().center()), Popup::Bottom);
- _popup.show();
+ popup_.set_position(mapToGlobal(rect().center()), Popup::Bottom);
+ popup_.show();
}
void ColourButton::on_selected(int row, int col)
{
- _cur_colour = _popup.well_array().cellBrush(row, col).color();
- selected(_cur_colour);
+ cur_colour_ = popup_.well_array().cellBrush(row, col).color();
+ selected(cur_colour_);
}
void ColourButton::paintEvent(QPaintEvent *e)
const QRect r = rect().adjusted(SwatchMargin, SwatchMargin,
-SwatchMargin, -SwatchMargin);
p.setPen(QApplication::palette().color(QPalette::Dark));
- p.setBrush(QBrush(_cur_colour));
+ p.setBrush(QBrush(cur_colour_));
p.drawRect(r);
}
void selected(const QColor &colour);
private:
- ColourPopup _popup;
- QColor _cur_colour;
+ ColourPopup popup_;
+ QColor cur_colour_;
};
} // widgets
ColourPopup::ColourPopup(int rows, int cols, QWidget *parent) :
Popup(parent),
- _well_array(rows, cols, this),
- _layout(this)
+ well_array_(rows, cols, this),
+ layout_(this)
{
- _layout.addWidget(&_well_array);
- setLayout(&_layout);
+ layout_.addWidget(&well_array_);
+ setLayout(&layout_);
- connect(&_well_array, SIGNAL(selected(int, int)),
+ connect(&well_array_, SIGNAL(selected(int, int)),
this, SIGNAL(selected(int, int)));
- connect(&_well_array, SIGNAL(selected(int, int)),
+ connect(&well_array_, SIGNAL(selected(int, int)),
this, SLOT(colour_selected(int, int)));
}
QWellArray& ColourPopup::well_array()
{
- return _well_array;
+ return well_array_;
}
void ColourPopup::colour_selected(int, int)
void colour_selected(int, int);
private:
- QWellArray _well_array;
- QVBoxLayout _layout;
+ QWellArray well_array_;
+ QVBoxLayout layout_;
};
} // widgets
DecoderGroupBox::DecoderGroupBox(QString title, QWidget *parent) :
QWidget(parent),
- _layout(new QGridLayout),
- _show_hide_button(QIcon(":/icons/decoder-shown.svg"), QString(), this)
+ layout_(new QGridLayout),
+ show_hide_button_(QIcon(":/icons/decoder-shown.svg"), QString(), this)
{
- _layout->setContentsMargins(0, 0, 0, 0);
- setLayout(_layout);
+ layout_->setContentsMargins(0, 0, 0, 0);
+ setLayout(layout_);
- _layout->addWidget(new QLabel(QString("<h3>%1</h3>").arg(title)),
+ layout_->addWidget(new QLabel(QString("<h3>%1</h3>").arg(title)),
0, 0);
- _layout->setColumnStretch(0, 1);
+ layout_->setColumnStretch(0, 1);
QHBoxLayout *const toolbar = new QHBoxLayout;
- _layout->addLayout(toolbar, 0, 1);
+ layout_->addLayout(toolbar, 0, 1);
- _show_hide_button.setFlat(true);
- _show_hide_button.setIconSize(QSize(16, 16));
- connect(&_show_hide_button, SIGNAL(clicked()),
+ show_hide_button_.setFlat(true);
+ show_hide_button_.setIconSize(QSize(16, 16));
+ connect(&show_hide_button_, SIGNAL(clicked()),
this, SIGNAL(show_hide_decoder()));
- toolbar->addWidget(&_show_hide_button);
+ toolbar->addWidget(&show_hide_button_);
QPushButton *const delete_button = new QPushButton(
QIcon(":/icons/decoder-delete.svg"), QString(), this);
void DecoderGroupBox::add_layout(QLayout *layout)
{
assert(layout);
- _layout->addLayout(layout, 1, 0, 1, 2);
+ layout_->addLayout(layout, 1, 0, 1, 2);
}
void DecoderGroupBox::set_decoder_visible(bool visible)
{
- _show_hide_button.setIcon(QIcon(visible ?
+ show_hide_button_.setIcon(QIcon(visible ?
":/icons/decoder-shown.svg" :
":/icons/decoder-hidden.svg"));
}
void show_hide_decoder();
private:
- QGridLayout *const _layout;
- QPushButton _show_hide_button;
+ QGridLayout *const layout_;
+ QPushButton show_hide_button_;
};
} // widgets
DecoderMenu::DecoderMenu(QWidget *parent, bool first_level_decoder) :
QMenu(parent),
- _mapper(this)
+ mapper_(this)
{
GSList *l = g_slist_sort(g_slist_copy(
(GSList*)srd_decoder_list()), decoder_name_cmp);
QAction *const action =
addAction(QString::fromUtf8(d->name));
action->setData(qVariantFromValue(l->data));
- _mapper.setMapping(action, action);
+ mapper_.setMapping(action, action);
connect(action, SIGNAL(triggered()),
- &_mapper, SLOT(map()));
+ &mapper_, SLOT(map()));
}
}
g_slist_free(l);
- connect(&_mapper, SIGNAL(mapped(QObject*)),
+ connect(&mapper_, SIGNAL(mapped(QObject*)),
this, SLOT(on_action(QObject*)));
}
void decoder_selected(srd_decoder *decoder);
private:
- QSignalMapper _mapper;
+ QSignalMapper mapper_;
};
} // widgets
Popup::Popup(QWidget *parent) :
QWidget(parent, Qt::Popup | Qt::FramelessWindowHint),
- _point(),
- _pos(Left)
+ point_(),
+ pos_(Left)
{
}
const QPoint& Popup::point() const
{
- return _point;
+ return point_;
}
Popup::Position Popup::position() const
{
- return _pos;
+ return pos_;
}
void Popup::set_position(const QPoint point, Position pos)
{
- _point = point, _pos = pos;
+ point_ = point, pos_ = pos;
setContentsMargins(
MarginWidth + ((pos == Right) ? ArrowLength : 0),
bool Popup::space_for_arrow() const
{
// Check if there is room for the arrow
- switch (_pos) {
+ switch (pos_) {
case Right:
- if (_point.x() > x())
+ if (point_.x() > x())
return false;
return true;
case Bottom:
- if (_point.y() > y())
+ if (point_.y() > y())
return false;
return true;
case Left:
- if (_point.x() < (x() + width()))
+ if (point_.x() < (x() + width()))
return false;
return true;
case Top:
- if (_point.y() < (y() + height()))
+ if (point_.y() < (y() + height()))
return false;
return true;
}
{
QPolygon poly;
- const QPoint p = mapFromGlobal(_point);
+ const QPoint p = mapFromGlobal(point_);
const int l = ArrowLength + ArrowOverlap;
- switch (_pos)
+ switch (pos_)
{
case Right:
poly << QPoint(p.x() + l, p.y() - l);
poly << p;
- switch (_pos)
+ switch (pos_)
{
case Right:
case Bottom:
QRect Popup::bubble_rect() const
{
return QRect(
- QPoint((_pos == Right) ? ArrowLength : 0,
- (_pos == Bottom) ? ArrowLength : 0),
- QSize(width() - ((_pos == Left || _pos == Right) ?
+ QPoint((pos_ == Right) ? ArrowLength : 0,
+ (pos_ == Bottom) ? ArrowLength : 0),
+ QSize(width() - ((pos_ == Left || pos_ == Right) ?
ArrowLength : 0),
- height() - ((_pos == Top || _pos == Bottom) ?
+ height() - ((pos_ == Top || pos_ == Bottom) ?
ArrowLength : 0)));
}
QPoint o;
const QRect screen_rect = QApplication::desktop()->availableGeometry(
- QApplication::desktop()->screenNumber(_point));
+ QApplication::desktop()->screenNumber(point_));
- if (_pos == Right || _pos == Left)
+ if (pos_ == Right || pos_ == Left)
o.ry() = -height() / 2;
else
o.rx() = -width() / 2;
- if (_pos == Left)
+ if (pos_ == Left)
o.rx() = -width();
- else if(_pos == Top)
+ else if(pos_ == Top)
o.ry() = -height();
- o += _point;
+ o += point_;
move(max(min(o.x(), screen_rect.right() - width()),
screen_rect.left()),
max(min(o.y(), screen_rect.bottom() - height()),
const QRegion a(arrow_region());
const QRegion arrow_outline = a.subtracted(
- a.translated(ArrowOffsets[_pos]));
+ a.translated(ArrowOffsets[pos_]));
painter.setClipRegion(bubble_outline.subtracted(a).united(
arrow_outline));
void closed();
private:
- QPoint _point;
- Position _pos;
+ QPoint point_;
+ Position pos_;
};
} // namespace widgets
PopupToolButton::PopupToolButton(QWidget *parent) :
QToolButton(parent),
- _popup(NULL)
+ popup_(NULL)
{
connect(this, SIGNAL(clicked(bool)), this, SLOT(on_clicked(bool)));
}
Popup* PopupToolButton::popup() const
{
- return _popup;
+ return popup_;
}
void PopupToolButton::set_popup(Popup *popup)
{
assert(popup);
- _popup = popup;
+ popup_ = popup;
}
void PopupToolButton::on_clicked(bool)
{
- if(!_popup)
+ if(!popup_)
return;
const QRect r = rect();
- _popup->set_position(mapToGlobal(QPoint((r.left() + r.right()) / 2,
+ popup_->set_position(mapToGlobal(QPoint((r.left() + r.right()) / 2,
((r.top() + r.bottom() * 3) / 4))), Popup::Bottom);
- _popup->show();
+ popup_->show();
}
} // widgets
void on_clicked(bool);
private:
- Popup *_popup;
+ Popup *popup_;
};
} // widgets
SweepTimingWidget::SweepTimingWidget(const char *suffix,
QWidget *parent) :
QWidget(parent),
- _suffix(suffix),
- _layout(this),
- _value(this),
- _list(this),
- _value_type(None)
+ suffix_(suffix),
+ layout_(this),
+ value_(this),
+ list_(this),
+ value_type_(None)
{
setContentsMargins(0, 0, 0, 0);
- _value.setDecimals(0);
- _value.setSuffix(QString::fromUtf8(suffix));
+ value_.setDecimals(0);
+ value_.setSuffix(QString::fromUtf8(suffix));
- connect(&_list, SIGNAL(currentIndexChanged(int)),
+ connect(&list_, SIGNAL(currentIndexChanged(int)),
this, SIGNAL(value_changed()));
- connect(&_value, SIGNAL(editingFinished()),
+ connect(&value_, SIGNAL(editingFinished()),
this, SIGNAL(value_changed()));
- setLayout(&_layout);
- _layout.setMargin(0);
- _layout.addWidget(&_list);
- _layout.addWidget(&_value);
+ setLayout(&layout_);
+ layout_.setMargin(0);
+ layout_.addWidget(&list_);
+ layout_.addWidget(&value_);
show_none();
}
void SweepTimingWidget::show_none()
{
- _value_type = None;
- _value.hide();
- _list.hide();
+ value_type_ = None;
+ value_.hide();
+ list_.hide();
}
void SweepTimingWidget::show_min_max_step(uint64_t min, uint64_t max,
assert(max > min);
assert(step > 0);
- _value_type = MinMaxStep;
+ value_type_ = MinMaxStep;
- _value.setRange(min, max);
- _value.setSingleStep(step);
+ value_.setRange(min, max);
+ value_.setSingleStep(step);
- _value.show();
- _list.hide();
+ value_.show();
+ list_.hide();
}
void SweepTimingWidget::show_list(const uint64_t *vals, size_t count)
{
- _value_type = List;
+ value_type_ = List;
- _list.clear();
+ list_.clear();
for (size_t i = 0; i < count; i++)
{
- char *const s = sr_si_string_u64(vals[i], _suffix);
- _list.addItem(QString::fromUtf8(s),
+ char *const s = sr_si_string_u64(vals[i], suffix_);
+ list_.addItem(QString::fromUtf8(s),
qVariantFromValue(vals[i]));
g_free(s);
}
- _value.hide();
- _list.show();
+ value_.hide();
+ list_.show();
}
void SweepTimingWidget::show_125_list(uint64_t min, uint64_t max)
uint64_t SweepTimingWidget::value() const
{
- switch(_value_type)
+ switch(value_type_)
{
case None:
return 0;
case MinMaxStep:
- return (uint64_t)_value.value();
+ return (uint64_t)value_.value();
case List:
{
- const int index = _list.currentIndex();
- return (index >= 0) ? _list.itemData(
+ const int index = list_.currentIndex();
+ return (index >= 0) ? list_.itemData(
index).value<uint64_t>() : 0;
}
void SweepTimingWidget::set_value(uint64_t value)
{
- _value.setValue(value);
+ value_.setValue(value);
- int best_match = _list.count() - 1;
+ int best_match = list_.count() - 1;
int64_t best_variance = INT64_MAX;
- for (int i = 0; i < _list.count(); i++) {
+ for (int i = 0; i < list_.count(); i++) {
const int64_t this_variance = abs(
- (int64_t)value - _list.itemData(i).value<int64_t>());
+ (int64_t)value - list_.itemData(i).value<int64_t>());
if (this_variance < best_variance) {
best_variance = this_variance;
best_match = i;
}
}
- _list.setCurrentIndex(best_match);
+ list_.setCurrentIndex(best_match);
}
} // widgets
void value_changed();
private:
- const char *const _suffix;
+ const char *const suffix_;
- QHBoxLayout _layout;
+ QHBoxLayout layout_;
- QDoubleSpinBox _value;
- QComboBox _list;
+ QDoubleSpinBox value_;
+ QComboBox list_;
- ValueType _value_type;
+ ValueType value_type_;
};
} // widgets
#include <QDebug>
#include <QSocketNotifier>
-int SignalHandler::_sockets[2];
+int SignalHandler::sockets_[2];
bool SignalHandler::prepare_signals()
{
- if(socketpair(AF_UNIX, SOCK_STREAM, 0, _sockets) != 0)
+ if(socketpair(AF_UNIX, SOCK_STREAM, 0, sockets_) != 0)
return false;
struct sigaction sig_action;
if(sigaction(SIGINT, &sig_action, 0) != 0 ||
sigaction(SIGTERM, &sig_action, 0) != 0) {
- close(_sockets[0]);
- close(_sockets[1]);
+ close(sockets_[0]);
+ close(sockets_[1]);
return false;
}
}
SignalHandler::SignalHandler(QObject* parent) : QObject(parent),
- _socket_notifier(0)
+ socket_notifier_(0)
{
- _socket_notifier = new QSocketNotifier(_sockets[1],
+ socket_notifier_ = new QSocketNotifier(sockets_[1],
QSocketNotifier::Read, this);
- connect(_socket_notifier, SIGNAL(activated(int)),
+ connect(socket_notifier_, SIGNAL(activated(int)),
SLOT(on_socket_notifier_activated()));
}
void SignalHandler::on_socket_notifier_activated()
{
- _socket_notifier->setEnabled(false);
+ socket_notifier_->setEnabled(false);
int sig_number;
- if(read(_sockets[1], &sig_number, sizeof(int)) !=
+ if(read(sockets_[1], &sig_number, sizeof(int)) !=
sizeof(int)) {
qDebug() << "Failed to catch signal";
abort();
break;
}
- _socket_notifier->setEnabled(true);
+ socket_notifier_->setEnabled(true);
}
void SignalHandler::handle_signals(int sig_number)
{
- if(write(_sockets[0], &sig_number, sizeof(int)) !=
+ if(write(sockets_[0], &sig_number, sizeof(int)) !=
sizeof(int)) {
// Failed to handle signal
abort();
static void handle_signals(int sig_number);
private:
- QSocketNotifier* _socket_notifier;
+ QSocketNotifier* socket_notifier_;
private:
- static int _sockets[2];
+ static int sockets_[2];
};
#endif // SIGNALHANDLER_H
BOOST_CHECK(s.get_sample_count() == 0);
for (unsigned int i = 0; i < AnalogSnapshot::ScaleStepCount; i++)
{
- const AnalogSnapshot::Envelope &m = s._envelope_levels[i];
+ const AnalogSnapshot::Envelope &m = s.envelope_levels_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
BOOST_CHECK(m.samples == NULL);
// There should not be enough samples to have a single mip map sample
for (unsigned int i = 0; i < AnalogSnapshot::ScaleStepCount; i++)
{
- const AnalogSnapshot::Envelope &m = s._envelope_levels[i];
+ const AnalogSnapshot::Envelope &m = s.envelope_levels_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
BOOST_CHECK(m.samples == NULL);
// There should now be enough data for exactly one sample
// in mip map level 0, and that sample should be 0
- const AnalogSnapshot::Envelope &e0 = s._envelope_levels[0];
+ const AnalogSnapshot::Envelope &e0 = s.envelope_levels_[0];
BOOST_CHECK_EQUAL(e0.length, 1);
BOOST_CHECK_EQUAL(e0.data_length, AnalogSnapshot::EnvelopeDataUnit);
BOOST_REQUIRE(e0.samples != NULL);
// The higher levels should still be empty
for (unsigned int i = 1; i < AnalogSnapshot::ScaleStepCount; i++)
{
- const AnalogSnapshot::Envelope &m = s._envelope_levels[i];
+ const AnalogSnapshot::Envelope &m = s.envelope_levels_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
BOOST_CHECK(m.samples == NULL);
BOOST_CHECK_EQUAL(e0.samples[i].max, -1.0f);
}
- const AnalogSnapshot::Envelope &e1 = s._envelope_levels[1];
+ const AnalogSnapshot::Envelope &e1 = s.envelope_levels_[1];
BOOST_CHECK_EQUAL(e1.length, 1);
BOOST_CHECK_EQUAL(e1.data_length, AnalogSnapshot::EnvelopeDataUnit);
BOOST_REQUIRE(e1.samples != NULL);
BOOST_REQUIRE(dec1);
// Wait for the decode threads to complete
- dec0->_decode_thread.join();
- dec1->_decode_thread.join();
+ dec0->decode_thread_.join();
+ dec1->decode_thread_.join();
// Check there were no errors
BOOST_CHECK_EQUAL(dec0->error_message().isEmpty(), true);
BOOST_CHECK(s.get_sample_count() == 0);
for (unsigned int i = 0; i < LogicSnapshot::ScaleStepCount; i++)
{
- const LogicSnapshot::MipMapLevel &m = s._mip_map[i];
+ const LogicSnapshot::MipMapLevel &m = s.mip_map_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
BOOST_CHECK(m.data == NULL);
// There should not be enough samples to have a single mip map sample
for (unsigned int i = 0; i < LogicSnapshot::ScaleStepCount; i++)
{
- const LogicSnapshot::MipMapLevel &m = s._mip_map[i];
+ const LogicSnapshot::MipMapLevel &m = s.mip_map_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
BOOST_CHECK(m.data == NULL);
// There should now be enough data for exactly one sample
// in mip map level 0, and that sample should be 0
- const LogicSnapshot::MipMapLevel &m0 = s._mip_map[0];
+ const LogicSnapshot::MipMapLevel &m0 = s.mip_map_[0];
BOOST_CHECK_EQUAL(m0.length, 1);
BOOST_CHECK_EQUAL(m0.data_length, LogicSnapshot::MipMapDataUnit);
BOOST_REQUIRE(m0.data != NULL);
// The higher levels should still be empty
for (unsigned int i = 1; i < LogicSnapshot::ScaleStepCount; i++)
{
- const LogicSnapshot::MipMapLevel &m = s._mip_map[i];
+ const LogicSnapshot::MipMapLevel &m = s.mip_map_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
BOOST_CHECK(m.data == NULL);
for (unsigned int i = 2; i < m0.length; i++)
BOOST_CHECK_EQUAL(((uint8_t*)m0.data)[i], 0);
- const LogicSnapshot::MipMapLevel &m1 = s._mip_map[1];
+ const LogicSnapshot::MipMapLevel &m1 = s.mip_map_[1];
BOOST_CHECK_EQUAL(m1.length, 1);
BOOST_CHECK_EQUAL(m1.data_length, LogicSnapshot::MipMapDataUnit);
BOOST_REQUIRE(m1.data != NULL);
BOOST_CHECK(s.get_sample_count() == Length);
// Check mip map level 0
- BOOST_CHECK_EQUAL(s._mip_map[0].length, 62500);
- BOOST_CHECK_EQUAL(s._mip_map[0].data_length,
+ BOOST_CHECK_EQUAL(s.mip_map_[0].length, 62500);
+ BOOST_CHECK_EQUAL(s.mip_map_[0].data_length,
LogicSnapshot::MipMapDataUnit);
- BOOST_REQUIRE(s._mip_map[0].data != NULL);
+ BOOST_REQUIRE(s.mip_map_[0].data != NULL);
prev_sample = 0;
- for (unsigned int i = 0; i < s._mip_map[0].length;)
+ for (unsigned int i = 0; i < s.mip_map_[0].length;)
{
BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]");
prev_sample ^ sample);
prev_sample = sample;
- for (int j = 1; i < s._mip_map[0].length && j < 16; j++)
+ for (int j = 1; i < s.mip_map_[0].length && j < 16; j++)
{
BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]");
BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, 0);
}
// Check mip map level 1
- BOOST_CHECK_EQUAL(s._mip_map[1].length, 3906);
- BOOST_CHECK_EQUAL(s._mip_map[1].data_length,
+ BOOST_CHECK_EQUAL(s.mip_map_[1].length, 3906);
+ BOOST_CHECK_EQUAL(s.mip_map_[1].data_length,
LogicSnapshot::MipMapDataUnit);
- BOOST_REQUIRE(s._mip_map[1].data != NULL);
+ BOOST_REQUIRE(s.mip_map_[1].data != NULL);
prev_sample = 0;
- for (unsigned int i = 0; i < s._mip_map[1].length; i++)
+ for (unsigned int i = 0; i < s.mip_map_[1].length; i++)
{
BOOST_TEST_MESSAGE("Testing mip_map[1].data[" << i << "]");
}
// Check mip map level 2
- BOOST_CHECK_EQUAL(s._mip_map[2].length, 244);
- BOOST_CHECK_EQUAL(s._mip_map[2].data_length,
+ BOOST_CHECK_EQUAL(s.mip_map_[2].length, 244);
+ BOOST_CHECK_EQUAL(s.mip_map_[2].data_length,
LogicSnapshot::MipMapDataUnit);
- BOOST_REQUIRE(s._mip_map[2].data != NULL);
+ BOOST_REQUIRE(s.mip_map_[2].data != NULL);
prev_sample = 0;
- for (unsigned int i = 0; i < s._mip_map[2].length; i++)
+ for (unsigned int i = 0; i < s.mip_map_[2].length; i++)
{
BOOST_TEST_MESSAGE("Testing mip_map[2].data[" << i << "]");
}
// Check mip map level 3
- BOOST_CHECK_EQUAL(s._mip_map[3].length, 15);
- BOOST_CHECK_EQUAL(s._mip_map[3].data_length,
+ BOOST_CHECK_EQUAL(s.mip_map_[3].length, 15);
+ BOOST_CHECK_EQUAL(s.mip_map_[3].data_length,
LogicSnapshot::MipMapDataUnit);
- BOOST_REQUIRE(s._mip_map[3].data != NULL);
+ BOOST_REQUIRE(s.mip_map_[3].data != NULL);
- for (unsigned int i = 0; i < s._mip_map[3].length; i++)
- BOOST_CHECK_EQUAL(*((uint8_t*)s._mip_map[3].data + i),
+ for (unsigned int i = 0; i < s.mip_map_[3].length; i++)
+ BOOST_CHECK_EQUAL(*((uint8_t*)s.mip_map_[3].data + i),
0xFF);
// Check the higher levels
for (unsigned int i = 4; i < LogicSnapshot::ScaleStepCount; i++)
{
- const LogicSnapshot::MipMapLevel &m = s._mip_map[i];
+ const LogicSnapshot::MipMapLevel &m = s.mip_map_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
BOOST_CHECK(m.data == NULL);
//----- Check the mip-map -----//
// Check mip map level 0
- BOOST_CHECK_EQUAL(s._mip_map[0].length, 12);
- BOOST_CHECK_EQUAL(s._mip_map[0].data_length,
+ BOOST_CHECK_EQUAL(s.mip_map_[0].length, 12);
+ BOOST_CHECK_EQUAL(s.mip_map_[0].data_length,
LogicSnapshot::MipMapDataUnit);
- BOOST_REQUIRE(s._mip_map[0].data != NULL);
+ BOOST_REQUIRE(s.mip_map_[0].data != NULL);
- for (unsigned int i = 0; i < s._mip_map[0].length;) {
+ for (unsigned int i = 0; i < s.mip_map_[0].length;) {
BOOST_TEST_MESSAGE("Testing mip_map[0].data[" << i << "]");
BOOST_CHECK_EQUAL(s.get_subsample(0, i++) & 0xFF, 0xFF);
for (int j = 1;
- i < s._mip_map[0].length &&
+ i < s.mip_map_[0].length &&
j < Period/LogicSnapshot::MipMapScaleFactor; j++) {
BOOST_TEST_MESSAGE(
"Testing mip_map[0].data[" << i << "]");
// Check the higher levels are all inactive
for (unsigned int i = 1; i < LogicSnapshot::ScaleStepCount; i++) {
- const LogicSnapshot::MipMapLevel &m = s._mip_map[i];
+ const LogicSnapshot::MipMapLevel &m = s.mip_map_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
BOOST_CHECK(m.data == NULL);
//----- Check the mip-map -----//
// Check mip map level 0
- BOOST_CHECK_EQUAL(s._mip_map[0].length, 12);
- BOOST_CHECK_EQUAL(s._mip_map[0].data_length,
+ BOOST_CHECK_EQUAL(s.mip_map_[0].length, 12);
+ BOOST_CHECK_EQUAL(s.mip_map_[0].data_length,
LogicSnapshot::MipMapDataUnit);
- BOOST_REQUIRE(s._mip_map[0].data != NULL);
+ BOOST_REQUIRE(s.mip_map_[0].data != NULL);
- for (unsigned int i = 0; i < s._mip_map[0].length;) {
- for (j = 0; i < s._mip_map[0].length && j < 2; j++) {
+ for (unsigned int i = 0; i < s.mip_map_[0].length;) {
+ for (j = 0; i < s.mip_map_[0].length && j < 2; j++) {
BOOST_TEST_MESSAGE(
"Testing mip_map[0].data[" << i << "]");
BOOST_CHECK_EQUAL(s.get_subsample(0, i++), ~0);
}
- for (; i < s._mip_map[0].length &&
+ for (; i < s.mip_map_[0].length &&
j < Period/LogicSnapshot::MipMapScaleFactor; j++) {
BOOST_TEST_MESSAGE(
"Testing mip_map[0].data[" << i << "]");
// Check the higher levels are all inactive
for (unsigned int i = 1; i < LogicSnapshot::ScaleStepCount; i++) {
- const LogicSnapshot::MipMapLevel &m = s._mip_map[i];
+ const LogicSnapshot::MipMapLevel &m = s.mip_map_[i];
BOOST_CHECK_EQUAL(m.length, 0);
BOOST_CHECK_EQUAL(m.data_length, 0);
BOOST_CHECK(m.data == NULL);