12#ifndef Q_HEX_WALKER_H3MODEL_H
13#define Q_HEX_WALKER_H3MODEL_H
15#include <QAbstractListModel>
58class H3Model final :
public QAbstractListModel {
93 explicit H3Model(QObject *parent =
nullptr);
105 [[nodiscard]]
int rowCount(
const QModelIndex &parent)
const override;
113 [[nodiscard]] QVariant
data(
const QModelIndex &index,
int role)
const override;
119 [[nodiscard]] QHash<int, QByteArray>
roleNames()
const override;
165 void onCellComputed(quint8 res, H3Index index,
const QVariantList &polygon,
bool isSearching);
171 void onPathCellsBatch(
const std::vector<std::tuple<quint8, H3Index, QVariantList>> &cells);
185 void onSearchStats(
int exploredCells,
double timeMs,
int pathLength);
201 Q_INVOKABLE
void requestCells(
const std::vector<H3Index> &indexes);
210 void clearingStarted();
242 [[nodiscard]] std::optional<H3Cell *>
findCellByID(quint64
id)
const;
249 [[nodiscard]] std::optional<H3Cell *>
findCellByRes(quint8 res)
const;
273 void addCell(quint8 res, H3Index index,
const QVariantList &polygon,
const QColor &color);
297 {3,
"limegreen"}, {4,
"green"}, {5,
"darkGreen"}, {6,
"gold"}, {7,
"yellow"},
298 {8,
"greenyellow"}, {9,
"limegreen"}, {10,
"mediumseagreen"}, {11,
"turquoise"}, {12,
"deepskyblue"},
299 {13,
"dodgerblue"}, {14,
"mediumblue"}, {15,
"darkviolet"}};
Qt model for H3 hexagonal cell visualization and management.
~H3Model() override
Destructor.
QHash< int, QByteArray > roleNames() const override
Returns the role names for QML access.
void mazeRadiusChanged()
Emitted when maze radius changes.
QString searchStatsText_
Formatted search statistics.
void mazePolygonsChanged()
Emitted when maze polygons change.
void requestCells(const std::vector< H3Index > &indexes)
Requests visualization of specific cells.
void mazeWallsGenerated(const std::unordered_set< H3Index > &walls)
Emitted when maze walls are generated.
int rowCount(const QModelIndex &parent) const override
Returns the number of cells in the model.
QGeoCoordinate mazeCenter() const noexcept
Gets the geographic center of the maze.
bool isCoordinateTargetValid(quint8 zoom, const QGeoCoordinate &coordinate) const
Validates if a coordinate is a valid target.
void coordinatesChanged()
Emitted when coordinates property changes.
QGeoCoordinate mazeCenter_
Maze center coordinate.
void addCell(quint8 res, H3Index index, const QVariantList &polygon, const QColor &color)
Adds a new cell to the model.
void clearingFinished()
Emitted when cell clearing completes.
void mazeBoundsGenerated(const QGeoCoordinate ¢er, double radiusMeters)
Emitted with maze boundary information.
const uint8_t maxZoom_c
Maximum supported zoom level.
void onCellComputed(quint8 res, H3Index index, const QVariantList &polygon, bool isSearching)
Handles individual cell computation during search.
std::optional< H3Cell * > findCellByRes(quint8 res) const
Finds a cell by its resolution.
double mazeRadius() const noexcept
Gets the maze boundary radius.
void onSearchStats(int exploredCells, double timeMs, int pathLength)
Handles search statistics update.
void onMazePolygonsComputed(const std::vector< QVariantList > &polygons)
Handles maze polygon computation results.
void Init()
Initializes the model and starts worker thread.
QString searchStatsText() const noexcept
Gets search statistics as formatted text.
QString getColorForResolution(quint8 resolution) const
Gets the display color for a resolution level.
void onCellsComputed(const QVariantList &list)
Handles batch cell computation results.
QVariantList coordinates() const noexcept
Gets cell coordinates for map display.
double mazeRadius_
Maze boundary radius in meters.
Roles
Cell polygon coordinates for QML map display.
@ PathRole
Whether cell is part of path.
@ CellColor
Cell display color.
@ IndexRole
H3 cell index.
@ ResRole
Cell resolution (3-15).
QList< H3Cell * > pathCells_
Cells that are part of the current path.
const uint8_t minZoom_c
Minimum supported zoom level.
QVariantList coordinates_
Cell coordinates for display.
QThread * thread_
Worker thread.
QVariant data(const QModelIndex &index, int role) const override
Returns data for a cell at the given index.
H3_VIEWER::H3Worker * worker_
Worker for async operations.
std::optional< H3Cell * > findCellByID(quint64 id) const
Finds a cell by its H3 index.
std::atomic_bool isClearing_
Flag indicating clearing in progress.
void clearAllCells()
Clears all cells from the model.
std::unordered_map< uint8_t, uint8_t > zoomToRes_
Zoom to resolution mapping.
const QHash< int, QString > resolutionColors_c
Color palette for different resolutions.
void searchStatsChanged()
Emitted when search statistics update.
QList< QVariantList > mazePolygons() const noexcept
Gets maze wall polygons.
H3MazeAdapter * mazeAdapter_
Maze generation adapter.
void addPentagons()
Adds pentagon cells to the model.
void onPathCellsBatch(const std::vector< std::tuple< quint8, H3Index, QVariantList > > &cells)
Handles batch cell computation for path visualization (optimized).
QList< QVariantList > mazePolygons_
Maze wall polygons.
void mazeCenterChanged()
Emitted when maze center changes.
Worker thread for asynchronous H3 operations.
Namespace containing H3 visualization components.