QGIS API Documentation 3.43.0-Master (0bee5d6404c)
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;
50class QgsGeoTransform;
51
52namespace Qt3DCore
53{
54 class QEntity;
55#if QT_VERSION >= QT_VERSION_CHECK( 6, 0, 0 )
56 class QBuffer;
57 class QGeometry;
58 class QAttribute;
59#endif
60} // namespace Qt3DCore
61
62namespace Qt3DRender
63{
64#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
65 class QBuffer;
66 class QGeometry;
67 class QAttribute;
68#endif
69 class QGeometryRenderer;
70} // namespace Qt3DRender
71
83class _3D_EXPORT QgsRubberBand3D
84{
85 public:
87 enum MarkerType
88 {
92 Square,
93
97 Circle
98 };
99
100 QgsRubberBand3D( Qgs3DMapSettings &map, QgsAbstract3DEngine *engine, Qt3DCore::QEntity *parentEntity, Qgis::GeometryType geometryType = Qgis::GeometryType::Line );
101 ~QgsRubberBand3D();
102
104 float width() const;
105
107 void setWidth( float width );
108
110 QColor color() const;
111
113 void setColor( QColor color );
114
119 QColor outlineColor() const;
120
125 void setOutlineColor( QColor color );
126
130 void setMarkerType( MarkerType marker );
131
135 MarkerType markerType() const;
136
142 void setMarkerOutlineStyle( Qt::PenStyle style );
143
148 Qt::PenStyle markerOutlineStyle() const;
149
154 void setMarkersEnabled( bool enable );
155
160 bool hasMarkersEnabled() const;
161
166 void setEdgesEnabled( bool enable );
167
172 bool hasEdgesEnabled() const;
173
178 void setFillEnabled( bool enable );
179
184 bool hasFillEnabled() const;
185
186 void reset();
187
188 void addPoint( const QgsPoint &pt );
189
195 void setGeometry( const QgsGeometry &geometry );
196
198 void removeLastPoint();
199
201 void removePenultimatePoint();
202
204 void moveLastPoint( const QgsPoint &pt );
205
207 void setHideLastMarker( const bool hide ) { mHideLastMarker = hide; }
208
209 bool isEmpty() const { return mGeometry.isEmpty(); }
210
211 private:
212 void updateGeometry();
213 void updateMarkerMaterial();
214 void setupMarker( Qt3DCore::QEntity *parentEntity );
215 void setupLine( Qt3DCore::QEntity *parentEntity, QgsAbstract3DEngine *engine );
216 void setupPolygon( Qt3DCore::QEntity *parentEntity );
218 void removePoint( int index );
219
220 const float DEFAULT_POLYGON_OPACITY = 0.25;
221
222 QgsGeometry mGeometry;
223 bool mHideLastMarker = false;
224
225 Qgs3DMapSettings *mMapSettings = nullptr; // not owned
226 QgsAbstract3DEngine *mEngine = nullptr;
228
230 MarkerType mMarkerType = Circle;
231 float mWidth = 3.f;
232 QColor mColor = Qt::red;
233 QColor mOutlineColor;
234 Qt::PenStyle mMarkerOutlineStyle = Qt::PenStyle::SolidLine;
235
236 bool mMarkerEnabled = true;
237 bool mEdgesEnabled = true;
238 bool mPolygonFillEnabled = true;
239
240 Qt3DCore::QEntity *mLineEntity = nullptr; // owned by parentEntity (from constructor)
241 Qt3DCore::QEntity *mPolygonEntity = nullptr; // owned by parentEntity (from constructor)
242 Qt3DCore::QEntity *mMarkerEntity = nullptr; // owned by parentEntity (from constructor)
243
244 QgsGeoTransform *mLineTransform = nullptr;
245 QgsGeoTransform *mPolygonTransform = nullptr;
246 QgsGeoTransform *mMarkerTransform = nullptr;
247
248 // all these are owned by mPolygonEntity
249 QgsTessellatedPolygonGeometry *mPolygonGeometry = nullptr;
250 QgsMaterial *mPolygonMaterial = nullptr;
251
252 // all these are owned by mLineEntity
253 Qt3DRender::QGeometryRenderer *mLineGeometryRenderer = nullptr;
254#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
255 Qt3DRender::QGeometry *mLineGeometry = nullptr;
256 Qt3DRender::QAttribute *mPositionAttribute = nullptr;
257 Qt3DRender::QAttribute *mIndexAttribute = nullptr;
258#else
259 Qt3DCore::QGeometry *mLineGeometry = nullptr;
260 Qt3DCore::QAttribute *mPositionAttribute = nullptr;
261 Qt3DCore::QAttribute *mIndexAttribute = nullptr;
262#endif
263 QgsLineMaterial *mLineMaterial = nullptr;
264
265 // and these are owned by mMarkerEntity
266 Qt3DRender::QGeometryRenderer *mMarkerGeometryRenderer = nullptr;
267 QgsBillboardGeometry *mMarkerGeometry = nullptr;
268 QgsPoint3DBillboardMaterial *mMarkerMaterial = nullptr;
269
270 std::unique_ptr<QgsMarkerSymbol> mMarkerSymbol;
271
272 // Disable copying as we have pointer members.
273 QgsRubberBand3D( const QgsRubberBand3D & ) = delete;
274 QgsRubberBand3D &operator=( const QgsRubberBand3D & ) = delete;
275};
276
278
279#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.