X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fpopups%2Fchannels.cpp;h=9c200b9db31eb5d1c6a3e35cafcc85b1ec2cdbbf;hp=7dedb317cf8428043ca9d3701744e04aae71a86b;hb=067bb62415847791709f4c3cad8bb252a63f45f8;hpb=fe3a1c218407f6b8a0d7ac7c454593809212ea9e diff --git a/pv/popups/channels.cpp b/pv/popups/channels.cpp index 7dedb317..9c200b9d 100644 --- a/pv/popups/channels.cpp +++ b/pv/popups/channels.cpp @@ -14,12 +14,19 @@ * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * along with this program; if not, see . */ #include +#ifdef _WIN32 +// Windows: Avoid boost/thread namespace pollution (which includes windows.h). +#define NOGDI +#define NORESOURCE +#endif +#include +#include + #include #include #include @@ -27,7 +34,9 @@ #include "channels.hpp" -#include +#include +#include +#include #include #include @@ -42,14 +51,16 @@ using std::map; using std::mutex; using std::set; using std::shared_ptr; +using std::make_shared; +using std::unordered_set; using std::vector; +using pv::data::SignalBase; + using sigrok::Channel; using sigrok::ChannelGroup; using sigrok::Device; -using pv::view::Signal; - namespace pv { namespace popups { @@ -64,27 +75,26 @@ Channels::Channels(Session &session, QWidget *parent) : // Create the layout setLayout(&layout_); - shared_ptr device = session_.device(); + const shared_ptr device = session_.device()->device(); assert(device); // Collect a set of signals - map, shared_ptr > signal_map; + map, shared_ptr > signal_map; - shared_lock lock(session_.signals_mutex()); - const vector< shared_ptr > &sigs(session_.signals()); + unordered_set< shared_ptr > sigs; + for (const shared_ptr b : session_.signalbases()) + sigs.insert(b); - for (const shared_ptr &sig : sigs) + for (const shared_ptr &sig : sigs) signal_map[sig->channel()] = sig; // Populate channel groups - for (auto entry : device->channel_groups()) - { + for (auto entry : device->channel_groups()) { shared_ptr group = entry.second; // Make a set of signals, and removed this signals from the // signal map. - vector< shared_ptr > group_sigs; - for (auto channel : group->channels()) - { + vector< shared_ptr > group_sigs; + for (auto channel : group->channels()) { const auto iter = signal_map.find(channel); if (iter == signal_map.end()) @@ -98,17 +108,16 @@ Channels::Channels(Session &session, QWidget *parent) : } // Make a vector of the remaining channels - vector< shared_ptr > global_sigs; - for (auto channel : device->channels()) - { - const map, shared_ptr >:: + vector< shared_ptr > global_sigs; + for (auto channel : device->channels()) { + const map, shared_ptr >:: const_iterator iter = signal_map.find(channel); if (iter != signal_map.end()) global_sigs.push_back((*iter).second); } // Create a group - populate_group(NULL, global_sigs); + populate_group(nullptr, global_sigs); // Create the enable/disable all buttons connect(&enable_all_channels_, SIGNAL(clicked()), @@ -134,14 +143,13 @@ void Channels::set_all_channels(bool set) { updating_channels_ = true; - for (map >::const_iterator i = - check_box_signal_map_.begin(); - i != check_box_signal_map_.end(); i++) - { - const shared_ptr sig = (*i).second; + for (map >::const_iterator i = + check_box_signal_map_.begin(); + i != check_box_signal_map_.end(); i++) { + const shared_ptr sig = (*i).second; assert(sig); - sig->enable(set); + sig->set_enabled(set); (*i).first->setChecked(set); } @@ -149,16 +157,16 @@ void Channels::set_all_channels(bool set) } void Channels::populate_group(shared_ptr group, - const vector< shared_ptr > sigs) + const vector< shared_ptr > sigs) { - using pv::prop::binding::DeviceOptions; + using pv::binding::Device; // Only bind options if this is a group. We don't do it for general // options, because these properties are shown in the device config // popup. - shared_ptr binding; + shared_ptr binding; if (group) - binding = shared_ptr(new DeviceOptions(group)); + binding = make_shared(group); // Create a title if the group is going to have any content if ((!sigs.empty() || (binding && !binding->properties().empty())) && @@ -180,13 +188,12 @@ void Channels::populate_group(shared_ptr group, } QGridLayout* Channels::create_channel_group_grid( - const vector< shared_ptr > sigs) + const vector< shared_ptr > sigs) { int row = 0, col = 0; QGridLayout *const grid = new QGridLayout(); - for (const shared_ptr& sig : sigs) - { + for (const shared_ptr& sig : sigs) { assert(sig); QCheckBox *const checkbox = new QCheckBox(sig->name()); @@ -198,24 +205,23 @@ QGridLayout* Channels::create_channel_group_grid( check_box_signal_map_[checkbox] = sig; - if(++col >= 8) + if (++col >= 8) col = 0, row++; } return grid; } -void Channels::showEvent(QShowEvent *e) +void Channels::showEvent(QShowEvent *event) { - pv::widgets::Popup::showEvent(e); + pv::widgets::Popup::showEvent(event); updating_channels_ = true; - for (map >::const_iterator i = - check_box_signal_map_.begin(); - i != check_box_signal_map_.end(); i++) - { - const shared_ptr sig = (*i).second; + for (map >::const_iterator i = + check_box_signal_map_.begin(); + i != check_box_signal_map_.end(); i++) { + const shared_ptr sig = (*i).second; assert(sig); (*i).first->setChecked(sig->enabled()); @@ -233,14 +239,14 @@ void Channels::on_channel_checked(QWidget *widget) assert(check_box); // Look up the signal of this check-box - map< QCheckBox*, shared_ptr >::const_iterator iter = + map< QCheckBox*, shared_ptr >::const_iterator iter = check_box_signal_map_.find((QCheckBox*)check_box); assert(iter != check_box_signal_map_.end()); - const shared_ptr s = (*iter).second; + const shared_ptr s = (*iter).second; assert(s); - s->enable(check_box->isChecked()); + s->set_enabled(check_box->isChecked()); } void Channels::enable_all_channels()