KOSMIndoorMap

mapitem.h
1/*
2 SPDX-FileCopyrightText: 2020 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef KOSMINDOORMAP_MAPITEM_H
8#define KOSMINDOORMAP_MAPITEM_H
9
10#include "osmelement.h"
11
12#include <KOSMIndoorMap/FloorLevelModel>
13#include <KOSMIndoorMap/MapData>
14#include <KOSMIndoorMap/MapCSSStyle>
15#include <KOSMIndoorMap/MapLoader>
16#include <KOSMIndoorMap/PainterRenderer>
17#include <KOSMIndoorMap/SceneController>
18#include <KOSMIndoorMap/SceneGraph>
19#include <KOSMIndoorMap/View>
20
21#include <QQuickPaintedItem>
22
23namespace KOSMIndoorMap {
24
25class MapCSSLoader;
26class MapData;
27
28/** Map renderer for the IndoorMap QML item.
29 * @internal Do not use directly!
30 */
32{
34 Q_PROPERTY(KOSMIndoorMap::MapLoader* loader READ loader CONSTANT)
35 Q_PROPERTY(KOSMIndoorMap::View* view READ view CONSTANT)
36 Q_PROPERTY(QString styleSheet READ styleSheetName WRITE setStylesheetName NOTIFY styleSheetChanged)
37 Q_PROPERTY(KOSMIndoorMap::FloorLevelModel* floorLevels READ floorLevelModel CONSTANT)
38
39 /** There's a loading error (data not found, network issue, broken style sheet, etc). */
40 Q_PROPERTY(bool hasError READ hasError NOTIFY errorChanged)
41 /** Details on the error. */
42 Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorChanged)
43
44 Q_PROPERTY(KOSMIndoorMap::MapData mapData READ mapData NOTIFY mapDataChanged)
45
46 /** Sources for overlays that should be rendered on top of the map. */
47 Q_PROPERTY(QVariant overlaySources READ overlaySources WRITE setOverlaySources NOTIFY overlaySourcesChanged)
48
49 /** ISO 3166-1/2 country or region code this map area is in.
50 * Used for interpreting opening hours expressions.
51 */
52 Q_PROPERTY(QString region READ region WRITE setRegion NOTIFY regionChanged)
53
54 /** IANA timezone id of the timezone this map area is in.
55 * Used for interpreting opening hours expressions.
56 */
57 Q_PROPERTY(QString timeZone READ timeZoneId WRITE setTimeZoneId NOTIFY timeZoneChanged)
58
59 /** Currently hovered element. */
60 Q_PROPERTY(KOSMIndoorMap::OSMElement hoveredElement READ hoveredElement WRITE setHoveredElement NOTIFY hoveredElementChanged)
61
62public:
63 explicit MapItem(QQuickItem *parent = nullptr);
64 ~MapItem();
65
66 void paint(QPainter *painter) override;
67
68 [[nodiscard]] MapLoader* loader() const;
69 [[nodiscard]] View* view() const;
70
71 [[nodiscard]] QString styleSheetName() const;
72 void setStylesheetName(const QString &styleSheet);
73
74 [[nodiscard]] FloorLevelModel *floorLevelModel() const;
75
76 [[nodiscard]] Q_INVOKABLE KOSMIndoorMap::OSMElement elementAt(double x, double y) const;
77
78 [[nodiscard]] bool hasError() const;
79 [[nodiscard]] QString errorMessage() const;
80
81 [[nodiscard]] QString region() const;
82 void setRegion(const QString &region);
83 [[nodiscard]] QString timeZoneId() const;
84 void setTimeZoneId(const QString &tz);
85
87 void mapDataChanged();
88 void styleSheetChanged();
89 void currentFloorLevelChanged();
90 void errorChanged();
91 void overlaySourcesChanged();
92 void regionChanged();
93 void timeZoneChanged();
94 void hoveredElementChanged();
95
96protected:
97 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
98
99private:
100 void clear();
101 void loaderDone();
102 [[nodiscard]] MapData mapData() const;
103 [[nodiscard]] QVariant overlaySources() const;
104 void setOverlaySources(const QVariant &overlays);
105
106 void addOverlaySource(std::vector<QPointer<AbstractOverlaySource>> &overlaySources, const QVariant &source);
107 void overlayUpdate();
108 void overlayReset();
109
110 [[nodiscard]] OSMElement hoveredElement() const;
111 void setHoveredElement(const OSMElement &element);
112
113 MapLoader *m_loader = nullptr;
114 MapData m_data;
115 SceneGraph m_sg;
116 View *m_view = nullptr;
117 QUrl m_styleSheetUrl;
118 MapCSSLoader *m_styleLoader = nullptr;
119 MapCSSStyle m_style;
120 SceneController m_controller;
121 PainterRenderer m_renderer;
122 FloorLevelModel *m_floorLevelModel = nullptr;
123 QString m_errorMessage;
124 QVariant m_overlaySources;
125 std::vector<std::unique_ptr<AbstractOverlaySource>> m_ownedOverlaySources;
126};
127
128}
129
130#endif // KOSMINDOORMAP_MAPITEM_H
A source for overlay elements, drawn on top of the static map data.
Asynchronous loader for (remote) MapCSS assets.
A parsed MapCSS style sheet.
Definition mapcssstyle.h:33
Raw OSM map data, separated by levels.
Definition mapdata.h:60
Map renderer for the IndoorMap QML item.
Definition mapitem.h:32
bool hasError
There's a loading error (data not found, network issue, broken style sheet, etc).
Definition mapitem.h:40
KOSMIndoorMap::OSMElement hoveredElement
Currently hovered element.
Definition mapitem.h:60
QVariant overlaySources
Sources for overlays that should be rendered on top of the map.
Definition mapitem.h:47
QString region
ISO 3166-1/2 country or region code this map area is in.
Definition mapitem.h:52
QString timeZone
IANA timezone id of the timezone this map area is in.
Definition mapitem.h:57
QString errorMessage
Details on the error.
Definition mapitem.h:42
Loader for OSM data for a single station or airport.
Definition maploader.h:29
QML wrapper around an OSM element.
Definition osmelement.h:21
QPainter-based renderer of a SceneGraph.
Creates/updates the scene graph based on a given style sheet and view.
Scene graph of the currently displayed level.
Definition scenegraph.h:29
View transformations and transformation manipulation.
Definition view.h:40
OSM-based multi-floor indoor maps for buildings.
Q_INVOKABLEQ_INVOKABLE
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 11 2024 12:16:37 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.