Commit 01f66fe5 authored by Oliver Bock's avatar Oliver Bock
Browse files

Slightly refactored drawCurve (into plot) to facilitate next steps

parent 99313a66
......@@ -59,7 +59,7 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
// establish object communications
connect(ui.pulsarGlWidget, SIGNAL(pulseProfileUpdated(const QVector<double>&)),
ui.pulseScopeWidget, SLOT(drawCurve(const QVector<double>&)), Qt::DirectConnection);
ui.pulseScopeWidget, SLOT(plot(const QVector<double>&)), Qt::DirectConnection);
connect(m_hiddenShortcut, SIGNAL(activated()),
this, SLOT(toggleHiddenDemoMode()));
......
......@@ -59,7 +59,7 @@ PulseScopeWidget::PulseScopeWidget(QWidget *parent) : QGraphicsView(parent),
setScene(&m_scene);
m_data.fill(0.0, qRound(m_scopeSizeH));
drawCurve(m_data);
drawCurve(m_path, m_data, "black");
}
PulseScopeWidget::~PulseScopeWidget()
......@@ -74,18 +74,22 @@ void PulseScopeWidget::resizeEvent(QResizeEvent *event)
fitInView(m_scene.itemsBoundingRect(), Qt::IgnoreAspectRatio);
}
void PulseScopeWidget::drawCurve(const QVector<double>& vector)
void PulseScopeWidget::plot(const QVector<double>& vector)
{
m_data = vector;
drawCurve(m_path, vector, "yellow");
}
QPainterPath pulsePath(QPointF(0.0, m_scopeSizeV - m_data.at(0) - 1.0));
void PulseScopeWidget::drawCurve(QGraphicsPathItem* path, const QVector<double>& vector, QString color)
{
QPainterPath pulsePath(QPointF(0.0, m_scopeSizeV - vector.at(0) - 1.0));
for(int i = 1; i < m_scopeSizeH; ++i) {
pulsePath.lineTo(i, m_scopeSizeV - m_data.at(i) - 1.0);
pulsePath.lineTo(i, m_scopeSizeV - vector.at(i) - 1.0);
}
if(m_path == NULL) {
m_path = m_scene.addPath(pulsePath, QPen(Qt::yellow));
if(path == NULL) {
path = m_scene.addPath(pulsePath, QPen(QColor(color)));
}
else {
m_path->setPath(pulsePath);
path->setPen(QPen(QColor(color)));
path->setPath(pulsePath);
}
}
......@@ -42,9 +42,11 @@ public:
void resizeEvent(QResizeEvent *event);
public slots:
void drawCurve(const QVector<double>& vector);
void plot(const QVector<double>& vector);
private:
void drawCurve(QGraphicsPathItem* path, const QVector<double>& vector, QString color);
QGraphicsScene m_scene;
QVector<double> m_data;
QGraphicsPathItem *m_path;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment