KOSMIndoorMap

scenecontroller.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_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 
17 class QPolygonF;
18 class QString;
19 
20 namespace OSM {
21 class Element;
22 }
23 
24 namespace KOSMIndoorMap {
25 
26 class AbstractOverlaySource;
27 class MapData;
28 class MapCSSDeclaration;
29 class MapCSSResultItem;
30 class MapCSSStyle;
31 class SceneControllerPrivate;
32 class SceneGraph;
33 class View;
34 
35 /** Creates/updates the scene graph based on a given style sheet and view. */
36 class KOSMINDOORMAP_EXPORT SceneController
37 {
38 public:
39  explicit SceneController();
40  ~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  /** Creates or updates @p sg based on the currently set style and view settings.
50  * When possible, provide the scene graph of the previous run to re-use scene graph elements that didn't change.
51  */
52  void updateScene(SceneGraph &sg) const;
53 
54 private:
55  void updateCanvas(SceneGraph &sg) const;
56  void updateElement(OSM::Element e, int level, SceneGraph &sg) const;
57  void updateElement(OSM::Element e, int level, SceneGraph &sg, const MapCSSResultItem &result) const;
58 
59  QPolygonF createPolygon(OSM::Element e) const;
60  QPainterPath createPath(OSM::Element e, QPolygonF &outerPath) const;
61 
62  void applyGenericStyle(const MapCSSDeclaration *decl, SceneGraphItemPayload *item) const;
63  void applyPenStyle(OSM::Element e, const MapCSSDeclaration *decl, QPen &pen, double &opacity, Unit &unit) const;
64  void applyCasingPenStyle(OSM::Element e, const MapCSSDeclaration *decl, QPen &pen, double &opacity, Unit &unit) const;
65  void applyFontStyle(const MapCSSDeclaration *decl, QFont &font) const;
66 
67  void initializePen(QPen &pen) const;
68  void finalizePen(QPen &pen, double opacity) const;
69 
70  void addItem(SceneGraph &sg, OSM::Element e, int level, LayerSelectorKey layerSelector, std::unique_ptr<SceneGraphItemPayload> &&payload) const;
71 
72  std::unique_ptr<SceneControllerPrivate> d;
73 };
74 
75 }
76 
77 #endif // KOSMINDOORMAP_SCENECONTROLLER_H
OSM-based multi-floor indoor maps for buildings.
Scene graph of the currently displayed level.
Definition: scenegraph.h:28
Payload base class for scene graph items.
A parsed MapCSS style sheet.
Definition: mapcssstyle.h:29
View transformations and transformation manipulation.
Definition: view.h:39
A reference to any of OSM::Node/OSMWay/OSMRelation.
Definition: element.h:22
Creates/updates the scene graph based on a given style sheet and view.
Raw OSM map data, separated by levels.
Definition: mapdata.h:59
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-2021 The KDE developers.
Generated on Sat Oct 16 2021 23:05:32 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.