-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmilehigh.h
98 lines (77 loc) · 1.96 KB
/
milehigh.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#ifndef MILEHIGH_H
#define MILEHIGH_H
#include <QByteArray>
#include <QGraphicsScene>
#include <QDebug>
#include <QMap>
#include <QList>
#include <QJsonDocument>
class QTimer;
class QNetworkAccessManager;
class QNetworkReply;
class Obstacle;
class Plane;
class Runway;
class Waypoint;
class MileHigh : public QGraphicsScene
{
Q_OBJECT
public:
MileHigh(QObject* parent = 0);
static const QString STATIC_TOKEN;
enum class Status {
IDLE,
INITIALIZING,
RUNNING,
TERMINATING
};
QMap<int, Plane*> planes(){
return _planes;
}
bool initialize();
static const QString BASE_URL;
static const QString GET_URL;
static const QString POST_URL;
static const QString SESSION_URL;
void requestToken();
void requestData();
void sendData();
void generateWaypoints();
void regenerateWaypoints();
QString token(){
return _token;
}
QJsonDocument currentData() const {
return _currentData;
}
void updatePlanes();
void spawnWaypoint(QPointF pos, int direction, Waypoint *parent);
protected:
void drawBackground(QPainter *painter, const QRectF &rect);
void drawForeground(QPainter *painter, const QRectF &rect);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
private:
QNetworkAccessManager* _net;
QTimer* _timer;
QString _token;
Status _status;
void recievedToken(QJsonDocument* doc);
void recievedGet(QJsonDocument* doc);
void recievedPost(QJsonDocument* doc);
void addPlane(Plane* plane);
void addObstacle(Obstacle* ob);
void setPlanesDirty();
QJsonDocument _currentData;
Runway* _runway;
Waypoint* _runwayWaypoint;
Waypoint* _landWaypoint;
QList<Obstacle*> _obstacles;
QMap<int, Plane*> _planes;
private slots:
void tick();
void serverReply(QNetworkReply*);
signals:
void updated();
};
#endif // MILEHIGH_H