]> sigrok.org Git - pulseview.git/blob - pv/toolbars/samplingbar.h
e59d2f9f0b195da8417c126de2ea6f4ec7f53539
[pulseview.git] / pv / toolbars / samplingbar.h
1 /*
2  * This file is part of the PulseView project.
3  *
4  * Copyright (C) 2012 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_TOOLBARS_SAMPLINGBAR_H
22 #define PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H
23
24 #include <stdint.h>
25
26 #include <list>
27 #include <map>
28
29 #include <boost/shared_ptr.hpp>
30
31 #include <QComboBox>
32 #include <QDoubleSpinBox>
33 #include <QToolBar>
34 #include <QToolButton>
35
36 #include <pv/sigsession.h>
37 #include <pv/widgets/popuptoolbutton.h>
38 #include <pv/widgets/sweeptimingwidget.h>
39
40 class QAction;
41
42 namespace pv {
43
44 class SigSession;
45
46 namespace device {
47 class DevInst;
48 }
49
50 namespace toolbars {
51
52 class SamplingBar : public QToolBar
53 {
54         Q_OBJECT
55
56 private:
57         static const uint64_t MinSampleCount;
58         static const uint64_t MaxSampleCount;
59         static const uint64_t DefaultSampleCount;
60
61 public:
62         SamplingBar(SigSession &session, QWidget *parent);
63
64         void set_device_list(
65                 const std::list< boost::shared_ptr<pv::device::DevInst> >
66                         &devices,
67                 boost::shared_ptr<pv::device::DevInst> selected);
68
69         boost::shared_ptr<pv::device::DevInst> get_selected_device() const;
70
71         void set_capture_state(pv::SigSession::capture_state state);
72
73 signals:
74         void run_stop();
75
76 private:
77         void update_sample_rate_selector();
78         void update_sample_rate_selector_value();
79         void update_sample_count_selector();
80         void update_device_config_widgets();
81         void commit_sample_rate();
82         void commit_sample_count();
83
84 private slots:
85         void on_device_selected();
86         void on_sample_count_changed();
87         void on_sample_rate_changed();
88         void on_run_stop();
89
90         void on_config_changed();
91
92 private:
93         SigSession &_session;
94
95         QComboBox _device_selector;
96         std::map<const sr_dev_inst*, boost::weak_ptr<device::DevInst> >
97                 _device_selector_map;
98         bool _updating_device_selector;
99
100         pv::widgets::PopupToolButton _configure_button;
101         QAction *_configure_button_action;
102
103         pv::widgets::PopupToolButton _probes_button;
104
105         pv::widgets::SweepTimingWidget _sample_count;
106         pv::widgets::SweepTimingWidget _sample_rate;
107         bool _updating_sample_rate;
108         bool _updating_sample_count;
109
110         bool _sample_count_supported;
111
112         QIcon _icon_red;
113         QIcon _icon_green;
114         QIcon _icon_grey;
115         QToolButton _run_stop_button;
116 };
117
118 } // namespace toolbars
119 } // namespace pv
120
121 #endif // PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H