Select Git revision
pulsaranimationwidget.h
-
Oliver Bock authored
* 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
Oliver Bock authored* 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
pulsaranimationwidget.h 4.01 KiB
/******************************************************************************
* Copyright (C) 2008 by Oliver Bock *
* oliver.bock[AT]aei.mpg.de *
* *
* This file is part of PulsatingScience. *
* *
* PulsatingScience is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation, version 3 of the License. *
* *
* PulsatingScience is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with PulsatingScience. If not, see <http://www.gnu.org/licenses/>. *
* *
******************************************************************************/
#ifndef PULSARANIMATIONWIDGET_H_
#define PULSARANIMATIONWIDGET_H_
#include <cmath>
#include <QGLWidget>
#include <QTimer>
#include <QMouseEvent>
#define PI 3.14159265
class PulsarAnimationWidget : public QGLWidget
{
Q_OBJECT
public:
PulsarAnimationWidget(QWidget *parent);
virtual ~PulsarAnimationWidget();
void setFramePerSecond(const unsigned int fps);
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 double length);
public slots:
void runAnimation();
void pauseAnimation();
void stopAnimation();
void updateFrame();
void showOrbits(bool enabled);
void showRotationAxes(bool enabled);
signals:
void pulsarSemiMajorAxisUpdated(double value);
void pulseProfileUpdated(const QVector<double>& data);
void pulsarAnimationStep(double position);
private:
void initializeGL();
void resizeGL(int w, int h);
void paintGL();
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
void mouseReleaseEvent(QMouseEvent *event);
void updateOrbitPeriod();
void updateOrbitRadii();
void updateCameraPosition(const int angleH, const int angleV, const double zoom);
void resetParameters();
void updatePulseProfile();
QTimer m_frameTimer;
GLUquadricObj *m_quadricCompanionOrbitPlane;
GLUquadricObj *m_quadricCompanion;
GLUquadricObj *m_quadricPulsarOrbitPlane;
GLUquadricObj *m_quadricPulsar;
GLUquadricObj *m_quadricPulsarCone1;
GLUquadricObj *m_quadricPulsarCone2;
GLUquadricObj *m_quadricPulsarSpinAxis;
GLUquadricObj *m_quadricPulsarMagneticAxis;
GLuint m_pulsarTexture;
GLuint m_backgroundTexture;
int m_framesPerSecond;
double m_pulsarRotationAngle;
double m_pulsarRotationDelta;
double m_orbitalPeriod;
double m_orbitRotationAngle;
double m_orbitRotationDelta;
double m_pulsarMass;
double m_pulsarSemiMajorAxis;
double m_companionMass;
double m_companionSemiMajorAxis;
int m_pulsarSpinAxisInclination;
int m_pulsarMagneticAxisInclination;
bool m_showOrbits;
bool m_showRotationAxes;
bool m_cameraInteraction;
int m_mouseLastX;
int m_mouseLastY;
int m_mouseAngleH;
int m_mouseAngleV;
double m_cameraZoom;
double m_cameraZoomLBound;
double m_cameraPosX;
double m_cameraPosY;
double m_cameraPosZ;
QVector<double> m_pulseProfile;
static const double deg2rad;
};
#endif /* PULSARANIMATIONWIDGET_H_ */