// Run the application
ret = a.exec();
- } catch(std::exception e) {
+ } catch (std::exception e) {
qDebug() << e.what();
}
{
assert(layout);
- for (shared_ptr<pv::prop::Property> p : properties_)
- {
+ for (shared_ptr<pv::prop::Property> p : properties_) {
assert(p);
QWidget *const widget = p->get_widget(layout->parentWidget(),
const srd_decoder *const dec = decoder_->decoder();
assert(dec);
- for (GSList *l = dec->options; l; l = l->next)
- {
+ for (GSList *l = dec->options; l; l = l->next) {
const srd_decoder_option *const opt =
(srd_decoder_option*)l->data;
if (iter != options.end())
val = (*iter).second;
- else
- {
+ else {
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;
if (strcmp(opt->id, id) == 0) {
config_changed();
};
- switch (key->id())
- {
+ switch (key->id()) {
case SR_CONF_SAMPLERATE:
// Sample rate values are not bound because they are shown
// in the MainBar
InputOutput::InputOutput(
const map<string, shared_ptr<Option>> &options)
{
- for (pair<string, shared_ptr<Option>> o : options)
- {
+ for (pair<string, shared_ptr<Option>> o : options) {
const shared_ptr<Option> &opt = o.second;
assert(opt);
float *dst = (float*)data_.data() + sample_count_;
const float *dst_end = dst + sample_count;
- while (dst != dst_end)
- {
+ while (dst != dst_end) {
*dst++ = *data;
data += stride;
}
{
const uint64_t new_data_length = ((e.length + EnvelopeDataUnit - 1) /
EnvelopeDataUnit) * EnvelopeDataUnit;
- if (new_data_length > e.data_length)
- {
+ if (new_data_length > e.data_length) {
e.data_length = new_data_length;
e.samples = (EnvelopeSample*)realloc(e.samples,
new_data_length * sizeof(EnvelopeSample));
const float *const end_src_ptr = (float*)data_.data() +
e0.length * EnvelopeScaleFactor;
for (const float *src_ptr = (float*)data_.data() +
- prev_length * EnvelopeScaleFactor;
- src_ptr < end_src_ptr; src_ptr += EnvelopeScaleFactor)
- {
+ prev_length * EnvelopeScaleFactor;
+ src_ptr < end_src_ptr; src_ptr += EnvelopeScaleFactor) {
const EnvelopeSample sub_sample = {
*min_element(src_ptr, src_ptr + EnvelopeScaleFactor),
*max_element(src_ptr, src_ptr + EnvelopeScaleFactor),
}
// Compute higher level mipmaps
- for (unsigned int level = 1; level < ScaleStepCount; level++)
- {
+ for (unsigned int level = 1; level < ScaleStepCount; level++) {
Envelope &e = envelope_levels_[level];
const Envelope &el = envelope_levels_[level-1];
el.samples + prev_length * EnvelopeScaleFactor;
const EnvelopeSample *const end_dest_ptr = e.samples + e.length;
for (dest_ptr = e.samples + prev_length;
- dest_ptr < end_dest_ptr; dest_ptr++)
- {
+ dest_ptr < end_dest_ptr; dest_ptr++) {
const EnvelopeSample *const end_src_ptr =
src_ptr + EnvelopeScaleFactor;
EnvelopeSample sub_sample = *src_ptr++;
- while (src_ptr < end_src_ptr)
- {
+ while (src_ptr < end_src_ptr) {
sub_sample.min = min(sub_sample.min, src_ptr->min);
sub_sample.max = max(sub_sample.max, src_ptr->max);
src_ptr++;
vector<Row> rows;
- for (const shared_ptr<decode::Decoder> &dec : stack_)
- {
+ for (const shared_ptr<decode::Decoder> &dec : stack_) {
assert(dec);
if (!dec->shown())
continue;
rows.push_back(Row(decc));
// Add the decoder rows
- for (const GSList *l = decc->annotation_rows; l; l = l->next)
- {
+ for (const GSList *l = decc->annotation_rows; l; l = l->next) {
const srd_decoder_annotation_row *const ann_row =
(srd_decoder_annotation_row *)l->data;
assert(ann_row);
}
// 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();
assert(dec->decoder());
rows_[Row(decc)] = decode::RowData();
// Add the decoder rows
- for (const GSList *l = decc->annotation_rows; l; l = l->next)
- {
+ for (const GSList *l = decc->annotation_rows; l; l = l->next) {
const srd_decoder_annotation_row *const ann_row =
(srd_decoder_annotation_row *)l->data;
assert(ann_row);
DecodeChunkLength / segment_->unit_size();
for (int64_t i = 0; !interrupt_ && i < sample_count;
- i += chunk_sample_count)
- {
+ i += chunk_sample_count) {
lock_guard<mutex> decode_lock(global_decode_mutex_);
const int64_t chunk_end = min(
// Create the decoders
const unsigned int unit_size = segment_->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);
- if (!di)
- {
+ if (!di) {
error_message_ = tr("Failed to create decoder instance");
srd_session_destroy(session);
return;
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
- {
+ else {
// Failing that, use the decoder as a key
row_iter = d->rows_.find(Row(decc));
}
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 */
{
const uint64_t new_data_length = ((m.length + MipMapDataUnit - 1) /
MipMapDataUnit) * MipMapDataUnit;
- if (new_data_length > m.data_length)
- {
+ if (new_data_length > m.data_length) {
m.data_length = new_data_length;
// Padding is added to allow for the uint64_t write word
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;)
- {
+ prev_length * unit_size_ * MipMapScaleFactor;
+ src_ptr < end_src_ptr;) {
// Accumulate transitions which have occurred in this sample
accumulator = 0;
diff_counter = MipMapScaleFactor;
- while (diff_counter-- > 0)
- {
+ while (diff_counter-- > 0) {
const uint64_t sample = unpack_sample(src_ptr);
accumulator |= last_append_sample_ ^ sample;
last_append_sample_ = sample;
}
// Compute higher level mipmaps
- for (unsigned int level = 1; level < ScaleStepCount; level++)
- {
+ for (unsigned int level = 1; level < ScaleStepCount; level++) {
MipMapLevel &m = mip_map_[level];
const MipMapLevel &ml = mip_map_[level-1];
const uint8_t *const end_dest_ptr =
(uint8_t*)m.data + unit_size_ * m.length;
for (dest_ptr = (uint8_t*)m.data +
- unit_size_ * prev_length;
- dest_ptr < end_dest_ptr;
- dest_ptr += unit_size_)
- {
+ unit_size_ * prev_length;
+ dest_ptr < end_dest_ptr;
+ dest_ptr += unit_size_) {
accumulator = 0;
diff_counter = MipMapScaleFactor;
- while (diff_counter-- > 0)
- {
+ while (diff_counter-- > 0) {
accumulator |= unpack_sample(src_ptr);
src_ptr += unit_size_;
}
last_sample = (get_sample(start) & sig_mask) != 0;
edges.push_back(pair<int64_t, bool>(index++, last_sample));
- while (index + block_length <= end)
- {
+ while (index + block_length <= end) {
//----- Continue to search -----//
level = min_level;
// at the minimum level.
fast_forward = (mip_map_[level].data != nullptr);
- if (min_length < MipMapScaleFactor)
- {
+ if (min_length < MipMapScaleFactor) {
// Search individual samples up to the beginning of
// the next first level mip map block
const uint64_t final_index = min(end,
pow2_ceil(index, MipMapScalePower));
for (; index < final_index &&
- (index & ~(~0 << MipMapScalePower)) != 0;
- index++)
- {
+ (index & ~(~0 << MipMapScalePower)) != 0;
+ index++) {
const bool sample =
(get_sample(index) & sig_mask) != 0;
break;
}
}
- }
- else
- {
+ } else {
// If resolution is less than a mip map block,
// round up to the beginning of the mip-map block
// for this level of detail
// 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 ||
- (get_subsample(level, offset) &
+ (get_subsample(level, offset) &
sig_mask)) {
// Zoom in unless we reached the minimum
// zoom
// Ensure there's enough capacity to copy.
const uint64_t free_space = capacity_ - sample_count_;
- if (free_space < samples) {
+ if (free_space < samples)
set_capacity(sample_count_ + samples);
- }
memcpy((uint8_t*)data_.data() + sample_count_ * unit_size_,
data, samples * unit_size_);
// If present, vendor and model always have to match.
if (dev_info.count("vendor") > 0 && search_info.count("vendor") > 0)
- if (dev_info.at("vendor") != search_info.at("vendor")) continue;
+ if (dev_info.at("vendor") != search_info.at("vendor"))
+ continue;
if (dev_info.count("model") > 0 && search_info.count("model") > 0)
- if (dev_info.at("model") != search_info.at("model")) continue;
+ if (dev_info.at("model") != search_info.at("model"))
+ continue;
// Most unique match: vendor/model/serial_num (but don't match a S/N of 0)
if ((dev_info.count("serial_num") > 0) && (dev_info.at("serial_num") != "0")
}
bool DeviceManager::compare_devices(shared_ptr<devices::Device> a,
- shared_ptr<devices::Device> b) {
+ shared_ptr<devices::Device> b)
+{
assert(a);
assert(b);
return a->display_name(*this).compare(b->display_name(*this)) < 0;
namespace pv {
namespace devices {
-Device::Device() {
+Device::Device()
+{
}
-Device::~Device() {
+Device::~Device()
+{
if (session_)
session_->remove_datafeed_callbacks();
}
-std::shared_ptr<sigrok::Session> Device::session() const {
+std::shared_ptr<sigrok::Session> Device::session() const
+{
return session_;
}
-std::shared_ptr<sigrok::Device> Device::device() const {
+std::shared_ptr<sigrok::Device> Device::device() const
+{
return device_;
}
device_->config_get(ConfigKey::SAMPLERATE)).get();
}
-void Device::start() {
+void Device::start()
+{
assert(session_);
session_->start();
}
-void Device::run() {
+void Device::run()
+{
assert(device_);
assert(session_);
session_->run();
}
-void Device::stop() {
+void Device::stop()
+{
assert(session_);
session_->stop();
}
namespace devices {
File::File(const std::string &file_name) :
- file_name_(file_name) {
+ file_name_(file_name)
+{
}
-std::string File::full_name() const {
+std::string File::full_name() const
+{
return boost::filesystem::path(file_name_).filename().string();
}
-std::string File::display_name(const DeviceManager&) const {
+std::string File::display_name(const DeviceManager&) const
+{
return File::full_name();
}
HardwareDevice::HardwareDevice(const std::shared_ptr<sigrok::Context> &context,
std::shared_ptr<sigrok::HardwareDevice> device) :
context_(context),
- device_open_(false) {
+ device_open_(false)
+{
device_ = device;
}
-HardwareDevice::~HardwareDevice() {
+HardwareDevice::~HardwareDevice()
+{
close();
}
-string HardwareDevice::full_name() const {
+string HardwareDevice::full_name() const
+{
vector<string> parts = {device_->vendor(), device_->model(),
device_->version(), device_->serial_number()};
if (device_->connection_id().length() > 0)
return join(parts, " ");
}
-shared_ptr<sigrok::HardwareDevice> HardwareDevice::hardware_device() const {
+shared_ptr<sigrok::HardwareDevice> HardwareDevice::hardware_device() const
+{
return static_pointer_cast<sigrok::HardwareDevice>(device_);
}
string HardwareDevice::display_name(
- const DeviceManager &device_manager) const {
+ const DeviceManager &device_manager) const
+{
const auto hw_dev = hardware_device();
// If we can find another device with the same model/vendor then
return join(parts, " ");
}
-void HardwareDevice::open() {
+void HardwareDevice::open()
+{
if (device_open_)
close();
try {
device_->open();
- } catch(const sigrok::Error &e) {
+ } catch (const sigrok::Error &e) {
throw QString(e.what());
}
session_->add_device(device_);
}
-void HardwareDevice::close() {
+void HardwareDevice::close()
+{
if (device_open_)
device_->close();
File(file_name),
context_(context),
input_(format->create_input(options)),
- interrupt_(false) {
+ interrupt_(false)
+{
if (!input_)
throw QString("Failed to create input");
}
-void InputFile::open() {
+void InputFile::open()
+{
if (session_)
close();
session_ = context_->create_session();
}
-void InputFile::close() {
+void InputFile::close()
+{
if (session_)
session_->remove_devices();
}
-void InputFile::start() {
+void InputFile::start()
+{
}
-void InputFile::run() {
+void InputFile::run()
+{
char buffer[BufferSize];
bool need_device = true;
input_->end();
}
-void InputFile::stop() {
+void InputFile::stop()
+{
interrupt_ = true;
}
SessionFile::SessionFile(const std::shared_ptr<sigrok::Context> context,
const std::string &file_name) :
File(file_name),
- context_(context) {
+ context_(context)
+{
}
-void SessionFile::open() {
+void SessionFile::open()
+{
if (session_)
close();
device_ = session_->devices()[0];
}
-void SessionFile::close() {
+void SessionFile::close()
+{
if (session_)
session_->remove_devices();
}
const list< shared_ptr<HardwareDevice> > devices =
device_manager_.driver_scan(driver, drvopts);
- for (shared_ptr<HardwareDevice> device : devices)
- {
+ for (shared_ptr<HardwareDevice> device : devices) {
assert(device);
QString text = QString::fromStdString(
void MainWindow::run_stop()
{
- switch(session_.get_capture_state()) {
+ switch (session_.get_capture_state()) {
case Session::Stopped:
session_.start_capture([&](QString message) {
session_error("Capture failed", message); });
break;
-
case Session::AwaitingTrigger:
case Session::Running:
session_.stop_capture();
session_.set_device(device);
else
session_.set_default_device();
- } catch(const QString &e) {
+ } catch (const QString &e) {
QMessageBox msg(this);
msg.setText(e);
msg.setInformativeText(tr("Failed to Select Device"));
}
-void MainWindow::select_init_device() {
+void MainWindow::select_init_device()
+{
QSettings settings;
map<string, string> dev_info;
list<string> key_list;
}
void MainWindow::load_init_file(const std::string &file_name,
- const std::string &format) {
+ const std::string &format)
+{
shared_ptr<InputFormat> input_format;
if (!format.empty()) {
session_.device());
for (string key : key_list) {
-
if (dev_info.count(key))
settings.setValue(QString::fromUtf8(key.c_str()),
QString::fromUtf8(dev_info.at(key).c_str()));
new devices::SessionFile(
device_manager_.context(),
file_name.toStdString())));
- } catch(Error e) {
+ } catch (Error e) {
show_session_error(tr("Failed to load ") + file_name, e.what());
session_.set_default_device();
update_device_list();
signal_map[sig->channel()] = sig;
// Populate channel groups
- for (auto entry : device->channel_groups())
- {
+ for (auto entry : device->channel_groups()) {
shared_ptr<ChannelGroup> group = entry.second;
// Make a set of signals, and removed this signals from the
// signal map.
vector< shared_ptr<Signal> > group_sigs;
- for (auto channel : group->channels())
- {
+ for (auto channel : group->channels()) {
const auto iter = signal_map.find(channel);
if (iter == signal_map.end())
// Make a vector of the remaining channels
vector< shared_ptr<Signal> > global_sigs;
- for (auto channel : device->channels())
- {
+ for (auto channel : device->channels()) {
const map<shared_ptr<Channel>, shared_ptr<Signal> >::
const_iterator iter = signal_map.find(channel);
if (iter != signal_map.end())
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);
int row = 0, col = 0;
QGridLayout *const grid = new QGridLayout();
- for (const shared_ptr<pv::view::Signal>& sig : sigs)
- {
+ for (const shared_ptr<pv::view::Signal>& sig : sigs) {
assert(sig);
QCheckBox *const checkbox = new QCheckBox(sig->name());
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);
const GVariantType *const type = g_variant_get_type(value);
assert(type);
- if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE))
- {
+ if (g_variant_type_equal(type, G_VARIANT_TYPE_BYTE)) {
int_val = g_variant_get_byte(value);
range_min = 0, range_max = UINT8_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16))
- {
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT16)) {
int_val = g_variant_get_int16(value);
range_min = INT16_MIN, range_max = INT16_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16))
- {
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT16)) {
int_val = g_variant_get_uint16(value);
range_min = 0, range_max = UINT16_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32))
- {
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT32)) {
int_val = g_variant_get_int32(value);
range_min = INT32_MIN, range_max = INT32_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32))
- {
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT32)) {
int_val = g_variant_get_uint32(value);
range_min = 0, range_max = UINT32_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64))
- {
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_INT64)) {
int_val = g_variant_get_int64(value);
range_min = INT64_MIN, range_max = INT64_MAX;
- }
- else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64))
- {
+ } else if (g_variant_type_equal(type, G_VARIANT_TYPE_UINT64)) {
int_val = g_variant_get_uint64(value);
range_min = 0, range_max = UINT64_MAX;
- }
- else
- {
+ } else {
// Unexpected value type.
assert(0);
}
map<const srd_channel*, shared_ptr<view::LogicSignal> > channels;
shared_ptr<data::DecoderStack> decoder_stack;
- try
- {
+ try {
lock_guard<boost::shared_mutex> lock(signals_mutex_);
// Create the decoder
// 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);
if (l && QString::fromUtf8(pdch->name).
new view::DecodeTrace(*this, decoder_stack,
decode_traces_.size()));
decode_traces_.push_back(d);
- }
- catch(std::runtime_error e)
- {
+ } catch (std::runtime_error e) {
return false;
}
void Session::remove_decode_signal(view::DecodeTrace *signal)
{
for (auto i = decode_traces_.begin(); i != decode_traces_.end(); i++)
- if ((*i).get() == signal)
- {
+ if ((*i).get() == signal) {
decode_traces_.erase(i);
signals_changed();
return;
try {
device_->start();
- } catch(Error e) {
+ } catch (Error e) {
error_handler(e.what());
return;
}
set_capture_state(Stopped);
// Confirm that SR_DF_END was received
- if (cur_logic_segment_)
- {
+ if (cur_logic_segment_) {
qDebug("SR_DF_END was not received.");
assert(0);
}
const size_t sample_count = logic->data_length() / logic->unit_size();
- if (!logic_data_)
- {
+ if (!logic_data_) {
// The only reason logic_data_ would not have been created is
// if it was not possible to determine the signals when the
// device was created.
update_signals();
}
- if (!cur_logic_segment_)
- {
+ if (!cur_logic_segment_) {
// This could be the first packet after a trigger
set_capture_state(Running);
// frame_began is DecoderStack, but in future we need to signal
// this after both analog and logic sweeps have begun.
frame_began();
- }
- else
- {
+ } else {
// Append to the existing data segment
cur_logic_segment_->append_payload(logic);
}
const float *data = static_cast<const float *>(analog->data_pointer());
bool sweep_beginning = false;
- if (signals_.empty()) {
+ if (signals_.empty())
update_signals();
- }
- for (auto channel : channels)
- {
+ for (auto channel : channels) {
shared_ptr<data::AnalogSegment> segment;
// Try to get the segment of the channel
iterator iter = cur_analog_segments_.find(channel);
if (iter != cur_analog_segments_.end())
segment = (*iter).second;
- else
- {
+ else {
// If no segment was found, this means we havn't
// created one yet. i.e. this is the first packet
// in the sweep containing this segment.
const unsigned int samples_per_block = BlockSize / unit_size;
- while (!interrupt_ && sample_count_)
- {
+ while (!interrupt_ && sample_count_) {
progress_updated();
const uint64_t packet_len =
(*iter).second.find(sigrok::LIST) != (*iter).second.end()) {
try {
gvar_dict = sr_dev->config_list(ConfigKey::SAMPLERATE);
- } catch(const sigrok::Error &e) {
+ } catch (const sigrok::Error &e) {
// Failed to enunmerate samplerate
(void)e;
}
}
if ((gvar_list = g_variant_lookup_value(gvar_dict.gobj(),
- "samplerate-steps", G_VARIANT_TYPE("at"))))
- {
+ "samplerate-steps", G_VARIANT_TYPE("at")))) {
elements = (const uint64_t *)g_variant_get_fixed_array(
gvar_list, &num_elements, sizeof(uint64_t));
if (step == 1)
sample_rate_.show_125_list(min, max);
- else
- {
+ 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);
}
- }
- else if ((gvar_list = g_variant_lookup_value(gvar_dict.gobj(),
- "samplerates", G_VARIANT_TYPE("at"))))
- {
+ } else if ((gvar_list = g_variant_lookup_value(gvar_dict.gobj(),
+ "samplerates", G_VARIANT_TYPE("at")))) {
elements = (const uint64_t *)g_variant_get_fixed_array(
gvar_list, &num_elements, sizeof(uint64_t));
sample_rate_.show_list(elements, num_elements);
assert(!updating_sample_count_);
updating_sample_count_ = true;
- if (!sample_count_supported_)
- {
+ if (!sample_count_supported_) {
sample_count_.show_none();
updating_sample_count_ = false;
return;
if (gvar.gobj())
g_variant_get(gvar.gobj(), "(tt)",
&min_sample_count, &max_sample_count);
- } catch(const sigrok::Error &e) {
+ } catch (const sigrok::Error &e) {
// Failed to query sample limit
(void)e;
}
sample_count_supported_ = false;
try {
- for (auto entry : sr_dev->config_keys(ConfigKey::DEVICE_OPTIONS))
- {
+ for (auto entry : sr_dev->config_keys(ConfigKey::DEVICE_OPTIONS)) {
auto key = entry.first;
auto capabilities = entry.second;
switch (key->id()) {
sample_count_supported_ = true;
break;
case SR_CONF_LIMIT_FRAMES:
- if (capabilities.count(Capability::SET))
- {
+ if (capabilities.count(Capability::SET)) {
sr_dev->config_set(ConfigKey::LIMIT_FRAMES,
Glib::Variant<guint64>::create(1));
on_config_changed();
const shared_ptr<sigrok::Device> sr_dev = device->device();
sample_count = sample_count_.value();
- if (sample_count_supported_)
- {
+ if (sample_count_supported_) {
try {
sr_dev->config_set(ConfigKey::LIMIT_SAMPLES,
Glib::Variant<guint64>::create(sample_count));
bool MainBar::eventFilter(QObject *watched, QEvent *event)
{
- if (sample_count_supported_ &&
- (watched == &sample_count_ || watched == &sample_rate_) &&
- (event->type() == QEvent::ToolTip)) {
+ if (sample_count_supported_ && (watched == &sample_count_ ||
+ watched == &sample_rate_) &&
+ (event->type() == QEvent::ToolTip)) {
auto sec = pv::util::Timestamp(sample_count_.value()) / sample_rate_.value();
QHelpEvent *help_event = static_cast<QHelpEvent*>(event);
std::ostringstream ss;
ss << std::fixed;
- if (stream.numberFlags() & QTextStream::ForceSign) {
+ if (stream.numberFlags() & QTextStream::ForceSign)
ss << std::showpos;
- }
- if (0 == precision) {
- ss
- << std::setprecision(1)
- << round(t);
- } else {
- ss
- << std::setprecision(precision)
- << t;
- }
+ if (0 == precision)
+ ss << std::setprecision(1) << round(t);
+ else
+ ss << std::setprecision(precision) << t;
std::string str(ss.str());
if (0 == precision) {
return second_;
}
-void CursorPair::set_time(const pv::util::Timestamp& time) {
+void CursorPair::set_time(const pv::util::Timestamp& time)
+{
const pv::util::Timestamp delta = second_->time() - first_->time();
first_->set_time(time);
second_->set_time(time + delta);
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;
if (selected()) {
}
}
-void CursorPair::paint_back(QPainter &p, const ViewItemPaintParams &pp) {
+void CursorPair::paint_back(QPainter &p, const ViewItemPaintParams &pp)
+{
if (!enabled())
return;
assert(decoder_stack_);
const QString err = decoder_stack_->error_message();
- if (!err.isEmpty())
- {
+ if (!err.isEmpty()) {
draw_unresolved_period(
p, annotation_height, pp.left(), pp.right());
draw_error(p, err, pp);
const vector<Row> rows(decoder_stack_->get_visible_rows());
visible_rows_.clear();
- for (size_t i = 0; i < rows.size(); i++)
- {
+ for (size_t i = 0; i < rows.size(); i++) {
const Row &row = rows[i];
size_t base_colour = 0x13579BDF;
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();
p.setPen(QPen(Qt::NoPen));
p.setBrush(QApplication::palette().brush(QPalette::WindowText));
- if (i != 0)
- {
+ if (i != 0) {
const QPointF points[] = {
QPointF(pp.left(), y - ArrowSize),
QPointF(pp.left() + ArrowSize, y),
const list< shared_ptr<Decoder> >& stack = decoder_stack_->stack();
- if (stack.empty())
- {
+ if (stack.empty()) {
QLabel *const l = new QLabel(
tr("<p><i>No decoders in the stack</i></p>"));
l->setAlignment(Qt::AlignCenter);
form->addRow(l);
- }
- else
- {
+ } else {
auto iter = stack.cbegin();
for (int i = 0; i < (int)stack.size(); i++, iter++) {
shared_ptr<Decoder> dec(*iter);
p.setBrush(fill);
// If the two ends are within 1 pixel, draw a vertical line
- if (start + 1.0 > end)
- {
+ if (start + 1.0 > end) {
p.drawLine(QPointF(start, top), QPointF(start, bottom));
return;
}
for (const shared_ptr<view::Signal> &s : sig_list) {
assert(s);
- if (dynamic_pointer_cast<LogicSignal>(s) && s->enabled())
- {
+ if (dynamic_pointer_cast<LogicSignal>(s) && s->enabled()) {
selector->addItem(s->name(),
qVariantFromValue((void*)s.get()));
const unordered_set< shared_ptr<Signal> > sigs(session_.signals());
- for (const ChannelSelector &s : channel_selectors_)
- {
+ for (const ChannelSelector &s : channel_selectors_) {
if (s.decoder_ != dec)
break;
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
- for (const shared_ptr<RowItem> r : items)
- {
+ for (const shared_ptr<RowItem> r : items) {
assert(r);
const bool highlight = !item_dragging_ &&
{
assert(e);
- if (e->key() == Qt::Key_Delete)
- {
+ if (e->key() == Qt::Key_Delete) {
const auto items = this->items();
for (auto &i : items)
if (i->selected())
void Ruler::paintEvent(QPaintEvent*)
{
if (!tick_position_cache_) {
- auto ffunc = [this](const pv::util::Timestamp& t)
- {
+ auto ffunc = [this](const pv::util::Timestamp& t) {
return format_time_with_distance(
this->view_.tick_period(),
t,
{
boost::optional<Timestamp> left_time, right_time;
const set< shared_ptr<SignalData> > visible_data = get_visible_data();
- for (const shared_ptr<SignalData> d : visible_data)
- {
+ for (const shared_ptr<SignalData> d : visible_data) {
const vector< shared_ptr<Segment> > segments =
d->segments();
for (const shared_ptr<Segment> &s : segments) {
{
vector< shared_ptr<Trace> > filtered_traces;
- for (const auto &channel : channels)
- {
+ for (const auto &channel : channels) {
const auto map_iter = signal_map.find(channel);
if (map_iter == signal_map.end())
continue;
bool View::viewportEvent(QEvent *e)
{
- switch(e->type()) {
+ switch (e->type()) {
case QEvent::Paint:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::TouchUpdate:
case QEvent::TouchEnd:
return false;
-
default:
return QAbstractScrollArea::viewportEvent(e);
}
signal_map[sig->channel()] = sig;
// Populate channel groups
- for (auto entry : sr_dev->channel_groups())
- {
+ for (auto entry : sr_dev->channel_groups()) {
const shared_ptr<sigrok::ChannelGroup> &group = entry.second;
if (group->channels().size() <= 1)
const QRect &rect, double scale, const pv::util::Timestamp& offset) :
rect_(rect),
scale_(scale),
- offset_(offset) {
+ offset_(offset)
+{
assert(scale > 0.0);
}
return QApplication::font();
}
-int ViewItemPaintParams::text_height() {
+int ViewItemPaintParams::text_height()
+{
return QFontMetrics(font()).height();
}
{
assert(e);
- if (e->orientation() == Qt::Vertical)
- {
+ if (e->orientation() == Qt::Vertical) {
if (e->modifiers() & Qt::ControlModifier) {
// Vertical scrolling with the control key pressed
// is intrepretted as vertical scrolling
// Vertical scrolling is interpreted as zooming in/out
view_.zoom(e->delta() / 120, e->x());
}
- }
- else if (e->orientation() == Qt::Horizontal)
- {
+ } else if (e->orientation() == Qt::Horizontal) {
// Horizontal scrolling is interpreted as moving left/right
view_.set_scale_offset(view_.scale(),
e->delta() * view_.scale() + view_.offset());
const bool any_time_items_selected = any_of(items.begin(), items.end(),
[](const shared_ptr<TimeItem> &i) { return i->selected(); });
- if (any_row_items_selected && !any_time_items_selected)
- {
+ if (any_row_items_selected && !any_time_items_selected) {
// Check all the drag items share a common owner
TraceTreeItemOwner *item_owner = nullptr;
for (shared_ptr<TraceTreeItem> r : trace_tree_items)
}
return true;
- }
- else if (any_time_items_selected && !any_row_items_selected)
- {
+ } else if (any_time_items_selected && !any_row_items_selected) {
return true;
}
if (item_dragging_)
view_.restack_all_trace_tree_items();
- else
- {
+ else {
if (!ctrl_pressed) {
for (shared_ptr<ViewItem> i : items)
if (mouse_down_item_ != i)
if (!e->buttons())
item_hover(get_mouse_over_item(e->pos()));
- else if (e->buttons() & Qt::LeftButton)
- {
- if (!item_dragging_)
- {
+ else if (e->buttons() & Qt::LeftButton) {
+ if (!item_dragging_) {
if ((e->pos() - mouse_down_point_).manhattanLength() <
QApplication::startDragDistance())
return;
for (unsigned int r = 0; r < rows; r++)
for (unsigned int c = 0; c < cols; c++)
- if (popup_.well_array().cellBrush(r, c).color() ==
- colour)
- {
+ if (popup_.well_array().cellBrush(r, c).color() == colour) {
popup_.well_array().setSelected(r, c);
popup_.well_array().setCurrent(r, c);
return;
{
GSList *l = g_slist_sort(g_slist_copy(
(GSList*)srd_decoder_list()), decoder_name_cmp);
- for (; l; l = l->next)
- {
+ for (; l; l = l->next) {
const srd_decoder *const d = (srd_decoder*)l->data;
assert(d);
MarginWidth + ((pos == Bottom) ? ArrowLength : 0),
MarginWidth + ((pos == Left) ? ArrowLength : 0),
MarginWidth + ((pos == Top) ? ArrowLength : 0));
-
}
bool Popup::eventFilter(QObject *obj, QEvent *evt)
const QPoint p = mapFromGlobal(point_);
const int l = ArrowLength + ArrowOverlap;
- switch (pos_)
- {
+ switch (pos_) {
case Right:
poly << QPoint(p.x() + l, p.y() - l);
break;
poly << p;
- switch (pos_)
- {
+ switch (pos_) {
case Right:
case Bottom:
poly << QPoint(p.x() + l, p.y() + l);
value_type_ = List;
list_.clear();
- for (size_t i = 0; i < count; i++)
- {
+ for (size_t i = 0; i < count; i++) {
char *const s = sr_si_string_u64(vals[i], suffix_);
list_.addItem(QString::fromUtf8(s),
qVariantFromValue(vals[i]));
uint64_t SweepTimingWidget::value() const
{
- switch(value_type_)
- {
+ switch(value_type_) {
case None:
return 0;
captures.removeFirst(); // remove entire match
QString str = captures.join("");
setValue(pv::util::Timestamp(str.toStdString()));
- }
- else {
+ } else {
// replace the malformed entered string with the old value
updateEdit();
}