{
assert(_probe_index >= 0);
}
+
+void LogicSignal::paint(QGLWidget &widget, const QRect &rect)
+{
+ glColor3f(1,0,0);
+ glBegin(GL_POLYGON);
+ glVertex2f(rect.left(), rect.top());
+ glVertex2f(rect.right(), rect.top());
+ glVertex2f(rect.right(), rect.bottom());
+ glEnd();
+}
LogicSignal(QString name, boost::shared_ptr<SignalData> data,
int probe_index);
+ void paint(QGLWidget &widget, const QRect &rect);
+
private:
int _probe_index;
};
*/
#include <boost/shared_ptr.hpp>
+
+#include <QGLWidget>
+#include <QRect>
#include <QString>
+
#include <stdint.h>
class SignalData;
public:
QString get_name() const;
+ virtual void paint(QGLWidget &widget, const QRect &rect) = 0;
+
protected:
QString _name;
boost::shared_ptr<SignalData> _data;
#include "logicdata.h"
#include "logicdatasnapshot.h"
+#include "logicsignal.h"
#include <QDebug>
#include <assert.h>
using namespace boost;
+using namespace std;
// TODO: This should not be necessary
SigSession* SigSession::session = NULL;
}
}
+vector< shared_ptr<Signal> >& SigSession::get_signals()
+{
+ return _signals;
+}
+
void SigSession::dataFeedIn(const struct sr_dev_inst *sdi,
struct sr_datafeed_packet *packet)
{
switch (packet->type) {
case SR_DF_HEADER:
+ _signals.clear();
break;
case SR_DF_META_LOGIC:
{
assert(packet->payload);
- _logic_data.reset(new LogicData(
- *(sr_datafeed_meta_logic*)packet->payload));
+ const sr_datafeed_meta_logic &meta_logic =
+ *(sr_datafeed_meta_logic*)packet->payload;
+ // Create an empty LogiData for coming data snapshots
+ _logic_data.reset(new LogicData(meta_logic));
assert(_logic_data);
if(!_logic_data)
break;
+ // Add the signals
+ for (int i = 0; i < meta_logic.num_probes; i++)
+ {
+ const sr_probe *const probe =
+ (const sr_probe*)g_slist_nth_data(
+ sdi->probes, i);
+ if(probe->enabled)
+ {
+ boost::shared_ptr<LogicSignal> signal(
+ new LogicSignal(probe->name,
+ _logic_data,
+ probe->index));
+ _signals.push_back(signal);
+ }
+ }
+
break;
}
#include <boost/shared_ptr.hpp>
-#include <list>
-#include <map>
#include <string>
+#include <vector>
#include <QObject>
void loadFile(const std::string &name);
+ std::vector< boost::shared_ptr<Signal> >&
+ get_signals();
+
private:
void dataFeedIn(const struct sr_dev_inst *sdi,
struct sr_datafeed_packet *packet);
struct sr_datafeed_packet *packet);
private:
- std::list< boost::shared_ptr<Signal> > _signals;
+ std::vector< boost::shared_ptr<Signal> > _signals;
boost::shared_ptr<LogicData> _logic_data;
boost::shared_ptr<LogicDataSnapshot> _cur_logic_snapshot;
#include "sigview.h"
#include "sigsession.h"
+#include "signal.h"
+
+#include <boost/foreach.hpp>
+
+using namespace boost;
+using namespace std;
+
+const int SigView::SignalHeight = 50;
SigView::SigView(SigSession &session, QWidget *parent) :
QGLWidget(parent),
void SigView::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT);
+
+ QRect rect(0, 0, width(), SignalHeight);
+ const vector< shared_ptr<Signal> > &sigs =
+ _session.get_signals();
+ BOOST_FOREACH(const shared_ptr<Signal> s, sigs)
+ {
+ assert(s);
+ s->paint(*this, rect);
+ rect.translate(0, SignalHeight);
+ }
}
void SigView::dataUpdated()
{
- printf("Data Updated\n");
+ update();
}
class SigView : public QGLWidget
{
Q_OBJECT
+
+private:
+ static const int SignalHeight;
+
public:
explicit SigView(SigSession &session, QWidget *parent = 0);