]> sigrok.org Git - pulseview.git/blame - pv/view/tracegroup.cpp
RowItem: Replaced fixed signal heights with extents
[pulseview.git] / pv / view / tracegroup.cpp
CommitLineData
722930c1
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#include <assert.h>
22
23#include <algorithm>
24
25#include "tracegroup.h"
26
a5d93c27 27using std::pair;
722930c1
JH
28using std::shared_ptr;
29
30namespace pv {
31namespace view {
32
b781f806
JH
33const int TraceGroup::Padding = 8;
34const int TraceGroup::Width = 12;
35
722930c1
JH
36TraceGroup::~TraceGroup()
37{
38 _owner = nullptr;
39 clear_child_items();
40}
41
42bool TraceGroup::enabled() const
43{
44 return std::any_of(child_items().begin(), child_items().end(),
45 [](const shared_ptr<RowItem> &r) { return r->enabled(); });
46}
47
48pv::SigSession& TraceGroup::session()
49{
50 assert(_owner);
51 return _owner->session();
52}
53
54const pv::SigSession& TraceGroup::session() const
55{
56 assert(_owner);
57 return _owner->session();
58}
59
60pv::view::View* TraceGroup::view()
61{
62 assert(_owner);
63 return _owner->view();
64}
65
66const pv::view::View* TraceGroup::view() const
67{
68 assert(_owner);
69 return _owner->view();
70}
71
a5d93c27
JH
72pair<int, int> TraceGroup::v_extents() const
73{
74 return RowItemOwner::v_extents();
75}
76
722930c1
JH
77void TraceGroup::paint_label(QPainter &p, int right, bool hover)
78{
79 (void)p;
80 (void)right;
81 (void)hover;
82}
83
0067d804 84QRectF TraceGroup::label_rect(int right) const
722930c1 85{
b781f806
JH
86 QRectF rect;
87 for (const shared_ptr<RowItem> r : child_items())
88 if (r)
89 rect = rect.united(r->label_rect(right));
90
91 return QRectF(rect.x() - Width - Padding, rect.y(),
92 Width, rect.height());
722930c1
JH
93}
94
95bool TraceGroup::pt_in_label_rect(int left, int right, const QPoint &point)
96{
97 (void)left;
98 (void)right;
99 (void)point;
100
101 return false;
102}
103
104QMenu* TraceGroup::create_context_menu(QWidget *parent)
105{
106 (void)parent;
107
108 return NULL;
109}
110
111pv::widgets::Popup* TraceGroup::create_popup(QWidget *parent)
112{
113 (void)parent;
114 return NULL;
115}
116
117int TraceGroup::owner_v_offset() const
118{
119 return v_offset() + _owner->owner_v_offset();
120}
121
122void TraceGroup::update_viewport()
123{
124 if (_owner)
125 _owner->update_viewport();
126}
127
128} // namespace view
129} // namespace pv