-
Notifications
You must be signed in to change notification settings - Fork 0
/
canvas.h
49 lines (41 loc) · 1.01 KB
/
canvas.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#ifndef CANVAS_H
#define CANVAS_H
#include <QWidget>
#include <QPainter>
#include <vector>
#include "planet.h"
#include "math.h"
#include "spacecraft.h"
class Canvas : public QWidget {
Q_OBJECT
public:
Canvas(QWidget *parent = 0);
void addPlanet(Planet* planet);
void addSpacecraft(Spacecraft* spacecraft);
void removeSpacecraft();
public slots:
//comments please
void simulate(int time);
void reset();
protected:
void paintEvent(QPaintEvent *event);
void wheelEvent(QWheelEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
private:
std::vector<Planet*> planets;
std::vector<Spacecraft*> spacecrafts;
QPolygonF path;
QTimer* timer;
double zoomAmount;
long x;
long y;
long prevX;
long prevY;
long pressX;
long pressY;
bool firstRender;
static const double G = 6.67384e-11;
static const double PI = 3.14159265;
};
#endif // CANVAS_H