#include <libsigrokcxx/libsigrokcxx.hpp>
-#include "decodetrace.hpp"
+#include "analogsignal.hpp"
#include "header.hpp"
#include "logicsignal.hpp"
#include "ruler.hpp"
#include "pv/data/logicsegment.hpp"
#include "pv/util.hpp"
+#ifdef ENABLE_DECODE
+#include "decodetrace.hpp"
+#endif
+
using boost::shared_lock;
using boost::shared_mutex;
sticky_scrolling_ = state;
}
+void View::enable_coloured_bg(bool state)
+{
+ const vector<shared_ptr<TraceTreeItem>> items(
+ list_by_type<TraceTreeItem>());
+
+ for (shared_ptr<TraceTreeItem> i : items) {
+ // Can't cast to Trace because it's abstract, so we need to
+ // check for any derived classes individually
+
+ shared_ptr<AnalogSignal> a = dynamic_pointer_cast<AnalogSignal>(i);
+ if (a)
+ a->set_coloured_bg(state);
+
+ shared_ptr<LogicSignal> l = dynamic_pointer_cast<LogicSignal>(i);
+ if (l)
+ l->set_coloured_bg(state);
+
+#ifdef ENABLE_DECODE
+ shared_ptr<DecodeTrace> d = dynamic_pointer_cast<DecodeTrace>(i);
+ if (d)
+ d->set_coloured_bg(state);
+#endif
+ }
+
+ viewport_->update();
+}
+
bool View::cursors_shown() const
{
return show_cursors_;
for (auto &o : sorted_owners)
o->restack_items();
+ // Re-assign background colors
+ bool next_bgcolour_state = 0;
+
+ for (auto &o : sorted_owners)
+ next_bgcolour_state = o->reassign_bgcolour_states(next_bgcolour_state);
+
// Animate the items to their destination
for (const auto &i : items)
i->animate_to_layout_v_offset();
return QObject::eventFilter(object, event);
}
-bool View::viewportEvent(QEvent *e)
+bool View::viewportEvent(QEvent *event)
{
- switch (e->type()) {
+ switch (event->type()) {
case QEvent::Paint:
case QEvent::MouseButtonPress:
case QEvent::MouseButtonRelease:
case QEvent::TouchEnd:
return false;
default:
- return QAbstractScrollArea::viewportEvent(e);
+ return QAbstractScrollArea::viewportEvent(event);
}
}
vector< shared_ptr<TraceTreeItem> > new_top_level_items;
- const auto device = session_.device();
- if (!device)
+ if (!session_.device())
return;
- shared_ptr<sigrok::Device> sr_dev = device->device();
+ shared_ptr<sigrok::Device> sr_dev = session_.device()->device();
assert(sr_dev);
-
const vector< shared_ptr<Channel> > channels(
sr_dev->channels());
offset += extents.second;
}
+ // Assign proper vertical offsets to each channel in the group
+ new_trace_group->restack_items();
+
// If this is a new group, enqueue it in the new top level
// items list
if (!new_traces_in_group.empty() && new_trace_group)
copy_if(channels.begin(), channels.end(), back_inserter(logic_channels),
[](const shared_ptr<Channel>& c) {
return c->type() == sigrok::ChannelType::LOGIC; });
+
const vector< shared_ptr<Trace> > non_grouped_logic_signals =
- extract_new_traces_for_channels(logic_channels,
- signal_map, add_traces);
- const shared_ptr<TraceGroup> non_grouped_trace_group(
- make_shared<TraceGroup>());
- for (shared_ptr<Trace> trace : non_grouped_logic_signals)
- non_grouped_trace_group->add_child_item(trace);
- new_top_level_items.push_back(non_grouped_trace_group);
+ extract_new_traces_for_channels(logic_channels, signal_map, add_traces);
+
+ if (non_grouped_logic_signals.size() > 0) {
+ const shared_ptr<TraceGroup> non_grouped_trace_group(
+ make_shared<TraceGroup>());
+ for (shared_ptr<Trace> trace : non_grouped_logic_signals)
+ non_grouped_trace_group->add_child_item(trace);
+
+ non_grouped_trace_group->restack_items();
+ new_top_level_items.push_back(non_grouped_trace_group);
+ }
// Enqueue the remaining channels as free ungrouped traces
const vector< shared_ptr<Trace> > new_top_level_signals =
- extract_new_traces_for_channels(channels,
- signal_map, add_traces);
+ extract_new_traces_for_channels(channels, signal_map, add_traces);
new_top_level_items.insert(new_top_level_items.end(),
new_top_level_signals.begin(), new_top_level_signals.end());
// Add and position the pending top levels items
for (auto item : new_top_level_items) {
+ // Position the item after the last item or at the top if there is none
+ int offset = v_extents().second;
+
add_child_item(item);
+ item->force_to_v_offset(offset);
- // Position the item after the last present item
- int offset = v_extents().second;
const pair<int, int> extents = item->v_extents();
if (item->enabled())
- offset += -extents.first;
- item->force_to_v_offset(offset);
- if (item->enabled())
- offset += extents.second;
+ offset += (extents.second - extents.first);
}
update_layout();