Commit 21633ac3 authored by Oliver Bock's avatar Oliver Bock
Browse files

Removed obsolete stuff

parent 7aaa6ebf
......@@ -26,17 +26,13 @@ QT += core \
webkit
HEADERS += src/pulsaranimationwidget.h \
src/pulsescopewidget.h \
src/pulsatingscience.h \
src/pulsatingsciencehelp.h
src/pulsatingscience.h
SOURCES += src/pulsaranimationwidget.cpp \
src/pulsescopewidget.cpp \
src/pulsatingscience.cpp \
src/pulsatingsciencehelp.cpp \
src/main.cpp
FORMS += src/pulsatingscience.ui \
src/pulsatingsciencehelp.ui
RESOURCES += src/pulsatingscience.qrc \
src/pulsatingsciencehelp.qrc
FORMS += src/pulsatingscience.ui
RESOURCES += src/pulsatingscience.qrc
TS_DIR = src/resources
TRANSLATIONS = src/resources/pulsatingscience_de.ts
......
......@@ -24,7 +24,7 @@ const double PulsarAnimationWidget::deg2rad = PI/180.0;
PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
QGLWidget(QGLFormat(QGL::AlphaChannel | QGL::SampleBuffers), parent),
m_frameTimer(),
m_pulseProfile(360, 0.0)
{
QString msgThis = tr("3D animation");
......@@ -49,9 +49,6 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
qWarning() << msg.arg(msgThis);
}
// connect primary rendering timer to local callback
connect(&m_frameTimer, SIGNAL(timeout()), this, SLOT(updateFrame()));
// initialize quadric pointers
m_quadricVirgoh = NULL;
m_quadricVirgov = NULL;
......@@ -65,16 +62,8 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
m_quadricLHOh = NULL;
// initialize texture pointers
m_backgroundTexture = 0;
m_beamTexture = 0;
// initial render timing settings
m_framesPerSecond = 25;
m_pulsarRotationDelta = 0.0;
m_orbitRotationDelta = 0.0;
m_pulsarRotationAngle = 0.0;
m_orbitRotationAngle = 0.0;
// initial parameters (have to match GUI!)
m_LHOAngle = 180;
m_LLOAngle = -100;
......@@ -84,22 +73,7 @@ PulsarAnimationWidget::PulsarAnimationWidget(QWidget *parent) :
m_pulsarRadius = 3.0;
m_pulsarSpinAxisInclination = 0.0;
// initial spin frequency of 0.5 Hz
m_pulsarRotationDelta = (360.0 * 0.5) / m_framesPerSecond;
// beam properties (keep this order!)
m_pulsarBeamLength = 3.0f;
setPulsarBeamAngle(30);
// initial companion is "Neutron Star"
m_companionMass = 1.4;
m_companionSemiMajorAxis = (m_pulsarMass/m_companionMass) * m_pulsarSemiMajorAxis;
// update orbital period (based on settings above)
updateOrbitPeriod();
// initial view features
m_showOrbits = false;
m_showRotationAxes = false;
m_showPulseFlashes = true;
m_cameraInteraction = false;
// initial view settings
......@@ -128,7 +102,6 @@ PulsarAnimationWidget::~PulsarAnimationWidget()
if(m_quadricLHOv) gluDeleteQuadric(m_quadricLHOv);
if(m_quadricLHOh) gluDeleteQuadric(m_quadricLHOh);
if(m_backgroundTexture) deleteTexture(m_backgroundTexture);
if(m_beamTexture) deleteTexture(m_beamTexture);
}
......@@ -188,34 +161,10 @@ void PulsarAnimationWidget::initializeGL()
GLint maxTextureSize;
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);
// prepare local messages
QString msgShape = tr("%1 texture shape not quadratic!");
QString msgPower = tr("%1 texture dimensions not a power of 2!");
QString msgSize = tr("Maximum texture size exceeded! Scaling down %1 texture to %2x%3...");
// prepare and check background texture
QImage backgroundTexture(":/textures/resources/texture_background_carina.png");
if(backgroundTexture.width() != backgroundTexture.height()) {
qWarning() << msgShape.arg(tr("Background"));
}
else {
double integer = 0.0;
double fraction = 0.0;
fraction = modf(log(backgroundTexture.width()) / log(2.0), &integer);
if(fraction > 0.0) {
qWarning() << msgPower.arg(tr("Background"));
}
}
if(backgroundTexture.width() > maxTextureSize) {
qWarning() << msgSize.arg(tr("background").arg(maxTextureSize).arg(maxTextureSize));
backgroundTexture = backgroundTexture.scaled(maxTextureSize, maxTextureSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
}
// prepare and check beam texture
QImage beamTexture(":/textures/resources/World-Map-7.jpg");
// bind textures
m_backgroundTexture = bindTexture(backgroundTexture, GL_TEXTURE_2D, GL_RGBA);
m_beamTexture = bindTexture(beamTexture, GL_TEXTURE_2D, GL_RGBA);
// use mipmapped textures
......@@ -490,63 +439,6 @@ void PulsarAnimationWidget::paintGL()
glPopMatrix();
}
void PulsarAnimationWidget::runAnimation()
{
m_frameTimer.start(qRound(1000.0 / m_framesPerSecond));
}
void PulsarAnimationWidget::pauseAnimation()
{
m_frameTimer.stop();
}
void PulsarAnimationWidget::stopAnimation()
{
m_frameTimer.stop();
resetParameters();
updateGL();
}
void PulsarAnimationWidget::updateFrame()
{
m_pulsarRotationAngle += m_pulsarRotationDelta;
if(m_pulsarRotationAngle > 360.0) {
m_pulsarRotationAngle -= 360.0;
}
m_orbitRotationAngle += m_orbitRotationDelta;
if(m_orbitRotationAngle > 360.0) {
m_orbitRotationAngle -= 360.0;
}
updatePulseProfile();
updateGL();
emit pulsarAnimationStep(m_pulsarRotationAngle);
}
void PulsarAnimationWidget::showOrbits(bool enabled)
{
m_showOrbits = enabled;
updateGL();
}
void PulsarAnimationWidget::showRotationAxes(bool enabled)
{
m_showRotationAxes = enabled;
updateGL();
}
void PulsarAnimationWidget::showPulseFlashes(bool enabled)
{
m_showPulseFlashes = enabled;
updateGL();
}
void PulsarAnimationWidget::mousePressEvent(QMouseEvent *event)
{
Q_UNUSED(event);
......@@ -616,11 +508,6 @@ void PulsarAnimationWidget::updateCameraPosition(const double angleH, const doub
updateGL();
}
void PulsarAnimationWidget::setFramePerSecond(const unsigned int fps)
{
m_framesPerSecond = fps;
}
void PulsarAnimationWidget::setSourceInclination(const double degrees)
{
m_sourceInclination = degrees;
......@@ -661,23 +548,6 @@ void PulsarAnimationWidget::setPulsarSpinAxisInclination(const int degrees)
updateGL();
}
void PulsarAnimationWidget::setPulsarBeamAngle(const int degrees)
{
double beamTexturePeakCorrectionFactor = 0.83;
double correctedOuterRadius;
// compute visual radius
m_pulsarBeamOuterRadius = tan(deg2rad * degrees * 0.5f) * m_pulsarBeamLength;
// compute corrected angle for pulse profile
correctedOuterRadius = m_pulsarBeamOuterRadius * beamTexturePeakCorrectionFactor;
m_pulsarBeamAngle = 2 * atan(correctedOuterRadius / m_pulsarBeamLength) * 180.0/PI;
updatePulseProfile();
updateGL();
}
void PulsarAnimationWidget::getCameraPosition(double& cameraAngleH, double& cameraAngleV, double& cameraZoom)
{
cameraAngleH = m_mouseAngleH;
......@@ -694,72 +564,10 @@ void PulsarAnimationWidget::resetCameraPosition(const double angleH, const doubl
updateCameraPosition(m_mouseAngleH, m_mouseAngleV, m_cameraZoom);
}
void PulsarAnimationWidget::updateOrbitPeriod()
{
m_orbitalPeriod = 3.1553e7 * sqrt(
(pow(m_pulsarSemiMajorAxis, 3.0) * pow(m_pulsarMass+m_companionMass, 2.0)) / pow(m_companionMass, 3.0)
);
// visual correction factor (increase orbital momentum)
double visualCorrection = 1e-8;
m_orbitRotationDelta = (360.0 / (m_orbitalPeriod*visualCorrection)) / m_framesPerSecond;
}
void PulsarAnimationWidget::updateOrbitRadii()
{
m_pulsarSemiMajorAxis = 1.0015e-5 * pow(
(pow(m_orbitalPeriod, 2.0) * pow(m_companionMass, 3.0)) / pow(m_pulsarMass+m_companionMass, 2.0),
1.0/3.0
);
m_companionSemiMajorAxis = (m_pulsarMass/m_companionMass) * m_pulsarSemiMajorAxis;
emit pulsarSemiMajorAxisUpdated(m_pulsarSemiMajorAxis);
}
void PulsarAnimationWidget::resetParameters()
{
m_pulsarRotationAngle = 0.0;
m_orbitRotationAngle = 0.0;
updatePulseProfile();
emit pulsarAnimationStep(m_pulsarRotationAngle);
}
void PulsarAnimationWidget::updatePulseProfile()
{
// avoid division by zero (keep profile visible if pulsar doesn't spin)
double pulsarRotationDelta = m_pulsarRotationDelta == 0.0 ? 0.01 : m_pulsarRotationDelta;
// prepare parameters (e.g. convert to radians where necessary)
const double i = deg2rad * m_pulsarSpinAxisInclination;
const double y = deg2rad * m_pulsarMagneticAxisInclination;
double phiOrb = deg2rad * (m_orbitRotationAngle + 90.0);
const double deltaPhiRot = deg2rad * 1.0;
const double deltaPhiOrb = deg2rad * deltaPhiRot * m_orbitRotationDelta / pulsarRotationDelta;
const double rp = m_pulsarSemiMajorAxis;
const double xk = -m_cameraPosZ;
const double yk = -m_cameraPosX;
const double zk = m_cameraPosY;
const double cam = pow(xk, 2.0) + pow(yk, 2.0) + pow(zk, 2.0);
const double alpha = deg2rad * (90.0 - m_mouseAngleH);
const double delta = deg2rad * m_mouseAngleV;
const double gaussProfile = 0.012337;
for(int x = 0; x < 360; ++x) {
// determine angle between pulsar's magnetic axis and line of sight
phiOrb += deltaPhiOrb;
const double phiRot = x * deltaPhiRot;
double a = -sin(y) * sin(phiRot) * (xk + rp * cos(phiOrb)) \
+ (cos(i) * sin(y) * cos(phiRot) + sin(i) * cos(y)) * (yk + rp * sin(phiOrb)) \
- (sin(i) * sin(y) * cos(phiRot) - cos(i) * cos(y)) * zk;
double b = sqrt(pow(rp,2.0) + cam - (2.0 * sqrt(cam) * rp * cos(delta) * sin(alpha + phiOrb)));
// determine and store pulse amplitude
m_pulseProfile[x] = exp(-2.0 * (1.0 - fabs(a/b)) / gaussProfile);
m_pulseProfile[x] = 0;
}
// propagate new profile
......
......@@ -45,32 +45,16 @@ public:
PulsarAnimationWidget(QWidget *parent);
virtual ~PulsarAnimationWidget();
void setFramePerSecond(const unsigned int fps);
void setCompanionMass(const double mass);
void setLHOAngle(const double degrees);
void setLLOAngle(const double degrees);
void setVirgoAngle(const int degrees);
void setPulsarSpinAxisInclination(const int degrees);
void setSourceInclination(const double length);
void setPulsarBeamAngle(const int degrees);
void getCameraPosition(double& cameraAngleH, double& cameraAngleV, double& cameraZoom);
void resetCameraPosition(const double angleH, const double angleV, const double zoom);
public slots:
void runAnimation();
void pauseAnimation();
void stopAnimation();
void updateFrame();
void showOrbits(bool enabled);
void showRotationAxes(bool enabled);
void showPulseFlashes(bool enabled);
signals:
void pulsarSemiMajorAxisUpdated(double value);
void pulseProfileUpdated(const QVector<double>& data);
void pulsarAnimationStep(double position);
private:
void initializeGL();
......@@ -82,14 +66,9 @@ private:
void mouseReleaseEvent(QMouseEvent *event);
void showEvent(QShowEvent *event);
void updateOrbitPeriod();
void updateOrbitRadii();
void updateCameraPosition(const double angleH, const double angleV, const double zoom);
void resetParameters();
void updatePulseProfile();
QTimer m_frameTimer;
GLUquadricObj *m_quadricVirgoh;
GLUquadricObj *m_quadricVirgov;
GLUquadricObj *m_quadricPulsarOrbitPlane;
......@@ -101,33 +80,15 @@ private:
GLUquadricObj *m_quadricLHOv;
GLUquadricObj *m_quadricLHOh;
GLuint m_backgroundTexture;
GLuint m_beamTexture;
int m_framesPerSecond;
double m_pulsarRotationAngle;
double m_pulsarRotationDelta;
double m_orbitalPeriod;
double m_orbitRotationAngle;
double m_orbitRotationDelta;
double m_pulsarRadius;
double m_pulsarBeamLength;
double m_pulsarBeamAngle;
double m_pulsarBeamOuterRadius;
double m_LHOAngle;
double m_LLOAngle;
double m_VirgoAngle;
double m_pulsarSpinAxisInclination;
double m_sourceInclination;
double m_companionMass;
double m_companionSemiMajorAxis;
bool m_showOrbits;
bool m_showRotationAxes;
bool m_showPulseFlashes;
bool m_cameraInteraction;
int m_mouseLastX;
......
......@@ -40,9 +40,6 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
#endif
// inital status (based on GUI)
m_permanentOrbits = ui.actionPermanent_orbits->isChecked();
m_rotationAxesVisible = ui.actionRotationAxes->isChecked();
m_pulseFlashesVisible = ui.actionPulseFlashes->isChecked();
m_menuBarVisible = ui.actionMenu_bar->isChecked();
m_statusBarVisible = ui.actionStatus_bar->isChecked();
m_animControlVisible = true;
......@@ -50,18 +47,6 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
m_hiddenDemoModeActivated = false;
// register alternate shortcuts (will be enabled when menu is hidden)
m_runShortcut = new QShortcut(ui.actionRun->shortcut(), this);
m_runShortcut->setEnabled(false);
m_pauseShortcut = new QShortcut(ui.actionPause->shortcut(), this);
m_pauseShortcut->setEnabled(false);
m_stopShortcut = new QShortcut(ui.actionStop->shortcut(), this);
m_stopShortcut->setEnabled(false);
m_permanentOrbitsShortcut = new QShortcut(ui.actionPermanent_orbits->shortcut(), this);
m_permanentOrbitsShortcut->setEnabled(false);
m_rotationAxesShortcut = new QShortcut(ui.actionRotationAxes->shortcut(), this);
m_rotationAxesShortcut->setEnabled(false);
m_pulseFlashesShortcut = new QShortcut(ui.actionPulseFlashes->shortcut(), this);
m_pulseFlashesShortcut->setEnabled(false);
m_menuBarShortcut = new QShortcut(ui.actionMenu_bar->shortcut(), this);
m_menuBarShortcut->setEnabled(false);
m_fullscreenShortcut = new QShortcut(ui.actionFullscreen->shortcut(), this);
......@@ -73,27 +58,6 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
m_hiddenShortcut = new QShortcut(QKeySequence(Qt::SHIFT + Qt::ALT + Qt::Key_D), this);
// establish object communications
connect(ui.actionRun, SIGNAL(triggered()),
ui.pulsarGlWidget, SLOT(runAnimation()));
connect(ui.actionPause, SIGNAL(triggered()),
ui.pulsarGlWidget, SLOT(pauseAnimation()));
connect(ui.actionStop, SIGNAL(triggered()),
ui.pulsarGlWidget, SLOT(stopAnimation()));
connect(ui.actionPermanent_orbits, SIGNAL(toggled(bool)),
ui.pulsarGlWidget, SLOT(showOrbits(bool)));
connect(ui.actionRotationAxes, SIGNAL(toggled(bool)),
ui.pulsarGlWidget, SLOT(showRotationAxes(bool)));
connect(ui.actionPulseFlashes, SIGNAL(toggled(bool)),
ui.pulsarGlWidget, SLOT(showPulseFlashes(bool)));
connect(ui.pulsarGlWidget, SIGNAL(pulsarAnimationStep(double)),
ui.pulseScopeWidget, SLOT(setMarker(double)), Qt::DirectConnection);
connect(ui.pulsarGlWidget, SIGNAL(pulseProfileUpdated(const QVector<double>&)),
ui.pulseScopeWidget, SLOT(drawCurve(const QVector<double>&)), Qt::DirectConnection);
......@@ -114,45 +78,10 @@ PulsatingScience::PulsatingScience(QWidget *parent) : QMainWindow(parent)
restoreGeometry(settings.value("windowGeometry").toByteArray());
restoreState(settings.value("windowState").toByteArray());
ui.splitter->restoreState(settings.value("splitterSizes").toByteArray());
// restore view features
ui.actionPermanent_orbits->setChecked(settings.value("viewOrbitalPlanes", m_permanentOrbits).toBool());
ui.actionRotationAxes->setChecked(settings.value("viewRotationAxes", m_rotationAxesVisible).toBool());
ui.actionPulseFlashes->setChecked(settings.value("viewPulseFlashes", m_pulseFlashesVisible).toBool());
}
PulsatingScience::~PulsatingScience()
{
if(m_runShortcut) {
m_runShortcut->disconnect();
delete m_runShortcut;
}
if(m_pauseShortcut) {
m_pauseShortcut->disconnect();
delete m_pauseShortcut;
}
if(m_stopShortcut) {
m_stopShortcut->disconnect();
delete m_stopShortcut;
}
if(m_permanentOrbitsShortcut) {
m_permanentOrbitsShortcut->disconnect();
delete m_permanentOrbitsShortcut;
}
if(m_rotationAxesShortcut) {
m_rotationAxesShortcut->disconnect();
delete m_rotationAxesShortcut;
}
if(m_pulseFlashesShortcut) {
m_pulseFlashesShortcut->disconnect();
delete m_pulseFlashesShortcut;
}
if(m_menuBarShortcut) {
m_menuBarShortcut->disconnect();
delete m_menuBarShortcut;
......@@ -190,11 +119,6 @@ void PulsatingScience::closeEvent(QCloseEvent *event)
settings.setValue("windowState", saveState());
settings.setValue("splitterSizes", ui.splitter->saveState());
// save view features
settings.setValue("viewOrbitalPlanes", m_permanentOrbits);
settings.setValue("viewRotationAxes", m_rotationAxesVisible);
settings.setValue("viewPulseFlashes", m_pulseFlashesVisible);
event->accept();
}
}
......@@ -229,51 +153,6 @@ void PulsatingScience::on_sliderSourceInclination_valueChanged(int value)
ui.lcdSourceInclination->display(QString::number(value));
}
void PulsatingScience::permanentOrbitsToggled() {
if(m_permanentOrbits) {
on_actionPermanent_orbits_toggled(false);
ui.actionPermanent_orbits->setChecked(false);
}
else {
on_actionPermanent_orbits_toggled(true);
ui.actionPermanent_orbits->setChecked(true);
}
}
void PulsatingScience::on_actionPermanent_orbits_toggled(bool checked) {
m_permanentOrbits = checked;
}
void PulsatingScience::rotationAxesToggled() {
if(m_rotationAxesVisible) {
on_actionRotationAxes_toggled(false);
ui.actionRotationAxes->setChecked(false);
}
else {
on_actionRotationAxes_toggled(true);
ui.actionRotationAxes->setChecked(true);
}
}
void PulsatingScience::on_actionRotationAxes_toggled(bool checked) {
m_rotationAxesVisible = checked;
}
void PulsatingScience::pulseFlashesToggled() {
if(m_pulseFlashesVisible) {
on_actionPulseFlashes_toggled(false);
ui.actionPulseFlashes->setChecked(false);
}
else {
on_actionPulseFlashes_toggled(true);
ui.actionPulseFlashes->setChecked(true);
}
}
void PulsatingScience::on_actionPulseFlashes_toggled(bool checked) {
m_pulseFlashesVisible = checked;
}
void PulsatingScience::menuBarToggled()
{
if(ui.menuBar->isVisible()) {
......@@ -294,18 +173,6 @@ void PulsatingScience::on_actionMenu_bar_toggled(bool checked)
m_menuBarVisible = true;
// deactivate alternate shortcuts
m_runShortcut->disconnect();
m_runShortcut->setEnabled(false);
m_pauseShortcut->disconnect();
m_pauseShortcut->setEnabled(false);
m_stopShortcut->disconnect();
m_stopShortcut->setEnabled(false);
m_permanentOrbitsShortcut->disconnect();
m_permanentOrbitsShortcut->setEnabled(false);
m_rotationAxesShortcut->disconnect();
m_rotationAxesShortcut->setEnabled(false);
m_pulseFlashesShortcut->disconnect();
m_pulseFlashesShortcut->setEnabled(false);
m_fullscreenShortcut->disconnect();
m_fullscreenShortcut->setEnabled(false);
m_menuBarShortcut->disconnect();
......@@ -316,18 +183,6 @@ void PulsatingScience::on_actionMenu_bar_toggled(bool checked)
m_menuBarVisible = false;
// activate alternate shortcuts
m_runShortcut->setEnabled(true);
connect(m_runShortcut, SIGNAL(activated()), ui.pulsarGlWidget, SLOT(runAnimation()));
m_pauseShortcut->setEnabled(true);
connect(m_pauseShortcut, SIGNAL(activated()), ui.pulsarGlWidget, SLOT(pauseAnimation()));
m_stopShortcut->setEnabled(true);
connect(m_stopShortcut, SIGNAL(activated()), ui.pulsarGlWidget, SLOT(stopAnimation()));
m_permanentOrbitsShortcut->setEnabled(true);
connect(m_permanentOrbitsShortcut, SIGNAL(activated()), this, SLOT(permanentOrbitsToggled()));
m_rotationAxesShortcut->setEnabled(true);
connect(m_rotationAxesShortcut, SIGNAL(activated()), this, SLOT(rotationAxesToggled()));
m_pulseFlashesShortcut->setEnabled(true);
connect(m_pulseFlashesShortcut, SIGNAL(activated()), this, SLOT(pulseFlashesToggled()));
m_fullscreenShortcut->setEnabled(true);
connect(m_fullscreenShortcut, SIGNAL(activated()), this, SLOT(fullscreenToggled()));
m_menuBarShortcut->setEnabled(true);
......@@ -404,17 +259,6 @@ void PulsatingScience::on_dockAnimControl_topLevelChanged(bool topLevel) {
m_animControlFloating = topLevel;
}
void PulsatingScience::on_actionHelp_triggered()
{
PulsatingScienceHelp help(this);
help.exec();
}
void PulsatingScience::on_actionWebsite_triggered()
{
QDesktopServices::openUrl(QUrl("http://www.aei.mpg.de"));
}
void PulsatingScience::on_actionAbout_triggered()
{
QString content = "<b>%1</b><br>"
......
......@@ -27,8 +27,6 @@
#include <QDesktopServices>
#include <QUrl>
#include "pulsatingsciencehelp.h"
#include "ui_pulsatingscience.h"
......@@ -49,12 +47,6 @@ public slots:
void on_sliderPulsarSpinAxisInclination_valueChanged(int value);
void on_sliderSourceInclination_valueChanged(int value);
void permanentOrbitsToggled();
void on_actionPermanent_orbits_toggled(bool checked);
void rotationAxesToggled();
void on_actionRotationAxes_toggled(bool checked);
void pulseFlashesToggled();
void on_actionPulseFlashes_toggled(bool checked);
void fullscreenToggled();
void on_actionFullscreen_toggled(bool checked);
void menuBarToggled();
......@@ -63,8 +55,6 @@ public slots:
void on_dockAnimControl_visibilityChanged(bool visible);