KOSMIndoorMap

mapitem.h
1 /*
2  SPDX-FileCopyrightText: 2020 Volker Krause <[email protected]>
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 
23 namespace KOSMIndoorMap {
24 
25 class MapData;
26 
27 /** Map renderer for the IndoorMap QML item.
28  * @internal Do not use directly!
29  */
30 class MapItem : public QQuickPaintedItem
31 {
32  Q_OBJECT
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 public:
59  explicit MapItem(QQuickItem *parent = nullptr);
60  ~MapItem();
61 
62  void paint(QPainter *painter) override;
63 
64  MapLoader* loader() const;
65  View* view() const;
66 
67  QString styleSheetName() const;
68  void setStylesheetName(const QString &styleSheet);
69 
70  FloorLevelModel *floorLevelModel() const;
71 
72  Q_INVOKABLE KOSMIndoorMap::OSMElement elementAt(double x, double y) const;
73 
74  bool hasError() const;
75  QString errorMessage() const;
76 
77  QString region() const;
78  void setRegion(const QString &region);
79  QString timeZoneId() const;
80  void setTimeZoneId(const QString &tz);
81 
82 Q_SIGNALS:
83  void mapDataChanged();
84  void styleSheetChanged();
85  void currentFloorLevelChanged();
86  void errorChanged();
87  void overlaySourcesChanged();
88  void regionChanged();
89  void timeZoneChanged();
90 
91 protected:
92  void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) override;
93 
94 private:
95  void clear();
96  void loaderDone();
97  MapData mapData() const;
98  QVariant overlaySources() const;
99  void setOverlaySources(const QVariant &overlays);
100 
101  void addOverlaySource(std::vector<QPointer<AbstractOverlaySource>> &overlaySources, const QVariant &source);
102  void overlayUpdate();
103  void overlayReset();
104 
105  MapLoader *m_loader = nullptr;
106  MapData m_data;
107  SceneGraph m_sg;
108  View *m_view = nullptr;
109  QString m_styleSheetName;
110  MapCSSStyle m_style;
111  SceneController m_controller;
112  PainterRenderer m_renderer;
113  FloorLevelModel *m_floorLevelModel = nullptr;
114  QString m_errorMessage;
115  QVariant m_overlaySources;
116  std::vector<std::unique_ptr<AbstractOverlaySource>> m_ownedOverlaySources;
117 };
118 
119 }
120 
121 #endif // KOSMINDOORMAP_MAPITEM_H
OSM-based multi-floor indoor maps for buildings.
QML wrapper around an OSM element.
Definition: osmelement.h:18
Loader for OSM data for a single station or airport.
Definition: maploader.h:24
Scene graph of the currently displayed level.
Definition: scenegraph.h:28
A parsed MapCSS style sheet.
Definition: mapcssstyle.h:29
View transformations and transformation manipulation.
Definition: view.h:39
Q_SIGNALSQ_SIGNALS
Creates/updates the scene graph based on a given style sheet and view.
Q_OBJECTQ_OBJECT
QPainter-based renderer of a SceneGraph.
Raw OSM map data, separated by levels.
Definition: mapdata.h:59
qreal x() const const
Q_PROPERTY(...)
QString timeZone
IANA timezone id of the timezone this map area is in.
Definition: mapitem.h:56
A source for overlay elements, drawn on top of the static map data.
Definition: overlaysource.h:26
Q_INVOKABLEQ_INVOKABLE
Map renderer for the IndoorMap QML item.
Definition: mapitem.h:30
qreal y() const const
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 23:04:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.