KOSMIndoorMap

painterrenderer.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_PAINTERRENDERER_H
8 #define KOSMINDOORMAP_PAINTERRENDERER_H
9 
10 #include "kosmindoormap_export.h"
11 
12 #include <KOSMIndoorMap/SceneGraphItem>
13 
14 class QPainter;
15 
16 namespace KOSMIndoorMap {
17 
18 class SceneGraph;
19 class View;
20 
21 /** QPainter-based renderer of a SceneGraph.
22  * Trying to keep this somewhat backend-agnostic to possibly implement a 3D renderer in the future.
23  */
24 class KOSMINDOORMAP_EXPORT PainterRenderer
25 {
26 public:
27  explicit PainterRenderer();
28  ~PainterRenderer();
29 
30  void setPainter(QPainter *painter);
31  void render(const SceneGraph &sg, View *view);
32 
33 private:
34  void beginRender();
35  void beginPhase(SceneGraphItemPayload::RenderPhase phase);
36  void renderBackground(const QColor &bgColor);
37  void renderPolygon(PolygonItem *item, SceneGraphItemPayload::RenderPhase phase);
38  void renderMultiPolygon(MultiPolygonItem *item, SceneGraphItemPayload::RenderPhase phase);
39  void renderPolyline(PolylineItem *item, SceneGraphItemPayload::RenderPhase phase);
40  void renderLabel(LabelItem *item);
41  void renderForeground(const QColor &bgColor);
42  void endRender();
43 
44  double mapToSceneWidth(double width, Unit unit) const;
45 
46  QPainter *m_painter = nullptr;
47  View *m_view = nullptr;
48 
49  std::vector<SceneGraphItemPayload*> m_renderBatch; // member rather than function-local to preserve allocations
50 };
51 
52 }
53 
54 #endif // KOSMINDOORMAP_PAINTERRENDERER_H
OSM-based multi-floor indoor maps for buildings.
A path/way/line item in the scenegraph.
Scene graph of the currently displayed level.
Definition: scenegraph.h:28
View transformations and transformation manipulation.
Definition: view.h:39
A text or item label.
Multi-polygon item, used for polygons with "holes" in them.
QPainter-based renderer of a SceneGraph.
A single filled polygon.
Unit
Unit for geometry sizes.
RenderPhase
See MapCSS spec: "Within a layer, first all fills are rendered, then all casings, then all strokes...
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Oct 23 2021 23:03:45 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.