-
-
Notifications
You must be signed in to change notification settings - Fork 3k
/
qgspointcloudlayerrenderer.h
138 lines (105 loc) · 3.95 KB
/
qgspointcloudlayerrenderer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/***************************************************************************
qgspointcloudlayerrenderer.h
--------------------
begin : October 2020
copyright : (C) 2020 by Peter Petrik
email : zilolv at gmail dot com
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSPOINTCLOUDLAYERRENDERER_H
#define QGSPOINTCLOUDLAYERRENDERER_H
#include "qgis_core.h"
#include "qgscolorramp.h"
#include "qgsmaplayerrenderer.h"
#include "qgsreadwritecontext.h"
#include "qgspointcloudindex.h"
#include <QDomElement>
#include <QString>
#include <QPainter>
class QgsRenderContext;
class QgsPointCloudLayer;
class QgsPointCloudRenderer;
class QgsPointCloudRenderContext;
#define SIP_NO_FILE
///@cond PRIVATE
/**
* Configuration of the 2d renderer
*/
class CORE_EXPORT QgsPointCloudRendererConfig
{
public:
//! Ctor
QgsPointCloudRendererConfig();
//! Copy constructor
QgsPointCloudRendererConfig( const QgsPointCloudRendererConfig &other );
//! Assignment constructor
QgsPointCloudRendererConfig &operator= ( const QgsPointCloudRendererConfig &other );
//! Returns z min
double zMin() const;
//! Sets z min
void setZMin( double value );
//! Returns z max
double zMax() const;
//! Sets z max
void setZMax( double value );
//! Returns pen width
int penWidth() const;
//! Sets pen width
void setPenWidth( int value );
//! Returns color ramp
QgsColorRamp *colorRamp() const;
//! Sets color ramp (ownership is transferrred)
void setColorRamp( QgsColorRamp *value SIP_TRANSFER );
//! Returns maximum allowed screen error in pixels
float maximumScreenError() const;
QString attribute() const;
void setAttribute( const QString &attribute );
private:
double mZMin = 0, mZMax = 0;
QString mAttribute;
int mPenWidth = 1;
std::unique_ptr<QgsColorRamp> mColorRamp;
float mMaximumScreenError = 5;
};
///@endcond
/**
* \ingroup core
*
* Implementation of threaded rendering for point cloud layers.
*
* \note The API is considered EXPERIMENTAL and can be changed without a notice
* \note Not available in Python bindings
*
* \since QGIS 3.18
*/
class CORE_EXPORT QgsPointCloudLayerRenderer: public QgsMapLayerRenderer
{
public:
//! Ctor
explicit QgsPointCloudLayerRenderer( QgsPointCloudLayer *layer, QgsRenderContext &context );
~QgsPointCloudLayerRenderer();
bool render() override;
private:
//! Traverses tree and returns all nodes in specified depth
QList<IndexedPointCloudNode> traverseTree( const QgsPointCloudIndex *pc, const QgsRenderContext &context, IndexedPointCloudNode n, float maxErrorPixels, float nodeErrorPixels );
QgsPointCloudLayer *mLayer = nullptr;
std::unique_ptr< QgsPointCloudRenderer > mRenderer;
QgsPointCloudRendererConfig mConfig;
QgsVector3D mScale;
QgsVector3D mOffset;
QgsPointCloudAttributeCollection mAttributes;
// int imgW, imgH; // DO WE NEED AT ALL?
// QgsPointCloudDataBounds mBounds; // DO WE NEED AT ALL?
// some stats
int nodesDrawn = 0;
int pointsDrawn = 0;
void drawData( QgsPointCloudRenderContext &context, const QgsPointCloudBlock *data, const QgsPointCloudRendererConfig &config );
};
#endif // QGSPOINTCLOUDLAYERRENDERER_H