KOSMIndoorMap

overlaysource.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_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
20
21namespace KOSMIndoorMap {
22
23class AbstractOverlaySourcePrivate;
24
25/** A source for overlay elements, drawn on top of the static map data. */
26class KOSMINDOORMAP_EXPORT AbstractOverlaySource : public QObject
27{
28 Q_OBJECT
29public:
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;
37
38 /** Indicates the being of a scene graph update.
39 * @see SceneGraph
40 */
41 virtual void beginSwap();
42 /** Indicates the end of a scene graph update.
43 * At this point dynamically created and no longer needed OSM elements can safely be deleted.
44 */
45 virtual void endSwap();
46
47 // HACK this still needs a proper solution for dynamic geometry
48 /** Nodes for newly created geometry. */
49 [[nodiscard]] virtual const std::vector<OSM::Node>* transientNodes() const;
50
51Q_SIGNALS:
52 /** Trigger map re-rendering when the source changes. */
53 void update();
54
55 /** Trigger style re-compilation.
56 * This is needed for example when the source added new tag keys that the map data
57 * didn't previously contain (and thus would be optimized out of the style).
58 */
59 void reset();
60
61protected:
62 explicit AbstractOverlaySource(QObject *parent);
63 explicit AbstractOverlaySource(AbstractOverlaySourcePrivate *dd, QObject *parent);
64 std::unique_ptr<AbstractOverlaySourcePrivate> d_ptr;
65 Q_DECLARE_PRIVATE(AbstractOverlaySource)
66};
67
68class ModelOverlaySourcePrivate;
69
70/** A source for overlay elements, based on a QAbstractItemModel as input. */
71class KOSMINDOORMAP_EXPORT ModelOverlaySource : public AbstractOverlaySource
72{
73 Q_OBJECT
74public:
75 explicit ModelOverlaySource(QAbstractItemModel *model, QObject *parent = nullptr);
77
78 /** Iteration interface with floor level filtering. */
79 void forEach(int floorLevel, const std::function<void(OSM::Element, int)> &func) const override;
80
81 /** Adds hidden elements to @param elems. */
82 void hiddenElements(std::vector<OSM::Element> &elems) const override;
83
84private:
85 Q_DECLARE_PRIVATE(ModelOverlaySource)
86};
87
88}
89
90#endif // KOSMINDOORMAP_OVERLAYSOURCE_H
A source for overlay elements, drawn on top of the static map data.
void reset()
Trigger style re-compilation.
void update()
Trigger map re-rendering when the source changes.
virtual void forEach(int floorLevel, const std::function< void(OSM::Element, int)> &func) const =0
Iteration interface with floor level filtering.
A source for overlay elements, based on a QAbstractItemModel as input.
A reference to any of OSM::Node/OSM::Way/OSM::Relation.
Definition element.h:24
OSM-based multi-floor indoor maps for buildings.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:17:55 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.