QGIS API Documentation 3.99.0-Master (c22de0620c0)
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
21
22//
23// W A R N I N G
24// -------------
25//
26// This file is not part of the QGIS API. It exists purely as an
27// implementation detail. This header file may change from version to
28// version without notice, or even be removed.
29//
30
31#include "qgis_3d.h"
32#include "qgsgeometry.h"
33#include "qobjectuniqueptr.h"
34
35#include <QColor>
36
37#define SIP_NO_FILE
38
39class QgsGeometry;
41class QgsPoint;
43class QgsMaterial;
45class QgsLineMaterial;
48class QgsMarkerSymbol;
50class QgsGeoTransform;
51
52namespace Qt3DCore
53{
54 class QEntity;
55 class QBuffer;
56 class QGeometry;
57 class QAttribute;
58} // namespace Qt3DCore
59
60namespace Qt3DRender
61{
62 class QGeometryRenderer;
63} // namespace Qt3DRender
64
76class _3D_EXPORT QgsRubberBand3D
77{
78 public:
80 enum MarkerType
81 {
82
86 Square,
87
91 Circle
92 };
93
94 QgsRubberBand3D( Qgs3DMapSettings &map, QgsAbstract3DEngine *engine, Qt3DCore::QEntity *parentEntity, Qgis::GeometryType geometryType = Qgis::GeometryType::Line );
95 ~QgsRubberBand3D();
96
98 float width() const;
99
101 void setWidth( float width );
102
104 QColor color() const;
105
107 void setColor( QColor color );
108
113 QColor outlineColor() const;
114
119 void setOutlineColor( QColor color );
120
124 void setMarkerType( MarkerType marker );
125
129 MarkerType markerType() const;
130
136 void setMarkerOutlineStyle( Qt::PenStyle style );
137
142 Qt::PenStyle markerOutlineStyle() const;
143
148 void setMarkersEnabled( bool enable );
149
154 bool hasMarkersEnabled() const;
155
160 void setEdgesEnabled( bool enable );
161
166 bool hasEdgesEnabled() const;
167
172 void setFillEnabled( bool enable );
173
178 bool hasFillEnabled() const;
179
180 void reset();
181
182 void addPoint( const QgsPoint &pt );
183
189 void setGeometry( const QgsGeometry &geometry );
190
192 void removeLastPoint();
193
195 void removePenultimatePoint();
196
198 void moveLastPoint( const QgsPoint &pt );
199
201 void setHideLastMarker( const bool hide ) { mHideLastMarker = hide; }
202
203 bool isEmpty() const { return mGeometry.isEmpty(); }
204
205 private:
206 void updateGeometry();
207 void updateMarkerMaterial();
208 void setupMarker( Qt3DCore::QEntity *parentEntity );
209 void setupLine( Qt3DCore::QEntity *parentEntity );
210 void setupPolygon( Qt3DCore::QEntity *parentEntity );
212 void removePoint( int index );
213
214 const float DEFAULT_POLYGON_OPACITY = 0.25;
215
216 QgsGeometry mGeometry;
217 bool mHideLastMarker = false;
218
219 Qgs3DMapSettings *mMapSettings = nullptr; // not owned
220 QgsAbstract3DEngine *mEngine = nullptr;
222
224 MarkerType mMarkerType = Circle;
225 float mWidth = 3.f;
226 QColor mColor = Qt::red;
227 QColor mOutlineColor;
228 Qt::PenStyle mMarkerOutlineStyle = Qt::PenStyle::SolidLine;
229
230 bool mMarkerEnabled = true;
231 bool mEdgesEnabled = true;
232 bool mPolygonFillEnabled = true;
233
234 QObjectUniquePtr<Qt3DCore::QEntity> mLineEntity = nullptr; // owned by parentEntity (from constructor)
235 QObjectUniquePtr<Qt3DCore::QEntity> mPolygonEntity = nullptr; // owned by parentEntity (from constructor)
236 QObjectUniquePtr<Qt3DCore::QEntity> mMarkerEntity = nullptr; // owned by parentEntity (from constructor)
237
238 QgsGeoTransform *mLineTransform = nullptr;
239 QgsGeoTransform *mPolygonTransform = nullptr;
240 QgsGeoTransform *mMarkerTransform = nullptr;
241
242 // all these are owned by mPolygonEntity
243 QgsTessellatedPolygonGeometry *mPolygonGeometry = nullptr;
244 QgsMaterial *mPolygonMaterial = nullptr;
245
246 // all these are owned by mLineEntity
247 Qt3DRender::QGeometryRenderer *mLineGeometryRenderer = nullptr;
248 Qt3DCore::QGeometry *mLineGeometry = nullptr;
249 Qt3DCore::QAttribute *mPositionAttribute = nullptr;
250 Qt3DCore::QAttribute *mIndexAttribute = nullptr;
251 QgsLineMaterial *mLineMaterial = nullptr;
252
253 // and these are owned by mMarkerEntity
254 Qt3DRender::QGeometryRenderer *mMarkerGeometryRenderer = nullptr;
255 QgsBillboardGeometry *mMarkerGeometry = nullptr;
256 QgsPoint3DBillboardMaterial *mMarkerMaterial = nullptr;
257
258 std::unique_ptr<QgsMarkerSymbol> mMarkerSymbol;
259
260 // Disable copying as we have pointer members.
261 QgsRubberBand3D( const QgsRubberBand3D & ) = delete;
262 QgsRubberBand3D &operator=( const QgsRubberBand3D & ) = delete;
263};
264
266
267#endif // QGSRUBBERBAND3D_H
GeometryType
The geometry types are used to group Qgis::WkbType in a coarse way.
Definition qgis.h:376
@ Line
Lines.
Definition qgis.h:378
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:40
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.