26 #include <Qt3DCore/QEntity>
27 #include <Qt3DRender/QAttribute>
28 #include <Qt3DRender/QBuffer>
29 #include <Qt3DRender/QGeometry>
30 #include <Qt3DRender/QGeometryRenderer>
31 #include <Qt3DRender/QMaterial>
41 mEntity =
new Qt3DCore::QEntity( parentEntity );
43 QgsLineVertexData dummyLineData;
44 mGeometry = dummyLineData.createGeometry( mEntity );
46 Q_ASSERT( mGeometry->attributes().count() == 2 );
47 mPositionAttribute = mGeometry->attributes()[0];
48 mIndexAttribute = mGeometry->attributes()[1];
50 mGeomRenderer =
new Qt3DRender::QGeometryRenderer;
51 mGeomRenderer->setPrimitiveType( Qt3DRender::QGeometryRenderer::LineStripAdjacency );
52 mGeomRenderer->setGeometry( mGeometry );
53 mGeomRenderer->setPrimitiveRestartEnabled(
true );
54 mGeomRenderer->setRestartIndexValue( 0 );
56 mEntity->addComponent( mGeomRenderer );
58 mLineMaterial =
new QgsLineMaterial;
59 mLineMaterial->setLineWidth( 3 );
60 mLineMaterial->setLineColor( Qt::red );
64 mLineMaterial->setViewportSize( cameraController->
viewport().size() );
66 mLineMaterial->setViewportSize( cameraController->
viewport().size() );
68 mEntity->addComponent( mLineMaterial );
71 QgsRubberBand3D::~QgsRubberBand3D()
76 float QgsRubberBand3D::width()
const
78 return mLineMaterial->lineWidth();
81 void QgsRubberBand3D::setWidth(
float width )
83 mLineMaterial->setLineWidth( width );
86 QColor QgsRubberBand3D::color()
const
88 return mLineMaterial->lineColor();
91 void QgsRubberBand3D::setColor( QColor color )
93 mLineMaterial->setLineColor( color );
96 void QgsRubberBand3D::reset()
102 void QgsRubberBand3D::addPoint(
const QgsPoint &pt )
104 mLineString.addVertex( pt );
108 void QgsRubberBand3D::removeLastPoint()
110 const int lastVertexIndex = mLineString.numPoints() - 1;
111 mLineString.deleteVertex(
QgsVertexId( 0, 0, lastVertexIndex ) );
115 void QgsRubberBand3D::updateGeometry()
117 QgsLineVertexData lineData;
118 lineData.withAdjacency =
true;
120 lineData.addLineString( mLineString );
122 mPositionAttribute->buffer()->setData( lineData.createVertexBuffer() );
123 mIndexAttribute->buffer()->setData( lineData.createIndexBuffer() );
124 mGeomRenderer->setVertexCount( lineData.indexes.count() );
@ AltClampAbsolute
Z_final = z_geometry.
@ AltBindVertex
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.