|
qHexWalker 0.0.1
Hexagonal Grid Pathfinding & Maze Visualization on Interactive Maps
|
Qt model for H3 hexagonal cell visualization and management. More...
#include <h3Model.h>
Inheritance diagram for H3Model:
Collaboration diagram for H3Model:Public Types | |
| enum | Roles { ResRole = Qt::UserRole + 1 , IndexRole , CellColor , PathRole } |
| Cell polygon coordinates for QML map display. More... | |
Public Member Functions | |
| H3Model (QObject *parent=nullptr) | |
| Constructs an H3Model. | |
| ~H3Model () override | |
| Destructor. | |
| int | rowCount (const QModelIndex &parent) const override |
| Returns the number of cells in the model. | |
| QVariant | data (const QModelIndex &index, int role) const override |
| Returns data for a cell at the given index. | |
| QHash< int, QByteArray > | roleNames () const override |
| Returns the role names for QML access. | |
| QVariantList | coordinates () const noexcept |
| Gets cell coordinates for map display. | |
| QList< QVariantList > | mazePolygons () const noexcept |
| Gets maze wall polygons. | |
| QString | searchStatsText () const noexcept |
| Gets search statistics as formatted text. | |
| QGeoCoordinate | mazeCenter () const noexcept |
| Gets the geographic center of the maze. | |
| double | mazeRadius () const noexcept |
| Gets the maze boundary radius. | |
| void | Init () |
| Initializes the model and starts worker thread. | |
| void | requestCells (const std::vector< H3Index > &indexes) |
| Requests visualization of specific cells. | |
| void | clearAllCells () |
| Clears all cells from the model. | |
| void | clearingFinished () |
| Emitted when cell clearing completes. | |
| void | coordinatesChanged () |
| Emitted when coordinates property changes. | |
| void | mazePolygonsChanged () |
| Emitted when maze polygons change. | |
| void | searchStatsChanged () |
| Emitted when search statistics update. | |
| void | mazeWallsGenerated (const std::unordered_set< H3Index > &walls) |
| Emitted when maze walls are generated. | |
| void | mazeCenterChanged () |
| Emitted when maze center changes. | |
| void | mazeRadiusChanged () |
| Emitted when maze radius changes. | |
| void | mazeBoundsGenerated (const QGeoCoordinate ¢er, double radiusMeters) |
| Emitted with maze boundary information. | |
Public Attributes | |
| : void clearingStarted() | |
Private Member Functions | |
| void | onCellsComputed (const QVariantList &list) |
| Handles batch cell computation results. | |
| void | onCellComputed (quint8 res, H3Index index, const QVariantList &polygon, bool isSearching) |
| Handles individual cell computation during search. | |
| void | onPathCellsBatch (const std::vector< std::tuple< quint8, H3Index, QVariantList > > &cells) |
| Handles batch cell computation for path visualization (optimized). | |
| void | onMazePolygonsComputed (const std::vector< QVariantList > &polygons) |
| Handles maze polygon computation results. | |
| void | onSearchStats (int exploredCells, double timeMs, int pathLength) |
| Handles search statistics update. | |
| std::optional< H3Cell * > | findCellByID (quint64 id) const |
| Finds a cell by its H3 index. | |
| std::optional< H3Cell * > | findCellByRes (quint8 res) const |
| Finds a cell by its resolution. | |
| bool | isCoordinateTargetValid (quint8 zoom, const QGeoCoordinate &coordinate) const |
| Validates if a coordinate is a valid target. | |
| QString | getColorForResolution (quint8 resolution) const |
| Gets the display color for a resolution level. | |
| void | addCell (quint8 res, H3Index index, const QVariantList &polygon, const QColor &color) |
| Adds a new cell to the model. | |
| void | addPentagons () |
| Adds pentagon cells to the model. | |
Private Attributes | |
| H3_VIEWER::H3Worker * | worker_ {} |
| Worker for async operations. | |
| QThread * | thread_ {} |
| Worker thread. | |
| H3MazeAdapter * | mazeAdapter_ {} |
| Maze generation adapter. | |
| QList< H3Cell * > | pathCells_ |
| Cells that are part of the current path. | |
| QVariantList | coordinates_ |
| Cell coordinates for display. | |
| QList< QVariantList > | mazePolygons_ |
| Maze wall polygons. | |
| QString | searchStatsText_ |
| Formatted search statistics. | |
| QGeoCoordinate | mazeCenter_ |
| Maze center coordinate. | |
| double | mazeRadius_ {0.0} |
| Maze boundary radius in meters. | |
| const uint8_t | minZoom_c {3} |
| Minimum supported zoom level. | |
| const uint8_t | maxZoom_c {15} |
| Maximum supported zoom level. | |
| std::unordered_map< uint8_t, uint8_t > | zoomToRes_ |
| Zoom to resolution mapping. | |
| const QHash< int, QString > | resolutionColors_c |
| Color palette for different resolutions. | |
| std::atomic_bool | isClearing_ {false} |
| Flag indicating clearing in progress. | |
Qt model for H3 hexagonal cell visualization and management.
H3Model serves as the central data model connecting the QML UI with the pathfinding algorithms and maze generation. It manages:
| enum H3Model::Roles |
Cell polygon coordinates for QML map display.
Maze wall polygons for QML rendering.
Human-readable search statistics text.
Geographic center of the generated maze.
Maze boundary radius in meters.
Custom roles for the list model.
| Enumerator | |
|---|---|
| ResRole | Cell resolution (3-15). |
| IndexRole | H3 cell index. |
| CellColor | Cell display color. |
| PathRole | Whether cell is part of path. |
|
explicit |
Constructs an H3Model.
| parent | Optional parent QObject. |
Definition at line 11 of file h3Model.cpp.
References maxZoom_c, minZoom_c, and zoomToRes_.
|
override |
|
private |
Adds a new cell to the model.
| res | Cell resolution. |
| index | H3 cell index. |
| polygon | Cell polygon coordinates. |
| color | Cell display color. |
Definition at line 158 of file h3Model.cpp.
References findCellByID(), isClearing_, and pathCells_.
Referenced by onCellComputed().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Adds pentagon cells to the model.
Definition at line 178 of file h3Model.cpp.
References H3_VIEWER::Helper::indexToPolygon(), and onCellComputed().
Here is the call graph for this function:| void H3Model::clearAllCells | ( | ) |
Clears all cells from the model.
Definition at line 271 of file h3Model.cpp.
References clearingFinished(), isClearing_, and pathCells_.
Referenced by requestCells().
Here is the call graph for this function:
Here is the caller graph for this function:| void H3Model::clearingFinished | ( | ) |
Emitted when cell clearing completes.
Referenced by clearAllCells().
Here is the caller graph for this function:
|
inlinenoexcept |
Gets cell coordinates for map display.
Definition at line 125 of file h3Model.h.
References coordinates_.
| void H3Model::coordinatesChanged | ( | ) |
Emitted when coordinates property changes.
Referenced by onCellsComputed().
Here is the caller graph for this function:
|
override |
Returns data for a cell at the given index.
| index | Model index. |
| role | Data role to retrieve. |
Definition at line 36 of file h3Model.cpp.
References CellColor, data(), IndexRole, pathCells_, PathRole, and ResRole.
Referenced by data().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Finds a cell by its H3 index.
| id | H3 cell index. |
Definition at line 146 of file h3Model.cpp.
References pathCells_.
Referenced by addCell(), and onPathCellsBatch().
Here is the caller graph for this function:
|
private |
Finds a cell by its resolution.
| res | Cell resolution. |
Definition at line 138 of file h3Model.cpp.
References pathCells_.
|
private |
Gets the display color for a resolution level.
| resolution | Cell resolution (3-15). |
Definition at line 154 of file h3Model.cpp.
References resolutionColors_c.
Referenced by onCellComputed(), and onPathCellsBatch().
Here is the caller graph for this function:| void H3Model::Init | ( | ) |
Initializes the model and starts worker thread.
Must be called after construction to set up the worker thread and maze adapter.
Definition at line 64 of file h3Model.cpp.
References H3_VIEWER::H3Worker::cellComputed(), H3_VIEWER::H3Worker::cellsComputed(), H3_VIEWER::H3Worker::doWork(), H3MazeAdapter::generateMazeAsync(), mazeAdapter_, mazeBoundsGenerated(), mazeCenter_, mazeCenterChanged(), H3_VIEWER::H3Worker::mazePolygonsComputed(), mazeRadius_, mazeRadiusChanged(), H3MazeAdapter::mazeRadiusComputed(), H3MazeAdapter::mazeWallsGenerated(), mazeWallsGenerated(), onCellComputed(), onCellsComputed(), onMazePolygonsComputed(), onSearchStats(), H3_VIEWER::H3Worker::searchStats(), H3_VIEWER::H3Worker::setWalls(), thread_, and worker_.
Referenced by EntryPoint::InitDataModels().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Validates if a coordinate is a valid target.
| zoom | Current zoom level. |
| coordinate | Target coordinate. |
Definition at line 127 of file h3Model.cpp.
References maxZoom_c.
| void H3Model::mazeBoundsGenerated | ( | const QGeoCoordinate & | center, |
| double | radiusMeters | ||
| ) |
Emitted with maze boundary information.
Referenced by Init(), and EntryPoint::InitDataModels().
Here is the caller graph for this function:
|
inlinenoexcept |
Gets the geographic center of the maze.
Definition at line 143 of file h3Model.h.
References mazeCenter_.
| void H3Model::mazeCenterChanged | ( | ) |
|
inlinenoexcept |
Gets maze wall polygons.
Definition at line 131 of file h3Model.h.
References mazePolygons_.
| void H3Model::mazePolygonsChanged | ( | ) |
Emitted when maze polygons change.
Referenced by onMazePolygonsComputed().
Here is the caller graph for this function:
|
inlinenoexcept |
Gets the maze boundary radius.
Definition at line 149 of file h3Model.h.
References mazeRadius_.
| void H3Model::mazeRadiusChanged | ( | ) |
| void H3Model::mazeWallsGenerated | ( | const std::unordered_set< H3Index > & | walls | ) |
Emitted when maze walls are generated.
Referenced by Init(), and EntryPoint::InitDataModels().
Here is the caller graph for this function:
|
private |
Handles individual cell computation during search.
| res | Cell resolution. |
| index | H3 cell index. |
| polygon | Cell polygon coordinates. |
| isSearching | Whether this is during active search. |
Definition at line 200 of file h3Model.cpp.
References addCell(), getColorForResolution(), and isClearing_.
Referenced by addPentagons(), and Init().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Handles batch cell computation results.
| list | List of computed cell data. |
Definition at line 195 of file h3Model.cpp.
References coordinates_, and coordinatesChanged().
Referenced by Init().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Handles maze polygon computation results.
| polygons | Vector of polygon coordinate lists. |
Definition at line 295 of file h3Model.cpp.
References isClearing_, mazePolygons_, and mazePolygonsChanged().
Referenced by Init().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Handles batch cell computation for path visualization (optimized).
| cells | Vector of cell data tuples (res, index, polygon). |
Definition at line 215 of file h3Model.cpp.
References findCellByID(), getColorForResolution(), isClearing_, and pathCells_.
Here is the call graph for this function:
|
private |
Handles search statistics update.
| exploredCells | Number of cells explored. |
| timeMs | Search time in milliseconds. |
| pathLength | Length of found path. |
Definition at line 311 of file h3Model.cpp.
References searchStatsChanged(), and searchStatsText_.
Referenced by Init().
Here is the call graph for this function:
Here is the caller graph for this function:| void H3Model::requestCells | ( | const std::vector< H3Index > & | indexes | ) |
Requests visualization of specific cells.
| indexes | Vector of H3 cell indices to display. |
Definition at line 255 of file h3Model.cpp.
References clearAllCells(), isClearing_, pathCells_, H3_VIEWER::H3Worker::requestCell(), and worker_.
Referenced by EntryPoint::InitDataModels().
Here is the call graph for this function:
Here is the caller graph for this function:
|
override |
|
override |
Returns the number of cells in the model.
| parent | Parent index (unused for list models). |
Definition at line 31 of file h3Model.cpp.
References pathCells_.
| void H3Model::searchStatsChanged | ( | ) |
Emitted when search statistics update.
Referenced by onSearchStats().
Here is the caller graph for this function:
|
inlinenoexcept |
Gets search statistics as formatted text.
Definition at line 137 of file h3Model.h.
References searchStatsText_.
|
private |
Cell coordinates for display.
Definition at line 285 of file h3Model.h.
Referenced by coordinates(), and onCellsComputed().
|
private |
Flag indicating clearing in progress.
Definition at line 301 of file h3Model.h.
Referenced by addCell(), clearAllCells(), onCellComputed(), onMazePolygonsComputed(), onPathCellsBatch(), and requestCells().
|
private |
Maximum supported zoom level.
Definition at line 292 of file h3Model.h.
Referenced by H3Model(), and isCoordinateTargetValid().
|
private |
|
private |
Maze center coordinate.
Definition at line 288 of file h3Model.h.
Referenced by Init(), and mazeCenter().
|
private |
Maze wall polygons.
Definition at line 286 of file h3Model.h.
Referenced by mazePolygons(), and onMazePolygonsComputed().
|
private |
Maze boundary radius in meters.
Definition at line 289 of file h3Model.h.
Referenced by Init(), and mazeRadius().
|
private |
|
private |
Cells that are part of the current path.
Definition at line 284 of file h3Model.h.
Referenced by ~H3Model(), addCell(), clearAllCells(), data(), findCellByID(), findCellByRes(), onPathCellsBatch(), requestCells(), and rowCount().
|
private |
Color palette for different resolutions.
Definition at line 296 of file h3Model.h.
Referenced by getColorForResolution().
|
private |
Formatted search statistics.
Definition at line 287 of file h3Model.h.
Referenced by onSearchStats(), and searchStatsText().
|
private |
|
private |
Worker for async operations.
Definition at line 280 of file h3Model.h.
Referenced by ~H3Model(), Init(), and requestCells().
|
private |