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