QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
40 const QString &baseName,
41 const QString &providerKey,
52 if ( !meshLayerPath.isEmpty() && !providerKey.isEmpty() )
55 ok = setDataProvider( providerKey, providerOptions );
61 setDefaultRendererSettings();
72 void QgsMeshLayer::setDefaultRendererSettings()
81 if ( meta.
maximum() == std::numeric_limits<double>::quiet_NaN() &&
82 meta.
minimum() == std::numeric_limits<double>::quiet_NaN() )
113 applyClassificationOnScalarSettings( meta, scalarSettings );
120 void QgsMeshLayer::createSimplifiedMeshes()
122 if ( mSimplificationSettings.
isEnabled() && !hasSimplifiedMeshes() )
126 QVector<QgsTriangularMesh *> simplifyMeshes =
127 mTriangularMeshes[0]->simplifyMesh( reductionFactor );
129 for (
int i = 0; i < simplifyMeshes.count() ; ++i )
131 mTriangularMeshes.emplace_back( simplifyMeshes[i] );
136 bool QgsMeshLayer::hasSimplifiedMeshes()
const
139 return ( mTriangularMeshes.size() > 1 );
144 delete mDataProvider;
149 return mDataProvider;
154 return mDataProvider;
172 return mDataProvider->
extent();
193 if ( !isTemporalBefore &&
dataProvider()->temporalCapabilities()->hasTemporalCapabilities() )
200 QDateTime referenceTime = defaultReferenceTime;
201 if ( !defaultReferenceTime.isValid() )
202 referenceTime = QDateTime( QDate::currentDate(), QTime( 0, 0, 0, Qt::UTC ) );
216 return mNativeMesh.get();
221 return mNativeMesh.get();
226 for (
const std::unique_ptr<QgsTriangularMesh> &lod : mTriangularMeshes )
228 if ( lod && lod->averageTriangleSize() > minimumTriangleSize )
232 if ( !mTriangularMeshes.empty() )
233 return mTriangularMeshes.back().get();
248 if ( mTriangularMeshes.empty() )
251 mTriangularMeshes.emplace_back( baseMesh );
254 if ( mTriangularMeshes[0].get()->update( mNativeMesh.get(), transform ) )
255 mTriangularMeshes.resize( 1 );
260 return mRendererCache.get();
265 return mRendererSettings;
272 mRendererSettings = settings;
286 return mTimeSettings;
291 mTimeSettings = settings;
298 return QgsMeshLayerUtils::formatTime( hours, mTemporalProperties->
referenceTime(), mTimeSettings );
300 return QgsMeshLayerUtils::formatTime( hours, QDateTime(), mTimeSettings );
310 if (
dataProvider()->contains( QgsMesh::ElementType::Edge ) )
312 QgsRectangle searchRectangle( point.
x() - searchRadius, point.
y() - searchRadius, point.
x() + searchRadius, point.
y() + searchRadius );
316 if ( faceIndex >= 0 )
320 if (
dataProvider()->isFaceActive( index, nativeFaceIndex ) )
333 const int v1 = face[0], v2 = face[1], v3 = face[2];
338 const double x = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.
x(), val2.
x(), val3.
x(), point );
339 double y = std::numeric_limits<double>::quiet_NaN();
342 y = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.
y(), val2.
y(), val3.
y(), point );
357 value = block2d.
value( 0 );
385 if ( faceIndex >= 0 )
399 int selectedIndex = closestEdge( point, searchRadius, projectedPoint );
401 if ( selectedIndex >= 0 )
415 const int v1 = edge.first, v2 = edge.second;
419 double edgeLength = p1.
distance( p2 );
420 double dist1 = p1.
distance( projectedPoint.
x(), projectedPoint.
y() );
421 value = QgsMeshLayerUtils::interpolateFromVerticesData( dist1 / edgeLength, val1, val2 );
440 if ( ! mTemporalProperties->
isActive() )
443 const QDateTime layerReferenceTime = mTemporalProperties->
referenceTime();
444 qint64 startTime = layerReferenceTime.msecsTo( timeRange.begin() );
460 if ( meta.
extraOptions().contains( QStringLiteral(
"classification" ) ) )
464 QStringList classes = meta.
extraOptions()[QStringLiteral(
"classification" )].split( QStringLiteral(
";;" ) );
467 if ( meta.
extraOptions().contains( QStringLiteral(
"units" ) ) )
468 units = meta.
extraOptions()[ QStringLiteral(
"units" )];
470 QVector<QVector<double>> bounds;
471 for (
const QString classe : classes )
473 QStringList boundsStr = classe.split(
',' );
474 QVector<double> bound;
475 for (
const QString boundStr : boundsStr )
476 bound.append( boundStr.toDouble() );
477 bounds.append( bound );
480 if ( ( bounds.count() == 1 && bounds.first().count() > 2 ) ||
481 ( bounds.count() > 1 ) )
483 const QVector<double> firstClass = bounds.first();
484 const QVector<double> lastClass = bounds.last();
485 double minValue = firstClass.count() > 1 ? ( firstClass.first() + firstClass.last() ) / 2 : firstClass.first();
486 double maxValue = lastClass.count() > 1 ? ( lastClass.first() + lastClass.last() ) / 2 : lastClass.first();
487 double diff = maxValue - minValue;
488 QList<QgsColorRampShader::ColorRampItem> colorRampItemlist;
489 for (
int i = 0; i < bounds.count(); ++i )
491 const QVector<double> &boundClass = bounds.at( i );
494 if ( !boundClass.isEmpty() )
496 double scalarValue = ( boundClass.first() + boundClass.last() ) / 2;
497 item.
color = colorRamp->
color( ( scalarValue - minValue ) / diff );
498 if ( i != 0 && i < bounds.count() - 1 )
500 item.
label = QString( (
"%1 - %2 %3" ) ).
501 arg( QString::number( boundClass.first() ) ).
502 arg( QString::number( boundClass.last() ) ).
506 colorRampItemlist.append( item );
509 if ( firstClass.count() == 1 )
510 colorRampItemlist.first().label = QObject::tr(
"below %1 %2" ).
511 arg( QString::number( firstClass.first() ) ).
515 colorRampItemlist.first().label = QString( (
"%1 - %2 %3" ) ).
516 arg( QString::number( firstClass.first() ) ).
517 arg( QString::number( firstClass.last() ) ).
521 if ( lastClass.count() == 1 )
522 colorRampItemlist.last().label = QObject::tr(
"above %1 %2" ).
523 arg( QString::number( lastClass.first() ) ).
527 colorRampItemlist.last().label = QString( (
"%1 - %2 %3" ) ).
528 arg( QString::number( lastClass.first() ) ).
529 arg( QString::number( lastClass.last() ) ).
548 if ( mTemporalProperties->
isActive() )
556 if ( mTemporalProperties->
isActive() )
562 void QgsMeshLayer::fillNativeMesh()
564 Q_ASSERT( !mNativeMesh );
566 mNativeMesh.reset(
new QgsMesh() );
574 void QgsMeshLayer::onDatasetGroupsAdded(
int count )
578 for (
int i = newDatasetGroupCount - count; i < newDatasetGroupCount; ++i )
579 assignDefaultStyleToDatasetGroup( i );
585 QList<QgsMeshDatasetGroupMetadata> metadataList;
587 for (
int i = totalCount - count; i < totalCount; ++i )
589 QgsMeshLayerUtils::createDatasetGroupTreeItems( metadataList, mDatasetGroupTreeRootItem.get(), totalCount - count );
595 return mDatasetGroupTreeRootItem.get();
601 mDatasetGroupTreeRootItem.reset( rootItem->
clone() );
603 mDatasetGroupTreeRootItem.reset();
605 updateActiveDatasetGroups();
608 int QgsMeshLayer::closestEdge(
const QgsPointXY &point,
double searchRadius,
QgsPointXY &projectedPoint )
const
610 QgsRectangle searchRectangle( point.
x() - searchRadius, point.
y() - searchRadius, point.
x() + searchRadius, point.
y() + searchRadius );
614 int selectedIndex = -1;
618 double sqrMaxDistFromPoint = pow( searchRadius, 2 );
619 for (
const int edgeIndex : edgeIndexes )
625 double sqrDist = point.
sqrDistToSegment( vertex1.
x(), vertex1.
y(), vertex2.
x(), vertex2.
y(), projPoint );
626 if ( sqrDist < sqrMaxDistFromPoint )
628 selectedIndex = edgeIndex;
629 projectedPoint = projPoint;
630 sqrMaxDistFromPoint = sqrDist;
635 return selectedIndex;
661 return exactPosition;
662 QgsRectangle rectangle( point.
x() - searchRadius, point.
y() - searchRadius, point.
x() + searchRadius, point.
y() + searchRadius );
663 double maxDistance = searchRadius;
666 for (
const int edgeIndex : edgeIndexes )
671 double dist1 = point.
distance( vertex1 );
672 double dist2 = point.
distance( vertex2 );
673 if ( dist1 < maxDistance )
676 exactPosition = vertex1;
678 if ( dist2 < maxDistance )
681 exactPosition = vertex2;
687 for (
const int faceIndex : faceIndexes )
690 for (
int i = 0; i < 3; ++i )
693 double dist = point.
distance( vertex );
694 if ( dist < maxDistance )
697 exactPosition = vertex;
702 return exactPosition;
708 closestEdge( point, searchRadius, projectedPoint );
710 return projectedPoint;
718 return centroidPosition;
719 QgsRectangle rectangle( point.
x() - searchRadius, point.
y() - searchRadius, point.
x() + searchRadius, point.
y() + searchRadius );
720 double maxDistance = std::numeric_limits<double>::max();
723 for (
const int faceIndex : faceIndexes )
726 if ( nativefaceIndex < 0 && nativefaceIndex >= mesh->
faceCentroids().count() )
729 double dist = point.
distance( centroid );
730 if ( dist < maxDistance )
733 centroidPosition = centroid;
737 return centroidPosition;
743 QList<QgsMeshDatasetGroupMetadata> metadataList;
746 QgsMeshLayerUtils::createDatasetGroupTreeItems( metadataList, mDatasetGroupTreeRootItem.get(), 0 );
747 updateActiveDatasetGroups();
752 if ( !mDataProvider )
755 for (
int i = 0; i < groupCount; ++i )
765 void QgsMeshLayer::updateActiveDatasetGroups()
767 if ( !mDatasetGroupTreeRootItem )
775 mDatasetGroupTreeRootItem->childFromDatasetGroupIndex( oldActiveScalar );
777 if ( !activeScalarItem && mDatasetGroupTreeRootItem->childCount() > 0 )
778 activeScalarItem = mDatasetGroupTreeRootItem->child( 0 );
780 if ( activeScalarItem && !activeScalarItem->
isEnabled() )
782 for (
int i = 0; i < mDatasetGroupTreeRootItem->childCount(); ++i )
784 activeScalarItem = mDatasetGroupTreeRootItem->child( i );
788 activeScalarItem =
nullptr;
792 if ( activeScalarItem )
798 mDatasetGroupTreeRootItem->childFromDatasetGroupIndex( oldActiveVector );
800 if ( !( activeVectorItem && activeVectorItem->
isEnabled() ) )
813 switch ( elementType )
816 return snapOnVertex( point, searchRadius );
818 return snapOnEdge( point, searchRadius );
820 return snapOnFace( point, searchRadius );
854 return mSimplificationSettings;
859 mSimplificationSettings = simplifySettings;
870 props[
"color1"] =
"13,8,135,255";
871 props[
"color2"] =
"240,249,33,255";
873 "0.0196078;27,6,141,255:0.0392157;38,5,145,255:0.0588235;47,5,150,255:0.0784314;56,4,154,255:0.0980392;65,4,157,255:"
874 "0.117647;73,3,160,255:0.137255;81,2,163,255:0.156863;89,1,165,255:0.176471;97,0,167,255:0.196078;105,0,168,255:"
875 "0.215686;113,0,168,255:0.235294;120,1,168,255:0.254902;128,4,168,255:0.27451;135,7,166,255:0.294118;142,12,164,255:"
876 "0.313725;149,17,161,255:0.333333;156,23,158,255:0.352941;162,29,154,255:0.372549;168,34,150,255:0.392157;174,40,146,255:"
877 "0.411765;180,46,141,255:0.431373;186,51,136,255:0.45098;191,57,132,255:0.470588;196,62,127,255:0.490196;201,68,122,255:"
878 "0.509804;205,74,118,255:0.529412;210,79,113,255:0.54902;214,85,109,255:0.568627;218,91,105,255:0.588235;222,97,100,255:"
879 "0.607843;226,102,96,255:0.627451;230,108,92,255:0.647059;233,114,87,255:0.666667;237,121,83,255:0.686275;240,127,79,255:"
880 "0.705882;243,133,75,255:0.72549;245,140,70,255:0.745098;247,147,66,255:0.764706;249,154,62,255:0.784314;251,161,57,255:"
881 "0.803922;252,168,53,255:0.823529;253,175,49,255:0.843137;254,183,45,255:0.862745;254,190,42,255:0.882353;253,198,39,255:"
882 "0.901961;252,206,37,255:0.921569;251,215,36,255:0.941176;248,223,37,255:0.960784;246,232,38,255:0.980392;243,240,39,255";
886 void QgsMeshLayer::assignDefaultStyleToDatasetGroup(
int groupIndex )
889 double groupMin =
metadata.minimum();
890 double groupMax =
metadata.maximum();
893 fcn.classifyColorRamp( 5, -1,
QgsRectangle(),
nullptr );
920 createSimplifiedMeshes();
923 if ( !mRendererCache )
924 mRendererCache.reset(
new QgsMeshLayerRendererCache() );
932 Q_UNUSED( errorMessage )
935 QDomElement elem = node.toElement();
939 QDomElement elemRendererSettings = elem.firstChildElement(
"mesh-renderer-settings" );
940 if ( !elemRendererSettings.isNull() )
941 mRendererSettings.
readXml( elemRendererSettings );
943 QDomElement elemSimplifySettings = elem.firstChildElement(
"mesh-simplify-settings" );
944 if ( !elemSimplifySettings.isNull() )
945 mSimplificationSettings.
readXml( elemSimplifySettings, context );
948 QDomNode blendModeNode = node.namedItem( QStringLiteral(
"blendMode" ) );
949 if ( !blendModeNode.isNull() )
951 QDomElement e = blendModeNode.toElement();
961 Q_UNUSED( errorMessage )
964 QDomElement elem = node.toElement();
968 QDomElement elemRendererSettings = mRendererSettings.
writeXml( doc );
969 elem.appendChild( elemRendererSettings );
971 QDomElement elemSimplifySettings = mSimplificationSettings.
writeXml( doc, context );
972 elem.appendChild( elemSimplifySettings );
975 QDomElement blendModeElement = doc.createElement( QStringLiteral(
"blendMode" ) );
977 blendModeElement.appendChild( blendModeText );
978 node.appendChild( blendModeElement );
985 return writeSymbology( node, doc, errorMessage, context, categories );
990 return readSymbology( node, errorMessage, context, categories );
996 if ( provider == QLatin1String(
"mdal" ) )
1018 QDomNode pkeyNode = layer_node.namedItem( QStringLiteral(
"provider" ) );
1020 if ( pkeyNode.isNull() )
1026 QDomElement pkeyElt = pkeyNode.toElement();
1036 if ( !setDataProvider(
mProviderKey, providerOptions ) )
1041 QDomElement elemExtraDatasets = layer_node.firstChildElement( QStringLiteral(
"extra-datasets" ) );
1042 if ( !elemExtraDatasets.isNull() )
1044 QDomElement elemUri = elemExtraDatasets.firstChildElement( QStringLiteral(
"uri" ) );
1045 while ( !elemUri.isNull() )
1051 QgsDebugMsg( QStringLiteral(
"extra dataset (res %1): %2" ).arg( res ).arg( uri ) );
1056 elemUri = elemUri.nextSiblingElement( QStringLiteral(
"uri" ) );
1060 if ( mDataProvider && pkeyNode.toElement().hasAttribute( QStringLiteral(
"time-unit" ) ) )
1065 QDomElement elemDatasetGroupTree = layer_node.firstChildElement( QStringLiteral(
"dataset-groups-tree" ) );
1066 QDomElement rootItemElement = elemDatasetGroupTree.firstChildElement( QStringLiteral(
"mesh-dataset-group_tree-item" ) );
1067 if ( rootItemElement.isNull() )
1075 if ( !mTemporalProperties->
timeExtent().begin().isValid() )
1079 QDomElement elemStaticDataset = layer_node.firstChildElement( QStringLiteral(
"static-active-dataset" ) );
1080 if ( elemStaticDataset.hasAttribute( QStringLiteral(
"scalar" ) ) )
1082 mStaticScalarDatasetIndex = elemStaticDataset.attribute( QStringLiteral(
"scalar" ) ).toInt();
1084 if ( elemStaticDataset.hasAttribute( QStringLiteral(
"vector" ) ) )
1086 mStaticVectorDatasetIndex = elemStaticDataset.attribute( QStringLiteral(
"vector" ) ).toInt();
1095 QDomElement mapLayerNode = layer_node.toElement();
1097 if ( mapLayerNode.isNull() || ( QLatin1String(
"maplayer" ) != mapLayerNode.nodeName() ) )
1103 mapLayerNode.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"mesh" ) );
1106 if ( mDataProvider )
1108 QDomElement provider = document.createElement( QStringLiteral(
"provider" ) );
1109 QDomText providerText = document.createTextNode(
providerType() );
1110 provider.appendChild( providerText );
1111 layer_node.appendChild( provider );
1114 const QStringList extraDatasetUris = mDataProvider->
extraDatasets();
1115 QDomElement elemExtraDatasets = document.createElement( QStringLiteral(
"extra-datasets" ) );
1116 for (
const QString &uri : extraDatasetUris )
1119 QDomElement elemUri = document.createElement( QStringLiteral(
"uri" ) );
1120 elemUri.appendChild( document.createTextNode( path ) );
1121 elemExtraDatasets.appendChild( elemUri );
1123 layer_node.appendChild( elemExtraDatasets );
1126 QDomElement elemStaticDataset = document.createElement( QStringLiteral(
"static-active-dataset" ) );
1127 elemStaticDataset.setAttribute( QStringLiteral(
"scalar" ), mStaticScalarDatasetIndex );
1128 elemStaticDataset.setAttribute( QStringLiteral(
"vector" ), mStaticVectorDatasetIndex );
1129 layer_node.appendChild( elemStaticDataset );
1132 QDomElement elemDatasetTree = document.createElement( QStringLiteral(
"dataset-groups-tree" ) );
1133 elemDatasetTree.appendChild( mDatasetGroupTreeRootItem->writeXml( document, context ) );
1134 layer_node.appendChild( elemDatasetTree );
1138 return writeSymbology( layer_node, document, errorMsg, context );
1143 if ( mDataProvider && mDataProvider->
isValid() )
1149 mNativeMesh.reset(
new QgsMesh );
1154 mTriangularMeshes.clear();
1157 mRendererCache.reset(
new QgsMeshLayerRendererCache() );
1163 if ( mDataProvider )
1166 return QStringList();
1171 delete mDataProvider;
1177 if ( !mDataProvider )
1179 QgsDebugMsgLevel( QStringLiteral(
"Unable to get mesh data provider" ), 2 );
1183 mDataProvider->setParent(
this );
1184 QgsDebugMsgLevel( QStringLiteral(
"Instantiated the mesh data provider plugin" ), 2 );
1195 if ( provider == QStringLiteral(
"mesh_memory" ) )
1202 assignDefaultStyleToDatasetGroup( i );
1212 return mTemporalProperties;
int dataset() const
Returns a dataset index within group()
virtual int datasetGroupCount() const =0
Returns number of datasets groups loaded.
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
QgsUnitTypes::TemporalUnit temporalUnit() const
Returns the temporal unit used to read data by the data provider.
Abstract base class for color ramps.
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types.
virtual QgsMeshDatasetValue datasetValue(QgsMeshDatasetIndex index, int valueIndex) const =0
Returns vector/scalar value associated with the index from the dataset To read multiple continuous va...
@ EqualInterval
Uses equal interval.
double distance(double x, double y) const
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
QgsMesh3dDataBlock dataset3dValue(const QgsMeshDatasetIndex &index, const QgsPointXY &point) const
Returns the 3d values of stacked 3d mesh defined by the given point.
void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext.
void setClassificationMinimumMaximum(double minimum, double maximum)
Sets min/max values used for creation of the color ramp shader.
void setReferenceTime(const QDateTime &referenceTime)
Sets the reference time of the layer.
const QVector< QgsMeshVertex > & vertices() const
Returns vertices in map coordinate system.
Setting options for creating vector data providers.
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
void setClassificationMode(ClassificationMode classificationMode)
Sets classification mode.
QgsMeshDatasetValue dataset1dValue(const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius) const
Returns the value of 1D mesh dataset defined on edge that are in the search area defined by point ans...
void setMeshSimplificationSettings(const QgsMeshSimplificationSettings &meshSimplificationSettings)
Sets mesh simplification settings.
void setActiveVectorDatasetGroup(int activeVectorDatasetGroup)
Sets the active vector dataset group.
QgsInterval firstValidTimeStep() const
Returns the first valid time step of the dataset groups, invalid QgInterval if no time step is presen...
Point geometry type, with support for z-dimension and m-values.
#define QgsDebugMsgLevel(str, level)
bool isValid() const
Returns the status of the layer.
void setVectorSettings(int groupIndex, const QgsMeshRendererVectorSettings &settings)
Sets new renderer settings.
virtual bool addDataset(const QString &uri)=0
Associate dataset with the mesh.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
void setScalarSettings(int groupIndex, const QgsMeshRendererScalarSettings &settings)
Sets new renderer settings.
bool readXml(const QDomNode &layer_node, QgsReadWriteContext &context) override
Called by readLayerXML(), used by children to read state specific to them from project files.
QgsMapLayer::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when restoring state from XML.
const QVector< QgsMeshVertex > & faceCentroids() const
Returns centroids of the native faces in map CRS.
static QgsMapLayerLegend * defaultMeshLegend(QgsMeshLayer *ml)
Create new legend implementation for mesh layer.
QgsCoordinateTransformContext transformContext
void setTimeSettings(const QgsMeshTimeSettings &settings)
Sets time format settings.
QgsMeshDatasetGroupTreeItem * datasetGroupTreeRootItem() const
Returns the root items of the dataset group tree item.
void reload() override
Synchronises with changes in the datasource.
virtual void populateMesh(QgsMesh *mesh) const =0
Populates the mesh vertices, edges and faces.
QgsMeshLayerRendererCache * rendererCache()
Returns native mesh (nullptr before rendering)
QgsMeshSimplificationSettings meshSimplificationSettings() const
Returns mesh simplification settings.
bool writeXml(QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by children to write state specific to them to project files.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
const QVector< QgsMeshFace > & triangles() const
Returns triangles.
void setStaticVectorDatasetIndex(const QgsMeshDatasetIndex &staticVectorDatasetIndex)
Sets the static vector dataset index that is rendered if the temporal properties is not active.
void setTemporalMatchingMethod(const QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod &matchingMethod)
Sets the method used to match the temporal dataset from a requested time, see activeVectorDatasetAtTi...
void setMatchingMethod(const QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod &matchingMethod)
Sets the method used to match dataset from temporal capabilities.
QStringList subLayers() const override
Returns the sublayers of this layer.
TemporalUnit
Temporal units.
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
QList< int > edgeIndexesForRectangle(const QgsRectangle &rectangle) const
Finds indexes of edges intersecting given bounding box It uses spatial indexing.
void setReferenceTime(const QDateTime &referenceTime, const QgsDataProviderTemporalCapabilities *capabilities)
Sets the reference time and update the time extent from the temporal capabilities,...
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads configuration from the given DOM element.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
QgsTriangularMesh * triangularMesh(double minimumTriangleSize=0) const
Returns triangular mesh (nullptr before rendering or calling to updateMesh).
QgsMeshDatasetValue datasetValue(const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius=0) const
Interpolates the value on the given point from given dataset.
void setEdgeStrokeWidth(const QgsInterpolatedLineWidth &strokeWidth)
Sets the stroke width used to render edges scalar dataset.
bool mShouldValidateCrs
true if the layer's CRS should be validated and invalid CRSes are not permitted.
QgsMeshLayer * clone() const override
Returns a new instance equivalent to this one except for the id which is still unique.
@ FindClosestDatasetFromStartRangeTime
Finds the closest dataset which have its time before the requested start range time.
QgsDateTimeRange timeExtent() const
Returns the time extent.
QString mProviderKey
Data provider key (name of the data provider)
QgsMeshDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
Setting options for loading mesh layers.
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
QgsMeshDatasetGroupTreeItem * clone() const
Clones the item.
static QgsStyle * defaultStyle()
Returns default application-wide style.
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
void updateTriangularMesh(const QgsCoordinateTransform &transform=QgsCoordinateTransform())
Gets native mesh and updates (creates if it doesn't exist) the base triangular mesh.
QgsMeshDatasetIndex datasetIndexClosestFromRelativeTime(int group, qint64 timeSinceGlobalReference) const
Returns the closest dataset index from the timeSinceGlobalReference.
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
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...
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
void dataSourceChanged()
Emitted whenever the layer's data source has been changed.
@ NeighbourAverage
Does a simple average of values defined for all surrounding faces/vertices.
void setMinimumValue(double minimumValue)
Sets the minimum value used to defined the variable width.
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
@ FlagDontResolveLayers
Don't resolve layer paths or create data providers for layers.
QgsMeshDatasetIndex staticVectorDatasetIndex() const
Returns the static vector dataset index that is rendered if the temporal properties is not active.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
double sqrDistToSegment(double x1, double y1, double x2, double y2, QgsPointXY &minDistPoint, double epsilon=DEFAULT_SEGMENT_EPSILON) const
Returns the minimum distance between this point and a segment.
QgsLayerMetadata metadata
QgsMeshDatasetIndex datasetIndexAtTime(const QgsDateTimeRange &timeRange, int datasetGroupIndex) const
Returns dataset index from datasets group depending on the time range.
void setColorRampType(QgsColorRampShader::Type colorRampType)
Sets the color ramp type.
virtual void reloadData()
Reloads the data from the source by calling reloadProviderData() implemented by providers with data c...
bool mValid
Indicates if the layer is valid and can be drawn.
int activeScalarDatasetGroup() const
Returns the active scalar dataset group.
int group() const
Returns a group index.
QgsColorRamp * sourceColorRamp() const
Returns the source color ramp.
bool isActive() const
Returns true if the temporal property is active.
ElementType
Defines type of mesh elements.
QgsMeshRendererScalarSettings scalarSettings(int groupIndex) const
Returns renderer settings.
bool isEnabled() const
Returns if the overview is active.
@ Exact
Assigns the color of the exact matching value in the color ramp item list.
QgsColorRampShader colorRampShader() const
Returns color ramp shader function.
QString formatTime(double hours)
Returns (date) time in hours formatted to human readable form.
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write style data common to all layer types.
QgsMeshTimeSettings timeSettings() const
Returns time format settings.
int activeVectorDatasetGroup() const
Returns the active vector dataset group.
bool contains(const QgsMesh::ElementType &type) const
Returns whether the mesh contains at mesh elements of given type.
void setDatasetGroupTreeRootItem(QgsMeshDatasetGroupTreeItem *rootItem)
Sets the root items of the dataset group tree item.
const QVector< QgsMeshEdge > & edges() const
Returns edges.
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const override
double distance(double x, double y) const
Returns the distance between this point and a specified x, y coordinate.
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
bool isValid() const
Returns whether index is valid, ie at least groups is set.
virtual void setMaximumValue(double value)
Sets the maximum value for the raster shader.
bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) override
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
double x() const
Returns x value.
void setTemporalUnit(QgsUnitTypes::TemporalUnit unit)
Sets the temporal unit of the provider and reload data if it changes.
qint64 firstTimeStepDuration(int group) const
Returns the duration of the first time step of the dataset group with index group.
QDateTime referenceTime() const
Returns the reference time.
QgsMesh * nativeMesh()
Returns native mesh (nullptr before rendering or calling to updateMesh)
@ None
Does not use resampling.
MatchingTemporalDatasetMethod
Method for selection of temporal mesh dataset from a range time.
void setDefaultsFromDataProviderTemporalCapabilities(const QgsDataProviderTemporalCapabilities *capabilities) override
Sets the layers temporal settings to appropriate defaults based on a provider's temporal capabilities...
QString mDataSource
Data source description string, varies by layer type.
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &list)
Sets a custom colormap.
void setNativeMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new native mesh renderer settings, triggers repaint.
QgsMeshDatasetIndex activeVectorDatasetAtTime(const QgsDateTimeRange &timeRange) const
Returns dataset index from active vector group depending on the time range If the temporal properties...
int faceIndexForPoint_v2(const QgsPointXY &point) const
Finds index of triangle at given point It uses spatial indexing and don't use geos to be faster.
QVector< int > QgsMeshFace
List of vertex indexes.
void setIsActive(bool active)
Sets whether the temporal property is active.
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element.
void rendererChanged()
Signal emitted when renderer is changed.
bool writeStyle(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const override
Write just the symbology information for the layer into the document.
void setColorRampShader(const QgsColorRampShader &shader)
Sets color ramp shader function.
bool readStyle(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) override
Read the style for the current layer from the DOM node supplied.
void activeScalarDatasetGroupChanged(int index)
Emitted when active scalar group dataset is changed.
QString decodedSource(const QString &source, const QString &provider, const QgsReadWriteContext &context) const override
Called by readLayerXML(), used by derived classes to decode provider's specific data source from proj...
void dataChanged()
Data of layer changed.
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)
Sets data coordinate transform context to transformContext.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
QString source() const
Returns the source for the layer.
void setColorRampShader(const QgsColorRampShader &colorRampShader)
Returns the color ramp shader used to render vector datasets.
QList< int > faceIndexesForRectangle(const QgsRectangle &rectangle) const
Finds indexes of triangles intersecting given bounding box It uses spatial indexing.
QMap< QString, QString > QgsStringMap
void setMaximumValue(double maximumValue)
Sets the maximum value used to defined the variable width.
@ TemporalMilliseconds
Milliseconds.
bool addDatasets(const QString &path, const QDateTime &defaultReferenceTime=QDateTime())
Add datasets to the mesh from file with path.
void setDataResamplingMethod(const DataResamplingMethod &dataResamplingMethod)
Sets data interpolation method.
@ FindClosestDatasetBeforeStartRangeTime
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
QPair< int, int > QgsMeshEdge
Edge is a straight line seqment between 2 points.
virtual QStringList extraDatasets() const =0
Returns list of additional dataset file URIs added using addDataset() calls.
const QVector< int > & trianglesToNativeFaces() const
Returns mapping between triangles and original faces.
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
virtual QgsMesh3dDataBlock dataset3dValues(QgsMeshDatasetIndex index, int faceIndex, int count) const =0
Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes.
A representation of the interval between two datetime values.
double y() const
Returns y value.
QgsMeshLayer(const QString &path=QString(), const QString &baseName=QString(), const QString &providerLib=QStringLiteral("mesh_memory"), const QgsMeshLayer::LayerOptions &options=QgsMeshLayer::LayerOptions())
Constructor - creates a mesh layer.
QgsMeshDatasetIndex datasetIndexClosestBeforeRelativeTime(int group, qint64 timeSinceGlobalReference) const
Returns the last dataset whith time less than or equal to timeSinceGlobalReference.
void timeSettingsChanged()
Emitted when time format is changed.
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
void setEnabled(bool enabled)
Sets whether mesh structure rendering is enabled.
QgsMeshDatasetIndex staticScalarDatasetIndex() const
Returns the static scalar dataset index that is rendered if the temporal properties is not active.
void resetDatasetGroupTreeItem()
Reset the dataset group tree item to default from provider.
virtual void setDefaultsFromDataProviderTemporalCapabilities(const QgsDataProviderTemporalCapabilities *capabilities)=0
Sets the layers temporal settings to appropriate defaults based on a provider's temporal capabilities...
void datasetGroupsAdded(int count)
Emitted when some new dataset groups have been added.
QgsMesh3dAveragingMethod * averagingMethod() const
Returns averaging method for conversion of 3d stacked mesh data to 2d data.
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsColorRamp from a map of properties.
int datasetGroupIndex() const
bool hasTemporalCapabilities() const
Returns true if the provider has temporal capabilities available.
QgsRectangle extent() const override
Returns the extent of the layer.
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a new DOM element.
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
void setStaticScalarDatasetIndex(const QgsMeshDatasetIndex &staticScalarDatasetIndex)
Sets the static scalar dataset index that is rendered if the temporal properties is not active.
QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod matchingMethod() const
Returns the method used to match dataset from temporal capabilities.
QgsMeshDatasetValue value(int index) const
Returns a value represented by the index For active flag the behavior is undefined.
QString providerType() const
Returns the provider type for this layer.
void activeVectorDatasetGroupChanged(int index)
Emitted when active vector group dataset is changed.
void setRendererSettings(const QgsMeshRendererSettings &settings)
Sets new renderer settings.
QgsMeshDataBlock calculate(const QgsMesh3dDataBlock &block3d, QgsFeedback *feedback=nullptr) const
Calculated 2d block values from 3d stacked mesh values.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
double reductionFactor() const
Returns the reduction factor used to build simplified mesh.
void setProviderType(const QString &providerType)
Sets the providerType (provider key)
void setActiveScalarDatasetGroup(int activeScalarDatasetGroup)
Sets the active scalar dataset group.
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata(int groupIndex) const =0
Returns dataset group metadata.
QgsMeshDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
QgsMeshDatasetIndex activeScalarDatasetAtTime(const QgsDateTimeRange &timeRange) const
Returns dataset index from active scalar group depending on the time range.
QgsColorRamp * colorRamp(const QString &name) const
Returns a new copy of the specified color ramp.
QgsPointXY snapOnElement(QgsMesh::ElementType elementType, const QgsPointXY &point, double searchRadius)
Returns the position of the snapped point on the mesh element closest to point intersecting with the ...
virtual bool isValid() const =0
Returns true if this is a valid layer.
virtual QStringList subLayers() const
Sub-layers handled by this provider, in order from bottom to top.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
virtual void setMinimumValue(double value)
Sets the minimum value for the raster shader.
bool isValid() const
Whether the block is valid.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.