qHexWalker 0.0.1
Hexagonal Grid Pathfinding & Maze Visualization on Interactive Maps
Loading...
Searching...
No Matches
entryPoint.cpp
Go to the documentation of this file.
1#include "entryPoint.h"
2
3#include "h3Model.h"
4#include "h3TargetsModel.h"
5
6#include "logger.h"
7
8#include "mapProvider.h"
9
10#include <qdir.h>
11
12EntryPoint::EntryPoint(const std::string &loggerName, QObject *parent) : QObject(parent) {
13 InitLogger(loggerName);
14
15 engine_ = new QQmlApplicationEngine(this);
16
18 InitMap();
19 InitEngine();
20
21 connect(engine_, &QQmlApplicationEngine::quit, &QGuiApplication::quit);
22}
23
24EntryPoint::~EntryPoint() = default;
25
26void EntryPoint::InitLogger(const std::string_view loggerName) {
27 try {
28 logger_ = std::make_unique<TD::Logger>(loggerName);
29 } catch (const std::exception &e) {
30 printf("%s", e.what());
31 }
32}
34 h3Model_ = new H3Model(this);
35 engine_->rootContext()->setContextProperty("h3Model", h3Model_);
36 try {
37 h3Model_->Init();
38 } catch (const std::exception &e) {
39 spdlog::critical(e.what());
40 }
41
42 targetsModel_ = new H3TargetsModel(this);
43 engine_->rootContext()->setContextProperty("targetsModel", targetsModel_);
44
49 Qt::QueuedConnection);
50}
52 mapProvider_ = new MapProvider(this);
53 engine_->rootContext()->setContextProperty("mapProvider", mapProvider_);
54 spdlog::info("Map url -> {}", pathUrl_c.toStdString());
55
57
58 // #ifndef __APPLE__
59 // const QString pathToMap = "mbtiles://" + QDir::currentPath() + QDir::separator() + "maplibre.mbtiles";
60 // mapProvider_->exchangeUrlOffline(pathToMap);
61 // #else
62 // mapProvider_->setUrl(pathUrl_c);
63 // #endif
64}
65
67 const QUrl url("qrc:/QHexWalker/ui/main.qml");
68 connect(
69 engine_, &QQmlApplicationEngine::objectCreated, this,
70 [this, url](QObject *obj, const QUrl &objUrl) {
71 if (!obj && url == objUrl) {
72 QCoreApplication::exit(-1);
73 }
74 if (url == objUrl) {
75 rootWindow_ = qobject_cast<QQuickWindow *>(obj);
76 if (!rootWindow_) {
77 qWarning() << "QQuickWindow is not root-object!";
78 }
79 }
80 },
81 Qt::QueuedConnection);
82
83 engine_->load(url);
84}
MapProvider * mapProvider_
Map tile provider.
Definition entryPoint.h:123
QQuickWindow * rootWindow_
Root window reference.
Definition entryPoint.h:118
std::unique_ptr< TD::Logger > logger_
Logger instance.
Definition entryPoint.h:120
EntryPoint(const std::string &loggerName, QObject *parent=nullptr)
Constructs and initializes the application.
~EntryPoint() override
Destructor.
void InitEngine()
Initializes the QML engine and loads the UI.
H3TargetsModel * targetsModel_
Waypoint targets model.
Definition entryPoint.h:122
H3Model * h3Model_
Hexagonal cell model.
Definition entryPoint.h:121
void InitMap()
Initializes the map provider and style.
QQmlApplicationEngine * engine_
QML application engine.
Definition entryPoint.h:117
void InitLogger(std::string_view loggerName)
Initializes the spdlog logging system.
const QString pathUrl_c
Default MapTiler API URL for map tiles.
Definition entryPoint.h:107
void InitDataModels()
Initializes data models (H3Model, H3TargetsModel).
Qt model for H3 hexagonal cell visualization and management.
Definition h3Model.h:58
void requestCells(const std::vector< H3Index > &indexes)
Requests visualization of specific cells.
Definition h3Model.cpp:255
void mazeWallsGenerated(const std::unordered_set< H3Index > &walls)
Emitted when maze walls are generated.
void mazeBoundsGenerated(const QGeoCoordinate &center, double radiusMeters)
Emitted with maze boundary information.
void Init()
Initializes the model and starts worker thread.
Definition h3Model.cpp:64
void onCompute(const std::vector< H3Index > &indexes)
void setMazeWalls(const std::unordered_set< H3Index > &walls)
void setMazeBounds(const QGeoCoordinate &center, double radiusMeters)
public::void onRemoveCell(const std::vector< H3Index > &indexes)
void setUrl(const QString &url) noexcept
Definition mapProvider.h:22
Application entry point and initialization orchestrator.
Qt list model for managing H3 hexagonal cells and pathfinding visualization.