]> sigrok.org Git - pulseview.git/blame - pv/views/trace/tracetreeitem.hpp
TabularDecView: Allow return/enter press and don't change scale
[pulseview.git] / pv / views / trace / 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
efdec55a 17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
af503b10
JH
18 */
19
8845be3c
UH
20#ifndef PULSEVIEW_PV_VIEWS_TRACE_TRACETREEITEM_HPP
21#define PULSEVIEW_PV_VIEWS_TRACE_TRACETREEITEM_HPP
af503b10
JH
22
23#include <memory>
24
25#include <QPropertyAnimation>
26
af33d4cb 27#include "viewitem.hpp"
af503b10 28
6f925ba9
UH
29using std::enable_shared_from_this;
30using std::pair;
31
af503b10 32namespace pv {
f4e57597 33namespace views {
1573bf16 34namespace trace {
af503b10
JH
35
36class TraceTreeItemOwner;
37
af33d4cb 38class TraceTreeItem : public ViewItem,
6f925ba9 39 public enable_shared_from_this<TraceTreeItem>
af503b10
JH
40{
41 Q_OBJECT
42 Q_PROPERTY(int visual_v_offset
43 READ visual_v_offset
44 WRITE set_visual_v_offset)
45
46public:
47 /**
48 * Constructor.
49 */
50 TraceTreeItem();
51
c373f828 52 /**
4ca23e7d 53 * Gets the owner of this item in the view item hierachy.
c373f828
JH
54 */
55 TraceTreeItemOwner* owner() const;
56
75663e3a
JH
57 /**
58 * Selects or deselects the signal.
59 */
60 void select(bool select = true);
61
af503b10
JH
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
af503b10
JH
93 /**
94 * Sets the owner this trace in the view trace hierachy.
95 * @param The new owner of the trace.
96 */
a653b83d 97 virtual void set_owner(TraceTreeItemOwner *owner);
af503b10
JH
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 */
a3d5a7c7 114 QPoint drag_point(const QRect &rect) const;
af503b10
JH
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 */
6f925ba9 120 virtual pair<int, int> v_extents() const = 0;
af503b10 121
af503b10 122protected:
c373f828 123 TraceTreeItemOwner *owner_;
af503b10
JH
124
125 int layout_v_offset_;
126 int visual_v_offset_;
127
128private:
129 QPropertyAnimation v_offset_animation_;
130};
131
1573bf16 132} // namespace trace
f4e57597 133} // namespace views
af503b10
JH
134} // namespace pv
135
8845be3c 136#endif // PULSEVIEW_PV_VIEWS_TRACE_TRACETREEITEM_HPP