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 );
Abstract base class for all geometries.
bool isEmpty() const override SIP_HOLDGIL
Returns true if the geometry is empty.
int numGeometries() const SIP_HOLDGIL
Returns the number of geometries within the collection.
const QgsAbstractGeometry * geometryN(int n) const
Returns a const reference to a geometry from within the collection.
A geometry is the spatial representation of a feature.
const QgsAbstractGeometry * constGet() const SIP_HOLDGIL
Returns a non-modifiable (const) reference to the underlying abstract geometry primitive.
QgsWkbTypes::GeometryType type
Line string geometry type, with support for z-dimension and m-values.
const double * yData() const
Returns a const pointer to the y vertex data.
int numPoints() const override SIP_HOLDGIL
Returns the number of points in the curve.
const double * xData() const
Returns a const pointer to the x vertex data.
Point geometry type, with support for z-dimension and m-values.
QgsQuickHighlightSGNode(const QgsGeometry &geom, const QColor &color, float width)
Constructor of new QT Quick scene node based on geometry.
A rectangle specified with double values.
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
QgsRectangle boundingBox() const override
Returns the minimal bounding box for the geometry.
Class that takes care of tessellation of polygons into triangles.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.