QGIS API Documentation 3.99.0-Master (752b475928d)
Loading...
Searching...
No Matches
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 {
89
93 Square,
94
98 Circle
99 };
100
101 QgsRubberBand3D( Qgs3DMapSettings &map, QgsAbstract3DEngine *engine, Qt3DCore::QEntity *parentEntity, Qgis::GeometryType geometryType = Qgis::GeometryType::Line );
102 ~QgsRubberBand3D();
103
105 float width() const;
106
108 void setWidth( float width );
109
111 QColor color() const;
112
114 void setColor( QColor color );
115
120 QColor outlineColor() const;
121
126 void setOutlineColor( QColor color );
127
131 void setMarkerType( MarkerType marker );
132
136 MarkerType markerType() const;
137
143 void setMarkerOutlineStyle( Qt::PenStyle style );
144
149 Qt::PenStyle markerOutlineStyle() const;
150
155 void setMarkersEnabled( bool enable );
156
161 bool hasMarkersEnabled() const;
162
167 void setEdgesEnabled( bool enable );
168
173 bool hasEdgesEnabled() const;
174
179 void setFillEnabled( bool enable );
180
185 bool hasFillEnabled() const;
186
187 void reset();
188
189 void addPoint( const QgsPoint &pt );
190
196 void setGeometry( const QgsGeometry &geometry );
197
199 void removeLastPoint();
200
202 void removePenultimatePoint();
203
205 void moveLastPoint( const QgsPoint &pt );
206
208 void setHideLastMarker( const bool hide ) { mHideLastMarker = hide; }
209
210 bool isEmpty() const { return mGeometry.isEmpty(); }
211
212 private:
213 void updateGeometry();
214 void updateMarkerMaterial();
215 void setupMarker( Qt3DCore::QEntity *parentEntity );
216 void setupLine( Qt3DCore::QEntity *parentEntity, QgsAbstract3DEngine *engine );
217 void setupPolygon( Qt3DCore::QEntity *parentEntity );
219 void removePoint( int index );
220
221 const float DEFAULT_POLYGON_OPACITY = 0.25;
222
223 QgsGeometry mGeometry;
224 bool mHideLastMarker = false;
225
226 Qgs3DMapSettings *mMapSettings = nullptr; // not owned
227 QgsAbstract3DEngine *mEngine = nullptr;
229
231 MarkerType mMarkerType = Circle;
232 float mWidth = 3.f;
233 QColor mColor = Qt::red;
234 QColor mOutlineColor;
235 Qt::PenStyle mMarkerOutlineStyle = Qt::PenStyle::SolidLine;
236
237 bool mMarkerEnabled = true;
238 bool mEdgesEnabled = true;
239 bool mPolygonFillEnabled = true;
240
241 Qt3DCore::QEntity *mLineEntity = nullptr; // owned by parentEntity (from constructor)
242 Qt3DCore::QEntity *mPolygonEntity = nullptr; // owned by parentEntity (from constructor)
243 Qt3DCore::QEntity *mMarkerEntity = nullptr; // owned by parentEntity (from constructor)
244
245 QgsGeoTransform *mLineTransform = nullptr;
246 QgsGeoTransform *mPolygonTransform = nullptr;
247 QgsGeoTransform *mMarkerTransform = nullptr;
248
249 // all these are owned by mPolygonEntity
250 QgsTessellatedPolygonGeometry *mPolygonGeometry = nullptr;
251 QgsMaterial *mPolygonMaterial = nullptr;
252
253 // all these are owned by mLineEntity
254 Qt3DRender::QGeometryRenderer *mLineGeometryRenderer = nullptr;
255#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
256 Qt3DRender::QGeometry *mLineGeometry = nullptr;
257 Qt3DRender::QAttribute *mPositionAttribute = nullptr;
258 Qt3DRender::QAttribute *mIndexAttribute = nullptr;
259#else
260 Qt3DCore::QGeometry *mLineGeometry = nullptr;
261 Qt3DCore::QAttribute *mPositionAttribute = nullptr;
262 Qt3DCore::QAttribute *mIndexAttribute = nullptr;
263#endif
264 QgsLineMaterial *mLineMaterial = nullptr;
265
266 // and these are owned by mMarkerEntity
267 Qt3DRender::QGeometryRenderer *mMarkerGeometryRenderer = nullptr;
268 QgsBillboardGeometry *mMarkerGeometry = nullptr;
269 QgsPoint3DBillboardMaterial *mMarkerMaterial = nullptr;
270
271 std::unique_ptr<QgsMarkerSymbol> mMarkerSymbol;
272
273 // Disable copying as we have pointer members.
274 QgsRubberBand3D( const QgsRubberBand3D & ) = delete;
275 QgsRubberBand3D &operator=( const QgsRubberBand3D & ) = delete;
276};
277
279
280#endif // QGSRUBBERBAND3D_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:358
@ Line
Lines.
Definition qgis.h:360
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.