QGIS API Documentation 4.1.0-Master (009143bf4b4)
Loading...
Searching...
No Matches
qgstiledscenelayerrenderer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgstiledscenelayerrenderer.h
3 --------------------
4 begin : June 2023
5 copyright : (C) 2023 by Nyall Dawson
6 email : nyall dot dawson at gmail dot com
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSTILEDSCENELAYERRENDERER_H
19#define QGSTILEDSCENELAYERRENDERER_H
20
21#include <memory>
22
23#include "qgis_core.h"
25#include "qgsmaplayerrenderer.h"
27#include "qgstiledsceneindex.h"
28
29#include <QElapsedTimer>
30#include <QHash>
31#include <QImage>
32#include <QSet>
33
34#define SIP_NO_FILE
35
37class QgsFeedback;
41
42namespace tinygltf
43{
44 struct Image;
45 class Model;
46 class Node;
47 class TinyGLTF;
48 struct Primitive;
49} //namespace tinygltf
50
62{
63 public:
67
68 bool render() override;
69 Qgis::MapLayerRendererFlags flags() const override;
70 bool forceRasterRender() const override;
71 QgsFeedback *feedback() const override { return mFeedback.get(); }
72
73 private:
74 QgsTiledSceneRequest createBaseRequest();
75
76 bool renderTiles( QgsTiledSceneRenderContext &context );
77
78 void renderTile( const QgsTiledSceneTile &tile, QgsTiledSceneRenderContext &context );
79
85 bool renderTileContent( const QgsTiledSceneTile &tile, QgsTiledSceneRenderContext &context );
86
87 void renderModel( tinygltf::Model &model, const QgsVector3D &centerOffset, const QgsTiledSceneTile &tile, QgsTiledSceneRenderContext &context );
88
89 void renderPrimitive(
90 const tinygltf::Model &model,
91 const tinygltf::Primitive &primitive,
92 const QgsTiledSceneTile &tile,
93 const QgsVector3D &tileTranslationEcef,
94 const QMatrix4x4 *gltfLocalTransform,
95 const QString &contentUri,
97 );
98
99 void renderTrianglePrimitive(
100 const tinygltf::Model &model,
101 const tinygltf::Primitive &primitive,
102 const QgsTiledSceneTile &tile,
103 const QgsVector3D &tileTranslationEcef,
104 const QMatrix4x4 *gltfLocalTransform,
105 const QString &contentUri,
107 );
108
109 void renderLinePrimitive(
110 const tinygltf::Model &model,
111 const tinygltf::Primitive &primitive,
112 const QgsTiledSceneTile &tile,
113 const QgsVector3D &tileTranslationEcef,
114 const QMatrix4x4 *gltfLocalTransform,
115 const QString &contentUri,
117 );
118
119 QString mLayerName;
120
121 std::unique_ptr< QgsTiledSceneRenderer > mRenderer;
122 bool mRenderTileBorders = false;
123
124 QList< QgsMapClippingRegion > mClippingRegions;
125
128 QgsTiledSceneBoundingVolume mLayerBoundingVolume;
129 QgsTiledSceneIndex mIndex;
130
131 QgsCoordinateTransform mSceneToMapTransform;
132
133 enum class PrimitiveType
134 {
135 Line,
136 Triangle
137 };
138
139 struct PrimitiveData
140 {
141 PrimitiveType type;
142 QPolygonF coordinates;
143 float z;
144 QPair< int, int > textureId { -1, -1 };
145 float textureCoords[6];
146 };
147
148 QVector< PrimitiveData > mPrimitiveData;
149
150 int mCurrentModelId = 0;
151 QHash< QPair< int, int >, QImage > mTextures;
152
153 struct TileDetails
154 {
155 QPolygonF boundary;
156 bool hasContent = false;
157 QString id;
158 };
159 QVector< TileDetails > mTileDetails;
160
161 std::unique_ptr<QgsFeedback> mFeedback;
162 QSet< int > mWarnedPrimitiveTypes;
163
164 QElapsedTimer mElapsedTimer;
165
166 bool mEnableProfile = false;
167 quint64 mPreparationTime = 0;
168};
169
170#endif // QGSTILEDSCENELAYERRENDERER_H
QFlags< MapLayerRendererFlag > MapLayerRendererFlags
Flags which control how map layer renderers behave.
Definition qgis.h:2946
Represents a coordinate reference system (CRS).
Handles coordinate transforms between two coordinate systems.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
A map clipping region (in map coordinates and CRS).
virtual bool render()=0
Do the rendering (based on data stored in the class).
virtual bool forceRasterRender() const
Returns true if the renderer must be rendered to a raster paint device (e.g.
virtual Qgis::MapLayerRendererFlags flags() const
Returns flags which control how the map layer rendering behaves.
QgsMapLayerRenderer(const QString &layerID, QgsRenderContext *context=nullptr)
Constructor for QgsMapLayerRenderer, with the associated layerID and render context.
Contains information about the context of a rendering operation.
Represents a bounding volume for a tiled scene.
An index for tiled scene data providers.
QgsTiledSceneLayerRenderer(QgsTiledSceneLayer *layer, QgsRenderContext &context)
Ctor.
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be nullptr).
~QgsTiledSceneLayerRenderer() override
Represents a map layer supporting display of tiled scene objects.
Encapsulates the render context for a 2D tiled scene rendering operation.
Abstract base class for 2d tiled scene renderers.
Tiled scene data request.
Represents an individual tile from a tiled scene data source.
A 3D vector (similar to QVector3D) with the difference that it uses double precision instead of singl...
Definition qgsvector3d.h:33