]> sigrok.org Git - pulseview.git/blob - pv/views/trace/tracetreeitem.hpp
Rename ViewItem::point() to ViewItem::drag_point() for clarity
[pulseview.git] / pv / views / trace / tracetreeitem.hpp
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 #ifndef PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACETREEITEM_HPP
21 #define PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACETREEITEM_HPP
22
23 #include <memory>
24
25 #include <QPropertyAnimation>
26
27 #include "rowitem.hpp"
28
29 using std::enable_shared_from_this;
30 using std::pair;
31
32 namespace pv {
33 namespace views {
34 namespace trace {
35
36 class TraceTreeItemOwner;
37
38 class TraceTreeItem : public RowItem,
39         public enable_shared_from_this<TraceTreeItem>
40 {
41         Q_OBJECT
42         Q_PROPERTY(int visual_v_offset
43                 READ visual_v_offset
44                 WRITE set_visual_v_offset)
45
46 public:
47         /**
48          * Constructor.
49          */
50         TraceTreeItem();
51
52         /**
53          * Gets the owner of this item in the view item hierachy.
54          */
55         TraceTreeItemOwner* owner() const;
56
57         /**
58          * Selects or deselects the signal.
59          */
60         void select(bool select = true);
61
62         /**
63          * Gets the vertical layout offset of this signal.
64          */
65         int layout_v_offset() const;
66
67         /**
68          * Sets the vertical layout offset of this signal.
69          */
70         void set_layout_v_offset(int v_offset);
71
72         /**
73          * Gets the vertical visual offset of this signal.
74          */
75         int visual_v_offset() const;
76
77         /**
78          * Sets the vertical visual offset of this signal.
79          */
80         void set_visual_v_offset(int v_offset);
81
82         /**
83          * Sets the visual and layout offset of this signal.
84          */
85         void force_to_v_offset(int v_offset);
86
87         /**
88          * Begins an animation that will animate the visual offset toward
89          * the layout offset.
90          */
91         void animate_to_layout_v_offset();
92
93         /**
94          * Sets the owner this trace in the view trace hierachy.
95          * @param The new owner of the trace.
96          */
97         void set_owner(TraceTreeItemOwner *owner);
98
99         /**
100          * Gets the visual y-offset of the axis.
101          */
102         int get_visual_y() const;
103
104         /**
105          * Drags the item to a delta relative to the drag point.
106          * @param delta the offset from the drag point.
107          */
108         void drag_by(const QPoint &delta);
109
110         /**
111          * Gets the arrow-tip point of the row item marker.
112          * @param rect the rectangle of the header area.
113          */
114         QPoint drag_point(const QRect &rect) const;
115
116         /**
117          * Computes the vertical extents of the contents of this row item.
118          * @return A pair containing the minimum and maximum y-values.
119          */
120         virtual pair<int, int> v_extents() const = 0;
121
122 protected:
123         TraceTreeItemOwner *owner_;
124
125         int layout_v_offset_;
126         int visual_v_offset_;
127
128 private:
129         QPropertyAnimation v_offset_animation_;
130 };
131
132 } // namespace trace
133 } // namespace views
134 } // namespace pv
135
136 #endif // PULSEVIEW_PV_VIEWS_TRACEVIEW_TRACETREEITEM_HPP