QGIS API Documentation 3.43.0-Master (c67cf405802)
qgsrubberband3d.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsrubberband3d.h
3 --------------------------------------
4 Date : June 2021
5 Copyright : (C) 2021 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 QGSRUBBERBAND3D_H
17#define QGSRUBBERBAND3D_H
18
19#define SIP_NO_FILE
20
22
23//
24// W A R N I N G
25// -------------
26//
27// This file is not part of the QGIS API. It exists purely as an
28// implementation detail. This header file may change from version to
29// version without notice, or even be removed.
30//
31
32#include "qgis_3d.h"
33#include "qgsgeometry.h"
34#include "qgspolygon.h"
35#include "qgstessellator.h"
36
37#include <QColor>
38
39class QgsGeometry;
41class QgsPoint;
43class QgsMaterial;
45class QgsLineMaterial;
48class QgsMarkerSymbol;
50
51namespace Qt3DCore
52{
53 class QEntity;
54#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
55 class QBuffer;
56 class QGeometry;
57 class QAttribute;
58#endif
59} // namespace Qt3DCore
60
61namespace Qt3DRender
62{
63#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
64 class QBuffer;
65 class QGeometry;
66 class QAttribute;
67#endif
68 class QGeometryRenderer;
69} // namespace Qt3DRender
70
82class _3D_EXPORT QgsRubberBand3D
83{
84 public:
86 enum MarkerType
87 {
91 Square,
92
96 Circle
97 };
98
99 QgsRubberBand3D( Qgs3DMapSettings &map, QgsAbstract3DEngine *engine, Qt3DCore::QEntity *parentEntity, Qgis::GeometryType geometryType = Qgis::GeometryType::Line );
100 ~QgsRubberBand3D();
101
103 float width() const;
104
106 void setWidth( float width );
107
109 QColor color() const;
110
112 void setColor( QColor color );
113
118 QColor outlineColor() const;
119
124 void setOutlineColor( QColor color );
125
129 void setMarkerType( MarkerType marker );
130
134 MarkerType markerType() const;
135
141 void setMarkerOutlineStyle( Qt::PenStyle style );
142
147 Qt::PenStyle markerOutlineStyle() const;
148
153 void setMarkersEnabled( bool enable );
154
159 bool hasMarkersEnabled() const;
160
165 void setEdgesEnabled( bool enable );
166
171 bool hasEdgesEnabled() const;
172
177 void setFillEnabled( bool enable );
178
183 bool hasFillEnabled() const;
184
185 void reset();
186
187 void addPoint( const QgsPoint &pt );
188
194 void setGeometry( const QgsGeometry &geometry );
195
197 void removeLastPoint();
198
200 void removePenultimatePoint();
201
203 void moveLastPoint( const QgsPoint &pt );
204
206 void setHideLastMarker( const bool hide ) { mHideLastMarker = hide; }
207
208 bool isEmpty() const { return mGeometry.isEmpty(); }
209
210 private:
211 void updateGeometry();
212 void updateMarkerMaterial();
213 void setupMarker( Qt3DCore::QEntity *parentEntity );
214 void setupLine( Qt3DCore::QEntity *parentEntity, QgsAbstract3DEngine *engine );
215 void setupPolygon( Qt3DCore::QEntity *parentEntity );
217 void removePoint( int index );
218
219 const float DEFAULT_POLYGON_OPACITY = 0.25;
220
221 QgsGeometry mGeometry;
222 bool mHideLastMarker = false;
223
224 Qgs3DMapSettings *mMapSettings = nullptr; // not owned
225 QgsAbstract3DEngine *mEngine = nullptr;
227
229 MarkerType mMarkerType = Circle;
230 float mWidth = 3.f;
231 QColor mColor = Qt::red;
232 QColor mOutlineColor;
233 Qt::PenStyle mMarkerOutlineStyle = Qt::PenStyle::SolidLine;
234
235 bool mMarkerEnabled = true;
236 bool mEdgesEnabled = true;
237 bool mPolygonFillEnabled = true;
238
239 Qt3DCore::QEntity *mLineEntity = nullptr; // owned by parentEntity (from constructor)
240 Qt3DCore::QEntity *mPolygonEntity = nullptr; // owned by parentEntity (from constructor)
241 Qt3DCore::QEntity *mMarkerEntity = nullptr; // owned by parentEntity (from constructor)
242
243 // all these are owned by mPolygonEntity
244 QgsTessellatedPolygonGeometry *mPolygonGeometry = nullptr;
245 QgsMaterial *mPolygonMaterial = nullptr;
246
247 // all these are owned by mLineEntity
248 Qt3DRender::QGeometryRenderer *mLineGeometryRenderer = nullptr;
249#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
250 Qt3DRender::QGeometry *mLineGeometry = nullptr;
251 Qt3DRender::QAttribute *mPositionAttribute = nullptr;
252 Qt3DRender::QAttribute *mIndexAttribute = nullptr;
253#else
254 Qt3DCore::QGeometry *mLineGeometry = nullptr;
255 Qt3DCore::QAttribute *mPositionAttribute = nullptr;
256 Qt3DCore::QAttribute *mIndexAttribute = nullptr;
257#endif
258 QgsLineMaterial *mLineMaterial = nullptr;
259
260 // and these are owned by mMarkerEntity
261 Qt3DRender::QGeometryRenderer *mMarkerGeometryRenderer = nullptr;
262 QgsBillboardGeometry *mMarkerGeometry = nullptr;
263 QgsPoint3DBillboardMaterial *mMarkerMaterial = nullptr;
264
265 std::unique_ptr<QgsMarkerSymbol> mMarkerSymbol;
266
267 // Disable copying as we have pointer members.
268 QgsRubberBand3D( const QgsRubberBand3D & ) = delete;
269 QgsRubberBand3D &operator=( const QgsRubberBand3D & ) = delete;
270};
271
273
274#endif // QGSRUBBERBAND3D_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:337
Definition of the world.
Base class for 3D engine implementation.
Geometry of the billboard rendering for points in 3D map view.
A geometry is the spatial representation of a feature.
A marker symbol type, for rendering Point and MultiPoint geometries.
Base class for all materials used within QGIS 3D views.
Definition qgsmaterial.h:39
Basic shading material used for rendering based on the Phong shading model with three color component...
Material of the billboard rendering for points in 3D map view.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49
Qt3DRender::QGeometry subclass that represents polygons tessellated into 3D geometry.