]> sigrok.org Git - pulseview.git/blob - pv/toolbars/samplingbar.h
Wrapped sr_dev_inst in a class: pv::DevInst
[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 DevInst;
45 class SigSession;
46
47 namespace toolbars {
48
49 class SamplingBar : public QToolBar
50 {
51         Q_OBJECT
52
53 private:
54         static const uint64_t MinSampleCount;
55         static const uint64_t MaxSampleCount;
56         static const uint64_t DefaultSampleCount;
57
58 public:
59         SamplingBar(SigSession &session, QWidget *parent);
60
61         void set_device_list(
62                 const std::list< boost::shared_ptr<pv::DevInst> > &devices);
63
64         boost::shared_ptr<pv::DevInst> get_selected_device() const;
65         void set_selected_device(boost::shared_ptr<pv::DevInst> dev_inst);
66
67         void set_capture_state(pv::SigSession::capture_state state);
68
69 signals:
70         void run_stop();
71
72 private:
73         void update_sample_rate_selector();
74         void update_sample_rate_selector_value();
75         void update_sample_count_selector();
76         void commit_sample_rate();
77         void commit_sample_count();
78
79 private slots:
80         void on_device_selected();
81         void on_sample_count_changed();
82         void on_sample_rate_changed();
83         void on_run_stop();
84
85 private:
86         SigSession &_session;
87
88         QComboBox _device_selector;
89         std::map<const sr_dev_inst*, boost::weak_ptr<DevInst> >
90                 _device_selector_map;
91         bool _updating_device_selector;
92
93         pv::widgets::PopupToolButton _configure_button;
94         QAction *_configure_button_action;
95
96         pv::widgets::PopupToolButton _probes_button;
97
98         pv::widgets::SweepTimingWidget _sample_count;
99         pv::widgets::SweepTimingWidget _sample_rate;
100         bool _updating_sample_rate;
101         bool _updating_sample_count;
102
103         bool _sample_count_supported;
104
105         QIcon _icon_red;
106         QIcon _icon_green;
107         QIcon _icon_grey;
108         QToolButton _run_stop_button;
109 };
110
111 } // namespace toolbars
112 } // namespace pv
113
114 #endif // PULSEVIEW_PV_TOOLBARS_SAMPLINGBAR_H