QGIS API Documentation  3.24.2-Tisler (13c1a02865)
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 Qt3DCore
43 {
44  class QTransform;
45 }
46 
47 namespace QgsRayCastingUtils
48 {
49  class Ray3D;
50 }
51 
52 class Qgs3DMapSettings;
53 class QgsTerrainTextureGenerator;
55 class QgsMapLayer;
57 class TerrainMapUpdateJobFactory;
58 
65 class QgsTerrainEntity : public QgsChunkedEntity
66 {
67  Q_OBJECT
68  public:
70  explicit QgsTerrainEntity( const Qgs3DMapSettings &map, Qt3DCore::QNode *parent = nullptr );
71 
72  ~QgsTerrainEntity() override;
73 
75  const Qgs3DMapSettings &map3D() const { return mMap; }
77  QgsTerrainTextureGenerator *textureGenerator() { return mTextureGenerator; }
79  const QgsCoordinateTransform &terrainToMapTransform() const { return *mTerrainToMapTransform; }
80 
82  Qt3DRender::QObjectPicker *terrainPicker() const { return mTerrainPicker; }
84  Qt3DCore::QTransform *transform() const { return mTerrainTransform; }
86  float terrainElevationOffset() const;
87 
89  bool rayIntersection( const QgsRayCastingUtils::Ray3D &ray, QVector3D &intersectionPoint );
90 
91  private slots:
92  void onShowBoundingBoxesChanged();
93  void invalidateMapImages();
94  void onLayersChanged();
95  void onTerrainElevationOffsetChanged( float newOffset );
96 
97  private:
98 
99  void connectToLayersRepaintRequest();
100 
101  const Qgs3DMapSettings &mMap;
103  Qt3DRender::QObjectPicker *mTerrainPicker = nullptr;
104  QgsTerrainTextureGenerator *mTextureGenerator = nullptr;
105  QgsCoordinateTransform *mTerrainToMapTransform = nullptr;
106  Qt3DCore::QTransform *mTerrainTransform = nullptr;
107 
108  std::unique_ptr<TerrainMapUpdateJobFactory> mUpdateJobFactory;
109 
111  QList<QgsMapLayer *> mLayers;
112 };
113 
114 
115 
117 class TerrainMapUpdateJob : public QgsChunkQueueJob
118 {
119  Q_OBJECT
120  public:
121  TerrainMapUpdateJob( QgsTerrainTextureGenerator *textureGenerator, QgsChunkNode *mNode );
122 
123  void cancel() override;
124 
125  private slots:
126  void onTileReady( int jobId, const QImage &image );
127 
128  private:
129  QgsTerrainTextureGenerator *mTextureGenerator = nullptr;
130  int mJobId;
131 };
132 
134 
135 #endif // QGSTERRAINENTITY_P_H
Class for doing transforms between two map coordinate systems.
Base class for all map layer types.
Definition: qgsmaplayer.h:73