qHexWalker 0.0.1
Hexagonal Grid Pathfinding & Maze Visualization on Interactive Maps
Loading...
Searching...
No Matches
h3TargetsModel.h
Go to the documentation of this file.
1#ifndef QHEXWALKER_H3TARGETSMODEL_H
2#define QHEXWALKER_H3TARGETSMODEL_H
3
4#include <QAbstractListModel>
5
6class H3Target;
7namespace H3_VIEWER {
8}
9class H3TargetsModel final : public QAbstractListModel {
10 Q_OBJECT
11 Q_DISABLE_COPY_MOVE(H3TargetsModel)
12public:
14
15 explicit H3TargetsModel(QObject *parent = nullptr);
16 ~H3TargetsModel() override;
17
18 [[nodiscard]] int rowCount(const QModelIndex &parent) const override;
19 [[nodiscard]] QVariant data(const QModelIndex &index, int role) const override;
20 [[nodiscard]] QHash<int, QByteArray> roleNames() const override;
21
22public slots:
23 Q_INVOKABLE void compute();
24 Q_INVOKABLE void move(int from, int to);
25 Q_INVOKABLE qsizetype remove(int row);
26 Q_INVOKABLE void requestCell(quint8 mapZoom, const QGeoCoordinate &coordinate);
27 Q_INVOKABLE void clearAllCells();
28 void setMazeWalls(const std::unordered_set<H3Index> &walls);
29 void setMazeBounds(const QGeoCoordinate &center, double radiusMeters);
30
31signals:
32 void onRemoveCell(const std::vector<H3Index> &indexes);
33 void onCompute(const std::vector<H3Index> &indexes);
36 void showNotification(const QString &message, const QString &type);
37
38private:
39 [[nodiscard]] bool isCoordinateTargetValid(quint8 zoom, const QGeoCoordinate &coordinate) const;
40
41 QList<H3Target *> cells_;
42 std::unordered_set<H3Index> mazeWalls_; // Стены лабиринта
43 QGeoCoordinate mazeCenter_; // Центр лабиринта
44 double mazeRadius_{0.0}; // Радиус допустимой области в метрах
45
46 const uint8_t minZoom_c{3};
47 const uint8_t maxZoom_c{15};
48 std::unordered_map<uint8_t, uint8_t> zoomToRes_;
49 const QHash<int, QString> resolutionColors_c = {
50 {3, "limegreen"}, {4, "green"}, {5, "darkGreen"}, {6, "gold"}, {7, "yellow"},
51 {8, "greenyellow"}, {9, "limegreen"}, {10, "mediumseagreen"}, {11, "turquoise"}, {12, "deepskyblue"},
52 {13, "dodgerblue"}, {14, "mediumblue"}, {15, "darkviolet"}};
53
54 std::atomic_bool isClearing_{false};
55};
56
57#endif // QHEXWALKER_H3TARGETSMODEL_H
void onCompute(const std::vector< H3Index > &indexes)
void clearingFinished()
void setMazeWalls(const std::unordered_set< H3Index > &walls)
QList< H3Target * > cells_
const QHash< int, QString > resolutionColors_c
void setMazeBounds(const QGeoCoordinate &center, double radiusMeters)
qsizetype remove(int row)
const uint8_t maxZoom_c
void clearingStarted()
std::unordered_map< uint8_t, uint8_t > zoomToRes_
std::unordered_set< H3Index > mazeWalls_
void showNotification(const QString &message, const QString &type)
QVariant data(const QModelIndex &index, int role) const override
bool isCoordinateTargetValid(quint8 zoom, const QGeoCoordinate &coordinate) const
QHash< int, QByteArray > roleNames() const override
std::atomic_bool isClearing_
public::void onRemoveCell(const std::vector< H3Index > &indexes)
QGeoCoordinate mazeCenter_
void move(int from, int to)
int rowCount(const QModelIndex &parent) const override
const uint8_t minZoom_c
~H3TargetsModel() override
void requestCell(quint8 mapZoom, const QGeoCoordinate &coordinate)
Namespace containing H3 visualization components.
Definition h3Model.h:20