KOSMIndoorMap

overlaysource.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_OVERLAYSOURCE_H
8 #define KOSMINDOORMAP_OVERLAYSOURCE_H
9 
10 #include "kosmindoormap_export.h"
11 
12 #include <KOSM/Element>
13 
14 #include <QObject>
15 #include <QPointer>
16 
17 #include <functional>
18 
19 class QAbstractItemModel;
20 
21 namespace KOSMIndoorMap {
22 
23 class AbstractOverlaySourcePrivate;
24 
25 /** A source for overlay elements, drawn on top of the static map data. */
26 class KOSMINDOORMAP_EXPORT AbstractOverlaySource : public QObject
27 {
28  Q_OBJECT
29 public:
30  virtual ~AbstractOverlaySource();
31 
32  /** Iteration interface with floor level filtering. */
33  virtual void forEach(int floorLevel, const std::function<void(OSM::Element, int)> &func) const = 0;
34 
35  /** Adds hidden elements to @param elems. */
36  virtual void hiddenElements(std::vector<OSM::Element> &elems) const = 0;
37 
38 Q_SIGNALS:
39  /** Trigger map re-rendering when the source changes. */
40  void update();
41 
42  /** Trigger style re-compilation.
43  * This is needed for example when the source added new tag keys that the map data
44  * didn't previously contain (and thus would be optimized out of the style).
45  */
46  void reset();
47 
48 protected:
49  explicit AbstractOverlaySource(AbstractOverlaySourcePrivate *dd, QObject *parent);
50  std::unique_ptr<AbstractOverlaySourcePrivate> d_ptr;
51  Q_DECLARE_PRIVATE(AbstractOverlaySource)
52 };
53 
54 class ModelOverlaySourcePrivate;
55 
56 /** A source for overlay elements, based on a QAbstractItemModel as input. */
57 class KOSMINDOORMAP_EXPORT ModelOverlaySource : public AbstractOverlaySource
58 {
59  Q_OBJECT
60 public:
61  explicit ModelOverlaySource(QAbstractItemModel *model, QObject *parent = nullptr);
63 
64  /** Iteration interface with floor level filtering. */
65  void forEach(int floorLevel, const std::function<void(OSM::Element, int)> &func) const override;
66 
67  /** Adds hidden elements to @param elems. */
68  void hiddenElements(std::vector<OSM::Element> &elems) const override;
69 
70 private:
71  Q_DECLARE_PRIVATE(ModelOverlaySource)
72 };
73 
74 }
75 
76 #endif // KOSMINDOORMAP_OVERLAYSOURCE_H
A source for overlay elements, based on a QAbstractItemModel as input.
Definition: overlaysource.h:57
OSM-based multi-floor indoor maps for buildings.
A reference to any of OSM::Node/OSMWay/OSMRelation.
Definition: element.h:22
A source for overlay elements, drawn on top of the static map data.
Definition: overlaysource.h:26
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Sep 25 2021 23:05:04 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.