pulsaranimationwidget.h 3.9 KB
Newer Older
Oliver Bock's avatar
Oliver Bock committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/******************************************************************************
 *   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_

24
25
#include <cmath>

Oliver Bock's avatar
Oliver Bock committed
26
#include <QGLWidget>
Oliver Bock's avatar
Oliver Bock committed
27
#include <QTimer>
28
29
30
#include <QMouseEvent>

#define PI 3.14159265
Oliver Bock's avatar
Oliver Bock committed
31
32
33
34
35
36
37
38
39

class PulsarAnimationWidget : public QGLWidget
{
	Q_OBJECT

public:
	PulsarAnimationWidget(QWidget *parent);
	virtual ~PulsarAnimationWidget();

Oliver Bock's avatar
Oliver Bock committed
40
	void setFramePerSecond(const unsigned int fps);
Oliver Bock's avatar
Oliver Bock committed
41
42
43
	void setCompanionMass(const float mass);
	void setPulsarMass(const float mass);
	void setPulsarSpinFrequency(const float frequency);
44
	void setPulsarSpinAxisInclination(const int degrees);
45
	void setPulsarMagneticAxisInclination(const int degrees);
Oliver Bock's avatar
Oliver Bock committed
46
	void setPulsarSemiMajorAxis(const float length);
Oliver Bock's avatar
Oliver Bock committed
47

Oliver Bock's avatar
Oliver Bock committed
48
49
50
51
52
53
54
public slots:
	void runAnimation();
	void pauseAnimation();
	void stopAnimation();

	void updateFrame();

Oliver Bock's avatar
Oliver Bock committed
55
56
	void showRotationAxes(bool enabled);

Oliver Bock's avatar
Oliver Bock committed
57
58
signals:
	void pulsarSemiMajorAxisUpdated(double value);
Oliver Bock's avatar
Oliver Bock committed
59
60
61
	void pulsarViewDataUpdated(const QVector<float>& data);
	void pulsarAnimationStep(float stepSize);
	void pulsarAnimationReset();
Oliver Bock's avatar
Oliver Bock committed
62

Oliver Bock's avatar
Oliver Bock committed
63
64
65
66
protected:
    void initializeGL();
    void resizeGL(int w, int h);
    void paintGL();
Oliver Bock's avatar
Oliver Bock committed
67

68
    void mousePressEvent(QMouseEvent *event);
69
70
71
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);

Oliver Bock's avatar
Oliver Bock committed
72
73
	void updateOrbitPeriod();
    void updateOrbitRadii();
74
    void updateCameraPosition(const int angleH, const int angleV, const float zoom);
75
    void resetParameters();
76

Oliver Bock's avatar
Oliver Bock committed
77
78
    QTimer m_frameTimer;

Oliver Bock's avatar
Oliver Bock committed
79
80
    GLUquadricObj *m_quadricCompanionOrbitPlane;
    GLUquadricObj *m_quadricCompanion;
81
    GLUquadricObj *m_quadricPulsarOrbitPlane;
Oliver Bock's avatar
Oliver Bock committed
82
83
84
	GLUquadricObj *m_quadricPulsar;
	GLUquadricObj *m_quadricPulsarCone1;
	GLUquadricObj *m_quadricPulsarCone2;
85
	GLUquadricObj *m_quadricPulsarSpinAxis;
86
	GLUquadricObj *m_quadricPulsarMagneticAxis;
Oliver Bock's avatar
Oliver Bock committed
87

88
	GLuint m_pulsarTexture;
89
	GLuint m_backgroundTexture;
90

Oliver Bock's avatar
Oliver Bock committed
91
	int m_framesPerSecond;
92

Oliver Bock's avatar
Oliver Bock committed
93
	float m_pulsarRotationAngle;
Oliver Bock's avatar
Oliver Bock committed
94
	float m_pulsarRotationDelta;
95

Oliver Bock's avatar
Oliver Bock committed
96
	double m_orbitalPeriod;
Oliver Bock's avatar
Oliver Bock committed
97
98
	float m_orbitRotationAngle;
	float m_orbitRotationDelta;
99

Oliver Bock's avatar
Oliver Bock committed
100
101
102
103
	float m_pulsarMass;
	double m_pulsarSemiMajorAxis;
	float m_companionMass;
	double m_companionSemiMajorAxis;
104

105
	int m_pulsarSpinAxisInclination;
106
107
	int m_pulsarMagneticAxisInclination;

Oliver Bock's avatar
Oliver Bock committed
108
	bool m_showRotationAxes;
109
	bool m_cameraInteraction;
110
111
112
113
114
115
116
117
118
	int m_mouseLastX;
	int m_mouseLastY;
	int m_mouseAngleH;
	int m_mouseAngleV;
	float m_cameraZoom;
	float m_cameraZoomLBound;
	float m_cameraPosX;
	float m_cameraPosY;
	float m_cameraPosZ;
119
120

	static const float deg2rad;
Oliver Bock's avatar
Oliver Bock committed
121
122
123
};

#endif /* PULSARANIMATIONWIDGET_H_ */