addToolBar(_toolbar);
// Setup the sampling bar
- _sampling_bar = new toolbars::SamplingBar(this);
+ _sampling_bar = new toolbars::SamplingBar(_session, this);
// Populate the device list and select the initially selected device
update_device_list();
- connect(_sampling_bar, SIGNAL(device_selected()), this,
- SLOT(device_selected()));
connect(_sampling_bar, SIGNAL(run_stop()), this,
SLOT(run_stop()));
addToolBar(_sampling_bar);
dlg.exec();
}
-void MainWindow::device_selected()
-{
- _session.set_device(_sampling_bar->get_selected_device());
-}
-
void MainWindow::add_decoder(QObject *action)
{
assert(action);
void on_actionAbout_triggered();
- void device_selected();
-
void add_decoder(QObject *action);
void run_stop();
#include "probes.h"
+#include <pv/sigsession.h>
+#include <pv/view/signal.h>
+
+using namespace boost;
using namespace Qt;
+using namespace std;
namespace pv {
namespace popups {
-Probes::Probes(sr_dev_inst *sdi, QWidget *parent) :
+Probes::Probes(SigSession &session, QWidget *parent) :
Popup(parent),
- _sdi(sdi),
+ _session(session),
_layout(this),
_probes(this),
_probes_bar(this),
_enable_all_probes(this),
_disable_all_probes(this)
{
- assert(_sdi);
-
setLayout(&_layout);
connect(&_enable_all_probes, SIGNAL(clicked()),
_layout.addWidget(&_probes_bar);
- for (const GSList *l = _sdi->probes; l; l = l->next) {
- sr_probe *const probe = (sr_probe*)l->data;
- assert(probe);
+ const vector< shared_ptr<pv::view::Signal> > sigs =
+ _session.get_signals();
+ for (unsigned int i = 0; i < sigs.size(); i++)
+ {
+ const shared_ptr<pv::view::Signal> &s = sigs[i];
+ assert(s);
QListWidgetItem *const item = new QListWidgetItem(
- probe->name, &_probes);
+ s->get_name(), &_probes);
assert(item);
- item->setData(UserRole,
- qVariantFromValue((void*)probe));
- item->setCheckState(probe->enabled ?
- Checked : Unchecked);
+ item->setData(UserRole, qVariantFromValue(i));
+ item->setCheckState(s->enabled() ? Checked : Unchecked);
_probes.addItem(item);
}
void Probes::set_all_probes(bool set)
{
- for (int i = 0; i < _probes.count(); i++) {
+ using pv::view::Signal;
+
+ const vector< shared_ptr<pv::view::Signal> > sigs =
+ _session.get_signals();
+ for (unsigned int i = 0; i < sigs.size(); i++)
+ {
+ const shared_ptr<pv::view::Signal> &s = sigs[i];
+ assert(s);
+ s->enable(set);
+
QListWidgetItem *const item = _probes.item(i);
assert(item);
item->setCheckState(set ? Qt::Checked : Qt::Unchecked);
-
- sr_probe *const probe = (sr_probe*)
- item->data(UserRole).value<void*>();
- assert(probe);
- probe->enabled = item->checkState() == Checked;
}
}
void Probes::item_changed(QListWidgetItem *item)
{
+ using pv::view::Signal;
+
assert(item);
- sr_probe *const probe = (sr_probe*)
- item->data(UserRole).value<void*>();
- assert(probe);
- probe->enabled = item->checkState() == Checked;
+ const vector< shared_ptr<pv::view::Signal> > sigs =
+ _session.get_signals();
+ const shared_ptr<pv::view::Signal> s = sigs[
+ item->data(UserRole).value<unsigned int>()];
+ assert(s);
+ s->enable(item->checkState() == Checked);
}
void Probes::enable_all_probes()
#include <pv/widgets/popup.h>
namespace pv {
+
+class SigSession;
+
namespace popups {
class Probes : public pv::widgets::Popup
Q_OBJECT
public:
- Probes(sr_dev_inst *sdi, QWidget *parent);
+ Probes(SigSession &_session, QWidget *parent);
private:
void set_all_probes(bool set);
void disable_all_probes();
private:
- sr_dev_inst *_sdi;
+ pv::SigSession &_session;
QVBoxLayout _layout;
if(sdi) {
for (const GSList *l = sdi->probes; l; l = l->next) {
- const sr_probe *const probe =
- (const sr_probe *)l->data;
+ sr_probe *const probe = (sr_probe *)l->data;
assert(probe);
switch(probe->type) {
const uint64_t SamplingBar::DefaultRecordLength = 1000000;
-SamplingBar::SamplingBar(QWidget *parent) :
+SamplingBar::SamplingBar(SigSession &session, QWidget *parent) :
QToolBar("Sampling Bar", parent),
+ _session(session),
_device_selector(this),
_configure_button(this),
_probes_button(this),
update_sample_rate_selector();
sr_dev_inst *const sdi = get_selected_device();
+ _session.set_device(sdi);
_configure_button.set_popup(new DeviceOptions(sdi, this));
- _probes_button.set_popup(new Probes(sdi, this));
-
- device_selected();
+ _probes_button.set_popup(new Probes(_session, this));
}
void SamplingBar::on_sample_rate_changed()
class QAction;
namespace pv {
+
+class SigSession;
+
namespace toolbars {
class SamplingBar : public QToolBar
static const uint64_t DefaultRecordLength;
public:
- SamplingBar(QWidget *parent);
+ SamplingBar(SigSession &session, QWidget *parent);
void set_device_list(const std::list<struct sr_dev_inst*> &devices);
void set_capture_state(pv::SigSession::capture_state state);
signals:
- void device_selected();
-
void run_stop();
private:
void on_run_stop();
private:
+ SigSession &_session;
+
QComboBox _device_selector;
pv::widgets::PopupToolButton _configure_button;
const float AnalogSignal::EnvelopeThreshold = 256.0f;
-AnalogSignal::AnalogSignal(pv::SigSession &session, const sr_probe *const probe,
+AnalogSignal::AnalogSignal(pv::SigSession &session, sr_probe *const probe,
shared_ptr<data::Analog> data) :
Signal(session, probe),
_data(data),
static const float EnvelopeThreshold;
public:
- AnalogSignal(pv::SigSession &session, const sr_probe *const probe,
+ AnalogSignal(pv::SigSession &session, sr_probe *const probe,
boost::shared_ptr<pv::data::Analog> data);
virtual ~AnalogSignal();
const vector< shared_ptr<Trace> > traces(_view.get_traces());
BOOST_FOREACH(shared_ptr<Trace> t, traces) {
assert(t);
+ connect(t.get(), SIGNAL(visibility_changed()),
+ this, SLOT(update()));
connect(t.get(), SIGNAL(text_changed()),
this, SLOT(update()));
connect(t.get(), SIGNAL(colour_changed()),
QColor(0xEE, 0xEE, 0xEC), // White
};
-LogicSignal::LogicSignal(pv::SigSession &session, const sr_probe *const probe,
+LogicSignal::LogicSignal(pv::SigSession &session, sr_probe *const probe,
shared_ptr<data::Logic> data) :
Signal(session, probe),
_data(data),
static const QColor SignalColours[10];
public:
- LogicSignal(pv::SigSession &session, const sr_probe *const probe,
+ LogicSignal(pv::SigSession &session, sr_probe *const probe,
boost::shared_ptr<pv::data::Logic> data);
virtual ~LogicSignal();
"SCL"
};
-Signal::Signal(pv::SigSession &session, const sr_probe *const probe) :
+Signal::Signal(pv::SigSession &session, sr_probe *const probe) :
Trace(session, probe->name),
_probe(probe),
_name_widget(NULL),
return _probe->enabled;
}
+void Signal::enable(bool enable)
+{
+ _probe->enabled = enable;
+ visibility_changed();
+}
+
const sr_probe* Signal::probe() const
{
return _probe;
Q_OBJECT
protected:
- Signal(pv::SigSession &session, const sr_probe *const probe);
+ Signal(pv::SigSession &session, sr_probe *const probe);
public:
/**
*/
bool enabled() const;
+ void enable(bool enable = true);
+
const sr_probe* probe() const;
virtual void populate_popup_form(QWidget *parent, QFormLayout *form);
protected:
- const sr_probe *const _probe;
+ sr_probe *const _probe;
QComboBox *_name_widget;
bool _updating_name_widget;
void on_colour_changed(const QColor &colour);
signals:
+ void visibility_changed();
void text_changed();
void colour_changed();
setAutoFillBackground(true);
setBackgroundRole(QPalette::Base);
+ connect(&_view.session(), SIGNAL(signals_changed()),
+ this, SLOT(on_signals_changed()));
+
connect(&_view, SIGNAL(signals_moved()),
this, SLOT(on_signals_moved()));
}
}
}
+void Viewport::on_signals_changed()
+{
+ const vector< shared_ptr<Trace> > traces(_view.get_traces());
+ BOOST_FOREACH(shared_ptr<Trace> t, traces) {
+ assert(t);
+ connect(t.get(), SIGNAL(visibility_changed()),
+ this, SLOT(update()));
+ }
+}
+
void Viewport::on_signals_moved()
{
update();
void wheelEvent(QWheelEvent *event);
private slots:
+ void on_signals_changed();
void on_signals_moved();
private: