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 MapData;
26
27/** Map renderer for the IndoorMap QML item.
28 * @internal Do not use directly!
29 */
31{
33 Q_PROPERTY(KOSMIndoorMap::MapLoader* loader READ loader CONSTANT)
34 Q_PROPERTY(KOSMIndoorMap::View* view READ view CONSTANT)
35 Q_PROPERTY(QString styleSheet READ styleSheetName WRITE setStylesheetName NOTIFY styleSheetChanged)
36 Q_PROPERTY(KOSMIndoorMap::FloorLevelModel* floorLevels READ floorLevelModel CONSTANT)
37
38 /** There's a loading error (data not found, network issue, broken style sheet, etc). */
39 Q_PROPERTY(bool hasError READ hasError NOTIFY errorChanged)
40 /** Details on the error. */
41 Q_PROPERTY(QString errorMessage READ errorMessage NOTIFY errorChanged)
42
43 Q_PROPERTY(KOSMIndoorMap::MapData mapData READ mapData NOTIFY mapDataChanged)
44
45 /** Sources for overlays that should be rendered on top of the map. */
46 Q_PROPERTY(QVariant overlaySources READ overlaySources WRITE setOverlaySources NOTIFY overlaySourcesChanged)
47
48 /** ISO 3166-1/2 country or region code this map area is in.
49 * Used for interpreting opening hours expressions.
50 */
51 Q_PROPERTY(QString region READ region WRITE setRegion NOTIFY regionChanged)
52
53 /** IANA timezone id of the timezone this map area is in.
54 * Used for interpreting opening hours expressions.
55 */
56 Q_PROPERTY(QString timeZone READ timeZoneId WRITE setTimeZoneId NOTIFY timeZoneChanged)
57
58 /** Currently hovered element. */
59 Q_PROPERTY(KOSMIndoorMap::OSMElement hoveredElement READ hoveredElement WRITE setHoveredElement NOTIFY hoveredElementChanged)
60
61public:
62 explicit MapItem(QQuickItem *parent = nullptr);
63 ~MapItem();
64
65 void paint(QPainter *painter) override;
66
67 [[nodiscard]] MapLoader* loader() const;
68 [[nodiscard]] View* view() const;
69
70 [[nodiscard]] QString styleSheetName() const;
71 void setStylesheetName(const QString &styleSheet);
72
73 [[nodiscard]] FloorLevelModel *floorLevelModel() const;
74
75 [[nodiscard]] Q_INVOKABLE KOSMIndoorMap::OSMElement elementAt(double x, double y) const;
76
77 [[nodiscard]] bool hasError() const;
78 [[nodiscard]] QString errorMessage() const;
79
80 [[nodiscard]] QString region() const;
81 void setRegion(const QString &region);
82 [[nodiscard]] QString timeZoneId() const;
83 void setTimeZoneId(const QString &tz);
84
86 void mapDataChanged();
87 void styleSheetChanged();
88 void currentFloorLevelChanged();
89 void errorChanged();
90 void overlaySourcesChanged();
91 void regionChanged();
92 void timeZoneChanged();
93 void hoveredElementChanged();
94
95protected:
96 void geometryChange(const QRectF &newGeometry, const QRectF &oldGeometry) override;
97
98private:
99 void clear();
100 void loaderDone();
101 [[nodiscard]] MapData mapData() const;
102 [[nodiscard]] QVariant overlaySources() const;
103 void setOverlaySources(const QVariant &overlays);
104
105 void addOverlaySource(std::vector<QPointer<AbstractOverlaySource>> &overlaySources, const QVariant &source);
106 void overlayUpdate();
107 void overlayReset();
108
109 [[nodiscard]] OSMElement hoveredElement() const;
110 void setHoveredElement(const OSMElement &element);
111
112 MapLoader *m_loader = nullptr;
113 MapData m_data;
114 SceneGraph m_sg;
115 View *m_view = nullptr;
116 QString m_styleSheetName;
117 MapCSSStyle m_style;
118 SceneController m_controller;
119 PainterRenderer m_renderer;
120 FloorLevelModel *m_floorLevelModel = nullptr;
121 QString m_errorMessage;
122 QVariant m_overlaySources;
123 std::vector<std::unique_ptr<AbstractOverlaySource>> m_ownedOverlaySources;
124};
125
126}
127
128#endif // KOSMINDOORMAP_MAPITEM_H
A source for overlay elements, drawn on top of the static map data.
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:31
bool hasError
There's a loading error (data not found, network issue, broken style sheet, etc).
Definition mapitem.h:39
KOSMIndoorMap::OSMElement hoveredElement
Currently hovered element.
Definition mapitem.h:59
QVariant overlaySources
Sources for overlays that should be rendered on top of the map.
Definition mapitem.h:46
QString region
ISO 3166-1/2 country or region code this map area is in.
Definition mapitem.h:51
QString timeZone
IANA timezone id of the timezone this map area is in.
Definition mapitem.h:56
QString errorMessage
Details on the error.
Definition mapitem.h:41
Loader for OSM data for a single station or airport.
Definition maploader.h:29
QML wrapper around an OSM element.
Definition osmelement.h:19
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 May 3 2024 11:50:52 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.