PulseView  unreleased development snapshot
A Qt-based sigrok GUI
tracetreeitem.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of the PulseView project.
3  *
4  * Copyright (C) 2013 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 #include <cassert>
21 
22 #include "view.hpp"
23 
24 #include "tracetreeitem.hpp"
25 
26 namespace pv {
27 namespace views {
28 namespace trace {
29 
31  owner_(nullptr),
32  layout_v_offset_(0),
33  visual_v_offset_(0),
34  v_offset_animation_(this, "visual_v_offset")
35 {
36 }
37 
39 {
40  ViewItem::select(select);
42 }
43 
45 {
46  return layout_v_offset_;
47 }
48 
50 {
51  if (layout_v_offset_ == v_offset)
52  return;
53 
54  layout_v_offset_ = v_offset;
55 
56  if (owner_)
57  owner_->extents_changed(false, true);
58 }
59 
61 {
62  return visual_v_offset_;
63 }
64 
66 {
67  visual_v_offset_ = v_offset;
68 
69  if (owner_)
71 }
72 
74 {
75  v_offset_animation_.stop();
77 
78  if (owner_) {
80  owner_->extents_changed(false, true);
81  }
82 }
83 
85 {
87  (v_offset_animation_.endValue() == layout_v_offset_ &&
88  v_offset_animation_.state() == QAbstractAnimation::Running))
89  return;
90 
91  v_offset_animation_.setDuration(100);
94  v_offset_animation_.setEasingCurve(QEasingCurve::OutQuad);
95  v_offset_animation_.start();
96 }
97 
99 {
100  return owner_;
101 }
102 
104 {
105  assert(owner_ || owner);
106  v_offset_animation_.stop();
107 
108  if (owner_) {
109  const int owner_offset = owner_->owner_visual_v_offset();
110  layout_v_offset_ += owner_offset;
111  visual_v_offset_ += owner_offset;
112  }
113 
114  owner_ = owner;
115 
116  if (owner_) {
117  const int owner_offset = owner_->owner_visual_v_offset();
118  layout_v_offset_ -= owner_offset;
119  visual_v_offset_ -= owner_offset;
120  }
121 }
122 
124 {
125  assert(owner_);
127 }
128 
129 void TraceTreeItem::drag_by(const QPoint &delta)
130 {
131  assert(owner_);
132  force_to_v_offset(drag_point_.y() + delta.y() -
134 }
135 
136 QPoint TraceTreeItem::drag_point(const QRect &rect) const
137 {
138  return QPoint(rect.right(), get_visual_y());
139 }
140 
141 } // namespace trace
142 } // namespace views
143 } // namespace pv
void select(bool select=true)
virtual void set_owner(TraceTreeItemOwner *owner)
virtual void extents_changed(bool horz, bool vert)=0
void set_layout_v_offset(int v_offset)
virtual int owner_visual_v_offset() const =0
void set_visual_v_offset(int v_offset)
void drag_by(const QPoint &delta)
TraceTreeItemOwner * owner() const
QPoint drag_point(const QRect &rect) const
it will come up with a session that has the demo device selected That you can get to know the program even when you don t have any hardware to use it you see a list of devices PulseView has recognized If the device you want to use is you can just select it here image::device_selector_dropdown png[] If it s not you ll need to scan for it first Since most serial port and Ethernet devices can t be auto this is usually required for those To do either choose the Connect to Device option from the list or click on the button itself You will see the following you ll need to pick a driver that you want to use In order to do this
Definition: acquisition.txt:14
void force_to_v_offset(int v_offset)
virtual void select(bool select=true)
Definition: viewitem.cpp:53
virtual void row_item_appearance_changed(bool label, bool content)=0
QPropertyAnimation v_offset_animation_