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>
47 mEntity =
new Qt3DCore::QEntity( parentEntity );
49 QgsLineVertexData dummyLineData;
50 mGeometry = dummyLineData.createGeometry( mEntity );
52 Q_ASSERT( mGeometry->attributes().count() == 2 );
53 mPositionAttribute = mGeometry->attributes()[0];
54 mIndexAttribute = mGeometry->attributes()[1];
56 mGeomRenderer =
new Qt3DRender::QGeometryRenderer;
57 mGeomRenderer->setPrimitiveType( Qt3DRender::QGeometryRenderer::LineStripAdjacency );
58 mGeomRenderer->setGeometry( mGeometry );
59 mGeomRenderer->setPrimitiveRestartEnabled(
true );
60 mGeomRenderer->setRestartIndexValue( 0 );
62 mEntity->addComponent( mGeomRenderer );
64 mLineMaterial =
new QgsLineMaterial;
65 mLineMaterial->setLineWidth( 3 );
66 mLineMaterial->setLineColor( Qt::red );
70 mLineMaterial->setViewportSize( cameraController->
viewport().size() );
72 mLineMaterial->setViewportSize( cameraController->
viewport().size() );
74 mEntity->addComponent( mLineMaterial );
77QgsRubberBand3D::~QgsRubberBand3D()
82float QgsRubberBand3D::width()
const
84 return mLineMaterial->lineWidth();
87void QgsRubberBand3D::setWidth(
float width )
89 mLineMaterial->setLineWidth( width );
92QColor QgsRubberBand3D::color()
const
94 return mLineMaterial->lineColor();
97void QgsRubberBand3D::setColor( QColor color )
99 mLineMaterial->setLineColor( color );
102void QgsRubberBand3D::reset()
108void QgsRubberBand3D::addPoint(
const QgsPoint &pt )
110 mLineString.addVertex( pt );
114void QgsRubberBand3D::removeLastPoint()
116 const int lastVertexIndex = mLineString.numPoints() - 1;
117 mLineString.deleteVertex(
QgsVertexId( 0, 0, lastVertexIndex ) );
121void QgsRubberBand3D::updateGeometry()
123 QgsLineVertexData lineData;
124 lineData.withAdjacency =
true;
126 lineData.addLineString( mLineString );
128 mPositionAttribute->buffer()->setData( lineData.createVertexBuffer() );
129 mIndexAttribute->buffer()->setData( lineData.createIndexBuffer() );
130 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 viewportChanged()
Emitted when viewport rectangle has been updated.
Point geometry type, with support for z-dimension and m-values.
Utility class for identifying a unique vertex within a geometry.