]> sigrok.org Git - pulseview.git/blob - pv/view/tracegroup.h
0d246cee3c05471c88dbe4f99425eafcea395230
[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 public:
35         /**
36          * Virtual destructor
37          */
38         virtual ~TraceGroup();
39
40         /**
41          * Returns true if the item is visible and enabled.
42          */
43         bool enabled() const;
44
45         /**
46          * Returns the session of the onwer.
47          */
48         pv::SigSession& session();
49
50         /**
51          * Returns the session of the onwer.
52          */
53         const pv::SigSession& session() const;
54
55         /**
56          * Returns the view of the owner.
57          */
58         virtual pv::view::View* view();
59
60         /**
61          * Returns the view of the owner.
62          */
63         virtual const pv::view::View* view() const;
64
65         /**
66          * Paints the signal label.
67          * @param p the QPainter to paint into.
68          * @param right the x-coordinate of the right edge of the header
69          *      area.
70          * @param hover true if the label is being hovered over by the mouse.
71          */
72         void paint_label(QPainter &p, int right, bool hover);
73
74         /**
75          * Computes the outline rectangle of a label.
76          * @param right the x-coordinate of the right edge of the header
77          *      area.
78          * @return Returns the rectangle of the signal label.
79          */
80         QRectF label_rect(int right) const;
81
82         /**
83          * Determines if a point is in the header label rect.
84          * @param left the x-coordinate of the left edge of the header
85          *      area.
86          * @param right the x-coordinate of the right edge of the header
87          *      area.
88          * @param point the point to test.
89          */
90         bool pt_in_label_rect(int left, int right, const QPoint &point);
91
92         QMenu* create_context_menu(QWidget *parent);
93
94         pv::widgets::Popup* create_popup(QWidget *parent);
95
96         /**
97          * Returns the total vertical offset of this trace and all it's owners
98          */
99         int owner_v_offset() const;
100
101         void update_viewport();
102 };
103
104 } // view
105 } // pv
106
107 #endif // PULSEVIEW_PV_VIEW_TRACEGROUP_H