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