QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
50 const QString &baseName,
51 const QString &providerKey,
61 QgsDataProvider::ReadFlags
flags = QgsDataProvider::ReadFlags();
70 setDataSourcePrivate( meshLayerPath, baseName, providerKey, providerOptions,
flags );
83 void QgsMeshLayer::createSimplifiedMeshes()
85 if ( mSimplificationSettings.
isEnabled() && !hasSimplifiedMeshes() )
87 const double reductionFactor = mSimplificationSettings.
reductionFactor();
89 QVector<QgsTriangularMesh *> simplifyMeshes =
90 mTriangularMeshes[0]->simplifyMesh( reductionFactor );
92 for (
int i = 0; i < simplifyMeshes.count() ; ++i )
94 mTriangularMeshes.emplace_back( simplifyMeshes[i] );
99 bool QgsMeshLayer::hasSimplifiedMeshes()
const
102 return ( mTriangularMeshes.size() > 1 );
107 delete mDataProvider;
112 return mDataProvider;
117 return mDataProvider;
130 layer->mElevationProperties = mElevationProperties->
clone();
131 layer->mElevationProperties->setParent( layer );
139 return mMeshEditor->
extent();
142 return mDataProvider->
extent();
158 if ( !mDataProvider )
173 for (
const int index : groupsList )
174 assignDefaultStyleToDatasetGroup( index );
178 if ( !groupsList.isEmpty() )
184 if ( meta.
maximum() == std::numeric_limits<double>::quiet_NaN() &&
185 meta.
minimum() == std::numeric_limits<double>::quiet_NaN() )
196 for (
const int i : groupsList )
198 assignDefaultStyleToDatasetGroup( i );
217 applyClassificationOnScalarSettings( meta, scalarSettings );
222 if ( !groupsList.isEmpty() )
234 if ( mDatasetGroupStore->addPersistentDatasets( path ) )
236 mExtraDatasetUri.append( path );
238 if ( !isTemporalBefore &&
dataProvider()->temporalCapabilities()->hasTemporalCapabilities() )
245 QDateTime referenceTime = defaultReferenceTime;
246 if ( !defaultReferenceTime.isValid() )
247 referenceTime = QDateTime( QDate::currentDate(), QTime( 0, 0, 0 ), Qt::UTC );
262 if ( mDatasetGroupStore->addDatasetGroup( datasetGroup ) )
272 return mDatasetGroupStore->saveDatasetGroup( path, datasetGroupIndex, driver );
277 return mNativeMesh.get();
282 return mNativeMesh.get();
287 for (
const std::unique_ptr<QgsTriangularMesh> &lod : mTriangularMeshes )
289 if ( lod && lod->averageTriangleSize() > minimumTriangleSize )
293 if ( !mTriangularMeshes.empty() )
294 return mTriangularMeshes.back().get();
301 return mTriangularMeshes.size();
306 if ( mTriangularMeshes.empty() )
309 return mTriangularMeshes.front().get();
311 if ( lodIndex >=
int( mTriangularMeshes.size() ) )
312 return mTriangularMeshes.back().get();
314 return mTriangularMeshes.at( lodIndex ).get();
327 if ( mTriangularMeshes.empty() )
330 mTriangularMeshes.emplace_back( baseMesh );
333 if ( mTriangularMeshes[0].get()->update( mNativeMesh.get(), transform ) )
334 mTriangularMeshes.resize( 1 );
336 createSimplifiedMeshes();
341 return mRendererCache.get();
346 return mRendererSettings;
353 mRendererSettings = settings;
367 return mTimeSettings;
372 mTimeSettings = settings;
379 return QgsMeshLayerUtils::formatTime( hours, mTemporalProperties->
referenceTime(), mTimeSettings );
381 return QgsMeshLayerUtils::formatTime( hours, QDateTime(), mTimeSettings );
386 return mDatasetGroupStore->datasetGroupCount();
391 return mDatasetGroupStore->extraDatasetGroupCount();
396 return mDatasetGroupStore->datasetGroupIndexes();
401 return mDatasetGroupStore->enabledDatasetGroupIndexes();
406 return mDatasetGroupStore->datasetGroupMetadata( index );
411 return mDatasetGroupStore->datasetCount( index.
group() );
416 return mDatasetGroupStore->datasetMetadata( index );
421 return mDatasetGroupStore->datasetValue( index, valueIndex );
426 return mDatasetGroupStore->datasetValues( index, valueIndex, count );
431 return mDatasetGroupStore->dataset3dValues( index, faceIndex, count );
436 return mDatasetGroupStore->areFacesActive( index, faceIndex, count );
441 return mDatasetGroupStore->isFaceActive( index, faceIndex );
451 if (
contains( QgsMesh::ElementType::Edge ) )
453 const QgsRectangle searchRectangle( point.
x() - searchRadius, point.
y() - searchRadius, point.
x() + searchRadius, point.
y() + searchRadius );
457 if ( faceIndex >= 0 )
474 const int v1 = face[0], v2 = face[1], v3 = face[2];
479 const double x = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.
x(), val2.
x(), val3.
x(), point );
480 double y = std::numeric_limits<double>::quiet_NaN();
483 y = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.
y(), val2.
y(), val3.
y(), point );
498 value = block2d.
value( 0 );
526 if ( faceIndex >= 0 )
540 const int selectedIndex = closestEdge( point, searchRadius, projectedPoint );
542 if ( selectedIndex >= 0 )
556 const int v1 = edge.first, v2 = edge.second;
560 const double edgeLength = p1.
distance( p2 );
561 const double dist1 = p1.
distance( projectedPoint.
x(), projectedPoint.
y() );
562 value = QgsMeshLayerUtils::interpolateFromVerticesData( dist1 / edgeLength, val1, val2 );
582 if ( ! mTemporalProperties->
isActive() )
585 const QDateTime layerReferenceTime = mTemporalProperties->
referenceTime();
586 QDateTime utcTime = timeRange.begin();
587 if ( utcTime.timeSpec() != Qt::UTC )
588 utcTime.setTimeSpec( Qt::UTC );
589 const qint64 startTime = layerReferenceTime.msecsTo( utcTime );
591 return mDatasetGroupStore->datasetIndexAtTime( startTime, datasetGroupIndex, mTemporalProperties->
matchingMethod() );
596 return mDatasetGroupStore->datasetIndexAtTime( relativeTime.
seconds() * 1000, datasetGroupIndex, mTemporalProperties->
matchingMethod() );
601 qint64 usedRelativeTime1 = startRelativeTime.
seconds() * 1000;
602 qint64 usedRelativeTime2 = endRelativeTime.
seconds() * 1000;
614 return mDatasetGroupStore->datasetIndexInTimeInterval( usedRelativeTime1, usedRelativeTime2, datasetGroupIndex );
619 if ( meta.
extraOptions().contains( QStringLiteral(
"classification" ) ) )
623 const QStringList classes = meta.
extraOptions()[QStringLiteral(
"classification" )].split( QStringLiteral(
";;" ) );
626 if ( meta.
extraOptions().contains( QStringLiteral(
"units" ) ) )
627 units = meta.
extraOptions()[ QStringLiteral(
"units" )];
629 QVector<QVector<double>> bounds;
630 for (
const QString &classe : classes )
632 const QStringList boundsStr = classe.split(
',' );
633 QVector<double> bound;
634 for (
const QString &boundStr : boundsStr )
635 bound.append( boundStr.toDouble() );
636 bounds.append( bound );
639 if ( ( bounds.count() == 1 && bounds.first().count() > 2 ) ||
640 ( bounds.count() > 1 ) )
642 const QVector<double> firstClass = bounds.first();
643 const QVector<double> lastClass = bounds.last();
644 const double minValue = firstClass.count() > 1 ? ( firstClass.first() + firstClass.last() ) / 2 : firstClass.first();
645 const double maxValue = lastClass.count() > 1 ? ( lastClass.first() + lastClass.last() ) / 2 : lastClass.first();
646 const double diff = maxValue - minValue;
647 QList<QgsColorRampShader::ColorRampItem> colorRampItemlist;
648 for (
int i = 0; i < bounds.count(); ++i )
650 const QVector<double> &boundClass = bounds.at( i );
653 if ( !boundClass.isEmpty() )
655 const double scalarValue = ( boundClass.first() + boundClass.last() ) / 2;
656 item.
color = colorRamp->
color( ( scalarValue - minValue ) / diff );
657 if ( i != 0 && i < bounds.count() - 1 )
659 item.
label = QString( (
"%1 - %2 %3" ) ).
660 arg( QString::number( boundClass.first() ) ).
661 arg( QString::number( boundClass.last() ) ).
665 colorRampItemlist.append( item );
668 if ( firstClass.count() == 1 )
669 colorRampItemlist.first().label = QObject::tr(
"below %1 %2" ).
670 arg( QString::number( firstClass.first() ) ).
674 colorRampItemlist.first().label = QString( (
"%1 - %2 %3" ) ).
675 arg( QString::number( firstClass.first() ) ).
676 arg( QString::number( firstClass.last() ) ).
680 if ( lastClass.count() == 1 )
681 colorRampItemlist.last().label = QObject::tr(
"above %1 %2" ).
682 arg( QString::number( lastClass.first() ) ).
686 colorRampItemlist.last().label = QString( (
"%1 - %2 %3" ) ).
687 arg( QString::number( lastClass.first() ) ).
688 arg( QString::number( lastClass.last() ) ).
707 if ( mTemporalProperties->
isActive() )
715 if ( mTemporalProperties->
isActive() )
721 void QgsMeshLayer::fillNativeMesh()
723 Q_ASSERT( !mNativeMesh );
725 mNativeMesh.reset(
new QgsMesh() );
733 void QgsMeshLayer::onDatasetGroupsAdded(
const QList<int> &datasetGroupIndexes )
736 for (
int datasetGroupIndex : datasetGroupIndexes )
738 if ( !mRendererSettings.
hasSettings( datasetGroupIndex ) )
739 assignDefaultStyleToDatasetGroup( datasetGroupIndex );
746 void QgsMeshLayer::onMeshEdited()
748 mRendererCache.reset(
new QgsMeshLayerRendererCache() );
756 return mDatasetGroupStore->datasetGroupTreeItem();
761 mDatasetGroupStore->setDatasetGroupTreeItem( rootItem );
762 updateActiveDatasetGroups();
765 int QgsMeshLayer::closestEdge(
const QgsPointXY &point,
double searchRadius,
QgsPointXY &projectedPoint )
const
767 const QgsRectangle searchRectangle( point.
x() - searchRadius, point.
y() - searchRadius, point.
x() + searchRadius, point.
y() + searchRadius );
771 int selectedIndex = -1;
775 double sqrMaxDistFromPoint = pow( searchRadius, 2 );
776 for (
const int edgeIndex : edgeIndexes )
782 const double sqrDist = point.
sqrDistToSegment( vertex1.
x(), vertex1.
y(), vertex2.
x(), vertex2.
y(), projPoint );
783 if ( sqrDist < sqrMaxDistFromPoint )
785 selectedIndex = edgeIndex;
786 projectedPoint = projPoint;
787 sqrMaxDistFromPoint = sqrDist;
792 return selectedIndex;
803 mTemporalProperties->
setReferenceTime( referenceTime, lDataProvider->temporalCapabilities() );
818 return exactPosition;
819 const QgsRectangle rectangle( point.
x() - searchRadius, point.
y() - searchRadius, point.
x() + searchRadius, point.
y() + searchRadius );
820 double maxDistance = searchRadius;
823 for (
const int edgeIndex : edgeIndexes )
828 const double dist1 = point.
distance( vertex1 );
829 const double dist2 = point.
distance( vertex2 );
830 if ( dist1 < maxDistance )
833 exactPosition = vertex1;
835 if ( dist2 < maxDistance )
838 exactPosition = vertex2;
844 for (
const int faceIndex : faceIndexes )
847 for (
int i = 0; i < 3; ++i )
850 const double dist = point.
distance( vertex );
851 if ( dist < maxDistance )
854 exactPosition = vertex;
859 return exactPosition;
865 closestEdge( point, searchRadius, projectedPoint );
867 return projectedPoint;
875 return centroidPosition;
876 const QgsRectangle rectangle( point.
x() - searchRadius, point.
y() - searchRadius, point.
x() + searchRadius, point.
y() + searchRadius );
877 double maxDistance = std::numeric_limits<double>::max();
880 for (
const int faceIndex : faceIndexes )
883 if ( nativefaceIndex < 0 && nativefaceIndex >= mesh->
faceCentroids().count() )
887 if ( dist < maxDistance )
894 return centroidPosition;
899 mDatasetGroupStore->resetDatasetGroupTreeItem();
900 updateActiveDatasetGroups();
905 if ( !mDataProvider )
908 for (
int i = 0; i < groupCount; ++i )
920 const qint64 time = mDatasetGroupStore->datasetRelativeTime( index );
930 return mDatasetGroupStore->datasetRelativeTime( index );
942 message = QObject::tr(
"Face %1 invalid" ).arg( error.
elementIndex );
945 message = QObject::tr(
"Too many vertices for face %1" ).arg( error.
elementIndex );
948 message = QObject::tr(
"Face %1 is flat" ).arg( error.
elementIndex );
951 message = QObject::tr(
"Vertex %1 is a unique shared vertex" ).arg( error.
elementIndex );
954 message = QObject::tr(
"Vertex %1 is invalid" ).arg( error.
elementIndex );
957 message = QObject::tr(
"Face %1 is manifold" ).arg( error.
elementIndex );
988 mMeshEditor->deleteLater();
989 mMeshEditor =
nullptr;
992 arg(
name(), detailsErrorMessage(
error ) ), QString(), Qgis::MessageLevel::Critical );
997 mDataProvider->
close();
1000 mExtraDatasetUri.clear();
1016 QString detailsError;
1020 detailsError = tr(
"Unknown inconsistent mesh error" );
1025 detailsError = detailsErrorMessage(
error );
1028 if ( !detailsError.isEmpty() )
1031 arg(
name(), detailsError ), QString(), Qgis::MessageLevel::Critical );
1037 if ( !mDataProvider )
1040 const bool res = mDataProvider->
saveMeshFrame( *mNativeMesh.get() );
1042 if ( continueEditing )
1049 mMeshEditor->deleteLater();
1050 mMeshEditor =
nullptr;
1056 mDatasetGroupStore->setPersistentProvider( mDataProvider, QStringList() );
1065 if ( !mDataProvider )
1068 mTriangularMeshes.clear();
1072 mRendererCache.reset(
new QgsMeshLayerRendererCache() );
1075 if ( continueEditing )
1082 mMeshEditor->deleteLater();
1083 mMeshEditor =
nullptr;
1087 mDatasetGroupStore->setPersistentProvider( mDataProvider, QStringList() );
1100 mTriangularMeshes.at( 0 )->update( mNativeMesh.get(), transform );
1101 mRendererCache.reset(
new QgsMeshLayerRendererCache() );
1109 if ( !mMeshEditor->
reindex( renumber ) )
1112 mTriangularMeshes.clear();
1114 mTriangularMeshes.at( 0 )->update( mNativeMesh.get(), transform );
1115 mRendererCache.reset(
new QgsMeshLayerRendererCache() );
1138 case QgsMesh::ElementType::Vertex:
1140 case QgsMesh::ElementType::Edge:
1142 case QgsMesh::ElementType::Face:
1152 else if ( mDataProvider )
1161 else if ( mDataProvider )
1169 return mNativeMesh->edgeCount();
1170 else if ( mDataProvider )
1175 void QgsMeshLayer::updateActiveDatasetGroups()
1179 if ( !mDatasetGroupStore->datasetGroupTreeItem() )
1189 if ( !activeScalarItem && treeItem->
childCount() > 0 && oldActiveScalar != -1 )
1190 activeScalarItem = treeItem->
child( 0 );
1192 if ( activeScalarItem && !activeScalarItem->
isEnabled() )
1194 for (
int i = 0; i < treeItem->
childCount(); ++i )
1196 activeScalarItem = treeItem->
child( i );
1200 activeScalarItem =
nullptr;
1204 if ( activeScalarItem )
1212 if ( !( activeVectorItem && activeVectorItem->
isEnabled() ) )
1223 void QgsMeshLayer::setDataSourcePrivate(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags )
1229 if ( !
mDataSource.isEmpty() && !provider.isEmpty() )
1230 setDataProvider( provider, options,
flags );
1235 switch ( elementType )
1238 return snapOnVertex( point, searchRadius );
1240 return snapOnEdge( point, searchRadius );
1242 return snapOnFace( point, searchRadius );
1263 context.
lastScope()->
setVariable( QStringLiteral(
"_mesh_layer" ), QVariant::fromValue(
this ) );
1265 expression.
prepare( &context );
1267 for (
int i = 0; i < mNativeMesh->vertexCount(); ++i )
1271 if ( expression.
evaluate( &context ).toBool() )
1294 context.
lastScope()->
setVariable( QStringLiteral(
"_mesh_layer" ), QVariant::fromValue(
this ) );
1296 expression.
prepare( &context );
1298 for (
int i = 0; i < mNativeMesh->faceCount(); ++i )
1302 if ( expression.
evaluate( &context ).toBool() )
1338 return mSimplificationSettings;
1343 mSimplificationSettings = simplifySettings;
1354 props[
"color1"] =
"13,8,135,255";
1355 props[
"color2"] =
"240,249,33,255";
1357 "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:"
1358 "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:"
1359 "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:"
1360 "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:"
1361 "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:"
1362 "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:"
1363 "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:"
1364 "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:"
1365 "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:"
1366 "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";
1370 void QgsMeshLayer::assignDefaultStyleToDatasetGroup(
int groupIndex )
1373 const double groupMin =
metadata.minimum();
1374 const double groupMax =
metadata.maximum();
1377 fcn.classifyColorRamp( 5, -1,
QgsRectangle(),
nullptr );
1404 createSimplifiedMeshes();
1407 if ( !mRendererCache )
1408 mRendererCache.reset(
new QgsMeshLayerRendererCache() );
1421 Q_UNUSED( errorMessage )
1424 const QDomElement elem = node.toElement();
1428 const QDomElement elemRendererSettings = elem.firstChildElement(
"mesh-renderer-settings" );
1429 if ( !elemRendererSettings.isNull() )
1430 mRendererSettings.
readXml( elemRendererSettings, context );
1432 const QDomElement elemSimplifySettings = elem.firstChildElement(
"mesh-simplify-settings" );
1433 if ( !elemSimplifySettings.isNull() )
1434 mSimplificationSettings.
readXml( elemSimplifySettings, context );
1437 const QDomNode blendModeNode = node.namedItem( QStringLiteral(
"blendMode" ) );
1438 if ( !blendModeNode.isNull() )
1440 const QDomElement e = blendModeNode.toElement();
1447 const QDomNode layerOpacityNode = node.namedItem( QStringLiteral(
"layerOpacity" ) );
1448 if ( !layerOpacityNode.isNull() )
1450 const QDomElement e = layerOpacityNode.toElement();
1461 Q_UNUSED( errorMessage )
1464 QDomElement elem = node.toElement();
1468 const QDomElement elemRendererSettings = mRendererSettings.
writeXml( doc, context );
1469 elem.appendChild( elemRendererSettings );
1471 const QDomElement elemSimplifySettings = mSimplificationSettings.
writeXml( doc, context );
1472 elem.appendChild( elemSimplifySettings );
1475 QDomElement blendModeElement = doc.createElement( QStringLiteral(
"blendMode" ) );
1477 blendModeElement.appendChild( blendModeText );
1478 node.appendChild( blendModeElement );
1483 QDomElement layerOpacityElem = doc.createElement( QStringLiteral(
"layerOpacity" ) );
1484 const QDomText layerOpacityText = doc.createTextNode( QString::number(
opacity() ) );
1485 layerOpacityElem.appendChild( layerOpacityText );
1486 node.appendChild( layerOpacityElem );
1494 return writeSymbology( node, doc, errorMessage, context, categories );
1499 return readSymbology( node, errorMessage, context, categories );
1507 if ( uriParts.contains( QStringLiteral(
"path" ) ) )
1509 QString filePath = uriParts.value( QStringLiteral(
"path" ) ).toString();
1511 uriParts.insert( QStringLiteral(
"path" ), filePath );
1522 if ( uriParts.contains( QStringLiteral(
"path" ) ) )
1524 QString filePath = uriParts.value( QStringLiteral(
"path" ) ).toString();
1526 uriParts.insert( QStringLiteral(
"path" ), filePath );
1537 const QDomNode pkeyNode = layer_node.namedItem( QStringLiteral(
"provider" ) );
1539 if ( pkeyNode.isNull() )
1545 const QDomElement pkeyElt = pkeyNode.toElement();
1555 QgsDataProvider::ReadFlags
flags = QgsDataProvider::ReadFlags();
1561 const QDomElement elemExtraDatasets = layer_node.firstChildElement( QStringLiteral(
"extra-datasets" ) );
1562 if ( !elemExtraDatasets.isNull() )
1564 QDomElement elemUri = elemExtraDatasets.firstChildElement( QStringLiteral(
"uri" ) );
1565 while ( !elemUri.isNull() )
1568 mExtraDatasetUri.append( uri );
1569 elemUri = elemUri.nextSiblingElement( QStringLiteral(
"uri" ) );
1573 if ( pkeyNode.toElement().hasAttribute( QStringLiteral(
"time-unit" ) ) )
1574 mTemporalUnit =
static_cast<QgsUnitTypes::TemporalUnit>( pkeyNode.toElement().attribute( QStringLiteral(
"time-unit" ) ).toInt() );
1577 const QDomElement elemDatasetGroupsStore = layer_node.firstChildElement( QStringLiteral(
"mesh-dataset-groups-store" ) );
1578 if ( elemDatasetGroupsStore.isNull() )
1581 mDatasetGroupStore->readXml( elemDatasetGroupsStore, context );
1588 if ( !mTemporalProperties->
timeExtent().begin().isValid() )
1592 const QDomElement elemStaticDataset = layer_node.firstChildElement( QStringLiteral(
"static-active-dataset" ) );
1593 if ( elemStaticDataset.hasAttribute( QStringLiteral(
"scalar" ) ) )
1595 mStaticScalarDatasetIndex = elemStaticDataset.attribute( QStringLiteral(
"scalar" ) ).toInt();
1597 if ( elemStaticDataset.hasAttribute( QStringLiteral(
"vector" ) ) )
1599 mStaticVectorDatasetIndex = elemStaticDataset.attribute( QStringLiteral(
"vector" ) ).toInt();
1608 QDomElement mapLayerNode = layer_node.toElement();
1610 if ( mapLayerNode.isNull() || ( QLatin1String(
"maplayer" ) != mapLayerNode.nodeName() ) )
1619 if ( mDataProvider )
1621 QDomElement provider = document.createElement( QStringLiteral(
"provider" ) );
1622 const QDomText providerText = document.createTextNode(
providerType() );
1623 provider.appendChild( providerText );
1624 layer_node.appendChild( provider );
1627 const QStringList extraDatasetUris = mDataProvider->
extraDatasets();
1628 QDomElement elemExtraDatasets = document.createElement( QStringLiteral(
"extra-datasets" ) );
1629 for (
const QString &uri : extraDatasetUris )
1632 QDomElement elemUri = document.createElement( QStringLiteral(
"uri" ) );
1633 elemUri.appendChild( document.createTextNode( path ) );
1634 elemExtraDatasets.appendChild( elemUri );
1636 layer_node.appendChild( elemExtraDatasets );
1639 QDomElement elemStaticDataset = document.createElement( QStringLiteral(
"static-active-dataset" ) );
1640 elemStaticDataset.setAttribute( QStringLiteral(
"scalar" ), mStaticScalarDatasetIndex );
1641 elemStaticDataset.setAttribute( QStringLiteral(
"vector" ), mStaticVectorDatasetIndex );
1642 layer_node.appendChild( elemStaticDataset );
1646 layer_node.appendChild( mDatasetGroupStore->writeXml( document, context ) );
1650 return writeSymbology( layer_node, document, errorMsg, context );
1655 if ( !mMeshEditor && mDataProvider && mDataProvider->
isValid() )
1661 mNativeMesh.reset(
new QgsMesh );
1666 mTriangularMeshes.clear();
1669 mRendererCache.reset(
new QgsMeshLayerRendererCache() );
1675 if ( mDataProvider )
1678 return QStringList();
1684 QString myMetadata = QStringLiteral(
"<html>\n<body>\n" );
1689 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Information from provider" ) + QStringLiteral(
"</h1>\n<hr>\n" );
1690 myMetadata += QLatin1String(
"<table class=\"list-view\">\n" );
1693 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Extent" ) + QStringLiteral(
"</td><td>" ) +
extent().
toString() + QStringLiteral(
"</td></tr>\n" );
1696 QLocale locale = QLocale();
1697 locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
1701 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
1702 + tr(
"Vertex count" ) + QStringLiteral(
"</td><td>" )
1704 + QStringLiteral(
"</td></tr>\n" );
1705 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
1706 + tr(
"Face count" ) + QStringLiteral(
"</td><td>" )
1707 + ( locale.toString(
static_cast<qlonglong
>(
meshFaceCount() ) ) )
1708 + QStringLiteral(
"</td></tr>\n" );
1709 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
1710 + tr(
"Edge count" ) + QStringLiteral(
"</td><td>" )
1711 + ( locale.toString(
static_cast<qlonglong
>(
meshEdgeCount() ) ) )
1712 + QStringLiteral(
"</td></tr>\n" );
1713 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
1714 + tr(
"Dataset groups count" ) + QStringLiteral(
"</td><td>" )
1716 + QStringLiteral(
"</td></tr>\n" );
1720 myMetadata += QLatin1String(
"</table>\n<br><br>" );
1726 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Identification" ) + QStringLiteral(
"</h1>\n<hr>\n" );
1728 myMetadata += QLatin1String(
"<br><br>\n" );
1731 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Extent" ) + QStringLiteral(
"</h1>\n<hr>\n" );
1733 myMetadata += QLatin1String(
"<br><br>\n" );
1736 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Access" ) + QStringLiteral(
"</h1>\n<hr>\n" );
1738 myMetadata += QLatin1String(
"<br><br>\n" );
1741 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Contacts" ) + QStringLiteral(
"</h1>\n<hr>\n" );
1743 myMetadata += QLatin1String(
"<br><br>\n" );
1746 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Links" ) + QStringLiteral(
"</h1>\n<hr>\n" );
1748 myMetadata += QLatin1String(
"<br><br>\n" );
1751 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"History" ) + QStringLiteral(
"</h1>\n<hr>\n" );
1753 myMetadata += QLatin1String(
"<br><br>\n" );
1755 myMetadata += QLatin1String(
"\n</body>\n</html>\n" );
1761 return mMeshEditor !=
nullptr;
1766 mDatasetGroupStore->setPersistentProvider(
nullptr, QStringList() );
1768 delete mDataProvider;
1774 if ( !mDataProvider )
1776 QgsDebugMsgLevel( QStringLiteral(
"Unable to get mesh data provider" ), 2 );
1780 mDataProvider->setParent(
this );
1781 QgsDebugMsgLevel( QStringLiteral(
"Instantiated the mesh data provider plugin" ), 2 );
1790 if ( !mTemporalProperties->
isValid() )
1797 mDatasetGroupStore->setPersistentProvider( mDataProvider, mExtraDatasetUri );
1801 if ( provider == QLatin1String(
"mesh_memory" ) )
1810 int globalIndex = mDatasetGroupStore->globalDatasetGroupIndexInSource( mDataProvider, i );
1811 if ( globalIndex != -1 &&
1813 assignDefaultStyleToDatasetGroup( globalIndex );
1826 return mTemporalProperties;
1831 return mElevationProperties;
QList< int > datasetGroupsIndexes() const
Returns the list of indexes of dataset groups handled by the layer.
int dataset() const
Returns a dataset index within group()
virtual int datasetGroupCount() const =0
Returns number of datasets groups loaded.
Represents a renderer settings for vector datasets.
void setEnabled(bool isEnabled)
Sets if the overview is active.
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
QString crsHtmlMetadata() const
Returns a HTML fragment containing the layer's CRS metadata, for use in the htmlMetadata() method.
QgsUnitTypes::TemporalUnit temporalUnit() const
Returns the temporal unit used to read data by the data provider.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
double distance(double x, double y) const SIP_HOLDGIL
Returns the distance between this point and a specified x, y coordinate.
void emitStyleChanged()
Triggers an emission of the styleChanged() signal.
bool isModified() const override
Returns whether the mesh frame has been modified since the last save.
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.
@ EqualInterval
Uses equal interval.
QgsMeshDatasetGroup * createZValueDatasetGroup()
Creates and returns a scalar dataset group with value on vertex that is can be used to access the Z v...
QgsMesh3dDataBlock dataset3dValue(const QgsMeshDatasetIndex &index, const QgsPointXY &point) const
Returns the 3d values of stacked 3d mesh defined by the given point.
int validVerticesCount() const
Returns the count of valid vertices, that is non void vertices in the mesh.
void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext.
double seconds() const
Returns the interval duration in seconds.
Contains information about the context in which a coordinate transform is executed.
void setClassificationMinimumMaximum(double minimum, double maximum)
Sets min/max values used for creation of the color ramp shader.
@ FlagTrustLayerMetadata
Trust layer metadata. Improves layer load time by skipping expensive checks like primary key unicity,...
QgsMeshDatasetIndex datasetIndexAtRelativeTime(const QgsInterval &relativeTime, int datasetGroupIndex) const
Returns dataset index from datasets group depending on the relative time from the layer reference tim...
void setReferenceTime(const QDateTime &referenceTime)
Sets the reference time of the layer.
const QVector< QgsMeshVertex > & vertices() const
Returns vertices in map coordinate system.
void editingStopped()
Emitted when edited changes have been successfully written to the data provider.
Represents a mesh time settings for mesh datasets.
void setVariable(const QString &name, const QVariant &value, bool isStatic=false)
Convenience method for setting a variable in the context scope by name name and value.
int meshEdgeCount() const
Returns the edges count of the mesh frame.
bool startFrameEditing(const QgsCoordinateTransform &transform)
Starts edition of the mesh frame.
Represents all mesh renderer settings.
Setting options for creating vector data providers.
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
@ MeshLayer
Mesh layer. Added in QGIS 3.2.
bool contains(const QgsMesh::ElementType &type) const
Returns whether the mesh contains at mesh elements of given type.
void setClassificationMode(ClassificationMode classificationMode)
Sets classification mode.
The class is used as a container of context for various read/write operations on other objects.
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...
@ FlatFace
A flat face is present.
bool saveDataset(const QString &path, int datasetGroupIndex, QString driver)
Saves datasets group on file with the specified driver.
double distance(double x, double y) const SIP_HOLDGIL
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
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.
Represents a mesh renderer settings for mesh object.
#define QgsDebugMsgLevel(str, level)
void setVectorSettings(int groupIndex, const QgsMeshRendererVectorSettings &settings)
Sets new renderer settings.
Base class for storage of map layer elevation properties.
CORE_EXPORT QgsMeshVertex centroid(const QgsMeshFace &face, const QVector< QgsMeshVertex > &vertices)
Returns the centroid of the face.
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
Coordinate transform context.
Mesh layer specific subclass of QgsMapLayerElevationProperties.
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.
bool supportsEditing() const override
Returns whether the layer supports editing or not.
@ FlagTrustDataSource
Trust datasource config (primary key unicity, geometry type and srid, etc). Improves provider load ti...
QgsMeshDatasetValue represents single dataset value.
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context.
QgsMapLayerType
Types of layers that can be added to a map.
QString encodeUri(const QString &providerKey, const QVariantMap &parts)
Reassembles a provider data source URI from its component paths (e.g.
QgsMeshLayerRendererCache * rendererCache()
Returns native mesh (nullptr before rendering)
QgsMeshSimplificationSettings meshSimplificationSettings() const
Returns mesh simplification settings.
Abstract base class for objects which generate elevation profiles.
void stopFrameEditing(const QgsCoordinateTransform &transform)
Stops edition of the mesh, re-indexes the faces and vertices, rebuilds the triangular mesh and its sp...
bool isValid() const
Returns whether the instance is valid.
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.
Contains information about the context of a rendering operation.
Implementation of map layer temporal properties for mesh layers.
void setMinimal() SIP_HOLDGIL
Set a rectangle so that min corner is at max and max corner is at min.
Tree item for display of the mesh dataset groups. Dataset group is set of datasets with the same name...
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...
bool rollBackFrameEditing(const QgsCoordinateTransform &transform, bool continueEditing=true)
Rolls Back edition of the mesh frame.
void setMatchingMethod(const QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod &matchingMethod)
Sets the method used to match dataset from temporal capabilities.
Mesh - vertices, edges and faces.
QStringList subLayers() const override
Returns the sublayers of this layer.
void editingStarted()
Emitted when editing on this layer has started.
TemporalUnit
Temporal units.
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
bool isFaceActive(const QgsMeshDatasetIndex &index, int faceIndex) const
Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes.
bool reindex(const QgsCoordinateTransform &transform, bool renumber)
Re-indexes the faces and vertices, and renumber the indexes if renumber is true.
QgsMeshDatasetValue datasetValue(const QgsMeshDatasetIndex &index, int valueIndex) const
Returns vector/scalar value associated with the index from the dataset To read multiple continuous va...
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,...
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads configuration from the given DOM element.
int triangularMeshLevelOfDetailCount() const
Returns the count of levels of detail of the mesh simplification.
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).
A rectangle specified with double values.
void setEdgeStrokeWidth(const QgsInterpolatedLineWidth &strokeWidth)
Sets the stroke width used to render edges scalar dataset.
QgsMesh3dDataBlock is a block of 3d stacked mesh data related N faces defined on base mesh frame.
bool loadDefaultStyle
Set to true if the default layer style should be loaded.
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.
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.
@ Rendering
Rendering: scale visibility, simplify method, opacity.
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
QgsMeshDatasetMetadata datasetMetadata(const QgsMeshDatasetIndex &index) const
Returns the dataset metadata.
int extraDatasetGroupCount() const
Returns the extra dataset groups count handle by the layer.
static QgsStyle * defaultStyle()
Returns default application-wide style.
Class that makes edit operation on a mesh.
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
QString mLayerName
Name of the layer - used for display.
void updateTriangularMesh(const QgsCoordinateTransform &transform=QgsCoordinateTransform())
Gets native mesh and updates (creates if it doesn't exist) the base triangular mesh.
QList< int > selectFacesByExpression(QgsExpression expression)
Returns a list of faces indexes that meet the condition defined by expression with the context expres...
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext()) const
Writes configuration to a new DOM element.
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...
Class used to register and access all the dataset groups related to a mesh layer.
void stopEditing()
Stops editing.
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.
int meshVertexCount() const
Returns the vertices count of the mesh frame.
QgsMeshDatasetIndex staticVectorDatasetIndex() const
Returns the static vector dataset index that is rendered if the temporal properties is not active.
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
static QString typeToString(QgsMapLayerType type)
Converts a map layer type to a string value.
bool isModified() const
Returns whether the mesh has been modified.
QgsLayerMetadata metadata
QgsMeshDatasetIndex datasetIndexAtTime(const QgsDateTimeRange &timeRange, int datasetGroupIndex) const
Returns dataset index from datasets group depending on the time range.
virtual bool saveMeshFrame(const QgsMesh &mesh)=0
Saves the mesh frame to the source.
void setColorRampType(QgsColorRampShader::Type colorRampType)
Sets the color ramp type.
virtual void reloadData()
Reloads the data from the source for providers with data caches to synchronize, changes in the data s...
int activeScalarDatasetGroup() const
Returns the active scalar dataset group.
int group() const
Returns a group index.
QgsColorRamp * sourceColorRamp() const
Returns the source color ramp.
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
bool isActive() const
Returns true if the temporal property is active.
ElementType
Defines type of mesh elements.
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsColorRamp from a map of properties.
QgsMeshRendererScalarSettings scalarSettings(int groupIndex) const
Returns renderer settings.
bool isEnabled() const
Returns if the overview is active.
@ FlagLoadDefaultStyle
Reset the layer's style to the default for the datasource.
@ Exact
Assigns the color of the exact matching value in the color ramp item list.
Represents a width than can vary depending on values.
QgsMesh3dDataBlock dataset3dValues(const QgsMeshDatasetIndex &index, int faceIndex, int count) const
Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes.
int childCount() const
Returns the count of children.
QgsColorRampShader colorRampShader() const
Returns color ramp shader function.
QString formatTime(double hours)
Returns (date) time in hours formatted to human readable form.
QgsInterval datasetRelativeTime(const QgsMeshDatasetIndex &index)
Returns the relative time of the dataset from the reference time of its group.
QgsMeshDatasetGroupTreeItem * childFromDatasetGroupIndex(int index)
Returns the child with dataset group index Searches as depper as needed on the child hierarchy.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g. wind speed) and a dataset in thi...
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.
QList< int > selectVerticesByExpression(QgsExpression expression)
Returns a list of vertex indexes that meet the condition defined by expression with the context expre...
int activeVectorDatasetGroup() const
Returns the active vector dataset group.
bool contains(const QgsMesh::ElementType &type) const
Returns whether the mesh contains mesh elements of given type.
Represents a mesh layer supporting display of data on structured or unstructured meshes.
void setDatasetGroupTreeRootItem(QgsMeshDatasetGroupTreeItem *rootItem)
Sets the root items of the dataset group tree item.
const QVector< QgsMeshEdge > & edges() const
Returns edges.
QString generalHtmlMetadata() const
Returns an HTML fragment containing general metadata information, for use in the htmlMetadata() metho...
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const override
int validFacesCount() const
Returns the count of valid faces, that is non void faces in the mesh.
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
QgsRectangle extent() const
Returns the extent of the edited mesh.
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.
int meshFaceCount() const
Returns the faces count of the mesh frame.
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.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
Class defining color to render mesh datasets. The color can vary depending on the dataset value.
Class that represents an error during mesh editing.
double x() const
Returns x value.
void setTemporalUnit(QgsUnitTypes::TemporalUnit unit)
Sets the temporal unit of the provider and reload data if it changes.
int datasetCount(const QgsMeshDatasetIndex &index) const
Returns the dataset count in the dataset groups.
qint64 firstTimeStepDuration(int group) const
Returns the duration of the first time step of the dataset group with index group.
Base class for providing data for QgsMeshLayer.
@ InvalidFace
An error occurs due to an invalid face (for example, vertex indexes are unordered)
QDateTime referenceTime() const
Returns the reference time.
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...
QgsMesh * nativeMesh()
Returns native mesh (nullptr before rendering or calling to updateMesh)
QgsMeshEditingError initialize()
Initialize the mesh editor and return errors if the internal native mesh have topologic errors.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
bool commitFrameEditing(const QgsCoordinateTransform &transform, bool continueEditing=true)
Commits edition of the mesh frame, Rebuilds the triangular mesh and its spatial index with transform,...
@ None
Does not use resampling.
MatchingTemporalDatasetMethod
Method for selection of temporal mesh dataset from a range time.
virtual int edgeCount() const =0
Returns number of edges in the native mesh.
Base class for storage of map layer temporal properties.
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.
QgsTriangularMesh * triangularMeshByLodIndex(int lodIndex) const
Returns triangular corresponding to the index of level of details.
void setNativeMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new native mesh renderer settings, triggers repaint.
void layerModified()
Emitted when modifications has been done on layer.
@ InvalidVertex
An error occurs due to an invalid vertex (for example, vertex index is out of range the available ver...
QgsMeshDatasetIndex activeVectorDatasetAtTime(const QgsDateTimeRange &timeRange) const
Returns dataset index from active vector group depending on the time range If the temporal properties...
qint64 datasetRelativeTimeInMilliseconds(const QgsMeshDatasetIndex &index)
Returns the relative time (in milliseconds) of the dataset from the reference time of its group.
virtual int vertexCount() const =0
Returns number of vertices in the native mesh.
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.
Implementation of QgsAbstractProfileGenerator for mesh layers.
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QVector< int > QgsMeshFace
List of vertex indexes.
void setIsActive(bool active)
Sets whether the temporal property is active.
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.
QgsMeshLayerElevationProperties * clone() const override
Creates a clone of the properties.
void setColorRampShader(const QgsColorRampShader &shader)
Sets color ramp shader function.
QVariant evaluate()
Evaluate the feature and return the result.
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.
Abstract class to interpolate 3d stacked mesh data to 2d data.
Abstract class that represents a dataset group.
Represents an overview renderer settings.
void activeScalarDatasetGroupChanged(int index)
Emitted when active scalar group dataset is changed.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
void resetTriangularMesh(QgsTriangularMesh *triangularMesh)
Resets the triangular mesh.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
A class to represent a 2D point.
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.
QList< int > enabledDatasetGroupsIndexes() const
Returns the list of indexes of enables dataset groups handled by the layer.
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.
Represents a mesh renderer settings for scalar datasets.
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.
virtual int faceCount() const =0
Returns number of faces in the native mesh.
void setMaximumValue(double maximumValue)
Sets the maximum value used to defined the variable width.
@ TemporalMilliseconds
Milliseconds.
virtual QgsMeshDriverMetadata driverMetadata() const
Returns the mesh driver metadata of the provider.
bool addDatasets(const QString &path, const QDateTime &defaultReferenceTime=QDateTime())
Adds datasets to the mesh from file with path.
void setDataResamplingMethod(const DataResamplingMethod &dataResamplingMethod)
Sets data interpolation method.
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
static QgsExpressionContextScope * meshExpressionScope(QgsMesh::ElementType elementType)
Creates a new scope which contains functions relating to mesh layer element elementType.
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.
void meshEdited()
Emitted when the mesh is edited.
virtual void close()=0
Closes the data provider and free every resources used.
QgsAbstractProfileGenerator * createProfileGenerator(const QgsProfileRequest &request) override
Given a profile request, returns a new profile generator ready for generating elevation profiles.
static QgsMeshEditingError checkTopology(const QgsMesh &mesh, int maxVerticesPerFace)
Checks the topology of the mesh mesh, if error occurs, this mesh can't be edited.
QList< QgsMeshDatasetIndex > datasetIndexInRelativeTimeInterval(const QgsInterval &startRelativeTime, const QgsInterval &endRelativeTime, int datasetGroupIndex) const
Returns a list of dataset indexes from datasets group that are in a interval time from the layer refe...
@ ManifoldFace
ManifoldFace.
Base class for all map layer types. This is the base class for all map layer types (vector,...
const QVector< int > & trianglesToNativeFaces() const
Returns mapping between triangles and original faces.
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...
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
void invalidateWgs84Extent()
Invalidates the WGS84 extent.
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.
void timeSettingsChanged()
Emitted when time format is changed.
Implementation of threaded rendering for mesh layers.
void readXml(const QDomElement &elem, const QgsReadWriteContext &context=QgsReadWriteContext())
Reads configuration from the given DOM element.
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.
bool reindex(bool renumbering)
Reindexes the mesh, that is remove unusued index of face and vertices, this operation void the undo/r...
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...
QgsMesh3dAveragingMethod * averagingMethod() const
Returns averaging method for conversion of 3d stacked mesh data to 2d data.
void datasetGroupsAdded(QList< int > indexes)
Emitted after dataset groups are added.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
QgsMeshDatasetGroupMetadata datasetGroupMetadata(const QgsMeshDatasetIndex &index) const
Returns the dataset groups metadata.
int datasetGroupIndex() const
Qgis::MeshEditingErrorType errorType
@ TooManyVerticesInFace
A face has more vertices than the maximum number supported per face.
Triangular/Derived Mesh is mesh with vertices in map coordinates.
QgsMeshEditor * meshEditor()
Returns a pointer to the mesh editor own by the mesh layer.
bool hasTemporalCapabilities() const
Returns true if the provider has temporal capabilities available.
QgsRectangle extent() const override
Returns the extent of the layer.
virtual bool isSpatial() const
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated w...
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a new DOM element.
Represents a simple line renderer with width and color varying depending on values.
QgsMeshDataBlock datasetValues(const QgsMeshDatasetIndex &index, int valueIndex, int count) const
Returns N vector/scalar values from the index from the dataset.
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation 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.
void setValid(bool valid)
Sets whether layer is valid or not.
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.
bool checkConsistency(QgsMeshEditingError &error) const
Return true if the edited mesh is consistent.
void activeVectorDatasetGroupChanged(int index)
Emitted when active vector group dataset is changed.
Class for parsing and evaluation of expressions (formerly called "search strings")....
void setRendererSettings(const QgsMeshRendererSettings &settings)
Sets new renderer settings.
void trigger3DUpdate()
Will advise any 3D maps that this layer requires to be updated in the scene.
QgsMeshDatasetGroupTreeItem * child(int row) const
Returns a child.
int datasetGroupCount() const
Returns the dataset groups count handle by the layer.
QgsMeshDataBlock calculate(const QgsMesh3dDataBlock &block3d, QgsFeedback *feedback=nullptr) const
Calculated 2d block values from 3d stacked mesh values.
double sqrDistToSegment(double x1, double y1, double x2, double y2, QgsPointXY &minDistPoint, double epsilon=DEFAULT_SEGMENT_EPSILON) const SIP_HOLDGIL
Returns the minimum distance between this point and a segment.
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.
QgsMeshDataBlock areFacesActive(const QgsMeshDatasetIndex &index, int faceIndex, int count) const
Returns whether the faces are active for particular dataset.
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.
bool hasSettings(int datasetGroupIndex) const
Returns whether the group with index has render settings (scalar or vector)
@ UniqueSharedVertex
A least two faces share only one vertices.
bool isEditable() const override
Returns true if the layer can be edited.
int maximumVerticesPerFace() const
Returns the maximum count of vertices per face that the mesh can support.
virtual QStringList subLayers() const
Sub-layers handled by this provider, in order from bottom to top.
QDateTime referenceTime() const
Returns the reference time.
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.
virtual QgsError error() const
Gets current status error.
#define INVALID_MESHLAYER_TIME