QGIS API Documentation 4.1.0-Master (d6fb7a379fb)
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"
24#include "qgscesiumutils.h"
26#include "qgsmaplayerrenderer.h"
28#include "qgstiledsceneindex.h"
29
30#include <QElapsedTimer>
31#include <QHash>
32#include <QImage>
33#include <QSet>
34
35#define SIP_NO_FILE
36
38class QgsFeedback;
42
43namespace tinygltf
44{
45 struct Image;
46 class Model;
47 class Node;
48 class TinyGLTF;
49 struct Primitive;
50} //namespace tinygltf
51
63{
64 public:
68
69 bool render() override;
70 Qgis::MapLayerRendererFlags flags() const override;
71 bool forceRasterRender() const override;
72 QgsFeedback *feedback() const override { return mFeedback.get(); }
73
74 private:
75 QgsTiledSceneRequest createBaseRequest();
76
77 bool renderTiles( QgsTiledSceneRenderContext &context );
78
79 void renderTile( const QgsTiledSceneTile &tile, QgsTiledSceneRenderContext &context );
80
86 bool renderTileContent( const QgsTiledSceneTile &tile, QgsTiledSceneRenderContext &context );
87
88 void renderModel(
89 tinygltf::Model &model, const QgsVector3D &centerOffset, const std::optional<QgsCesiumUtils::TileI3dmData> &tileInstancing, const QgsTiledSceneTile &tile, QgsTiledSceneRenderContext &context
90 );
91
92 void renderPrimitive(
93 const tinygltf::Model &model,
94 const tinygltf::Primitive &primitive,
95 const QgsTiledSceneTile &tile,
96 const QgsVector3D &tileTranslationEcef,
97 const QMatrix4x4 *gltfLocalTransform,
98 Qgis::Axis gltfUpAxis,
99 const QString &contentUri,
101 );
102
103 void renderTrianglePrimitive(
104 const tinygltf::Model &model,
105 const tinygltf::Primitive &primitive,
106 const QgsTiledSceneTile &tile,
107 const QgsVector3D &tileTranslationEcef,
108 const QMatrix4x4 *gltfLocalTransform,
109 Qgis::Axis gltfUpAxis,
110 const QString &contentUri,
112 );
113
114 void renderLinePrimitive(
115 const tinygltf::Model &model,
116 const tinygltf::Primitive &primitive,
117 const QgsTiledSceneTile &tile,
118 const QgsVector3D &tileTranslationEcef,
119 const QMatrix4x4 *gltfLocalTransform,
120 Qgis::Axis gltfUpAxis,
121 const QString &contentUri,
123 );
124
125 QString mLayerName;
126
127 std::unique_ptr< QgsTiledSceneRenderer > mRenderer;
128 bool mRenderTileBorders = false;
129
130 QList< QgsMapClippingRegion > mClippingRegions;
131
134 QgsTiledSceneBoundingVolume mLayerBoundingVolume;
135 QgsTiledSceneIndex mIndex;
136
137 QgsCoordinateTransform mSceneToMapTransform;
138
139 enum class PrimitiveType
140 {
141 Line,
142 Triangle
143 };
144
145 struct PrimitiveData
146 {
147 PrimitiveType type;
148 QPolygonF coordinates;
149 float z;
150 QPair< int, int > textureId { -1, -1 };
151 float textureCoords[6];
152 };
153
154 QVector< PrimitiveData > mPrimitiveData;
155
156 int mCurrentModelId = 0;
157 QHash< QPair< int, int >, QImage > mTextures;
158
159 struct TileDetails
160 {
161 QPolygonF boundary;
162 bool hasContent = false;
163 QString id;
164 };
165 QVector< TileDetails > mTileDetails;
166
167 std::unique_ptr<QgsFeedback> mFeedback;
168 QSet< int > mWarnedPrimitiveTypes;
169
170 QElapsedTimer mElapsedTimer;
171
172 bool mEnableProfile = false;
173 quint64 mPreparationTime = 0;
174};
175
176#endif // QGSTILEDSCENELAYERRENDERER_H
QFlags< MapLayerRendererFlag > MapLayerRendererFlags
Flags which control how map layer renderers behave.
Definition qgis.h:2960
Axis
Cartesian axes.
Definition qgis.h:2607
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