X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fpopups%2Fchannels.cpp;h=4a5e396c2e08e685d81205caa642608d3be73a13;hp=beacfb436d8eaf0166522e233ca822316277716c;hb=c063290ac7189bdd15221450f598504f43286b43;hpb=8dbbc7f0b9ea59d0f0d62225772f8a56eee125f5 diff --git a/pv/popups/channels.cpp b/pv/popups/channels.cpp index beacfb43..4a5e396c 100644 --- a/pv/popups/channels.cpp +++ b/pv/popups/channels.cpp @@ -14,46 +14,50 @@ * 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 "channels.h" +#include "channels.hpp" -#include -#include -#include +#include +#include +#include +#include +#include -#include +#include using namespace Qt; -using boost::shared_lock; -using boost::shared_mutex; -using std::lock_guard; 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 { -Channels::Channels(SigSession &session, QWidget *parent) : +Channels::Channels(Session &session, QWidget *parent) : Popup(parent), session_(session), updating_channels_(false), @@ -64,27 +68,26 @@ Channels::Channels(SigSession &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 +101,16 @@ Channels::Channels(SigSession &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 +136,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 +150,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())) && @@ -167,26 +168,23 @@ void Channels::populate_group(shared_ptr group, QString("

%1

").arg(group->name().c_str()))); // Create the channel group grid - QGridLayout *const channel_grid = - create_channel_group_grid(sigs); + QGridLayout *const channel_grid = create_channel_group_grid(sigs); layout_.addRow(channel_grid); // Create the channel group options - if (binding) - { + if (binding) { binding->add_properties_to_form(&layout_, true); group_bindings_.push_back(binding); } } 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 +196,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 +230,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()