KOSMIndoorMap

scenecontroller.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_SCENECONTROLLER_H
8#define KOSMINDOORMAP_SCENECONTROLLER_H
9
10#include "kosmindoormap_export.h"
11
12#include "scenegraphitem.h"
13
14#include <memory>
15#include <vector>
16
17class QPolygonF;
18class QString;
19
20namespace OSM {
21class Element;
22}
23
24namespace KOSMIndoorMap {
25
26class AbstractOverlaySource;
27class MapData;
28class MapCSSDeclaration;
29class MapCSSResultLayer;
30class MapCSSStyle;
31class SceneControllerPrivate;
32class SceneGraph;
33class View;
34
35/** Creates/updates the scene graph based on a given style sheet and view. */
36class KOSMINDOORMAP_EXPORT SceneController
37{
38public:
39 explicit SceneController();
41
42 void setMapData(const MapData &data);
43 void setStyleSheet(const MapCSSStyle *styleSheet);
44 void setView(const View *view);
45 void setOverlaySources(std::vector<QPointer<AbstractOverlaySource>> &&overlays);
46 /** Overlay dirty state tracking. */
47 void overlaySourceUpdated();
48
49 /** Set currently hovered element. */
50 [[nodiscard]] OSM::Element hoveredElement() const;
51 void setHoveredElement(OSM::Element element);
52
53 /** Creates or updates @p sg based on the currently set style and view settings.
54 * When possible, provide the scene graph of the previous run to re-use scene graph elements that didn't change.
55 */
56 void updateScene(SceneGraph &sg) const;
57
58private:
59 void updateCanvas(SceneGraph &sg) const;
60 void updateElement(OSM::Element e, int level, SceneGraph &sg) const;
61 void updateElement(OSM::Element e, int level, SceneGraph &sg, const MapCSSResultLayer &result) const;
62
63 [[nodiscard]] QPolygonF createPolygon(OSM::Element e) const;
64 [[nodiscard]] QPainterPath createPath(OSM::Element e, QPolygonF &outerPath) const;
65
66 void applyGenericStyle(const MapCSSDeclaration *decl, SceneGraphItemPayload *item) const;
67 void applyPenStyle(OSM::Element e, const MapCSSDeclaration *decl, QPen &pen, double &opacity, Unit &unit) const;
68 void applyCasingPenStyle(OSM::Element e, const MapCSSDeclaration *decl, QPen &pen, double &opacity, Unit &unit) const;
69 void applyFontStyle(const MapCSSDeclaration *decl, QFont &font) const;
70
71 void initializePen(QPen &pen) const;
72 void finalizePen(QPen &pen, double opacity) const;
73
74 void addItem(SceneGraph &sg, OSM::Element e, int level, const MapCSSResultLayer &result, std::unique_ptr<SceneGraphItemPayload> &&payload) const;
75
76 std::unique_ptr<SceneControllerPrivate> d;
77};
78
79}
80
81#endif // KOSMINDOORMAP_SCENECONTROLLER_H
Result of MapCSS stylesheet evaluation for a single layer selector.
A parsed MapCSS style sheet.
Definition mapcssstyle.h:33
Raw OSM map data, separated by levels.
Definition mapdata.h:60
Creates/updates the scene graph based on a given style sheet and view.
Payload base class for scene graph items.
Scene graph of the currently displayed level.
Definition scenegraph.h:29
View transformations and transformation manipulation.
Definition view.h:40
A reference to any of OSM::Node/OSM::Way/OSM::Relation.
Definition element.h:24
OSM-based multi-floor indoor maps for buildings.
Unit
Unit for geometry sizes.
Low-level types and functions to work with raw OSM data as efficiently as possible.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.