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 MapCSSState;
32class SceneControllerPrivate;
33class SceneGraph;
34class View;
35
36/** Creates/updates the scene graph based on a given style sheet and view. */
37class KOSMINDOORMAP_EXPORT SceneController
38{
39public:
40 explicit SceneController();
42
43 void setMapData(const MapData &data);
44 void setStyleSheet(const MapCSSStyle *styleSheet);
45 void setView(const View *view);
46 void setOverlaySources(std::vector<QPointer<AbstractOverlaySource>> &&overlays);
47 /** Overlay dirty state tracking. */
48 void overlaySourceUpdated();
49
50 /** Set currently hovered element. */
51 [[nodiscard]] OSM::Element hoveredElement() const;
52 void setHoveredElement(OSM::Element element);
53
54 /** Creates or updates @p sg based on the currently set style and view settings.
55 * When possible, provide the scene graph of the previous run to re-use scene graph elements that didn't change.
56 */
57 void updateScene(SceneGraph &sg) const;
58
59private:
60 void updateCanvas(SceneGraph &sg) const;
61 void updateElement(OSM::Element e, int level, SceneGraph &sg) const;
62 void updateElement(const MapCSSState &state, int level, SceneGraph &sg, const MapCSSResultLayer &result) const;
63
64 [[nodiscard]] QPolygonF createPolygon(OSM::Element e) const;
65 [[nodiscard]] QPainterPath createPath(OSM::Element e, QPolygonF &outerPath) const;
66
67 void applyGenericStyle(const MapCSSDeclaration *decl, SceneGraphItemPayload *item) const;
68 void applyPenStyle(OSM::Element e, const MapCSSDeclaration *decl, QPen &pen, double &opacity, Unit &unit) const;
69 void applyCasingPenStyle(OSM::Element e, const MapCSSDeclaration *decl, QPen &pen, double &opacity, Unit &unit) const;
70 void applyFontStyle(const MapCSSDeclaration *decl, QFont &font) const;
71
72 void initializePen(QPen &pen) const;
73 void finalizePen(QPen &pen, double opacity) const;
74
75 void addItem(SceneGraph &sg, const MapCSSState &state, int level, const MapCSSResultLayer &result, std::unique_ptr<SceneGraphItemPayload> &&payload) const;
76
77 std::unique_ptr<SceneControllerPrivate> d;
78};
79
80}
81
82#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 Fri Dec 20 2024 11:55:21 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.