]>
Commit | Line | Data |
---|---|---|
adb4b10c | 1 | /* |
b3f22de0 | 2 | * This file is part of the PulseView project. |
adb4b10c JH |
3 | * |
4 | * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation; either version 2 of the License, or | |
9 | * (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
efdec55a | 17 | * along with this program; if not, see <http://www.gnu.org/licenses/>. |
adb4b10c JH |
18 | */ |
19 | ||
269528f5 | 20 | #ifdef ENABLE_DECODE |
4e5a4405 | 21 | #include <libsigrokdecode/libsigrokdecode.h> |
269528f5 | 22 | #endif |
4e5a4405 | 23 | |
361c560e JH |
24 | #include <extdef.h> |
25 | ||
cf124e47 | 26 | #include <algorithm> |
c3a740dd JH |
27 | #include <cassert> |
28 | #include <climits> | |
29 | #include <cmath> | |
3a21afa6 | 30 | #include <iostream> |
cf124e47 | 31 | #include <iterator> |
7ff0145f | 32 | #include <unordered_set> |
adb4b10c | 33 | |
361c560e | 34 | #include <QApplication> |
e887fe9e | 35 | #include <QDebug> |
adb4b10c | 36 | #include <QEvent> |
361c560e | 37 | #include <QFontMetrics> |
d9b55cc8 | 38 | #include <QMenu> |
cbd80f64 | 39 | #include <QMouseEvent> |
adb4b10c | 40 | #include <QScrollBar> |
33094993 | 41 | #include <QVBoxLayout> |
adb4b10c | 42 | |
fe3a1c21 | 43 | #include <libsigrokcxx/libsigrokcxx.hpp> |
448a72cf | 44 | |
574c568d | 45 | #include "analogsignal.hpp" |
2acdb232 JH |
46 | #include "header.hpp" |
47 | #include "logicsignal.hpp" | |
48 | #include "ruler.hpp" | |
49 | #include "signal.hpp" | |
50 | #include "tracegroup.hpp" | |
1a2288a1 | 51 | #include "triggermarker.hpp" |
2acdb232 JH |
52 | #include "view.hpp" |
53 | #include "viewport.hpp" | |
adb4b10c | 54 | |
2acdb232 | 55 | #include "pv/data/logic.hpp" |
f3d66e52 | 56 | #include "pv/data/logicsegment.hpp" |
aca9aa83 UH |
57 | #include "pv/devices/device.hpp" |
58 | #include "pv/globalsettings.hpp" | |
59 | #include "pv/session.hpp" | |
361c560e | 60 | #include "pv/util.hpp" |
adb4b10c | 61 | |
dcfe0a01 SA |
62 | #ifdef ENABLE_DECODE |
63 | #include "decodetrace.hpp" | |
64 | #endif | |
65 | ||
1bc6525b | 66 | using pv::data::SignalData; |
f3d66e52 | 67 | using pv::data::Segment; |
ef454ad5 | 68 | using pv::util::TimeUnit; |
60d9b99a | 69 | using pv::util::Timestamp; |
361c560e | 70 | |
769a79b5 JH |
71 | using std::back_inserter; |
72 | using std::copy_if; | |
6f925ba9 | 73 | using std::count_if; |
cf124e47 | 74 | using std::inserter; |
819f4c25 | 75 | using std::max; |
1bc6525b | 76 | using std::make_pair; |
769a79b5 | 77 | using std::make_shared; |
819f4c25 | 78 | using std::min; |
f6b6c9bf | 79 | using std::numeric_limits; |
1bc6525b | 80 | using std::pair; |
819f4c25 | 81 | using std::set; |
cf124e47 | 82 | using std::set_difference; |
f9abf97e | 83 | using std::shared_ptr; |
448a72cf | 84 | using std::unordered_map; |
7ff0145f | 85 | using std::unordered_set; |
819f4c25 | 86 | using std::vector; |
adb4b10c | 87 | |
cdf7bea7 | 88 | namespace pv { |
f4e57597 | 89 | namespace views { |
1573bf16 | 90 | namespace trace { |
adb4b10c | 91 | |
60d9b99a JS |
92 | const Timestamp View::MaxScale("1e9"); |
93 | const Timestamp View::MinScale("1e-12"); | |
adb4b10c | 94 | |
f25770e2 JH |
95 | const int View::MaxScrollValue = INT_MAX / 2; |
96 | ||
6381b375 SA |
97 | /* Area at the top and bottom of the view that can't be scrolled out of sight */ |
98 | const int View::ViewScrollMargin = 50; | |
361c560e | 99 | |
6381b375 | 100 | const int View::ScaleUnits[3] = {1, 2, 5}; |
f4e57597 | 101 | |
33094993 | 102 | CustomScrollArea::CustomScrollArea(QWidget *parent) : |
f4e57597 SA |
103 | QAbstractScrollArea(parent) |
104 | { | |
105 | } | |
106 | ||
33094993 | 107 | bool CustomScrollArea::viewportEvent(QEvent *event) |
f4e57597 SA |
108 | { |
109 | switch (event->type()) { | |
110 | case QEvent::Paint: | |
111 | case QEvent::MouseButtonPress: | |
112 | case QEvent::MouseButtonRelease: | |
113 | case QEvent::MouseButtonDblClick: | |
114 | case QEvent::MouseMove: | |
115 | case QEvent::Wheel: | |
116 | case QEvent::TouchBegin: | |
117 | case QEvent::TouchUpdate: | |
118 | case QEvent::TouchEnd: | |
119 | return false; | |
120 | default: | |
121 | return QAbstractScrollArea::viewportEvent(event); | |
122 | } | |
123 | } | |
124 | ||
a24412db | 125 | View::View(Session &session, bool is_main_view, QMainWindow *parent) : |
143d322d | 126 | ViewBase(session, is_main_view, parent), |
5a206446 SA |
127 | |
128 | // Note: Place defaults in View::reset_view_state(), not here | |
33094993 | 129 | splitter_(new QSplitter()), |
9f094349 | 130 | header_was_shrunk_(false), // The splitter remains unchanged after a reset, so this goes here |
4ab6d244 UH |
131 | sticky_scrolling_(false), // Default setting is set in MainWindow::setup_ui() |
132 | scroll_needs_defaults_(true) | |
adb4b10c | 133 | { |
33094993 SA |
134 | QVBoxLayout *root_layout = new QVBoxLayout(this); |
135 | root_layout->setContentsMargins(0, 0, 0, 0); | |
136 | root_layout->addWidget(splitter_); | |
137 | ||
138 | viewport_ = new Viewport(*this); | |
139 | scrollarea_ = new CustomScrollArea(splitter_); | |
140 | scrollarea_->setViewport(viewport_); | |
141 | scrollarea_->setFrameShape(QFrame::NoFrame); | |
142 | ||
143 | ruler_ = new Ruler(*this); | |
144 | ||
145 | header_ = new Header(*this); | |
c1a6513b | 146 | header_->setMinimumWidth(10); // So that the arrow tips show at least |
33094993 SA |
147 | |
148 | // We put the header into a simple layout so that we can add the top margin, | |
149 | // allowing us to make it line up with the bottom of the ruler | |
150 | QWidget *header_container = new QWidget(); | |
151 | header_container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
152 | QVBoxLayout *header_layout = new QVBoxLayout(header_container); | |
153 | header_layout->setContentsMargins(0, ruler_->sizeHint().height(), 0, 0); | |
154 | header_layout->addWidget(header_); | |
155 | ||
156 | // To let the ruler and scrollarea be on the same split pane, we need a layout | |
157 | QWidget *trace_container = new QWidget(); | |
158 | trace_container->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); | |
159 | QVBoxLayout *trace_layout = new QVBoxLayout(trace_container); | |
160 | trace_layout->setSpacing(0); // We don't want space between the ruler and scrollarea | |
161 | trace_layout->setContentsMargins(0, 0, 0, 0); | |
162 | trace_layout->addWidget(ruler_); | |
163 | trace_layout->addWidget(scrollarea_); | |
164 | ||
165 | splitter_->addWidget(header_container); | |
166 | splitter_->addWidget(trace_container); | |
167 | splitter_->setHandleWidth(1); // Don't show a visible rubber band | |
168 | splitter_->setCollapsible(0, false); // Prevent the header from collapsing | |
169 | splitter_->setCollapsible(1, false); // Prevent the traces from collapsing | |
9f094349 SA |
170 | splitter_->setStretchFactor(0, 0); // Prevent the panes from being resized |
171 | splitter_->setStretchFactor(1, 1); // when the entire view is resized | |
33094993 SA |
172 | splitter_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
173 | ||
174 | viewport_->installEventFilter(this); | |
175 | ruler_->installEventFilter(this); | |
176 | header_->installEventFilter(this); | |
177 | ||
178 | // Set up settings and event handlers | |
24c29d4f | 179 | GlobalSettings settings; |
641574bc | 180 | colored_bg_ = settings.value(GlobalSettings::Key_View_ColoredBG).toBool(); |
fb641801 | 181 | snap_distance_ = settings.value(GlobalSettings::Key_View_SnapDistance).toInt(); |
24c29d4f | 182 | |
d0c0573b | 183 | GlobalSettings::add_change_handler(this); |
451dc5f3 | 184 | |
33094993 | 185 | connect(scrollarea_->horizontalScrollBar(), SIGNAL(valueChanged(int)), |
b16907d3 | 186 | this, SLOT(h_scroll_value_changed(int))); |
33094993 | 187 | connect(scrollarea_->verticalScrollBar(), SIGNAL(valueChanged(int)), |
f8400017 | 188 | this, SLOT(v_scroll_value_changed())); |
69dd2b03 | 189 | |
8dbbc7f0 | 190 | connect(header_, SIGNAL(selection_changed()), |
819e2e95 JH |
191 | ruler_, SLOT(clear_selection())); |
192 | connect(ruler_, SIGNAL(selection_changed()), | |
8dbbc7f0 | 193 | header_, SLOT(clear_selection())); |
17348f85 | 194 | |
8dbbc7f0 | 195 | connect(header_, SIGNAL(selection_changed()), |
8b454527 | 196 | this, SIGNAL(selection_changed())); |
819e2e95 | 197 | connect(ruler_, SIGNAL(selection_changed()), |
8b454527 JH |
198 | this, SIGNAL(selection_changed())); |
199 | ||
e0be5f21 SA |
200 | connect(splitter_, SIGNAL(splitterMoved(int, int)), |
201 | this, SLOT(on_splitter_moved())); | |
202 | ||
8dbbc7f0 | 203 | connect(&lazy_event_handler_, SIGNAL(timeout()), |
32218d3e | 204 | this, SLOT(process_sticky_events())); |
8dbbc7f0 | 205 | lazy_event_handler_.setSingleShot(true); |
38b77a3b | 206 | lazy_event_handler_.setInterval(1000 / ViewBase::MaxViewAutoUpdateRate); |
32218d3e | 207 | |
476ca5f4 SA |
208 | // Set up local keyboard shortcuts |
209 | zoom_in_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Plus), this, | |
3d6ff1cd | 210 | SLOT(on_zoom_in_shortcut_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); |
476ca5f4 SA |
211 | zoom_in_shortcut_->setAutoRepeat(false); |
212 | ||
213 | zoom_out_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Minus), this, | |
214 | SLOT(on_zoom_out_shortcut_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); | |
215 | zoom_out_shortcut_->setAutoRepeat(false); | |
216 | ||
217 | zoom_in_shortcut_2_ = new QShortcut(QKeySequence(Qt::Key_Up), this, | |
218 | SLOT(on_zoom_in_shortcut_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); | |
219 | zoom_out_shortcut_2_ = new QShortcut(QKeySequence(Qt::Key_Down), this, | |
220 | SLOT(on_zoom_out_shortcut_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); | |
221 | ||
222 | home_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Home), this, | |
223 | SLOT(on_scroll_to_start_shortcut_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); | |
224 | home_shortcut_->setAutoRepeat(false); | |
225 | ||
226 | end_shortcut_ = new QShortcut(QKeySequence(Qt::Key_End), this, | |
227 | SLOT(on_scroll_to_end_shortcut_triggered()), nullptr, Qt::WidgetWithChildrenShortcut); | |
228 | end_shortcut_->setAutoRepeat(false); | |
229 | ||
3d6ff1cd SA |
230 | grab_ruler_left_shortcut_ = new QShortcut(QKeySequence(Qt::Key_1), this, |
231 | nullptr, nullptr, Qt::WidgetWithChildrenShortcut); | |
95a4b2a1 MM |
232 | connect(grab_ruler_left_shortcut_, &QShortcut::activated, |
233 | this, [=]{on_grab_ruler(1);}); | |
234 | grab_ruler_left_shortcut_->setAutoRepeat(false); | |
235 | ||
3d6ff1cd SA |
236 | grab_ruler_right_shortcut_ = new QShortcut(QKeySequence(Qt::Key_2), this, |
237 | nullptr, nullptr, Qt::WidgetWithChildrenShortcut); | |
95a4b2a1 MM |
238 | connect(grab_ruler_right_shortcut_, &QShortcut::activated, |
239 | this, [=]{on_grab_ruler(2);}); | |
240 | grab_ruler_right_shortcut_->setAutoRepeat(false); | |
241 | ||
3d6ff1cd SA |
242 | cancel_grab_shortcut_ = new QShortcut(QKeySequence(Qt::Key_Escape), this, |
243 | nullptr, nullptr, Qt::WidgetWithChildrenShortcut); | |
95a4b2a1 MM |
244 | connect(cancel_grab_shortcut_, &QShortcut::activated, |
245 | this, [=]{grabbed_widget_ = nullptr;}); | |
246 | cancel_grab_shortcut_->setAutoRepeat(false); | |
247 | ||
9f46d905 JH |
248 | // Trigger the initial event manually. The default device has signals |
249 | // which were created before this object came into being | |
d873f4d6 | 250 | signals_changed(); |
84a0d458 | 251 | |
476ca5f4 | 252 | // Make sure the transparent widgets are on the top |
819e2e95 | 253 | ruler_->raise(); |
8dbbc7f0 | 254 | header_->raise(); |
361c560e | 255 | |
5a206446 | 256 | reset_view_state(); |
adb4b10c JH |
257 | } |
258 | ||
d0c0573b SA |
259 | View::~View() |
260 | { | |
261 | GlobalSettings::remove_change_handler(this); | |
262 | } | |
263 | ||
db298158 SA |
264 | ViewType View::get_type() const |
265 | { | |
266 | return ViewTypeTrace; | |
267 | } | |
268 | ||
5a206446 SA |
269 | void View::reset_view_state() |
270 | { | |
271 | ViewBase::reset_view_state(); | |
272 | ||
273 | segment_display_mode_ = Trace::ShowLastSegmentOnly; | |
274 | segment_selectable_ = false; | |
275 | scale_ = 1e-3; | |
276 | offset_ = 0; | |
277 | ruler_offset_ = 0; | |
e887fe9e SA |
278 | zero_offset_ = 0; |
279 | custom_zero_offset_set_ = false; | |
5a206446 SA |
280 | updating_scroll_ = false; |
281 | settings_restored_ = false; | |
282 | always_zoom_to_fit_ = false; | |
283 | tick_period_ = 0; | |
284 | tick_prefix_ = pv::util::SIPrefix::yocto; | |
285 | tick_precision_ = 0; | |
286 | time_unit_ = util::TimeUnit::Time; | |
287 | show_cursors_ = false; | |
288 | cursors_ = make_shared<CursorPair>(*this); | |
289 | next_flag_text_ = 'A'; | |
290 | trigger_markers_.clear(); | |
581724de | 291 | hover_widget_ = nullptr; |
95a4b2a1 | 292 | grabbed_widget_ = nullptr; |
5a206446 SA |
293 | hover_point_ = QPoint(-1, -1); |
294 | scroll_needs_defaults_ = true; | |
295 | saved_v_offset_ = 0; | |
296 | scale_at_acq_start_ = 0; | |
297 | offset_at_acq_start_ = 0; | |
298 | suppress_zoom_to_fit_after_acq_ = false; | |
299 | ||
300 | show_cursors_ = false; | |
e4e5a958 | 301 | cursor_state_changed(show_cursors_); |
5a206446 SA |
302 | flags_.clear(); |
303 | ||
304 | // Update the zoom state | |
305 | calculate_tick_spacing(); | |
306 | ||
307 | // Make sure the standard bar's segment selector is in sync | |
308 | set_segment_display_mode(segment_display_mode_); | |
309 | } | |
310 | ||
2b81ae46 | 311 | Session& View::session() |
1d19ef83 | 312 | { |
8dbbc7f0 | 313 | return session_; |
1d19ef83 JH |
314 | } |
315 | ||
2b81ae46 | 316 | const Session& View::session() const |
38eeddea | 317 | { |
8dbbc7f0 | 318 | return session_; |
38eeddea JH |
319 | } |
320 | ||
533b67b7 | 321 | vector< shared_ptr<Signal> > View::signals() const |
47e9e7bb SA |
322 | { |
323 | return signals_; | |
324 | } | |
325 | ||
0a952555 SA |
326 | shared_ptr<Signal> View::get_signal_by_signalbase(shared_ptr<data::SignalBase> base) const |
327 | { | |
328 | shared_ptr<Signal> ret_val; | |
329 | ||
feda6c6b | 330 | for (const shared_ptr<Signal>& s : signals_) |
0a952555 SA |
331 | if (s->base() == base) { |
332 | ret_val = s; | |
333 | break; | |
334 | } | |
335 | ||
336 | return ret_val; | |
337 | } | |
338 | ||
47e9e7bb SA |
339 | void View::clear_signals() |
340 | { | |
03408f5f | 341 | ViewBase::clear_signals(); |
47e9e7bb SA |
342 | signals_.clear(); |
343 | } | |
344 | ||
f4e57597 | 345 | void View::add_signal(const shared_ptr<Signal> signal) |
47e9e7bb | 346 | { |
5ed05b69 | 347 | ViewBase::add_signalbase(signal->base()); |
533b67b7 | 348 | signals_.push_back(signal); |
00c518d6 | 349 | |
7daebd05 | 350 | signal->set_segment_display_mode(segment_display_mode_); |
8a603e13 | 351 | signal->set_current_segment(current_segment_); |
7daebd05 | 352 | |
00c518d6 SA |
353 | connect(signal->base().get(), SIGNAL(name_changed(const QString&)), |
354 | this, SLOT(on_signal_name_changed())); | |
47e9e7bb SA |
355 | } |
356 | ||
bb7dd726 | 357 | #ifdef ENABLE_DECODE |
f4e57597 | 358 | void View::clear_decode_signals() |
bb7dd726 | 359 | { |
e77de61f | 360 | ViewBase::clear_decode_signals(); |
bb7dd726 SA |
361 | decode_traces_.clear(); |
362 | } | |
363 | ||
ad908057 | 364 | void View::add_decode_signal(shared_ptr<data::DecodeSignal> signal) |
bb7dd726 | 365 | { |
e77de61f SA |
366 | ViewBase::add_decode_signal(signal); |
367 | ||
f4e57597 | 368 | shared_ptr<DecodeTrace> d( |
ad908057 | 369 | new DecodeTrace(session_, signal, decode_traces_.size())); |
bb7dd726 | 370 | decode_traces_.push_back(d); |
00c518d6 | 371 | |
7daebd05 | 372 | d->set_segment_display_mode(segment_display_mode_); |
8a603e13 | 373 | d->set_current_segment(current_segment_); |
7daebd05 | 374 | |
00c518d6 SA |
375 | connect(signal.get(), SIGNAL(name_changed(const QString&)), |
376 | this, SLOT(on_signal_name_changed())); | |
bb7dd726 SA |
377 | } |
378 | ||
ad908057 | 379 | void View::remove_decode_signal(shared_ptr<data::DecodeSignal> signal) |
bb7dd726 SA |
380 | { |
381 | for (auto i = decode_traces_.begin(); i != decode_traces_.end(); i++) | |
ad908057 | 382 | if ((*i)->base() == signal) { |
bb7dd726 SA |
383 | decode_traces_.erase(i); |
384 | signals_changed(); | |
385 | return; | |
386 | } | |
e77de61f SA |
387 | |
388 | ViewBase::remove_decode_signal(signal); | |
bb7dd726 SA |
389 | } |
390 | #endif | |
391 | ||
eeceee99 SA |
392 | shared_ptr<Signal> View::get_signal_under_mouse_cursor() const |
393 | { | |
394 | return signal_under_mouse_cursor_; | |
395 | } | |
396 | ||
eae6e30a JH |
397 | View* View::view() |
398 | { | |
399 | return this; | |
400 | } | |
401 | ||
402 | const View* View::view() const | |
403 | { | |
404 | return this; | |
405 | } | |
406 | ||
2ae445ba SA |
407 | Viewport* View::viewport() |
408 | { | |
8dbbc7f0 | 409 | return viewport_; |
2ae445ba SA |
410 | } |
411 | ||
412 | const Viewport* View::viewport() const | |
413 | { | |
8dbbc7f0 | 414 | return viewport_; |
2ae445ba SA |
415 | } |
416 | ||
c6b4e925 SA |
417 | QAbstractScrollArea* View::scrollarea() const |
418 | { | |
419 | return scrollarea_; | |
420 | } | |
421 | ||
79b53a1a SA |
422 | const Ruler* View::ruler() const |
423 | { | |
424 | return ruler_; | |
425 | } | |
426 | ||
3a21afa6 SA |
427 | void View::save_settings(QSettings &settings) const |
428 | { | |
429 | settings.setValue("scale", scale_); | |
39ab01e7 | 430 | settings.setValue("v_offset", |
33094993 | 431 | scrollarea_->verticalScrollBar()->sliderPosition()); |
3a21afa6 | 432 | |
37849039 | 433 | settings.setValue("splitter_state", splitter_->saveState()); |
89914a86 | 434 | settings.setValue("segment_display_mode", segment_display_mode_); |
37849039 | 435 | |
e887fe9e SA |
436 | GlobalSettings::store_timestamp(settings, "offset", offset_); |
437 | ||
438 | if (custom_zero_offset_set_) | |
439 | GlobalSettings::store_timestamp(settings, "zero_offset", -zero_offset_); | |
440 | else | |
441 | settings.remove("zero_offset"); | |
3a21afa6 | 442 | |
f4ab4b5c | 443 | for (const shared_ptr<Signal>& signal : signals_) { |
3a21afa6 SA |
444 | settings.beginGroup(signal->base()->internal_name()); |
445 | signal->save_settings(settings); | |
446 | settings.endGroup(); | |
447 | } | |
448 | } | |
449 | ||
450 | void View::restore_settings(QSettings &settings) | |
451 | { | |
39ab01e7 SA |
452 | // Note: It is assumed that this function is only called once, |
453 | // immediately after restoring a previous session. | |
454 | ||
3a21afa6 SA |
455 | if (settings.contains("scale")) |
456 | set_scale(settings.value("scale").toDouble()); | |
457 | ||
458 | if (settings.contains("offset")) { | |
e887fe9e SA |
459 | // This also updates ruler_offset_ |
460 | set_offset(GlobalSettings::restore_timestamp(settings, "offset")); | |
3a21afa6 SA |
461 | } |
462 | ||
e887fe9e SA |
463 | if (settings.contains("zero_offset")) |
464 | set_zero_position(GlobalSettings::restore_timestamp(settings, "zero_offset")); | |
465 | ||
37849039 SA |
466 | if (settings.contains("splitter_state")) |
467 | splitter_->restoreState(settings.value("splitter_state").toByteArray()); | |
468 | ||
89914a86 SA |
469 | if (settings.contains("segment_display_mode")) |
470 | set_segment_display_mode( | |
471 | (Trace::SegmentDisplayMode)(settings.value("segment_display_mode").toInt())); | |
472 | ||
f4e57597 | 473 | for (shared_ptr<Signal> signal : signals_) { |
3a21afa6 SA |
474 | settings.beginGroup(signal->base()->internal_name()); |
475 | signal->restore_settings(settings); | |
476 | settings.endGroup(); | |
477 | } | |
39ab01e7 SA |
478 | |
479 | if (settings.contains("v_offset")) { | |
480 | saved_v_offset_ = settings.value("v_offset").toInt(); | |
481 | set_v_offset(saved_v_offset_); | |
e62bee73 | 482 | scroll_needs_defaults_ = false; |
5f9b7de5 | 483 | // Note: see eventFilter() for additional information |
39ab01e7 | 484 | } |
4cc2e925 SA |
485 | |
486 | settings_restored_ = true; | |
28ceff25 | 487 | suppress_zoom_to_fit_after_acq_ = true; |
bca3faab SA |
488 | |
489 | // Update the ruler so that it uses the new scale | |
490 | calculate_tick_spacing(); | |
3a21afa6 SA |
491 | } |
492 | ||
2496bf45 JH |
493 | vector< shared_ptr<TimeItem> > View::time_items() const |
494 | { | |
8914fe79 JH |
495 | const vector<shared_ptr<Flag>> f(flags()); |
496 | vector<shared_ptr<TimeItem>> items(f.begin(), f.end()); | |
5a206446 SA |
497 | |
498 | if (cursors_) { | |
499 | items.push_back(cursors_); | |
500 | items.push_back(cursors_->first()); | |
501 | items.push_back(cursors_->second()); | |
502 | } | |
1a2288a1 | 503 | |
f4ab4b5c | 504 | for (auto& trigger_marker : trigger_markers_) |
92ff2b60 | 505 | items.push_back(trigger_marker); |
1a2288a1 | 506 | |
2496bf45 JH |
507 | return items; |
508 | } | |
509 | ||
cdf7bea7 | 510 | double View::scale() const |
adb4b10c | 511 | { |
8dbbc7f0 | 512 | return scale_; |
adb4b10c JH |
513 | } |
514 | ||
4b0af0b6 JS |
515 | void View::set_scale(double scale) |
516 | { | |
517 | if (scale_ != scale) { | |
518 | scale_ = scale; | |
25e734c8 | 519 | scale_changed(); |
4b0af0b6 JS |
520 | } |
521 | } | |
522 | ||
451dc5f3 | 523 | void View::set_offset(const pv::util::Timestamp& offset, bool force_update) |
4b0af0b6 | 524 | { |
451dc5f3 | 525 | if ((offset_ != offset) || force_update) { |
4b0af0b6 | 526 | offset_ = offset; |
fe68068b | 527 | ruler_offset_ = offset_ + zero_offset_; |
25e734c8 | 528 | offset_changed(); |
4b0af0b6 JS |
529 | } |
530 | } | |
531 | ||
ffc00fdd C |
532 | const Timestamp& View::offset() const |
533 | { | |
534 | return offset_; | |
535 | } | |
536 | ||
ffc00fdd C |
537 | const Timestamp& View::ruler_offset() const |
538 | { | |
539 | return ruler_offset_; | |
540 | } | |
541 | ||
e23567ed | 542 | void View::set_zero_position(const pv::util::Timestamp& position) |
451dc5f3 | 543 | { |
fe68068b | 544 | zero_offset_ = -position; |
e887fe9e | 545 | custom_zero_offset_set_ = true; |
451dc5f3 SA |
546 | |
547 | // Force an immediate update of the offsets | |
548 | set_offset(offset_, true); | |
549 | ruler_->update(); | |
550 | } | |
551 | ||
552 | void View::reset_zero_position() | |
553 | { | |
fe68068b | 554 | zero_offset_ = 0; |
451dc5f3 | 555 | |
e887fe9e SA |
556 | // When enabled, the first trigger for this segment is used as the zero position |
557 | GlobalSettings settings; | |
558 | bool trigger_is_zero_time = settings.value(GlobalSettings::Key_View_TriggerIsZeroTime).toBool(); | |
559 | ||
560 | if (trigger_is_zero_time) { | |
561 | vector<util::Timestamp> triggers = session_.get_triggers(current_segment_); | |
562 | ||
563 | if (triggers.size() > 0) | |
564 | zero_offset_ = triggers.front(); | |
565 | } | |
566 | ||
567 | custom_zero_offset_set_ = false; | |
568 | ||
451dc5f3 SA |
569 | // Force an immediate update of the offsets |
570 | set_offset(offset_, true); | |
571 | ruler_->update(); | |
572 | } | |
573 | ||
4468ee42 SA |
574 | pv::util::Timestamp View::zero_offset() const |
575 | { | |
576 | return zero_offset_; | |
577 | } | |
578 | ||
7ff0145f | 579 | int View::owner_visual_v_offset() const |
adb4b10c | 580 | { |
33094993 | 581 | return -scrollarea_->verticalScrollBar()->sliderPosition(); |
adb4b10c JH |
582 | } |
583 | ||
4d476647 JH |
584 | void View::set_v_offset(int offset) |
585 | { | |
33094993 | 586 | scrollarea_->verticalScrollBar()->setSliderPosition(offset); |
4d476647 JH |
587 | header_->update(); |
588 | viewport_->update(); | |
589 | } | |
590 | ||
ccf6a266 MM |
591 | void View::set_h_offset(int offset) |
592 | { | |
593 | scrollarea_->horizontalScrollBar()->setSliderPosition(offset); | |
594 | header_->update(); | |
595 | viewport_->update(); | |
596 | } | |
597 | ||
598 | int View::get_h_scrollbar_maximum() const | |
599 | { | |
600 | return scrollarea_->horizontalScrollBar()->maximum(); | |
601 | } | |
602 | ||
3e769a37 JH |
603 | unsigned int View::depth() const |
604 | { | |
605 | return 0; | |
606 | } | |
607 | ||
89914a86 SA |
608 | uint32_t View::current_segment() const |
609 | { | |
610 | return current_segment_; | |
611 | } | |
612 | ||
d001f416 | 613 | pv::util::SIPrefix View::tick_prefix() const |
361c560e JH |
614 | { |
615 | return tick_prefix_; | |
616 | } | |
617 | ||
4b0af0b6 JS |
618 | void View::set_tick_prefix(pv::util::SIPrefix tick_prefix) |
619 | { | |
620 | if (tick_prefix_ != tick_prefix) { | |
621 | tick_prefix_ = tick_prefix; | |
25e734c8 | 622 | tick_prefix_changed(); |
4b0af0b6 JS |
623 | } |
624 | } | |
625 | ||
d40f4db7 SA |
626 | unsigned int View::tick_precision() const |
627 | { | |
628 | return tick_precision_; | |
629 | } | |
630 | ||
4b0af0b6 JS |
631 | void View::set_tick_precision(unsigned tick_precision) |
632 | { | |
633 | if (tick_precision_ != tick_precision) { | |
634 | tick_precision_ = tick_precision; | |
25e734c8 | 635 | tick_precision_changed(); |
4b0af0b6 JS |
636 | } |
637 | } | |
638 | ||
c677193d | 639 | const pv::util::Timestamp& View::tick_period() const |
361c560e JH |
640 | { |
641 | return tick_period_; | |
642 | } | |
643 | ||
4a076157 C |
644 | unsigned int View::minor_tick_count() const |
645 | { | |
646 | return minor_tick_count_; | |
647 | } | |
648 | ||
c677193d | 649 | void View::set_tick_period(const pv::util::Timestamp& tick_period) |
4b0af0b6 JS |
650 | { |
651 | if (tick_period_ != tick_period) { | |
652 | tick_period_ = tick_period; | |
25e734c8 | 653 | tick_period_changed(); |
4b0af0b6 JS |
654 | } |
655 | } | |
656 | ||
ef454ad5 SA |
657 | TimeUnit View::time_unit() const |
658 | { | |
659 | return time_unit_; | |
660 | } | |
661 | ||
4b0af0b6 JS |
662 | void View::set_time_unit(pv::util::TimeUnit time_unit) |
663 | { | |
664 | if (time_unit_ != time_unit) { | |
665 | time_unit_ = time_unit; | |
25e734c8 | 666 | time_unit_changed(); |
4b0af0b6 JS |
667 | } |
668 | } | |
669 | ||
558ad6ce SA |
670 | void View::set_current_segment(uint32_t segment_id) |
671 | { | |
672 | current_segment_ = segment_id; | |
673 | ||
f4ab4b5c | 674 | for (const shared_ptr<Signal>& signal : signals_) |
558ad6ce | 675 | signal->set_current_segment(current_segment_); |
57c04e78 | 676 | #ifdef ENABLE_DECODE |
f4ab4b5c | 677 | for (shared_ptr<DecodeTrace>& dt : decode_traces_) |
558ad6ce | 678 | dt->set_current_segment(current_segment_); |
57c04e78 | 679 | #endif |
558ad6ce | 680 | |
451dc5f3 SA |
681 | vector<util::Timestamp> triggers = session_.get_triggers(current_segment_); |
682 | ||
7ea2a4ff | 683 | trigger_markers_.clear(); |
451dc5f3 | 684 | for (util::Timestamp timestamp : triggers) |
7ea2a4ff SA |
685 | trigger_markers_.push_back(make_shared<TriggerMarker>(*this, timestamp)); |
686 | ||
e887fe9e SA |
687 | if (!custom_zero_offset_set_) |
688 | reset_zero_position(); | |
451dc5f3 | 689 | |
558ad6ce | 690 | viewport_->update(); |
89914a86 SA |
691 | |
692 | segment_changed(segment_id); | |
558ad6ce SA |
693 | } |
694 | ||
7daebd05 SA |
695 | bool View::segment_is_selectable() const |
696 | { | |
697 | return segment_selectable_; | |
698 | } | |
699 | ||
89914a86 SA |
700 | Trace::SegmentDisplayMode View::segment_display_mode() const |
701 | { | |
702 | return segment_display_mode_; | |
703 | } | |
704 | ||
7daebd05 SA |
705 | void View::set_segment_display_mode(Trace::SegmentDisplayMode mode) |
706 | { | |
89914a86 SA |
707 | segment_display_mode_ = mode; |
708 | ||
f4ab4b5c | 709 | for (const shared_ptr<Signal>& signal : signals_) |
7daebd05 SA |
710 | signal->set_segment_display_mode(mode); |
711 | ||
89914a86 SA |
712 | uint32_t last_segment = session_.get_segment_count() - 1; |
713 | ||
714 | switch (mode) { | |
715 | case Trace::ShowLastSegmentOnly: | |
716 | if (current_segment_ != last_segment) | |
717 | set_current_segment(last_segment); | |
718 | break; | |
719 | ||
720 | case Trace::ShowLastCompleteSegmentOnly: | |
721 | // Do nothing if we only have one segment so far | |
722 | if (last_segment > 0) { | |
723 | // If the last segment isn't complete, the previous one must be | |
724 | uint32_t segment_id = | |
725 | (session_.all_segments_complete(last_segment)) ? | |
726 | last_segment : last_segment - 1; | |
727 | ||
728 | if (current_segment_ != segment_id) | |
729 | set_current_segment(segment_id); | |
730 | } | |
731 | break; | |
732 | ||
733 | case Trace::ShowSingleSegmentOnly: | |
734 | case Trace::ShowAllSegments: | |
735 | case Trace::ShowAccumulatedIntensity: | |
736 | default: | |
737 | // Current segment remains as-is | |
738 | break; | |
739 | } | |
7daebd05 SA |
740 | |
741 | segment_selectable_ = true; | |
742 | ||
89914a86 | 743 | if ((mode == Trace::ShowAllSegments) || (mode == Trace::ShowAccumulatedIntensity)) |
7daebd05 SA |
744 | segment_selectable_ = false; |
745 | ||
89914a86 SA |
746 | viewport_->update(); |
747 | ||
748 | segment_display_mode_changed((int)mode, segment_selectable_); | |
7daebd05 SA |
749 | } |
750 | ||
cdf7bea7 | 751 | void View::zoom(double steps) |
adb4b10c | 752 | { |
8dbbc7f0 | 753 | zoom(steps, viewport_->width() / 2); |
adb4b10c JH |
754 | } |
755 | ||
17c0f398 JH |
756 | void View::zoom(double steps, int offset) |
757 | { | |
c063290a | 758 | set_zoom(scale_ * pow(3.0 / 2.0, -steps), offset); |
17c0f398 JH |
759 | } |
760 | ||
ce11b2ea | 761 | void View::zoom_fit(bool gui_state) |
ca46b534 | 762 | { |
ce11b2ea SA |
763 | // Act as one-shot when stopped, toggle along with the GUI otherwise |
764 | if (session_.get_capture_state() == Session::Stopped) { | |
765 | always_zoom_to_fit_ = false; | |
766 | always_zoom_to_fit_changed(false); | |
767 | } else { | |
768 | always_zoom_to_fit_ = gui_state; | |
769 | always_zoom_to_fit_changed(gui_state); | |
770 | } | |
771 | ||
60d9b99a JS |
772 | const pair<Timestamp, Timestamp> extents = get_time_extents(); |
773 | const Timestamp delta = extents.second - extents.first; | |
774 | if (delta < Timestamp("1e-12")) | |
ca46b534 JH |
775 | return; |
776 | ||
8dbbc7f0 JH |
777 | assert(viewport_); |
778 | const int w = viewport_->width(); | |
ca46b534 JH |
779 | if (w <= 0) |
780 | return; | |
781 | ||
60d9b99a JS |
782 | const Timestamp scale = max(min(delta / w, MaxScale), MinScale); |
783 | set_scale_offset(scale.convert_to<double>(), extents.first); | |
ca46b534 JH |
784 | } |
785 | ||
60d9b99a | 786 | void View::set_scale_offset(double scale, const Timestamp& offset) |
adb4b10c | 787 | { |
ce11b2ea SA |
788 | // Disable sticky scrolling / always zoom to fit when acquisition runs |
789 | // and user drags the viewport | |
c7b03d9d | 790 | if ((scale_ == scale) && (offset_ != offset) && |
ce11b2ea SA |
791 | (session_.get_capture_state() == Session::Running)) { |
792 | ||
793 | if (sticky_scrolling_) { | |
794 | sticky_scrolling_ = false; | |
795 | sticky_scrolling_changed(false); | |
796 | } | |
797 | ||
798 | if (always_zoom_to_fit_) { | |
799 | always_zoom_to_fit_ = false; | |
800 | always_zoom_to_fit_changed(false); | |
801 | } | |
c7b03d9d SA |
802 | } |
803 | ||
4b0af0b6 JS |
804 | set_scale(scale); |
805 | set_offset(offset); | |
ccdd3ef5 | 806 | |
361c560e JH |
807 | calculate_tick_spacing(); |
808 | ||
adb4b10c | 809 | update_scroll(); |
8dbbc7f0 | 810 | ruler_->update(); |
8dbbc7f0 | 811 | viewport_->update(); |
adb4b10c JH |
812 | } |
813 | ||
533b67b7 | 814 | vector< shared_ptr<SignalData> > View::get_visible_data() const |
1bc6525b | 815 | { |
1bc6525b | 816 | // Make a set of all the visible data objects |
533b67b7 | 817 | vector< shared_ptr<SignalData> > visible_data; |
f4ab4b5c | 818 | for (const shared_ptr<Signal>& sig : signals_) |
1bc6525b | 819 | if (sig->enabled()) |
533b67b7 | 820 | visible_data.push_back(sig->data()); |
1bc6525b JH |
821 | |
822 | return visible_data; | |
823 | } | |
824 | ||
60d9b99a | 825 | pair<Timestamp, Timestamp> View::get_time_extents() const |
1bc6525b | 826 | { |
60d9b99a | 827 | boost::optional<Timestamp> left_time, right_time; |
533b67b7 SA |
828 | |
829 | vector< shared_ptr<SignalData> > data; | |
830 | if (signals_.size() == 0) | |
831 | return make_pair(0, 0); | |
832 | ||
833 | data.push_back(signals_.front()->data()); | |
834 | ||
835 | for (const shared_ptr<SignalData>& d : data) { | |
c063290a | 836 | const vector< shared_ptr<Segment> > segments = d->segments(); |
f4ab4b5c | 837 | for (const shared_ptr<Segment>& s : segments) { |
ff008de6 JH |
838 | double samplerate = s->samplerate(); |
839 | samplerate = (samplerate <= 0.0) ? 1.0 : samplerate; | |
840 | ||
60d9b99a JS |
841 | const Timestamp start_time = s->start_time(); |
842 | left_time = left_time ? | |
843 | min(*left_time, start_time) : | |
9f094349 | 844 | start_time; |
60d9b99a JS |
845 | right_time = right_time ? |
846 | max(*right_time, start_time + d->max_sample_count() / samplerate) : | |
9f094349 | 847 | start_time + d->max_sample_count() / samplerate; |
7f4038d6 | 848 | } |
1bc6525b JH |
849 | } |
850 | ||
60d9b99a JS |
851 | if (!left_time || !right_time) |
852 | return make_pair(0, 0); | |
7f4038d6 | 853 | |
60d9b99a JS |
854 | assert(*left_time < *right_time); |
855 | return make_pair(*left_time, *right_time); | |
1bc6525b JH |
856 | } |
857 | ||
641574bc | 858 | bool View::colored_bg() const |
48995388 | 859 | { |
641574bc | 860 | return colored_bg_; |
48995388 JH |
861 | } |
862 | ||
f76af637 JH |
863 | bool View::cursors_shown() const |
864 | { | |
8dbbc7f0 | 865 | return show_cursors_; |
f76af637 JH |
866 | } |
867 | ||
868 | void View::show_cursors(bool show) | |
869 | { | |
a47b5a3f SA |
870 | if (show_cursors_ != show) { |
871 | show_cursors_ = show; | |
4eba9990 | 872 | |
a47b5a3f SA |
873 | cursor_state_changed(show); |
874 | ruler_->update(); | |
875 | viewport_->update(); | |
876 | } | |
4eba9990 | 877 | } |
878 | ||
a47b5a3f SA |
879 | void View::set_cursors(pv::util::Timestamp& first, pv::util::Timestamp& second) |
880 | { | |
881 | assert(cursors_); | |
4eba9990 | 882 | |
a47b5a3f SA |
883 | cursors_->first()->set_time(first); |
884 | cursors_->second()->set_time(second); | |
4eba9990 | 885 | |
a47b5a3f SA |
886 | ruler_->update(); |
887 | viewport_->update(); | |
f76af637 JH |
888 | } |
889 | ||
3d6ff1cd | 890 | void View::center_cursors() |
b4d91e56 | 891 | { |
a47b5a3f | 892 | assert(cursors_); |
5a206446 | 893 | |
a47b5a3f SA |
894 | const double time_width = scale_ * viewport_->width(); |
895 | cursors_->first()->set_time(offset_ + time_width * 0.4); | |
896 | cursors_->second()->set_time(offset_ + time_width * 0.6); | |
4eba9990 | 897 | |
a47b5a3f SA |
898 | ruler_->update(); |
899 | viewport_->update(); | |
b4d91e56 JH |
900 | } |
901 | ||
6f925ba9 | 902 | shared_ptr<CursorPair> View::cursors() const |
58864c5c | 903 | { |
8dbbc7f0 | 904 | return cursors_; |
58864c5c JH |
905 | } |
906 | ||
710c2a18 | 907 | shared_ptr<Flag> View::add_flag(const Timestamp& time) |
8914fe79 | 908 | { |
9f094349 SA |
909 | shared_ptr<Flag> flag = |
910 | make_shared<Flag>(*this, time, QString("%1").arg(next_flag_text_)); | |
710c2a18 | 911 | flags_.push_back(flag); |
48257a69 | 912 | |
8914fe79 JH |
913 | next_flag_text_ = (next_flag_text_ >= 'Z') ? 'A' : |
914 | (next_flag_text_ + 1); | |
48257a69 | 915 | |
8914fe79 | 916 | time_item_appearance_changed(true, true); |
710c2a18 | 917 | return flag; |
8914fe79 JH |
918 | } |
919 | ||
6f925ba9 | 920 | void View::remove_flag(shared_ptr<Flag> flag) |
8914fe79 JH |
921 | { |
922 | flags_.remove(flag); | |
923 | time_item_appearance_changed(true, true); | |
924 | } | |
925 | ||
6f925ba9 | 926 | vector< shared_ptr<Flag> > View::flags() const |
8914fe79 | 927 | { |
6f925ba9 | 928 | vector< shared_ptr<Flag> > flags(flags_.begin(), flags_.end()); |
8914fe79 JH |
929 | stable_sort(flags.begin(), flags.end(), |
930 | [](const shared_ptr<Flag> &a, const shared_ptr<Flag> &b) { | |
931 | return a->time() < b->time(); | |
932 | }); | |
933 | ||
934 | return flags; | |
935 | } | |
936 | ||
cbd80f64 JH |
937 | const QPoint& View::hover_point() const |
938 | { | |
8dbbc7f0 | 939 | return hover_point_; |
cbd80f64 JH |
940 | } |
941 | ||
581724de SA |
942 | const QWidget* View::hover_widget() const |
943 | { | |
944 | return hover_widget_; | |
945 | } | |
946 | ||
f6b6c9bf | 947 | int64_t View::get_nearest_level_change(const QPoint &p) |
eeceee99 | 948 | { |
e0544801 | 949 | // Is snapping disabled? |
fb641801 SA |
950 | if (snap_distance_ == 0) |
951 | return -1; | |
952 | ||
e0544801 SA |
953 | struct entry_t { |
954 | entry_t(shared_ptr<Signal> s) : | |
955 | signal(s), delta(numeric_limits<int64_t>::max()), sample(-1), is_dense(false) {} | |
956 | shared_ptr<Signal> signal; | |
957 | int64_t delta; | |
958 | int64_t sample; | |
959 | bool is_dense; | |
960 | }; | |
961 | ||
962 | vector<entry_t> list; | |
963 | ||
964 | // Create list of signals to consider | |
965 | if (signal_under_mouse_cursor_) | |
966 | list.emplace_back(signal_under_mouse_cursor_); | |
967 | else | |
968 | for (shared_ptr<Signal> s : signals_) { | |
969 | if (!s->enabled()) | |
970 | continue; | |
eeceee99 | 971 | |
e0544801 SA |
972 | list.emplace_back(s); |
973 | } | |
eeceee99 | 974 | |
e0544801 SA |
975 | // Get data for listed signals |
976 | for (entry_t &e : list) { | |
f6b6c9bf | 977 | // Calculate sample number from cursor position |
e0544801 | 978 | const double samples_per_pixel = e.signal->base()->get_samplerate() * scale(); |
f6b6c9bf SA |
979 | const int64_t x_offset = offset().convert_to<double>() / scale(); |
980 | const int64_t sample_num = max(((x_offset + p.x()) * samples_per_pixel), 0.0); | |
eeceee99 | 981 | |
e0544801 SA |
982 | vector<data::LogicSegment::EdgePair> edges = |
983 | e.signal->get_nearest_level_changes(sample_num); | |
f6b6c9bf | 984 | |
e0544801 SA |
985 | if (edges.empty()) |
986 | continue; | |
f6b6c9bf | 987 | |
e0544801 SA |
988 | // Check first edge |
989 | const int64_t first_sample_delta = abs(sample_num - edges.front().first); | |
990 | const int64_t first_delta = first_sample_delta / samples_per_pixel; | |
991 | e.delta = first_delta; | |
992 | e.sample = edges.front().first; | |
f6b6c9bf | 993 | |
e0544801 SA |
994 | // Check second edge if available |
995 | if (edges.size() == 2) { | |
996 | // Note: -1 because this is usually the right edge and sample points are left-aligned | |
997 | const int64_t second_sample_delta = abs(sample_num - edges.back().first - 1); | |
998 | const int64_t second_delta = second_sample_delta / samples_per_pixel; | |
f6b6c9bf | 999 | |
e0544801 SA |
1000 | // If both edges are too close, we mark this signal as being dense |
1001 | if ((first_delta + second_delta) <= snap_distance_) | |
1002 | e.is_dense = true; | |
eeceee99 | 1003 | |
e0544801 SA |
1004 | if (second_delta < first_delta) { |
1005 | e.delta = second_delta; | |
1006 | e.sample = edges.back().first; | |
1007 | } | |
1008 | } | |
1009 | } | |
eeceee99 | 1010 | |
e0544801 SA |
1011 | // Look for the best match: non-dense first, then dense |
1012 | entry_t *match = nullptr; | |
eeceee99 | 1013 | |
e0544801 SA |
1014 | for (entry_t &e : list) { |
1015 | if (e.delta > snap_distance_ || e.is_dense) | |
1016 | continue; | |
eeceee99 | 1017 | |
e0544801 SA |
1018 | if (match) { |
1019 | if (e.delta < match->delta) | |
1020 | match = &e; | |
1021 | } else | |
1022 | match = &e; | |
1023 | } | |
f6b6c9bf | 1024 | |
e0544801 SA |
1025 | if (!match) { |
1026 | for (entry_t &e : list) { | |
1027 | if (!e.is_dense) | |
1028 | continue; | |
f6b6c9bf | 1029 | |
e0544801 SA |
1030 | if (match) { |
1031 | if (e.delta < match->delta) | |
1032 | match = &e; | |
1033 | } else | |
1034 | match = &e; | |
1035 | } | |
1036 | } | |
47cf8590 | 1037 | |
e0544801 SA |
1038 | if (match) { |
1039 | // Somewhat ugly hack to make TimeItem::drag_by() work | |
1040 | signal_under_mouse_cursor_ = match->signal; | |
f6b6c9bf | 1041 | |
e0544801 | 1042 | return match->sample; |
f6b6c9bf | 1043 | } |
eeceee99 | 1044 | |
e0544801 | 1045 | return -1; |
eeceee99 SA |
1046 | } |
1047 | ||
af503b10 | 1048 | void View::restack_all_trace_tree_items() |
7ff0145f | 1049 | { |
873cbed0 | 1050 | // Make a list of owners that is sorted from deepest first |
cc88566c JH |
1051 | const vector<shared_ptr<TraceTreeItem>> items( |
1052 | list_by_type<TraceTreeItem>()); | |
4800cf9a | 1053 | set< TraceTreeItemOwner* > owners; |
cc88566c | 1054 | for (const auto &r : items) |
4800cf9a | 1055 | owners.insert(r->owner()); |
af503b10 | 1056 | vector< TraceTreeItemOwner* > sorted_owners(owners.begin(), owners.end()); |
7ff0145f | 1057 | sort(sorted_owners.begin(), sorted_owners.end(), |
af503b10 | 1058 | [](const TraceTreeItemOwner* a, const TraceTreeItemOwner *b) { |
7ff0145f JH |
1059 | return a->depth() > b->depth(); }); |
1060 | ||
1061 | // Restack the items recursively | |
1062 | for (auto &o : sorted_owners) | |
1063 | o->restack_items(); | |
1064 | ||
1065 | // Animate the items to their destination | |
cef5997e JH |
1066 | for (const auto &i : items) |
1067 | i->animate_to_layout_v_offset(); | |
9cef9567 JH |
1068 | } |
1069 | ||
cbd9ec7f SA |
1070 | int View::header_width() const |
1071 | { | |
1072 | return header_->extended_size_hint().width(); | |
1073 | } | |
1074 | ||
d0c0573b SA |
1075 | void View::on_setting_changed(const QString &key, const QVariant &value) |
1076 | { | |
8ba6f8b7 SA |
1077 | GlobalSettings settings; |
1078 | ||
1079 | if (key == GlobalSettings::Key_View_ColoredBG) { | |
1080 | colored_bg_ = settings.value(GlobalSettings::Key_View_ColoredBG).toBool(); | |
1081 | viewport_->update(); | |
1082 | } | |
1083 | ||
1084 | if ((key == GlobalSettings::Key_View_ShowSamplingPoints) || | |
1085 | (key == GlobalSettings::Key_View_ShowAnalogMinorGrid)) | |
1086 | viewport_->update(); | |
1087 | ||
d0c0573b SA |
1088 | if (key == GlobalSettings::Key_View_TriggerIsZeroTime) |
1089 | on_settingViewTriggerIsZeroTime_changed(value); | |
fb641801 | 1090 | |
8ba6f8b7 | 1091 | if (key == GlobalSettings::Key_View_SnapDistance) |
fb641801 | 1092 | snap_distance_ = settings.value(GlobalSettings::Key_View_SnapDistance).toInt(); |
d0c0573b SA |
1093 | } |
1094 | ||
7ea2a4ff | 1095 | void View::trigger_event(int segment_id, util::Timestamp location) |
48257a69 | 1096 | { |
7ea2a4ff SA |
1097 | // TODO This doesn't work if we're showing multiple segments at once |
1098 | if ((uint32_t)segment_id != current_segment_) | |
1099 | return; | |
1100 | ||
e887fe9e SA |
1101 | if (!custom_zero_offset_set_) |
1102 | reset_zero_position(); | |
ffc00fdd | 1103 | |
067bb624 | 1104 | trigger_markers_.push_back(make_shared<TriggerMarker>(*this, location)); |
48257a69 SA |
1105 | } |
1106 | ||
60d9b99a | 1107 | void View::get_scroll_layout(double &length, Timestamp &offset) const |
f25770e2 | 1108 | { |
60d9b99a JS |
1109 | const pair<Timestamp, Timestamp> extents = get_time_extents(); |
1110 | length = ((extents.second - extents.first) / scale_).convert_to<double>(); | |
8dbbc7f0 | 1111 | offset = offset_ / scale_; |
f25770e2 JH |
1112 | } |
1113 | ||
d1e7d82c JH |
1114 | void View::set_zoom(double scale, int offset) |
1115 | { | |
ce11b2ea SA |
1116 | // Reset the "always zoom to fit" feature as the user changed the zoom |
1117 | always_zoom_to_fit_ = false; | |
1118 | always_zoom_to_fit_changed(false); | |
1119 | ||
60d9b99a JS |
1120 | const Timestamp cursor_offset = offset_ + scale_ * offset; |
1121 | const Timestamp new_scale = max(min(Timestamp(scale), MaxScale), MinScale); | |
1122 | const Timestamp new_offset = cursor_offset - new_scale * offset; | |
1123 | set_scale_offset(new_scale.convert_to<double>(), new_offset); | |
d1e7d82c JH |
1124 | } |
1125 | ||
361c560e JH |
1126 | void View::calculate_tick_spacing() |
1127 | { | |
8a1bc087 | 1128 | const double SpacingIncrement = 10.0f; |
8a463dbc | 1129 | const double MinValueSpacing = 40.0f; |
361c560e | 1130 | |
1e124d4b SA |
1131 | // Figure out the highest numeric value visible on a label |
1132 | const QSize areaSize = viewport_->size(); | |
60d9b99a | 1133 | const Timestamp max_time = max(fabs(offset_), |
1e124d4b SA |
1134 | fabs(offset_ + scale_ * areaSize.width())); |
1135 | ||
d40f4db7 SA |
1136 | double min_width = SpacingIncrement; |
1137 | double label_width, tick_period_width; | |
361c560e JH |
1138 | |
1139 | QFontMetrics m(QApplication::font()); | |
1140 | ||
adb3831e JS |
1141 | // Copies of the member variables with the same name, used in the calculation |
1142 | // and written back afterwards, so that we don't emit signals all the time | |
1143 | // during the calculation. | |
1144 | pv::util::Timestamp tick_period = tick_period_; | |
1145 | pv::util::SIPrefix tick_prefix = tick_prefix_; | |
1146 | unsigned tick_precision = tick_precision_; | |
1147 | ||
361c560e JH |
1148 | do { |
1149 | const double min_period = scale_ * min_width; | |
1150 | ||
1151 | const int order = (int)floorf(log10f(min_period)); | |
c677193d JS |
1152 | const pv::util::Timestamp order_decimal = |
1153 | pow(pv::util::Timestamp(10), order); | |
361c560e | 1154 | |
8a1bc087 SA |
1155 | // Allow for a margin of error so that a scale unit of 1 can be used. |
1156 | // Otherwise, for a SU of 1 the tick period will almost always be below | |
1157 | // the min_period by a small amount - and thus skipped in favor of 2. | |
1158 | // Note: margin assumes that SU[0] and SU[1] contain the smallest values | |
1159 | double tp_margin = (ScaleUnits[0] + ScaleUnits[1]) / 2.0; | |
1160 | double tp_with_margin; | |
361c560e JH |
1161 | unsigned int unit = 0; |
1162 | ||
1163 | do { | |
c677193d JS |
1164 | tp_with_margin = order_decimal.convert_to<double>() * |
1165 | (ScaleUnits[unit++] + tp_margin); | |
8a1bc087 | 1166 | } while (tp_with_margin < min_period && unit < countof(ScaleUnits)); |
361c560e | 1167 | |
e4cc0ee6 | 1168 | minor_tick_count_ = (unit == 2) ? 4 : 5; |
adb3831e JS |
1169 | tick_period = order_decimal * ScaleUnits[unit - 1]; |
1170 | tick_prefix = static_cast<pv::util::SIPrefix>( | |
1171 | (order - pv::util::exponent(pv::util::SIPrefix::yocto)) / 3); | |
361c560e | 1172 | |
d40f4db7 SA |
1173 | // Precision is the number of fractional digits required, not |
1174 | // taking the prefix into account (and it must never be negative) | |
6f925ba9 | 1175 | tick_precision = max(ceil(log10(1 / tick_period)).convert_to<int>(), 0); |
d40f4db7 | 1176 | |
adb3831e | 1177 | tick_period_width = (tick_period / scale_).convert_to<double>(); |
d40f4db7 | 1178 | |
3ccf0f7f JS |
1179 | const QString label_text = Ruler::format_time_with_distance( |
1180 | tick_period, max_time, tick_prefix, time_unit_, tick_precision); | |
d40f4db7 SA |
1181 | |
1182 | label_width = m.boundingRect(0, 0, INT_MAX, INT_MAX, | |
1183 | Qt::AlignLeft | Qt::AlignTop, label_text).width() + | |
361c560e JH |
1184 | MinValueSpacing; |
1185 | ||
1186 | min_width += SpacingIncrement; | |
d40f4db7 | 1187 | } while (tick_period_width < label_width); |
adb3831e JS |
1188 | |
1189 | set_tick_period(tick_period); | |
1190 | set_tick_prefix(tick_prefix); | |
1191 | set_tick_precision(tick_precision); | |
361c560e JH |
1192 | } |
1193 | ||
8a5fd81f SA |
1194 | void View::adjust_top_margin() |
1195 | { | |
1196 | assert(viewport_); | |
1197 | ||
1198 | const QSize areaSize = viewport_->size(); | |
1199 | ||
1200 | const pair<int, int> extents = v_extents(); | |
1201 | const int top_margin = owner_visual_v_offset() + extents.first; | |
1202 | const int trace_bottom = owner_visual_v_offset() + extents.first + extents.second; | |
1203 | ||
1204 | // Do we have empty space at the top while the last trace goes out of screen? | |
1205 | if ((top_margin > 0) && (trace_bottom > areaSize.height())) { | |
1206 | const int trace_height = extents.second - extents.first; | |
1207 | ||
1208 | // Center everything vertically if there is enough space | |
1209 | if (areaSize.height() >= trace_height) | |
1210 | set_v_offset(extents.first - | |
1211 | ((areaSize.height() - trace_height) / 2)); | |
1212 | else | |
1213 | // Remove the top margin to make as many traces fit on screen as possible | |
1214 | set_v_offset(extents.first); | |
1215 | } | |
1216 | } | |
1217 | ||
cdf7bea7 | 1218 | void View::update_scroll() |
adb4b10c | 1219 | { |
8dbbc7f0 | 1220 | assert(viewport_); |
33094993 SA |
1221 | QScrollBar *hscrollbar = scrollarea_->horizontalScrollBar(); |
1222 | QScrollBar *vscrollbar = scrollarea_->verticalScrollBar(); | |
adb4b10c | 1223 | |
8dbbc7f0 | 1224 | const QSize areaSize = viewport_->size(); |
adb4b10c JH |
1225 | |
1226 | // Set the horizontal scroll bar | |
60d9b99a JS |
1227 | double length = 0; |
1228 | Timestamp offset; | |
f25770e2 JH |
1229 | get_scroll_layout(length, offset); |
1230 | length = max(length - areaSize.width(), 0.0); | |
adb4b10c | 1231 | |
c677193d | 1232 | int major_tick_distance = (tick_period_ / scale_).convert_to<int>(); |
d7aae647 | 1233 | |
f4e57597 SA |
1234 | hscrollbar->setPageStep(areaSize.width() / 2); |
1235 | hscrollbar->setSingleStep(major_tick_distance); | |
f25770e2 | 1236 | |
8dbbc7f0 | 1237 | updating_scroll_ = true; |
528bd8a1 | 1238 | |
333d5bbc | 1239 | if (length < MaxScrollValue) { |
f4e57597 SA |
1240 | hscrollbar->setRange(0, length); |
1241 | hscrollbar->setSliderPosition(offset.convert_to<double>()); | |
f25770e2 | 1242 | } else { |
f4e57597 SA |
1243 | hscrollbar->setRange(0, MaxScrollValue); |
1244 | hscrollbar->setSliderPosition( | |
60d9b99a | 1245 | (offset_ * MaxScrollValue / (scale_ * length)).convert_to<double>()); |
f25770e2 | 1246 | } |
adb4b10c | 1247 | |
8dbbc7f0 | 1248 | updating_scroll_ = false; |
528bd8a1 | 1249 | |
adb4b10c | 1250 | // Set the vertical scrollbar |
f4e57597 SA |
1251 | vscrollbar->setPageStep(areaSize.height()); |
1252 | vscrollbar->setSingleStep(areaSize.height() / 8); | |
a5d93c27 JH |
1253 | |
1254 | const pair<int, int> extents = v_extents(); | |
925763b0 SA |
1255 | |
1256 | // Don't change the scrollbar range if there are no traces | |
6381b375 SA |
1257 | if (extents.first != extents.second) { |
1258 | int top_margin = ViewScrollMargin; | |
1259 | int btm_margin = ViewScrollMargin; | |
1260 | ||
1261 | vscrollbar->setRange(extents.first - areaSize.height() + top_margin, | |
1262 | extents.second - btm_margin); | |
1263 | } | |
925763b0 | 1264 | |
2099158e | 1265 | if (scroll_needs_defaults_) { |
925763b0 | 1266 | set_scroll_default(); |
2099158e SA |
1267 | scroll_needs_defaults_ = false; |
1268 | } | |
925763b0 SA |
1269 | } |
1270 | ||
1271 | void View::reset_scroll() | |
1272 | { | |
33094993 | 1273 | scrollarea_->verticalScrollBar()->setRange(0, 0); |
925763b0 SA |
1274 | } |
1275 | ||
1276 | void View::set_scroll_default() | |
1277 | { | |
1278 | assert(viewport_); | |
1279 | ||
1280 | const QSize areaSize = viewport_->size(); | |
1281 | ||
925763b0 SA |
1282 | const pair<int, int> extents = v_extents(); |
1283 | const int trace_height = extents.second - extents.first; | |
1284 | ||
1285 | // Do all traces fit in the view? | |
1286 | if (areaSize.height() >= trace_height) | |
1287 | // Center all traces vertically | |
1288 | set_v_offset(extents.first - | |
1289 | ((areaSize.height() - trace_height) / 2)); | |
1290 | else | |
1291 | // Put the first trace at the top, letting the bottom ones overflow | |
1292 | set_v_offset(extents.first); | |
adb4b10c JH |
1293 | } |
1294 | ||
9510aea0 | 1295 | void View::determine_if_header_was_shrunk() |
33094993 | 1296 | { |
b571a8e7 SA |
1297 | const int header_pane_width = |
1298 | splitter_->sizes().front(); // clazy:exclude=detaching-temporary | |
33094993 | 1299 | |
e0be5f21 SA |
1300 | // Allow for a slight margin of error so that we also accept |
1301 | // slight differences when e.g. a label name change increased | |
1302 | // the overall width | |
cbd9ec7f | 1303 | header_was_shrunk_ = (header_pane_width < (header_width() - 10)); |
33094993 SA |
1304 | } |
1305 | ||
60c426a0 | 1306 | void View::resize_header_to_fit() |
d7c0ca4a | 1307 | { |
572c3bb7 SA |
1308 | // Setting the maximum width of the header widget doesn't work as |
1309 | // expected because the splitter would allow the user to make the | |
1310 | // pane wider than that, creating empty space as a result. | |
1311 | // To make this work, we stricly enforce the maximum width by | |
1312 | // expanding the header unless the user shrunk it on purpose. | |
1313 | // As we're then setting the width of the header pane, we set the | |
1314 | // splitter to the maximum allowed position. | |
1315 | ||
76750c41 | 1316 | int splitter_area_width = 0; |
b571a8e7 | 1317 | for (int w : splitter_->sizes()) // clazy:exclude=range-loop |
76750c41 | 1318 | splitter_area_width += w; |
33094993 | 1319 | |
76750c41 SA |
1320 | // Make sure the header has enough horizontal space to show all labels fully |
1321 | QList<int> pane_sizes; | |
1322 | pane_sizes.push_back(header_->extended_size_hint().width()); | |
1323 | pane_sizes.push_back(splitter_area_width - header_->extended_size_hint().width()); | |
1324 | splitter_->setSizes(pane_sizes); | |
1325 | } | |
1326 | ||
1327 | void View::update_layout() | |
1328 | { | |
d7c0ca4a JH |
1329 | update_scroll(); |
1330 | } | |
1331 | ||
af503b10 | 1332 | TraceTreeItemOwner* View::find_prevalent_trace_group( |
cf124e47 | 1333 | const shared_ptr<sigrok::ChannelGroup> &group, |
bf0edd2b | 1334 | const unordered_map<shared_ptr<data::SignalBase>, shared_ptr<Signal> > |
cf124e47 | 1335 | &signal_map) |
448a72cf | 1336 | { |
cf124e47 | 1337 | assert(group); |
448a72cf | 1338 | |
af503b10 JH |
1339 | unordered_set<TraceTreeItemOwner*> owners; |
1340 | vector<TraceTreeItemOwner*> owner_list; | |
448a72cf | 1341 | |
cf124e47 | 1342 | // Make a set and a list of all the owners |
f4ab4b5c SA |
1343 | for (const auto& channel : group->channels()) { |
1344 | for (auto& entry : signal_map) { | |
bf0edd2b SA |
1345 | if (entry.first->channel() == channel) { |
1346 | TraceTreeItemOwner *const o = (entry.second)->owner(); | |
1347 | owner_list.push_back(o); | |
1348 | owners.insert(o); | |
1349 | } | |
1350 | } | |
cf124e47 | 1351 | } |
448a72cf | 1352 | |
cf124e47 JH |
1353 | // Iterate through the list of owners, and find the most prevalent |
1354 | size_t max_prevalence = 0; | |
af503b10 JH |
1355 | TraceTreeItemOwner *prevalent_owner = nullptr; |
1356 | for (TraceTreeItemOwner *owner : owners) { | |
6f925ba9 | 1357 | const size_t prevalence = count_if( |
cf124e47 | 1358 | owner_list.begin(), owner_list.end(), |
af503b10 | 1359 | [&](TraceTreeItemOwner *o) { return o == owner; }); |
cf124e47 JH |
1360 | if (prevalence > max_prevalence) { |
1361 | max_prevalence = prevalence; | |
1362 | prevalent_owner = owner; | |
1363 | } | |
448a72cf JH |
1364 | } |
1365 | ||
cf124e47 | 1366 | return prevalent_owner; |
448a72cf JH |
1367 | } |
1368 | ||
cf124e47 JH |
1369 | vector< shared_ptr<Trace> > View::extract_new_traces_for_channels( |
1370 | const vector< shared_ptr<sigrok::Channel> > &channels, | |
bf0edd2b | 1371 | const unordered_map<shared_ptr<data::SignalBase>, shared_ptr<Signal> > |
cf124e47 JH |
1372 | &signal_map, |
1373 | set< shared_ptr<Trace> > &add_list) | |
1374 | { | |
1375 | vector< shared_ptr<Trace> > filtered_traces; | |
1376 | ||
f4ab4b5c SA |
1377 | for (const auto& channel : channels) { |
1378 | for (auto& entry : signal_map) { | |
bf0edd2b SA |
1379 | if (entry.first->channel() == channel) { |
1380 | shared_ptr<Trace> trace = entry.second; | |
1381 | const auto list_iter = add_list.find(trace); | |
1382 | if (list_iter == add_list.end()) | |
1383 | continue; | |
1384 | ||
1385 | filtered_traces.push_back(trace); | |
1386 | add_list.erase(list_iter); | |
1387 | } | |
1388 | } | |
cf124e47 JH |
1389 | } |
1390 | ||
1391 | return filtered_traces; | |
448a72cf JH |
1392 | } |
1393 | ||
ef454ad5 SA |
1394 | void View::determine_time_unit() |
1395 | { | |
7ee199a7 | 1396 | // Check whether we know the sample rate and hence can use time as the unit |
d001f416 | 1397 | if (time_unit_ == util::TimeUnit::Samples) { |
7ee199a7 | 1398 | // Check all signals but... |
f4ab4b5c | 1399 | for (const shared_ptr<Signal>& signal : signals_) { |
7ee199a7 SA |
1400 | const shared_ptr<SignalData> data = signal->data(); |
1401 | ||
1402 | // ...only check first segment of each | |
1403 | const vector< shared_ptr<Segment> > segments = data->segments(); | |
1404 | if (!segments.empty()) | |
1405 | if (segments[0]->samplerate()) { | |
4b0af0b6 | 1406 | set_time_unit(util::TimeUnit::Time); |
7ee199a7 SA |
1407 | break; |
1408 | } | |
1409 | } | |
ef454ad5 SA |
1410 | } |
1411 | } | |
1412 | ||
cbd80f64 JH |
1413 | bool View::eventFilter(QObject *object, QEvent *event) |
1414 | { | |
1415 | const QEvent::Type type = event->type(); | |
74bf6666 | 1416 | |
333d5bbc | 1417 | if (type == QEvent::MouseMove) { |
cbd80f64 | 1418 | |
581724de SA |
1419 | if (object) |
1420 | hover_widget_ = qobject_cast<QWidget*>(object); | |
1421 | ||
cbd80f64 | 1422 | const QMouseEvent *const mouse_event = (QMouseEvent*)event; |
8dbbc7f0 JH |
1423 | if (object == viewport_) |
1424 | hover_point_ = mouse_event->pos(); | |
819e2e95 | 1425 | else if (object == ruler_) |
581724de | 1426 | hover_point_ = mouse_event->pos(); |
8dbbc7f0 JH |
1427 | else if (object == header_) |
1428 | hover_point_ = QPoint(0, mouse_event->y()); | |
cbd80f64 | 1429 | else |
8dbbc7f0 | 1430 | hover_point_ = QPoint(-1, -1); |
cbd80f64 | 1431 | |
873e8035 | 1432 | update_hover_point(); |
cbd80f64 | 1433 | |
95a4b2a1 MM |
1434 | if (grabbed_widget_) { |
1435 | int64_t nearest = get_nearest_level_change(hover_point_); | |
1436 | pv::util::Timestamp mouse_time = offset_ + hover_point_.x() * scale_; | |
1437 | ||
1438 | if (nearest == -1) { | |
1439 | grabbed_widget_->set_time(mouse_time); | |
1440 | } else { | |
1441 | grabbed_widget_->set_time(nearest / get_signal_under_mouse_cursor()->base()->get_samplerate()); | |
1442 | } | |
1443 | } | |
1444 | ||
74bf6666 | 1445 | } else if (type == QEvent::MouseButtonPress) { |
95a4b2a1 MM |
1446 | grabbed_widget_ = nullptr; |
1447 | ||
74bf6666 SA |
1448 | const QMouseEvent *const mouse_event = (QMouseEvent*)event; |
1449 | if ((object == viewport_) && (mouse_event->button() & Qt::LeftButton)) { | |
1450 | // Send event to all trace tree items | |
1451 | const vector<shared_ptr<TraceTreeItem>> trace_tree_items( | |
1452 | list_by_type<TraceTreeItem>()); | |
1453 | for (const shared_ptr<TraceTreeItem>& r : trace_tree_items) | |
1454 | r->mouse_left_press_event(mouse_event); | |
1455 | } | |
333d5bbc | 1456 | } else if (type == QEvent::Leave) { |
8dbbc7f0 | 1457 | hover_point_ = QPoint(-1, -1); |
873e8035 | 1458 | update_hover_point(); |
5f9b7de5 SA |
1459 | } else if (type == QEvent::Show) { |
1460 | ||
1461 | // This is somewhat of a hack, unfortunately. We cannot use | |
1462 | // set_v_offset() from within restore_settings() as the view | |
1463 | // at that point is neither visible nor properly sized. | |
1464 | // This is the least intrusive workaround I could come up | |
1465 | // with: set the vertical offset (or scroll defaults) when | |
1466 | // the view is shown, which happens after all widgets were | |
1467 | // resized to their final sizes. | |
1468 | update_layout(); | |
1469 | ||
60c426a0 SA |
1470 | if (settings_restored_) |
1471 | determine_if_header_was_shrunk(); | |
1472 | else | |
1473 | resize_header_to_fit(); | |
b760e6e0 | 1474 | |
5f9b7de5 SA |
1475 | if (scroll_needs_defaults_) { |
1476 | set_scroll_default(); | |
1477 | scroll_needs_defaults_ = false; | |
1478 | } | |
1479 | ||
1480 | if (saved_v_offset_) { | |
1481 | set_v_offset(saved_v_offset_); | |
1482 | saved_v_offset_ = 0; | |
1483 | } | |
cbd80f64 JH |
1484 | } |
1485 | ||
1486 | return QObject::eventFilter(object, event); | |
1487 | } | |
1488 | ||
d9b55cc8 SA |
1489 | void View::contextMenuEvent(QContextMenuEvent *event) |
1490 | { | |
be843692 SA |
1491 | QPoint pos = event->pos() - QPoint(0, ruler_->sizeHint().height()); |
1492 | ||
1493 | const shared_ptr<ViewItem> r = viewport_->get_mouse_over_item(pos); | |
d9b55cc8 SA |
1494 | if (!r) |
1495 | return; | |
1496 | ||
be843692 | 1497 | QMenu *menu = r->create_view_context_menu(this, pos); |
d9b55cc8 | 1498 | if (menu) |
8835b5e7 | 1499 | menu->popup(event->globalPos()); |
d9b55cc8 SA |
1500 | } |
1501 | ||
8a5fd81f | 1502 | void View::resizeEvent(QResizeEvent* event) |
adb4b10c | 1503 | { |
8a5fd81f SA |
1504 | // Only adjust the top margin if we shrunk vertically |
1505 | if (event->size().height() < event->oldSize().height()) | |
1506 | adjust_top_margin(); | |
1507 | ||
d7c0ca4a | 1508 | update_layout(); |
adb4b10c JH |
1509 | } |
1510 | ||
873e8035 SA |
1511 | void View::update_hover_point() |
1512 | { | |
eeceee99 SA |
1513 | // Determine signal that the mouse cursor is hovering over |
1514 | signal_under_mouse_cursor_.reset(); | |
581724de | 1515 | if (hover_widget_ == this) { |
f4ab4b5c | 1516 | for (const shared_ptr<Signal>& s : signals_) { |
581724de SA |
1517 | const pair<int, int> extents = s->v_extents(); |
1518 | const int top = s->get_visual_y() + extents.first; | |
1519 | const int btm = s->get_visual_y() + extents.second; | |
1520 | if ((hover_point_.y() >= top) && (hover_point_.y() <= btm) | |
1521 | && s->base()->enabled()) | |
1522 | signal_under_mouse_cursor_ = s; | |
1523 | } | |
eeceee99 SA |
1524 | } |
1525 | ||
1526 | // Update all trace tree items | |
873e8035 SA |
1527 | const vector<shared_ptr<TraceTreeItem>> trace_tree_items( |
1528 | list_by_type<TraceTreeItem>()); | |
f4ab4b5c | 1529 | for (const shared_ptr<TraceTreeItem>& r : trace_tree_items) |
873e8035 SA |
1530 | r->hover_point_changed(hover_point_); |
1531 | ||
eeceee99 | 1532 | // Notify any other listeners |
581724de | 1533 | hover_point_changed(hover_widget_, hover_point_); |
873e8035 SA |
1534 | } |
1535 | ||
6e2c3c85 | 1536 | void View::row_item_appearance_changed(bool label, bool content) |
32218d3e JH |
1537 | { |
1538 | if (label) | |
8dbbc7f0 | 1539 | header_->update(); |
32218d3e | 1540 | if (content) |
8dbbc7f0 | 1541 | viewport_->update(); |
32218d3e JH |
1542 | } |
1543 | ||
98cfe4e8 JH |
1544 | void View::time_item_appearance_changed(bool label, bool content) |
1545 | { | |
e0be5f21 | 1546 | if (label) { |
819e2e95 | 1547 | ruler_->update(); |
e0be5f21 SA |
1548 | |
1549 | // Make sure the header pane width is updated, too | |
1550 | update_layout(); | |
1551 | } | |
1552 | ||
98cfe4e8 JH |
1553 | if (content) |
1554 | viewport_->update(); | |
1555 | } | |
1556 | ||
32218d3e JH |
1557 | void View::extents_changed(bool horz, bool vert) |
1558 | { | |
8dbbc7f0 | 1559 | sticky_events_ |= |
af503b10 JH |
1560 | (horz ? TraceTreeItemHExtentsChanged : 0) | |
1561 | (vert ? TraceTreeItemVExtentsChanged : 0); | |
5ed05b69 | 1562 | |
38b77a3b SA |
1563 | if (!lazy_event_handler_.isActive()) |
1564 | lazy_event_handler_.start(); | |
32218d3e JH |
1565 | } |
1566 | ||
00c518d6 SA |
1567 | void View::on_signal_name_changed() |
1568 | { | |
9510aea0 | 1569 | if (!header_was_shrunk_) |
60c426a0 | 1570 | resize_header_to_fit(); |
00c518d6 SA |
1571 | } |
1572 | ||
e0be5f21 SA |
1573 | void View::on_splitter_moved() |
1574 | { | |
9510aea0 SA |
1575 | // The header can only shrink when the splitter is moved manually |
1576 | determine_if_header_was_shrunk(); | |
1577 | ||
1578 | if (!header_was_shrunk_) | |
60c426a0 | 1579 | resize_header_to_fit(); |
e0be5f21 SA |
1580 | } |
1581 | ||
476ca5f4 SA |
1582 | void View::on_zoom_in_shortcut_triggered() |
1583 | { | |
1584 | zoom(1); | |
1585 | } | |
1586 | ||
1587 | void View::on_zoom_out_shortcut_triggered() | |
1588 | { | |
1589 | zoom(-1); | |
1590 | } | |
1591 | ||
1592 | void View::on_scroll_to_start_shortcut_triggered() | |
1593 | { | |
1594 | set_h_offset(0); | |
1595 | } | |
1596 | ||
1597 | void View::on_scroll_to_end_shortcut_triggered() | |
1598 | { | |
1599 | set_h_offset(get_h_scrollbar_maximum()); | |
1600 | } | |
1601 | ||
b16907d3 | 1602 | void View::h_scroll_value_changed(int value) |
adb4b10c | 1603 | { |
8dbbc7f0 | 1604 | if (updating_scroll_) |
528bd8a1 JH |
1605 | return; |
1606 | ||
c7b03d9d SA |
1607 | // Disable sticky scrolling when user moves the horizontal scroll bar |
1608 | // during a running acquisition | |
1609 | if (sticky_scrolling_ && (session_.get_capture_state() == Session::Running)) { | |
1610 | sticky_scrolling_ = false; | |
1611 | sticky_scrolling_changed(false); | |
1612 | } | |
1613 | ||
33094993 | 1614 | const int range = scrollarea_->horizontalScrollBar()->maximum(); |
333d5bbc | 1615 | if (range < MaxScrollValue) |
4b0af0b6 | 1616 | set_offset(scale_ * value); |
f25770e2 | 1617 | else { |
60d9b99a JS |
1618 | double length = 0; |
1619 | Timestamp offset; | |
f25770e2 | 1620 | get_scroll_layout(length, offset); |
4b0af0b6 | 1621 | set_offset(scale_ * length * value / MaxScrollValue); |
f25770e2 JH |
1622 | } |
1623 | ||
8dbbc7f0 | 1624 | ruler_->update(); |
8dbbc7f0 | 1625 | viewport_->update(); |
adb4b10c JH |
1626 | } |
1627 | ||
f8400017 | 1628 | void View::v_scroll_value_changed() |
adb4b10c | 1629 | { |
8dbbc7f0 JH |
1630 | header_->update(); |
1631 | viewport_->update(); | |
adb4b10c JH |
1632 | } |
1633 | ||
95a4b2a1 MM |
1634 | void View::on_grab_ruler(int ruler_id) |
1635 | { | |
3d6ff1cd SA |
1636 | if (!cursors_shown()) { |
1637 | center_cursors(); | |
1638 | show_cursors(); | |
95a4b2a1 | 1639 | } |
3d6ff1cd SA |
1640 | |
1641 | // Release the grabbed widget if its trigger hotkey was pressed twice | |
1642 | if (ruler_id == 1) | |
1643 | grabbed_widget_ = (grabbed_widget_ == cursors_->first().get()) ? | |
1644 | nullptr : cursors_->first().get(); | |
1645 | else | |
1646 | grabbed_widget_ = (grabbed_widget_ == cursors_->second().get()) ? | |
1647 | nullptr : cursors_->second().get(); | |
1648 | ||
1649 | if (grabbed_widget_) | |
1650 | grabbed_widget_->set_time(ruler_->get_absolute_time_from_x_pos( | |
1651 | mapFromGlobal(QCursor::pos()).x() - header_width())); | |
95a4b2a1 MM |
1652 | } |
1653 | ||
69dd2b03 JH |
1654 | void View::signals_changed() |
1655 | { | |
769a79b5 JH |
1656 | using sigrok::Channel; |
1657 | ||
925763b0 SA |
1658 | vector< shared_ptr<Channel> > channels; |
1659 | shared_ptr<sigrok::Device> sr_dev; | |
60c426a0 | 1660 | bool signals_added_or_removed = false; |
68b21a71 | 1661 | |
925763b0 SA |
1662 | // Do we need to set the vertical scrollbar to its default position later? |
1663 | // We do if there are no traces, i.e. the scroll bar has no range set | |
1664 | bool reset_scrollbar = | |
33094993 SA |
1665 | (scrollarea_->verticalScrollBar()->minimum() == |
1666 | scrollarea_->verticalScrollBar()->maximum()); | |
925763b0 SA |
1667 | |
1668 | if (!session_.device()) { | |
1669 | reset_scroll(); | |
47e9e7bb | 1670 | signals_.clear(); |
925763b0 | 1671 | } else { |
925763b0 | 1672 | sr_dev = session_.device()->device(); |
3b353d67 | 1673 | assert(sr_dev); |
925763b0 SA |
1674 | channels = sr_dev->channels(); |
1675 | } | |
e37e05f7 | 1676 | |
925763b0 | 1677 | vector< shared_ptr<TraceTreeItem> > new_top_level_items; |
769a79b5 | 1678 | |
cf124e47 JH |
1679 | // Make a list of traces that are being added, and a list of traces |
1680 | // that are being removed | |
364d2155 JH |
1681 | const vector<shared_ptr<Trace>> prev_trace_list = list_by_type<Trace>(); |
1682 | const set<shared_ptr<Trace>> prev_traces( | |
1683 | prev_trace_list.begin(), prev_trace_list.end()); | |
448a72cf | 1684 | |
47e9e7bb | 1685 | set< shared_ptr<Trace> > traces(signals_.begin(), signals_.end()); |
cf124e47 JH |
1686 | |
1687 | #ifdef ENABLE_DECODE | |
bb7dd726 | 1688 | traces.insert(decode_traces_.begin(), decode_traces_.end()); |
cf124e47 JH |
1689 | #endif |
1690 | ||
1691 | set< shared_ptr<Trace> > add_traces; | |
1692 | set_difference(traces.begin(), traces.end(), | |
1693 | prev_traces.begin(), prev_traces.end(), | |
1694 | inserter(add_traces, add_traces.begin())); | |
1695 | ||
1696 | set< shared_ptr<Trace> > remove_traces; | |
1697 | set_difference(prev_traces.begin(), prev_traces.end(), | |
1698 | traces.begin(), traces.end(), | |
1699 | inserter(remove_traces, remove_traces.begin())); | |
1700 | ||
1701 | // Make a look-up table of sigrok Channels to pulseview Signals | |
bf0edd2b | 1702 | unordered_map<shared_ptr<data::SignalBase>, shared_ptr<Signal> > |
cf124e47 | 1703 | signal_map; |
f4ab4b5c | 1704 | for (const shared_ptr<Signal>& sig : signals_) |
73a25a6e | 1705 | signal_map[sig->base()] = sig; |
448a72cf JH |
1706 | |
1707 | // Populate channel groups | |
925763b0 | 1708 | if (sr_dev) |
f4ab4b5c | 1709 | for (auto& entry : sr_dev->channel_groups()) { |
925763b0 SA |
1710 | const shared_ptr<sigrok::ChannelGroup> &group = entry.second; |
1711 | ||
1712 | if (group->channels().size() <= 1) | |
1713 | continue; | |
1714 | ||
1715 | // Find best trace group to add to | |
1716 | TraceTreeItemOwner *owner = find_prevalent_trace_group( | |
1717 | group, signal_map); | |
1718 | ||
1719 | // If there is no trace group, create one | |
1720 | shared_ptr<TraceGroup> new_trace_group; | |
1721 | if (!owner) { | |
1722 | new_trace_group.reset(new TraceGroup()); | |
1723 | owner = new_trace_group.get(); | |
1724 | } | |
1725 | ||
1726 | // Extract traces for the trace group, removing them from | |
1727 | // the add list | |
1728 | const vector< shared_ptr<Trace> > new_traces_in_group = | |
1729 | extract_new_traces_for_channels(group->channels(), | |
1730 | signal_map, add_traces); | |
1731 | ||
1732 | // Add the traces to the group | |
1733 | const pair<int, int> prev_v_extents = owner->v_extents(); | |
1734 | int offset = prev_v_extents.second - prev_v_extents.first; | |
f4ab4b5c | 1735 | for (const shared_ptr<Trace>& trace : new_traces_in_group) { |
925763b0 SA |
1736 | assert(trace); |
1737 | owner->add_child_item(trace); | |
1738 | ||
1739 | const pair<int, int> extents = trace->v_extents(); | |
1740 | if (trace->enabled()) | |
1741 | offset += -extents.first; | |
1742 | trace->force_to_v_offset(offset); | |
1743 | if (trace->enabled()) | |
1744 | offset += extents.second; | |
1745 | } | |
1746 | ||
7d556523 SA |
1747 | if (new_trace_group) { |
1748 | // Assign proper vertical offsets to each channel in the group | |
1749 | new_trace_group->restack_items(); | |
1750 | ||
1751 | // If this is a new group, enqueue it in the new top level | |
1752 | // items list | |
1753 | if (!new_traces_in_group.empty()) | |
1754 | new_top_level_items.push_back(new_trace_group); | |
1755 | } | |
cf124e47 | 1756 | } |
68b21a71 | 1757 | |
769a79b5 JH |
1758 | // Enqueue the remaining logic channels in a group |
1759 | vector< shared_ptr<Channel> > logic_channels; | |
1760 | copy_if(channels.begin(), channels.end(), back_inserter(logic_channels), | |
1761 | [](const shared_ptr<Channel>& c) { | |
1762 | return c->type() == sigrok::ChannelType::LOGIC; }); | |
d6128866 | 1763 | |
769a79b5 | 1764 | const vector< shared_ptr<Trace> > non_grouped_logic_signals = |
d6128866 SA |
1765 | extract_new_traces_for_channels(logic_channels, signal_map, add_traces); |
1766 | ||
1767 | if (non_grouped_logic_signals.size() > 0) { | |
1768 | const shared_ptr<TraceGroup> non_grouped_trace_group( | |
1769 | make_shared<TraceGroup>()); | |
f4ab4b5c | 1770 | for (const shared_ptr<Trace>& trace : non_grouped_logic_signals) |
d6128866 SA |
1771 | non_grouped_trace_group->add_child_item(trace); |
1772 | ||
1773 | non_grouped_trace_group->restack_items(); | |
1774 | new_top_level_items.push_back(non_grouped_trace_group); | |
1775 | } | |
769a79b5 | 1776 | |
cf124e47 JH |
1777 | // Enqueue the remaining channels as free ungrouped traces |
1778 | const vector< shared_ptr<Trace> > new_top_level_signals = | |
d6128866 | 1779 | extract_new_traces_for_channels(channels, signal_map, add_traces); |
cf124e47 JH |
1780 | new_top_level_items.insert(new_top_level_items.end(), |
1781 | new_top_level_signals.begin(), new_top_level_signals.end()); | |
1782 | ||
1783 | // Enqueue any remaining traces i.e. decode traces | |
1784 | new_top_level_items.insert(new_top_level_items.end(), | |
1785 | add_traces.begin(), add_traces.end()); | |
1786 | ||
1787 | // Remove any removed traces | |
f4ab4b5c | 1788 | for (const shared_ptr<Trace>& trace : remove_traces) { |
af503b10 | 1789 | TraceTreeItemOwner *const owner = trace->owner(); |
cf124e47 JH |
1790 | assert(owner); |
1791 | owner->remove_child_item(trace); | |
60c426a0 | 1792 | signals_added_or_removed = true; |
cf124e47 | 1793 | } |
448a72cf | 1794 | |
bc72e51f SA |
1795 | // Remove any empty trace groups |
1796 | for (shared_ptr<TraceGroup> group : list_by_type<TraceGroup>()) | |
e28c998e | 1797 | if (group->child_items().size() == 0) { |
bc72e51f | 1798 | remove_child_item(group); |
e28c998e SA |
1799 | group.reset(); |
1800 | } | |
bc72e51f | 1801 | |
cf124e47 | 1802 | // Add and position the pending top levels items |
6644424f | 1803 | int offset = v_extents().second; |
cf124e47 | 1804 | for (auto item : new_top_level_items) { |
8c09273b SA |
1805 | add_child_item(item); |
1806 | ||
d6128866 | 1807 | // Position the item after the last item or at the top if there is none |
8c09273b SA |
1808 | const pair<int, int> extents = item->v_extents(); |
1809 | ||
1810 | if (item->enabled()) | |
1811 | offset += -extents.first; | |
d6128866 | 1812 | |
d6128866 | 1813 | item->force_to_v_offset(offset); |
cf124e47 | 1814 | |
cf124e47 | 1815 | if (item->enabled()) |
8c09273b | 1816 | offset += extents.second; |
60c426a0 | 1817 | signals_added_or_removed = true; |
ef8311a4 JH |
1818 | } |
1819 | ||
76750c41 | 1820 | |
60c426a0 SA |
1821 | if (signals_added_or_removed && !header_was_shrunk_) |
1822 | resize_header_to_fit(); | |
76750c41 | 1823 | |
a6c1726e | 1824 | update_layout(); |
cf124e47 JH |
1825 | |
1826 | header_->update(); | |
1827 | viewport_->update(); | |
925763b0 SA |
1828 | |
1829 | if (reset_scrollbar) | |
1830 | set_scroll_default(); | |
69dd2b03 JH |
1831 | } |
1832 | ||
7ee199a7 | 1833 | void View::capture_state_updated(int state) |
adb4b10c | 1834 | { |
28ceff25 SA |
1835 | GlobalSettings settings; |
1836 | ||
92ff2b60 | 1837 | if (state == Session::Running) { |
4b0af0b6 | 1838 | set_time_unit(util::TimeUnit::Samples); |
fd03a279 | 1839 | |
92ff2b60 | 1840 | trigger_markers_.clear(); |
e887fe9e SA |
1841 | if (!custom_zero_offset_set_) |
1842 | set_zero_position(0); | |
90472a51 | 1843 | |
28ceff25 SA |
1844 | scale_at_acq_start_ = scale_; |
1845 | offset_at_acq_start_ = offset_; | |
1846 | ||
820ce18a SA |
1847 | // Activate "always zoom to fit" if the setting is enabled and we're |
1848 | // the main view of this session (other trace views may be used for | |
1849 | // zooming and we don't want to mess them up) | |
e91fb166 | 1850 | bool state = settings.value(GlobalSettings::Key_View_ZoomToFitDuringAcq).toBool(); |
820ce18a | 1851 | if (is_main_view_ && state) { |
90472a51 SA |
1852 | always_zoom_to_fit_ = true; |
1853 | always_zoom_to_fit_changed(always_zoom_to_fit_); | |
1854 | } | |
9b64f2df SA |
1855 | |
1856 | // Enable sticky scrolling if the setting is enabled | |
1857 | sticky_scrolling_ = settings.value(GlobalSettings::Key_View_StickyScrolling).toBool(); | |
558ad6ce SA |
1858 | |
1859 | // Reset all traces to segment 0 | |
1860 | current_segment_ = 0; | |
1861 | set_current_segment(current_segment_); | |
92ff2b60 TS |
1862 | } |
1863 | ||
fd03a279 SA |
1864 | if (state == Session::Stopped) { |
1865 | // After acquisition has stopped we need to re-calculate the ticks once | |
1866 | // as it's otherwise done when the user pans or zooms, which is too late | |
1867 | calculate_tick_spacing(); | |
1868 | ||
1869 | // Reset "always zoom to fit", the acquisition has stopped | |
1870 | if (always_zoom_to_fit_) { | |
3906e758 SA |
1871 | // Perform a final zoom-to-fit before disabling |
1872 | zoom_fit(always_zoom_to_fit_); | |
fd03a279 | 1873 | always_zoom_to_fit_ = false; |
90472a51 | 1874 | always_zoom_to_fit_changed(always_zoom_to_fit_); |
fd03a279 | 1875 | } |
28ceff25 SA |
1876 | |
1877 | bool zoom_to_fit_after_acq = | |
1878 | settings.value(GlobalSettings::Key_View_ZoomToFitAfterAcq).toBool(); | |
1879 | ||
1880 | // Only perform zoom-to-fit if the user hasn't altered the viewport and | |
1881 | // we didn't restore settings in the meanwhile | |
1882 | if (zoom_to_fit_after_acq && | |
1883 | !suppress_zoom_to_fit_after_acq_ && | |
1884 | (scale_ == scale_at_acq_start_) && | |
1885 | (offset_ == offset_at_acq_start_)) | |
1886 | zoom_fit(false); // We're stopped, so the GUI state doesn't matter | |
1887 | ||
1888 | suppress_zoom_to_fit_after_acq_ = false; | |
fd03a279 | 1889 | } |
7ee199a7 SA |
1890 | } |
1891 | ||
4e86ec70 SA |
1892 | void View::on_new_segment(int new_segment_id) |
1893 | { | |
1894 | on_segment_changed(new_segment_id); | |
1895 | } | |
1896 | ||
558ad6ce SA |
1897 | void View::on_segment_completed(int segment_id) |
1898 | { | |
1899 | on_segment_changed(segment_id); | |
558ad6ce SA |
1900 | } |
1901 | ||
526c8c00 SA |
1902 | void View::on_segment_changed(int segment) |
1903 | { | |
7daebd05 SA |
1904 | switch (segment_display_mode_) { |
1905 | case Trace::ShowLastSegmentOnly: | |
1906 | case Trace::ShowSingleSegmentOnly: | |
558ad6ce SA |
1907 | set_current_segment(segment); |
1908 | break; | |
1909 | ||
1910 | case Trace::ShowLastCompleteSegmentOnly: | |
89914a86 SA |
1911 | // Only update if all segments are complete |
1912 | if (session_.all_segments_complete(segment)) | |
1913 | set_current_segment(segment); | |
7daebd05 | 1914 | break; |
526c8c00 | 1915 | |
7daebd05 SA |
1916 | case Trace::ShowAllSegments: |
1917 | case Trace::ShowAccumulatedIntensity: | |
1918 | default: | |
1919 | break; | |
1920 | } | |
526c8c00 SA |
1921 | } |
1922 | ||
451dc5f3 SA |
1923 | void View::on_settingViewTriggerIsZeroTime_changed(const QVariant new_value) |
1924 | { | |
761f8302 SA |
1925 | (void)new_value; |
1926 | ||
e887fe9e | 1927 | if (!custom_zero_offset_set_) |
451dc5f3 SA |
1928 | reset_zero_position(); |
1929 | } | |
1930 | ||
c7b03d9d SA |
1931 | void View::perform_delayed_view_update() |
1932 | { | |
3906e758 | 1933 | if (always_zoom_to_fit_) { |
ce11b2ea | 1934 | zoom_fit(true); |
3906e758 | 1935 | } else if (sticky_scrolling_) { |
c7b03d9d | 1936 | // Make right side of the view sticky |
60d9b99a JS |
1937 | double length = 0; |
1938 | Timestamp offset; | |
c7b03d9d SA |
1939 | get_scroll_layout(length, offset); |
1940 | ||
1941 | const QSize areaSize = viewport_->size(); | |
1942 | length = max(length - areaSize.width(), 0.0); | |
1943 | ||
4b0af0b6 | 1944 | set_offset(scale_ * length); |
c7b03d9d | 1945 | } |
adb4b10c | 1946 | |
ef454ad5 | 1947 | determine_time_unit(); |
c7b03d9d SA |
1948 | update_scroll(); |
1949 | ruler_->update(); | |
8dbbc7f0 | 1950 | viewport_->update(); |
adb4b10c | 1951 | } |
cdf7bea7 | 1952 | |
32218d3e | 1953 | void View::process_sticky_events() |
d7c0ca4a | 1954 | { |
af503b10 | 1955 | if (sticky_events_ & TraceTreeItemHExtentsChanged) |
32218d3e | 1956 | update_layout(); |
af503b10 JH |
1957 | if (sticky_events_ & TraceTreeItemVExtentsChanged) { |
1958 | restack_all_trace_tree_items(); | |
f15bb3bc JH |
1959 | update_scroll(); |
1960 | } | |
32218d3e JH |
1961 | |
1962 | // Clear the sticky events | |
8dbbc7f0 | 1963 | sticky_events_ = 0; |
d7c0ca4a JH |
1964 | } |
1965 | ||
1573bf16 | 1966 | } // namespace trace |
f4e57597 | 1967 | } // namespace views |
cdf7bea7 | 1968 | } // namespace pv |