Commit 817406f3 authored by Oliver Bock's avatar Oliver Bock

Just to be on the safe side

* Use double precision
* No explicit float literals
parent 5761d7ec
This diff is collapsed.
......@@ -39,12 +39,12 @@ public:
virtual ~PulsarAnimationWidget();
void setFramePerSecond(const unsigned int fps);
void setCompanionMass(const float mass);
void setPulsarMass(const float mass);
void setPulsarSpinFrequency(const float frequency);
void setCompanionMass(const double mass);
void setPulsarMass(const double mass);
void setPulsarSpinFrequency(const double frequency);
void setPulsarSpinAxisInclination(const int degrees);
void setPulsarMagneticAxisInclination(const int degrees);
void setPulsarSemiMajorAxis(const float length);
void setPulsarSemiMajorAxis(const double length);
public slots:
void runAnimation();
......@@ -58,8 +58,8 @@ public slots:
signals:
void pulsarSemiMajorAxisUpdated(double value);
void pulseProfileUpdated(const QVector<float>& data);
void pulsarAnimationStep(float stepSize);
void pulseProfileUpdated(const QVector<double>& data);
void pulsarAnimationStep(double stepSize);
void pulsarAnimationReset();
private:
......@@ -73,7 +73,7 @@ private:
void updateOrbitPeriod();
void updateOrbitRadii();
void updateCameraPosition(const int angleH, const int angleV, const float zoom);
void updateCameraPosition(const int angleH, const int angleV, const double zoom);
void resetParameters();
void updatePulseProfile();
......@@ -93,16 +93,16 @@ private:
int m_framesPerSecond;
float m_pulsarRotationAngle;
float m_pulsarRotationDelta;
double m_pulsarRotationAngle;
double m_pulsarRotationDelta;
double m_orbitalPeriod;
float m_orbitRotationAngle;
float m_orbitRotationDelta;
double m_orbitRotationAngle;
double m_orbitRotationDelta;
float m_pulsarMass;
double m_pulsarMass;
double m_pulsarSemiMajorAxis;
float m_companionMass;
double m_companionMass;
double m_companionSemiMajorAxis;
int m_pulsarSpinAxisInclination;
......@@ -116,15 +116,15 @@ private:
int m_mouseLastY;
int m_mouseAngleH;
int m_mouseAngleV;
float m_cameraZoom;
float m_cameraZoomLBound;
float m_cameraPosX;
float m_cameraPosY;
float m_cameraPosZ;
double m_cameraZoom;
double m_cameraZoomLBound;
double m_cameraPosX;
double m_cameraPosY;
double m_cameraPosZ;
QVector<float> m_pulseProfile;
QVector<double> m_pulseProfile;
static const float deg2rad;
static const double deg2rad;
};
#endif /* PULSARANIMATIONWIDGET_H_ */
......@@ -72,14 +72,14 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
connect(ui.pulsarGlWidget, SIGNAL(pulsarSemiMajorAxisUpdated(double)),
this, SLOT(updatePulsarSemiMajorAxisValue(double)));
connect(ui.pulsarGlWidget, SIGNAL(pulsarAnimationStep(float)),
ui.pulseScopeWidget, SLOT(markerStep(float)), Qt::DirectConnection);
connect(ui.pulsarGlWidget, SIGNAL(pulsarAnimationStep(double)),
ui.pulseScopeWidget, SLOT(markerStep(double)), Qt::DirectConnection);
connect(ui.pulsarGlWidget, SIGNAL(pulsarAnimationReset()),
ui.pulseScopeWidget, SLOT(markerReset()));
connect(ui.pulsarGlWidget, SIGNAL(pulseProfileUpdated(const QVector<float>&)),
ui.pulseScopeWidget, SLOT(drawCurve(const QVector<float>&)), Qt::DirectConnection);
connect(ui.pulsarGlWidget, SIGNAL(pulseProfileUpdated(const QVector<double>&)),
ui.pulseScopeWidget, SLOT(drawCurve(const QVector<double>&)), Qt::DirectConnection);
}
PulsatingScience::~PulsatingScience()
......@@ -151,37 +151,37 @@ void PulsatingScience::on_pushStop_clicked()
void PulsatingScience::on_radioCompanionWD_toggled(bool checked)
{
if(checked) {
ui.pulsarGlWidget->setCompanionMass(0.6f);
ui.lcdCompanionMass->display(QString::number(0.6f, 'f', 1));
ui.pulsarGlWidget->setCompanionMass(0.6);
ui.lcdCompanionMass->display(QString::number(0.6, 'f', 1));
}
}
void PulsatingScience::on_radioCompanionSun_toggled(bool checked)
{
if(checked) {
ui.pulsarGlWidget->setCompanionMass(1.0f);
ui.lcdCompanionMass->display(QString::number(1.0f, 'f', 1));
ui.pulsarGlWidget->setCompanionMass(1.0);
ui.lcdCompanionMass->display(QString::number(1.0, 'f', 1));
}
}
void PulsatingScience::on_radioCompanionNS_toggled(bool checked)
{
if(checked) {
ui.pulsarGlWidget->setCompanionMass(1.4f);
ui.lcdCompanionMass->display(QString::number(1.4f, 'f', 1));
ui.pulsarGlWidget->setCompanionMass(1.4);
ui.lcdCompanionMass->display(QString::number(1.4, 'f', 1));
}
}
void PulsatingScience::on_sliderPulsarMass_valueChanged(int value)
{
ui.pulsarGlWidget->setPulsarMass(value * 0.1f);
ui.lcdPulsarMass->display(QString::number(value * 0.1f, 'f', 1));
ui.pulsarGlWidget->setPulsarMass(value * 0.1);
ui.lcdPulsarMass->display(QString::number(value * 0.1, 'f', 1));
}
void PulsatingScience::on_sliderPulsarSpinFrequency_valueChanged(int value)
{
ui.pulsarGlWidget->setPulsarSpinFrequency(value * 0.1f);
ui.lcdPulsarSpinFrequency->display(QString::number(value * 0.1f, 'f', 1));
ui.pulsarGlWidget->setPulsarSpinFrequency(value * 0.1);
ui.lcdPulsarSpinFrequency->display(QString::number(value * 0.1, 'f', 1));
}
void PulsatingScience::on_sliderPulsarSpinAxisInclination_valueChanged(int value)
......@@ -198,8 +198,8 @@ void PulsatingScience::on_sliderPulsarMagneticAxisInclination_valueChanged(int v
void PulsatingScience::on_sliderPulsarSemiMajorAxis_valueChanged(int value)
{
ui.pulsarGlWidget->setPulsarSemiMajorAxis(value * 0.001f);
ui.lcdPulsarSemiMajorAxis->display(QString::number(value * 0.001f, 'f', 1));
ui.pulsarGlWidget->setPulsarSemiMajorAxis(value * 0.001);
ui.lcdPulsarSemiMajorAxis->display(QString::number(value * 0.001, 'f', 1));
ui.lcdPulsarSemiMajorAxis->setStyleSheet("color: black");
}
......
......@@ -42,16 +42,16 @@ PulseScopeWidget::PulseScopeWidget(QWidget *parent) : QGraphicsView(parent),
qWarning("Sorry, no multisampling support for pulse scope...");
}
m_scopeSizeH = 360.0f;
m_scopeSizeV = 1.0f;
m_scopeSizeH = 360.0;
m_scopeSizeV = 1.0;
m_path = NULL;
m_marker = m_scene.addLine(0.0f, 0.0f, 0.0f, m_scopeSizeV, QPen(Qt::red));
m_marker = m_scene.addLine(0.0, 0.0, 0.0, m_scopeSizeV, QPen(Qt::red));
m_marker->setZValue(1);
setScene(&m_scene);
m_data.fill(0.0f, m_scopeSizeH);
m_data.fill(0.0, m_scopeSizeH);
drawCurve(m_data);
}
......@@ -67,11 +67,11 @@ void PulseScopeWidget::resizeEvent(QResizeEvent *event)
fitInView(m_scene.itemsBoundingRect(), Qt::IgnoreAspectRatio);
}
void PulseScopeWidget::drawCurve(const QVector<float>& vector)
void PulseScopeWidget::drawCurve(const QVector<double>& vector)
{
m_data = vector;
QPainterPath pulsePath(QPoint(0.0f, m_scopeSizeV));
QPainterPath pulsePath(QPoint(0.0, m_scopeSizeV));
for(int i = 0; i < m_scopeSizeH; ++i) {
pulsePath.lineTo(i, m_scopeSizeV - m_data.at(i));
}
......@@ -83,12 +83,12 @@ void PulseScopeWidget::drawCurve(const QVector<float>& vector)
}
}
void PulseScopeWidget::markerStep(float stepSize) {
static float x = 0.0f;
void PulseScopeWidget::markerStep(double stepSize) {
static double x = 0.0;
if(x < m_scopeSizeH) {
x += stepSize;
m_marker->setLine(x, 0.0f, x, m_scopeSizeV);
m_marker->setLine(x, 0.0, x, m_scopeSizeV);
}
else {
x -= m_scopeSizeH;
......@@ -96,5 +96,5 @@ void PulseScopeWidget::markerStep(float stepSize) {
}
void PulseScopeWidget::markerReset() {
m_marker->setLine(0.0f, 0.0f, 0.0f, m_scopeSizeV);
m_marker->setLine(0.0, 0.0, 0.0, m_scopeSizeV);
}
......@@ -41,18 +41,18 @@ public:
void resizeEvent(QResizeEvent *event);
public slots:
void drawCurve(const QVector<float>& vector);
void markerStep(float stepSize);
void drawCurve(const QVector<double>& vector);
void markerStep(double stepSize);
void markerReset();
private:
QGraphicsScene m_scene;
QVector<float> m_data;
QVector<double> m_data;
QGraphicsPathItem *m_path;
QGraphicsLineItem *m_marker;
float m_scopeSizeH;
float m_scopeSizeV;
double m_scopeSizeH;
double m_scopeSizeV;
};
#endif /* PULSESCOPEWIDGET_H_ */
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