pulsaranimationwidget.h 3.73 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
#include <QMouseEvent>
Oliver Bock's avatar
Oliver Bock committed
29
#include <QDebug>
30

Oliver Bock's avatar
Oliver Bock committed
31
32
33
34
35
36
#ifdef __APPLE__
    #include <OpenGL/glu.h>
#else
    #include <GL/glu.h>
#endif

37
#define PI 3.14159265
Oliver Bock's avatar
Oliver Bock committed
38

39

Oliver Bock's avatar
Oliver Bock committed
40
41
class PulsarAnimationWidget : public QGLWidget
{
42
    Q_OBJECT
Oliver Bock's avatar
Oliver Bock committed
43
44

public:
45
46
    PulsarAnimationWidget(QWidget *parent);
    virtual ~PulsarAnimationWidget();
Oliver Bock's avatar
Oliver Bock committed
47

Oliver Bock's avatar
Oliver Bock committed
48
    void setLHOAngle(const double degrees);
49
50
    void setLLOAngle(const double degrees);
    void setVirgoAngle(const int degrees);
51
    void setPulsarSpinAxisInclination(const int degrees);
52
    void setSourceInclination(const double length);
53
54
    void getCameraPosition(double& cameraAngleH, double& cameraAngleV, double& cameraZoom);
    void resetCameraPosition(const double angleH, const double angleV, const double zoom);
Oliver Bock's avatar
Oliver Bock committed
55

Oliver Bock's avatar
Oliver Bock committed
56
signals:
57
    void pulseProfileUpdated(const QVector<double>& data);
Oliver Bock's avatar
Oliver Bock committed
58

59
private:
Oliver Bock's avatar
Oliver Bock committed
60
61
62
    void initializeGL();
    void resizeGL(int w, int h);
    void paintGL();
Oliver Bock's avatar
Oliver Bock committed
63

64
    void mousePressEvent(QMouseEvent *event);
65
66
    void mouseMoveEvent(QMouseEvent *event);
    void mouseReleaseEvent(QMouseEvent *event);
Oliver Bock's avatar
Oliver Bock committed
67
    void showEvent(QShowEvent *event);
68

Oliver Bock's avatar
Oliver Bock committed
69
    void updateCameraPosition(const double angleH, const double angleV, const double zoom);
70
    void updatePulseProfile();
71

Oliver Bock's avatar
Oliver Bock committed
72
73
    GLUquadricObj *m_quadricVirgoh;
    GLUquadricObj *m_quadricVirgov;
74
    GLUquadricObj *m_quadricPulsarOrbitPlane;
75
    GLUquadricObj *m_quadricPulsar;
Oliver Bock's avatar
Oliver Bock committed
76
77
    GLUquadricObj *m_quadricLLOh;
    GLUquadricObj *m_quadricLLOv;
78
    GLUquadricObj *m_quadricPulsarSpinAxis;
79
    GLUquadricObj *m_quadricPulsarSpinAxisTop1;
80
81
    GLUquadricObj *m_quadricLHOv;
    GLUquadricObj *m_quadricLHOh;
82

83
    GLuint m_beamTexture;
84

Oliver Bock's avatar
Oliver Bock committed
85
    double m_pulsarRadius;
86
87
88
    double m_LHOAngle;
    double m_LLOAngle;
    double m_VirgoAngle;
89
    double m_pulsarSpinAxisInclination;
90
    double m_sourceInclination;
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107

    bool m_cameraInteraction;

    int m_mouseLastX;
    int m_mouseLastY;
    double m_mouseAngleH;
    double m_mouseAngleV;
    double m_cameraZoom;
    double m_cameraZoomLBound;
    double m_cameraZoomUBound;
    double m_cameraPosX;
    double m_cameraPosY;
    double m_cameraPosZ;

    QVector<double> m_pulseProfile;

    static const double deg2rad;
Oliver Bock's avatar
Oliver Bock committed
108
109
110
};

#endif /* PULSARANIMATIONWIDGET_H_ */