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