QGIS API Documentation  3.6.0-Noosa (5873452)
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 #include "qgschunkedentity_p.h"
31 #include "qgschunkqueuejob_p.h"
32 
33 #include <memory>
34 
35 namespace Qt3DRender
36 {
37  class QObjectPicker;
38 }
39 
40 namespace QgsRayCastingUtils
41 {
42  class Ray3D;
43 }
44 
45 class Qgs3DMapSettings;
46 class QgsTerrainTextureGenerator;
48 class QgsMapLayer;
50 class TerrainMapUpdateJobFactory;
51 
58 class QgsTerrainEntity : public QgsChunkedEntity
59 {
60  Q_OBJECT
61  public:
63  explicit QgsTerrainEntity( int maxLevel, const Qgs3DMapSettings &map, Qt3DCore::QNode *parent = nullptr );
64 
65  ~QgsTerrainEntity() override;
66 
68  const Qgs3DMapSettings &map3D() const { return mMap; }
70  QgsTerrainTextureGenerator *textureGenerator() { return mTextureGenerator; }
72  const QgsCoordinateTransform &terrainToMapTransform() const { return *mTerrainToMapTransform; }
73 
75  Qt3DRender::QObjectPicker *terrainPicker() const { return mTerrainPicker; }
76 
78  bool rayIntersection( const QgsRayCastingUtils::Ray3D &ray, QVector3D &intersectionPoint );
79 
80  private slots:
81  void onShowBoundingBoxesChanged();
82  void invalidateMapImages();
83  void onLayersChanged();
84 
85  private:
86 
87  void connectToLayersRepaintRequest();
88 
89  const Qgs3DMapSettings &mMap;
91  Qt3DRender::QObjectPicker *mTerrainPicker = nullptr;
92  QgsTerrainTextureGenerator *mTextureGenerator = nullptr;
93  QgsCoordinateTransform *mTerrainToMapTransform = nullptr;
94 
95  std::unique_ptr<TerrainMapUpdateJobFactory> mUpdateJobFactory;
96 
98  QList<QgsMapLayer *> mLayers;
99 };
100 
101 
102 
104 class TerrainMapUpdateJob : public QgsChunkQueueJob
105 {
106  Q_OBJECT
107  public:
108  TerrainMapUpdateJob( QgsTerrainTextureGenerator *textureGenerator, QgsChunkNode *mNode );
109 
110  void cancel() override;
111 
112  private slots:
113  void onTileReady( int jobId, const QImage &image );
114 
115  private:
116  QgsTerrainTextureGenerator *mTextureGenerator = nullptr;
117  int mJobId;
118 };
119 
121 
122 #endif // QGSTERRAINENTITY_P_H
Base class for all map layer types.
Definition: qgsmaplayer.h:64
3 Definition of the world
3 Base class for generators of terrain.
Class for doing transforms between two map coordinate systems.