KOSMIndoorMap

painterrenderer.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_PAINTERRENDERER_H
8#define KOSMINDOORMAP_PAINTERRENDERER_H
9
10#include "kosmindoormap_export.h"
11
12#include <KOSMIndoorMap/SceneGraphItem>
13
14class QPainter;
15
16namespace KOSMIndoorMap {
17
18class SceneGraph;
19class 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 */
24class KOSMINDOORMAP_EXPORT PainterRenderer
25{
26public:
27 explicit PainterRenderer();
29
30 void setPainter(QPainter *painter);
31 void render(const SceneGraph &sg, View *view);
32
33private:
34 void beginRender();
35 void beginPhase(SceneGraphItemPayload::RenderPhase phase);
36 void prepareBatch(SceneGraphItemPayload::RenderPhase phase);
37 void renderBackground(const QColor &bgColor);
38 void renderPolygon(PolygonItem *item, SceneGraphItemPayload::RenderPhase phase);
39 void renderMultiPolygon(MultiPolygonItem *item, SceneGraphItemPayload::RenderPhase phase);
40 void renderPolyline(PolylineItem *item, SceneGraphItemPayload::RenderPhase phase);
41 void renderLabel(LabelItem *item, SceneGraphItemPayload::RenderPhase phase);
42 void renderForeground(const QColor &bgColor);
43 void endRender();
44
45 template <typename T>
46 void renderPolygonFill(PolygonBaseItem *item, const T &geom);
47 template <typename T>
48 void renderPolygonLine(PolygonBaseItem *item, const T &geom);
49 template <typename T>
50 void renderPolygonCasing(PolygonBaseItem *item, const T &geom);
51
52 [[nodiscard]] double mapToSceneWidth(double width, Unit unit) const;
53 // inverse view transformation with translation applied
54 // needed for textured brushes
55 [[nodiscard]] QTransform brushTransform() const;
56
57 QPainter *m_painter = nullptr;
58 View *m_view = nullptr;
59
60 std::vector<SceneGraphItemPayload*> m_renderBatch; // member rather than function-local to preserve allocations
61};
62
63}
64
65#endif // KOSMINDOORMAP_PAINTERRENDERER_H
A text or icon label.
Multi-polygon item, used for polygons with "holes" in them.
QPainter-based renderer of a SceneGraph.
Base item for filled polygons.
A single filled polygon.
A path/way/line item in the scenegraph.
RenderPhase
See MapCSS spec: "Within a layer, first all fills are rendered, then all casings, then all strokes,...
Scene graph of the currently displayed level.
Definition scenegraph.h:29
View transformations and transformation manipulation.
Definition view.h:40
OSM-based multi-floor indoor maps for buildings.
Unit
Unit for geometry sizes.
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.