QGIS API Documentation 3.99.0-Master (357b655ed83)
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#include "qobjectuniqueptr.h"
37
38#include <QColor>
39
40class QgsGeometry;
42class QgsPoint;
44class QgsMaterial;
46class QgsLineMaterial;
49class QgsMarkerSymbol;
51class QgsGeoTransform;
52
53namespace Qt3DCore
54{
55 class QEntity;
56 class QBuffer;
57 class QGeometry;
58 class QAttribute;
59} // namespace Qt3DCore
60
61namespace Qt3DRender
62{
63 class QGeometryRenderer;
64} // namespace Qt3DRender
65
77class _3D_EXPORT QgsRubberBand3D
78{
79 public:
81 enum MarkerType
82 {
83
87 Square,
88
92 Circle
93 };
94
95 QgsRubberBand3D( Qgs3DMapSettings &map, QgsAbstract3DEngine *engine, Qt3DCore::QEntity *parentEntity, Qgis::GeometryType geometryType = Qgis::GeometryType::Line );
96 ~QgsRubberBand3D();
97
99 float width() const;
100
102 void setWidth( float width );
103
105 QColor color() const;
106
108 void setColor( QColor color );
109
114 QColor outlineColor() const;
115
120 void setOutlineColor( QColor color );
121
125 void setMarkerType( MarkerType marker );
126
130 MarkerType markerType() const;
131
137 void setMarkerOutlineStyle( Qt::PenStyle style );
138
143 Qt::PenStyle markerOutlineStyle() const;
144
149 void setMarkersEnabled( bool enable );
150
155 bool hasMarkersEnabled() const;
156
161 void setEdgesEnabled( bool enable );
162
167 bool hasEdgesEnabled() const;
168
173 void setFillEnabled( bool enable );
174
179 bool hasFillEnabled() const;
180
181 void reset();
182
183 void addPoint( const QgsPoint &pt );
184
190 void setGeometry( const QgsGeometry &geometry );
191
193 void removeLastPoint();
194
196 void removePenultimatePoint();
197
199 void moveLastPoint( const QgsPoint &pt );
200
202 void setHideLastMarker( const bool hide ) { mHideLastMarker = hide; }
203
204 bool isEmpty() const { return mGeometry.isEmpty(); }
205
206 private:
207 void updateGeometry();
208 void updateMarkerMaterial();
209 void setupMarker( Qt3DCore::QEntity *parentEntity );
210 void setupLine( Qt3DCore::QEntity *parentEntity );
211 void setupPolygon( Qt3DCore::QEntity *parentEntity );
213 void removePoint( int index );
214
215 const float DEFAULT_POLYGON_OPACITY = 0.25;
216
217 QgsGeometry mGeometry;
218 bool mHideLastMarker = false;
219
220 Qgs3DMapSettings *mMapSettings = nullptr; // not owned
221 QgsAbstract3DEngine *mEngine = nullptr;
223
225 MarkerType mMarkerType = Circle;
226 float mWidth = 3.f;
227 QColor mColor = Qt::red;
228 QColor mOutlineColor;
229 Qt::PenStyle mMarkerOutlineStyle = Qt::PenStyle::SolidLine;
230
231 bool mMarkerEnabled = true;
232 bool mEdgesEnabled = true;
233 bool mPolygonFillEnabled = true;
234
235 QObjectUniquePtr<Qt3DCore::QEntity> mLineEntity = nullptr; // owned by parentEntity (from constructor)
236 QObjectUniquePtr<Qt3DCore::QEntity> mPolygonEntity = nullptr; // owned by parentEntity (from constructor)
237 QObjectUniquePtr<Qt3DCore::QEntity> mMarkerEntity = nullptr; // owned by parentEntity (from constructor)
238
239 QgsGeoTransform *mLineTransform = nullptr;
240 QgsGeoTransform *mPolygonTransform = nullptr;
241 QgsGeoTransform *mMarkerTransform = nullptr;
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 Qt3DCore::QGeometry *mLineGeometry = nullptr;
250 Qt3DCore::QAttribute *mPositionAttribute = nullptr;
251 Qt3DCore::QAttribute *mIndexAttribute = nullptr;
252 QgsLineMaterial *mLineMaterial = nullptr;
253
254 // and these are owned by mMarkerEntity
255 Qt3DRender::QGeometryRenderer *mMarkerGeometryRenderer = nullptr;
256 QgsBillboardGeometry *mMarkerGeometry = nullptr;
257 QgsPoint3DBillboardMaterial *mMarkerMaterial = nullptr;
258
259 std::unique_ptr<QgsMarkerSymbol> mMarkerSymbol;
260
261 // Disable copying as we have pointer members.
262 QgsRubberBand3D( const QgsRubberBand3D & ) = delete;
263 QgsRubberBand3D &operator=( const QgsRubberBand3D & ) = delete;
264};
265
267
268#endif // QGSRUBBERBAND3D_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:365
@ Line
Lines.
Definition qgis.h:367
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:53
Qt3DRender::QGeometry subclass that represents polygons tessellated into 3D geometry.