QGIS API Documentation 3.43.0-Master (9e873c7bc91)
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;
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
196 void removeLastPoint();
197
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, QgsAbstract3DEngine *engine );
210 void setupPolygon( Qt3DCore::QEntity *parentEntity );
211
212 const float DEFAULT_POLYGON_OPACITY = 0.25;
213
214 QgsGeometry mGeometry;
215 bool mHideLastMarker = false;
216
217 Qgs3DMapSettings *mMapSettings = nullptr; // not owned
218 QgsAbstract3DEngine *mEngine = nullptr;
220
222 MarkerType mMarkerType = Circle;
223 float mWidth = 3.f;
224 QColor mColor = Qt::red;
225 QColor mOutlineColor;
226 Qt::PenStyle mMarkerOutlineStyle = Qt::PenStyle::SolidLine;
227
228 bool mMarkerEnabled = true;
229 bool mEdgesEnabled = true;
230 bool mPolygonFillEnabled = true;
231
232 Qt3DCore::QEntity *mLineEntity = nullptr; // owned by parentEntity (from constructor)
233 Qt3DCore::QEntity *mPolygonEntity = nullptr; // owned by parentEntity (from constructor)
234 Qt3DCore::QEntity *mMarkerEntity = nullptr; // owned by parentEntity (from constructor)
235
236 // all these are owned by mPolygonEntity
237 QgsTessellatedPolygonGeometry *mPolygonGeometry = nullptr;
238 QgsMaterial *mPolygonMaterial = nullptr;
239
240 // all these are owned by mLineEntity
241 Qt3DRender::QGeometryRenderer *mLineGeometryRenderer = nullptr;
242#if QT_VERSION < QT_VERSION_CHECK( 6, 0, 0 )
243 Qt3DRender::QGeometry *mLineGeometry = nullptr;
244 Qt3DRender::QAttribute *mPositionAttribute = nullptr;
245 Qt3DRender::QAttribute *mIndexAttribute = nullptr;
246#else
247 Qt3DCore::QGeometry *mLineGeometry = nullptr;
248 Qt3DCore::QAttribute *mPositionAttribute = nullptr;
249 Qt3DCore::QAttribute *mIndexAttribute = nullptr;
250#endif
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:337
A geometry is the spatial representation of a feature.
A marker symbol type, for rendering Point and MultiPoint geometries.
Point geometry type, with support for z-dimension and m-values.
Definition qgspoint.h:49