26 const QColor &color,
float width )
30 mMaterial.setColor( color );
31 handleGeometryCollection( geom.
constGet(), geom.
type() );
37 if ( collection && !collection->
isEmpty() )
42 handleSingleGeometry( geomN, type );
47 handleSingleGeometry( geom, type );
57 const QgsPoint *point = qgsgeometry_cast<const QgsPoint *>( geom );
59 appendChildNode( createPointGeometry( point ) );
65 const QgsLineString *line = qgsgeometry_cast<const QgsLineString *>( geom );
67 appendChildNode( createLineGeometry( line ) );
73 const QgsPolygon *poly = qgsgeometry_cast<const QgsPolygon *>( geom );
75 appendChildNode( createPolygonGeometry( poly ) );
85 QSGGeometryNode *QgsQuickHighlightSGNode::createLineGeometry(
const QgsLineString *line )
89 std::unique_ptr<QSGGeometryNode> node = qgis::make_unique< QSGGeometryNode>();
90 std::unique_ptr<QSGGeometry> sgGeom = qgis::make_unique< QSGGeometry>( QSGGeometry::defaultAttributes_Point2D(), line->
numPoints() );
91 QSGGeometry::Point2D *vertices = sgGeom->vertexDataAsPoint2D();
93 const double *x = line->
xData();
94 const double *y = line->
yData();
96 for (
int i = 0; i < line->
numPoints(); ++i )
99 static_cast< float >( x[i] ),
100 static_cast< float >( y[i] )
104 sgGeom->setLineWidth( mWidth );
105 sgGeom->setDrawingMode( GL_LINE_STRIP );
106 node->setGeometry( sgGeom.release() );
107 node->setMaterial( &mMaterial );
108 node->setFlag( QSGNode::OwnsGeometry );
109 node->setFlag( QSGNode::OwnedByParent );
110 return node.release();
113 QSGGeometryNode *QgsQuickHighlightSGNode::createPointGeometry(
const QgsPoint *point )
117 std::unique_ptr<QSGGeometryNode> node = qgis::make_unique< QSGGeometryNode>();
118 std::unique_ptr<QSGGeometry> sgGeom = qgis::make_unique<QSGGeometry>( QSGGeometry::defaultAttributes_Point2D(), 1 );
120 QSGGeometry::Point2D *vertices = sgGeom->vertexDataAsPoint2D();
122 static_cast< float >( point->
x() ),
123 static_cast< float >( point->
y() )
125 sgGeom->setDrawingMode( GL_POINTS );
126 sgGeom->setLineWidth( mWidth );
128 node->setGeometry( sgGeom.release() );
129 node->setMaterial( &mMaterial );
130 node->setFlag( QSGNode::OwnsGeometry );
131 node->setFlag( QSGNode::OwnedByParent );
132 return node.release();
135 QSGGeometryNode *QgsQuickHighlightSGNode::createPolygonGeometry(
const QgsPolygon *polygon )
141 tes.addPolygon( *polygon, 0.0 );
143 QSGGeometryNode *node =
new QSGGeometryNode;
144 QSGGeometry *sgGeom =
new QSGGeometry( QSGGeometry::defaultAttributes_Point2D(), tes.dataVerticesCount() );
146 QSGGeometry::Point2D *vertices = sgGeom->vertexDataAsPoint2D();
149 float translateX =
static_cast< float >( bounds.
xMinimum() );
150 float translateY =
static_cast< float >( bounds.
yMinimum() );
152 const QVector<float> data = tes.data();
154 for (
auto it = data.constBegin(); it != data.constEnd(); )
157 vertices[i].x = translateX + x;
163 vertices[i].y = translateY + y;
168 sgGeom->setDrawingMode( GL_TRIANGLES );
169 node->setGeometry( sgGeom );
170 node->setMaterial( &mMaterial );
171 node->setFlag( QSGNode::OwnsGeometry );
172 node->setFlag( QSGNode::OwnedByParent );