24#include <Qt3DCore/QEntity>
26#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
27#include <Qt3DRender/QAttribute>
28#include <Qt3DRender/QBuffer>
29#include <Qt3DRender/QGeometry>
31#include <Qt3DCore/QAttribute>
32#include <Qt3DCore/QBuffer>
33#include <Qt3DCore/QGeometry>
36#include <Qt3DRender/QGeometryRenderer>
37#include <Qt3DRender/QMaterial>
48 mEntity =
new Qt3DCore::QEntity( parentEntity );
50 QgsLineVertexData dummyLineData;
51 mGeometry = dummyLineData.createGeometry( mEntity );
53 Q_ASSERT( mGeometry->attributes().count() == 2 );
54 mPositionAttribute = mGeometry->attributes()[0];
55 mIndexAttribute = mGeometry->attributes()[1];
57 mGeomRenderer =
new Qt3DRender::QGeometryRenderer;
58 mGeomRenderer->setPrimitiveType( Qt3DRender::QGeometryRenderer::LineStripAdjacency );
59 mGeomRenderer->setGeometry( mGeometry );
60 mGeomRenderer->setPrimitiveRestartEnabled(
true );
61 mGeomRenderer->setRestartIndexValue( 0 );
63 mEntity->addComponent( mGeomRenderer );
65 mLineMaterial =
new QgsLineMaterial;
66 mLineMaterial->setLineWidth( 3 );
67 mLineMaterial->setLineColor( Qt::red );
71 mLineMaterial->setViewportSize( engine->
size() );
73 mLineMaterial->setViewportSize( engine->
size() );
75 mEntity->addComponent( mLineMaterial );
78QgsRubberBand3D::~QgsRubberBand3D()
83float QgsRubberBand3D::width()
const
85 return mLineMaterial->lineWidth();
88void QgsRubberBand3D::setWidth(
float width )
90 mLineMaterial->setLineWidth( width );
93QColor QgsRubberBand3D::color()
const
95 return mLineMaterial->lineColor();
98void QgsRubberBand3D::setColor( QColor color )
100 mLineMaterial->setLineColor( color );
103void QgsRubberBand3D::reset()
109void QgsRubberBand3D::addPoint(
const QgsPoint &pt )
111 mLineString.addVertex( pt );
115void QgsRubberBand3D::removeLastPoint()
117 const int lastVertexIndex = mLineString.numPoints() - 1;
118 mLineString.deleteVertex(
QgsVertexId( 0, 0, lastVertexIndex ) );
122void QgsRubberBand3D::updateGeometry()
124 QgsLineVertexData lineData;
125 lineData.withAdjacency =
true;
127 lineData.addLineString( mLineString );
129 mPositionAttribute->buffer()->setData( lineData.createVertexBuffer() );
130 mIndexAttribute->buffer()->setData( lineData.createIndexBuffer() );
131 mGeomRenderer->setVertexCount( lineData.indexes.count() );
@ Absolute
Elevation is taken directly from feature and is independent of terrain height (final elevation = feat...
@ Vertex
Clamp every vertex of feature.
void sizeChanged()
Emitted after a call to setSize()
Point geometry type, with support for z-dimension and m-values.
QSize size() const override
Returns size of the engine's rendering area in pixels.
Utility class for identifying a unique vertex within a geometry.