Commit f63f2520 authored by Oliver Bock's avatar Oliver Bock

Fixed marker positioning/synchronization

* Using rotation angle directly (instead of independent stepping)
* One signal/slot link for position update and reset
* Also: added pulse profile update (reset) to stop animation slot
parent e0f6c689
......@@ -64,7 +64,8 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
m_framesPerSecond = 25;
m_pulsarRotationDelta = 0.0;
m_orbitRotationDelta = 0.0;
resetParameters();
m_pulsarRotationAngle = 0.0;
m_orbitRotationAngle = 0.0;
// initial binary system parameters (have to match GUI!)
m_pulsarMass = 1.4;
......@@ -393,7 +394,7 @@ void PulsarAnimationWidget::updateFrame()
updateGL();
emit pulsarAnimationStep(m_pulsarRotationDelta);
emit pulsarAnimationStep(m_pulsarRotationAngle);
}
void PulsarAnimationWidget::showOrbits(bool enabled)
......@@ -455,6 +456,7 @@ void PulsarAnimationWidget::mouseReleaseEvent(QMouseEvent *event)
m_mouseLastX = 0;
m_mouseLastY = 0;
m_cameraInteraction = false;
updateGL();
}
......@@ -554,8 +556,9 @@ void PulsarAnimationWidget::resetParameters()
{
m_pulsarRotationAngle = 0.0;
m_orbitRotationAngle = 0.0;
updatePulseProfile();
emit pulsarAnimationReset();
emit pulsarAnimationStep(m_pulsarRotationAngle);
}
void PulsarAnimationWidget::updatePulseProfile()
......
......@@ -59,8 +59,7 @@ public slots:
signals:
void pulsarSemiMajorAxisUpdated(double value);
void pulseProfileUpdated(const QVector<double>& data);
void pulsarAnimationStep(double stepSize);
void pulsarAnimationReset();
void pulsarAnimationStep(double position);
private:
void initializeGL();
......
......@@ -73,10 +73,7 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
this, SLOT(updatePulsarSemiMajorAxisValue(double)));
connect(ui.pulsarGlWidget, SIGNAL(pulsarAnimationStep(double)),
ui.pulseScopeWidget, SLOT(markerStep(double)), Qt::DirectConnection);
connect(ui.pulsarGlWidget, SIGNAL(pulsarAnimationReset()),
ui.pulseScopeWidget, SLOT(markerReset()));
ui.pulseScopeWidget, SLOT(setMarker(double)), Qt::DirectConnection);
connect(ui.pulsarGlWidget, SIGNAL(pulseProfileUpdated(const QVector<double>&)),
ui.pulseScopeWidget, SLOT(drawCurve(const QVector<double>&)), Qt::DirectConnection);
......
......@@ -83,18 +83,6 @@ void PulseScopeWidget::drawCurve(const QVector<double>& vector)
}
}
void PulseScopeWidget::markerStep(double stepSize) {
static double x = 0.0;
if(x < m_scopeSizeH) {
x += stepSize;
m_marker->setLine(x, 0.0, x, m_scopeSizeV);
}
else {
x -= m_scopeSizeH;
}
}
void PulseScopeWidget::markerReset() {
m_marker->setLine(0.0, 0.0, 0.0, m_scopeSizeV);
void PulseScopeWidget::setMarker(double position) {
m_marker->setLine(position, 0.0, position, m_scopeSizeV);
}
......@@ -42,8 +42,7 @@ public:
public slots:
void drawCurve(const QVector<double>& vector);
void markerStep(double stepSize);
void markerReset();
void setMarker(double position);
private:
QGraphicsScene m_scene;
......
Markdown is supported
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