QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgsmeshlayer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmeshlayer.cpp
3  ----------------
4  begin : April 2018
5  copyright : (C) 2018 by Peter Petrik
6  email : zilolv at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include <cstddef>
19 #include <limits>
20 
21 #include <QUuid>
22 
23 #include "qgscolorramp.h"
24 #include "qgslogger.h"
25 #include "qgsmaplayerlegend.h"
26 #include "qgsmeshdataprovider.h"
28 #include "qgsmeshlayer.h"
29 #include "qgsmeshlayerrenderer.h"
31 #include "qgsmeshlayerutils.h"
32 #include "qgsmeshtimesettings.h"
33 #include "qgspainting.h"
34 #include "qgsproviderregistry.h"
35 #include "qgsreadwritecontext.h"
36 #include "qgsstyle.h"
37 #include "qgstriangularmesh.h"
38 #include "qgsmesh3daveraging.h"
40 
41 QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
42  const QString &baseName,
43  const QString &providerKey,
44  const QgsMeshLayer::LayerOptions &options )
45  : QgsMapLayer( QgsMapLayerType::MeshLayer, baseName, meshLayerPath ),
46  mDatasetGroupStore( new QgsMeshDatasetGroupStore( this ) ),
47  mTemporalProperties( new QgsMeshLayerTemporalProperties( this ) )
48 
49 {
51 
52  setProviderType( providerKey );
53  // if we’re given a provider type, try to create and bind one to this layer
54  bool ok = false;
55  if ( !meshLayerPath.isEmpty() && !providerKey.isEmpty() )
56  {
57  QgsDataProvider::ProviderOptions providerOptions { options.transformContext };
58  QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags();
60  {
62  }
63  ok = setDataProvider( providerKey, providerOptions, flags );
64  }
65 
66  if ( ok )
67  {
69  setDefaultRendererSettings( mDatasetGroupStore->datasetGroupIndexes() );
70 
71  if ( mDataProvider )
72  {
73  mTemporalProperties->setDefaultsFromDataProviderTemporalCapabilities( mDataProvider->temporalCapabilities() );
75  }
76  }
77 
78  connect( mDatasetGroupStore.get(), &QgsMeshDatasetGroupStore::datasetGroupsAdded, this, &QgsMeshLayer::onDatasetGroupsAdded );
79 }
80 
81 
82 void QgsMeshLayer::setDefaultRendererSettings( const QList<int> &groupIndexes )
83 {
84  QgsMeshRendererMeshSettings meshSettings;
85  if ( groupIndexes.count() > 0 )
86  {
87  // Show data from the first dataset group
88  mRendererSettings.setActiveScalarDatasetGroup( 0 );
89  // If the first dataset group has nan min/max, display the mesh to avoid nothing displayed
91  if ( meta.maximum() == std::numeric_limits<double>::quiet_NaN() &&
92  meta.minimum() == std::numeric_limits<double>::quiet_NaN() )
93  meshSettings.setEnabled( true );
94  }
95  else
96  {
97  // show at least the mesh by default
98  meshSettings.setEnabled( true );
99  return;
100  }
101  mRendererSettings.setNativeMeshSettings( meshSettings );
102 
103  // Sets default resample method for scalar dataset
104  for ( int i : groupIndexes )
105  {
107  QgsMeshRendererScalarSettings scalarSettings = mRendererSettings.scalarSettings( i );
108  switch ( meta.dataType() )
109  {
111  case QgsMeshDatasetGroupMetadata::DataOnVolumes: // data on volumes are averaged to 2D data on faces
113  break;
116  break;
118  break;
119  }
120 
121  //override color ramp if the values in the dataset group are classified
122  applyClassificationOnScalarSettings( meta, scalarSettings );
123 
124  mRendererSettings.setScalarSettings( i, scalarSettings );
125  }
126 
127 }
128 
129 void QgsMeshLayer::createSimplifiedMeshes()
130 {
131  if ( mSimplificationSettings.isEnabled() && !hasSimplifiedMeshes() )
132  {
133  double reductionFactor = mSimplificationSettings.reductionFactor();
134 
135  QVector<QgsTriangularMesh *> simplifyMeshes =
136  mTriangularMeshes[0]->simplifyMesh( reductionFactor );
137 
138  for ( int i = 0; i < simplifyMeshes.count() ; ++i )
139  {
140  mTriangularMeshes.emplace_back( simplifyMeshes[i] );
141  }
142  }
143 }
144 
145 bool QgsMeshLayer::hasSimplifiedMeshes() const
146 {
147  //First mesh is the base mesh, so if size>1, there is no simplified meshes
148  return ( mTriangularMeshes.size() > 1 );
149 }
150 
152 {
153  delete mDataProvider;
154 }
155 
157 {
158  return mDataProvider;
159 }
160 
162 {
163  return mDataProvider;
164 }
165 
167 {
169  if ( mDataProvider )
170  {
171  options.transformContext = mDataProvider->transformContext();
172  }
173  QgsMeshLayer *layer = new QgsMeshLayer( source(), name(), mProviderKey, options );
174  QgsMapLayer::clone( layer );
175  return layer;
176 }
177 
179 {
180  if ( mDataProvider )
181  return mDataProvider->extent();
182  else
183  {
184  QgsRectangle rec;
185  rec.setMinimal();
186  return rec;
187  }
188 }
189 
191 {
192  return mProviderKey;
193 }
194 
195 bool QgsMeshLayer::addDatasets( const QString &path, const QDateTime &defaultReferenceTime )
196 {
197  bool isTemporalBefore = dataProvider()->temporalCapabilities()->hasTemporalCapabilities();
198  if ( mDatasetGroupStore->addPersistentDatasets( path ) )
199  {
200  QgsMeshLayerTemporalProperties *temporalProperties = qobject_cast< QgsMeshLayerTemporalProperties * >( mTemporalProperties );
201  if ( !isTemporalBefore && dataProvider()->temporalCapabilities()->hasTemporalCapabilities() )
202  {
204  dataProvider()->temporalCapabilities() );
205 
206  if ( ! temporalProperties->referenceTime().isValid() )
207  {
208  QDateTime referenceTime = defaultReferenceTime;
209  if ( !defaultReferenceTime.isValid() ) // If project reference time is invalid, use current date
210  referenceTime = QDateTime( QDate::currentDate(), QTime( 0, 0, 0, Qt::UTC ), Qt::UTC );
211  temporalProperties->setReferenceTime( referenceTime, dataProvider()->temporalCapabilities() );
212  }
213 
214  mTemporalProperties->setIsActive( true );
215  }
216  emit dataSourceChanged();
217  return true;
218  }
219 
220  return false;
221 }
222 
224 {
225  if ( mDatasetGroupStore->addDatasetGroup( datasetGroup ) )
226  {
227  emit dataChanged();
228  return true;
229  }
230  return false;
231 }
232 
233 bool QgsMeshLayer::saveDataset( const QString &path, int datasetGroupIndex, QString driver )
234 {
235  return mDatasetGroupStore->saveDatasetGroup( path, datasetGroupIndex, driver );
236 }
237 
239 {
240  return mNativeMesh.get();
241 }
242 
244 {
245  return mNativeMesh.get();
246 }
247 
248 QgsTriangularMesh *QgsMeshLayer::triangularMesh( double minimumTriangleSize ) const
249 {
250  for ( const std::unique_ptr<QgsTriangularMesh> &lod : mTriangularMeshes )
251  {
252  if ( lod && lod->averageTriangleSize() > minimumTriangleSize )
253  return lod.get();
254  }
255 
256  if ( !mTriangularMeshes.empty() )
257  return mTriangularMeshes.back().get();
258  else
259  return nullptr;
260 }
261 
263 {
264  // Native mesh
265  if ( !mNativeMesh )
266  {
267  // lazy loading of mesh data
268  fillNativeMesh();
269  }
270 
271  // Triangular mesh
272  if ( mTriangularMeshes.empty() )
273  {
274  QgsTriangularMesh *baseMesh = new QgsTriangularMesh;
275  mTriangularMeshes.emplace_back( baseMesh );
276  }
277 
278  if ( mTriangularMeshes[0].get()->update( mNativeMesh.get(), transform ) )
279  mTriangularMeshes.resize( 1 ); //if the base triangular mesh is effectivly updated, remove simplified meshes
280 }
281 
282 QgsMeshLayerRendererCache *QgsMeshLayer::rendererCache()
283 {
284  return mRendererCache.get();
285 }
286 
288 {
289  return mRendererSettings;
290 }
291 
293 {
294  int oldActiveScalar = mRendererSettings.activeScalarDatasetGroup();
295  int oldActiveVector = mRendererSettings.activeVectorDatasetGroup();
296  mRendererSettings = settings;
297 
298  if ( oldActiveScalar != mRendererSettings.activeScalarDatasetGroup() )
299  emit activeScalarDatasetGroupChanged( mRendererSettings.activeScalarDatasetGroup() );
300 
301  if ( oldActiveVector != mRendererSettings.activeVectorDatasetGroup() )
302  emit activeVectorDatasetGroupChanged( mRendererSettings.activeVectorDatasetGroup() );
303 
304  emit rendererChanged();
305  triggerRepaint();
306 }
307 
309 {
310  return mTimeSettings;
311 }
312 
314 {
315  mTimeSettings = settings;
316  emit timeSettingsChanged();
317 }
318 
319 QString QgsMeshLayer::formatTime( double hours )
320 {
321  if ( dataProvider() && dataProvider()->temporalCapabilities()->hasReferenceTime() )
322  return QgsMeshLayerUtils::formatTime( hours, mTemporalProperties->referenceTime(), mTimeSettings );
323  else
324  return QgsMeshLayerUtils::formatTime( hours, QDateTime(), mTimeSettings );
325 }
326 
328 {
329  return mDatasetGroupStore->datasetGroupCount();
330 }
331 
333 {
334  return mDatasetGroupStore->extraDatasetGroupCount();
335 }
336 
338 {
339  return mDatasetGroupStore->datasetGroupIndexes();
340 }
341 
343 {
344  return mDatasetGroupStore->datasetGroupMetadata( index );
345 }
346 
348 {
349  return mDatasetGroupStore->datasetCount( index.group() );
350 }
351 
353 {
354  return mDatasetGroupStore->datasetMetadata( index );
355 }
356 
358 {
359  return mDatasetGroupStore->datasetValue( index, valueIndex );
360 }
361 
362 QgsMeshDataBlock QgsMeshLayer::datasetValues( const QgsMeshDatasetIndex &index, int valueIndex, int count ) const
363 {
364  return mDatasetGroupStore->datasetValues( index, valueIndex, count );
365 }
366 
367 QgsMesh3dDataBlock QgsMeshLayer::dataset3dValues( const QgsMeshDatasetIndex &index, int faceIndex, int count ) const
368 {
369  return mDatasetGroupStore->dataset3dValues( index, faceIndex, count );
370 }
371 
372 QgsMeshDataBlock QgsMeshLayer::areFacesActive( const QgsMeshDatasetIndex &index, int faceIndex, int count ) const
373 {
374  return mDatasetGroupStore->areFacesActive( index, faceIndex, count );
375 }
376 
377 bool QgsMeshLayer::isFaceActive( const QgsMeshDatasetIndex &index, int faceIndex ) const
378 {
379  return mDatasetGroupStore->isFaceActive( index, faceIndex );
380 }
381 
382 QgsMeshDatasetValue QgsMeshLayer::datasetValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius ) const
383 {
384  QgsMeshDatasetValue value;
385  const QgsTriangularMesh *mesh = triangularMesh();
386 
387  if ( mesh && dataProvider() && dataProvider()->isValid() && index.isValid() )
388  {
389  if ( dataProvider()->contains( QgsMesh::ElementType::Edge ) )
390  {
391  QgsRectangle searchRectangle( point.x() - searchRadius, point.y() - searchRadius, point.x() + searchRadius, point.y() + searchRadius );
392  return dataset1dValue( index, point, searchRadius );
393  }
394  int faceIndex = mesh->faceIndexForPoint_v2( point ) ;
395  if ( faceIndex >= 0 )
396  {
397  int nativeFaceIndex = mesh->trianglesToNativeFaces().at( faceIndex );
399  if ( isFaceActive( index, nativeFaceIndex ) )
400  {
401  switch ( dataType )
402  {
404  {
405  value = datasetValue( index, nativeFaceIndex );
406  }
407  break;
408 
410  {
411  const QgsMeshFace &face = mesh->triangles()[faceIndex];
412  const int v1 = face[0], v2 = face[1], v3 = face[2];
413  const QgsPoint p1 = mesh->vertices()[v1], p2 = mesh->vertices()[v2], p3 = mesh->vertices()[v3];
414  const QgsMeshDatasetValue val1 = datasetValue( index, v1 );
415  const QgsMeshDatasetValue val2 = datasetValue( index, v2 );
416  const QgsMeshDatasetValue val3 = datasetValue( index, v3 );
417  const double x = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.x(), val2.x(), val3.x(), point );
418  double y = std::numeric_limits<double>::quiet_NaN();
419  bool isVector = datasetGroupMetadata( index ).isVector();
420  if ( isVector )
421  y = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.y(), val2.y(), val3.y(), point );
422 
423  value = QgsMeshDatasetValue( x, y );
424  }
425  break;
426 
428  {
429  const QgsMesh3dAveragingMethod *avgMethod = mRendererSettings.averagingMethod();
430  if ( avgMethod )
431  {
432  const QgsMesh3dDataBlock block3d = dataset3dValues( index, nativeFaceIndex, 1 );
433  const QgsMeshDataBlock block2d = avgMethod->calculate( block3d );
434  if ( block2d.isValid() )
435  {
436  value = block2d.value( 0 );
437  }
438  }
439  }
440  break;
441 
442  default:
443  break;
444  }
445  }
446  }
447  }
448 
449  return value;
450 }
451 
453 {
454  QgsMesh3dDataBlock block3d;
455 
456  const QgsTriangularMesh *baseTriangularMesh = triangularMesh();
457 
458  if ( baseTriangularMesh && dataProvider() && dataProvider()->isValid() && index.isValid() )
459  {
462  {
463  int faceIndex = baseTriangularMesh->faceIndexForPoint_v2( point );
464  if ( faceIndex >= 0 )
465  {
466  int nativeFaceIndex = baseTriangularMesh->trianglesToNativeFaces().at( faceIndex );
467  block3d = dataset3dValues( index, nativeFaceIndex, 1 );
468  }
469  }
470  }
471  return block3d;
472 }
473 
474 QgsMeshDatasetValue QgsMeshLayer::dataset1dValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius ) const
475 {
476  QgsMeshDatasetValue value;
477  QgsPointXY projectedPoint;
478  int selectedIndex = closestEdge( point, searchRadius, projectedPoint );
479  const QgsTriangularMesh *mesh = triangularMesh();
480  if ( selectedIndex >= 0 )
481  {
483  switch ( dataType )
484  {
486  {
487  value = datasetValue( index, selectedIndex );
488  }
489  break;
490 
492  {
493  const QgsMeshEdge &edge = mesh->edges()[selectedIndex];
494  const int v1 = edge.first, v2 = edge.second;
495  const QgsPoint p1 = mesh->vertices()[v1], p2 = mesh->vertices()[v2];
496  const QgsMeshDatasetValue val1 = datasetValue( index, v1 );
497  const QgsMeshDatasetValue val2 = datasetValue( index, v2 );
498  double edgeLength = p1.distance( p2 );
499  double dist1 = p1.distance( projectedPoint.x(), projectedPoint.y() );
500  value = QgsMeshLayerUtils::interpolateFromVerticesData( dist1 / edgeLength, val1, val2 );
501  }
502  break;
503  default:
504  break;
505  }
506  }
507 
508  return value;
509 }
510 
512 {
513  if ( mDataProvider )
514  mDataProvider->setTransformContext( transformContext );
515 }
516 
517 QgsMeshDatasetIndex QgsMeshLayer::datasetIndexAtTime( const QgsDateTimeRange &timeRange, int datasetGroupIndex ) const
518 {
519  if ( ! mTemporalProperties->isActive() )
520  return QgsMeshDatasetIndex( datasetGroupIndex, -1 );
521 
522  const QDateTime layerReferenceTime = mTemporalProperties->referenceTime();
523  qint64 startTime = layerReferenceTime.msecsTo( timeRange.begin() );
524 
525  return mDatasetGroupStore->datasetIndexAtTime( startTime, datasetGroupIndex, mTemporalProperties->matchingMethod() );
526 }
527 
528 QgsMeshDatasetIndex QgsMeshLayer::datasetIndexAtRelativeTime( const QgsInterval &relativeTime, int datasetGroupIndex ) const
529 {
530  qint64 usedRelativeTime = relativeTime.seconds() * 1000;
531 
532  //adjust relative time if layer reference time is different from provider reference time
533  if ( mTemporalProperties->referenceTime().isValid() &&
534  mDataProvider &&
535  mDataProvider->isValid() &&
536  mTemporalProperties->referenceTime() != mDataProvider->temporalCapabilities()->referenceTime() )
537  usedRelativeTime = usedRelativeTime + mTemporalProperties->referenceTime().msecsTo( mDataProvider->temporalCapabilities()->referenceTime() );
538 
539  return mDatasetGroupStore->datasetIndexAtTime( relativeTime.seconds() * 1000, datasetGroupIndex, mTemporalProperties->matchingMethod() );
540 }
541 
542 void QgsMeshLayer::applyClassificationOnScalarSettings( const QgsMeshDatasetGroupMetadata &meta, QgsMeshRendererScalarSettings &scalarSettings ) const
543 {
544  if ( meta.extraOptions().contains( QStringLiteral( "classification" ) ) )
545  {
546  QgsColorRampShader colorRampShader = scalarSettings.colorRampShader();
547  QgsColorRamp *colorRamp = colorRampShader.sourceColorRamp();
548  QStringList classes = meta.extraOptions()[QStringLiteral( "classification" )].split( QStringLiteral( ";;" ) );
549 
550  QString units;
551  if ( meta.extraOptions().contains( QStringLiteral( "units" ) ) )
552  units = meta.extraOptions()[ QStringLiteral( "units" )];
553 
554  QVector<QVector<double>> bounds;
555  for ( const QString &classe : classes )
556  {
557  QStringList boundsStr = classe.split( ',' );
558  QVector<double> bound;
559  for ( const QString &boundStr : boundsStr )
560  bound.append( boundStr.toDouble() );
561  bounds.append( bound );
562  }
563 
564  if ( ( bounds.count() == 1 && bounds.first().count() > 2 ) || // at least a class with two value
565  ( bounds.count() > 1 ) ) // or at least two classes
566  {
567  const QVector<double> firstClass = bounds.first();
568  const QVector<double> lastClass = bounds.last();
569  double minValue = firstClass.count() > 1 ? ( firstClass.first() + firstClass.last() ) / 2 : firstClass.first();
570  double maxValue = lastClass.count() > 1 ? ( lastClass.first() + lastClass.last() ) / 2 : lastClass.first();
571  double diff = maxValue - minValue;
572  QList<QgsColorRampShader::ColorRampItem> colorRampItemlist;
573  for ( int i = 0; i < bounds.count(); ++i )
574  {
575  const QVector<double> &boundClass = bounds.at( i );
577  item.value = i + 1;
578  if ( !boundClass.isEmpty() )
579  {
580  double scalarValue = ( boundClass.first() + boundClass.last() ) / 2;
581  item.color = colorRamp->color( ( scalarValue - minValue ) / diff );
582  if ( i != 0 && i < bounds.count() - 1 ) //The first and last labels are treated after
583  {
584  item.label = QString( ( "%1 - %2 %3" ) ).
585  arg( QString::number( boundClass.first() ) ).
586  arg( QString::number( boundClass.last() ) ).
587  arg( units );
588  }
589  }
590  colorRampItemlist.append( item );
591  }
592  //treat first and last labels
593  if ( firstClass.count() == 1 )
594  colorRampItemlist.first().label = QObject::tr( "below %1 %2" ).
595  arg( QString::number( firstClass.first() ) ).
596  arg( units );
597  else
598  {
599  colorRampItemlist.first().label = QString( ( "%1 - %2 %3" ) ).
600  arg( QString::number( firstClass.first() ) ).
601  arg( QString::number( firstClass.last() ) ).
602  arg( units );
603  }
604 
605  if ( lastClass.count() == 1 )
606  colorRampItemlist.last().label = QObject::tr( "above %1 %2" ).
607  arg( QString::number( lastClass.first() ) ).
608  arg( units );
609  else
610  {
611  colorRampItemlist.last().label = QString( ( "%1 - %2 %3" ) ).
612  arg( QString::number( lastClass.first() ) ).
613  arg( QString::number( lastClass.last() ) ).
614  arg( units );
615  }
616 
617  colorRampShader.setMinimumValue( 0 );
618  colorRampShader.setMaximumValue( colorRampItemlist.count() - 1 );
619  scalarSettings.setClassificationMinimumMaximum( 0, colorRampItemlist.count() - 1 );
620  colorRampShader.setColorRampItemList( colorRampItemlist );
621  colorRampShader.setColorRampType( QgsColorRampShader::Exact );
623  }
624 
625  scalarSettings.setColorRampShader( colorRampShader );
627  }
628 }
629 
630 QgsMeshDatasetIndex QgsMeshLayer::activeScalarDatasetAtTime( const QgsDateTimeRange &timeRange ) const
631 {
632  if ( mTemporalProperties->isActive() )
633  return datasetIndexAtTime( timeRange, mRendererSettings.activeScalarDatasetGroup() );
634  else
635  return QgsMeshDatasetIndex( mRendererSettings.activeScalarDatasetGroup(), mStaticScalarDatasetIndex );
636 }
637 
638 QgsMeshDatasetIndex QgsMeshLayer::activeVectorDatasetAtTime( const QgsDateTimeRange &timeRange ) const
639 {
640  if ( mTemporalProperties->isActive() )
641  return datasetIndexAtTime( timeRange, mRendererSettings.activeVectorDatasetGroup() );
642  else
643  return QgsMeshDatasetIndex( mRendererSettings.activeVectorDatasetGroup(), mStaticVectorDatasetIndex );
644 }
645 
646 void QgsMeshLayer::fillNativeMesh()
647 {
648  Q_ASSERT( !mNativeMesh );
649 
650  mNativeMesh.reset( new QgsMesh() );
651 
652  if ( !( dataProvider() && dataProvider()->isValid() ) )
653  return;
654 
655  dataProvider()->populateMesh( mNativeMesh.get() );
656 }
657 
658 void QgsMeshLayer::onDatasetGroupsAdded( const QList<int> &datasetGroupIndexes )
659 {
660  // assign default style to new dataset groups
661  for ( int i = 0; i < datasetGroupIndexes.count(); ++i )
662  assignDefaultStyleToDatasetGroup( datasetGroupIndexes.at( i ) );
663 
664  temporalProperties()->setIsActive( mDatasetGroupStore->hasTemporalCapabilities() );
665  emit rendererChanged();
666 }
667 
669 {
670  return mDatasetGroupStore->datasetGroupTreeItem();
671 }
672 
674 {
675  mDatasetGroupStore->setDatasetGroupTreeItem( rootItem );
676  updateActiveDatasetGroups();
677 }
678 
679 int QgsMeshLayer::closestEdge( const QgsPointXY &point, double searchRadius, QgsPointXY &projectedPoint ) const
680 {
681  QgsRectangle searchRectangle( point.x() - searchRadius, point.y() - searchRadius, point.x() + searchRadius, point.y() + searchRadius );
682  const QgsTriangularMesh *mesh = triangularMesh();
683  // search for the closest edge in search area from point
684  const QList<int> edgeIndexes = mesh->edgeIndexesForRectangle( searchRectangle );
685  int selectedIndex = -1;
686  if ( mesh->contains( QgsMesh::Edge ) &&
687  mDataProvider->isValid() )
688  {
689  double sqrMaxDistFromPoint = pow( searchRadius, 2 );
690  for ( const int edgeIndex : edgeIndexes )
691  {
692  const QgsMeshEdge &edge = mesh->edges().at( edgeIndex );
693  const QgsMeshVertex &vertex1 = mesh->vertices()[edge.first];
694  const QgsMeshVertex &vertex2 = mesh->vertices()[edge.second];
695  QgsPointXY projPoint;
696  double sqrDist = point.sqrDistToSegment( vertex1.x(), vertex1.y(), vertex2.x(), vertex2.y(), projPoint );
697  if ( sqrDist < sqrMaxDistFromPoint )
698  {
699  selectedIndex = edgeIndex;
700  projectedPoint = projPoint;
701  sqrMaxDistFromPoint = sqrDist;
702  }
703  }
704  }
705 
706  return selectedIndex;
707 }
708 
710 {
711  return QgsMeshDatasetIndex( mRendererSettings.activeVectorDatasetGroup(), mStaticVectorDatasetIndex );
712 }
713 
714 void QgsMeshLayer::setReferenceTime( const QDateTime &referenceTime )
715 {
716  if ( auto *lDataProvider = dataProvider() )
717  mTemporalProperties->setReferenceTime( referenceTime, lDataProvider->temporalCapabilities() );
718  else
719  mTemporalProperties->setReferenceTime( referenceTime, nullptr );
720 }
721 
723 {
724  mTemporalProperties->setMatchingMethod( matchingMethod );
725 }
726 
727 QgsPointXY QgsMeshLayer::snapOnVertex( const QgsPointXY &point, double searchRadius )
728 {
729  const QgsTriangularMesh *mesh = triangularMesh();
730  QgsPointXY exactPosition;
731  if ( !mesh )
732  return exactPosition;
733  QgsRectangle rectangle( point.x() - searchRadius, point.y() - searchRadius, point.x() + searchRadius, point.y() + searchRadius );
734  double maxDistance = searchRadius;
735  //attempt to snap on edges's vertices
736  QList<int> edgeIndexes = mesh->edgeIndexesForRectangle( rectangle );
737  for ( const int edgeIndex : edgeIndexes )
738  {
739  const QgsMeshEdge &edge = mesh->edges().at( edgeIndex );
740  const QgsMeshVertex &vertex1 = mesh->vertices()[edge.first];
741  const QgsMeshVertex &vertex2 = mesh->vertices()[edge.second];
742  double dist1 = point.distance( vertex1 );
743  double dist2 = point.distance( vertex2 );
744  if ( dist1 < maxDistance )
745  {
746  maxDistance = dist1;
747  exactPosition = vertex1;
748  }
749  if ( dist2 < maxDistance )
750  {
751  maxDistance = dist2;
752  exactPosition = vertex2;
753  }
754  }
755 
756  //attempt to snap on face's vertices
757  QList<int> faceIndexes = mesh->faceIndexesForRectangle( rectangle );
758  for ( const int faceIndex : faceIndexes )
759  {
760  const QgsMeshFace &face = mesh->triangles().at( faceIndex );
761  for ( int i = 0; i < 3; ++i )
762  {
763  const QgsMeshVertex &vertex = mesh->vertices()[face.at( i )];
764  double dist = point.distance( vertex );
765  if ( dist < maxDistance )
766  {
767  maxDistance = dist;
768  exactPosition = vertex;
769  }
770  }
771  }
772 
773  return exactPosition;
774 }
775 
776 QgsPointXY QgsMeshLayer::snapOnEdge( const QgsPointXY &point, double searchRadius )
777 {
778  QgsPointXY projectedPoint;
779  closestEdge( point, searchRadius, projectedPoint );
780 
781  return projectedPoint;
782 }
783 
784 QgsPointXY QgsMeshLayer::snapOnFace( const QgsPointXY &point, double searchRadius )
785 {
786  const QgsTriangularMesh *mesh = triangularMesh();
787  QgsPointXY centroidPosition;
788  if ( !mesh )
789  return centroidPosition;
790  QgsRectangle rectangle( point.x() - searchRadius, point.y() - searchRadius, point.x() + searchRadius, point.y() + searchRadius );
791  double maxDistance = std::numeric_limits<double>::max();
792 
793  QList<int> faceIndexes = mesh->faceIndexesForRectangle( rectangle );
794  for ( const int faceIndex : faceIndexes )
795  {
796  int nativefaceIndex = mesh->trianglesToNativeFaces().at( faceIndex );
797  if ( nativefaceIndex < 0 && nativefaceIndex >= mesh->faceCentroids().count() )
798  continue;
799  const QgsPointXY centroid = mesh->faceCentroids()[nativefaceIndex];
800  double dist = point.distance( centroid );
801  if ( dist < maxDistance )
802  {
803  maxDistance = dist;
804  centroidPosition = centroid;
805  }
806  }
807 
808  return centroidPosition;
809 }
810 
812 {
813  mDatasetGroupStore->resetDatasetGroupTreeItem();
814  updateActiveDatasetGroups();
815 }
816 
818 {
819  if ( !mDataProvider )
820  return QgsInterval();
821  int groupCount = mDataProvider->datasetGroupCount();
822  for ( int i = 0; i < groupCount; ++i )
823  {
824  qint64 timeStep = mDataProvider->temporalCapabilities()->firstTimeStepDuration( i );
825  if ( timeStep > 0 )
827  }
828 
829  return QgsInterval();
830 }
831 
833 {
834  qint64 time = mDatasetGroupStore->datasetRelativeTime( index );
835 
836  if ( time == INVALID_MESHLAYER_TIME )
837  return QgsInterval();
838  else
840 }
841 
843 {
844  return mDatasetGroupStore->datasetRelativeTime( index );
845 }
846 
847 void QgsMeshLayer::updateActiveDatasetGroups()
848 {
849  QgsMeshDatasetGroupTreeItem *treeItem = mDatasetGroupStore->datasetGroupTreeItem();
850 
851  if ( !mDatasetGroupStore->datasetGroupTreeItem() )
852  return;
853 
855  int oldActiveScalar = settings.activeScalarDatasetGroup();
856  int oldActiveVector = settings.activeVectorDatasetGroup();
857 
858  QgsMeshDatasetGroupTreeItem *activeScalarItem =
859  treeItem->childFromDatasetGroupIndex( oldActiveScalar );
860 
861  if ( !activeScalarItem && treeItem->childCount() > 0 )
862  activeScalarItem = treeItem->child( 0 );
863 
864  if ( activeScalarItem && !activeScalarItem->isEnabled() )
865  {
866  for ( int i = 0; i < treeItem->childCount(); ++i )
867  {
868  activeScalarItem = treeItem->child( i );
869  if ( activeScalarItem->isEnabled() )
870  break;
871  else
872  activeScalarItem = nullptr;
873  }
874  }
875 
876  if ( activeScalarItem )
877  settings.setActiveScalarDatasetGroup( activeScalarItem->datasetGroupIndex() );
878  else
879  settings.setActiveScalarDatasetGroup( -1 );
880 
881  QgsMeshDatasetGroupTreeItem *activeVectorItem =
882  treeItem->childFromDatasetGroupIndex( oldActiveVector );
883 
884  if ( !( activeVectorItem && activeVectorItem->isEnabled() ) )
885  settings.setActiveVectorDatasetGroup( -1 );
886 
887  setRendererSettings( settings );
888 
889  if ( oldActiveScalar != settings.activeScalarDatasetGroup() )
891  if ( oldActiveVector != settings.activeVectorDatasetGroup() )
893 }
894 
895 QgsPointXY QgsMeshLayer::snapOnElement( QgsMesh::ElementType elementType, const QgsPointXY &point, double searchRadius )
896 {
897  switch ( elementType )
898  {
899  case QgsMesh::Vertex:
900  return snapOnVertex( point, searchRadius );
901  case QgsMesh::Edge:
902  return snapOnEdge( point, searchRadius );
903  case QgsMesh::Face:
904  return snapOnFace( point, searchRadius );
905  }
906  return QgsPointXY(); // avoid warnings
907 }
908 
910 {
911  return QgsMeshDatasetIndex( mRendererSettings.activeScalarDatasetGroup(), mStaticScalarDatasetIndex );
912 }
913 
914 void QgsMeshLayer::setStaticVectorDatasetIndex( const QgsMeshDatasetIndex &staticVectorDatasetIndex )
915 {
916  int oldActiveVector = mRendererSettings.activeVectorDatasetGroup();
917 
918  mStaticVectorDatasetIndex = staticVectorDatasetIndex.dataset();
920 
921  if ( oldActiveVector != mRendererSettings.activeVectorDatasetGroup() )
922  emit activeVectorDatasetGroupChanged( mRendererSettings.activeVectorDatasetGroup() );
923 }
924 
925 void QgsMeshLayer::setStaticScalarDatasetIndex( const QgsMeshDatasetIndex &staticScalarDatasetIndex )
926 {
927  int oldActiveScalar = mRendererSettings.activeScalarDatasetGroup();
928 
929  mStaticScalarDatasetIndex = staticScalarDatasetIndex.dataset();
931 
932  if ( oldActiveScalar != mRendererSettings.activeScalarDatasetGroup() )
933  emit activeScalarDatasetGroupChanged( mRendererSettings.activeScalarDatasetGroup() );
934 }
935 
937 {
938  return mSimplificationSettings;
939 }
940 
942 {
943  mSimplificationSettings = simplifySettings;
944 }
945 
946 static QgsColorRamp *_createDefaultColorRamp()
947 {
948  QgsColorRamp *ramp = QgsStyle::defaultStyle()->colorRamp( QStringLiteral( "Plasma" ) );
949  if ( ramp )
950  return ramp;
951 
952  // definition of "Plasma" color ramp (in case it is not available in the style for some reason)
953  QgsStringMap props;
954  props["color1"] = "13,8,135,255";
955  props["color2"] = "240,249,33,255";
956  props["stops"] =
957  "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:"
958  "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:"
959  "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:"
960  "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:"
961  "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:"
962  "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:"
963  "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:"
964  "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:"
965  "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:"
966  "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";
967  return QgsGradientColorRamp::create( props );
968 }
969 
970 void QgsMeshLayer::assignDefaultStyleToDatasetGroup( int groupIndex )
971 {
973  double groupMin = metadata.minimum();
974  double groupMax = metadata.maximum();
975 
976  QgsColorRampShader fcn( groupMin, groupMax, _createDefaultColorRamp() );
977  fcn.classifyColorRamp( 5, -1, QgsRectangle(), nullptr );
978 
979  QgsMeshRendererScalarSettings scalarSettings;
980  scalarSettings.setClassificationMinimumMaximum( groupMin, groupMax );
981  scalarSettings.setColorRampShader( fcn );
982  QgsInterpolatedLineWidth edgeStrokeWidth;
983  edgeStrokeWidth.setMinimumValue( groupMin );
984  edgeStrokeWidth.setMaximumValue( groupMax );
985  QgsInterpolatedLineColor edgeStrokeColor( fcn );
986  QgsInterpolatedLineRenderer edgeStrokePen;
987  scalarSettings.setEdgeStrokeWidth( edgeStrokeWidth );
988  mRendererSettings.setScalarSettings( groupIndex, scalarSettings );
989 
990  if ( metadata.isVector() )
991  {
992  QgsMeshRendererVectorSettings vectorSettings;
993  vectorSettings.setColorRampShader( fcn );
994  mRendererSettings.setVectorSettings( groupIndex, vectorSettings );
995  }
996 }
997 
999 {
1000  // Triangular mesh
1001  updateTriangularMesh( rendererContext.coordinateTransform() );
1002 
1003  // Build overview triangular meshes if needed
1004  createSimplifiedMeshes();
1005 
1006  // Cache
1007  if ( !mRendererCache )
1008  mRendererCache.reset( new QgsMeshLayerRendererCache() );
1009 
1010  return new QgsMeshLayerRenderer( this, rendererContext );
1011 }
1012 
1013 bool QgsMeshLayer::readSymbology( const QDomNode &node, QString &errorMessage,
1014  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
1015 {
1016  Q_UNUSED( errorMessage )
1017  // TODO: implement categories for raster layer
1018 
1019  QDomElement elem = node.toElement();
1020 
1021  readCommonStyle( elem, context, categories );
1022 
1023  QDomElement elemRendererSettings = elem.firstChildElement( "mesh-renderer-settings" );
1024  if ( !elemRendererSettings.isNull() )
1025  mRendererSettings.readXml( elemRendererSettings );
1026 
1027  QDomElement elemSimplifySettings = elem.firstChildElement( "mesh-simplify-settings" );
1028  if ( !elemSimplifySettings.isNull() )
1029  mSimplificationSettings.readXml( elemSimplifySettings, context );
1030 
1031  // get and set the blend mode if it exists
1032  QDomNode blendModeNode = node.namedItem( QStringLiteral( "blendMode" ) );
1033  if ( !blendModeNode.isNull() )
1034  {
1035  QDomElement e = blendModeNode.toElement();
1036  setBlendMode( QgsPainting::getCompositionMode( static_cast< QgsPainting::BlendMode >( e.text().toInt() ) ) );
1037  }
1038 
1039  return true;
1040 }
1041 
1042 bool QgsMeshLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1043  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
1044 {
1045  Q_UNUSED( errorMessage )
1046  // TODO: implement categories for raster layer
1047 
1048  QDomElement elem = node.toElement();
1049 
1050  writeCommonStyle( elem, doc, context, categories );
1051 
1052  QDomElement elemRendererSettings = mRendererSettings.writeXml( doc );
1053  elem.appendChild( elemRendererSettings );
1054 
1055  QDomElement elemSimplifySettings = mSimplificationSettings.writeXml( doc, context );
1056  elem.appendChild( elemSimplifySettings );
1057 
1058  // add blend mode node
1059  QDomElement blendModeElement = doc.createElement( QStringLiteral( "blendMode" ) );
1060  QDomText blendModeText = doc.createTextNode( QString::number( QgsPainting::getBlendModeEnum( blendMode() ) ) );
1061  blendModeElement.appendChild( blendModeText );
1062  node.appendChild( blendModeElement );
1063 
1064  return true;
1065 }
1066 
1067 bool QgsMeshLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
1068 {
1069  return writeSymbology( node, doc, errorMessage, context, categories );
1070 }
1071 
1072 bool QgsMeshLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
1073 {
1074  return readSymbology( node, errorMessage, context, categories );
1075 }
1076 
1077 QString QgsMeshLayer::decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const
1078 {
1079  QString src( source );
1080  if ( provider == QLatin1String( "mdal" ) )
1081  {
1082  src = context.pathResolver().readPath( src );
1083  }
1084  return src;
1085 }
1086 
1087 QString QgsMeshLayer::encodedSource( const QString &source, const QgsReadWriteContext &context ) const
1088 {
1089  QString src( source );
1090  if ( providerType() == QLatin1String( "mdal" ) )
1091  {
1092  src = context.pathResolver().writePath( src );
1093  }
1094  return src;
1095 }
1096 
1097 bool QgsMeshLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &context )
1098 {
1099  QgsDebugMsgLevel( QStringLiteral( "Datasource in QgsMeshLayer::readXml: %1" ).arg( mDataSource.toLocal8Bit().data() ), 3 );
1100 
1101  //process provider key
1102  QDomNode pkeyNode = layer_node.namedItem( QStringLiteral( "provider" ) );
1103 
1104  if ( pkeyNode.isNull() )
1105  {
1106  mProviderKey.clear();
1107  }
1108  else
1109  {
1110  QDomElement pkeyElt = pkeyNode.toElement();
1111  mProviderKey = pkeyElt.text();
1112  }
1113 
1115  {
1116  return false;
1117  }
1118 
1119  QgsDataProvider::ProviderOptions providerOptions;
1120  QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags();
1122  {
1124  }
1125  if ( !setDataProvider( mProviderKey, providerOptions, flags ) )
1126  {
1127  return false;
1128  }
1129 
1130  QDomElement elemExtraDatasets = layer_node.firstChildElement( QStringLiteral( "extra-datasets" ) );
1131  if ( !elemExtraDatasets.isNull() )
1132  {
1133  QDomElement elemUri = elemExtraDatasets.firstChildElement( QStringLiteral( "uri" ) );
1134  while ( !elemUri.isNull() )
1135  {
1136  QString uri = context.pathResolver().readPath( elemUri.text() );
1137 
1138  bool res = mDataProvider->addDataset( uri );
1139 #ifdef QGISDEBUG
1140  QgsDebugMsg( QStringLiteral( "extra dataset (res %1): %2" ).arg( res ).arg( uri ) );
1141 #else
1142  ( void )res; // avoid unused warning in release builds
1143 #endif
1144 
1145  elemUri = elemUri.nextSiblingElement( QStringLiteral( "uri" ) );
1146  }
1147  }
1148 
1149  if ( mDataProvider && pkeyNode.toElement().hasAttribute( QStringLiteral( "time-unit" ) ) )
1150  mDataProvider->setTemporalUnit(
1151  static_cast<QgsUnitTypes::TemporalUnit>( pkeyNode.toElement().attribute( QStringLiteral( "time-unit" ) ).toInt() ) );
1152 
1153  // read dataset group store
1154  QDomElement elemDatasetGroupsStore = layer_node.firstChildElement( QStringLiteral( "mesh-dataset-groups-store" ) );
1155  if ( elemDatasetGroupsStore.isNull() )
1157  else
1158  mDatasetGroupStore->readXml( elemDatasetGroupsStore, context );
1159 
1160  QString errorMsg;
1161  readSymbology( layer_node, errorMsg, context );
1162 
1163  if ( !mTemporalProperties->timeExtent().begin().isValid() )
1165 
1166  // read static dataset
1167  QDomElement elemStaticDataset = layer_node.firstChildElement( QStringLiteral( "static-active-dataset" ) );
1168  if ( elemStaticDataset.hasAttribute( QStringLiteral( "scalar" ) ) )
1169  {
1170  mStaticScalarDatasetIndex = elemStaticDataset.attribute( QStringLiteral( "scalar" ) ).toInt();
1171  }
1172  if ( elemStaticDataset.hasAttribute( QStringLiteral( "vector" ) ) )
1173  {
1174  mStaticVectorDatasetIndex = elemStaticDataset.attribute( QStringLiteral( "vector" ) ).toInt();
1175  }
1176 
1177  return isValid(); // should be true if read successfully
1178 }
1179 
1180 bool QgsMeshLayer::writeXml( QDomNode &layer_node, QDomDocument &document, const QgsReadWriteContext &context ) const
1181 {
1182  // first get the layer element so that we can append the type attribute
1183  QDomElement mapLayerNode = layer_node.toElement();
1184 
1185  if ( mapLayerNode.isNull() || ( QLatin1String( "maplayer" ) != mapLayerNode.nodeName() ) )
1186  {
1187  QgsDebugMsgLevel( QStringLiteral( "can't find <maplayer>" ), 2 );
1188  return false;
1189  }
1190 
1191  mapLayerNode.setAttribute( QStringLiteral( "type" ), QStringLiteral( "mesh" ) );
1192 
1193  // add provider node
1194  if ( mDataProvider )
1195  {
1196  QDomElement provider = document.createElement( QStringLiteral( "provider" ) );
1197  QDomText providerText = document.createTextNode( providerType() );
1198  provider.appendChild( providerText );
1199  layer_node.appendChild( provider );
1200  provider.setAttribute( QStringLiteral( "time-unit" ), mDataProvider->temporalCapabilities()->temporalUnit() );
1201 
1202  const QStringList extraDatasetUris = mDataProvider->extraDatasets();
1203  QDomElement elemExtraDatasets = document.createElement( QStringLiteral( "extra-datasets" ) );
1204  for ( const QString &uri : extraDatasetUris )
1205  {
1206  QString path = context.pathResolver().writePath( uri );
1207  QDomElement elemUri = document.createElement( QStringLiteral( "uri" ) );
1208  elemUri.appendChild( document.createTextNode( path ) );
1209  elemExtraDatasets.appendChild( elemUri );
1210  }
1211  layer_node.appendChild( elemExtraDatasets );
1212  }
1213 
1214  QDomElement elemStaticDataset = document.createElement( QStringLiteral( "static-active-dataset" ) );
1215  elemStaticDataset.setAttribute( QStringLiteral( "scalar" ), mStaticScalarDatasetIndex );
1216  elemStaticDataset.setAttribute( QStringLiteral( "vector" ), mStaticVectorDatasetIndex );
1217  layer_node.appendChild( elemStaticDataset );
1218 
1219  // write dataset group store
1220  layer_node.appendChild( mDatasetGroupStore->writeXml( document, context ) );
1221 
1222  // renderer specific settings
1223  QString errorMsg;
1224  return writeSymbology( layer_node, document, errorMsg, context );
1225 }
1226 
1228 {
1229  if ( mDataProvider && mDataProvider->isValid() )
1230  {
1231  mDataProvider->reloadData();
1232 
1233  //reload the mesh structure
1234  if ( !mNativeMesh )
1235  mNativeMesh.reset( new QgsMesh );
1236 
1237  dataProvider()->populateMesh( mNativeMesh.get() );
1238 
1239  //clear the TriangularMeshes
1240  mTriangularMeshes.clear();
1241 
1242  //clear the rendererCache
1243  mRendererCache.reset( new QgsMeshLayerRendererCache() );
1244  }
1245 }
1246 
1247 QStringList QgsMeshLayer::subLayers() const
1248 {
1249  if ( mDataProvider )
1250  return mDataProvider->subLayers();
1251  else
1252  return QStringList();
1253 }
1254 
1256 {
1257  QgsLayerMetadataFormatter htmlFormatter( metadata() );
1258  QString myMetadata = QStringLiteral( "<html>\n<body>\n" );
1259 
1260  // Begin Provider section
1261  myMetadata += QStringLiteral( "<h1>" ) + tr( "Information from provider" ) + QStringLiteral( "</h1>\n<hr>\n" );
1262  myMetadata += QLatin1String( "<table class=\"list-view\">\n" );
1263 
1264  // name
1265  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Name" ) + QStringLiteral( "</td><td>" ) + name() + QStringLiteral( "</td></tr>\n" );
1266 
1267  // local path
1268  QVariantMap uriComponents = QgsProviderRegistry::instance()->decodeUri( mProviderKey, publicSource() );
1269  QString path;
1270  if ( uriComponents.contains( QStringLiteral( "path" ) ) )
1271  {
1272  path = uriComponents[QStringLiteral( "path" )].toString();
1273  if ( QFile::exists( path ) )
1274  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Path" ) + QStringLiteral( "</td><td>%1" ).arg( QStringLiteral( "<a href=\"%1\">%2</a>" ).arg( QUrl::fromLocalFile( path ).toString(), QDir::toNativeSeparators( path ) ) ) + QStringLiteral( "</td></tr>\n" );
1275  }
1276  if ( uriComponents.contains( QStringLiteral( "url" ) ) )
1277  {
1278  const QString url = uriComponents[QStringLiteral( "url" )].toString();
1279  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "URL" ) + QStringLiteral( "</td><td>%1" ).arg( QStringLiteral( "<a href=\"%1\">%2</a>" ).arg( QUrl( url ).toString(), url ) ) + QStringLiteral( "</td></tr>\n" );
1280  }
1281 
1282  // data source
1283  if ( publicSource() != path )
1284  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Source" ) + QStringLiteral( "</td><td>%1" ).arg( publicSource() ) + QStringLiteral( "</td></tr>\n" );
1285 
1286  // EPSG
1287  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "CRS" ) + QStringLiteral( "</td><td>" );
1288  if ( crs().isValid() )
1289  {
1290  myMetadata += crs().userFriendlyIdentifier( QgsCoordinateReferenceSystem::FullString ) + QStringLiteral( " - " );
1291  if ( crs().isGeographic() )
1292  myMetadata += tr( "Geographic" );
1293  else
1294  myMetadata += tr( "Projected" );
1295  }
1296  myMetadata += QLatin1String( "</td></tr>\n" );
1297 
1298  // Extent
1299  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Extent" ) + QStringLiteral( "</td><td>" ) + extent().toString() + QStringLiteral( "</td></tr>\n" );
1300 
1301  // unit
1302  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Unit" ) + QStringLiteral( "</td><td>" ) + QgsUnitTypes::toString( crs().mapUnits() ) + QStringLiteral( "</td></tr>\n" );
1303 
1304  // feature count
1305  QLocale locale = QLocale();
1306  locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
1307 
1308  if ( dataProvider() )
1309  {
1310  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
1311  + tr( "Vertex count" ) + QStringLiteral( "</td><td>" )
1312  + ( locale.toString( static_cast<qlonglong>( dataProvider()->vertexCount() ) ) )
1313  + QStringLiteral( "</td></tr>\n" );
1314  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
1315  + tr( "Face count" ) + QStringLiteral( "</td><td>" )
1316  + ( locale.toString( static_cast<qlonglong>( dataProvider()->faceCount() ) ) )
1317  + QStringLiteral( "</td></tr>\n" );
1318  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
1319  + tr( "Edge count" ) + QStringLiteral( "</td><td>" )
1320  + ( locale.toString( static_cast<qlonglong>( dataProvider()->edgeCount() ) ) )
1321  + QStringLiteral( "</td></tr>\n" );
1322  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
1323  + tr( "Dataset groups count" ) + QStringLiteral( "</td><td>" )
1324  + ( locale.toString( static_cast<qlonglong>( dataProvider()->datasetGroupCount() ) ) )
1325  + QStringLiteral( "</td></tr>\n" );
1326  }
1327 
1328  // End Provider section
1329  myMetadata += QLatin1String( "</table>\n<br><br>" );
1330 
1331  // identification section
1332  myMetadata += QStringLiteral( "<h1>" ) + tr( "Identification" ) + QStringLiteral( "</h1>\n<hr>\n" );
1333  myMetadata += htmlFormatter.identificationSectionHtml( );
1334  myMetadata += QLatin1String( "<br><br>\n" );
1335 
1336  // extent section
1337  myMetadata += QStringLiteral( "<h1>" ) + tr( "Extent" ) + QStringLiteral( "</h1>\n<hr>\n" );
1338  myMetadata += htmlFormatter.extentSectionHtml( isSpatial() );
1339  myMetadata += QLatin1String( "<br><br>\n" );
1340 
1341  // Start the Access section
1342  myMetadata += QStringLiteral( "<h1>" ) + tr( "Access" ) + QStringLiteral( "</h1>\n<hr>\n" );
1343  myMetadata += htmlFormatter.accessSectionHtml( );
1344  myMetadata += QLatin1String( "<br><br>\n" );
1345 
1346  // Start the contacts section
1347  myMetadata += QStringLiteral( "<h1>" ) + tr( "Contacts" ) + QStringLiteral( "</h1>\n<hr>\n" );
1348  myMetadata += htmlFormatter.contactsSectionHtml( );
1349  myMetadata += QLatin1String( "<br><br>\n" );
1350 
1351  // Start the links section
1352  myMetadata += QStringLiteral( "<h1>" ) + tr( "Links" ) + QStringLiteral( "</h1>\n<hr>\n" );
1353  myMetadata += htmlFormatter.linksSectionHtml( );
1354  myMetadata += QLatin1String( "<br><br>\n" );
1355 
1356  // Start the history section
1357  myMetadata += QStringLiteral( "<h1>" ) + tr( "History" ) + QStringLiteral( "</h1>\n<hr>\n" );
1358  myMetadata += htmlFormatter.historySectionHtml( );
1359  myMetadata += QLatin1String( "<br><br>\n" );
1360 
1361  myMetadata += QLatin1String( "\n</body>\n</html>\n" );
1362  return myMetadata;
1363 }
1364 
1365 bool QgsMeshLayer::setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags )
1366 {
1367  delete mDataProvider;
1368 
1369  mProviderKey = provider;
1370  QString dataSource = mDataSource;
1371 
1372  mDataProvider = qobject_cast<QgsMeshDataProvider *>( QgsProviderRegistry::instance()->createProvider( provider, dataSource, options, flags ) );
1373  if ( !mDataProvider )
1374  {
1375  QgsDebugMsgLevel( QStringLiteral( "Unable to get mesh data provider" ), 2 );
1376  return false;
1377  }
1378 
1379  mDataProvider->setParent( this );
1380  QgsDebugMsgLevel( QStringLiteral( "Instantiated the mesh data provider plugin" ), 2 );
1381 
1382  setValid( mDataProvider->isValid() );
1383  if ( !isValid() )
1384  {
1385  QgsDebugMsgLevel( QStringLiteral( "Invalid mesh provider plugin %1" ).arg( QString( mDataSource.toUtf8() ) ), 2 );
1386  return false;
1387  }
1388 
1389  setCrs( mDataProvider->crs() );
1390 
1391  if ( provider == QLatin1String( "mesh_memory" ) )
1392  {
1393  // required so that source differs between memory layers
1394  mDataSource = mDataSource + QStringLiteral( "&uid=%1" ).arg( QUuid::createUuid().toString() );
1395  }
1396 
1397  mDatasetGroupStore->setPersistentProvider( mDataProvider );
1398 
1399  for ( int i = 0; i < mDataProvider->datasetGroupCount(); ++i )
1400  assignDefaultStyleToDatasetGroup( i );
1401 
1402  connect( mDataProvider, &QgsMeshDataProvider::dataChanged, this, &QgsMeshLayer::dataChanged );
1403 
1404  return true;
1405 }
1406 
1408 {
1409  return mTemporalProperties;
1410 }
QgsMeshLayer::datasetGroupsIndexes
QList< int > datasetGroupsIndexes() const
Returns the list of indexes of dataset groups count handled by the layer.
Definition: qgsmeshlayer.cpp:337
QgsMeshDatasetGroupMetadata::minimum
double minimum() const
Returns minimum scalar value/vector magnitude present for whole dataset group.
Definition: qgsmeshdataset.cpp:176
QgsMeshDatasetIndex::dataset
int dataset() const
Returns a dataset index within group()
Definition: qgsmeshdataset.cpp:31
qgsmeshlayerutils.h
QgsMeshDatasetSourceInterface::datasetGroupCount
virtual int datasetGroupCount() const =0
Returns number of datasets groups loaded.
QgsMeshRendererVectorSettings
Represents a renderer settings for vector datasets.
Definition: qgsmeshrenderersettings.h:411
QgsMeshLayer::createMapRenderer
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
Definition: qgsmeshlayer.cpp:998
QgsMeshDataProviderTemporalCapabilities::temporalUnit
QgsUnitTypes::TemporalUnit temporalUnit() const
Returns the temporal unit used to read data by the data provider.
Definition: qgsmeshdataprovidertemporalcapabilities.cpp:154
QgsPointXY::distance
double distance(double x, double y) const SIP_HOLDGIL
Returns the distance between this point and a specified x, y coordinate.
Definition: qgspointxy.h:196
QgsMapLayer::crs
QgsCoordinateReferenceSystem crs
Definition: qgsmaplayer.h:89
qgsmesh3daveraging.h
QgsColorRamp
Abstract base class for color ramps.
Definition: qgscolorramp.h:32
QgsMapLayer::readCommonStyle
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types.
Definition: qgsmaplayer.cpp:1622
QgsColorRampShader::EqualInterval
@ EqualInterval
Uses equal interval.
Definition: qgscolorrampshader.h:56
QgsMeshLayer::dataset3dValue
QgsMesh3dDataBlock dataset3dValue(const QgsMeshDatasetIndex &index, const QgsPointXY &point) const
Returns the 3d values of stacked 3d mesh defined by the given point.
Definition: qgsmeshlayer.cpp:452
QgsMeshLayer::setTransformContext
void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext.
Definition: qgsmeshlayer.cpp:511
qgsmeshdatasetgroupstore.h
QgsPointXY::y
double y
Definition: qgspointxy.h:48
QgsInterval::seconds
double seconds() const
Returns the interval duration in seconds.
Definition: qgsinterval.h:168
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
Definition: qgscoordinatetransformcontext.h:58
QgsMeshRendererScalarSettings::setClassificationMinimumMaximum
void setClassificationMinimumMaximum(double minimum, double maximum)
Sets min/max values used for creation of the color ramp shader.
Definition: qgsmeshrenderersettings.cpp:95
QgsMapLayer::FlagTrustLayerMetadata
@ FlagTrustLayerMetadata
Trust layer metadata. Improves layer load time by skipping expensive checks like primary key unicity,...
Definition: qgsmaplayer.h:557
QgsMeshLayer::datasetIndexAtRelativeTime
QgsMeshDatasetIndex datasetIndexAtRelativeTime(const QgsInterval &relativeTime, int datasetGroupIndex) const
Returns dataset index from datasets group depending on the relative time from the layer reference tim...
Definition: qgsmeshlayer.cpp:528
QgsMeshDatasetGroupMetadata::DataOnVolumes
@ DataOnVolumes
Data is defined on volumes.
Definition: qgsmeshdataset.h:358
QgsMeshLayer::setReferenceTime
void setReferenceTime(const QDateTime &referenceTime)
Sets the reference time of the layer.
Definition: qgsmeshlayer.cpp:714
QgsTriangularMesh::vertices
const QVector< QgsMeshVertex > & vertices() const
Returns vertices in map coordinate system.
Definition: qgstriangularmesh.cpp:287
QgsMeshTimeSettings
Represents a mesh time settings for mesh datasets.
Definition: qgsmeshtimesettings.h:36
QgsMeshRendererSettings
Represents all mesh renderer settings.
Definition: qgsmeshrenderersettings.h:591
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:105
QgsPainting::BlendMode
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
Definition: qgspainting.h:37
QgsColorRampShader::setClassificationMode
void setClassificationMode(ClassificationMode classificationMode)
Sets classification mode.
Definition: qgscolorrampshader.h:184
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
Definition: qgsreadwritecontext.h:35
QgsMeshLayer::dataset1dValue
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...
Definition: qgsmeshlayer.cpp:474
QgsMeshLayer::saveDataset
bool saveDataset(const QString &path, int datasetGroupIndex, QString driver)
Saves datasets group on file with the specified driver.
Definition: qgsmeshlayer.cpp:233
QgsPoint::distance
double distance(double x, double y) const SIP_HOLDGIL
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
Definition: qgspoint.h:332
QgsMeshLayer::setMeshSimplificationSettings
void setMeshSimplificationSettings(const QgsMeshSimplificationSettings &meshSimplificationSettings)
Sets mesh simplification settings.
Definition: qgsmeshlayer.cpp:941
QgsMeshRendererSettings::setActiveVectorDatasetGroup
void setActiveVectorDatasetGroup(int activeVectorDatasetGroup)
Sets the active vector dataset group.
Definition: qgsmeshrenderersettings.cpp:524
QgsMeshLayer::firstValidTimeStep
QgsInterval firstValidTimeStep() const
Returns the first valid time step of the dataset groups, invalid QgInterval if no time step is presen...
Definition: qgsmeshlayer.cpp:817
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:38
QgsCoordinateReferenceSystem::userFriendlyIdentifier
QString userFriendlyIdentifier(IdentifierType type=MediumString) const
Returns a user friendly identifier for the CRS.
Definition: qgscoordinatereferencesystem.cpp:1338
QgsMeshRendererMeshSettings
Represents a mesh renderer settings for mesh object.
Definition: qgsmeshrenderersettings.h:42
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsMeshRendererSettings::setVectorSettings
void setVectorSettings(int groupIndex, const QgsMeshRendererVectorSettings &settings)
Sets new renderer settings.
Definition: qgsmeshrenderersettings.h:631
QgsMeshDatasetSourceInterface::addDataset
virtual bool addDataset(const QString &uri)=0
Associate dataset with the mesh.
QgsMapLayer::clone
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
QgsMapLayer::blendMode
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
Definition: qgsmaplayer.cpp:212
QgsMeshRendererSettings::setScalarSettings
void setScalarSettings(int groupIndex, const QgsMeshRendererScalarSettings &settings)
Sets new renderer settings.
Definition: qgsmeshrenderersettings.h:626
QgsLayerMetadataFormatter::historySectionHtml
QString historySectionHtml() const
Formats the "History" section according to a metadata object.
Definition: qgslayermetadataformatter.cpp:230
QgsMeshLayer::readXml
bool readXml(const QDomNode &layer_node, QgsReadWriteContext &context) override
Called by readLayerXML(), used by children to read state specific to them from project files.
Definition: qgsmeshlayer.cpp:1097
QgsMapLayer::mReadFlags
QgsMapLayer::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when restoring state from XML.
Definition: qgsmaplayer.h:1589
qgsreadwritecontext.h
QgsTriangularMesh::faceCentroids
const QVector< QgsMeshVertex > & faceCentroids() const
Returns centroids of the native faces in map CRS.
Definition: qgstriangularmesh.cpp:307
QgsLayerMetadataFormatter
Class for metadata formatter.
Definition: qgslayermetadataformatter.h:34
QgsMesh::Face
@ Face
Definition: qgsmeshdataprovider.h:68
QgsMapLayerLegend::defaultMeshLegend
static QgsMapLayerLegend * defaultMeshLegend(QgsMeshLayer *ml)
Create new legend implementation for mesh layer.
Definition: qgsmaplayerlegend.cpp:57
QgsMeshLayer::LayerOptions::transformContext
QgsCoordinateTransformContext transformContext
Definition: qgsmeshlayer.h:113
QgsPointXY::x
Q_GADGET double x
Definition: qgspointxy.h:47
QgsMeshLayer::setTimeSettings
void setTimeSettings(const QgsMeshTimeSettings &settings)
Sets time format settings.
Definition: qgsmeshlayer.cpp:313
QgsMeshLayer::datasetGroupTreeRootItem
QgsMeshDatasetGroupTreeItem * datasetGroupTreeRootItem() const
Returns the root items of the dataset group tree item.
Definition: qgsmeshlayer.cpp:668
QgsMeshLayer::reload
void reload() override
Synchronises with changes in the datasource.
Definition: qgsmeshlayer.cpp:1227
QgsMeshDataSourceInterface::populateMesh
virtual void populateMesh(QgsMesh *mesh) const =0
Populates the mesh vertices, edges and faces.
QgsDataProvider::FlagTrustDataSource
@ FlagTrustDataSource
Trust datasource config (primary key unicity, geometry type and srid, etc). Improves provider load ti...
Definition: qgsdataprovider.h:120
QgsMeshDatasetValue
QgsMeshDatasetValue represents single dataset value.
Definition: qgsmeshdataset.h:78
QgsMapLayerType
QgsMapLayerType
Types of layers that can be added to a map.
Definition: qgsmaplayer.h:68
QgsMeshLayer::rendererCache
QgsMeshLayerRendererCache * rendererCache()
Returns native mesh (nullptr before rendering)
Definition: qgsmeshlayer.cpp:282
QgsMeshLayer::meshSimplificationSettings
QgsMeshSimplificationSettings meshSimplificationSettings() const
Returns mesh simplification settings.
Definition: qgsmeshlayer.cpp:936
QgsMeshDatasetGroupTreeItem::isEnabled
bool isEnabled() const
Definition: qgsmeshdataset.cpp:624
QgsMeshLayer::writeXml
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.
Definition: qgsmeshlayer.cpp:1180
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:58
QgsMeshLayerTemporalProperties
Implementation of map layer temporal properties for mesh layers.
Definition: qgsmeshlayertemporalproperties.h:52
QgsRectangle::setMinimal
void setMinimal() SIP_HOLDGIL
Set a rectangle so that min corner is at max and max corner is at min.
Definition: qgsrectangle.h:151
QgsMeshDatasetGroupTreeItem
Tree item for display of the mesh dataset groups.
Definition: qgsmeshdataset.h:785
QgsLayerMetadataFormatter::contactsSectionHtml
QString contactsSectionHtml() const
Formats the "Contacts" section according to a metadata object.
Definition: qgslayermetadataformatter.cpp:51
QgsMapLayer::setBlendMode
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
Definition: qgsmaplayer.cpp:202
QgsTriangularMesh::triangles
const QVector< QgsMeshFace > & triangles() const
Returns triangles.
Definition: qgstriangularmesh.cpp:292
QgsMeshLayer::setStaticVectorDatasetIndex
void setStaticVectorDatasetIndex(const QgsMeshDatasetIndex &staticVectorDatasetIndex)
Sets the static vector dataset index that is rendered if the temporal properties is not active.
Definition: qgsmeshlayer.cpp:914
QgsMeshLayer::setTemporalMatchingMethod
void setTemporalMatchingMethod(const QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod &matchingMethod)
Sets the method used to match the temporal dataset from a requested time, see activeVectorDatasetAtTi...
Definition: qgsmeshlayer.cpp:722
QgsMapLayer::isValid
bool isValid
Definition: qgsmaplayer.h:91
QgsMeshLayerTemporalProperties::setMatchingMethod
void setMatchingMethod(const QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod &matchingMethod)
Sets the method used to match dataset from temporal capabilities.
Definition: qgsmeshlayertemporalproperties.cpp:111
QgsMesh
Mesh - vertices, edges and faces.
Definition: qgsmeshdataprovider.h:58
QgsMeshLayer::subLayers
QStringList subLayers() const override
Returns the sublayers of this layer.
Definition: qgsmeshlayer.cpp:1247
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsUnitTypes::TemporalUnit
TemporalUnit
Temporal units.
Definition: qgsunittypes.h:150
QgsDataProvider::dataChanged
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
QgsMeshLayer::isFaceActive
bool isFaceActive(const QgsMeshDatasetIndex &index, int faceIndex) const
Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes.
Definition: qgsmeshlayer.cpp:377
QgsMeshLayer::datasetValue
QgsMeshDatasetValue datasetValue(const QgsMeshDatasetIndex &index, int valueIndex) const
Returns vector/scalar value associated with the index from the dataset To read multiple continuous va...
Definition: qgsmeshlayer.cpp:357
QgsTriangularMesh::edgeIndexesForRectangle
QList< int > edgeIndexesForRectangle(const QgsRectangle &rectangle) const
Finds indexes of edges intersecting given bounding box It uses spatial indexing.
Definition: qgstriangularmesh.cpp:358
QgsMeshLayerTemporalProperties::setReferenceTime
void setReferenceTime(const QDateTime &referenceTime, const QgsDataProviderTemporalCapabilities *capabilities)
Sets the reference time and update the time extent from the temporal capabilities,...
Definition: qgsmeshlayertemporalproperties.cpp:94
QgsColorRampShader
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Definition: qgscolorrampshader.h:40
QgsMeshSimplificationSettings::readXml
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads configuration from the given DOM element.
Definition: qgsmeshsimplificationsettings.cpp:50
QgsMapLayer::setCrs
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
Definition: qgsmaplayer.cpp:771
QgsMeshLayer::triangularMesh
QgsTriangularMesh * triangularMesh(double minimumTriangleSize=0) const
Returns triangular mesh (nullptr before rendering or calling to updateMesh).
Definition: qgsmeshlayer.cpp:248
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:42
QgsMeshDatasetMetadata
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such as whether the data is valid or ...
Definition: qgsmeshdataset.h:476
QgsMeshRendererScalarSettings::setEdgeStrokeWidth
void setEdgeStrokeWidth(const QgsInterpolatedLineWidth &strokeWidth)
Sets the stroke width used to render edges scalar dataset.
Definition: qgsmeshrenderersettings.cpp:176
QgsMesh3dDataBlock
QgsMesh3dDataBlock is a block of 3d stacked mesh data related N faces defined on base mesh frame.
Definition: qgsmeshdataset.h:245
QgsMapLayer::mShouldValidateCrs
bool mShouldValidateCrs
true if the layer's CRS should be validated and invalid CRSes are not permitted.
Definition: qgsmaplayer.h:1596
QgsMeshLayer::clone
QgsMeshLayer * clone() const override
Returns a new instance equivalent to this one except for the id which is still unique.
Definition: qgsmeshlayer.cpp:166
QgsMeshLayerTemporalProperties::timeExtent
QgsDateTimeRange timeExtent() const
Returns the time extent.
Definition: qgsmeshlayertemporalproperties.cpp:84
QgsMapLayer::mProviderKey
QString mProviderKey
Data provider key (name of the data provider)
Definition: qgsmaplayer.h:1584
QgsMeshLayer::LayerOptions
Setting options for loading mesh layers.
Definition: qgsmeshlayer.h:103
QgsDataProvider::transformContext
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
Definition: qgsdataprovider.cpp:76
QgsMapLayerRenderer
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Definition: qgsmaplayerrenderer.h:51
QgsMeshLayer::datasetMetadata
QgsMeshDatasetMetadata datasetMetadata(const QgsMeshDatasetIndex &index) const
Returns the dataset metadata.
Definition: qgsmeshlayer.cpp:352
QgsMeshLayer::extraDatasetGroupCount
int extraDatasetGroupCount() const
Returns the extra dataset groups count handle by the layer.
Definition: qgsmeshlayer.cpp:332
QgsLayerMetadataFormatter::linksSectionHtml
QString linksSectionHtml() const
Formats the "Links" section according to a metadata object.
Definition: qgslayermetadataformatter.cpp:256
QgsStyle::defaultStyle
static QgsStyle * defaultStyle()
Returns default application-wide style.
Definition: qgsstyle.cpp:127
QgsPainting::getBlendModeEnum
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
Definition: qgspainting.cpp:80
QgsMeshLayer::updateTriangularMesh
void updateTriangularMesh(const QgsCoordinateTransform &transform=QgsCoordinateTransform())
Gets native mesh and updates (creates if it doesn't exist) the base triangular mesh.
Definition: qgsmeshlayer.cpp:262
QgsMeshLayer::rendererSettings
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
Definition: qgsmeshlayer.cpp:287
QgsMeshLayer::encodedSource
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...
Definition: qgsmeshlayer.cpp:1087
QgsMeshDatasetGroupStore
Class used to register and access all the dataset groups related to a mesh layer.
Definition: qgsmeshdatasetgroupstore.h:120
QgsMapLayer::triggerRepaint
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
Definition: qgsmaplayer.cpp:1826
QgsMapLayer::dataSourceChanged
void dataSourceChanged()
Emitted whenever the layer's data source has been changed.
QgsMeshRendererScalarSettings::NeighbourAverage
@ NeighbourAverage
Does a simple average of values defined for all surrounding faces/vertices.
Definition: qgsmeshrenderersettings.h:116
qgstriangularmesh.h
QgsInterpolatedLineWidth::setMinimumValue
void setMinimumValue(double minimumValue)
Sets the minimum value used to defined the variable width.
Definition: qgsinterpolatedlinerenderer.cpp:232
QgsRenderContext::coordinateTransform
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
Definition: qgsrendercontext.h:245
QgsMapLayer::FlagDontResolveLayers
@ FlagDontResolveLayers
Don't resolve layer paths or create data providers for layers.
Definition: qgsmaplayer.h:556
QgsPoint::y
double y
Definition: qgspoint.h:42
qgsmeshtimesettings.h
QgsMeshLayer::staticVectorDatasetIndex
QgsMeshDatasetIndex staticVectorDatasetIndex() const
Returns the static vector dataset index that is rendered if the temporal properties is not active.
Definition: qgsmeshlayer.cpp:709
QgsMapLayer::flags
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
Definition: qgsmaplayer.cpp:134
QgsPathResolver::writePath
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
Definition: qgspathresolver.cpp:192
QgsMeshDatasetGroupMetadata::DataOnFaces
@ DataOnFaces
Data is defined on faces.
Definition: qgsmeshdataset.h:356
QgsMeshDatasetGroupMetadata::DataOnVertices
@ DataOnVertices
Data is defined on vertices.
Definition: qgsmeshdataset.h:357
QgsMeshLayer::dataProvider
QgsMeshDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
Definition: qgsmeshlayer.cpp:156
QgsColorRampShader::ColorRampItem::color
QColor color
Definition: qgscolorrampshader.h:98
QgsMeshLayer::datasetIndexAtTime
QgsMeshDatasetIndex datasetIndexAtTime(const QgsDateTimeRange &timeRange, int datasetGroupIndex) const
Returns dataset index from datasets group depending on the time range.
Definition: qgsmeshlayer.cpp:517
QgsColorRampShader::setColorRampType
void setColorRampType(QgsColorRampShader::Type colorRampType)
Sets the color ramp type.
Definition: qgscolorrampshader.cpp:100
QgsDataProvider::reloadData
virtual void reloadData()
Reloads the data from the source by calling reloadProviderData() implemented by providers with data c...
Definition: qgsdataprovider.cpp:40
QgsMeshRendererSettings::activeScalarDatasetGroup
int activeScalarDatasetGroup() const
Returns the active scalar dataset group.
Definition: qgsmeshrenderersettings.cpp:509
QgsMeshDatasetIndex::group
int group() const
Returns a group index.
Definition: qgsmeshdataset.cpp:26
QgsColorRampShader::sourceColorRamp
QgsColorRamp * sourceColorRamp() const
Returns the source color ramp.
Definition: qgscolorrampshader.cpp:126
QgsMeshLayer::htmlMetadata
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
Definition: qgsmeshlayer.cpp:1255
qgsproviderregistry.h
QgsColorRampShader::ColorRampItem
Definition: qgscolorrampshader.h:86
QgsTemporalProperty::isActive
bool isActive() const
Returns true if the temporal property is active.
Definition: qgstemporalproperty.cpp:36
QgsMesh::ElementType
ElementType
Defines type of mesh elements.
Definition: qgsmeshdataprovider.h:65
QgsMeshRendererSettings::scalarSettings
QgsMeshRendererScalarSettings scalarSettings(int groupIndex) const
Returns renderer settings.
Definition: qgsmeshrenderersettings.h:624
QgsMeshSimplificationSettings::isEnabled
bool isEnabled() const
Returns if the overview is active.
Definition: qgsmeshsimplificationsettings.cpp:20
QgsColorRampShader::Exact
@ Exact
Assigns the color of the exact matching value in the color ramp item list.
Definition: qgscolorrampshader.h:49
QgsInterpolatedLineWidth
Represents a width than can vary depending on values.
Definition: qgsinterpolatedlinerenderer.h:111
QgsMeshLayer::dataset3dValues
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.
Definition: qgsmeshlayer.cpp:367
QgsMeshDatasetGroupTreeItem::childCount
int childCount() const
Returns the count of children.
Definition: qgsmeshdataset.cpp:577
qgscolorramp.h
QgsMeshRendererScalarSettings::colorRampShader
QgsColorRampShader colorRampShader() const
Returns color ramp shader function.
Definition: qgsmeshrenderersettings.cpp:81
QgsMeshLayer::formatTime
QString formatTime(double hours)
Returns (date) time in hours formatted to human readable form.
Definition: qgsmeshlayer.cpp:319
QgsMeshLayer::datasetRelativeTime
QgsInterval datasetRelativeTime(const QgsMeshDatasetIndex &index)
Returns the relative time of the dataset from the reference time of its group.
Definition: qgsmeshlayer.cpp:832
QgsMeshDatasetGroupTreeItem::childFromDatasetGroupIndex
QgsMeshDatasetGroupTreeItem * childFromDatasetGroupIndex(int index)
Returns the child with dataset group index Searches as depper as needed on the child hierarchy.
Definition: qgsmeshdataset.cpp:555
QgsUnitTypes::toString
static Q_INVOKABLE QString toString(QgsUnitTypes::DistanceUnit unit)
Returns a translated string representing a distance unit.
Definition: qgsunittypes.cpp:199
QgsMeshDatasetIndex
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
Definition: qgsmeshdataset.h:47
QgsMapLayer::writeCommonStyle
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write style data common to all layer types.
Definition: qgsmaplayer.cpp:540
QgsMeshLayer::timeSettings
QgsMeshTimeSettings timeSettings() const
Returns time format settings.
Definition: qgsmeshlayer.cpp:308
QgsMeshRendererSettings::activeVectorDatasetGroup
int activeVectorDatasetGroup() const
Returns the active vector dataset group.
Definition: qgsmeshrenderersettings.cpp:519
QgsTriangularMesh::contains
bool contains(const QgsMesh::ElementType &type) const
Returns whether the mesh contains at mesh elements of given type.
Definition: qgstriangularmesh.cpp:272
QgsMeshLayer
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:95
QgsMeshLayer::setDatasetGroupTreeRootItem
void setDatasetGroupTreeRootItem(QgsMeshDatasetGroupTreeItem *rootItem)
Sets the root items of the dataset group tree item.
Definition: qgsmeshlayer.cpp:673
QgsTriangularMesh::edges
const QVector< QgsMeshEdge > & edges() const
Returns edges.
Definition: qgstriangularmesh.cpp:297
QgsMeshLayer::writeSymbology
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const override
Definition: qgsmeshlayer.cpp:1042
QgsPainting::getCompositionMode
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Definition: qgspainting.cpp:20
QgsMeshDatasetIndex::isValid
bool isValid() const
Returns whether index is valid, ie at least groups is set.
Definition: qgsmeshdataset.cpp:36
QgsRasterShaderFunction::setMaximumValue
virtual void setMaximumValue(double value)
Sets the maximum value for the raster shader.
Definition: qgsrastershaderfunction.cpp:30
QgsMeshLayer::readSymbology
bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) override
Definition: qgsmeshlayer.cpp:1013
QgsMeshLayer::LayerOptions::skipCrsValidation
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
Definition: qgsmeshlayer.h:128
QgsInterpolatedLineColor
Class defining color to render mesh datasets.
Definition: qgsinterpolatedlinerenderer.h:35
QgsMeshDataProvider::temporalCapabilities
QgsMeshDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
Definition: qgsmeshdataprovider.cpp:29
QgsMeshDatasetValue::x
double x() const
Returns x value.
Definition: qgsmeshdataset.cpp:93
QgsMeshDataProvider::setTemporalUnit
void setTemporalUnit(QgsUnitTypes::TemporalUnit unit)
Sets the temporal unit of the provider and reload data if it changes.
Definition: qgsmeshdataprovider.cpp:39
QgsMeshLayer::datasetCount
int datasetCount(const QgsMeshDatasetIndex &index) const
Returns the dataset count in the dataset groups.
Definition: qgsmeshlayer.cpp:347
QgsMesh::Edge
@ Edge
Definition: qgsmeshdataprovider.h:67
QgsMeshDataProviderTemporalCapabilities::firstTimeStepDuration
qint64 firstTimeStepDuration(int group) const
Returns the duration of the first time step of the dataset group with index group.
Definition: qgsmeshdataprovidertemporalcapabilities.cpp:178
qgspainting.h
QgsMeshDataProvider
Base class for providing data for QgsMeshLayer.
Definition: qgsmeshdataprovider.h:398
QgsMeshLayerTemporalProperties::referenceTime
QDateTime referenceTime() const
Returns the reference time.
Definition: qgsmeshlayertemporalproperties.cpp:89
QgsPoint::x
Q_GADGET double x
Definition: qgspoint.h:41
QgsProviderRegistry::decodeUri
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g.
Definition: qgsproviderregistry.cpp:433
QgsMeshRendererScalarSettings::None
@ None
Does not use resampling.
Definition: qgsmeshrenderersettings.h:111
QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod
MatchingTemporalDatasetMethod
Method for selection of temporal mesh dataset from a range time.
Definition: qgsmeshdataprovidertemporalcapabilities.h:42
QgsMapLayerTemporalProperties
Base class for storage of map layer temporal properties.
Definition: qgsmaplayertemporalproperties.h:43
QgsMeshLayerTemporalProperties::setDefaultsFromDataProviderTemporalCapabilities
void setDefaultsFromDataProviderTemporalCapabilities(const QgsDataProviderTemporalCapabilities *capabilities) override
Sets the layers temporal settings to appropriate defaults based on a provider's temporal capabilities...
Definition: qgsmeshlayertemporalproperties.cpp:67
QgsMapLayer::mDataSource
QString mDataSource
Data source description string, varies by layer type.
Definition: qgsmaplayer.h:1538
QgsColorRampShader::setColorRampItemList
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &list)
Sets a custom colormap.
Definition: qgscolorrampshader.cpp:92
QgsMeshRendererSettings::setNativeMeshSettings
void setNativeMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new native mesh renderer settings, triggers repaint.
Definition: qgsmeshrenderersettings.h:604
QgsMeshLayer::activeVectorDatasetAtTime
QgsMeshDatasetIndex activeVectorDatasetAtTime(const QgsDateTimeRange &timeRange) const
Returns dataset index from active vector group depending on the time range If the temporal properties...
Definition: qgsmeshlayer.cpp:638
QgsMeshLayer::datasetRelativeTimeInMilliseconds
qint64 datasetRelativeTimeInMilliseconds(const QgsMeshDatasetIndex &index)
Returns the relative time (in milliseconds) of the dataset from the reference time of its group.
Definition: qgsmeshlayer.cpp:842
QgsCoordinateReferenceSystem::FullString
@ FullString
Full definition – possibly a very lengthy string, e.g. with no truncation of custom WKT definitions.
Definition: qgscoordinatereferencesystem.h:633
QgsTriangularMesh::faceIndexForPoint_v2
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.
Definition: qgstriangularmesh.cpp:340
QgsMeshDatasetGroupMetadata::DataOnEdges
@ DataOnEdges
Data is defined on edges.
Definition: qgsmeshdataset.h:359
QgsMeshFace
QVector< int > QgsMeshFace
List of vertex indexes.
Definition: qgsmeshdataprovider.h:41
QgsTemporalProperty::setIsActive
void setIsActive(bool active)
Sets whether the temporal property is active.
Definition: qgstemporalproperty.cpp:27
QgsMeshRendererSettings::writeXml
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element.
Definition: qgsmeshrenderersettings.cpp:409
QgsMapLayer::rendererChanged
void rendererChanged()
Signal emitted when renderer is changed.
QgsMeshLayer::writeStyle
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.
Definition: qgsmeshlayer.cpp:1067
QgsMeshRendererScalarSettings::setColorRampShader
void setColorRampShader(const QgsColorRampShader &shader)
Sets color ramp shader function.
Definition: qgsmeshrenderersettings.cpp:86
QgsMeshLayer::readStyle
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.
Definition: qgsmeshlayer.cpp:1072
QgsMesh3dAveragingMethod
Abstract class to interpolate 3d stacked mesh data to 2d data.
Definition: qgsmesh3daveraging.h:40
QgsMeshDatasetGroup
Abstract class that represents a dataset group.
Definition: qgsmeshdataset.h:576
QgsMeshSimplificationSettings
Represents a overview renderer settings.
Definition: qgsmeshsimplificationsettings.h:40
qgsstyle.h
QgsMeshLayer::activeScalarDatasetGroupChanged
void activeScalarDatasetGroupChanged(int index)
Emitted when active scalar group dataset is changed.
QgsRectangle::toString
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
Definition: qgsrectangle.cpp:127
qgsmeshlayer.h
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:44
QgsMeshDatasetGroupMetadata::dataType
DataType dataType() const
Returns whether dataset group data is defined on vertices or faces or volumes.
Definition: qgsmeshdataset.cpp:171
QgsMeshLayer::decodedSource
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...
Definition: qgsmeshlayer.cpp:1077
QgsMapLayer::dataChanged
void dataChanged()
Data of layer changed.
QgsDataProvider::setTransformContext
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)
Sets data coordinate transform context to transformContext.
Definition: qgsdataprovider.cpp:82
QgsMapLayer::publicSource
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example,...
Definition: qgsmaplayer.cpp:184
QgsPathResolver::readPath
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
Definition: qgspathresolver.cpp:35
QgsMeshRendererScalarSettings
Represents a mesh renderer settings for scalar datasets.
Definition: qgsmeshrenderersettings.h:95
QgsMapLayer::source
QString source() const
Returns the source for the layer.
Definition: qgsmaplayer.cpp:192
QgsMeshRendererVectorSettings::setColorRampShader
void setColorRampShader(const QgsColorRampShader &colorRampShader)
Returns the color ramp shader used to render vector datasets.
Definition: qgsmeshrenderersettings.cpp:666
QgsTriangularMesh::faceIndexesForRectangle
QList< int > faceIndexesForRectangle(const QgsRectangle &rectangle) const
Finds indexes of triangles intersecting given bounding box It uses spatial indexing.
Definition: qgstriangularmesh.cpp:353
QgsMeshDatasetGroupMetadata::extraOptions
QMap< QString, QString > extraOptions() const
Returns extra metadata options, for example description.
Definition: qgsmeshdataset.cpp:146
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:758
QgsMeshDatasetGroupMetadata
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata such as whether the data is vec...
Definition: qgsmeshdataset.h:350
QgsInterpolatedLineWidth::setMaximumValue
void setMaximumValue(double maximumValue)
Sets the maximum value used to defined the variable width.
Definition: qgsinterpolatedlinerenderer.cpp:243
QgsUnitTypes::TemporalMilliseconds
@ TemporalMilliseconds
Milliseconds.
Definition: qgsunittypes.h:151
qgsmeshlayerrenderer.h
QgsMeshLayer::addDatasets
bool addDatasets(const QString &path, const QDateTime &defaultReferenceTime=QDateTime())
Adds datasets to the mesh from file with path.
Definition: qgsmeshlayer.cpp:195
QgsMeshRendererScalarSettings::setDataResamplingMethod
void setDataResamplingMethod(const DataResamplingMethod &dataResamplingMethod)
Sets data interpolation method.
Definition: qgsmeshrenderersettings.cpp:110
QgsMapLayer::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
Definition: qgsmaplayer.cpp:785
QgsMeshEdge
QPair< int, int > QgsMeshEdge
Edge is a straight line seqment between 2 points.
Definition: qgsmeshdataprovider.h:48
QgsMeshDatasetGroupMetadata::maximum
double maximum() const
Returns maximum scalar value/vector magnitude present for whole dataset group.
Definition: qgsmeshdataset.cpp:181
QgsMeshDatasetSourceInterface::extraDatasets
virtual QStringList extraDatasets() const =0
Returns list of additional dataset file URIs added using addDataset() calls.
QgsMeshDatasetGroupMetadata::DataType
DataType
Location of where data is specified for datasets in the dataset group.
Definition: qgsmeshdataset.h:355
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
QgsTriangularMesh::trianglesToNativeFaces
const QVector< int > & trianglesToNativeFaces() const
Returns mapping between triangles and original faces.
Definition: qgstriangularmesh.cpp:317
QgsDataProvider::extent
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
QgsInterval
A representation of the interval between two datetime values.
Definition: qgsinterval.h:41
QgsMeshDatasetValue::y
double y() const
Returns y value.
Definition: qgsmeshdataset.cpp:98
QgsMeshLayer::QgsMeshLayer
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.
Definition: qgsmeshlayer.cpp:41
QgsMeshLayer::timeSettingsChanged
void timeSettingsChanged()
Emitted when time format is changed.
QgsMeshLayerRenderer
Implementation of threaded rendering for mesh layers.
Definition: qgsmeshlayerrenderer.h:93
QgsColorRamp::color
virtual QColor color(double value) const =0
Returns the color corresponding to a specified value.
QgsMeshRendererMeshSettings::setEnabled
void setEnabled(bool enabled)
Sets whether mesh structure rendering is enabled.
Definition: qgsmeshrenderersettings.cpp:27
QgsMeshLayer::staticScalarDatasetIndex
QgsMeshDatasetIndex staticScalarDatasetIndex() const
Returns the static scalar dataset index that is rendered if the temporal properties is not active.
Definition: qgsmeshlayer.cpp:909
qgslayermetadataformatter.h
QgsMapLayer::name
QString name
Definition: qgsmaplayer.h:86
QgsMeshLayer::resetDatasetGroupTreeItem
void resetDatasetGroupTreeItem()
Reset the dataset group tree item to default from provider.
Definition: qgsmeshlayer.cpp:811
QgsMapLayerTemporalProperties::setDefaultsFromDataProviderTemporalCapabilities
virtual void setDefaultsFromDataProviderTemporalCapabilities(const QgsDataProviderTemporalCapabilities *capabilities)=0
Sets the layers temporal settings to appropriate defaults based on a provider's temporal capabilities...
QgsMeshRendererSettings::averagingMethod
QgsMesh3dAveragingMethod * averagingMethod() const
Returns averaging method for conversion of 3d stacked mesh data to 2d data.
Definition: qgsmeshrenderersettings.cpp:396
qgsmaplayerlegend.h
QgsMeshDatasetGroupStore::datasetGroupsAdded
void datasetGroupsAdded(QList< int > indexes)
Emitted after dataset groups are added.
QgsGradientColorRamp::create
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsColorRamp from a map of properties.
Definition: qgscolorramp.cpp:53
QgsMeshDataBlock
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
Definition: qgsmeshdataset.h:136
QgsMeshLayer::datasetGroupMetadata
QgsMeshDatasetGroupMetadata datasetGroupMetadata(const QgsMeshDatasetIndex &index) const
Returns the dataset groups metadata.
Definition: qgsmeshlayer.cpp:342
QgsMeshDatasetGroupTreeItem::datasetGroupIndex
int datasetGroupIndex() const
Definition: qgsmeshdataset.cpp:619
QgsMeshLayer::nativeMesh
QgsMesh * nativeMesh()
Returns native mesh (nullptr before rendering or calling to updateMesh)
Definition: qgsmeshlayer.cpp:238
QgsTriangularMesh
Triangular/Derived Mesh is mesh with vertices in map coordinates.
Definition: qgstriangularmesh.h:50
QgsColorRampShader::ColorRampItem::label
QString label
Definition: qgscolorrampshader.h:96
QgsDataProviderTemporalCapabilities::hasTemporalCapabilities
bool hasTemporalCapabilities() const
Returns true if the provider has temporal capabilities available.
Definition: qgsdataprovidertemporalcapabilities.h:74
QgsMeshLayer::extent
QgsRectangle extent() const override
Returns the extent of the layer.
Definition: qgsmeshlayer.cpp:178
QgsMapLayer::isSpatial
virtual bool isSpatial() const
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated w...
Definition: qgsmaplayer.cpp:1745
QgsMeshSimplificationSettings::writeXml
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a new DOM element.
Definition: qgsmeshsimplificationsettings.cpp:40
QgsInterpolatedLineRenderer
Represents a line with width and color varying depending on values.
Definition: qgsinterpolatedlinerenderer.h:185
QgsMeshLayer::datasetValues
QgsMeshDataBlock datasetValues(const QgsMeshDatasetIndex &index, int valueIndex, int count) const
Returns N vector/scalar values from the index from the dataset.
Definition: qgsmeshlayer.cpp:362
QgsMeshLayer::temporalProperties
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
Definition: qgsmeshlayer.cpp:1407
qgslogger.h
QgsMeshLayer::setStaticScalarDatasetIndex
void setStaticScalarDatasetIndex(const QgsMeshDatasetIndex &staticScalarDatasetIndex)
Sets the static scalar dataset index that is rendered if the temporal properties is not active.
Definition: qgsmeshlayer.cpp:925
QgsMeshDatasetGroupMetadata::isVector
bool isVector() const
Returns whether dataset group has vector data.
Definition: qgsmeshdataset.cpp:151
QgsLayerMetadataFormatter::extentSectionHtml
QString extentSectionHtml(const bool showSpatialExtent=true) const
Formats the "Extents" section according to a metadata object (extent and temporal).
Definition: qgslayermetadataformatter.cpp:111
QgsMeshLayerTemporalProperties::matchingMethod
QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod matchingMethod() const
Returns the method used to match dataset from temporal capabilities.
Definition: qgsmeshlayertemporalproperties.cpp:106
QgsMapLayer::setValid
void setValid(bool valid)
Sets whether layer is valid or not.
Definition: qgsmaplayer.cpp:1775
QgsMeshDataBlock::value
QgsMeshDatasetValue value(int index) const
Returns a value represented by the index For active flag the behavior is undefined.
Definition: qgsmeshdataset.cpp:266
QgsMeshLayer::providerType
QString providerType() const
Returns the provider type for this layer.
Definition: qgsmeshlayer.cpp:190
QgsMeshLayer::~QgsMeshLayer
~QgsMeshLayer() override
Definition: qgsmeshlayer.cpp:151
QgsMeshLayer::activeVectorDatasetGroupChanged
void activeVectorDatasetGroupChanged(int index)
Emitted when active vector group dataset is changed.
QgsMeshLayer::setRendererSettings
void setRendererSettings(const QgsMeshRendererSettings &settings)
Sets new renderer settings.
Definition: qgsmeshlayer.cpp:292
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:53
QgsMeshDatasetGroupTreeItem::child
QgsMeshDatasetGroupTreeItem * child(int row) const
Returns a child.
Definition: qgsmeshdataset.cpp:547
QgsMeshLayer::datasetGroupCount
int datasetGroupCount() const
Returns the dataset groups count handle by the layer.
Definition: qgsmeshlayer.cpp:327
QgsMesh3dAveragingMethod::calculate
QgsMeshDataBlock calculate(const QgsMesh3dDataBlock &block3d, QgsFeedback *feedback=nullptr) const
Calculated 2d block values from 3d stacked mesh values.
Definition: qgsmesh3daveraging.cpp:57
QgsPointXY::sqrDistToSegment
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.
Definition: qgspointxy.cpp:95
QgsProviderRegistry::instance
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Definition: qgsproviderregistry.cpp:48
QgsMeshSimplificationSettings::reductionFactor
double reductionFactor() const
Returns the reduction factor used to build simplified mesh.
Definition: qgsmeshsimplificationsettings.cpp:30
QgsLayerMetadataFormatter::accessSectionHtml
QString accessSectionHtml() const
Formats the "Access" section according to a metadata object.
Definition: qgslayermetadataformatter.cpp:27
QgsMapLayer::setProviderType
void setProviderType(const QString &providerType)
Sets the providerType (provider key)
Definition: qgsmaplayer.cpp:1899
QgsMeshRendererSettings::setActiveScalarDatasetGroup
void setActiveScalarDatasetGroup(int activeScalarDatasetGroup)
Sets the active scalar dataset group.
Definition: qgsmeshrenderersettings.cpp:514
QgsMeshLayer::areFacesActive
QgsMeshDataBlock areFacesActive(const QgsMeshDatasetIndex &index, int faceIndex, int count) const
Returns whether the faces are active for particular dataset.
Definition: qgsmeshlayer.cpp:372
qgsmeshdataprovider.h
QgsMeshRendererSettings::readXml
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
Definition: qgsmeshrenderersettings.cpp:458
QgsMapLayer::setLegend
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
Definition: qgsmaplayer.cpp:1784
QgsMeshLayer::activeScalarDatasetAtTime
QgsMeshDatasetIndex activeScalarDatasetAtTime(const QgsDateTimeRange &timeRange) const
Returns dataset index from active scalar group depending on the time range.
Definition: qgsmeshlayer.cpp:630
QgsStyle::colorRamp
QgsColorRamp * colorRamp(const QString &name) const
Returns a new copy of the specified color ramp.
Definition: qgsstyle.cpp:438
QgsColorRampShader::ColorRampItem::value
double value
Definition: qgscolorrampshader.h:97
QgsMapLayer::metadata
QgsLayerMetadata metadata
Definition: qgsmaplayer.h:88
QgsMeshLayer::snapOnElement
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 ...
Definition: qgsmeshlayer.cpp:895
qgsmeshlayertemporalproperties.h
QgsDataProvider::isValid
virtual bool isValid() const =0
Returns true if this is a valid layer.
QgsLayerMetadataFormatter::identificationSectionHtml
QString identificationSectionHtml() const
Formats the "Identification" section according to a metadata object.
Definition: qgslayermetadataformatter.cpp:181
QgsDataProvider::subLayers
virtual QStringList subLayers() const
Sub-layers handled by this provider, in order from bottom to top.
Definition: qgsdataprovider.h:283
QgsMeshDataProviderTemporalCapabilities::referenceTime
QDateTime referenceTime() const
Returns the reference time.
Definition: qgsmeshdataprovidertemporalcapabilities.cpp:104
QgsReadWriteContext::pathResolver
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
Definition: qgsreadwritecontext.cpp:47
QgsRasterShaderFunction::setMinimumValue
virtual void setMinimumValue(double value)
Sets the minimum value for the raster shader.
Definition: qgsrastershaderfunction.cpp:38
QgsMeshDataBlock::isValid
bool isValid() const
Whether the block is valid.
Definition: qgsmeshdataset.cpp:261
QgsDataProvider::crs
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
INVALID_MESHLAYER_TIME
#define INVALID_MESHLAYER_TIME
Definition: qgsmeshdataprovidertemporalcapabilities.h:25
QgsMesh::Vertex
@ Vertex
Definition: qgsmeshdataprovider.h:66