]> sigrok.org Git - pulseview.git/blob - pv/view/tracegroup.h
TraceGroup: Added ungroup item
[pulseview.git] / pv / view / tracegroup.h
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_TRACEGROUP_H
22 #define PULSEVIEW_PV_VIEW_TRACEGROUP_H
23
24 #include "rowitem.h"
25 #include "rowitemowner.h"
26
27 namespace pv {
28 namespace view {
29
30 class TraceGroup : public RowItem, public RowItemOwner
31 {
32         Q_OBJECT
33
34 private:
35         static const int Padding;
36         static const int Width;
37
38 public:
39         /**
40          * Virtual destructor
41          */
42         virtual ~TraceGroup();
43
44         /**
45          * Returns true if the item is visible and enabled.
46          */
47         bool enabled() const;
48
49         /**
50          * Returns the session of the onwer.
51          */
52         pv::SigSession& session();
53
54         /**
55          * Returns the session of the onwer.
56          */
57         const pv::SigSession& session() const;
58
59         /**
60          * Returns the view of the owner.
61          */
62         virtual pv::view::View* view();
63
64         /**
65          * Returns the view of the owner.
66          */
67         virtual const pv::view::View* view() const;
68
69         /**
70          * Computes the vertical extents of the contents of this row item.
71          * @return A pair containing the minimum and maximum y-values.
72          */
73         std::pair<int, int> v_extents() const;
74
75         /**
76          * Paints the signal label.
77          * @param p the QPainter to paint into.
78          * @param right the x-coordinate of the right edge of the header
79          *      area.
80          * @param hover true if the label is being hovered over by the mouse.
81          */
82         void paint_label(QPainter &p, int right, bool hover);
83
84         /**
85          * Computes the outline rectangle of a label.
86          * @param right the x-coordinate of the right edge of the header
87          *      area.
88          * @return Returns the rectangle of the signal label.
89          */
90         QRectF label_rect(int right) const;
91
92         /**
93          * Determines if a point is in the header label rect.
94          * @param left the x-coordinate of the left edge of the header
95          *      area.
96          * @param right the x-coordinate of the right edge of the header
97          *      area.
98          * @param point the point to test.
99          */
100         bool pt_in_label_rect(int left, int right, const QPoint &point);
101
102         QMenu* create_context_menu(QWidget *parent);
103
104         pv::widgets::Popup* create_popup(QWidget *parent);
105
106         /**
107          * Returns the total vertical offset of this trace and all it's owners
108          */
109         int owner_v_offset() const;
110
111         void update_viewport();
112
113 private Q_SLOTS:
114         void on_ungroup();
115 };
116
117 } // view
118 } // pv
119
120 #endif // PULSEVIEW_PV_VIEW_TRACEGROUP_H