23using namespace Qt::StringLiterals;
36 QObject::tr(
"Extent Only" ),
39 QObject::tr(
"Attribute by Ramp" ),
45 QObject::tr(
"Classification" ),
51 qDeleteAll( mRenderers );
56 if ( !metadata || mRenderers.contains( metadata->
name() ) )
59 mRenderers[metadata->
name()] = metadata;
60 mRenderersOrder << metadata->
name();
66 if ( !mRenderers.contains( rendererName ) )
69 delete mRenderers[rendererName];
70 mRenderers.remove( rendererName );
71 mRenderersOrder.removeAll( rendererName );
77 return mRenderers.value( rendererName );
82 QStringList renderers;
83 for (
const QString &renderer : mRenderersOrder )
87 renderers << renderer;
115 if ( attributes.
indexOf(
"Red"_L1 ) >= 0 && attributes.
indexOf(
"Green"_L1 ) >= 0 && attributes.
indexOf(
"Blue"_L1 ) >= 0 )
117 auto renderer = std::make_unique< QgsPointCloudRgbRenderer >();
120 const double redMax = stats.
maximum( u
"Red"_s );
121 const double greenMax = stats.
maximum( u
"Red"_s );
122 const double blueMax = stats.
maximum( u
"Red"_s );
123 if ( !std::isnan( redMax ) && !std::isnan( greenMax ) && !std::isnan( blueMax ) )
125 const int maxValue = std::max( blueMax, std::max( redMax, greenMax ) );
137 const int rangeGuess = maxValue > 255 ? 65535 : 255;
139 if ( rangeGuess > 255 )
164 return renderer.release();
168 if ( attributes.
indexOf(
"Classification"_L1 ) >= 0 )
171 QList<int> classes = stats.
classesOf( u
"Classification"_s );
173 classes.removeAll( 0 );
174 classes.removeAll( 1 );
175 if ( !classes.empty() )
178 auto renderer = std::make_unique< QgsPointCloudClassifiedRenderer >(
"Classification"_L1, categories );
179 return renderer.release();
184 auto renderer = std::make_unique< QgsPointCloudAttributeByRampRenderer >();
185 renderer->setAttribute( u
"Z"_s );
188 const double zMin = stats.
minimum( u
"Z"_s );
189 const double zMax = stats.
maximum( u
"Z"_s );
190 if ( !std::isnan( zMin ) && !std::isnan( zMax ) )
192 renderer->setMinimum( zMin );
193 renderer->setMaximum( zMax );
199 renderer->setColorRampShader( shader );
201 return renderer.release();
210 const QList<int> layerClasses = stats.
classesOf( u
"Classification"_s );
213 if ( layerClasses.isEmpty() )
214 return defaultCategories;
217 for (
const int &layerClass : layerClasses )
219 const bool isDefaultCategory = layerClass >= 0 && layerClass < defaultCategories.size();
@ UInt16
Sixteen bit unsigned integer (quint16).
@ UnknownDataType
Unknown or unspecified type.
static QgsColorSchemeRegistry * colorSchemeRegistry()
Returns the application's color scheme registry, used for managing color schemes.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
void classifyColorRamp(int classes=0, int band=-1, const QgsRectangle &extent=QgsRectangle(), QgsRasterInterface *input=nullptr)
Classify color ramp shader.
QColor fetchRandomStyleColor() const
Returns a random color for use with a new symbol style (e.g.
Handles contrast enhancement and clipping.
@ StretchToMinimumMaximum
Linear histogram.
void setMinimumValue(double value, bool generateTable=true)
Sets the minimum value for the contrast enhancement range.
void setContrastEnhancementAlgorithm(ContrastEnhancementAlgorithm algorithm, bool generateTable=true)
Sets the contrast enhancement algorithm.
void setMaximumValue(double value, bool generateTable=true)
Sets the maximum value for the contrast enhancement range.
virtual QString name() const =0
Returns a provider name.
An RGB renderer for 2d visualisation of point clouds using embedded red, green and blue attributes.
static QgsPointCloudRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates an RGB renderer from an XML element.
A collection of point cloud attributes.
int indexOf(const QString &name) const
Returns the index of the attribute with the specified name.
Represents an individual category (class) from a QgsPointCloudClassifiedRenderer.
static QgsPointCloudRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates an RGB renderer from an XML element.
static QgsPointCloudCategoryList defaultCategories()
Returns the default list of categories.
Base class for providing data for QgsPointCloudLayer.
virtual QgsPointCloudAttributeCollection attributes() const =0
Returns the attributes available from this data provider.
static QMap< int, QString > translatedLasClassificationCodes()
Returns the map of LAS classification code to translated string value, corresponding to the ASPRS Sta...
bool hasValidIndex() const
Returns whether provider has index which is valid.
A renderer for 2d visualisation of point clouds which shows the dataset's extents using a fill symbol...
static QgsPointCloudRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates an extent renderer from an XML element.
Represents a map layer supporting display of point clouds.
@ Calculating
The statistics calculation task is running.
PointCloudStatisticsCalculationState statisticsCalculationState() const
Returns the status of point cloud statistics calculation.
QgsPointCloudDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
const QgsPointCloudStatistics statistics() const
Returns the object containing statistics.
QgsPointCloudRendererRegistry()
static QgsPointCloudCategoryList classificationAttributeCategories(const QgsPointCloudLayer *layer)
Returns a list of categories using the available Classification classes of a specified layer,...
QgsPointCloudRendererAbstractMetadata * rendererMetadata(const QString &rendererName)
Returns the metadata for a specified renderer.
static QgsPointCloudRenderer * defaultRenderer(const QgsPointCloudLayer *layer)
Returns a new default point cloud renderer for a specified layer.
bool addRenderer(QgsPointCloudRendererAbstractMetadata *metadata)
Adds a renderer to the registry.
~QgsPointCloudRendererRegistry()
bool removeRenderer(const QString &rendererName)
Removes a renderer from registry.
QStringList renderersList() const
Returns a list of available renderers.
Abstract base class for 2d point cloud renderers.
static QgsPointCloudRenderer * create(QDomElement &element, const QgsReadWriteContext &context)
Creates an RGB renderer from an XML element.
Used to store statistics of a point cloud dataset.
double maximum(const QString &attribute) const
Returns the maximum value for the attribute attribute If no matching statistic is available then NaN ...
QList< int > classesOf(const QString &attribute) const
Returns a list of existing classes which are present for the specified attribute.
double minimum(const QString &attribute) const
Returns the minimum value for the attribute attribute If no matching statistic is available then NaN ...
virtual void setMaximumValue(double value)
Sets the maximum value for the raster shader.
virtual void setMinimumValue(double value)
Sets the minimum value for the raster shader.
A rectangle specified with double values.
QList< QgsPointCloudCategory > QgsPointCloudCategoryList