-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrenderlayer.h
130 lines (89 loc) · 2.75 KB
/
renderlayer.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
#ifndef RENDERLAYER_H
#define RENDERLAYER_H
#include <QDebug>
#include <QRectF>
#include "ogr_core.h"
#include "ogrsf_frmts.h"
//#include "ui_openglwindow.h"
#include <QMatrix4x4>
#include <QOpenGLBuffer>
#include <QOpenGLContext>
#include <QOpenGLFunctions>
#include <QOpenGLShaderProgram>
#include <QOpenGLVertexArrayObject>
#include <QtMath>
#include "gpc.h"
#include "rtreeindex.h"
// 头文件的互相引用,声明位置导致的问题。需要前置声明,并在CPP文件中包含定义。
// 在ui_openglwindow.h头文件中,Ui_OpenGLWindow出现在了类定义之前,所以要先声明
class Ui_OpenGLWindow;
class OpenGLWindow;
class RenderLayer {
public:
static Ui_OpenGLWindow *windowUi;
static OpenGLWindow *window;
RenderLayer(const char *str, int indexGrid = 5);
~RenderLayer();
// 外接矩形
OGREnvelope boundary;
QRectF boundaryQ;
// 依赖的图层
OGRLayer *layer;
QVector<OGRFeature *> features;
// 建立网格索引的密度
int indexGrid;
// 网格索引数量,indexGrid^2
int gridCount;
// 每个网格,保存着要素的引用
QVector<OGRFeature *> *gridArray;
// 外接矩形数组,用来判断要素落在哪个网格内
OGREnvelope *envelopeArray;
// 顶点数组
QVector<float> vertexVector;
// 画面时,面的分隔数组
QVector<int> vertexIndex;
// 要素类型
int geoType = 0;
QOpenGLBuffer vboOrigin;
QOpenGLVertexArrayObject vaoOrigin;
QOpenGLBuffer vboTriangular;
QOpenGLVertexArrayObject vaoTriangular;
QOpenGLBuffer vboSelect;
QOpenGLVertexArrayObject vaoSelect;
QOpenGLBuffer vboDensity;
QOpenGLVertexArrayObject vaoDensity;
QOpenGLBuffer vboRTree;
QOpenGLVertexArrayObject vaoRTree;
QOpenGLShaderProgram *shader = nullptr;
void renderInit(QOpenGLShaderProgram *shader);
void render();
float lineWidth = 2.f;
void selectFeature(float x, float y);
void selectFeature(float x, float y, float x2, float y2);
QString queryString;
bool concreteSelect = false;
void calculateDensity(float radius = 0.1, float resolution = 300);
void exportDensity(float x, float y, float dx, float dy, int xCount,
int yCount, QVector<float> data);
float layerHeight = 0;
private:
RenderLayer(OGRLayer *layer, int indexGrid = 5);
int appendFeature(OGRFeature *feature, QVector<float> &vertexVector,
QVector<int> &vertexIndex);
// 三角化
void triangulate();
// 三角化结果
QVector<float> triResult;
QVector<int> triIndex;
// 选择要素
QVector<float> selectVertex;
QVector<int> selectVertexIndex;
QVector<float> densityVertex;
QVector<float> RTreeVertex;
RTreeIndex rindex;
// 取随机数
static float randF();
float dx;
float dy;
};
#endif // RENDERLAYER_H