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