QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
31 : mRenderContext( context )
34 , mZValueScale( zValueScale )
35 , mZValueFixedOffset( zValueFixedOffset )
36 , mFeedback( feedback )
43 return mPointsRendered;
48 mPointsRendered += count;
64 if ( element.isNull() )
68 const QString rendererType = element.attribute( QStringLiteral(
"type" ) );
74 std::unique_ptr< QgsPointCloudRenderer > r( m->
createRenderer( element, context ) );
80 return QSet< QString >();
93 mThread = QThread::currentThread();
97 Q_ASSERT_X( mThread == QThread::currentThread(),
"QgsPointCloudRenderer::startRender",
"startRender called in a different thread - use a cloned renderer instead" );
103 switch ( mPointSymbol )
118 Q_ASSERT_X( mThread == QThread::currentThread(),
"QgsPointCloudRenderer::stopRender",
"stopRender called in a different thread - use a cloned renderer instead" );
134 return mMaximumScreenError;
139 mMaximumScreenError = error;
144 return mMaximumScreenErrorUnit;
149 mMaximumScreenErrorUnit = unit;
154 return QList<QgsLayerTreeModelLegendNode *>();
159 return QStringList();
175 mPointSize = element.attribute( QStringLiteral(
"pointSize" ), QStringLiteral(
"1" ) ).toDouble();
179 mMaximumScreenError = element.attribute( QStringLiteral(
"maximumScreenError" ), QStringLiteral(
"0.3" ) ).toDouble();
180 mMaximumScreenErrorUnit =
QgsUnitTypes::decodeRenderUnit( element.attribute( QStringLiteral(
"maximumScreenErrorUnit" ), QStringLiteral(
"MM" ) ) );
181 mPointSymbol =
static_cast< Qgis::PointCloudSymbol >( element.attribute( QStringLiteral(
"pointSymbol" ), QStringLiteral(
"0" ) ).toInt() );
182 mDrawOrder2d =
static_cast< Qgis::PointCloudDrawOrder >( element.attribute( QStringLiteral(
"drawOrder2d" ), QStringLiteral(
"0" ) ).toInt() );
187 element.setAttribute( QStringLiteral(
"pointSize" ),
qgsDoubleToString( mPointSize ) );
191 element.setAttribute( QStringLiteral(
"maximumScreenError" ),
qgsDoubleToString( mMaximumScreenError ) );
192 element.setAttribute( QStringLiteral(
"maximumScreenErrorUnit" ),
QgsUnitTypes::encodeUnit( mMaximumScreenErrorUnit ) );
193 element.setAttribute( QStringLiteral(
"pointSymbol" ), QString::number(
static_cast< int >( mPointSymbol ) ) );
194 element.setAttribute( QStringLiteral(
"drawOrder2d" ), QString::number(
static_cast< int >( mDrawOrder2d ) ) );
204 mPointSymbol = symbol;
214 mDrawOrder2d = order;
219 QVector<QVariantMap> selectedPoints;
238 QgsDebugMsg( QStringLiteral(
"Could not transform node extent to map CRS" ) );
239 rootNodeExtentMapCoords = rootNodeExtentLayerCoords;
244 rootNodeExtentMapCoords = rootNodeExtentLayerCoords;
247 const double rootErrorInMapCoordinates = rootNodeExtentMapCoords.
width() / index->
span();
248 const double rootErrorInLayerCoordinates = rootNodeExtentLayerCoords.
width() / index->
span();
251 if ( ( rootErrorInMapCoordinates < 0.0 ) || ( mapUnitsPerPixel < 0.0 ) || ( maxErrorPixels < 0.0 ) )
253 QgsDebugMsg( QStringLiteral(
"invalid screen error" ) );
254 return selectedPoints;
257 const double maxErrorInMapCoordinates = maxErrorPixels * mapUnitsPerPixel;
258 const double maxErrorInLayerCoordinates = maxErrorInMapCoordinates * rootErrorInLayerCoordinates / rootErrorInMapCoordinates;
263 const double x = geometry.
asPoint().
x();
264 const double y = geometry.
asPoint().
y();
266 const double pointSizePixels = renderContext.
convertToPainterUnits( mPointSize, mPointSizeUnit, mPointSizeMapUnitScale );
272 const QgsPointXY point1( deviceCoords.
x() - std::max( toleranceInPixels, pointSizePixels / 2.0 ), deviceCoords.
y() - std::max( toleranceInPixels, pointSizePixels / 2.0 ) );
273 const QgsPointXY point2( deviceCoords.
x() + std::max( toleranceInPixels, pointSizePixels / 2.0 ), deviceCoords.
y() + std::max( toleranceInPixels, pointSizePixels / 2.0 ) );
276 const QgsRectangle pointRect( point1MapCoords, point2MapCoords );
282 const QgsPoint centerMapCoords( x, y );
284 const QgsPoint point1( deviceCoords.
x(), deviceCoords.
y() - std::max( toleranceInPixels, pointSizePixels / 2.0 ) );
285 const QgsPoint point2( deviceCoords.
x(), deviceCoords.
y() + std::max( toleranceInPixels, pointSizePixels / 2.0 ) );
289 std::unique_ptr<QgsPolygon> polygon( circle.
toPolygon( 6 ) );
290 const QgsGeometry circleGeometry( std::move( polygon ) );
291 selectionGeometry = circleGeometry;
304 QgsDebugMsg( QStringLiteral(
"Could not transform geometry to layer CRS" ) );
305 return selectedPoints;
310 selectedPoints.erase( std::remove_if( selectedPoints.begin(), selectedPoints.end(), [
this](
const QMap<QString, QVariant> &point ) { return !this->willRenderPoint( point ); } ), selectedPoints.end() );
312 return selectedPoints;
QgsRectangle nodeMapExtent(const IndexedPointCloudNode &node) const
Returns the extent of a node in map coordinates.
QgsUnitTypes::RenderUnit maximumScreenErrorUnit() const
Returns the unit for the maximum screen error allowed when rendering the point cloud.
const QgsMapToPixel & mapToPixel() const
Returns the context's map to pixel transform, which transforms between map coordinates and device coo...
QVector< QVariantMap > identify(double maxError, const QgsGeometry &extentGeometry, const QgsDoubleRange &extentZRange=QgsDoubleRange(), int pointsLimit=1000)
Returns the list of points of the point cloud according to a zoom level defined by maxError (in layer...
QVector< QVariantMap > identify(QgsPointCloudLayer *layer, const QgsRenderContext &context, const QgsGeometry &geometry, double toleranceForPointIdentification=0)
Returns the list of visible points of the point cloud layer layer and an extent defined by a geometry...
void setPointSymbol(Qgis::PointCloudSymbol symbol)
Sets the symbol used by the renderer for drawing points.
RenderUnit
Rendering size units.
double mapUnitsPerPixel() const
Returns the current map units per pixel.
The class is used as a container of context for various read/write operations on other objects.
const QgsPointCloudAttribute * find(const QString &attributeName, int &offset) const
Finds the attribute with the name.
Qgis::PointCloudSymbol pointSymbol() const
Returns the symbol used by the renderer for drawing points.
static QString encodeMapUnitScale(const QgsMapUnitScale &mapUnitScale)
Point geometry type, with support for z-dimension and m-values.
Qgis::GeometryOperationResult transform(const QgsCoordinateTransform &ct, Qgis::TransformDirection direction=Qgis::TransformDirection::Forward, bool transformZ=false) SIP_THROW(QgsCsException)
Transforms this geometry as described by the coordinate transform ct.
void setPointSize(double size)
Sets the point size.
Represents a map layer supporting display of point clouds.
Class for storage of 3D vectors similar to QVector3D, with the difference that it uses double precisi...
static QgsPointCloudRendererRegistry * pointCloudRendererRegistry()
Returns the application's point cloud renderer registry, used for managing point cloud layer 2D rende...
virtual ~QgsPreparedPointCloudRendererData()
virtual QSet< QString > usedAttributes(const QgsPointCloudRenderContext &context) const
Returns a list of attributes required by this renderer.
virtual QList< QgsLayerTreeModelLegendNode * > createLegendNodes(QgsLayerTreeLayer *nodeLayer)
Creates a set of legend nodes representing the renderer.
virtual void checkLegendItem(const QString &key, bool state=true)
Called when the check state of the legend item with the specified key is changed.
virtual std::unique_ptr< QgsPreparedPointCloudRendererData > prepare()
Returns prepared data container for bulk point color retrieval.
Contains information about the context of a rendering operation.
void copyCommonProperties(QgsPointCloudRenderer *destination) const
Copies common point cloud properties (such as point size and screen error) to the destination rendere...
QgsPointXY toMapCoordinates(int x, int y) const
Transforms device coordinates to map (world) coordinates.
QgsPointCloudRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
A rectangle specified with double values.
virtual void startRender(QgsPointCloudRenderContext &context)
Must be called when a new render cycle is started.
QString qgsDoubleToString(double a, int precision=17)
Returns a string representation of a double.
static Q_INVOKABLE QgsUnitTypes::RenderUnit decodeRenderUnit(const QString &string, bool *ok=nullptr)
Decodes a render unit from a string.
static QgsCircle from2Points(const QgsPoint &pt1, const QgsPoint &pt2) SIP_HOLDGIL
Constructs a circle by 2 points on the circle.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
QgsPointCloudDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
Represents a indexed point cloud node in octree.
Custom exception class for Coordinate Reference System related exceptions.
double maximumScreenError() const
Returns the maximum screen error allowed when rendering the point cloud.
static Q_INVOKABLE QString encodeUnit(QgsUnitTypes::DistanceUnit unit)
Encodes a distance unit to a string.
Encapsulates the render context for a 2D point cloud rendering operation.
int pointRecordSize() const
Returns total size of record.
void incrementPointsRendered(long count)
Increments the count of points rendered by the specified amount.
void setAttributes(const QgsPointCloudAttributeCollection &attributes)
Sets the attributes associated with the rendered block.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Layer tree node points to a map layer.
Collection of point cloud attributes.
@ Square
Renders points as squares.
void setMaximumScreenErrorUnit(QgsUnitTypes::RenderUnit unit)
Sets the unit for the maximum screen error allowed when rendering the point cloud.
PointCloudSymbol
Rendering symbols for point cloud points.
void setPointSizeUnit(const QgsUnitTypes::RenderUnit units)
Sets the units used for the point size.
PointCloudDrawOrder
Pointcloud rendering order for 2d views.
IndexedPointCloudNode root()
Returns root node of the index.
void setPointSizeMapUnitScale(const QgsMapUnitScale &scale)
Sets the map unit scale used for the point size.
QgsPointCloudAttributeCollection attributes() const
Returns the attributes associated with the rendered block.
virtual void stopRender(QgsPointCloudRenderContext &context)
Must be called when a render cycle has finished, to allow the renderer to clean up.
@ Circle
Renders points as circles.
QgsPointXY transform(const QgsPointXY &p) const
Transforms a point p from map (world) coordinates to device coordinates.
QgsDoubleRange zRange() const
Returns the range of z-values which should be rendered.
void setMaximumScreenError(double error)
Sets the maximum screen error allowed when rendering the point cloud.
double pointSize() const
Returns the point size.
A class to represent a 2D point.
double convertToPainterUnits(double size, QgsUnitTypes::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
void setDrawOrder2d(Qgis::PointCloudDrawOrder order)
Sets the drawing order used by the renderer for drawing points.
QgsPointXY asPoint() const
Returns the contents of the geometry as a 2-dimensional point.
static QgsPointCloudRenderer * load(QDomElement &element, const QgsReadWriteContext &context)
Creates a renderer from an XML element.
A geometry is the spatial representation of a feature.
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
static QgsGeometry fromRect(const QgsRectangle &rect) SIP_HOLDGIL
Creates a new geometry from a QgsRectangle.
Abstract base class for 2d point cloud renderers.
void restoreCommonProperties(const QDomElement &element, const QgsReadWriteContext &context)
Restores common renderer properties (such as point size and screen error) from the specified DOM elem...
int span() const
Returns the number of points in one direction in a single node.
long pointsRendered() const
Returns the total number of points rendered.
QgsUnitTypes::RenderUnit pointSizeUnit() const
Returns the units used for the point size.
virtual QgsPolygon * toPolygon(unsigned int segments=36) const
Returns a segmented polygon.
QgsPointCloudRenderContext(QgsRenderContext &context, const QgsVector3D &scale, const QgsVector3D &offset, double zValueScale, double zValueFixedOffset, QgsFeedback *feedback=nullptr)
Constructor for QgsPointCloudRenderContext.
Represents a indexed point clouds data in octree.
virtual QStringList legendRuleKeys() const
Returns a list of all rule keys for legend nodes created by the renderer.
void saveCommonProperties(QDomElement &element, const QgsReadWriteContext &context) const
Saves common renderer properties (such as point size and screen error) to the specified DOM element.
Qgis::PointCloudDrawOrder drawOrder2d() const
Returns the drawing order used by the renderer for drawing points.
QPainter * painter()
Returns the destination QPainter for the render operation.
const QgsMapUnitScale & pointSizeMapUnitScale() const
Returns the map unit scale used for the point size.
QgsRenderContext & renderContext()
Returns a reference to the context's render context.
QgsWkbTypes::GeometryType type
virtual bool legendItemChecked(const QString &key)
Returns true if the legend item with the specified key is checked.
static QgsMapUnitScale decodeMapUnitScale(const QString &str)
virtual QgsPointCloudIndex * index() const
Returns the point cloud index associated with the provider.