QGIS API Documentation  3.20.0-Odense (decaadbb31)
qgsrulebasedchunkloader_p.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsrulebasedchunkloader_p.h
3  --------------------------------------
4  Date : November 2019
5  Copyright : (C) 2019 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 QGSRULEBASEDCHUNKLOADER_H
17 #define QGSRULEBASEDCHUNKLOADER_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 "qgschunkloader_p.h"
31 #include "qgsfeature3dhandler_p.h"
32 #include "qgschunkedentity_p.h"
33 #include "qgsrulebased3drenderer.h"
34 #include <QFutureWatcher>
35 
36 #define SIP_NO_FILE
37 
38 class Qgs3DMapSettings;
39 class QgsVectorLayer;
42 class QgsFeature3DHandler;
43 
44 namespace Qt3DCore
45 {
46  class QTransform;
47 }
48 
56 class QgsRuleBasedChunkLoaderFactory : public QgsQuadtreeChunkLoaderFactory
57 {
58  public:
60  QgsRuleBasedChunkLoaderFactory( const Qgs3DMapSettings &map, QgsVectorLayer *vl, QgsRuleBased3DRenderer::Rule *rootRule, int leafLevel, double zMin, double zMax );
61  ~QgsRuleBasedChunkLoaderFactory() override;
62 
64  virtual QgsChunkLoader *createChunkLoader( QgsChunkNode *node ) const override;
65 
66  const Qgs3DMapSettings &mMap;
67  QgsVectorLayer *mLayer;
68  std::unique_ptr<QgsRuleBased3DRenderer::Rule> mRootRule;
69  int mLeafLevel;
70 };
71 
72 
81 class QgsRuleBasedChunkLoader : public QgsChunkLoader
82 {
83  public:
85  QgsRuleBasedChunkLoader( const QgsRuleBasedChunkLoaderFactory *factory, QgsChunkNode *node );
86  ~QgsRuleBasedChunkLoader() override;
87 
88  virtual void cancel() override;
89  virtual Qt3DCore::QEntity *createEntity( Qt3DCore::QEntity *parent ) override;
90 
91  private:
92  const QgsRuleBasedChunkLoaderFactory *mFactory;
94  Qgs3DRenderContext mContext;
95  std::unique_ptr<QgsVectorLayerFeatureSource> mSource;
96  bool mCanceled = false;
97  QFutureWatcher<void> *mFutureWatcher = nullptr;
98  std::unique_ptr<QgsRuleBased3DRenderer::Rule> mRootRule;
99 };
100 
101 
113 class QgsRuleBasedChunkedEntity : public QgsChunkedEntity
114 {
115  Q_OBJECT
116  public:
118  explicit QgsRuleBasedChunkedEntity( QgsVectorLayer *vl, double zMin, double zMax, const QgsVectorLayer3DTilingSettings &tilingSettings, QgsRuleBased3DRenderer::Rule *rootRule, const Qgs3DMapSettings &map );
119 
120  ~QgsRuleBasedChunkedEntity();
121  private slots:
122  void onTerrainElevationOffsetChanged( float newOffset );
123  private:
124  Qt3DCore::QTransform *mTransform = nullptr;
125 };
126 
128 
129 #endif // QGSRULEBASEDCHUNKLOADER_H
QHash< const QgsRuleBased3DRenderer::Rule *, QgsFeature3DHandler * > RuleToHandlerMap
Partial snapshot of vector layer's state (only the members necessary for access to features)
Represents a vector layer which manages a vector based data sets.