47#include "qgsvirtualpointcloudprovider.h"
53#include "moc_qgspointcloudlayer.cpp"
55using namespace Qt::StringLiterals;
60 , mLayerOptions( options )
62 if ( !uri.isEmpty() && !providerLib.isEmpty() )
64 const QgsDataProvider::ProviderOptions providerOptions { options.transformContext };
68 providerFlags |= Qgis::DataProviderReadFlag::LoadDefaultStyle;
70 setDataSource( uri, baseName, providerLib, providerOptions, providerFlags );
84 mStatsCalculationTask = 0;
86 task->waitForFinished();
98 layer->setRenderer( mRenderer->clone() );
100 layer->mElevationProperties = mElevationProperties->clone();
101 layer->mElevationProperties->setParent( layer );
103 layer->mLayerOptions = mLayerOptions;
104 layer->mSync3DRendererTo2DRenderer = mSync3DRendererTo2DRenderer;
113 if ( !mDataProvider )
116 return mDataProvider->extent();
123 if ( mRenderer->type() !=
"extent"_L1 )
124 loadIndexesForRenderContext( rendererContext );
145 return mDataProvider.get();
152 return mDataProvider.get();
160 const QDomNode pkeyNode = layerNode.namedItem( u
"provider"_s );
170 const QDomNode extentNode = layerNode.namedItem( u
"extent"_s );
171 if ( !extentNode.isNull() )
182 const QDomNode subset = layerNode.namedItem( u
"subset"_s );
183 const QString subsetText = subset.toElement().text();
184 if ( !subsetText.isEmpty() )
205 QDomElement mapLayerNode = layerNode.toElement();
210 QDomElement subset = doc.createElement( u
"subset"_s );
211 const QDomText subsetText = doc.createTextNode(
subsetString() );
212 subset.appendChild( subsetText );
213 layerNode.appendChild( subset );
217 QDomElement provider = doc.createElement( u
"provider"_s );
218 const QDomText providerText = doc.createTextNode(
providerType() );
219 provider.appendChild( providerText );
220 layerNode.appendChild( provider );
233 const QDomElement elem = node.toElement();
237 readStyle( node, errorMessage, context, categories );
242 if ( categories.testFlag(
Legend ) )
246 const QDomElement legendElem = node.firstChildElement( u
"legend"_s );
249 l->readXml( legendElem, context );
265 bool sync = node.attributes().namedItem( u
"sync3DRendererTo2DRenderer"_s ).nodeValue().toInt( &ok );
272 QDomElement rendererElement = node.firstChildElement( u
"renderer"_s );
273 if ( !rendererElement.isNull() )
295 const QDomNode blendModeNode = node.namedItem( u
"blendMode"_s );
296 if ( !blendModeNode.isNull() )
298 const QDomElement e = blendModeNode.toElement();
306 const QDomNode layerOpacityNode = node.namedItem( u
"layerOpacity"_s );
307 if ( !layerOpacityNode.isNull() )
309 const QDomElement e = layerOpacityNode.toElement();
313 const bool hasScaleBasedVisibiliy { node.attributes().namedItem( u
"hasScaleBasedVisibilityFlag"_s ).nodeValue() ==
'1' };
316 const double maxScale { node.attributes().namedItem( u
"maxScale"_s ).nodeValue().toDouble( &ok ) };
321 const double minScale { node.attributes().namedItem( u
"minScale"_s ).nodeValue().toDouble( &ok ) };
334 Q_UNUSED( errorMessage )
336 QDomElement elem = node.toElement();
339 ( void )
writeStyle( node, doc, errorMessage, context, categories );
344 if ( !legendElement.isNull() )
345 node.appendChild( legendElement );
355 QDomElement mapLayerNode = node.toElement();
359 mapLayerNode.setAttribute( u
"sync3DRendererTo2DRenderer"_s, mSync3DRendererTo2DRenderer ? 1 : 0 );
366 const QDomElement rendererElement = mRenderer->save( doc, context );
367 node.appendChild( rendererElement );
380 QDomElement blendModeElem = doc.createElement( u
"blendMode"_s );
382 blendModeElem.appendChild( blendModeText );
383 node.appendChild( blendModeElem );
389 QDomElement layerOpacityElem = doc.createElement( u
"layerOpacity"_s );
390 const QDomText layerOpacityText = doc.createTextNode( QString::number(
opacity() ) );
391 layerOpacityElem.appendChild( layerOpacityText );
392 node.appendChild( layerOpacityElem );
395 mapLayerNode.setAttribute( u
"maxScale"_s,
maximumScale() );
396 mapLayerNode.setAttribute( u
"minScale"_s,
minimumScale() );
426 mDataProvider.reset( qobject_cast< QgsPointCloudDataProvider * >(
mPreloadedProvider.release() ) );
430 std::unique_ptr< QgsScopedRuntimeProfile > profile;
432 profile = std::make_unique< QgsScopedRuntimeProfile >( tr(
"Create %1 provider" ).arg( provider ), u
"projectload"_s );
436 if ( !mDataProvider )
438 QgsDebugError( u
"Unable to get point cloud data provider"_s );
443 mIsVpc = qobject_cast<QgsVirtualPointCloudProvider *>( mDataProvider.get() ) !=
nullptr;
445 mDataProvider->setParent(
this );
446 QgsDebugMsgLevel( u
"Instantiated the point cloud data provider plugin"_s, 2 );
448 setValid( mDataProvider->isValid() );
460 setCrs( mDataProvider->crs() );
466 bool loadDefaultStyleFlag =
false;
469 loadDefaultStyleFlag =
true;
474 mDataProvider->generateIndex();
479 calculateStatistics();
482 if ( !mRenderer || loadDefaultStyleFlag )
484 std::unique_ptr< QgsScopedRuntimeProfile > profile;
486 profile = std::make_unique< QgsScopedRuntimeProfile >( tr(
"Load layer style" ), u
"projectload"_s );
488 bool defaultLoadedFlag =
false;
493 std::unique_ptr< QgsPointCloudRenderer > defaultRenderer( mDataProvider->createRenderer() );
494 if ( defaultRenderer )
496 defaultLoadedFlag =
true;
501 if ( !defaultLoadedFlag && loadDefaultStyleFlag )
506 if ( !defaultLoadedFlag )
541 QgsError providerError = mDataProvider->error();
542 if ( !providerError.
isEmpty() )
562 std::unique_ptr< QgsPointCloudRenderer > defaultRenderer( mDataProvider->createRenderer() );
563 if ( defaultRenderer )
579 QString myMetadata = u
"<html>\n<body>\n"_s;
584 myMetadata += u
"<h1>"_s + tr(
"Information from provider" ) + u
"</h1>\n<hr>\n"_s;
585 myMetadata +=
"<table class=\"list-view\">\n"_L1;
588 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"Extent" ) + u
"</td><td>"_s +
extent().
toString() + u
"</td></tr>\n"_s;
591 QLocale locale = QLocale();
592 locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
593 const qint64
pointCount = mDataProvider ? mDataProvider->pointCount() : -1;
594 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"Point count" ) + u
"</td><td>"_s + (
pointCount < 0 ? tr(
"unknown" ) : locale.toString(
static_cast<qlonglong
>(
pointCount ) ) ) + u
"</td></tr>\n"_s;
598 myMetadata += provider->htmlMetadata();
601 myMetadata +=
"</table>\n<br><br>"_L1;
607 myMetadata += u
"<h1>"_s + tr(
"Metadata" ) + u
"</h1>\n<hr>\n"_s + u
"<table class=\"list-view\">\n"_s;
608 const QVariantMap originalMetadata = mDataProvider ? mDataProvider->originalMetadata() : QVariantMap();
610 if ( originalMetadata.value( u
"creation_year"_s ).toInt() > 0 && originalMetadata.contains( u
"creation_doy"_s ) )
612 QDate creationDate( originalMetadata.value( u
"creation_year"_s ).toInt(), 1, 1 );
613 creationDate = creationDate.addDays( originalMetadata.value( u
"creation_doy"_s ).toInt() );
615 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"Creation date" ) + u
"</td><td>"_s + creationDate.toString( Qt::ISODate ) + u
"</td></tr>\n"_s;
617 if ( originalMetadata.contains( u
"major_version"_s ) && originalMetadata.contains( u
"minor_version"_s ) )
619 myMetadata += u
"<tr><td class=\"highlight\">"_s
622 + u
"%1.%2"_s.arg( originalMetadata.value( u
"major_version"_s ).toString(), originalMetadata.value( u
"minor_version"_s ).toString() )
626 if ( !originalMetadata.value( u
"dataformat_id"_s ).toString().isEmpty() )
628 myMetadata += u
"<tr><td class=\"highlight\">"_s
629 + tr(
"Data format" )
637 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"Scale X" ) + u
"</td><td>"_s + QString::number( originalMetadata.value( u
"scale_x"_s ).toDouble() ) + u
"</td></tr>\n"_s;
638 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"Scale Y" ) + u
"</td><td>"_s + QString::number( originalMetadata.value( u
"scale_y"_s ).toDouble() ) + u
"</td></tr>\n"_s;
639 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"Scale Z" ) + u
"</td><td>"_s + QString::number( originalMetadata.value( u
"scale_z"_s ).toDouble() ) + u
"</td></tr>\n"_s;
641 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"Offset X" ) + u
"</td><td>"_s + QString::number( originalMetadata.value( u
"offset_x"_s ).toDouble() ) + u
"</td></tr>\n"_s;
642 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"Offset Y" ) + u
"</td><td>"_s + QString::number( originalMetadata.value( u
"offset_y"_s ).toDouble() ) + u
"</td></tr>\n"_s;
643 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"Offset Z" ) + u
"</td><td>"_s + QString::number( originalMetadata.value( u
"offset_z"_s ).toDouble() ) + u
"</td></tr>\n"_s;
645 if ( !originalMetadata.value( u
"project_id"_s ).toString().isEmpty() )
647 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"Project ID" ) + u
"</td><td>"_s + originalMetadata.value( u
"project_id"_s ).toString() + u
"</td></tr>\n"_s;
650 if ( !originalMetadata.value( u
"system_id"_s ).toString().isEmpty() )
652 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"System ID" ) + u
"</td><td>"_s + originalMetadata.value( u
"system_id"_s ).toString() + u
"</td></tr>\n"_s;
655 if ( !originalMetadata.value( u
"software_id"_s ).toString().isEmpty() )
657 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"Software ID" ) + u
"</td><td>"_s + originalMetadata.value( u
"software_id"_s ).toString() + u
"</td></tr>\n"_s;
661 myMetadata +=
"</table>\n<br><br>"_L1;
664 myMetadata += u
"<h1>"_s + tr(
"Identification" ) + u
"</h1>\n<hr>\n"_s;
665 myMetadata += htmlFormatter.identificationSectionHtml();
666 myMetadata +=
"<br><br>\n"_L1;
669 myMetadata += u
"<h1>"_s + tr(
"Extent" ) + u
"</h1>\n<hr>\n"_s;
670 myMetadata += htmlFormatter.extentSectionHtml(
isSpatial() );
671 myMetadata +=
"<br><br>\n"_L1;
674 myMetadata += u
"<h1>"_s + tr(
"Access" ) + u
"</h1>\n<hr>\n"_s;
675 myMetadata += htmlFormatter.accessSectionHtml();
676 myMetadata +=
"<br><br>\n"_L1;
679 myMetadata += u
"<h1>"_s + tr(
"Attributes" ) + u
"</h1>\n<hr>\n<table class=\"list-view\">\n"_s;
684 myMetadata += u
"<tr><td class=\"highlight\">"_s + tr(
"Count" ) + u
"</td><td>"_s + QString::number( attrs.
count() ) + u
"</td></tr>\n"_s;
686 myMetadata +=
"</table>\n<br><table width=\"100%\" class=\"tabular-view\">\n"_L1;
687 myMetadata +=
"<tr><th>"_L1 + tr(
"Attribute" ) +
"</th><th>"_L1 + tr(
"Type" ) +
"</th></tr>\n"_L1;
689 for (
int i = 0; i < attrs.
count(); ++i )
694 rowClass = u
"class=\"odd-row\""_s;
695 myMetadata +=
"<tr "_L1 + rowClass +
"><td>"_L1 + attribute.
name() +
"</td><td>"_L1 + attribute.
displayType() +
"</td></tr>\n"_L1;
699 myMetadata +=
"</table>\n<br><br>"_L1;
703 myMetadata += u
"<h1>"_s + tr(
"Contacts" ) + u
"</h1>\n<hr>\n"_s;
704 myMetadata += htmlFormatter.contactsSectionHtml();
705 myMetadata +=
"<br><br>\n"_L1;
708 myMetadata += u
"<h1>"_s + tr(
"Links" ) + u
"</h1>\n<hr>\n"_s;
709 myMetadata += htmlFormatter.linksSectionHtml();
710 myMetadata +=
"<br><br>\n"_L1;
713 myMetadata += u
"<h1>"_s + tr(
"History" ) + u
"</h1>\n<hr>\n"_s;
714 myMetadata += htmlFormatter.historySectionHtml();
715 myMetadata +=
"<br><br>\n"_L1;
719 myMetadata +=
"\n</body>\n</html>\n"_L1;
727 return mElevationProperties;
741 return mDataProvider ? mDataProvider->pointCount() : 0;
748 return mRenderer.get();
755 return mRenderer.get();
769 if ( mSync3DRendererTo2DRenderer )
777 if ( !
isValid() || !mDataProvider )
779 QgsDebugMsgLevel( u
"invoked with invalid layer or null mDataProvider"_s, 3 );
783 else if ( subset == mDataProvider->subsetString() )
786 bool res = mDataProvider->setSubsetString( subset );
799 if ( !
isValid() || !mDataProvider )
801 QgsDebugMsgLevel( u
"invoked with invalid layer or null mDataProvider"_s, 3 );
804 return mDataProvider->subsetString();
815 result = newRenderer->convertFrom2DRenderer(
renderer() );
826 return mSync3DRendererTo2DRenderer;
833 mSync3DRendererTo2DRenderer = sync;
838void QgsPointCloudLayer::calculateStatistics()
842 if ( !mDataProvider.get() || !mDataProvider->hasValidIndex() )
847 if ( mStatsCalculationTask )
849 QgsMessageLog::logMessage( QObject::tr(
"A statistics calculation task for the point cloud %1 is already in progress" ).arg( this->
name() ) );
853 QgsPointCloudStatistics indexStats = mDataProvider->metadataStatistics();
854 QList<QString> indexStatsAttributes = indexStats.
statisticsMap().keys();
855 QVector<QgsPointCloudAttribute>
attributes = mDataProvider->attributes().attributes();
859 if ( indexStatsAttributes.contains(
attributes[i].name() ) )
867 mStatistics = indexStats;
877 QgsPointCloudStatsCalculationTask *task =
new QgsPointCloudStatsCalculationTask( mDataProvider->index(),
attributes, 1000000 );
879 mStatistics = task->calculationResults();
882 QMap<QString, QgsPointCloudAttributeStatistics> statsMap = mStatistics.statisticsMap();
883 for (
const QString &attribute : indexStatsAttributes )
885 statsMap[attribute] = indexStats.
statisticsOf( attribute );
887 mStatistics = QgsPointCloudStatistics( mStatistics.sampledPointsCount(), statsMap );
892 mStatsCalculationTask = 0;
894 if ( mDataProvider && mDataProvider->index() && mDataProvider->index().isValid() && mDataProvider->name() ==
"pdal"_L1 && mStatistics.sampledPointsCount() != 0 )
896 mDataProvider->index().writeStatistics( mStatistics );
903 if ( mStatsCalculationTask )
906 mStatsCalculationTask = 0;
916void QgsPointCloudLayer::resetRenderer()
920 mDataProvider->loadIndex();
923 calculateStatistics();
925 if ( !mRenderer || mRenderer->type() ==
"extent"_L1 )
934void QgsPointCloudLayer::loadIndexesForRenderContext(
QgsRenderContext &rendererContext )
const
938 QgsRectangle renderExtent;
943 catch ( QgsCsException & )
948 const QVector<QgsPointCloudSubIndex> subIndex = mDataProvider->subIndexes();
949 if (
const QgsVirtualPointCloudProvider *vpcProvider =
dynamic_cast<QgsVirtualPointCloudProvider *
>( mDataProvider.get() ) )
951 for (
int i = 0; i < subIndex.size(); ++i )
954 if ( subIndex.at( i ).index() )
957 const double overviewSwitchingScale = mRenderer ? mRenderer->overviewSwitchingScale() : 1.0;
958 const double widthThreshold = vpcProvider->averageSubIndexWidth() * overviewSwitchingScale;
959 const double heightThreshold = vpcProvider->averageSubIndexHeight() * overviewSwitchingScale;
961 if ( subIndex.at( i ).extent().intersects( renderExtent ) && ( renderExtent.
width() < widthThreshold || renderExtent.
height() < heightThreshold ) )
963 mDataProvider->loadSubIndex( i,
true );
973 if ( !mDataProvider || mEditable )
978 QgsVirtualPointCloudProvider *vpcProvider = qobject_cast<QgsVirtualPointCloudProvider *>( mDataProvider.get() );
979 const QVector<QgsPointCloudSubIndex>
subIndexes = vpcProvider->subIndexes();
983 const QgsPointCloudSubIndex &subIndex =
subIndexes.at( i );
986 if ( !
index.isValid() )
992 mEditingIndexes[i] = editIndex;
998 if ( !mEditIndex.isValid() )
1017 if (
index.isModified() && !
index.commitChanges( &mCommitError ) )
1022 if ( mEditIndex.isModified() && !mEditIndex.commitChanges( &mCommitError ) )
1034 mEditingIndexes.clear();
1048 return mCommitError;
1059 if ( mEditingIndexes.isEmpty() )
1062 QVector<QPair<int, QList<QgsPointCloudNodeId>>> queuedUpdates;
1063 queuedUpdates.reserve( mEditingIndexes.size() );
1064 for (
auto [position,
index] : mEditingIndexes.asKeyValueRange() )
1066 if ( !
index.isValid() )
1068 const QList<QgsPointCloudNodeId> updatedNodes =
index.updatedNodes();
1069 if ( !updatedNodes.isEmpty() )
1070 queuedUpdates.push_back( qMakePair( position, updatedNodes ) );
1075 mEditingIndexes.clear();
1078 for (
const QPair<
int, QList<QgsPointCloudNodeId>> &pair : std::as_const( queuedUpdates ) )
1080 const int position = pair.first;
1081 const QList<QgsPointCloudNodeId> &nodes = pair.second;
1091 const QList<QgsPointCloudNodeId> updatedNodes = mEditIndex.updatedNodes();
1131 if (
index.isModified() )
1140 return mEditIndex.isModified();
1157 QgsEventTracing::ScopedEvent _trace( u
"PointCloud"_s, u
"QgsPointCloudLayer::changeAttributeValue"_s );
1162 QVector<QgsPointCloudSubIndex> subs =
subIndexes();
1164 for (
auto it = mappedPoints.constBegin(); it != mappedPoints.constEnd(); it++ )
1166 const int position = it.key();
1167 QHash<QgsPointCloudNodeId, QVector<int>> nodesAndPoints = it.value();
1173 if ( position >= subs.size() || position < 0 )
1184 editIndex = mEditIndex;
1189 if ( attribute.
name().compare(
'X'_L1, Qt::CaseInsensitive ) == 0 || attribute.
name().compare(
'Y'_L1, Qt::CaseInsensitive ) == 0 || attribute.
name().compare(
'Z'_L1, Qt::CaseInsensitive ) == 0 )
1194 int attributeOffset;
1197 if ( !at || at->
size() != attribute.
size() || at->
type() != attribute.
type() )
1207 for (
auto it = nodesAndPoints.constBegin(); it != nodesAndPoints.constEnd(); it++ )
1210 QVector<int> points = it.value();
1215 if ( points.isEmpty() )
1218 int pointsMin = std::numeric_limits<int>::max();
1219 int pointsMax = std::numeric_limits<int>::min();
1220 for (
int pt : std::as_const( points ) )
1222 if ( pt < pointsMin )
1224 if ( pt > pointsMax )
1244 if ( mDataProvider )
1245 return mDataProvider->index();
1254 if ( !mDataProvider )
1255 return QVector<QgsPointCloudSubIndex>();
1257 const QVector<QgsPointCloudSubIndex> subs = mDataProvider->subIndexes();
1264 QVector<QgsPointCloudSubIndex> indexes;
1265 indexes.reserve( subs.size() );
1267 for ( qsizetype i = 0; i < subs.size(); i++ )
1269 QgsPointCloudSubIndex sub = subs.at( i );
1272 if (
index.isValid() )
1274 if ( !mEditingIndexes.contains( i ) )
1277 mEditingIndexes[i] = editIndex;
1279 sub.setIndex( mEditingIndexes[i] );
1281 indexes.append( sub );
1289 if ( !mDataProvider || !mIsVpc )
1292 const QgsVirtualPointCloudProvider *vpcProvider =
dynamic_cast<QgsVirtualPointCloudProvider *
>( mDataProvider.get() );
1294 if ( vpcProvider->overviews().isEmpty() )
1297 return vpcProvider->overviews().first();
1302 if ( !mDataProvider || !mIsVpc )
1305 const QgsVirtualPointCloudProvider *vpcProvider =
dynamic_cast<QgsVirtualPointCloudProvider *
>( mDataProvider.get() );
1306 return vpcProvider->overviews();
Provides global constants and enumerations for use throughout the application.
BlendMode
Blending modes defining the available composition modes that can be used when painting.
QFlags< DataProviderReadFlag > DataProviderReadFlags
Flags which control data provider construction.
@ TriangulatedSurface
Create a TIN from the point cloud using Delaunay triangulation.
@ PointCloud
Point cloud layer. Added in QGIS 3.18.
@ LoadDefaultStyle
Reset the layer's style to the default for the datasource.
@ SkipGetExtent
Skip the extent from provider.
@ Reverse
Reverse/inverse transform (from destination to source).
Base class for point cloud 3D renderers.
Abstract base class for objects which generate elevation profiles.
static QgsRuntimeProfiler * profiler()
Returns the application runtime profiler.
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling.
Contains information about the context in which a coordinate transform is executed.
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
bool isEmpty() const
Test if no error is set.
QString summary() const
Short error description, usually the first error in chain, the real error.
Base class for storage of map layer elevation properties.
static QString typeToString(Qgis::LayerType type)
Converts a map layer type to a string value.
An abstract interface for implementations of legends for one map layer.
static QgsMapLayerLegend * defaultPointCloudLegend(QgsPointCloudLayer *layer)
Create new legend implementation for a point cloud layer.
virtual QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a DOM element, to be used later with readXml().
Base class for utility classes that encapsulate information necessary for rendering of map layers.
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any). To be called by subclasses.
virtual bool isSpatial() const
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated w...
QgsAbstract3DRenderer * renderer3D() const
Returns 3D renderer associated with the layer.
void setError(const QgsError &error)
Sets error message.
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists). To be called by subclasses.
QgsMapLayerLegend * legend() const
Can be nullptr.
void editingStopped()
Emitted when edited changes have been successfully written to the data provider.
QString source() const
Returns the source for the layer.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QString providerType() const
Returns the provider type (provider key) for this layer.
virtual void setExtent3D(const QgsBox3D &box)
Sets the extent.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
void configChanged()
Emitted whenever the configuration is changed.
void trigger3DUpdate()
Will advise any 3D maps that this layer requires to be updated in the scene.
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
static Qgis::DataProviderReadFlags providerReadFlags(const QDomNode &layerNode, QgsMapLayer::ReadFlags layerReadFlags)
Returns provider read flag deduced from layer read flags layerReadFlags and a dom node layerNode that...
void editingStarted()
Emitted when editing on this layer has started.
void writeCustomProperties(QDomNode &layerNode, QDomDocument &doc) const
Write custom properties to project file.
virtual QString loadDefaultStyle(bool &resultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
void setDataSource(const QString &dataSource, const QString &baseName=QString(), const QString &provider=QString(), bool loadDefaultStyleFlag=false)
Updates the data source of the layer.
QString mLayerName
Name of the layer - used for display.
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
QString crsHtmlMetadata() const
Returns a HTML fragment containing the layer's CRS metadata, for use in the htmlMetadata() method.
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.
QgsLayerMetadata metadata
QgsMapLayer(Qgis::LayerType type=Qgis::LayerType::Vector, const QString &name=QString(), const QString &source=QString())
Constructor for QgsMapLayer.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith=QString())
Read custom properties from project file.
QFlags< StyleCategory > StyleCategories
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
QString mProviderKey
Data provider key (name of the data provider).
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
QUndoStack * undoStack()
Returns pointer to layer's undo stack.
std::unique_ptr< QgsDataProvider > mPreloadedProvider
Optionally used when loading a project, it is released when the layer is effectively created.
void rendererChanged()
Signal emitted when renderer is changed.
void setScaleBasedVisibility(bool enabled)
Sets whether scale based visibility is enabled for the layer.
QgsMapLayer::LayerFlags flags
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
void emitStyleChanged()
Triggers an emission of the styleChanged() signal.
void dataChanged()
Data of layer changed.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
void setName(const QString &name)
Set the display name of the layer.
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
QString mDataSource
Data source description string, varies by layer type.
@ FlagReadExtentFromXml
Read extent from xml and skip get extent from provider.
@ FlagDontResolveLayers
Don't resolve layer paths or create data providers for layers.
void setValid(bool valid)
Sets whether layer is valid or not.
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types.
QgsMapLayer::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when restoring state from XML.
double minimumScale() const
Returns the minimum map scale (i.e.
@ Rendering
Rendering: scale visibility, simplify method, opacity.
@ Symbology3D
3D symbology
@ CustomProperties
Custom properties (by plugins for instance).
void layerModified()
Emitted when modifications has been done on layer.
void setRenderer3D(QgsAbstract3DRenderer *renderer)
Sets 3D renderer for the layer.
QString customPropertyHtmlMetadata() const
Returns an HTML fragment containing custom property information, for use in the htmlMetadata() method...
QString generalHtmlMetadata() const
Returns an HTML fragment containing general metadata information, for use in the htmlMetadata() metho...
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write style data common to all layer types.
double maximumScale() const
Returns the maximum map scale (i.e.
void invalidateWgs84Extent()
Invalidates the WGS84 extent.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE(), Qgis::StringFormat format=Qgis::StringFormat::PlainText)
Adds a message to the log instance (and creates it if necessary).
static Qgis::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a Qgis::BlendMode corresponding to a QPainter::CompositionMode.
static QPainter::CompositionMode getCompositionMode(Qgis::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a Qgis::BlendMode.
A collection of point cloud attributes.
const QgsPointCloudAttribute & at(int index) const
Returns the attribute at the specified index.
const QgsPointCloudAttribute * find(const QString &attributeName, int &offset) const
Finds the attribute with the name.
int count() const
Returns the number of attributes present in the collection.
Attribute for point cloud data pair of name and size in bytes.
QString displayType() const
Returns the type to use when displaying this field.
int size() const
Returns size of the attribute in bytes.
QString name() const
Returns name of the attribute.
DataType type() const
Returns the data type.
Base class for providing data for QgsPointCloudLayer.
@ CreateRenderer
Provider can create 2D renderers using backend-specific formatting information. See QgsPointCloudData...
@ ChangeAttributeValues
Provider can modify the values of point attributes.
@ ContainSubIndexes
Provider can contain multiple indexes. Virtual point cloud files for example.
static QMap< int, QString > translatedDataFormatIds()
Returns the map of LAS data format ID to translated string value.
void indexGenerationStateChanged(QgsPointCloudDataProvider::PointCloudIndexGenerationState state)
Emitted when point cloud generation state is changed.
PointCloudIndexGenerationState
Point cloud index state.
@ NotIndexed
Provider has no index available.
@ Indexing
Provider try to index the source data.
@ Indexed
The index is ready to be used.
A QgsPointCloudIndex that is used as an editing buffer when editing point cloud data.
Smart pointer for QgsAbstractPointCloudIndex.
QgsPointCloudNode getNode(QgsPointCloudNodeId id) const
Returns object for a given node.
bool hasNode(QgsPointCloudNodeId id) const
Returns whether the octree contain given node.
QgsPointCloudAttributeCollection attributes() const
Returns all attributes that are stored in the file.
static bool isAttributeValueValid(const QgsPointCloudAttribute &attribute, double value)
Check if value is within proper range for the attribute.
Point cloud layer specific subclass of QgsMapLayerElevationProperties.
Implementation of QgsAbstractProfileGenerator for point cloud layers.
Implementation of threaded rendering for point cloud layers.
An undo command subclass for changing point attribute values in a point cloud index.
QString decodedSource(const QString &source, const QString &dataProvider, const QgsReadWriteContext &context) const override
Called by readLayerXML(), used by derived classes to decode provider's specific data source from proj...
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
void chunkAttributeValuesChanged(QgsPointCloudNodeId n, const int position)
Emitted when a node gets some attribute values of some points changed.
void setSync3DRendererTo2DRenderer(bool sync)
Sets whether this layer's 3D renderer should be automatically updated with changes applied to the lay...
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation properties.
@ Calculated
The statistics calculation task is done and statistics are available.
@ NotStarted
The statistics calculation task has not been started.
@ Calculating
The statistics calculation task is running.
bool sync3DRendererTo2DRenderer() const
Returns whether this layer's 3D renderer should be automatically updated with changes applied to the ...
bool writeXml(QDomNode &layerNode, QDomDocument &doc, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by children to write state specific to them to project files.
QgsRectangle extent() const override
Returns the extent of the layer.
bool isModified() const override
Returns true if the layer has been modified since last commit/save.
QString encodedSource(const QString &source, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by derived classes to encode provider's specific data source to proje...
QString loadDefaultStyle(bool &resultFlag) final
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
QgsPointCloudRenderer * renderer()
Returns the 2D renderer for the point cloud.
bool convertRenderer3DFromRenderer2D()
Updates the layer's 3D renderer's symbol to match that of the layer's 2D renderer.
qint64 pointCount() const
Returns the total number of points available in the layer.
QgsPointCloudIndex index() const
Returns the point cloud index associated with the layer.
bool commitChanges(bool stopEditing=true)
Attempts to commit to the underlying data provider any buffered changes made since the last to call t...
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const override
Write the style for the layer into the document provided.
void raiseError(const QString &msg)
Signals an error related to this point cloud layer.
PointCloudStatisticsCalculationState statisticsCalculationState() const
Returns the status of point cloud statistics calculation.
QgsPointCloudDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
bool isEditable() const override
Returns true if the layer can be edited.
bool changeAttributeValue(QgsPointCloudNodeId n, const QVector< int > &points, const QgsPointCloudAttribute &attribute, double value)
Attempts to modify attribute values for specific points in the editing buffer.
void statisticsCalculationStateChanged(QgsPointCloudLayer::PointCloudStatisticsCalculationState state)
Emitted when statistics calculation state has changed.
bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) override
Read the symbology for the current layer from the DOM node supplied.
bool rollBack()
Stops a current editing operation and discards any uncommitted edits.
bool writeStyle(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const final
Write just the symbology information for the layer into the document.
~QgsPointCloudLayer() override
Q_DECL_DEPRECATED QgsPointCloudIndex overview() const
Returns the overview point cloud index associated with the layer (only if the layer has a virtual poi...
QgsPointCloudLayer(const QString &uri=QString(), const QString &baseName=QString(), const QString &providerLib=u"pointcloud"_s, const QgsPointCloudLayer::LayerOptions &options=QgsPointCloudLayer::LayerOptions())
Constructor - creates a point cloud layer.
bool readXml(const QDomNode &layerNode, QgsReadWriteContext &context) override
Called by readLayerXML(), used by children to read state specific to them from project files.
QString subsetString() const
Returns the string used to define a subset of the layer.
bool setSubsetString(const QString &subset)
Sets the string used to define a subset of the layer.
QString commitError() const
Returns the last error message generated when attempting to commit changes to the layer.
QgsPointCloudLayer * clone() const override
Returns a new instance equivalent to this one except for the id which is still unique.
QVector< QgsPointCloudIndex > overviews() const
Returns a list of all overview point cloud indexes associated with the layer (only if the layer has a...
QVector< QgsPointCloudSubIndex > subIndexes() const
Returns point cloud indexes associated with the layer (only if the layer has a virtual point cloud da...
void setRenderer(QgsPointCloudRenderer *renderer)
Sets the 2D renderer for the point cloud.
QgsPointCloudAttributeCollection attributes() const
Returns the attributes available from the layer.
void subsetStringChanged()
Emitted when the layer's subset string has changed.
void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext.
bool startEditing()
Makes the layer editable.
bool supportsEditing() const override
Returns whether the layer supports editing or not.
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
bool readStyle(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) final
Read the style for the current layer from the DOM node supplied.
QgsAbstractProfileGenerator * createProfileGenerator(const QgsProfileRequest &request) override
Given a profile request, returns a new profile generator ready for generating elevation profiles.
Represents an indexed point cloud node's position in octree.
bool isValid() const
Returns whether node is valid.
qint64 pointCount() const
Returns number of points contained in node data.
static QgsPointCloudRenderer * defaultRenderer(const QgsPointCloudLayer *layer)
Returns a new default point cloud renderer for a specified layer.
Abstract base class for 2d point cloud renderers.
static QgsPointCloudRenderer * load(QDomElement &element, const QgsReadWriteContext &context)
Creates a renderer from an XML element.
int sampledPointsCount() const
Returns the number of points used to calculate the statistics.
QMap< QString, QgsPointCloudAttributeStatistics > statisticsMap() const
Returns a map object containing all the statistics.
QgsPointCloudAttributeStatistics statisticsOf(const QString &attribute) const
Returns the calculated statistics of attribute attribute.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
QString absoluteToRelativeUri(const QString &providerKey, const QString &uri, const QgsReadWriteContext &context) const
Converts absolute path(s) to relative path(s) in the given provider-specific URI.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QString relativeToAbsoluteUri(const QString &providerKey, const QString &uri, const QgsReadWriteContext &context) const
Converts relative path(s) to absolute path(s) in the given provider-specific URI.
Allows entering a context category and takes care of leaving this category on deletion of the class.
A container for the context for various read/write operations on objects.
QgsReadWriteContextCategoryPopper enterCategory(const QString &category, const QString &details=QString()) const
Push a category to the stack.
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
A rectangle specified with double values.
Q_INVOKABLE QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be rounded to the spec...
Contains information about the context of a rendering operation.
QgsRectangle mapExtent() const
Returns the original extent of the map being rendered.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
long addTask(QgsTask *task, int priority=0)
Adds a task to the manager.
Abstract base class for long running background tasks.
void taskCompleted()
Will be emitted by task to indicate its successful completion.
void taskTerminated()
Will be emitted by task if it has terminated for any reason other then completion (e....
Implementation of QgsAbstractProfileGenerator for triangulated point cloud layers.
static QgsRectangle readRectangle(const QDomElement &element)
#define QgsDebugMsgLevel(str, level)
#define QgsDebugError(str)
#define QGIS_PROTECT_QOBJECT_THREAD_ACCESS
Setting options for creating vector data providers.
Setting options for loading point cloud layers.
bool loadDefaultStyle
Set to true if the default layer style should be loaded.