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