QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsterrainentity_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsterrainentity_p.h
3  --------------------------------------
4  Date : July 2017
5  Copyright : (C) 2017 by Martin Dobias
6  Email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSTERRAINENTITY_P_H
17 #define QGSTERRAINENTITY_P_H
18 
20 
21 //
22 // W A R N I N G
23 // -------------
24 //
25 // This file is not part of the QGIS API. It exists purely as an
26 // implementation detail. This header file may change from version to
27 // version without notice, or even be removed.
28 //
29 
30 #define SIP_NO_FILE
31 
32 #include "qgschunkedentity_p.h"
33 #include "qgschunkqueuejob_p.h"
34 
35 #include <memory>
36 
37 namespace Qt3DRender
38 {
39  class QObjectPicker;
40 }
41 
42 namespace QgsRayCastingUtils
43 {
44  class Ray3D;
45 }
46 
47 class Qgs3DMapSettings;
48 class QgsTerrainTextureGenerator;
50 class QgsMapLayer;
52 class TerrainMapUpdateJobFactory;
53 
60 class QgsTerrainEntity : public QgsChunkedEntity
61 {
62  Q_OBJECT
63  public:
65  explicit QgsTerrainEntity( int maxLevel, const Qgs3DMapSettings &map, Qt3DCore::QNode *parent = nullptr );
66 
67  ~QgsTerrainEntity() override;
68 
70  const Qgs3DMapSettings &map3D() const { return mMap; }
72  QgsTerrainTextureGenerator *textureGenerator() { return mTextureGenerator; }
74  const QgsCoordinateTransform &terrainToMapTransform() const { return *mTerrainToMapTransform; }
75 
77  Qt3DRender::QObjectPicker *terrainPicker() const { return mTerrainPicker; }
78 
80  bool rayIntersection( const QgsRayCastingUtils::Ray3D &ray, QVector3D &intersectionPoint );
81 
82  private slots:
83  void onShowBoundingBoxesChanged();
84  void invalidateMapImages();
85  void onLayersChanged();
86 
87  private:
88 
89  void connectToLayersRepaintRequest();
90 
91  const Qgs3DMapSettings &mMap;
93  Qt3DRender::QObjectPicker *mTerrainPicker = nullptr;
94  QgsTerrainTextureGenerator *mTextureGenerator = nullptr;
95  QgsCoordinateTransform *mTerrainToMapTransform = nullptr;
96 
97  std::unique_ptr<TerrainMapUpdateJobFactory> mUpdateJobFactory;
98 
100  QList<QgsMapLayer *> mLayers;
101 };
102 
103 
104 
106 class TerrainMapUpdateJob : public QgsChunkQueueJob
107 {
108  Q_OBJECT
109  public:
110  TerrainMapUpdateJob( QgsTerrainTextureGenerator *textureGenerator, QgsChunkNode *mNode );
111 
112  void cancel() override;
113 
114  private slots:
115  void onTileReady( int jobId, const QImage &image );
116 
117  private:
118  QgsTerrainTextureGenerator *mTextureGenerator = nullptr;
119  int mJobId;
120 };
121 
123 
124 #endif // QGSTERRAINENTITY_P_H
qgschunkqueuejob_p.h
QgsTerrainGenerator
3 Base class for generators of terrain.
Definition: qgsterraingenerator.h:48
qgschunkedentity_p.h
Qt3DRender
Definition: qgs3dmapscene.h:27
Qgs3DMapSettings
3 Definition of the world
Definition: qgs3dmapsettings.h:54
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:53