MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
- ui(new Ui::MainWindow)
+ _ui(new Ui::MainWindow)
{
- ui->setupUi(this);
+ _ui->setupUi(this);
_sampling_bar = new SamplingBar(this);
connect(_sampling_bar, SIGNAL(run_stop()), this,
SLOT(run_stop()));
addToolBar(_sampling_bar);
- view = new SigView(session, this);
- ui->verticalLayout->addWidget(view);
+ _view = new SigView(_session, this);
+ _ui->verticalLayout->addWidget(_view);
}
MainWindow::~MainWindow()
{
- delete ui;
+ delete _ui;
}
void MainWindow::on_actionOpen_triggered()
{
- QString fileName = QFileDialog::getOpenFileName(
+ QString file_name = QFileDialog::getOpenFileName(
this, tr("Open File"), "",
tr("Sigrok Sessions (*.sr)"));
- session.loadFile(fileName.toStdString());
+ _session.load_file(file_name.toStdString());
}
void MainWindow::on_actionAbout_triggered()
void MainWindow::run_stop()
{
- session.start_capture(
+ _session.start_capture(
_sampling_bar->get_selected_device(),
_sampling_bar->get_sample_rate());
}
~MainWindow();
private:
- Ui::MainWindow *ui;
+ Ui::MainWindow *_ui;
SamplingBar *_sampling_bar;
- SigSession session;
- SigView *view;
+ SigSession _session;
+ SigView *_view;
private slots:
using namespace std;
// TODO: This should not be necessary
-SigSession* SigSession::session = NULL;
+SigSession* SigSession::_session = NULL;
SigSession::SigSession()
{
// TODO: This should not be necessary
- session = this;
+ _session = this;
}
SigSession::~SigSession()
{
// TODO: This should not be necessary
- session = NULL;
+ _session = NULL;
}
-void SigSession::loadFile(const std::string &name)
+void SigSession::load_file(const std::string &name)
{
if (sr_session_load(name.c_str()) == SR_OK) {
/* sigrok session file */
- sr_session_datafeed_callback_add(dataFeedInProc);
+ sr_session_datafeed_callback_add(data_feed_in_proc);
sr_session_start();
sr_session_run();
sr_session_stop();
uint64_t sample_rate)
{
sr_session_new();
- sr_session_datafeed_callback_add(dataFeedInProc);
+ sr_session_datafeed_callback_add(data_feed_in_proc);
if (sr_session_dev_add(sdi) != SR_OK) {
qDebug() << "Failed to use device.";
return _signals;
}
-void SigSession::dataFeedIn(const struct sr_dev_inst *sdi,
+void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
struct sr_datafeed_packet *packet)
{
assert(sdi);
case SR_DF_END:
_cur_logic_snapshot.reset();
- dataUpdated();
+ data_updated();
break;
}
}
-void SigSession::dataFeedInProc(const struct sr_dev_inst *sdi,
+void SigSession::data_feed_in_proc(const struct sr_dev_inst *sdi,
struct sr_datafeed_packet *packet)
{
- assert(session);
- session->dataFeedIn(sdi, packet);
+ assert(_session);
+ _session->data_feed_in(sdi, packet);
}
~SigSession();
- void loadFile(const std::string &name);
+ void load_file(const std::string &name);
void start_capture(struct sr_dev_inst* sdi, uint64_t sample_rate);
get_signals();
private:
- void dataFeedIn(const struct sr_dev_inst *sdi,
+ void data_feed_in(const struct sr_dev_inst *sdi,
struct sr_datafeed_packet *packet);
- static void dataFeedInProc(const struct sr_dev_inst *sdi,
+ static void data_feed_in_proc(const struct sr_dev_inst *sdi,
struct sr_datafeed_packet *packet);
private:
boost::shared_ptr<LogicDataSnapshot> _cur_logic_snapshot;
signals:
- void dataUpdated();
+ void data_updated();
private:
// TODO: This should not be necessary. Multiple concurrent
// sessions should should be supported and it should be
// possible to associate a pointer with a sr_session.
- static SigSession *session;
+ static SigSession *_session;
};
#endif // SIGSESSION_H
_scale(1e-6),
_offset(0)
{
- connect(&_session, SIGNAL(dataUpdated()),
- this, SLOT(dataUpdated()));
+ connect(&_session, SIGNAL(data_updated()),
+ this, SLOT(data_updated()));
setMouseTracking(true);
setAutoFillBackground(false);
void SigView::resizeGL(int width, int height)
{
- setupViewport(width, height);
+ setup_viewport(width, height);
}
void SigView::paintEvent(QPaintEvent *event)
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
- setupViewport(width(), height());
+ setup_viewport(width(), height());
qglClearColor(Qt::white);
glClear(GL_COLOR_BUFFER_BIT);
}
// Paint the ruler
- paintRuler(painter);
+ paint_ruler(painter);
painter.end();
}
-void SigView::dataUpdated()
+void SigView::data_updated()
{
update();
}
update();
}
-void SigView::setupViewport(int width, int height)
+void SigView::setup_viewport(int width, int height)
{
glViewport(0, 0, (GLint)width, (GLint)height);
glMatrixMode(GL_PROJECTION);
glMatrixMode(GL_MODELVIEW);
}
-void SigView::paintRuler(QPainter &p)
+void SigView::paint_ruler(QPainter &p)
{
const double MinSpacing = 80;
void wheelEvent(QWheelEvent *event);
private:
- void setupViewport(int width, int height);
+ void setup_viewport(int width, int height);
- void paintRuler(QPainter &p);
+ void paint_ruler(QPainter &p);
private slots:
- void dataUpdated();
+ void data_updated();
private:
SigSession &_session;