QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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"
27 #include "qgsmeshlayer.h"
28 #include "qgsmeshlayerrenderer.h"
30 #include "qgsmeshlayerutils.h"
31 #include "qgsmeshtimesettings.h"
32 #include "qgspainting.h"
33 #include "qgsproviderregistry.h"
34 #include "qgsreadwritecontext.h"
35 #include "qgsstyle.h"
36 #include "qgstriangularmesh.h"
37 #include "qgsmesh3daveraging.h"
38 
39 QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
40  const QString &baseName,
41  const QString &providerKey,
42  const QgsMeshLayer::LayerOptions &options )
43  : QgsMapLayer( QgsMapLayerType::MeshLayer, baseName, meshLayerPath ),
44  mTemporalProperties( new QgsMeshLayerTemporalProperties( this ) ),
45  mDatasetGroupTreeRootItem( new QgsMeshDatasetGroupTreeItem )
46 {
48 
49  setProviderType( providerKey );
50  // if we’re given a provider type, try to create and bind one to this layer
51  bool ok = false;
52  if ( !meshLayerPath.isEmpty() && !providerKey.isEmpty() )
53  {
54  QgsDataProvider::ProviderOptions providerOptions { options.transformContext };
55  ok = setDataProvider( providerKey, providerOptions );
56  }
57 
58  if ( ok )
59  {
61  setDefaultRendererSettings();
62 
63  if ( mDataProvider )
64  {
65  mTemporalProperties->setDefaultsFromDataProviderTemporalCapabilities( mDataProvider->temporalCapabilities() );
67  }
68  }
69 }
70 
71 
72 void QgsMeshLayer::setDefaultRendererSettings()
73 {
74  QgsMeshRendererMeshSettings meshSettings;
75  if ( mDataProvider && mDataProvider->datasetGroupCount() > 0 )
76  {
77  // Show data from the first dataset group
78  mRendererSettings.setActiveScalarDatasetGroup( 0 );
79  // If the first dataset group has nan min/max, display the mesh to avoid nothing displayed
80  QgsMeshDatasetGroupMetadata meta = mDataProvider->datasetGroupMetadata( 0 );
81  if ( meta.maximum() == std::numeric_limits<double>::quiet_NaN() &&
82  meta.minimum() == std::numeric_limits<double>::quiet_NaN() )
83  meshSettings.setEnabled( true );
84  }
85  else
86  {
87  // show at least the mesh by default
88  meshSettings.setEnabled( true );
89  }
90  mRendererSettings.setNativeMeshSettings( meshSettings );
91 
92  // Sets default resample method for scalar dataset
93  if ( !mDataProvider )
94  return;
95  for ( int i = 0; i < mDataProvider->datasetGroupCount(); ++i )
96  {
97  QgsMeshDatasetGroupMetadata meta = mDataProvider->datasetGroupMetadata( i );
98  QgsMeshRendererScalarSettings scalarSettings = mRendererSettings.scalarSettings( i );
99  switch ( meta.dataType() )
100  {
102  case QgsMeshDatasetGroupMetadata::DataOnVolumes: // data on volumes are averaged to 2D data on faces
104  break;
107  break;
109  break;
110  }
111 
112  //override color ramp if the values in the dataset group are classified
113  applyClassificationOnScalarSettings( meta, scalarSettings );
114 
115  mRendererSettings.setScalarSettings( i, scalarSettings );
116  }
117 
118 }
119 
120 void QgsMeshLayer::createSimplifiedMeshes()
121 {
122  if ( mSimplificationSettings.isEnabled() && !hasSimplifiedMeshes() )
123  {
124  double reductionFactor = mSimplificationSettings.reductionFactor();
125 
126  QVector<QgsTriangularMesh *> simplifyMeshes =
127  mTriangularMeshes[0]->simplifyMesh( reductionFactor );
128 
129  for ( int i = 0; i < simplifyMeshes.count() ; ++i )
130  {
131  mTriangularMeshes.emplace_back( simplifyMeshes[i] );
132  }
133  }
134 }
135 
136 bool QgsMeshLayer::hasSimplifiedMeshes() const
137 {
138  //First mesh is the base mesh, so if size>1, there is no simplified meshes
139  return ( mTriangularMeshes.size() > 1 );
140 }
141 
143 {
144  delete mDataProvider;
145 }
146 
148 {
149  return mDataProvider;
150 }
151 
153 {
154  return mDataProvider;
155 }
156 
158 {
160  if ( mDataProvider )
161  {
162  options.transformContext = mDataProvider->transformContext();
163  }
164  QgsMeshLayer *layer = new QgsMeshLayer( source(), name(), mProviderKey, options );
165  QgsMapLayer::clone( layer );
166  return layer;
167 }
168 
170 {
171  if ( mDataProvider )
172  return mDataProvider->extent();
173  else
174  {
175  QgsRectangle rec;
176  rec.setMinimal();
177  return rec;
178  }
179 }
180 
182 {
183  return mProviderKey;
184 }
185 
186 bool QgsMeshLayer::addDatasets( const QString &path, const QDateTime &defaultReferenceTime )
187 {
188  bool isTemporalBefore = dataProvider()->temporalCapabilities()->hasTemporalCapabilities();
189  bool ok = dataProvider()->addDataset( path );
190  if ( ok )
191  {
192  QgsMeshLayerTemporalProperties *temporalProperties = qobject_cast< QgsMeshLayerTemporalProperties * >( mTemporalProperties );
193  if ( !isTemporalBefore && dataProvider()->temporalCapabilities()->hasTemporalCapabilities() )
194  {
196  dataProvider()->temporalCapabilities() );
197 
198  if ( ! temporalProperties->referenceTime().isValid() )
199  {
200  QDateTime referenceTime = defaultReferenceTime;
201  if ( !defaultReferenceTime.isValid() ) // If project reference time is invalid, use current date
202  referenceTime = QDateTime( QDate::currentDate(), QTime( 0, 0, 0, Qt::UTC ) );
203  temporalProperties->setReferenceTime( referenceTime, dataProvider()->temporalCapabilities() );
204  }
205 
206  mTemporalProperties->setIsActive( true );
207  }
208  emit dataSourceChanged();
209  }
210 
211  return ok;
212 }
213 
215 {
216  return mNativeMesh.get();
217 }
218 
219 const QgsMesh *QgsMeshLayer::nativeMesh() const
220 {
221  return mNativeMesh.get();
222 }
223 
224 QgsTriangularMesh *QgsMeshLayer::triangularMesh( double minimumTriangleSize ) const
225 {
226  for ( const std::unique_ptr<QgsTriangularMesh> &lod : mTriangularMeshes )
227  {
228  if ( lod && lod->averageTriangleSize() > minimumTriangleSize )
229  return lod.get();
230  }
231 
232  if ( !mTriangularMeshes.empty() )
233  return mTriangularMeshes.back().get();
234  else
235  return nullptr;
236 }
237 
239 {
240  // Native mesh
241  if ( !mNativeMesh )
242  {
243  // lazy loading of mesh data
244  fillNativeMesh();
245  }
246 
247  // Triangular mesh
248  if ( mTriangularMeshes.empty() )
249  {
250  QgsTriangularMesh *baseMesh = new QgsTriangularMesh;
251  mTriangularMeshes.emplace_back( baseMesh );
252  }
253 
254  if ( mTriangularMeshes[0].get()->update( mNativeMesh.get(), transform ) )
255  mTriangularMeshes.resize( 1 ); //if the base triangular mesh is effectivly updated, remove simplified meshes
256 }
257 
258 QgsMeshLayerRendererCache *QgsMeshLayer::rendererCache()
259 {
260  return mRendererCache.get();
261 }
262 
264 {
265  return mRendererSettings;
266 }
267 
269 {
270  int oldActiveScalar = mRendererSettings.activeScalarDatasetGroup();
271  int oldActiveVector = mRendererSettings.activeVectorDatasetGroup();
272  mRendererSettings = settings;
273 
274  if ( oldActiveScalar != mRendererSettings.activeScalarDatasetGroup() )
275  emit activeScalarDatasetGroupChanged( mRendererSettings.activeScalarDatasetGroup() );
276 
277  if ( oldActiveVector != mRendererSettings.activeVectorDatasetGroup() )
278  emit activeVectorDatasetGroupChanged( mRendererSettings.activeVectorDatasetGroup() );
279 
280  emit rendererChanged();
281  triggerRepaint();
282 }
283 
285 {
286  return mTimeSettings;
287 }
288 
290 {
291  mTimeSettings = settings;
292  emit timeSettingsChanged();
293 }
294 
295 QString QgsMeshLayer::formatTime( double hours )
296 {
297  if ( dataProvider() && dataProvider()->temporalCapabilities()->hasReferenceTime() )
298  return QgsMeshLayerUtils::formatTime( hours, mTemporalProperties->referenceTime(), mTimeSettings );
299  else
300  return QgsMeshLayerUtils::formatTime( hours, QDateTime(), mTimeSettings );
301 }
302 
303 QgsMeshDatasetValue QgsMeshLayer::datasetValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius ) const
304 {
305  QgsMeshDatasetValue value;
306  const QgsTriangularMesh *mesh = triangularMesh();
307 
308  if ( mesh && dataProvider() && dataProvider()->isValid() && index.isValid() )
309  {
310  if ( dataProvider()->contains( QgsMesh::ElementType::Edge ) )
311  {
312  QgsRectangle searchRectangle( point.x() - searchRadius, point.y() - searchRadius, point.x() + searchRadius, point.y() + searchRadius );
313  return dataset1dValue( index, point, searchRadius );
314  }
315  int faceIndex = mesh->faceIndexForPoint_v2( point ) ;
316  if ( faceIndex >= 0 )
317  {
318  int nativeFaceIndex = mesh->trianglesToNativeFaces().at( faceIndex );
320  if ( dataProvider()->isFaceActive( index, nativeFaceIndex ) )
321  {
322  switch ( dataType )
323  {
325  {
326  value = dataProvider()->datasetValue( index, nativeFaceIndex );
327  }
328  break;
329 
331  {
332  const QgsMeshFace &face = mesh->triangles()[faceIndex];
333  const int v1 = face[0], v2 = face[1], v3 = face[2];
334  const QgsPoint p1 = mesh->vertices()[v1], p2 = mesh->vertices()[v2], p3 = mesh->vertices()[v3];
335  const QgsMeshDatasetValue val1 = dataProvider()->datasetValue( index, v1 );
336  const QgsMeshDatasetValue val2 = dataProvider()->datasetValue( index, v2 );
337  const QgsMeshDatasetValue val3 = dataProvider()->datasetValue( index, v3 );
338  const double x = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.x(), val2.x(), val3.x(), point );
339  double y = std::numeric_limits<double>::quiet_NaN();
340  bool isVector = dataProvider()->datasetGroupMetadata( index ).isVector();
341  if ( isVector )
342  y = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.y(), val2.y(), val3.y(), point );
343 
344  value = QgsMeshDatasetValue( x, y );
345  }
346  break;
347 
349  {
350  const QgsMesh3dAveragingMethod *avgMethod = mRendererSettings.averagingMethod();
351  if ( avgMethod )
352  {
353  const QgsMesh3dDataBlock block3d = dataProvider()->dataset3dValues( index, nativeFaceIndex, 1 );
354  const QgsMeshDataBlock block2d = avgMethod->calculate( block3d );
355  if ( block2d.isValid() )
356  {
357  value = block2d.value( 0 );
358  }
359  }
360  }
361  break;
362 
363  default:
364  break;
365  }
366  }
367  }
368  }
369 
370  return value;
371 }
372 
374 {
375  QgsMesh3dDataBlock block3d;
376 
377  const QgsTriangularMesh *baseTriangularMesh = triangularMesh();
378 
379  if ( baseTriangularMesh && dataProvider() && dataProvider()->isValid() && index.isValid() )
380  {
383  {
384  int faceIndex = baseTriangularMesh->faceIndexForPoint_v2( point );
385  if ( faceIndex >= 0 )
386  {
387  int nativeFaceIndex = baseTriangularMesh->trianglesToNativeFaces().at( faceIndex );
388  block3d = dataProvider()->dataset3dValues( index, nativeFaceIndex, 1 );
389  }
390  }
391  }
392  return block3d;
393 }
394 
395 QgsMeshDatasetValue QgsMeshLayer::dataset1dValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius ) const
396 {
397  QgsMeshDatasetValue value;
398  QgsPointXY projectedPoint;
399  int selectedIndex = closestEdge( point, searchRadius, projectedPoint );
400  const QgsTriangularMesh *mesh = triangularMesh();
401  if ( selectedIndex >= 0 )
402  {
404  switch ( dataType )
405  {
407  {
408  value = dataProvider()->datasetValue( index, selectedIndex );
409  }
410  break;
411 
413  {
414  const QgsMeshEdge &edge = mesh->edges()[selectedIndex];
415  const int v1 = edge.first, v2 = edge.second;
416  const QgsPoint p1 = mesh->vertices()[v1], p2 = mesh->vertices()[v2];
417  const QgsMeshDatasetValue val1 = dataProvider()->datasetValue( index, v1 );
418  const QgsMeshDatasetValue val2 = dataProvider()->datasetValue( index, v2 );
419  double edgeLength = p1.distance( p2 );
420  double dist1 = p1.distance( projectedPoint.x(), projectedPoint.y() );
421  value = QgsMeshLayerUtils::interpolateFromVerticesData( dist1 / edgeLength, val1, val2 );
422  }
423  break;
424  default:
425  break;
426  }
427  }
428 
429  return value;
430 }
431 
433 {
434  if ( mDataProvider )
435  mDataProvider->setTransformContext( transformContext );
436 }
437 
438 QgsMeshDatasetIndex QgsMeshLayer::datasetIndexAtTime( const QgsDateTimeRange &timeRange, int datasetGroupIndex ) const
439 {
440  if ( ! mTemporalProperties->isActive() )
441  return QgsMeshDatasetIndex( datasetGroupIndex, -1 );
442 
443  const QDateTime layerReferenceTime = mTemporalProperties->referenceTime();
444  qint64 startTime = layerReferenceTime.msecsTo( timeRange.begin() );
445 
446  if ( dataProvider() )
447  switch ( mTemporalProperties->matchingMethod() )
448  {
450  return dataProvider()->temporalCapabilities()->datasetIndexClosestBeforeRelativeTime( datasetGroupIndex, startTime );
452  return dataProvider()->temporalCapabilities()->datasetIndexClosestFromRelativeTime( datasetGroupIndex, startTime );
453  }
454 
455  return QgsMeshDatasetIndex();
456 }
457 
458 void QgsMeshLayer::applyClassificationOnScalarSettings( const QgsMeshDatasetGroupMetadata &meta, QgsMeshRendererScalarSettings &scalarSettings ) const
459 {
460  if ( meta.extraOptions().contains( QStringLiteral( "classification" ) ) )
461  {
462  QgsColorRampShader colorRampShader = scalarSettings.colorRampShader();
463  QgsColorRamp *colorRamp = colorRampShader.sourceColorRamp();
464  QStringList classes = meta.extraOptions()[QStringLiteral( "classification" )].split( QStringLiteral( ";;" ) );
465 
466  QString units;
467  if ( meta.extraOptions().contains( QStringLiteral( "units" ) ) )
468  units = meta.extraOptions()[ QStringLiteral( "units" )];
469 
470  QVector<QVector<double>> bounds;
471  for ( const QString classe : classes )
472  {
473  QStringList boundsStr = classe.split( ',' );
474  QVector<double> bound;
475  for ( const QString boundStr : boundsStr )
476  bound.append( boundStr.toDouble() );
477  bounds.append( bound );
478  }
479 
480  if ( ( bounds.count() == 1 && bounds.first().count() > 2 ) || // at least a class with two value
481  ( bounds.count() > 1 ) ) // or at least two classes
482  {
483  const QVector<double> firstClass = bounds.first();
484  const QVector<double> lastClass = bounds.last();
485  double minValue = firstClass.count() > 1 ? ( firstClass.first() + firstClass.last() ) / 2 : firstClass.first();
486  double maxValue = lastClass.count() > 1 ? ( lastClass.first() + lastClass.last() ) / 2 : lastClass.first();
487  double diff = maxValue - minValue;
488  QList<QgsColorRampShader::ColorRampItem> colorRampItemlist;
489  for ( int i = 0; i < bounds.count(); ++i )
490  {
491  const QVector<double> &boundClass = bounds.at( i );
493  item.value = i + 1;
494  if ( !boundClass.isEmpty() )
495  {
496  double scalarValue = ( boundClass.first() + boundClass.last() ) / 2;
497  item.color = colorRamp->color( ( scalarValue - minValue ) / diff );
498  if ( i != 0 && i < bounds.count() - 1 ) //The first and last labels are treated after
499  {
500  item.label = QString( ( "%1 - %2 %3" ) ).
501  arg( QString::number( boundClass.first() ) ).
502  arg( QString::number( boundClass.last() ) ).
503  arg( units );
504  }
505  }
506  colorRampItemlist.append( item );
507  }
508  //treat first and last labels
509  if ( firstClass.count() == 1 )
510  colorRampItemlist.first().label = QObject::tr( "below %1 %2" ).
511  arg( QString::number( firstClass.first() ) ).
512  arg( units );
513  else
514  {
515  colorRampItemlist.first().label = QString( ( "%1 - %2 %3" ) ).
516  arg( QString::number( firstClass.first() ) ).
517  arg( QString::number( firstClass.last() ) ).
518  arg( units );
519  }
520 
521  if ( lastClass.count() == 1 )
522  colorRampItemlist.last().label = QObject::tr( "above %1 %2" ).
523  arg( QString::number( lastClass.first() ) ).
524  arg( units );
525  else
526  {
527  colorRampItemlist.last().label = QString( ( "%1 - %2 %3" ) ).
528  arg( QString::number( lastClass.first() ) ).
529  arg( QString::number( lastClass.last() ) ).
530  arg( units );
531  }
532 
533  colorRampShader.setMinimumValue( 0 );
534  colorRampShader.setMaximumValue( colorRampItemlist.count() - 1 );
535  scalarSettings.setClassificationMinimumMaximum( 0, colorRampItemlist.count() - 1 );
536  colorRampShader.setColorRampItemList( colorRampItemlist );
537  colorRampShader.setColorRampType( QgsColorRampShader::Exact );
539  }
540 
541  scalarSettings.setColorRampShader( colorRampShader );
543  }
544 }
545 
546 QgsMeshDatasetIndex QgsMeshLayer::activeScalarDatasetAtTime( const QgsDateTimeRange &timeRange ) const
547 {
548  if ( mTemporalProperties->isActive() )
549  return datasetIndexAtTime( timeRange, mRendererSettings.activeScalarDatasetGroup() );
550  else
551  return QgsMeshDatasetIndex( mRendererSettings.activeScalarDatasetGroup(), mStaticScalarDatasetIndex );
552 }
553 
554 QgsMeshDatasetIndex QgsMeshLayer::activeVectorDatasetAtTime( const QgsDateTimeRange &timeRange ) const
555 {
556  if ( mTemporalProperties->isActive() )
557  return datasetIndexAtTime( timeRange, mRendererSettings.activeVectorDatasetGroup() );
558  else
559  return QgsMeshDatasetIndex( mRendererSettings.activeVectorDatasetGroup(), mStaticVectorDatasetIndex );
560 }
561 
562 void QgsMeshLayer::fillNativeMesh()
563 {
564  Q_ASSERT( !mNativeMesh );
565 
566  mNativeMesh.reset( new QgsMesh() );
567 
568  if ( !( dataProvider() && dataProvider()->isValid() ) )
569  return;
570 
571  dataProvider()->populateMesh( mNativeMesh.get() );
572 }
573 
574 void QgsMeshLayer::onDatasetGroupsAdded( int count )
575 {
576  // assign default style to new dataset groups
577  int newDatasetGroupCount = mDataProvider->datasetGroupCount();
578  for ( int i = newDatasetGroupCount - count; i < newDatasetGroupCount; ++i )
579  assignDefaultStyleToDatasetGroup( i );
580 
581  if ( mDataProvider )
582  {
584 
585  QList<QgsMeshDatasetGroupMetadata> metadataList;
586  int totalCount = mDataProvider->datasetGroupCount();
587  for ( int i = totalCount - count; i < totalCount; ++i )
588  metadataList.append( mDataProvider->datasetGroupMetadata( i ) );
589  QgsMeshLayerUtils::createDatasetGroupTreeItems( metadataList, mDatasetGroupTreeRootItem.get(), totalCount - count );
590  }
591 }
592 
594 {
595  return mDatasetGroupTreeRootItem.get();
596 }
597 
599 {
600  if ( rootItem )
601  mDatasetGroupTreeRootItem.reset( rootItem->clone() );
602  else
603  mDatasetGroupTreeRootItem.reset();
604 
605  updateActiveDatasetGroups();
606 }
607 
608 int QgsMeshLayer::closestEdge( const QgsPointXY &point, double searchRadius, QgsPointXY &projectedPoint ) const
609 {
610  QgsRectangle searchRectangle( point.x() - searchRadius, point.y() - searchRadius, point.x() + searchRadius, point.y() + searchRadius );
611  const QgsTriangularMesh *mesh = triangularMesh();
612  // search for the closest edge in search area from point
613  const QList<int> edgeIndexes = mesh->edgeIndexesForRectangle( searchRectangle );
614  int selectedIndex = -1;
615  if ( mesh->contains( QgsMesh::Edge ) &&
616  mDataProvider->isValid() )
617  {
618  double sqrMaxDistFromPoint = pow( searchRadius, 2 );
619  for ( const int edgeIndex : edgeIndexes )
620  {
621  const QgsMeshEdge &edge = mesh->edges().at( edgeIndex );
622  const QgsMeshVertex &vertex1 = mesh->vertices()[edge.first];
623  const QgsMeshVertex &vertex2 = mesh->vertices()[edge.second];
624  QgsPointXY projPoint;
625  double sqrDist = point.sqrDistToSegment( vertex1.x(), vertex1.y(), vertex2.x(), vertex2.y(), projPoint );
626  if ( sqrDist < sqrMaxDistFromPoint )
627  {
628  selectedIndex = edgeIndex;
629  projectedPoint = projPoint;
630  sqrMaxDistFromPoint = sqrDist;
631  }
632  }
633  }
634 
635  return selectedIndex;
636 }
637 
639 {
640  return QgsMeshDatasetIndex( mRendererSettings.activeVectorDatasetGroup(), mStaticVectorDatasetIndex );
641 }
642 
643 void QgsMeshLayer::setReferenceTime( const QDateTime &referenceTime )
644 {
645  if ( dataProvider() )
646  mTemporalProperties->setReferenceTime( referenceTime, dataProvider()->temporalCapabilities() );
647  else
648  mTemporalProperties->setReferenceTime( referenceTime, nullptr );
649 }
650 
652 {
653  mTemporalProperties->setMatchingMethod( matchingMethod );
654 }
655 
656 QgsPointXY QgsMeshLayer::snapOnVertex( const QgsPointXY &point, double searchRadius )
657 {
658  const QgsTriangularMesh *mesh = triangularMesh();
659  QgsPointXY exactPosition;
660  if ( !mesh )
661  return exactPosition;
662  QgsRectangle rectangle( point.x() - searchRadius, point.y() - searchRadius, point.x() + searchRadius, point.y() + searchRadius );
663  double maxDistance = searchRadius;
664  //attempt to snap on edges's vertices
665  QList<int> edgeIndexes = mesh->edgeIndexesForRectangle( rectangle );
666  for ( const int edgeIndex : edgeIndexes )
667  {
668  const QgsMeshEdge &edge = mesh->edges().at( edgeIndex );
669  const QgsMeshVertex &vertex1 = mesh->vertices()[edge.first];
670  const QgsMeshVertex &vertex2 = mesh->vertices()[edge.second];
671  double dist1 = point.distance( vertex1 );
672  double dist2 = point.distance( vertex2 );
673  if ( dist1 < maxDistance )
674  {
675  maxDistance = dist1;
676  exactPosition = vertex1;
677  }
678  if ( dist2 < maxDistance )
679  {
680  maxDistance = dist2;
681  exactPosition = vertex2;
682  }
683  }
684 
685  //attempt to snap on face's vertices
686  QList<int> faceIndexes = mesh->faceIndexesForRectangle( rectangle );
687  for ( const int faceIndex : faceIndexes )
688  {
689  const QgsMeshFace &face = mesh->triangles().at( faceIndex );
690  for ( int i = 0; i < 3; ++i )
691  {
692  const QgsMeshVertex &vertex = mesh->vertices()[face.at( i )];
693  double dist = point.distance( vertex );
694  if ( dist < maxDistance )
695  {
696  maxDistance = dist;
697  exactPosition = vertex;
698  }
699  }
700  }
701 
702  return exactPosition;
703 }
704 
705 QgsPointXY QgsMeshLayer::snapOnEdge( const QgsPointXY &point, double searchRadius )
706 {
707  QgsPointXY projectedPoint;
708  closestEdge( point, searchRadius, projectedPoint );
709 
710  return projectedPoint;
711 }
712 
713 QgsPointXY QgsMeshLayer::snapOnFace( const QgsPointXY &point, double searchRadius )
714 {
715  const QgsTriangularMesh *mesh = triangularMesh();
716  QgsPointXY centroidPosition;
717  if ( !mesh )
718  return centroidPosition;
719  QgsRectangle rectangle( point.x() - searchRadius, point.y() - searchRadius, point.x() + searchRadius, point.y() + searchRadius );
720  double maxDistance = std::numeric_limits<double>::max();
721 
722  QList<int> faceIndexes = mesh->faceIndexesForRectangle( rectangle );
723  for ( const int faceIndex : faceIndexes )
724  {
725  int nativefaceIndex = mesh->trianglesToNativeFaces().at( faceIndex );
726  if ( nativefaceIndex < 0 && nativefaceIndex >= mesh->faceCentroids().count() )
727  continue;
728  const QgsPointXY centroid = mesh->faceCentroids()[nativefaceIndex];
729  double dist = point.distance( centroid );
730  if ( dist < maxDistance )
731  {
732  maxDistance = dist;
733  centroidPosition = centroid;
734  }
735  }
736 
737  return centroidPosition;
738 }
739 
741 {
742  mDatasetGroupTreeRootItem.reset( new QgsMeshDatasetGroupTreeItem );
743  QList<QgsMeshDatasetGroupMetadata> metadataList;
744  for ( int i = 0; i < mDataProvider->datasetGroupCount(); ++i )
745  metadataList.append( mDataProvider->datasetGroupMetadata( i ) );
746  QgsMeshLayerUtils::createDatasetGroupTreeItems( metadataList, mDatasetGroupTreeRootItem.get(), 0 );
747  updateActiveDatasetGroups();
748 }
749 
751 {
752  if ( !mDataProvider )
753  return QgsInterval();
754  int groupCount = mDataProvider->datasetGroupCount();
755  for ( int i = 0; i < groupCount; ++i )
756  {
757  qint64 timeStep = mDataProvider->temporalCapabilities()->firstTimeStepDuration( i );
758  if ( timeStep > 0 )
760  }
761 
762  return QgsInterval();
763 }
764 
765 void QgsMeshLayer::updateActiveDatasetGroups()
766 {
767  if ( !mDatasetGroupTreeRootItem )
768  return;
769 
771  int oldActiveScalar = settings.activeScalarDatasetGroup();
772  int oldActiveVector = settings.activeVectorDatasetGroup();
773 
774  QgsMeshDatasetGroupTreeItem *activeScalarItem =
775  mDatasetGroupTreeRootItem->childFromDatasetGroupIndex( oldActiveScalar );
776 
777  if ( !activeScalarItem && mDatasetGroupTreeRootItem->childCount() > 0 )
778  activeScalarItem = mDatasetGroupTreeRootItem->child( 0 );
779 
780  if ( activeScalarItem && !activeScalarItem->isEnabled() )
781  {
782  for ( int i = 0; i < mDatasetGroupTreeRootItem->childCount(); ++i )
783  {
784  activeScalarItem = mDatasetGroupTreeRootItem->child( i );
785  if ( activeScalarItem->isEnabled() )
786  break;
787  else
788  activeScalarItem = nullptr;
789  }
790  }
791 
792  if ( activeScalarItem )
793  settings.setActiveScalarDatasetGroup( activeScalarItem->datasetGroupIndex() );
794  else
795  settings.setActiveScalarDatasetGroup( -1 );
796 
797  QgsMeshDatasetGroupTreeItem *activeVectorItem =
798  mDatasetGroupTreeRootItem->childFromDatasetGroupIndex( oldActiveVector );
799 
800  if ( !( activeVectorItem && activeVectorItem->isEnabled() ) )
801  settings.setActiveVectorDatasetGroup( -1 );
802 
803  setRendererSettings( settings );
804 
805  if ( oldActiveScalar != settings.activeScalarDatasetGroup() )
807  if ( oldActiveVector != settings.activeVectorDatasetGroup() )
809 }
810 
811 QgsPointXY QgsMeshLayer::snapOnElement( QgsMesh::ElementType elementType, const QgsPointXY &point, double searchRadius )
812 {
813  switch ( elementType )
814  {
815  case QgsMesh::Vertex:
816  return snapOnVertex( point, searchRadius );
817  case QgsMesh::Edge:
818  return snapOnEdge( point, searchRadius );
819  case QgsMesh::Face:
820  return snapOnFace( point, searchRadius );
821  }
822  return QgsPointXY(); // avoid warnings
823 }
824 
826 {
827  return QgsMeshDatasetIndex( mRendererSettings.activeScalarDatasetGroup(), mStaticScalarDatasetIndex );
828 }
829 
830 void QgsMeshLayer::setStaticVectorDatasetIndex( const QgsMeshDatasetIndex &staticVectorDatasetIndex )
831 {
832  int oldActiveVector = mRendererSettings.activeVectorDatasetGroup();
833 
834  mStaticVectorDatasetIndex = staticVectorDatasetIndex.dataset();
836 
837  if ( oldActiveVector != mRendererSettings.activeVectorDatasetGroup() )
838  emit activeVectorDatasetGroupChanged( mRendererSettings.activeVectorDatasetGroup() );
839 }
840 
841 void QgsMeshLayer::setStaticScalarDatasetIndex( const QgsMeshDatasetIndex &staticScalarDatasetIndex )
842 {
843  int oldActiveScalar = mRendererSettings.activeScalarDatasetGroup();
844 
845  mStaticScalarDatasetIndex = staticScalarDatasetIndex.dataset();
847 
848  if ( oldActiveScalar != mRendererSettings.activeScalarDatasetGroup() )
849  emit activeScalarDatasetGroupChanged( mRendererSettings.activeScalarDatasetGroup() );
850 }
851 
853 {
854  return mSimplificationSettings;
855 }
856 
858 {
859  mSimplificationSettings = simplifySettings;
860 }
861 
862 static QgsColorRamp *_createDefaultColorRamp()
863 {
864  QgsColorRamp *ramp = QgsStyle::defaultStyle()->colorRamp( QStringLiteral( "Plasma" ) );
865  if ( ramp )
866  return ramp;
867 
868  // definition of "Plasma" color ramp (in case it is not available in the style for some reason)
869  QgsStringMap props;
870  props["color1"] = "13,8,135,255";
871  props["color2"] = "240,249,33,255";
872  props["stops"] =
873  "0.0196078;27,6,141,255:0.0392157;38,5,145,255:0.0588235;47,5,150,255:0.0784314;56,4,154,255:0.0980392;65,4,157,255:"
874  "0.117647;73,3,160,255:0.137255;81,2,163,255:0.156863;89,1,165,255:0.176471;97,0,167,255:0.196078;105,0,168,255:"
875  "0.215686;113,0,168,255:0.235294;120,1,168,255:0.254902;128,4,168,255:0.27451;135,7,166,255:0.294118;142,12,164,255:"
876  "0.313725;149,17,161,255:0.333333;156,23,158,255:0.352941;162,29,154,255:0.372549;168,34,150,255:0.392157;174,40,146,255:"
877  "0.411765;180,46,141,255:0.431373;186,51,136,255:0.45098;191,57,132,255:0.470588;196,62,127,255:0.490196;201,68,122,255:"
878  "0.509804;205,74,118,255:0.529412;210,79,113,255:0.54902;214,85,109,255:0.568627;218,91,105,255:0.588235;222,97,100,255:"
879  "0.607843;226,102,96,255:0.627451;230,108,92,255:0.647059;233,114,87,255:0.666667;237,121,83,255:0.686275;240,127,79,255:"
880  "0.705882;243,133,75,255:0.72549;245,140,70,255:0.745098;247,147,66,255:0.764706;249,154,62,255:0.784314;251,161,57,255:"
881  "0.803922;252,168,53,255:0.823529;253,175,49,255:0.843137;254,183,45,255:0.862745;254,190,42,255:0.882353;253,198,39,255:"
882  "0.901961;252,206,37,255:0.921569;251,215,36,255:0.941176;248,223,37,255:0.960784;246,232,38,255:0.980392;243,240,39,255";
883  return QgsGradientColorRamp::create( props );
884 }
885 
886 void QgsMeshLayer::assignDefaultStyleToDatasetGroup( int groupIndex )
887 {
888  const QgsMeshDatasetGroupMetadata metadata = mDataProvider->datasetGroupMetadata( groupIndex );
889  double groupMin = metadata.minimum();
890  double groupMax = metadata.maximum();
891 
892  QgsColorRampShader fcn( groupMin, groupMax, _createDefaultColorRamp() );
893  fcn.classifyColorRamp( 5, -1, QgsRectangle(), nullptr );
894 
895  QgsMeshRendererScalarSettings scalarSettings;
896  scalarSettings.setClassificationMinimumMaximum( groupMin, groupMax );
897  scalarSettings.setColorRampShader( fcn );
898  QgsInterpolatedLineWidth edgeStrokeWidth;
899  edgeStrokeWidth.setMinimumValue( groupMin );
900  edgeStrokeWidth.setMaximumValue( groupMax );
901  QgsInterpolatedLineColor edgeStrokeColor( fcn );
902  QgsInterpolatedLineRenderer edgeStrokePen;
903  scalarSettings.setEdgeStrokeWidth( edgeStrokeWidth );
904  mRendererSettings.setScalarSettings( groupIndex, scalarSettings );
905 
906  if ( metadata.isVector() )
907  {
908  QgsMeshRendererVectorSettings vectorSettings;
909  vectorSettings.setColorRampShader( fcn );
910  mRendererSettings.setVectorSettings( groupIndex, vectorSettings );
911  }
912 }
913 
915 {
916  // Triangular mesh
917  updateTriangularMesh( rendererContext.coordinateTransform() );
918 
919  // Build overview triangular meshes if needed
920  createSimplifiedMeshes();
921 
922  // Cache
923  if ( !mRendererCache )
924  mRendererCache.reset( new QgsMeshLayerRendererCache() );
925 
926  return new QgsMeshLayerRenderer( this, rendererContext );
927 }
928 
929 bool QgsMeshLayer::readSymbology( const QDomNode &node, QString &errorMessage,
930  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
931 {
932  Q_UNUSED( errorMessage )
933  // TODO: implement categories for raster layer
934 
935  QDomElement elem = node.toElement();
936 
937  readCommonStyle( elem, context, categories );
938 
939  QDomElement elemRendererSettings = elem.firstChildElement( "mesh-renderer-settings" );
940  if ( !elemRendererSettings.isNull() )
941  mRendererSettings.readXml( elemRendererSettings );
942 
943  QDomElement elemSimplifySettings = elem.firstChildElement( "mesh-simplify-settings" );
944  if ( !elemSimplifySettings.isNull() )
945  mSimplificationSettings.readXml( elemSimplifySettings, context );
946 
947  // get and set the blend mode if it exists
948  QDomNode blendModeNode = node.namedItem( QStringLiteral( "blendMode" ) );
949  if ( !blendModeNode.isNull() )
950  {
951  QDomElement e = blendModeNode.toElement();
952  setBlendMode( QgsPainting::getCompositionMode( static_cast< QgsPainting::BlendMode >( e.text().toInt() ) ) );
953  }
954 
955  return true;
956 }
957 
958 bool QgsMeshLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
959  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
960 {
961  Q_UNUSED( errorMessage )
962  // TODO: implement categories for raster layer
963 
964  QDomElement elem = node.toElement();
965 
966  writeCommonStyle( elem, doc, context, categories );
967 
968  QDomElement elemRendererSettings = mRendererSettings.writeXml( doc );
969  elem.appendChild( elemRendererSettings );
970 
971  QDomElement elemSimplifySettings = mSimplificationSettings.writeXml( doc, context );
972  elem.appendChild( elemSimplifySettings );
973 
974  // add blend mode node
975  QDomElement blendModeElement = doc.createElement( QStringLiteral( "blendMode" ) );
976  QDomText blendModeText = doc.createTextNode( QString::number( QgsPainting::getBlendModeEnum( blendMode() ) ) );
977  blendModeElement.appendChild( blendModeText );
978  node.appendChild( blendModeElement );
979 
980  return true;
981 }
982 
983 bool QgsMeshLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
984 {
985  return writeSymbology( node, doc, errorMessage, context, categories );
986 }
987 
988 bool QgsMeshLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
989 {
990  return readSymbology( node, errorMessage, context, categories );
991 }
992 
993 QString QgsMeshLayer::decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const
994 {
995  QString src( source );
996  if ( provider == QLatin1String( "mdal" ) )
997  {
998  src = context.pathResolver().readPath( src );
999  }
1000  return src;
1001 }
1002 
1003 QString QgsMeshLayer::encodedSource( const QString &source, const QgsReadWriteContext &context ) const
1004 {
1005  QString src( source );
1006  if ( providerType() == QLatin1String( "mdal" ) )
1007  {
1008  src = context.pathResolver().writePath( src );
1009  }
1010  return src;
1011 }
1012 
1013 bool QgsMeshLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &context )
1014 {
1015  QgsDebugMsgLevel( QStringLiteral( "Datasource in QgsMeshLayer::readXml: %1" ).arg( mDataSource.toLocal8Bit().data() ), 3 );
1016 
1017  //process provider key
1018  QDomNode pkeyNode = layer_node.namedItem( QStringLiteral( "provider" ) );
1019 
1020  if ( pkeyNode.isNull() )
1021  {
1022  mProviderKey.clear();
1023  }
1024  else
1025  {
1026  QDomElement pkeyElt = pkeyNode.toElement();
1027  mProviderKey = pkeyElt.text();
1028  }
1029 
1031  {
1032  return false;
1033  }
1034 
1035  QgsDataProvider::ProviderOptions providerOptions;
1036  if ( !setDataProvider( mProviderKey, providerOptions ) )
1037  {
1038  return false;
1039  }
1040 
1041  QDomElement elemExtraDatasets = layer_node.firstChildElement( QStringLiteral( "extra-datasets" ) );
1042  if ( !elemExtraDatasets.isNull() )
1043  {
1044  QDomElement elemUri = elemExtraDatasets.firstChildElement( QStringLiteral( "uri" ) );
1045  while ( !elemUri.isNull() )
1046  {
1047  QString uri = context.pathResolver().readPath( elemUri.text() );
1048 
1049  bool res = mDataProvider->addDataset( uri );
1050 #ifdef QGISDEBUG
1051  QgsDebugMsg( QStringLiteral( "extra dataset (res %1): %2" ).arg( res ).arg( uri ) );
1052 #else
1053  ( void )res; // avoid unused warning in release builds
1054 #endif
1055 
1056  elemUri = elemUri.nextSiblingElement( QStringLiteral( "uri" ) );
1057  }
1058  }
1059 
1060  if ( mDataProvider && pkeyNode.toElement().hasAttribute( QStringLiteral( "time-unit" ) ) )
1061  mDataProvider->setTemporalUnit(
1062  static_cast<QgsUnitTypes::TemporalUnit>( pkeyNode.toElement().attribute( QStringLiteral( "time-unit" ) ).toInt() ) );
1063 
1064  // read dataset group tree items
1065  QDomElement elemDatasetGroupTree = layer_node.firstChildElement( QStringLiteral( "dataset-groups-tree" ) );
1066  QDomElement rootItemElement = elemDatasetGroupTree.firstChildElement( QStringLiteral( "mesh-dataset-group_tree-item" ) );
1067  if ( rootItemElement.isNull() )
1069  else
1070  mDatasetGroupTreeRootItem.reset( new QgsMeshDatasetGroupTreeItem( rootItemElement, context ) );
1071 
1072  QString errorMsg;
1073  readSymbology( layer_node, errorMsg, context );
1074 
1075  if ( !mTemporalProperties->timeExtent().begin().isValid() )
1077 
1078  // read static dataset
1079  QDomElement elemStaticDataset = layer_node.firstChildElement( QStringLiteral( "static-active-dataset" ) );
1080  if ( elemStaticDataset.hasAttribute( QStringLiteral( "scalar" ) ) )
1081  {
1082  mStaticScalarDatasetIndex = elemStaticDataset.attribute( QStringLiteral( "scalar" ) ).toInt();
1083  }
1084  if ( elemStaticDataset.hasAttribute( QStringLiteral( "vector" ) ) )
1085  {
1086  mStaticVectorDatasetIndex = elemStaticDataset.attribute( QStringLiteral( "vector" ) ).toInt();
1087  }
1088 
1089  return mValid; // should be true if read successfully
1090 }
1091 
1092 bool QgsMeshLayer::writeXml( QDomNode &layer_node, QDomDocument &document, const QgsReadWriteContext &context ) const
1093 {
1094  // first get the layer element so that we can append the type attribute
1095  QDomElement mapLayerNode = layer_node.toElement();
1096 
1097  if ( mapLayerNode.isNull() || ( QLatin1String( "maplayer" ) != mapLayerNode.nodeName() ) )
1098  {
1099  QgsDebugMsgLevel( QStringLiteral( "can't find <maplayer>" ), 2 );
1100  return false;
1101  }
1102 
1103  mapLayerNode.setAttribute( QStringLiteral( "type" ), QStringLiteral( "mesh" ) );
1104 
1105  // add provider node
1106  if ( mDataProvider )
1107  {
1108  QDomElement provider = document.createElement( QStringLiteral( "provider" ) );
1109  QDomText providerText = document.createTextNode( providerType() );
1110  provider.appendChild( providerText );
1111  layer_node.appendChild( provider );
1112  provider.setAttribute( QStringLiteral( "time-unit" ), mDataProvider->temporalCapabilities()->temporalUnit() );
1113 
1114  const QStringList extraDatasetUris = mDataProvider->extraDatasets();
1115  QDomElement elemExtraDatasets = document.createElement( QStringLiteral( "extra-datasets" ) );
1116  for ( const QString &uri : extraDatasetUris )
1117  {
1118  QString path = context.pathResolver().writePath( uri );
1119  QDomElement elemUri = document.createElement( QStringLiteral( "uri" ) );
1120  elemUri.appendChild( document.createTextNode( path ) );
1121  elemExtraDatasets.appendChild( elemUri );
1122  }
1123  layer_node.appendChild( elemExtraDatasets );
1124  }
1125 
1126  QDomElement elemStaticDataset = document.createElement( QStringLiteral( "static-active-dataset" ) );
1127  elemStaticDataset.setAttribute( QStringLiteral( "scalar" ), mStaticScalarDatasetIndex );
1128  elemStaticDataset.setAttribute( QStringLiteral( "vector" ), mStaticVectorDatasetIndex );
1129  layer_node.appendChild( elemStaticDataset );
1130 
1131  // write dataset group tree items
1132  QDomElement elemDatasetTree = document.createElement( QStringLiteral( "dataset-groups-tree" ) );
1133  elemDatasetTree.appendChild( mDatasetGroupTreeRootItem->writeXml( document, context ) );
1134  layer_node.appendChild( elemDatasetTree );
1135 
1136  // renderer specific settings
1137  QString errorMsg;
1138  return writeSymbology( layer_node, document, errorMsg, context );
1139 }
1140 
1142 {
1143  if ( mDataProvider && mDataProvider->isValid() )
1144  {
1145  mDataProvider->reloadData();
1146 
1147  //reload the mesh structure
1148  if ( !mNativeMesh )
1149  mNativeMesh.reset( new QgsMesh );
1150 
1151  dataProvider()->populateMesh( mNativeMesh.get() );
1152 
1153  //clear the TriangularMeshes
1154  mTriangularMeshes.clear();
1155 
1156  //clear the rendererCache
1157  mRendererCache.reset( new QgsMeshLayerRendererCache() );
1158  }
1159 }
1160 
1161 QStringList QgsMeshLayer::subLayers() const
1162 {
1163  if ( mDataProvider )
1164  return mDataProvider->subLayers();
1165  else
1166  return QStringList();
1167 }
1168 
1169 bool QgsMeshLayer::setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options )
1170 {
1171  delete mDataProvider;
1172 
1173  mProviderKey = provider;
1174  QString dataSource = mDataSource;
1175 
1176  mDataProvider = qobject_cast<QgsMeshDataProvider *>( QgsProviderRegistry::instance()->createProvider( provider, dataSource, options ) );
1177  if ( !mDataProvider )
1178  {
1179  QgsDebugMsgLevel( QStringLiteral( "Unable to get mesh data provider" ), 2 );
1180  return false;
1181  }
1182 
1183  mDataProvider->setParent( this );
1184  QgsDebugMsgLevel( QStringLiteral( "Instantiated the mesh data provider plugin" ), 2 );
1185 
1186  mValid = mDataProvider->isValid();
1187  if ( !mValid )
1188  {
1189  QgsDebugMsgLevel( QStringLiteral( "Invalid mesh provider plugin %1" ).arg( QString( mDataSource.toUtf8() ) ), 2 );
1190  return false;
1191  }
1192 
1193  setCrs( mDataProvider->crs() );
1194 
1195  if ( provider == QStringLiteral( "mesh_memory" ) )
1196  {
1197  // required so that source differs between memory layers
1198  mDataSource = mDataSource + QStringLiteral( "&uid=%1" ).arg( QUuid::createUuid().toString() );
1199  }
1200 
1201  for ( int i = 0; i < mDataProvider->datasetGroupCount(); ++i )
1202  assignDefaultStyleToDatasetGroup( i );
1203 
1204  connect( mDataProvider, &QgsMeshDataProvider::dataChanged, this, &QgsMeshLayer::dataChanged );
1205  connect( mDataProvider, &QgsMeshDataProvider::datasetGroupsAdded, this, &QgsMeshLayer::onDatasetGroupsAdded );
1206 
1207  return true;
1208 }
1209 
1211 {
1212  return mTemporalProperties;
1213 }
QgsMeshDatasetGroupMetadata::minimum
double minimum() const
Returns minimum scalar value/vector magnitude present for whole dataset group.
Definition: qgsmeshdataset.cpp:174
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
Definition: qgsmeshrenderersettings.h:410
QgsMeshLayer::createMapRenderer
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
Definition: qgsmeshlayer.cpp:914
QgsMeshDataProviderTemporalCapabilities::temporalUnit
QgsUnitTypes::TemporalUnit temporalUnit() const
Returns the temporal unit used to read data by the data provider.
Definition: qgsmeshdataprovidertemporalcapabilities.cpp:154
qgsmesh3daveraging.h
QgsColorRamp
Abstract base class for color ramps.
Definition: qgscolorramp.h:31
QgsMapLayer::readCommonStyle
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types.
Definition: qgsmaplayer.cpp:1619
QgsMeshDatasetSourceInterface::datasetValue
virtual QgsMeshDatasetValue datasetValue(QgsMeshDatasetIndex index, int valueIndex) const =0
Returns vector/scalar value associated with the index from the dataset To read multiple continuous va...
QgsColorRampShader::EqualInterval
@ EqualInterval
Uses equal interval.
Definition: qgscolorrampshader.h:56
QgsPoint::distance
double distance(double x, double y) const
Returns the Cartesian 2D distance between this point and a specified x, y coordinate.
Definition: qgspoint.h:350
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:373
QgsMeshLayer::setTransformContext
void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext.
Definition: qgsmeshlayer.cpp:432
QgsPointXY::y
double y
Definition: qgspointxy.h:48
QgsCoordinateTransformContext
Definition: qgscoordinatetransformcontext.h:57
QgsMeshRendererScalarSettings::setClassificationMinimumMaximum
void setClassificationMinimumMaximum(double minimum, double maximum)
Sets min/max values used for creation of the color ramp shader.
Definition: qgsmeshrenderersettings.cpp:95
QgsMeshDatasetGroupMetadata::DataOnVolumes
@ DataOnVolumes
Data is defined on volumes.
Definition: qgsmeshdataset.h:357
QgsMeshLayer::setReferenceTime
void setReferenceTime(const QDateTime &referenceTime)
Sets the reference time of the layer.
Definition: qgsmeshlayer.cpp:643
QgsTriangularMesh::vertices
const QVector< QgsMeshVertex > & vertices() const
Returns vertices in map coordinate system.
Definition: qgstriangularmesh.cpp:287
QgsMeshTimeSettings
Definition: qgsmeshtimesettings.h:35
QgsMeshRendererSettings
Definition: qgsmeshrenderersettings.h:590
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:104
QgsPainting::BlendMode
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
Definition: qgspainting.h:49
QgsMapLayerType::MeshLayer
@ MeshLayer
Added in 3.2.
QgsColorRampShader::setClassificationMode
void setClassificationMode(ClassificationMode classificationMode)
Sets classification mode.
Definition: qgscolorrampshader.h:184
QgsReadWriteContext
Definition: qgsreadwritecontext.h:34
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:395
QgsMeshLayer::setMeshSimplificationSettings
void setMeshSimplificationSettings(const QgsMeshSimplificationSettings &meshSimplificationSettings)
Sets mesh simplification settings.
Definition: qgsmeshlayer.cpp:857
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:750
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
QgsMeshRendererMeshSettings
Definition: qgsmeshrenderersettings.h:41
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsMapLayer::isValid
bool isValid() const
Returns the status of the layer.
Definition: qgsmaplayer.cpp:656
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
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:1013
QgsMapLayer::mReadFlags
QgsMapLayer::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when restoring state from XML.
Definition: qgsmaplayer.h:1572
qgsreadwritecontext.h
QgsTriangularMesh::faceCentroids
const QVector< QgsMeshVertex > & faceCentroids() const
Returns centroids of the native faces in map CRS.
Definition: qgstriangularmesh.cpp:307
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
QgsMeshLayer::setTimeSettings
void setTimeSettings(const QgsMeshTimeSettings &settings)
Sets time format settings.
Definition: qgsmeshlayer.cpp:289
QgsMeshLayer::datasetGroupTreeRootItem
QgsMeshDatasetGroupTreeItem * datasetGroupTreeRootItem() const
Returns the root items of the dataset group tree item.
Definition: qgsmeshlayer.cpp:593
QgsMeshLayer::reload
void reload() override
Synchronises with changes in the datasource.
Definition: qgsmeshlayer.cpp:1141
QgsMeshDataSourceInterface::populateMesh
virtual void populateMesh(QgsMesh *mesh) const =0
Populates the mesh vertices, edges and faces.
QgsMeshDatasetValue
Definition: qgsmeshdataset.h:76
QgsMapLayerType
QgsMapLayerType
Definition: qgsmaplayer.h:67
QgsMeshLayer::rendererCache
QgsMeshLayerRendererCache * rendererCache()
Returns native mesh (nullptr before rendering)
Definition: qgsmeshlayer.cpp:258
QgsMeshLayer::meshSimplificationSettings
QgsMeshSimplificationSettings meshSimplificationSettings() const
Returns mesh simplification settings.
Definition: qgsmeshlayer.cpp:852
QgsMeshDatasetGroupTreeItem::isEnabled
bool isEnabled() const
Definition: qgsmeshdataset.cpp:577
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:1092
QgsRenderContext
Definition: qgsrendercontext.h:57
QgsMeshLayerTemporalProperties
Definition: qgsmeshlayertemporalproperties.h:51
QgsMeshDatasetGroupTreeItem
Definition: qgsmeshdataset.h:546
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:830
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:651
QgsMeshLayerTemporalProperties::setMatchingMethod
void setMatchingMethod(const QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod &matchingMethod)
Sets the method used to match dataset from temporal capabilities.
Definition: qgsmeshlayertemporalproperties.cpp:111
QgsMesh
Definition: qgsmeshdataprovider.h:57
QgsMeshLayer::subLayers
QStringList subLayers() const override
Returns the sublayers of this layer.
Definition: qgsmeshlayer.cpp:1161
QgsDebugMsg
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
QgsUnitTypes::TemporalUnit
TemporalUnit
Temporal units.
Definition: qgsunittypes.h:149
QgsDataProvider::dataChanged
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
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
Definition: qgscolorrampshader.h:39
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:769
QgsMeshLayer::triangularMesh
QgsTriangularMesh * triangularMesh(double minimumTriangleSize=0) const
Returns triangular mesh (nullptr before rendering or calling to updateMesh).
Definition: qgsmeshlayer.cpp:224
QgsRectangle
Definition: qgsrectangle.h:41
QgsMeshLayer::datasetValue
QgsMeshDatasetValue datasetValue(const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius=0) const
Interpolates the value on the given point from given dataset.
Definition: qgsmeshlayer.cpp:303
QgsMeshRendererScalarSettings::setEdgeStrokeWidth
void setEdgeStrokeWidth(const QgsInterpolatedLineWidth &strokeWidth)
Sets the stroke width used to render edges scalar dataset.
Definition: qgsmeshrenderersettings.cpp:176
QgsMesh3dDataBlock
Definition: qgsmeshdataset.h:243
QgsMapLayer::mShouldValidateCrs
bool mShouldValidateCrs
true if the layer's CRS should be validated and invalid CRSes are not permitted.
Definition: qgsmaplayer.h:1579
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:157
QgsMeshDataProviderTemporalCapabilities::FindClosestDatasetFromStartRangeTime
@ FindClosestDatasetFromStartRangeTime
Finds the closest dataset which have its time before the requested start range time.
Definition: qgsmeshdataprovidertemporalcapabilities.h:43
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:1567
QgsMeshDataProvider::temporalCapabilities
QgsMeshDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
Definition: qgsmeshdataprovider.cpp:28
QgsMeshLayer::LayerOptions
Setting options for loading mesh layers.
Definition: qgsmeshlayer.h:102
QgsDataProvider::transformContext
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
Definition: qgsdataprovider.cpp:74
QgsMapLayerRenderer
Definition: qgsmaplayerrenderer.h:50
QgsMeshDatasetGroupTreeItem::clone
QgsMeshDatasetGroupTreeItem * clone() const
Clones the item.
Definition: qgsmeshdataset.cpp:480
QgsStyle::defaultStyle
static QgsStyle * defaultStyle()
Returns default application-wide style.
Definition: qgsstyle.cpp:111
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:238
QgsMeshDataProviderTemporalCapabilities::datasetIndexClosestFromRelativeTime
QgsMeshDatasetIndex datasetIndexClosestFromRelativeTime(int group, qint64 timeSinceGlobalReference) const
Returns the closest dataset index from the timeSinceGlobalReference.
Definition: qgsmeshdataprovidertemporalcapabilities.cpp:24
QgsMeshLayer::rendererSettings
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
Definition: qgsmeshlayer.cpp:263
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:1003
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:1817
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:234
QgsRenderContext::coordinateTransform
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
Definition: qgsrendercontext.h:229
QgsMapLayer::FlagDontResolveLayers
@ FlagDontResolveLayers
Don't resolve layer paths or create data providers for layers.
Definition: qgsmaplayer.h:548
QgsPoint::y
double y
Definition: qgspoint.h:59
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:638
QgsPathResolver::writePath
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
Definition: qgspathresolver.cpp:187
QgsPointXY::sqrDistToSegment
double sqrDistToSegment(double x1, double y1, double x2, double y2, QgsPointXY &minDistPoint, double epsilon=DEFAULT_SEGMENT_EPSILON) const
Returns the minimum distance between this point and a segment.
Definition: qgspointxy.cpp:95
QgsMeshDatasetGroupMetadata::DataOnFaces
@ DataOnFaces
Data is defined on faces.
Definition: qgsmeshdataset.h:355
QgsMeshDatasetGroupMetadata::DataOnVertices
@ DataOnVertices
Data is defined on vertices.
Definition: qgsmeshdataset.h:356
QgsMapLayer::metadata
QgsLayerMetadata metadata
Definition: qgsmaplayer.h:87
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:438
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:38
QgsMapLayer::mValid
bool mValid
Indicates if the layer is valid and can be drawn.
Definition: qgsmaplayer.h:1518
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
qgsproviderregistry.h
QgsColorRampShader::ColorRampItem
Definition: qgscolorrampshader.h:85
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:64
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
Definition: qgsinterpolatedlinerenderer.h:110
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:295
QgsMeshDatasetIndex
Definition: qgsmeshdataset.h:45
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:284
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
Definition: qgsmeshlayer.h:94
QgsMeshLayer::setDatasetGroupTreeRootItem
void setDatasetGroupTreeRootItem(QgsMeshDatasetGroupTreeItem *rootItem)
Sets the root items of the dataset group tree item.
Definition: qgsmeshlayer.cpp:598
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:958
QgsPointXY::distance
double distance(double x, double y) const
Returns the distance between this point and a specified x, y coordinate.
Definition: qgspointxy.h:196
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:929
QgsMeshLayer::LayerOptions::skipCrsValidation
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
Definition: qgsmeshlayer.h:128
QgsInterpolatedLineColor
Definition: qgsinterpolatedlinerenderer.h:34
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:38
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
Definition: qgsmeshdataprovider.h:351
QgsMeshLayerTemporalProperties::referenceTime
QDateTime referenceTime() const
Returns the reference time.
Definition: qgsmeshlayertemporalproperties.cpp:89
QgsMeshLayer::nativeMesh
QgsMesh * nativeMesh()
Returns native mesh (nullptr before rendering or calling to updateMesh)
Definition: qgsmeshlayer.cpp:214
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:40
QgsMapLayerTemporalProperties
Definition: qgsmaplayertemporalproperties.h:42
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:1521
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:554
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:358
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:983
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:988
QgsMesh3dAveragingMethod
Definition: qgsmesh3daveraging.h:39
QgsMeshSimplificationSettings
Definition: qgsmeshsimplificationsettings.h:39
qgsstyle.h
QgsMeshLayer::activeScalarDatasetGroupChanged
void activeScalarDatasetGroupChanged(int index)
Emitted when active scalar group dataset is changed.
qgsmeshlayer.h
QgsPointXY
Definition: qgspointxy.h:43
QgsMeshDatasetGroupMetadata::dataType
DataType dataType() const
Returns whether dataset group data is defined on vertices or faces or volumes.
Definition: qgsmeshdataset.cpp:169
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:993
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:80
QgsPathResolver::readPath
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
Definition: qgspathresolver.cpp:35
QgsMeshRendererScalarSettings
Definition: qgsmeshrenderersettings.h:94
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:144
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:714
QgsMeshDatasetGroupMetadata
Definition: qgsmeshdataset.h:348
QgsInterpolatedLineWidth::setMaximumValue
void setMaximumValue(double maximumValue)
Sets the maximum value used to defined the variable width.
Definition: qgsinterpolatedlinerenderer.cpp:245
QgsUnitTypes::TemporalMilliseconds
@ TemporalMilliseconds
Milliseconds.
Definition: qgsunittypes.h:151
qgsmeshlayerrenderer.h
QgsMeshLayer::addDatasets
bool addDatasets(const QString &path, const QDateTime &defaultReferenceTime=QDateTime())
Add datasets to the mesh from file with path.
Definition: qgsmeshlayer.cpp:186
QgsMeshRendererScalarSettings::setDataResamplingMethod
void setDataResamplingMethod(const DataResamplingMethod &dataResamplingMethod)
Sets data interpolation method.
Definition: qgsmeshrenderersettings.cpp:110
QgsMeshDataProviderTemporalCapabilities::FindClosestDatasetBeforeStartRangeTime
@ FindClosestDatasetBeforeStartRangeTime
Definition: qgsmeshdataprovidertemporalcapabilities.h:42
QgsMapLayer::transformContext
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
Definition: qgsmaplayer.cpp:783
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:179
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:353
QgsMapLayer
Definition: qgsmaplayer.h:81
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.
QgsPointXY::x
double x
Definition: qgspointxy.h:47
QgsMeshDatasetSourceInterface::dataset3dValues
virtual QgsMesh3dDataBlock dataset3dValues(QgsMeshDatasetIndex index, int faceIndex, int count) const =0
Returns N vector/scalar values from the face index from the dataset for 3d stacked meshes.
QgsInterval
A representation of the interval between two datetime values.
Definition: qgsinterval.h:40
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:39
QgsMeshDataProviderTemporalCapabilities::datasetIndexClosestBeforeRelativeTime
QgsMeshDatasetIndex datasetIndexClosestBeforeRelativeTime(int group, qint64 timeSinceGlobalReference) const
Returns the last dataset whith time less than or equal to timeSinceGlobalReference.
Definition: qgsmeshdataprovidertemporalcapabilities.cpp:54
QgsMeshLayer::timeSettingsChanged
void timeSettingsChanged()
Emitted when time format is changed.
QgsMeshLayerRenderer
Definition: qgsmeshlayerrenderer.h:91
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:825
QgsMapLayer::name
QString name
Definition: qgsmaplayer.h:85
QgsMeshLayer::resetDatasetGroupTreeItem
void resetDatasetGroupTreeItem()
Reset the dataset group tree item to default from provider.
Definition: qgsmeshlayer.cpp:740
QgsMapLayerTemporalProperties::setDefaultsFromDataProviderTemporalCapabilities
virtual void setDefaultsFromDataProviderTemporalCapabilities(const QgsDataProviderTemporalCapabilities *capabilities)=0
Sets the layers temporal settings to appropriate defaults based on a provider's temporal capabilities...
QgsMeshDataProvider::datasetGroupsAdded
void datasetGroupsAdded(int count)
Emitted when some new dataset groups have been added.
QgsMeshRendererSettings::averagingMethod
QgsMesh3dAveragingMethod * averagingMethod() const
Returns averaging method for conversion of 3d stacked mesh data to 2d data.
Definition: qgsmeshrenderersettings.cpp:396
qgsmaplayerlegend.h
QgsGradientColorRamp::create
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsColorRamp from a map of properties.
Definition: qgscolorramp.cpp:53
QgsMeshDataBlock
Definition: qgsmeshdataset.h:134
QgsMeshDatasetGroupTreeItem::datasetGroupIndex
int datasetGroupIndex() const
Definition: qgsmeshdataset.cpp:572
QgsTriangularMesh
Definition: qgstriangularmesh.h:49
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:169
QgsRectangle::setMinimal
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
Definition: qgsrectangle.h:151
QgsMeshSimplificationSettings::writeXml
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a new DOM element.
Definition: qgsmeshsimplificationsettings.cpp:40
QgsInterpolatedLineRenderer
Definition: qgsinterpolatedlinerenderer.h:184
QgsMeshLayer::temporalProperties
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
Definition: qgsmeshlayer.cpp:1210
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:841
QgsMeshDatasetGroupMetadata::isVector
bool isVector() const
Returns whether dataset group has vector data.
Definition: qgsmeshdataset.cpp:149
QgsMeshLayerTemporalProperties::matchingMethod
QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod matchingMethod() const
Returns the method used to match dataset from temporal capabilities.
Definition: qgsmeshlayertemporalproperties.cpp:106
QgsMeshDataBlock::value
QgsMeshDatasetValue value(int index) const
Returns a value represented by the index For active flag the behavior is undefined.
Definition: qgsmeshdataset.cpp:259
QgsMeshLayer::providerType
QString providerType() const
Returns the provider type for this layer.
Definition: qgsmeshlayer.cpp:181
QgsMeshLayer::~QgsMeshLayer
~QgsMeshLayer() override
Definition: qgsmeshlayer.cpp:142
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:268
QgsCoordinateTransform
Definition: qgscoordinatetransform.h:52
QgsMesh3dAveragingMethod::calculate
QgsMeshDataBlock calculate(const QgsMesh3dDataBlock &block3d, QgsFeedback *feedback=nullptr) const
Calculated 2d block values from 3d stacked mesh values.
Definition: qgsmesh3daveraging.cpp:57
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
QgsMapLayer::setProviderType
void setProviderType(const QString &providerType)
Sets the providerType (provider key)
Definition: qgsmaplayer.cpp:1890
QgsMeshRendererSettings::setActiveScalarDatasetGroup
void setActiveScalarDatasetGroup(int activeScalarDatasetGroup)
Sets the active scalar dataset group.
Definition: qgsmeshrenderersettings.cpp:514
qgsmeshdataprovider.h
QgsMeshRendererSettings::readXml
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
Definition: qgsmeshrenderersettings.cpp:458
QgsMeshDatasetSourceInterface::datasetGroupMetadata
virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata(int groupIndex) const =0
Returns dataset group metadata.
QgsPoint::x
double x
Definition: qgspoint.h:58
QgsMeshLayer::dataProvider
QgsMeshDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
Definition: qgsmeshlayer.cpp:147
QgsMapLayer::setLegend
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
Definition: qgsmaplayer.cpp:1775
QgsMeshLayer::activeScalarDatasetAtTime
QgsMeshDatasetIndex activeScalarDatasetAtTime(const QgsDateTimeRange &timeRange) const
Returns dataset index from active scalar group depending on the time range.
Definition: qgsmeshlayer.cpp:546
QgsStyle::colorRamp
QgsColorRamp * colorRamp(const QString &name) const
Returns a new copy of the specified color ramp.
Definition: qgsstyle.cpp:396
QgsColorRampShader::ColorRampItem::value
double value
Definition: qgscolorrampshader.h:97
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:811
qgsmeshlayertemporalproperties.h
QgsDataProvider::isValid
virtual bool isValid() const =0
Returns true if this is a valid layer.
QgsDataProvider::subLayers
virtual QStringList subLayers() const
Sub-layers handled by this provider, in order from bottom to top.
Definition: qgsdataprovider.h:266
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:254
QgsDataProvider::crs
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
QgsMesh::Vertex
@ Vertex
Definition: qgsmeshdataprovider.h:66