/
qgslinematerial_p.h
80 lines (66 loc) · 2.63 KB
/
qgslinematerial_p.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
/***************************************************************************
qgslinematerial_p.h
--------------------------------------
Date : Apr 2019
Copyright : (C) 2019 by Martin Dobias
Email : wonder dot sk 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 QGSLINEMATERIAL_P_H
#define QGSLINEMATERIAL_P_H
/// @cond PRIVATE
//
// W A R N I N G
// -------------
//
// This file is not part of the QGIS API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//
#include <Qt3DRender/QMaterial>
namespace Qt3DRender
{
class QCamera;
}
/**
* \ingroup 3d
* Implementation of material that renders 3D linestrings.
*
* Supports:
* - arbitrary line width (in pixels)
* - bevel and miter line joins (including limit for miter join to avoid very long miters on sharp angles)
* - flat line caps
* - alpha blending
*
* The material needs information about viewport size (to correctly scale line widths) and to camera
* parameters (to correctly clip lines).
*
* It is implemented by using a geometry shader that accepts primitive type Line strip with adjacency
* (i.e. we have access to points p1-p2 which define line segment's endpoints, and in addition to that,
* we have access to previous (p0) and next (p3) points). Geometry shader generates two triangles
* for each segment and possibly another triangle for bevel join.
*/
class QgsLineMaterial : public Qt3DRender::QMaterial
{
Q_OBJECT
public:
QgsLineMaterial();
void setLineColor( const QColor &color );
QColor lineColor() const;
void setLineWidth( float width );
float lineWidth() const;
Q_INVOKABLE void setViewportSize( const QSizeF &viewportSize );
private:
Qt3DRender::QParameter *mParameterThickness = nullptr;
Qt3DRender::QParameter *mParameterMiterLimit = nullptr;
Qt3DRender::QParameter *mParameterLineColor = nullptr;
Qt3DRender::QParameter *mParameterWindowScale = nullptr;
};
/// @endcond
#endif // QGSLINEMATERIAL_P_H