QGIS API Documentation  3.0.2-Girona (307d082)
qgsdemterraintileloader_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsdemterraintileloader_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 QGSDEMTERRAINTILELOADER_P_H
17 #define QGSDEMTERRAINTILELOADER_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 <QtConcurrent/QtConcurrentRun>
31 #include <QFutureWatcher>
32 #include <QElapsedTimer>
33 
34 #include "qgsrectangle.h"
35 #include "qgsterraintileloader_p.h"
36 #include "qgstilingscheme.h"
37 
39 class QgsRasterLayer;
40 
46 class QgsDemTerrainTileLoader : public QgsTerrainTileLoader
47 {
48  Q_OBJECT
49  public:
51  QgsDemTerrainTileLoader( QgsTerrainEntity *terrain, QgsChunkNode *node );
52 
53  Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
54 
55  private slots:
56  void onHeightMapReady( int jobId, const QByteArray &heightMap );
57 
58  private:
59 
60  int mHeightMapJobId;
61  QByteArray mHeightMap;
62  int mResolution;
63  float mSkirtHeight;
64 };
65 
66 
67 
73 class QgsDemHeightMapGenerator : public QObject
74 {
75  Q_OBJECT
76  public:
77 
82  QgsDemHeightMapGenerator( QgsRasterLayer *dtm, const QgsTilingScheme &tilingScheme, int resolution );
83  ~QgsDemHeightMapGenerator() override;
84 
86  int render( int x, int y, int z );
87 
89  QByteArray renderSynchronously( int x, int y, int z );
90 
92  int resolution() const { return mResolution; }
93 
95  float heightAt( double x, double y );
96 
97  signals:
99  void heightMapReady( int jobId, const QByteArray &heightMap );
100 
101  private slots:
102  void onFutureFinished();
103 
104  private:
106  QgsRasterLayer *mDtm = nullptr;
107 
109  QgsRasterDataProvider *mClonedProvider = nullptr;
110 
111  QgsTilingScheme mTilingScheme;
112 
113  int mResolution;
114 
115  int mLastJobId;
116 
117  struct JobData
118  {
119  int jobId;
120  QgsRectangle extent;
121  QFuture<QByteArray> future;
122  QFutureWatcher<QByteArray> *fw;
123  QElapsedTimer timer;
124  };
125 
126  QHash<QFutureWatcher<QByteArray>*, JobData> mJobs;
127 
129  QByteArray mDtmCoarseData;
130 };
131 
133 
134 #endif // QGSDEMTERRAINTILELOADER_P_H
A rectangle specified with double values.
Definition: qgsrectangle.h:39
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
3 The class encapsulates tiling scheme (just like with WMTS / TMS / XYZ layers).
Base class for raster data providers.