forked from UAVGCSTeam/GCS
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmapcontroller.h
More file actions
55 lines (45 loc) · 1.56 KB
/
mapcontroller.h
File metadata and controls
55 lines (45 loc) · 1.56 KB
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
#define MAPCONTROLLER_H
#include <QObject>
#include <QVariant>
#include <QPair>
#include <QVector>
#include "droneclass.h"
/*
* Qt uses Slots and Signals to create responsive UI/GUI applications.
* It allows for communication between QML and C++.
* https://doc.qt.io/qt-6/signalsandslots.html
*/
/*
* Our API to control all map functionality.
* Everything regarding the map should go here.
* Ensures separation of different functions.
* Keeps logic in cpp and QML purely for UI.
*/
class MapController : public QObject
{
Q_OBJECT
public:
explicit MapController(QObject *parent = nullptr);
// Q_INVOKABLE void debugPrintDrones() const;
Q_INVOKABLE void createDrone(const QString &input_name);
public slots:
void setCenterPosition(const QVariant &lat, const QVariant &lon);
void setLocationMarking(const QVariant &lat, const QVariant &lon);
void changeMapType(int typeIndex);
void setZoomLevel(double level);
Q_INVOKABLE void addDrone(DroneClass* drone);
Q_INVOKABLE QVariantList getAllDrones() const;
signals:
void centerPositionChanged(const QVariant &lat, const QVariant &lon);
void locationMarked(const QVariant &lat, const QVariant &lon);
void mapTypeChanged(int typeIndex);
void zoomLevelChanged(double level);
private:
QPair<double, double> m_center;
QVector<QPair<double, double>> m_markers;
int m_currentMapType;
int m_supportedMapTypesCount;
QVector<DroneClass*> m_drones;
void updateCenter(const QPair<double, double> ¢er);
void addMarker(const QPair<double, double> &position);
};