QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
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 #include <QUrl>
23 
24 #include "qgscolorrampimpl.h"
25 #include "qgslogger.h"
26 #include "qgsmaplayerlegend.h"
27 #include "qgsmaplayerfactory.h"
28 #include "qgsmaplayerutils.h"
29 #include "qgsmeshdataprovider.h"
31 #include "qgsmeshlayer.h"
32 #include "qgsmeshlayerrenderer.h"
34 #include "qgsmeshlayerutils.h"
35 #include "qgsmeshtimesettings.h"
36 #include "qgspainting.h"
37 #include "qgsproviderregistry.h"
38 #include "qgsreadwritecontext.h"
39 #include "qgsstyle.h"
40 #include "qgstriangularmesh.h"
41 #include "qgsmesh3daveraging.h"
43 #include "qgsmesheditor.h"
44 #include "qgsmessagelog.h"
48 
49 QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
50  const QString &baseName,
51  const QString &providerKey,
52  const QgsMeshLayer::LayerOptions &options )
53  : QgsMapLayer( QgsMapLayerType::MeshLayer, baseName, meshLayerPath )
54  , mDatasetGroupStore( new QgsMeshDatasetGroupStore( this ) )
55  , mTemporalProperties( new QgsMeshLayerTemporalProperties( this ) )
56  , mElevationProperties( new QgsMeshLayerElevationProperties( this ) )
57 {
59 
60  const QgsDataProvider::ProviderOptions providerOptions { options.transformContext };
61  QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags();
62  if ( options.loadDefaultStyle )
63  {
65  }
67  {
69  }
70  setDataSourcePrivate( meshLayerPath, baseName, providerKey, providerOptions, flags );
73 
74  if ( isValid() && options.loadDefaultStyle )
75  {
76  bool result = false;
77  loadDefaultStyle( result );
78  }
79 
80  connect( mDatasetGroupStore.get(), &QgsMeshDatasetGroupStore::datasetGroupsAdded, this, &QgsMeshLayer::onDatasetGroupsAdded );
81 }
82 
83 void QgsMeshLayer::createSimplifiedMeshes()
84 {
85  if ( mSimplificationSettings.isEnabled() && !hasSimplifiedMeshes() )
86  {
87  const double reductionFactor = mSimplificationSettings.reductionFactor();
88 
89  QVector<QgsTriangularMesh *> simplifyMeshes =
90  mTriangularMeshes[0]->simplifyMesh( reductionFactor );
91 
92  for ( int i = 0; i < simplifyMeshes.count() ; ++i )
93  {
94  mTriangularMeshes.emplace_back( simplifyMeshes[i] );
95  }
96  }
97 }
98 
99 bool QgsMeshLayer::hasSimplifiedMeshes() const
100 {
101  //First mesh is the base mesh, so if size>1, there is no simplified meshes
102  return ( mTriangularMeshes.size() > 1 );
103 }
104 
106 {
107  delete mDataProvider;
108 }
109 
111 {
112  return mDataProvider;
113 }
114 
116 {
117  return mDataProvider;
118 }
119 
121 {
123  if ( mDataProvider )
124  {
125  options.transformContext = mDataProvider->transformContext();
126  }
127  QgsMeshLayer *layer = new QgsMeshLayer( source(), name(), mProviderKey, options );
128  QgsMapLayer::clone( layer );
129 
130  layer->mElevationProperties = mElevationProperties->clone();
131  layer->mElevationProperties->setParent( layer );
132 
133  return layer;
134 }
135 
137 {
138  if ( mMeshEditor )
139  return mMeshEditor->extent();
140 
141  if ( mDataProvider )
142  return mDataProvider->extent();
143  else
144  {
145  QgsRectangle rec;
146  rec.setMinimal();
147  return rec;
148  }
149 }
150 
152 {
153  return mProviderKey;
154 }
155 
157 {
158  if ( !mDataProvider )
159  return false;
160 
161  if ( mMeshEditor )
162  return true;
163 
164  const QgsMeshDriverMetadata driverMetadata = mDataProvider->driverMetadata();
165 
166  return driverMetadata.capabilities() & QgsMeshDriverMetadata::CanWriteMeshData;
167 }
168 
169 QString QgsMeshLayer::loadDefaultStyle( bool &resultFlag )
170 {
171  const QList<int> groupsList = datasetGroupsIndexes();
172 
173  for ( const int index : groupsList )
174  assignDefaultStyleToDatasetGroup( index );
175 
176 
177  QgsMeshRendererMeshSettings meshSettings;
178  if ( !groupsList.isEmpty() )
179  {
180  // Show data from the first dataset group
181  mRendererSettings.setActiveScalarDatasetGroup( 0 );
182  // If the first dataset group has nan min/max, display the mesh to avoid nothing displayed
184  if ( meta.maximum() == std::numeric_limits<double>::quiet_NaN() &&
185  meta.minimum() == std::numeric_limits<double>::quiet_NaN() )
186  meshSettings.setEnabled( true );
187  }
188  else
189  {
190  // show at least the mesh by default
191  meshSettings.setEnabled( true );
192  }
193 
194  mRendererSettings.setNativeMeshSettings( meshSettings );
195 
196  for ( const int i : groupsList )
197  {
198  assignDefaultStyleToDatasetGroup( i );
199 
200  // Sets default resample method for scalar dataset
202  QgsMeshRendererScalarSettings scalarSettings = mRendererSettings.scalarSettings( i );
203  switch ( meta.dataType() )
204  {
206  case QgsMeshDatasetGroupMetadata::DataOnVolumes: // data on volumes are averaged to 2D data on faces
208  break;
211  break;
213  break;
214  }
215 
216  //override color ramp if the values in the dataset group are classified
217  applyClassificationOnScalarSettings( meta, scalarSettings );
218 
219  mRendererSettings.setScalarSettings( i, scalarSettings );
220  }
221 
222  if ( !groupsList.isEmpty() )
223  {
224  emit rendererChanged();
226  }
227 
228  return QgsMapLayer::loadDefaultStyle( resultFlag );
229 }
230 
231 bool QgsMeshLayer::addDatasets( const QString &path, const QDateTime &defaultReferenceTime )
232 {
233  const bool isTemporalBefore = dataProvider()->temporalCapabilities()->hasTemporalCapabilities();
234  if ( mDatasetGroupStore->addPersistentDatasets( path ) )
235  {
236  mExtraDatasetUri.append( path );
237  QgsMeshLayerTemporalProperties *temporalProperties = qobject_cast< QgsMeshLayerTemporalProperties * >( mTemporalProperties );
238  if ( !isTemporalBefore && dataProvider()->temporalCapabilities()->hasTemporalCapabilities() )
239  {
241  dataProvider()->temporalCapabilities() );
242 
243  if ( ! temporalProperties->referenceTime().isValid() )
244  {
245  QDateTime referenceTime = defaultReferenceTime;
246  if ( !defaultReferenceTime.isValid() ) // If project reference time is invalid, use current date
247  referenceTime = QDateTime( QDate::currentDate(), QTime( 0, 0, 0 ), Qt::UTC );
248  temporalProperties->setReferenceTime( referenceTime, dataProvider()->temporalCapabilities() );
249  }
250 
251  mTemporalProperties->setIsActive( true );
252  }
253  emit dataSourceChanged();
254  return true;
255  }
256 
257  return false;
258 }
259 
261 {
262  if ( mDatasetGroupStore->addDatasetGroup( datasetGroup ) )
263  {
264  emit dataChanged();
265  return true;
266  }
267  return false;
268 }
269 
270 bool QgsMeshLayer::saveDataset( const QString &path, int datasetGroupIndex, QString driver )
271 {
272  return mDatasetGroupStore->saveDatasetGroup( path, datasetGroupIndex, driver );
273 }
274 
276 {
277  return mNativeMesh.get();
278 }
279 
280 const QgsMesh *QgsMeshLayer::nativeMesh() const
281 {
282  return mNativeMesh.get();
283 }
284 
285 QgsTriangularMesh *QgsMeshLayer::triangularMesh( double minimumTriangleSize ) const
286 {
287  for ( const std::unique_ptr<QgsTriangularMesh> &lod : mTriangularMeshes )
288  {
289  if ( lod && lod->averageTriangleSize() > minimumTriangleSize )
290  return lod.get();
291  }
292 
293  if ( !mTriangularMeshes.empty() )
294  return mTriangularMeshes.back().get();
295  else
296  return nullptr;
297 }
298 
300 {
301  return mTriangularMeshes.size();
302 }
303 
305 {
306  if ( mTriangularMeshes.empty() )
307  return nullptr;
308  if ( lodIndex < 0 )
309  return mTriangularMeshes.front().get();
310 
311  if ( lodIndex >= int( mTriangularMeshes.size() ) )
312  return mTriangularMeshes.back().get();
313 
314  return mTriangularMeshes.at( lodIndex ).get();
315 }
316 
318 {
319  // Native mesh
320  if ( !mNativeMesh )
321  {
322  // lazy loading of mesh data
323  fillNativeMesh();
324  }
325 
326  // Triangular mesh
327  if ( mTriangularMeshes.empty() )
328  {
329  QgsTriangularMesh *baseMesh = new QgsTriangularMesh;
330  mTriangularMeshes.emplace_back( baseMesh );
331  }
332 
333  if ( mTriangularMeshes[0].get()->update( mNativeMesh.get(), transform ) )
334  mTriangularMeshes.resize( 1 ); //if the base triangular mesh is effectivly updated, remove simplified meshes
335 
336  createSimplifiedMeshes();
337 }
338 
339 QgsMeshLayerRendererCache *QgsMeshLayer::rendererCache()
340 {
341  return mRendererCache.get();
342 }
343 
345 {
346  return mRendererSettings;
347 }
348 
350 {
351  const int oldActiveScalar = mRendererSettings.activeScalarDatasetGroup();
352  const int oldActiveVector = mRendererSettings.activeVectorDatasetGroup();
353  mRendererSettings = settings;
354 
355  if ( oldActiveScalar != mRendererSettings.activeScalarDatasetGroup() )
356  emit activeScalarDatasetGroupChanged( mRendererSettings.activeScalarDatasetGroup() );
357 
358  if ( oldActiveVector != mRendererSettings.activeVectorDatasetGroup() )
359  emit activeVectorDatasetGroupChanged( mRendererSettings.activeVectorDatasetGroup() );
360 
361  emit rendererChanged();
362  triggerRepaint();
363 }
364 
366 {
367  return mTimeSettings;
368 }
369 
371 {
372  mTimeSettings = settings;
373  emit timeSettingsChanged();
374 }
375 
376 QString QgsMeshLayer::formatTime( double hours )
377 {
378  if ( dataProvider() && dataProvider()->temporalCapabilities()->hasReferenceTime() )
379  return QgsMeshLayerUtils::formatTime( hours, mTemporalProperties->referenceTime(), mTimeSettings );
380  else
381  return QgsMeshLayerUtils::formatTime( hours, QDateTime(), mTimeSettings );
382 }
383 
385 {
386  return mDatasetGroupStore->datasetGroupCount();
387 }
388 
390 {
391  return mDatasetGroupStore->extraDatasetGroupCount();
392 }
393 
395 {
396  return mDatasetGroupStore->datasetGroupIndexes();
397 }
398 
400 {
401  return mDatasetGroupStore->enabledDatasetGroupIndexes();
402 }
403 
405 {
406  return mDatasetGroupStore->datasetGroupMetadata( index );
407 }
408 
410 {
411  return mDatasetGroupStore->datasetCount( index.group() );
412 }
413 
415 {
416  return mDatasetGroupStore->datasetMetadata( index );
417 }
418 
420 {
421  return mDatasetGroupStore->datasetValue( index, valueIndex );
422 }
423 
424 QgsMeshDataBlock QgsMeshLayer::datasetValues( const QgsMeshDatasetIndex &index, int valueIndex, int count ) const
425 {
426  return mDatasetGroupStore->datasetValues( index, valueIndex, count );
427 }
428 
429 QgsMesh3dDataBlock QgsMeshLayer::dataset3dValues( const QgsMeshDatasetIndex &index, int faceIndex, int count ) const
430 {
431  return mDatasetGroupStore->dataset3dValues( index, faceIndex, count );
432 }
433 
434 QgsMeshDataBlock QgsMeshLayer::areFacesActive( const QgsMeshDatasetIndex &index, int faceIndex, int count ) const
435 {
436  return mDatasetGroupStore->areFacesActive( index, faceIndex, count );
437 }
438 
439 bool QgsMeshLayer::isFaceActive( const QgsMeshDatasetIndex &index, int faceIndex ) const
440 {
441  return mDatasetGroupStore->isFaceActive( index, faceIndex );
442 }
443 
444 QgsMeshDatasetValue QgsMeshLayer::datasetValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius ) const
445 {
446  QgsMeshDatasetValue value;
447  const QgsTriangularMesh *mesh = triangularMesh();
448 
449  if ( mesh && index.isValid() )
450  {
451  if ( contains( QgsMesh::ElementType::Edge ) )
452  {
453  const QgsRectangle searchRectangle( point.x() - searchRadius, point.y() - searchRadius, point.x() + searchRadius, point.y() + searchRadius );
454  return dataset1dValue( index, point, searchRadius );
455  }
456  const int faceIndex = mesh->faceIndexForPoint_v2( point ) ;
457  if ( faceIndex >= 0 )
458  {
459  const int nativeFaceIndex = mesh->trianglesToNativeFaces().at( faceIndex );
461  if ( isFaceActive( index, nativeFaceIndex ) )
462  {
463  switch ( dataType )
464  {
466  {
467  value = datasetValue( index, nativeFaceIndex );
468  }
469  break;
470 
472  {
473  const QgsMeshFace &face = mesh->triangles()[faceIndex];
474  const int v1 = face[0], v2 = face[1], v3 = face[2];
475  const QgsPoint p1 = mesh->vertices()[v1], p2 = mesh->vertices()[v2], p3 = mesh->vertices()[v3];
476  const QgsMeshDatasetValue val1 = datasetValue( index, v1 );
477  const QgsMeshDatasetValue val2 = datasetValue( index, v2 );
478  const QgsMeshDatasetValue val3 = datasetValue( index, v3 );
479  const double x = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.x(), val2.x(), val3.x(), point );
480  double y = std::numeric_limits<double>::quiet_NaN();
481  const bool isVector = datasetGroupMetadata( index ).isVector();
482  if ( isVector )
483  y = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.y(), val2.y(), val3.y(), point );
484 
485  value = QgsMeshDatasetValue( x, y );
486  }
487  break;
488 
490  {
491  const QgsMesh3dAveragingMethod *avgMethod = mRendererSettings.averagingMethod();
492  if ( avgMethod )
493  {
494  const QgsMesh3dDataBlock block3d = dataset3dValues( index, nativeFaceIndex, 1 );
495  const QgsMeshDataBlock block2d = avgMethod->calculate( block3d );
496  if ( block2d.isValid() )
497  {
498  value = block2d.value( 0 );
499  }
500  }
501  }
502  break;
503 
504  default:
505  break;
506  }
507  }
508  }
509  }
510 
511  return value;
512 }
513 
515 {
516  QgsMesh3dDataBlock block3d;
517 
518  const QgsTriangularMesh *baseTriangularMesh = triangularMesh();
519 
520  if ( baseTriangularMesh && dataProvider() && dataProvider()->isValid() && index.isValid() )
521  {
524  {
525  const int faceIndex = baseTriangularMesh->faceIndexForPoint_v2( point );
526  if ( faceIndex >= 0 )
527  {
528  const int nativeFaceIndex = baseTriangularMesh->trianglesToNativeFaces().at( faceIndex );
529  block3d = dataset3dValues( index, nativeFaceIndex, 1 );
530  }
531  }
532  }
533  return block3d;
534 }
535 
536 QgsMeshDatasetValue QgsMeshLayer::dataset1dValue( const QgsMeshDatasetIndex &index, const QgsPointXY &point, double searchRadius ) const
537 {
538  QgsMeshDatasetValue value;
539  QgsPointXY projectedPoint;
540  const int selectedIndex = closestEdge( point, searchRadius, projectedPoint );
541  const QgsTriangularMesh *mesh = triangularMesh();
542  if ( selectedIndex >= 0 )
543  {
545  switch ( dataType )
546  {
548  {
549  value = datasetValue( index, selectedIndex );
550  }
551  break;
552 
554  {
555  const QgsMeshEdge &edge = mesh->edges()[selectedIndex];
556  const int v1 = edge.first, v2 = edge.second;
557  const QgsPoint p1 = mesh->vertices()[v1], p2 = mesh->vertices()[v2];
558  const QgsMeshDatasetValue val1 = datasetValue( index, v1 );
559  const QgsMeshDatasetValue val2 = datasetValue( index, v2 );
560  const double edgeLength = p1.distance( p2 );
561  const double dist1 = p1.distance( projectedPoint.x(), projectedPoint.y() );
562  value = QgsMeshLayerUtils::interpolateFromVerticesData( dist1 / edgeLength, val1, val2 );
563  }
564  break;
565  default:
566  break;
567  }
568  }
569 
570  return value;
571 }
572 
574 {
575  if ( mDataProvider )
576  mDataProvider->setTransformContext( transformContext );
578 }
579 
580 QgsMeshDatasetIndex QgsMeshLayer::datasetIndexAtTime( const QgsDateTimeRange &timeRange, int datasetGroupIndex ) const
581 {
582  if ( ! mTemporalProperties->isActive() )
583  return QgsMeshDatasetIndex( datasetGroupIndex, -1 );
584 
585  const QDateTime layerReferenceTime = mTemporalProperties->referenceTime();
586  QDateTime utcTime = timeRange.begin();
587  if ( utcTime.timeSpec() != Qt::UTC )
588  utcTime.setTimeSpec( Qt::UTC );
589  const qint64 startTime = layerReferenceTime.msecsTo( utcTime );
590 
591  return mDatasetGroupStore->datasetIndexAtTime( startTime, datasetGroupIndex, mTemporalProperties->matchingMethod() );
592 }
593 
594 QgsMeshDatasetIndex QgsMeshLayer::datasetIndexAtRelativeTime( const QgsInterval &relativeTime, int datasetGroupIndex ) const
595 {
596  return mDatasetGroupStore->datasetIndexAtTime( relativeTime.seconds() * 1000, datasetGroupIndex, mTemporalProperties->matchingMethod() );
597 }
598 
599 QList<QgsMeshDatasetIndex> QgsMeshLayer::datasetIndexInRelativeTimeInterval( const QgsInterval &startRelativeTime, const QgsInterval &endRelativeTime, int datasetGroupIndex ) const
600 {
601  qint64 usedRelativeTime1 = startRelativeTime.seconds() * 1000;
602  qint64 usedRelativeTime2 = endRelativeTime.seconds() * 1000;
603 
604  //adjust relative time if layer reference time is different from provider reference time
605  if ( mTemporalProperties->referenceTime().isValid() &&
606  mDataProvider &&
607  mDataProvider->isValid() &&
608  mTemporalProperties->referenceTime() != mDataProvider->temporalCapabilities()->referenceTime() )
609  {
610  usedRelativeTime1 = usedRelativeTime1 + mTemporalProperties->referenceTime().msecsTo( mDataProvider->temporalCapabilities()->referenceTime() );
611  usedRelativeTime2 = usedRelativeTime2 + mTemporalProperties->referenceTime().msecsTo( mDataProvider->temporalCapabilities()->referenceTime() );
612  }
613 
614  return mDatasetGroupStore->datasetIndexInTimeInterval( usedRelativeTime1, usedRelativeTime2, datasetGroupIndex );
615 }
616 
617 void QgsMeshLayer::applyClassificationOnScalarSettings( const QgsMeshDatasetGroupMetadata &meta, QgsMeshRendererScalarSettings &scalarSettings ) const
618 {
619  if ( meta.extraOptions().contains( QStringLiteral( "classification" ) ) )
620  {
621  QgsColorRampShader colorRampShader = scalarSettings.colorRampShader();
622  QgsColorRamp *colorRamp = colorRampShader.sourceColorRamp();
623  const QStringList classes = meta.extraOptions()[QStringLiteral( "classification" )].split( QStringLiteral( ";;" ) );
624 
625  QString units;
626  if ( meta.extraOptions().contains( QStringLiteral( "units" ) ) )
627  units = meta.extraOptions()[ QStringLiteral( "units" )];
628 
629  QVector<QVector<double>> bounds;
630  for ( const QString &classe : classes )
631  {
632  const QStringList boundsStr = classe.split( ',' );
633  QVector<double> bound;
634  for ( const QString &boundStr : boundsStr )
635  bound.append( boundStr.toDouble() );
636  bounds.append( bound );
637  }
638 
639  if ( ( bounds.count() == 1 && bounds.first().count() > 2 ) || // at least a class with two value
640  ( bounds.count() > 1 ) ) // or at least two classes
641  {
642  const QVector<double> firstClass = bounds.first();
643  const QVector<double> lastClass = bounds.last();
644  const double minValue = firstClass.count() > 1 ? ( firstClass.first() + firstClass.last() ) / 2 : firstClass.first();
645  const double maxValue = lastClass.count() > 1 ? ( lastClass.first() + lastClass.last() ) / 2 : lastClass.first();
646  const double diff = maxValue - minValue;
647  QList<QgsColorRampShader::ColorRampItem> colorRampItemlist;
648  for ( int i = 0; i < bounds.count(); ++i )
649  {
650  const QVector<double> &boundClass = bounds.at( i );
652  item.value = i + 1;
653  if ( !boundClass.isEmpty() )
654  {
655  const double scalarValue = ( boundClass.first() + boundClass.last() ) / 2;
656  item.color = colorRamp->color( ( scalarValue - minValue ) / diff );
657  if ( i != 0 && i < bounds.count() - 1 ) //The first and last labels are treated after
658  {
659  item.label = QString( ( "%1 - %2 %3" ) ).
660  arg( QString::number( boundClass.first() ) ).
661  arg( QString::number( boundClass.last() ) ).
662  arg( units );
663  }
664  }
665  colorRampItemlist.append( item );
666  }
667  //treat first and last labels
668  if ( firstClass.count() == 1 )
669  colorRampItemlist.first().label = QObject::tr( "below %1 %2" ).
670  arg( QString::number( firstClass.first() ) ).
671  arg( units );
672  else
673  {
674  colorRampItemlist.first().label = QString( ( "%1 - %2 %3" ) ).
675  arg( QString::number( firstClass.first() ) ).
676  arg( QString::number( firstClass.last() ) ).
677  arg( units );
678  }
679 
680  if ( lastClass.count() == 1 )
681  colorRampItemlist.last().label = QObject::tr( "above %1 %2" ).
682  arg( QString::number( lastClass.first() ) ).
683  arg( units );
684  else
685  {
686  colorRampItemlist.last().label = QString( ( "%1 - %2 %3" ) ).
687  arg( QString::number( lastClass.first() ) ).
688  arg( QString::number( lastClass.last() ) ).
689  arg( units );
690  }
691 
692  colorRampShader.setMinimumValue( 0 );
693  colorRampShader.setMaximumValue( colorRampItemlist.count() - 1 );
694  scalarSettings.setClassificationMinimumMaximum( 0, colorRampItemlist.count() - 1 );
695  colorRampShader.setColorRampItemList( colorRampItemlist );
696  colorRampShader.setColorRampType( QgsColorRampShader::Exact );
698  }
699 
700  scalarSettings.setColorRampShader( colorRampShader );
702  }
703 }
704 
705 QgsMeshDatasetIndex QgsMeshLayer::activeScalarDatasetAtTime( const QgsDateTimeRange &timeRange ) const
706 {
707  if ( mTemporalProperties->isActive() )
708  return datasetIndexAtTime( timeRange, mRendererSettings.activeScalarDatasetGroup() );
709  else
710  return QgsMeshDatasetIndex( mRendererSettings.activeScalarDatasetGroup(), mStaticScalarDatasetIndex );
711 }
712 
713 QgsMeshDatasetIndex QgsMeshLayer::activeVectorDatasetAtTime( const QgsDateTimeRange &timeRange ) const
714 {
715  if ( mTemporalProperties->isActive() )
716  return datasetIndexAtTime( timeRange, mRendererSettings.activeVectorDatasetGroup() );
717  else
718  return QgsMeshDatasetIndex( mRendererSettings.activeVectorDatasetGroup(), mStaticVectorDatasetIndex );
719 }
720 
721 void QgsMeshLayer::fillNativeMesh()
722 {
723  Q_ASSERT( !mNativeMesh );
724 
725  mNativeMesh.reset( new QgsMesh() );
726 
727  if ( !( dataProvider() && dataProvider()->isValid() ) )
728  return;
729 
730  dataProvider()->populateMesh( mNativeMesh.get() );
731 }
732 
733 void QgsMeshLayer::onDatasetGroupsAdded( const QList<int> &datasetGroupIndexes )
734 {
735  // assign default style to new dataset groups
736  for ( int datasetGroupIndex : datasetGroupIndexes )
737  {
738  if ( !mRendererSettings.hasSettings( datasetGroupIndex ) )
739  assignDefaultStyleToDatasetGroup( datasetGroupIndex );
740  }
741 
742  temporalProperties()->setIsActive( mDatasetGroupStore->hasTemporalCapabilities() );
743  emit rendererChanged();
744 }
745 
746 void QgsMeshLayer::onMeshEdited()
747 {
748  mRendererCache.reset( new QgsMeshLayerRendererCache() );
749  emit layerModified();
750  triggerRepaint();
751  trigger3DUpdate();
752 }
753 
755 {
756  return mDatasetGroupStore->datasetGroupTreeItem();
757 }
758 
760 {
761  mDatasetGroupStore->setDatasetGroupTreeItem( rootItem );
762  updateActiveDatasetGroups();
763 }
764 
765 int QgsMeshLayer::closestEdge( const QgsPointXY &point, double searchRadius, QgsPointXY &projectedPoint ) const
766 {
767  const QgsRectangle searchRectangle( point.x() - searchRadius, point.y() - searchRadius, point.x() + searchRadius, point.y() + searchRadius );
768  const QgsTriangularMesh *mesh = triangularMesh();
769  // search for the closest edge in search area from point
770  const QList<int> edgeIndexes = mesh->edgeIndexesForRectangle( searchRectangle );
771  int selectedIndex = -1;
772  if ( mesh->contains( QgsMesh::Edge ) &&
773  mDataProvider->isValid() )
774  {
775  double sqrMaxDistFromPoint = pow( searchRadius, 2 );
776  for ( const int edgeIndex : edgeIndexes )
777  {
778  const QgsMeshEdge &edge = mesh->edges().at( edgeIndex );
779  const QgsMeshVertex &vertex1 = mesh->vertices()[edge.first];
780  const QgsMeshVertex &vertex2 = mesh->vertices()[edge.second];
781  QgsPointXY projPoint;
782  const double sqrDist = point.sqrDistToSegment( vertex1.x(), vertex1.y(), vertex2.x(), vertex2.y(), projPoint );
783  if ( sqrDist < sqrMaxDistFromPoint )
784  {
785  selectedIndex = edgeIndex;
786  projectedPoint = projPoint;
787  sqrMaxDistFromPoint = sqrDist;
788  }
789  }
790  }
791 
792  return selectedIndex;
793 }
794 
796 {
797  return QgsMeshDatasetIndex( mRendererSettings.activeVectorDatasetGroup(), mStaticVectorDatasetIndex );
798 }
799 
800 void QgsMeshLayer::setReferenceTime( const QDateTime &referenceTime )
801 {
802  if ( auto *lDataProvider = dataProvider() )
803  mTemporalProperties->setReferenceTime( referenceTime, lDataProvider->temporalCapabilities() );
804  else
805  mTemporalProperties->setReferenceTime( referenceTime, nullptr );
806 }
807 
809 {
810  mTemporalProperties->setMatchingMethod( matchingMethod );
811 }
812 
813 QgsPointXY QgsMeshLayer::snapOnVertex( const QgsPointXY &point, double searchRadius )
814 {
815  const QgsTriangularMesh *mesh = triangularMesh();
816  QgsPointXY exactPosition;
817  if ( !mesh )
818  return exactPosition;
819  const QgsRectangle rectangle( point.x() - searchRadius, point.y() - searchRadius, point.x() + searchRadius, point.y() + searchRadius );
820  double maxDistance = searchRadius;
821  //attempt to snap on edges's vertices
822  const QList<int> edgeIndexes = mesh->edgeIndexesForRectangle( rectangle );
823  for ( const int edgeIndex : edgeIndexes )
824  {
825  const QgsMeshEdge &edge = mesh->edges().at( edgeIndex );
826  const QgsMeshVertex &vertex1 = mesh->vertices()[edge.first];
827  const QgsMeshVertex &vertex2 = mesh->vertices()[edge.second];
828  const double dist1 = point.distance( vertex1 );
829  const double dist2 = point.distance( vertex2 );
830  if ( dist1 < maxDistance )
831  {
832  maxDistance = dist1;
833  exactPosition = vertex1;
834  }
835  if ( dist2 < maxDistance )
836  {
837  maxDistance = dist2;
838  exactPosition = vertex2;
839  }
840  }
841 
842  //attempt to snap on face's vertices
843  const QList<int> faceIndexes = mesh->faceIndexesForRectangle( rectangle );
844  for ( const int faceIndex : faceIndexes )
845  {
846  const QgsMeshFace &face = mesh->triangles().at( faceIndex );
847  for ( int i = 0; i < 3; ++i )
848  {
849  const QgsMeshVertex &vertex = mesh->vertices()[face.at( i )];
850  const double dist = point.distance( vertex );
851  if ( dist < maxDistance )
852  {
853  maxDistance = dist;
854  exactPosition = vertex;
855  }
856  }
857  }
858 
859  return exactPosition;
860 }
861 
862 QgsPointXY QgsMeshLayer::snapOnEdge( const QgsPointXY &point, double searchRadius )
863 {
864  QgsPointXY projectedPoint;
865  closestEdge( point, searchRadius, projectedPoint );
866 
867  return projectedPoint;
868 }
869 
870 QgsPointXY QgsMeshLayer::snapOnFace( const QgsPointXY &point, double searchRadius )
871 {
872  const QgsTriangularMesh *mesh = triangularMesh();
873  QgsPointXY centroidPosition;
874  if ( !mesh )
875  return centroidPosition;
876  const QgsRectangle rectangle( point.x() - searchRadius, point.y() - searchRadius, point.x() + searchRadius, point.y() + searchRadius );
877  double maxDistance = std::numeric_limits<double>::max();
878 
879  const QList<int> faceIndexes = mesh->faceIndexesForRectangle( rectangle );
880  for ( const int faceIndex : faceIndexes )
881  {
882  const int nativefaceIndex = mesh->trianglesToNativeFaces().at( faceIndex );
883  if ( nativefaceIndex < 0 && nativefaceIndex >= mesh->faceCentroids().count() )
884  continue;
885  const QgsPointXY centroid = mesh->faceCentroids()[nativefaceIndex];
886  const double dist = point.distance( centroid );
887  if ( dist < maxDistance )
888  {
889  maxDistance = dist;
890  centroidPosition = centroid;
891  }
892  }
893 
894  return centroidPosition;
895 }
896 
898 {
899  mDatasetGroupStore->resetDatasetGroupTreeItem();
900  updateActiveDatasetGroups();
901 }
902 
904 {
905  if ( !mDataProvider )
906  return QgsInterval();
907  const int groupCount = mDataProvider->datasetGroupCount();
908  for ( int i = 0; i < groupCount; ++i )
909  {
910  const qint64 timeStep = mDataProvider->temporalCapabilities()->firstTimeStepDuration( i );
911  if ( timeStep > 0 )
913  }
914 
915  return QgsInterval();
916 }
917 
919 {
920  const qint64 time = mDatasetGroupStore->datasetRelativeTime( index );
921 
922  if ( time == INVALID_MESHLAYER_TIME )
923  return QgsInterval();
924  else
926 }
927 
929 {
930  return mDatasetGroupStore->datasetRelativeTime( index );
931 }
932 
933 static QString detailsErrorMessage( const QgsMeshEditingError &error )
934 {
935  QString message;
936 
937  switch ( error.errorType )
938  {
940  break;
942  message = QObject::tr( "Face %1 invalid" ).arg( error.elementIndex );
943  break;
945  message = QObject::tr( "Too many vertices for face %1" ).arg( error.elementIndex );
946  break;
948  message = QObject::tr( "Face %1 is flat" ).arg( error.elementIndex );
949  break;
951  message = QObject::tr( "Vertex %1 is a unique shared vertex" ).arg( error.elementIndex );
952  break;
954  message = QObject::tr( "Vertex %1 is invalid" ).arg( error.elementIndex );
955  break;
957  message = QObject::tr( "Face %1 is manifold" ).arg( error.elementIndex );
958  break;
959  }
960 
961  return message;
962 }
963 
965 {
966  if ( !supportsEditing() )
967  {
968  QgsMessageLog::logMessage( QObject::tr( "Mesh layer \"%1\" not support mesh editing" ).arg( name() ) );
969  return false;
970  }
971 
972  if ( mMeshEditor )
973  {
974  QgsMessageLog::logMessage( QObject::tr( "Mesh layer \"%1\" already in editing mode" ).arg( name() ) );
975  return false;
976  }
977 
978  mSimplificationSettings.setEnabled( false );
979 
980  updateTriangularMesh( transform );
981 
982  mMeshEditor = new QgsMeshEditor( this );
983 
984  const QgsMeshEditingError error = mMeshEditor->initialize();
985 
986  if ( error.errorType != Qgis::MeshEditingErrorType::NoError )
987  {
988  mMeshEditor->deleteLater();
989  mMeshEditor = nullptr;
990 
991  QgsMessageLog::logMessage( QObject::tr( "Unable to start editing of mesh layer \"%1\": %2" ).
992  arg( name(), detailsErrorMessage( error ) ), QString(), Qgis::MessageLevel::Critical );
993  return false;
994  }
995 
996  // During editing, we don't need anymore the provider data. Mesh frame data is stored in the mesh editor.
997  mDataProvider->close();
998 
999  // All dataset group are removed and replace by a unique virtual dataset group that provide vertices elevation value.
1000  mExtraDatasetUri.clear();
1001  mDatasetGroupStore.reset( new QgsMeshDatasetGroupStore( this ) );
1002  mDatasetGroupStore->addDatasetGroup( mMeshEditor->createZValueDatasetGroup() );
1004 
1005  connect( mMeshEditor, &QgsMeshEditor::meshEdited, this, &QgsMeshLayer::onMeshEdited );
1006 
1007  emit dataChanged();
1008  emit editingStarted();
1009 
1010  return true;
1011 }
1012 
1013 bool QgsMeshLayer::commitFrameEditing( const QgsCoordinateTransform &transform, bool continueEditing )
1014 {
1016  QString detailsError;
1017  if ( !mMeshEditor->checkConsistency( error ) )
1018  {
1019  if ( error.errorType == Qgis::MeshEditingErrorType::NoError )
1020  detailsError = tr( "Unknown inconsistent mesh error" );
1021  }
1022  else
1023  {
1024  error = QgsTopologicalMesh::checkTopology( *mNativeMesh, mMeshEditor->maximumVerticesPerFace() );
1025  detailsError = detailsErrorMessage( error );
1026  }
1027 
1028  if ( !detailsError.isEmpty() )
1029  {
1030  QgsMessageLog::logMessage( QObject::tr( "Edited mesh layer \"%1\" can't be save due to an error: %2" ).
1031  arg( name(), detailsError ), QString(), Qgis::MessageLevel::Critical );
1032  return false;
1033  }
1034 
1035  stopFrameEditing( transform );
1036 
1037  if ( !mDataProvider )
1038  return false;
1039 
1040  const bool res = mDataProvider->saveMeshFrame( *mNativeMesh.get() );
1041 
1042  if ( continueEditing )
1043  {
1044  mMeshEditor->initialize();
1045  emit layerModified();
1046  return res;
1047  }
1048 
1049  mMeshEditor->deleteLater();
1050  mMeshEditor = nullptr;
1051  emit editingStopped();
1052 
1053  mDataProvider->reloadData();
1054  mDataProvider->populateMesh( mNativeMesh.get() );
1055  mDatasetGroupStore.reset( new QgsMeshDatasetGroupStore( this ) );
1056  mDatasetGroupStore->setPersistentProvider( mDataProvider, QStringList() );
1058  return true;
1059 }
1060 
1061 bool QgsMeshLayer::rollBackFrameEditing( const QgsCoordinateTransform &transform, bool continueEditing )
1062 {
1063  stopFrameEditing( transform );
1064 
1065  if ( !mDataProvider )
1066  return false;
1067 
1068  mTriangularMeshes.clear();
1069  mDataProvider->reloadData();
1070  mDataProvider->populateMesh( mNativeMesh.get() );
1071  updateTriangularMesh( transform );
1072  mRendererCache.reset( new QgsMeshLayerRendererCache() );
1073  trigger3DUpdate();
1074 
1075  if ( continueEditing )
1076  {
1077  mMeshEditor->resetTriangularMesh( triangularMesh() );
1078  return mMeshEditor->initialize() == QgsMeshEditingError();
1079  }
1080  else
1081  {
1082  mMeshEditor->deleteLater();
1083  mMeshEditor = nullptr;
1084  emit editingStopped();
1085 
1086  mDatasetGroupStore.reset( new QgsMeshDatasetGroupStore( this ) );
1087  mDatasetGroupStore->setPersistentProvider( mDataProvider, QStringList() );
1089  emit dataChanged();
1090  return true;
1091  }
1092 }
1093 
1095 {
1096  if ( !mMeshEditor )
1097  return;
1098 
1099  mMeshEditor->stopEditing();
1100  mTriangularMeshes.at( 0 )->update( mNativeMesh.get(), transform );
1101  mRendererCache.reset( new QgsMeshLayerRendererCache() );
1102 }
1103 
1104 bool QgsMeshLayer::reindex( const QgsCoordinateTransform &transform, bool renumber )
1105 {
1106  if ( !mMeshEditor )
1107  return false;
1108 
1109  if ( !mMeshEditor->reindex( renumber ) )
1110  return false;
1111 
1112  mTriangularMeshes.clear();
1113  mTriangularMeshes.emplace_back( new QgsTriangularMesh );
1114  mTriangularMeshes.at( 0 )->update( mNativeMesh.get(), transform );
1115  mRendererCache.reset( new QgsMeshLayerRendererCache() );
1116  mMeshEditor->resetTriangularMesh( mTriangularMeshes.at( 0 ).get() );
1117 
1118  return true;
1119 }
1120 
1122 {
1123  return mMeshEditor;
1124 }
1125 
1127 {
1128  if ( mMeshEditor )
1129  return mMeshEditor->isModified();
1130 
1131  return false;
1132 }
1133 
1135 {
1136  switch ( type )
1137  {
1138  case QgsMesh::ElementType::Vertex:
1139  return meshVertexCount() != 0;
1140  case QgsMesh::ElementType::Edge:
1141  return meshEdgeCount() != 0;
1142  case QgsMesh::ElementType::Face:
1143  return meshFaceCount() != 0;
1144  }
1145  return false;
1146 }
1147 
1149 {
1150  if ( mMeshEditor )
1151  return mMeshEditor->validVerticesCount();
1152  else if ( mDataProvider )
1153  return mDataProvider->vertexCount();
1154  else return 0;
1155 }
1156 
1158 {
1159  if ( mMeshEditor )
1160  return mMeshEditor->validFacesCount();
1161  else if ( mDataProvider )
1162  return mDataProvider->faceCount();
1163  else return 0;
1164 }
1165 
1167 {
1168  if ( mMeshEditor )
1169  return mNativeMesh->edgeCount();
1170  else if ( mDataProvider )
1171  return mDataProvider->edgeCount();
1172  else return 0;
1173 }
1174 
1175 void QgsMeshLayer::updateActiveDatasetGroups()
1176 {
1177  QgsMeshDatasetGroupTreeItem *treeItem = mDatasetGroupStore->datasetGroupTreeItem();
1178 
1179  if ( !mDatasetGroupStore->datasetGroupTreeItem() )
1180  return;
1181 
1183  const int oldActiveScalar = settings.activeScalarDatasetGroup();
1184  const int oldActiveVector = settings.activeVectorDatasetGroup();
1185 
1186  QgsMeshDatasetGroupTreeItem *activeScalarItem =
1187  treeItem->childFromDatasetGroupIndex( oldActiveScalar );
1188 
1189  if ( !activeScalarItem && treeItem->childCount() > 0 && oldActiveScalar != -1 )
1190  activeScalarItem = treeItem->child( 0 );
1191 
1192  if ( activeScalarItem && !activeScalarItem->isEnabled() )
1193  {
1194  for ( int i = 0; i < treeItem->childCount(); ++i )
1195  {
1196  activeScalarItem = treeItem->child( i );
1197  if ( activeScalarItem->isEnabled() )
1198  break;
1199  else
1200  activeScalarItem = nullptr;
1201  }
1202  }
1203 
1204  if ( activeScalarItem )
1205  settings.setActiveScalarDatasetGroup( activeScalarItem->datasetGroupIndex() );
1206  else
1207  settings.setActiveScalarDatasetGroup( -1 );
1208 
1209  QgsMeshDatasetGroupTreeItem *activeVectorItem =
1210  treeItem->childFromDatasetGroupIndex( oldActiveVector );
1211 
1212  if ( !( activeVectorItem && activeVectorItem->isEnabled() ) )
1213  settings.setActiveVectorDatasetGroup( -1 );
1214 
1215  setRendererSettings( settings );
1216 
1217  if ( oldActiveScalar != settings.activeScalarDatasetGroup() )
1219  if ( oldActiveVector != settings.activeVectorDatasetGroup() )
1221 }
1222 
1223 void QgsMeshLayer::setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags )
1224 {
1225  mDataSource = dataSource;
1226  mLayerName = baseName;
1227  setProviderType( provider );
1228 
1229  if ( !mDataSource.isEmpty() && !provider.isEmpty() )
1230  setDataProvider( provider, options, flags );
1231 }
1232 
1233 QgsPointXY QgsMeshLayer::snapOnElement( QgsMesh::ElementType elementType, const QgsPointXY &point, double searchRadius )
1234 {
1235  switch ( elementType )
1236  {
1237  case QgsMesh::Vertex:
1238  return snapOnVertex( point, searchRadius );
1239  case QgsMesh::Edge:
1240  return snapOnEdge( point, searchRadius );
1241  case QgsMesh::Face:
1242  return snapOnFace( point, searchRadius );
1243  }
1244  return QgsPointXY(); // avoid warnings
1245 }
1246 
1248 {
1249  if ( !mNativeMesh )
1250  {
1251  // lazy loading of mesh data
1252  fillNativeMesh();
1253  }
1254 
1255  QList<int> ret;
1256 
1257  if ( !mNativeMesh )
1258  return ret;
1259 
1260  QgsExpressionContext context;
1261  std::unique_ptr<QgsExpressionContextScope> expScope( QgsExpressionContextUtils::meshExpressionScope( QgsMesh::Vertex ) );
1262  context.appendScope( expScope.release() );
1263  context.lastScope()->setVariable( QStringLiteral( "_mesh_layer" ), QVariant::fromValue( this ) );
1264 
1265  expression.prepare( &context );
1266 
1267  for ( int i = 0; i < mNativeMesh->vertexCount(); ++i )
1268  {
1269  context.lastScope()->setVariable( QStringLiteral( "_mesh_vertex_index" ), i, false );
1270 
1271  if ( expression.evaluate( &context ).toBool() )
1272  ret.append( i );
1273  }
1274 
1275  return ret;
1276 }
1277 
1279 {
1280  if ( !mNativeMesh )
1281  {
1282  // lazy loading of mesh data
1283  fillNativeMesh();
1284  }
1285 
1286  QList<int> ret;
1287 
1288  if ( !mNativeMesh )
1289  return ret;
1290 
1291  QgsExpressionContext context;
1292  std::unique_ptr<QgsExpressionContextScope> expScope( QgsExpressionContextUtils::meshExpressionScope( QgsMesh::Face ) );
1293  context.appendScope( expScope.release() );
1294  context.lastScope()->setVariable( QStringLiteral( "_mesh_layer" ), QVariant::fromValue( this ) );
1295 
1296  expression.prepare( &context );
1297 
1298  for ( int i = 0; i < mNativeMesh->faceCount(); ++i )
1299  {
1300  context.lastScope()->setVariable( QStringLiteral( "_mesh_face_index" ), i, false );
1301 
1302  if ( expression.evaluate( &context ).toBool() )
1303  ret.append( i );
1304  }
1305 
1306  return ret;
1307 }
1308 
1310 {
1311  return QgsMeshDatasetIndex( mRendererSettings.activeScalarDatasetGroup(), mStaticScalarDatasetIndex );
1312 }
1313 
1315 {
1316  const int oldActiveVector = mRendererSettings.activeVectorDatasetGroup();
1317 
1318  mStaticVectorDatasetIndex = staticVectorDatasetIndex.dataset();
1320 
1321  if ( oldActiveVector != mRendererSettings.activeVectorDatasetGroup() )
1322  emit activeVectorDatasetGroupChanged( mRendererSettings.activeVectorDatasetGroup() );
1323 }
1324 
1326 {
1327  const int oldActiveScalar = mRendererSettings.activeScalarDatasetGroup();
1328 
1329  mStaticScalarDatasetIndex = staticScalarDatasetIndex.dataset();
1331 
1332  if ( oldActiveScalar != mRendererSettings.activeScalarDatasetGroup() )
1333  emit activeScalarDatasetGroupChanged( mRendererSettings.activeScalarDatasetGroup() );
1334 }
1335 
1337 {
1338  return mSimplificationSettings;
1339 }
1340 
1342 {
1343  mSimplificationSettings = simplifySettings;
1344 }
1345 
1346 static QgsColorRamp *_createDefaultColorRamp()
1347 {
1348  QgsColorRamp *ramp = QgsStyle::defaultStyle()->colorRamp( QStringLiteral( "Plasma" ) );
1349  if ( ramp )
1350  return ramp;
1351 
1352  // definition of "Plasma" color ramp (in case it is not available in the style for some reason)
1353  QVariantMap props;
1354  props["color1"] = "13,8,135,255";
1355  props["color2"] = "240,249,33,255";
1356  props["stops"] =
1357  "0.0196078;27,6,141,255:0.0392157;38,5,145,255:0.0588235;47,5,150,255:0.0784314;56,4,154,255:0.0980392;65,4,157,255:"
1358  "0.117647;73,3,160,255:0.137255;81,2,163,255:0.156863;89,1,165,255:0.176471;97,0,167,255:0.196078;105,0,168,255:"
1359  "0.215686;113,0,168,255:0.235294;120,1,168,255:0.254902;128,4,168,255:0.27451;135,7,166,255:0.294118;142,12,164,255:"
1360  "0.313725;149,17,161,255:0.333333;156,23,158,255:0.352941;162,29,154,255:0.372549;168,34,150,255:0.392157;174,40,146,255:"
1361  "0.411765;180,46,141,255:0.431373;186,51,136,255:0.45098;191,57,132,255:0.470588;196,62,127,255:0.490196;201,68,122,255:"
1362  "0.509804;205,74,118,255:0.529412;210,79,113,255:0.54902;214,85,109,255:0.568627;218,91,105,255:0.588235;222,97,100,255:"
1363  "0.607843;226,102,96,255:0.627451;230,108,92,255:0.647059;233,114,87,255:0.666667;237,121,83,255:0.686275;240,127,79,255:"
1364  "0.705882;243,133,75,255:0.72549;245,140,70,255:0.745098;247,147,66,255:0.764706;249,154,62,255:0.784314;251,161,57,255:"
1365  "0.803922;252,168,53,255:0.823529;253,175,49,255:0.843137;254,183,45,255:0.862745;254,190,42,255:0.882353;253,198,39,255:"
1366  "0.901961;252,206,37,255:0.921569;251,215,36,255:0.941176;248,223,37,255:0.960784;246,232,38,255:0.980392;243,240,39,255";
1367  return QgsGradientColorRamp::create( props );
1368 }
1369 
1370 void QgsMeshLayer::assignDefaultStyleToDatasetGroup( int groupIndex )
1371 {
1373  const double groupMin = metadata.minimum();
1374  const double groupMax = metadata.maximum();
1375 
1376  QgsColorRampShader fcn( groupMin, groupMax, _createDefaultColorRamp() );
1377  fcn.classifyColorRamp( 5, -1, QgsRectangle(), nullptr );
1378 
1379  QgsMeshRendererScalarSettings scalarSettings;
1380  scalarSettings.setClassificationMinimumMaximum( groupMin, groupMax );
1381  scalarSettings.setColorRampShader( fcn );
1382  QgsInterpolatedLineWidth edgeStrokeWidth;
1383  edgeStrokeWidth.setMinimumValue( groupMin );
1384  edgeStrokeWidth.setMaximumValue( groupMax );
1385  const QgsInterpolatedLineColor edgeStrokeColor( fcn );
1386  const QgsInterpolatedLineRenderer edgeStrokePen;
1387  scalarSettings.setEdgeStrokeWidth( edgeStrokeWidth );
1388  mRendererSettings.setScalarSettings( groupIndex, scalarSettings );
1389 
1390  if ( metadata.isVector() )
1391  {
1392  QgsMeshRendererVectorSettings vectorSettings;
1393  vectorSettings.setColorRampShader( fcn );
1394  mRendererSettings.setVectorSettings( groupIndex, vectorSettings );
1395  }
1396 }
1397 
1399 {
1400  // Triangular mesh
1401  updateTriangularMesh( rendererContext.coordinateTransform() );
1402 
1403  // Build overview triangular meshes if needed
1404  createSimplifiedMeshes();
1405 
1406  // Cache
1407  if ( !mRendererCache )
1408  mRendererCache.reset( new QgsMeshLayerRendererCache() );
1409 
1410  return new QgsMeshLayerRenderer( this, rendererContext );
1411 }
1412 
1414 {
1415  return new QgsMeshLayerProfileGenerator( this, request );
1416 }
1417 
1418 bool QgsMeshLayer::readSymbology( const QDomNode &node, QString &errorMessage,
1419  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
1420 {
1421  Q_UNUSED( errorMessage )
1422  // TODO: implement categories for raster layer
1423 
1424  const QDomElement elem = node.toElement();
1425 
1426  readCommonStyle( elem, context, categories );
1427 
1428  const QDomElement elemRendererSettings = elem.firstChildElement( "mesh-renderer-settings" );
1429  if ( !elemRendererSettings.isNull() )
1430  mRendererSettings.readXml( elemRendererSettings, context );
1431 
1432  const QDomElement elemSimplifySettings = elem.firstChildElement( "mesh-simplify-settings" );
1433  if ( !elemSimplifySettings.isNull() )
1434  mSimplificationSettings.readXml( elemSimplifySettings, context );
1435 
1436  // get and set the blend mode if it exists
1437  const QDomNode blendModeNode = node.namedItem( QStringLiteral( "blendMode" ) );
1438  if ( !blendModeNode.isNull() )
1439  {
1440  const QDomElement e = blendModeNode.toElement();
1441  setBlendMode( QgsPainting::getCompositionMode( static_cast< QgsPainting::BlendMode >( e.text().toInt() ) ) );
1442  }
1443 
1444  // get and set the layer transparency
1445  if ( categories.testFlag( Rendering ) )
1446  {
1447  const QDomNode layerOpacityNode = node.namedItem( QStringLiteral( "layerOpacity" ) );
1448  if ( !layerOpacityNode.isNull() )
1449  {
1450  const QDomElement e = layerOpacityNode.toElement();
1451  setOpacity( e.text().toDouble() );
1452  }
1453  }
1454 
1455  return true;
1456 }
1457 
1458 bool QgsMeshLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1459  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
1460 {
1461  Q_UNUSED( errorMessage )
1462  // TODO: implement categories for raster layer
1463 
1464  QDomElement elem = node.toElement();
1465 
1466  writeCommonStyle( elem, doc, context, categories );
1467 
1468  const QDomElement elemRendererSettings = mRendererSettings.writeXml( doc, context );
1469  elem.appendChild( elemRendererSettings );
1470 
1471  const QDomElement elemSimplifySettings = mSimplificationSettings.writeXml( doc, context );
1472  elem.appendChild( elemSimplifySettings );
1473 
1474  // add blend mode node
1475  QDomElement blendModeElement = doc.createElement( QStringLiteral( "blendMode" ) );
1476  const QDomText blendModeText = doc.createTextNode( QString::number( QgsPainting::getBlendModeEnum( blendMode() ) ) );
1477  blendModeElement.appendChild( blendModeText );
1478  node.appendChild( blendModeElement );
1479 
1480  // add the layer opacity
1481  if ( categories.testFlag( Rendering ) )
1482  {
1483  QDomElement layerOpacityElem = doc.createElement( QStringLiteral( "layerOpacity" ) );
1484  const QDomText layerOpacityText = doc.createTextNode( QString::number( opacity() ) );
1485  layerOpacityElem.appendChild( layerOpacityText );
1486  node.appendChild( layerOpacityElem );
1487  }
1488 
1489  return true;
1490 }
1491 
1492 bool QgsMeshLayer::writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
1493 {
1494  return writeSymbology( node, doc, errorMessage, context, categories );
1495 }
1496 
1497 bool QgsMeshLayer::readStyle( const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
1498 {
1499  return readSymbology( node, errorMessage, context, categories );
1500 }
1501 
1502 QString QgsMeshLayer::decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const
1503 {
1504  QString src( source );
1505 
1506  QVariantMap uriParts = QgsProviderRegistry::instance()->decodeUri( provider, source );
1507  if ( uriParts.contains( QStringLiteral( "path" ) ) )
1508  {
1509  QString filePath = uriParts.value( QStringLiteral( "path" ) ).toString();
1510  filePath = context.pathResolver().readPath( filePath );
1511  uriParts.insert( QStringLiteral( "path" ), filePath );
1512  src = QgsProviderRegistry::instance()->encodeUri( provider, uriParts );
1513  }
1514 
1515  return src;
1516 }
1517 
1518 QString QgsMeshLayer::encodedSource( const QString &source, const QgsReadWriteContext &context ) const
1519 {
1520  QString src( source );
1521  QVariantMap uriParts = QgsProviderRegistry::instance()->decodeUri( mProviderKey, source );
1522  if ( uriParts.contains( QStringLiteral( "path" ) ) )
1523  {
1524  QString filePath = uriParts.value( QStringLiteral( "path" ) ).toString();
1525  filePath = context.pathResolver().writePath( filePath );
1526  uriParts.insert( QStringLiteral( "path" ), filePath );
1528  }
1529  return src;
1530 }
1531 
1532 bool QgsMeshLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &context )
1533 {
1534  QgsDebugMsgLevel( QStringLiteral( "Datasource in QgsMeshLayer::readXml: %1" ).arg( mDataSource.toLocal8Bit().data() ), 3 );
1535 
1536  //process provider key
1537  const QDomNode pkeyNode = layer_node.namedItem( QStringLiteral( "provider" ) );
1538 
1539  if ( pkeyNode.isNull() )
1540  {
1541  mProviderKey.clear();
1542  }
1543  else
1544  {
1545  const QDomElement pkeyElt = pkeyNode.toElement();
1546  mProviderKey = pkeyElt.text();
1547  }
1548 
1550  {
1551  return false;
1552  }
1553 
1554  const QgsDataProvider::ProviderOptions providerOptions;
1555  QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags();
1557  {
1559  }
1560 
1561  const QDomElement elemExtraDatasets = layer_node.firstChildElement( QStringLiteral( "extra-datasets" ) );
1562  if ( !elemExtraDatasets.isNull() )
1563  {
1564  QDomElement elemUri = elemExtraDatasets.firstChildElement( QStringLiteral( "uri" ) );
1565  while ( !elemUri.isNull() )
1566  {
1567  const QString uri = context.pathResolver().readPath( elemUri.text() );
1568  mExtraDatasetUri.append( uri );
1569  elemUri = elemUri.nextSiblingElement( QStringLiteral( "uri" ) );
1570  }
1571  }
1572 
1573  if ( pkeyNode.toElement().hasAttribute( QStringLiteral( "time-unit" ) ) )
1574  mTemporalUnit = static_cast<QgsUnitTypes::TemporalUnit>( pkeyNode.toElement().attribute( QStringLiteral( "time-unit" ) ).toInt() );
1575 
1576  // read dataset group store
1577  const QDomElement elemDatasetGroupsStore = layer_node.firstChildElement( QStringLiteral( "mesh-dataset-groups-store" ) );
1578  if ( elemDatasetGroupsStore.isNull() )
1580  else
1581  mDatasetGroupStore->readXml( elemDatasetGroupsStore, context );
1582 
1583  setDataProvider( mProviderKey, providerOptions, flags );
1584 
1585  QString errorMsg;
1586  readSymbology( layer_node, errorMsg, context );
1587 
1588  if ( !mTemporalProperties->timeExtent().begin().isValid() )
1590 
1591  // read static dataset
1592  const QDomElement elemStaticDataset = layer_node.firstChildElement( QStringLiteral( "static-active-dataset" ) );
1593  if ( elemStaticDataset.hasAttribute( QStringLiteral( "scalar" ) ) )
1594  {
1595  mStaticScalarDatasetIndex = elemStaticDataset.attribute( QStringLiteral( "scalar" ) ).toInt();
1596  }
1597  if ( elemStaticDataset.hasAttribute( QStringLiteral( "vector" ) ) )
1598  {
1599  mStaticVectorDatasetIndex = elemStaticDataset.attribute( QStringLiteral( "vector" ) ).toInt();
1600  }
1601 
1602  return isValid(); // should be true if read successfully
1603 }
1604 
1605 bool QgsMeshLayer::writeXml( QDomNode &layer_node, QDomDocument &document, const QgsReadWriteContext &context ) const
1606 {
1607  // first get the layer element so that we can append the type attribute
1608  QDomElement mapLayerNode = layer_node.toElement();
1609 
1610  if ( mapLayerNode.isNull() || ( QLatin1String( "maplayer" ) != mapLayerNode.nodeName() ) )
1611  {
1612  QgsDebugMsgLevel( QStringLiteral( "can't find <maplayer>" ), 2 );
1613  return false;
1614  }
1615 
1616  mapLayerNode.setAttribute( QStringLiteral( "type" ), QgsMapLayerFactory::typeToString( QgsMapLayerType::MeshLayer ) );
1617 
1618  // add provider node
1619  if ( mDataProvider )
1620  {
1621  QDomElement provider = document.createElement( QStringLiteral( "provider" ) );
1622  const QDomText providerText = document.createTextNode( providerType() );
1623  provider.appendChild( providerText );
1624  layer_node.appendChild( provider );
1625  provider.setAttribute( QStringLiteral( "time-unit" ), mDataProvider->temporalCapabilities()->temporalUnit() );
1626 
1627  const QStringList extraDatasetUris = mDataProvider->extraDatasets();
1628  QDomElement elemExtraDatasets = document.createElement( QStringLiteral( "extra-datasets" ) );
1629  for ( const QString &uri : extraDatasetUris )
1630  {
1631  const QString path = context.pathResolver().writePath( uri );
1632  QDomElement elemUri = document.createElement( QStringLiteral( "uri" ) );
1633  elemUri.appendChild( document.createTextNode( path ) );
1634  elemExtraDatasets.appendChild( elemUri );
1635  }
1636  layer_node.appendChild( elemExtraDatasets );
1637  }
1638 
1639  QDomElement elemStaticDataset = document.createElement( QStringLiteral( "static-active-dataset" ) );
1640  elemStaticDataset.setAttribute( QStringLiteral( "scalar" ), mStaticScalarDatasetIndex );
1641  elemStaticDataset.setAttribute( QStringLiteral( "vector" ), mStaticVectorDatasetIndex );
1642  layer_node.appendChild( elemStaticDataset );
1643 
1644  // write dataset group store if not in edting mode
1645  if ( !isEditable() )
1646  layer_node.appendChild( mDatasetGroupStore->writeXml( document, context ) );
1647 
1648  // renderer specific settings
1649  QString errorMsg;
1650  return writeSymbology( layer_node, document, errorMsg, context );
1651 }
1652 
1654 {
1655  if ( !mMeshEditor && mDataProvider && mDataProvider->isValid() )
1656  {
1657  mDataProvider->reloadData();
1658 
1659  //reload the mesh structure
1660  if ( !mNativeMesh )
1661  mNativeMesh.reset( new QgsMesh );
1662 
1663  dataProvider()->populateMesh( mNativeMesh.get() );
1664 
1665  //clear the TriangularMeshes
1666  mTriangularMeshes.clear();
1667 
1668  //clear the rendererCache
1669  mRendererCache.reset( new QgsMeshLayerRendererCache() );
1670  }
1671 }
1672 
1673 QStringList QgsMeshLayer::subLayers() const
1674 {
1675  if ( mDataProvider )
1676  return mDataProvider->subLayers();
1677  else
1678  return QStringList();
1679 }
1680 
1682 {
1683  const QgsLayerMetadataFormatter htmlFormatter( metadata() );
1684  QString myMetadata = QStringLiteral( "<html>\n<body>\n" );
1685 
1686  myMetadata += generalHtmlMetadata();
1687 
1688  // Begin Provider section
1689  myMetadata += QStringLiteral( "<h1>" ) + tr( "Information from provider" ) + QStringLiteral( "</h1>\n<hr>\n" );
1690  myMetadata += QLatin1String( "<table class=\"list-view\">\n" );
1691 
1692  // Extent
1693  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Extent" ) + QStringLiteral( "</td><td>" ) + extent().toString() + QStringLiteral( "</td></tr>\n" );
1694 
1695  // feature count
1696  QLocale locale = QLocale();
1697  locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
1698 
1699  if ( dataProvider() )
1700  {
1701  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
1702  + tr( "Vertex count" ) + QStringLiteral( "</td><td>" )
1703  + ( locale.toString( static_cast<qlonglong>( meshVertexCount() ) ) )
1704  + QStringLiteral( "</td></tr>\n" );
1705  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
1706  + tr( "Face count" ) + QStringLiteral( "</td><td>" )
1707  + ( locale.toString( static_cast<qlonglong>( meshFaceCount() ) ) )
1708  + QStringLiteral( "</td></tr>\n" );
1709  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
1710  + tr( "Edge count" ) + QStringLiteral( "</td><td>" )
1711  + ( locale.toString( static_cast<qlonglong>( meshEdgeCount() ) ) )
1712  + QStringLiteral( "</td></tr>\n" );
1713  myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" )
1714  + tr( "Dataset groups count" ) + QStringLiteral( "</td><td>" )
1715  + ( locale.toString( static_cast<qlonglong>( datasetGroupCount() ) ) )
1716  + QStringLiteral( "</td></tr>\n" );
1717  }
1718 
1719  // End Provider section
1720  myMetadata += QLatin1String( "</table>\n<br><br>" );
1721 
1722  // CRS
1723  myMetadata += crsHtmlMetadata();
1724 
1725  // identification section
1726  myMetadata += QStringLiteral( "<h1>" ) + tr( "Identification" ) + QStringLiteral( "</h1>\n<hr>\n" );
1727  myMetadata += htmlFormatter.identificationSectionHtml( );
1728  myMetadata += QLatin1String( "<br><br>\n" );
1729 
1730  // extent section
1731  myMetadata += QStringLiteral( "<h1>" ) + tr( "Extent" ) + QStringLiteral( "</h1>\n<hr>\n" );
1732  myMetadata += htmlFormatter.extentSectionHtml( isSpatial() );
1733  myMetadata += QLatin1String( "<br><br>\n" );
1734 
1735  // Start the Access section
1736  myMetadata += QStringLiteral( "<h1>" ) + tr( "Access" ) + QStringLiteral( "</h1>\n<hr>\n" );
1737  myMetadata += htmlFormatter.accessSectionHtml( );
1738  myMetadata += QLatin1String( "<br><br>\n" );
1739 
1740  // Start the contacts section
1741  myMetadata += QStringLiteral( "<h1>" ) + tr( "Contacts" ) + QStringLiteral( "</h1>\n<hr>\n" );
1742  myMetadata += htmlFormatter.contactsSectionHtml( );
1743  myMetadata += QLatin1String( "<br><br>\n" );
1744 
1745  // Start the links section
1746  myMetadata += QStringLiteral( "<h1>" ) + tr( "Links" ) + QStringLiteral( "</h1>\n<hr>\n" );
1747  myMetadata += htmlFormatter.linksSectionHtml( );
1748  myMetadata += QLatin1String( "<br><br>\n" );
1749 
1750  // Start the history section
1751  myMetadata += QStringLiteral( "<h1>" ) + tr( "History" ) + QStringLiteral( "</h1>\n<hr>\n" );
1752  myMetadata += htmlFormatter.historySectionHtml( );
1753  myMetadata += QLatin1String( "<br><br>\n" );
1754 
1755  myMetadata += QLatin1String( "\n</body>\n</html>\n" );
1756  return myMetadata;
1757 }
1758 
1760 {
1761  return mMeshEditor != nullptr;
1762 }
1763 
1764 bool QgsMeshLayer::setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags )
1765 {
1766  mDatasetGroupStore->setPersistentProvider( nullptr, QStringList() );
1767 
1768  delete mDataProvider;
1769  mProviderKey = provider;
1770  const QString dataSource = mDataSource;
1771 
1772  mDataProvider = qobject_cast<QgsMeshDataProvider *>( QgsProviderRegistry::instance()->createProvider( provider, dataSource, options, flags ) );
1773 
1774  if ( !mDataProvider )
1775  {
1776  QgsDebugMsgLevel( QStringLiteral( "Unable to get mesh data provider" ), 2 );
1777  return false;
1778  }
1779 
1780  mDataProvider->setParent( this );
1781  QgsDebugMsgLevel( QStringLiteral( "Instantiated the mesh data provider plugin" ), 2 );
1782 
1783  setValid( mDataProvider->isValid() );
1784  if ( !isValid() )
1785  {
1786  QgsDebugMsgLevel( QStringLiteral( "Invalid mesh provider plugin %1" ).arg( QString( mDataSource.toUtf8() ) ), 2 );
1787  return false;
1788  }
1789 
1790  if ( !mTemporalProperties->isValid() )
1791  {
1792  mTemporalProperties->setDefaultsFromDataProviderTemporalCapabilities( dataProvider()->temporalCapabilities() );
1793  }
1794 
1795  mDataProvider->setTemporalUnit( mTemporalUnit );
1796 
1797  mDatasetGroupStore->setPersistentProvider( mDataProvider, mExtraDatasetUri );
1798 
1799  setCrs( mDataProvider->crs() );
1800 
1801  if ( provider == QLatin1String( "mesh_memory" ) )
1802  {
1803  // required so that source differs between memory layers
1804  mDataSource = mDataSource + QStringLiteral( "&uid=%1" ).arg( QUuid::createUuid().toString() );
1805  }
1806 
1807  // set default style if required by flags or if the dataset group does not has a style yet
1808  for ( int i = 0; i < mDataProvider->datasetGroupCount(); ++i )
1809  {
1810  int globalIndex = mDatasetGroupStore->globalDatasetGroupIndexInSource( mDataProvider, i );
1811  if ( globalIndex != -1 &&
1812  ( !mRendererSettings.hasSettings( globalIndex ) || ( flags & QgsDataProvider::FlagLoadDefaultStyle ) ) )
1813  assignDefaultStyleToDatasetGroup( globalIndex );
1814  }
1815 
1816  emit rendererChanged();
1817  emitStyleChanged();
1818 
1819  connect( mDataProvider, &QgsMeshDataProvider::dataChanged, this, &QgsMeshLayer::dataChanged );
1820 
1821  return true;
1822 }
1823 
1825 {
1826  return mTemporalProperties;
1827 }
1828 
1830 {
1831  return mElevationProperties;
1832 }
QgsMeshLayer::datasetGroupsIndexes
QList< int > datasetGroupsIndexes() const
Returns the list of indexes of dataset groups handled by the layer.
Definition: qgsmeshlayer.cpp:394
QgsMeshDatasetGroupMetadata::minimum
double minimum() const
Returns minimum scalar value/vector magnitude present for whole dataset group.
Definition: qgsmeshdataset.cpp:177
QgsMeshDatasetIndex::dataset
int dataset() const
Returns a dataset index within group()
Definition: qgsmeshdataset.cpp:32
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:410
QgsMeshSimplificationSettings::setEnabled
void setEnabled(bool isEnabled)
Sets if the overview is active.
Definition: qgsmeshsimplificationsettings.cpp:25
QgsMeshLayer::createMapRenderer
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
Definition: qgsmeshlayer.cpp:1398
QgsMapLayer::crsHtmlMetadata
QString crsHtmlMetadata() const
Returns a HTML fragment containing the layer's CRS metadata, for use in the htmlMetadata() method.
Definition: qgsmaplayer.cpp:2372
QgsMeshDataProviderTemporalCapabilities::temporalUnit
QgsUnitTypes::TemporalUnit temporalUnit() const
Returns the temporal unit used to read data by the data provider.
Definition: qgsmeshdataprovidertemporalcapabilities.cpp:153
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:406
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:211
qgsmesh3daveraging.h
QgsMapLayer::emitStyleChanged
void emitStyleChanged()
Triggers an emission of the styleChanged() signal.
Definition: qgsmaplayer.cpp:2145
QgsMeshLayer::isModified
bool isModified() const override
Returns whether the mesh frame has been modified since the last save.
Definition: qgsmeshlayer.cpp:1126
QgsColorRamp
Abstract base class for color ramps.
Definition: qgscolorramp.h:29
QgsMapLayer::readCommonStyle
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types.
Definition: qgsmaplayer.cpp:1869
qgsexpressioncontextutils.h
qgscolorrampimpl.h
QgsColorRampShader::EqualInterval
@ EqualInterval
Uses equal interval.
Definition: qgscolorrampshader.h:59
QgsMeshEditor::createZValueDatasetGroup
QgsMeshDatasetGroup * createZValueDatasetGroup()
Creates and returns a scalar dataset group with value on vertex that is can be used to access the Z v...
Definition: qgsmesheditor.cpp:55
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:514
QgsMeshEditor::validVerticesCount
int validVerticesCount() const
Returns the count of valid vertices, that is non void vertices in the mesh.
Definition: qgsmesheditor.cpp:439
qgsmeshlayerprofilegenerator.h
QgsMeshLayer::setTransformContext
void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext.
Definition: qgsmeshlayer.cpp:573
qgsmeshdatasetgroupstore.h
QgsPointXY::y
double y
Definition: qgspointxy.h:63
QgsInterval::seconds
double seconds() const
Returns the interval duration in seconds.
Definition: qgsinterval.h:236
QgsCoordinateTransformContext
Contains information about the context in which a coordinate transform is executed.
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
QgsMapLayer::FlagTrustLayerMetadata
@ FlagTrustLayerMetadata
Trust layer metadata. Improves layer load time by skipping expensive checks like primary key unicity,...
Definition: qgsmaplayer.h:641
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:594
QgsMeshDatasetGroupMetadata::DataOnVolumes
@ DataOnVolumes
Data is defined on volumes.
Definition: qgsmeshdataset.h:360
QgsMeshLayer::setReferenceTime
void setReferenceTime(const QDateTime &referenceTime)
Sets the reference time of the layer.
Definition: qgsmeshlayer.cpp:800
QgsTriangularMesh::vertices
const QVector< QgsMeshVertex > & vertices() const
Returns vertices in map coordinate system.
Definition: qgstriangularmesh.cpp:352
QgsMapLayer::editingStopped
void editingStopped()
Emitted when edited changes have been successfully written to the data provider.
QgsMeshTimeSettings
Represents a mesh time settings for mesh datasets.
Definition: qgsmeshtimesettings.h:35
QgsExpressionContextScope::setVariable
void setVariable(const QString &name, const QVariant &value, bool isStatic=false)
Convenience method for setting a variable in the context scope by name name and value.
Definition: qgsexpressioncontext.cpp:83
QgsMeshLayer::meshEdgeCount
int meshEdgeCount() const
Returns the edges count of the mesh frame.
Definition: qgsmeshlayer.cpp:1166
QgsMeshLayer::startFrameEditing
bool startFrameEditing(const QgsCoordinateTransform &transform)
Starts edition of the mesh frame.
Definition: qgsmeshlayer.cpp:964
QgsMeshRendererSettings
Represents all mesh renderer settings.
Definition: qgsmeshrenderersettings.h:590
QgsDataProvider::ProviderOptions
Setting options for creating vector data providers.
Definition: qgsdataprovider.h:107
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
Mesh layer. Added in QGIS 3.2.
QgsMeshLayer::contains
bool contains(const QgsMesh::ElementType &type) const
Returns whether the mesh contains at mesh elements of given type.
Definition: qgsmeshlayer.cpp:1134
QgsColorRampShader::setClassificationMode
void setClassificationMode(ClassificationMode classificationMode)
Sets classification mode.
Definition: qgscolorrampshader.h:216
QgsReadWriteContext
The class is used as a container of context for various read/write operations on other objects.
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:536
Qgis::MeshEditingErrorType::FlatFace
@ FlatFace
A flat face is present.
QgsMeshLayer::saveDataset
bool saveDataset(const QString &path, int datasetGroupIndex, QString driver)
Saves datasets group on file with the specified driver.
Definition: qgsmeshlayer.cpp:270
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:360
QgsMeshLayer::setMeshSimplificationSettings
void setMeshSimplificationSettings(const QgsMeshSimplificationSettings &meshSimplificationSettings)
Sets mesh simplification settings.
Definition: qgsmeshlayer.cpp:1341
QgsMeshRendererSettings::setActiveVectorDatasetGroup
void setActiveVectorDatasetGroup(int activeVectorDatasetGroup)
Sets the active vector dataset group.
Definition: qgsmeshrenderersettings.cpp:522
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:903
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:48
QgsMeshRendererMeshSettings
Represents a mesh renderer settings for mesh object.
Definition: qgsmeshrenderersettings.h:41
QgsMeshDriverMetadata::CanWriteMeshData
@ CanWriteMeshData
If the driver can write mesh data on file.
Definition: qgsprovidermetadata.h:71
QgsDebugMsgLevel
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
QgsMapLayer::opacity
double opacity
Definition: qgsmaplayer.h:82
QgsMeshRendererSettings::setVectorSettings
void setVectorSettings(int groupIndex, const QgsMeshRendererVectorSettings &settings)
Sets new renderer settings.
Definition: qgsmeshrenderersettings.h:631
QgsMapLayerElevationProperties
Base class for storage of map layer elevation properties.
Definition: qgsmaplayerelevationproperties.h:41
QgsMeshUtils::centroid
CORE_EXPORT QgsMeshVertex centroid(const QgsMeshFace &face, const QVector< QgsMeshVertex > &vertices)
Returns the centroid of the face.
Definition: qgstriangularmesh.cpp:955
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:320
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:229
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:1532
QgsMapLayer::mReadFlags
QgsMapLayer::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when restoring state from XML.
Definition: qgsmaplayer.h:1987
qgsreadwritecontext.h
QgsTriangularMesh::faceCentroids
const QVector< QgsMeshVertex > & faceCentroids() const
Returns centroids of the native faces in map CRS.
Definition: qgstriangularmesh.cpp:372
QgsLayerMetadataFormatter
Class for metadata formatter.
Definition: qgslayermetadataformatter.h:33
QgsMesh::Face
@ Face
Definition: qgsmeshdataprovider.h:69
QgsMapLayerLegend::defaultMeshLegend
static QgsMapLayerLegend * defaultMeshLegend(QgsMeshLayer *ml)
Create new legend implementation for mesh layer.
Definition: qgsmaplayerlegend.cpp:64
QgsMeshLayer::LayerOptions::transformContext
QgsCoordinateTransformContext transformContext
Coordinate transform context.
Definition: qgsmeshlayer.h:120
QgsMeshLayerElevationProperties
Mesh layer specific subclass of QgsMapLayerElevationProperties.
Definition: qgsmeshlayerelevationproperties.h:37
QgsMeshLayer::setTimeSettings
void setTimeSettings(const QgsMeshTimeSettings &settings)
Sets time format settings.
Definition: qgsmeshlayer.cpp:370
QgsMeshLayer::datasetGroupTreeRootItem
QgsMeshDatasetGroupTreeItem * datasetGroupTreeRootItem() const
Returns the root items of the dataset group tree item.
Definition: qgsmeshlayer.cpp:754
QgsMeshLayer::reload
void reload() override
Synchronises with changes in the datasource.
Definition: qgsmeshlayer.cpp:1653
QgsMeshDataSourceInterface::populateMesh
virtual void populateMesh(QgsMesh *mesh) const =0
Populates the mesh vertices, edges and faces.
QgsMeshLayer::supportsEditing
bool supportsEditing() const override
Returns whether the layer supports editing or not.
Definition: qgsmeshlayer.cpp:156
QgsDataProvider::FlagTrustDataSource
@ FlagTrustDataSource
Trust datasource config (primary key unicity, geometry type and srid, etc). Improves provider load ti...
Definition: qgsdataprovider.h:123
QgsMeshDatasetValue
QgsMeshDatasetValue represents single dataset value.
Definition: qgsmeshdataset.h:79
QgsExpressionContext::lastScope
QgsExpressionContextScope * lastScope()
Returns the last scope added to the context.
Definition: qgsexpressioncontext.cpp:377
QgsMapLayerType
QgsMapLayerType
Types of layers that can be added to a map.
Definition: qgis.h:46
QgsProviderRegistry::encodeUri
QString encodeUri(const QString &providerKey, const QVariantMap &parts)
Reassembles a provider data source URI from its component paths (e.g.
Definition: qgsproviderregistry.cpp:564
QgsMeshLayer::rendererCache
QgsMeshLayerRendererCache * rendererCache()
Returns native mesh (nullptr before rendering)
Definition: qgsmeshlayer.cpp:339
QgsMeshLayer::meshSimplificationSettings
QgsMeshSimplificationSettings meshSimplificationSettings() const
Returns mesh simplification settings.
Definition: qgsmeshlayer.cpp:1336
QgsMeshDatasetGroupTreeItem::isEnabled
bool isEnabled() const
Definition: qgsmeshdataset.cpp:639
QgsAbstractProfileGenerator
Abstract base class for objects which generate elevation profiles.
Definition: qgsabstractprofilegenerator.h:392
QgsMeshLayer::stopFrameEditing
void stopFrameEditing(const QgsCoordinateTransform &transform)
Stops edition of the mesh, re-indexes the faces and vertices, rebuilds the triangular mesh and its sp...
Definition: qgsmeshlayer.cpp:1094
QgsMeshLayerTemporalProperties::isValid
bool isValid() const
Returns whether the instance is valid.
Definition: qgsmeshlayertemporalproperties.cpp:119
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:1605
QgsRenderContext
Contains information about the context of a rendering operation.
Definition: qgsrendercontext.h:59
QgsMeshLayerTemporalProperties
Implementation of map layer temporal properties for mesh layers.
Definition: qgsmeshlayertemporalproperties.h:51
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:172
QgsMeshDatasetGroupTreeItem
Tree item for display of the mesh dataset groups. Dataset group is set of datasets with the same name...
Definition: qgsmeshdataset.h:843
QgsLayerMetadataFormatter::contactsSectionHtml
QString contactsSectionHtml() const
Formats the "Contacts" section according to a metadata object.
Definition: qgslayermetadataformatter.cpp:50
QgsMapLayer::setBlendMode
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
Definition: qgsmaplayer.cpp:310
QgsTriangularMesh::triangles
const QVector< QgsMeshFace > & triangles() const
Returns triangles.
Definition: qgstriangularmesh.cpp:357
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:1314
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:808
QgsMeshLayer::rollBackFrameEditing
bool rollBackFrameEditing(const QgsCoordinateTransform &transform, bool continueEditing=true)
Rolls Back edition of the mesh frame.
Definition: qgsmeshlayer.cpp:1061
QgsMapLayer::isValid
bool isValid
Definition: qgsmaplayer.h:81
QgsMeshLayerTemporalProperties::setMatchingMethod
void setMatchingMethod(const QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod &matchingMethod)
Sets the method used to match dataset from temporal capabilities.
Definition: qgsmeshlayertemporalproperties.cpp:114
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:1673
QgsMapLayer::editingStarted
void editingStarted()
Emitted when editing on this layer has started.
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'...
qgsmeshlayerelevationproperties.h
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:439
QgsMeshLayer::reindex
bool reindex(const QgsCoordinateTransform &transform, bool renumber)
Re-indexes the faces and vertices, and renumber the indexes if renumber is true.
Definition: qgsmeshlayer.cpp:1104
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:419
QgsTriangularMesh::edgeIndexesForRectangle
QList< int > edgeIndexesForRectangle(const QgsRectangle &rectangle) const
Finds indexes of edges intersecting given bounding box It uses spatial indexing.
Definition: qgstriangularmesh.cpp:465
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:97
QgsColorRampShader
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Definition: qgscolorrampshader.h:42
QgsMeshSimplificationSettings::readXml
void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads configuration from the given DOM element.
Definition: qgsmeshsimplificationsettings.cpp:50
QgsMeshLayer::triangularMeshLevelOfDetailCount
int triangularMeshLevelOfDetailCount() const
Returns the count of levels of detail of the mesh simplification.
Definition: qgsmeshlayer.cpp:299
QgsMapLayer::setCrs
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
Definition: qgsmaplayer.cpp:937
QgsMeshLayer::triangularMesh
QgsTriangularMesh * triangularMesh(double minimumTriangleSize=0) const
Returns triangular mesh (nullptr before rendering or calling to updateMesh).
Definition: qgsmeshlayer.cpp:285
QgsRectangle
A rectangle specified with double values.
Definition: qgsrectangle.h:41
QgsMeshDatasetMetadata
QgsMeshDatasetMetadata is a collection of mesh dataset metadata such as whether the data is valid or ...
Definition: qgsmeshdataset.h:478
QgsMeshRendererScalarSettings::setEdgeStrokeWidth
void setEdgeStrokeWidth(const QgsInterpolatedLineWidth &strokeWidth)
Sets the stroke width used to render edges scalar dataset.
Definition: qgsmeshrenderersettings.cpp:174
QgsMesh3dDataBlock
QgsMesh3dDataBlock is a block of 3d stacked mesh data related N faces defined on base mesh frame.
Definition: qgsmeshdataset.h:246
QgsMeshLayer::LayerOptions::loadDefaultStyle
bool loadDefaultStyle
Set to true if the default layer style should be loaded.
Definition: qgsmeshlayer.h:126
QgsMapLayer::mShouldValidateCrs
bool mShouldValidateCrs
true if the layer's CRS should be validated and invalid CRSes are not permitted.
Definition: qgsmaplayer.h:1994
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:120
QgsMeshLayerTemporalProperties::timeExtent
QgsDateTimeRange timeExtent() const
Returns the time extent.
Definition: qgsmeshlayertemporalproperties.cpp:87
QgsMapLayer::mProviderKey
QString mProviderKey
Data provider key (name of the data provider)
Definition: qgsmaplayer.h:1982
QgsMeshDataProvider::temporalCapabilities
QgsMeshDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
Definition: qgsmeshdataprovider.cpp:29
QgsMeshDriverMetadata
Holds metadata about mesh driver.
Definition: qgsprovidermetadata.h:57
QgsMeshLayer::LayerOptions
Setting options for loading mesh layers.
Definition: qgsmeshlayer.h:106
QgsMapLayer::Rendering
@ Rendering
Rendering: scale visibility, simplify method, opacity.
Definition: qgsmaplayer.h:170
QgsDataProvider::transformContext
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
Definition: qgsdataprovider.cpp:81
QgsMapLayerRenderer
Base class for utility classes that encapsulate information necessary for rendering of map layers.
Definition: qgsmaplayerrenderer.h:54
QgsMeshLayer::datasetMetadata
QgsMeshDatasetMetadata datasetMetadata(const QgsMeshDatasetIndex &index) const
Returns the dataset metadata.
Definition: qgsmeshlayer.cpp:414
QgsMeshLayer::extraDatasetGroupCount
int extraDatasetGroupCount() const
Returns the extra dataset groups count handle by the layer.
Definition: qgsmeshlayer.cpp:389
QgsLayerMetadataFormatter::linksSectionHtml
QString linksSectionHtml() const
Formats the "Links" section according to a metadata object.
Definition: qgslayermetadataformatter.cpp:255
QgsStyle::defaultStyle
static QgsStyle * defaultStyle()
Returns default application-wide style.
Definition: qgsstyle.cpp:145
QgsMeshEditor
Class that makes edit operation on a mesh.
Definition: qgsmesheditor.h:67
qgsmaplayerfactory.h
QgsPainting::getBlendModeEnum
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
Definition: qgspainting.cpp:80
QgsMapLayer::mLayerName
QString mLayerName
Name of the layer - used for display.
Definition: qgsmaplayer.h:1944
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:317
QgsMeshLayer::selectFacesByExpression
QList< int > selectFacesByExpression(QgsExpression expression)
Returns a list of faces indexes that meet the condition defined by expression with the context expres...
Definition: qgsmeshlayer.cpp:1278
QgsMeshRendererSettings::writeXml
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context=QgsReadWriteContext()) const
Writes configuration to a new DOM element.
Definition: qgsmeshrenderersettings.cpp:407
QgsMeshLayer::rendererSettings
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
Definition: qgsmeshlayer.cpp:344
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:1518
QgsMeshDatasetGroupStore
Class used to register and access all the dataset groups related to a mesh layer.
Definition: qgsmeshdatasetgroupstore.h:119
QgsMeshEditor::stopEditing
void stopEditing()
Stops editing.
Definition: qgsmesheditor.cpp:766
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:2114
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:289
QgsRenderContext::coordinateTransform
QgsCoordinateTransform coordinateTransform() const
Returns the current coordinate transform for the context.
Definition: qgsrendercontext.h:178
QgsMapLayer::FlagDontResolveLayers
@ FlagDontResolveLayers
Don't resolve layer paths or create data providers for layers.
Definition: qgsmaplayer.h:640
QgsPoint::y
double y
Definition: qgspoint.h:70
qgsmeshtimesettings.h
QgsMeshLayer::meshVertexCount
int meshVertexCount() const
Returns the vertices count of the mesh frame.
Definition: qgsmeshlayer.cpp:1148
QgsMeshLayer::staticVectorDatasetIndex
QgsMeshDatasetIndex staticVectorDatasetIndex() const
Returns the static vector dataset index that is rendered if the temporal properties is not active.
Definition: qgsmeshlayer.cpp:795
QgsMapLayer::flags
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
Definition: qgsmaplayer.cpp:150
QgsPathResolver::writePath
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
Definition: qgspathresolver.cpp:225
QgsMapLayerFactory::typeToString
static QString typeToString(QgsMapLayerType type)
Converts a map layer type to a string value.
Definition: qgsmaplayerfactory.cpp:51
QgsMeshEditor::isModified
bool isModified() const
Returns whether the mesh has been modified.
Definition: qgsmesheditor.cpp:962
QgsMeshDatasetGroupMetadata::DataOnFaces
@ DataOnFaces
Data is defined on faces.
Definition: qgsmeshdataset.h:358
QgsMeshDatasetGroupMetadata::DataOnVertices
@ DataOnVertices
Data is defined on vertices.
Definition: qgsmeshdataset.h:359
QgsMapLayer::metadata
QgsLayerMetadata metadata
Definition: qgsmaplayer.h:78
QgsColorRampShader::ColorRampItem::color
QColor color
Definition: qgscolorrampshader.h:118
QgsMeshLayer::datasetIndexAtTime
QgsMeshDatasetIndex datasetIndexAtTime(const QgsDateTimeRange &timeRange, int datasetGroupIndex) const
Returns dataset index from datasets group depending on the time range.
Definition: qgsmeshlayer.cpp:580
QgsMeshDataSourceInterface::saveMeshFrame
virtual bool saveMeshFrame(const QgsMesh &mesh)=0
Saves the mesh frame to the source.
QgsColorRampShader::setColorRampType
void setColorRampType(QgsColorRampShader::Type colorRampType)
Sets the color ramp type.
Definition: qgscolorrampshader.cpp:107
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsDataProvider::reloadData
virtual void reloadData()
Reloads the data from the source for providers with data caches to synchronize, changes in the data s...
Definition: qgsdataprovider.cpp:45
QgsMeshRendererSettings::activeScalarDatasetGroup
int activeScalarDatasetGroup() const
Returns the active scalar dataset group.
Definition: qgsmeshrenderersettings.cpp:507
QgsMeshDatasetIndex::group
int group() const
Returns a group index.
Definition: qgsmeshdataset.cpp:27
QgsColorRampShader::sourceColorRamp
QgsColorRamp * sourceColorRamp() const
Returns the source color ramp.
Definition: qgscolorrampshader.cpp:133
QgsMeshLayer::htmlMetadata
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
Definition: qgsmeshlayer.cpp:1681
qgsproviderregistry.h
QgsColorRampShader::ColorRampItem
Definition: qgscolorrampshader.h:105
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
QgsGradientColorRamp::create
static QgsColorRamp * create(const QVariantMap &properties=QVariantMap())
Creates a new QgsColorRamp from a map of properties.
Definition: qgscolorrampimpl.cpp:216
QgsMeshDriverMetadata::capabilities
MeshDriverCapabilities capabilities() const
Returns the capabilities for this driver.
Definition: qgsprovidermetadata.cpp:395
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
QgsDataProvider::FlagLoadDefaultStyle
@ FlagLoadDefaultStyle
Reset the layer's style to the default for the datasource.
Definition: qgsdataprovider.h:125
QgsColorRampShader::Exact
@ Exact
Assigns the color of the exact matching value in the color ramp item list.
Definition: qgscolorrampshader.h:52
QgsInterpolatedLineWidth
Represents a width than can vary depending on values.
Definition: qgsinterpolatedlinerenderer.h:126
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:429
QgsMeshDatasetGroupTreeItem::childCount
int childCount() const
Returns the count of children.
Definition: qgsmeshdataset.cpp:578
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:376
QgsMeshLayer::datasetRelativeTime
QgsInterval datasetRelativeTime(const QgsMeshDatasetIndex &index)
Returns the relative time of the dataset from the reference time of its group.
Definition: qgsmeshlayer.cpp:918
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:556
QgsMeshDatasetIndex
QgsMeshDatasetIndex is index that identifies the dataset group (e.g. wind speed) and a dataset in thi...
Definition: qgsmeshdataset.h:48
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:679
QgsMeshLayer::timeSettings
QgsMeshTimeSettings timeSettings() const
Returns time format settings.
Definition: qgsmeshlayer.cpp:365
QgsMeshLayer::selectVerticesByExpression
QList< int > selectVerticesByExpression(QgsExpression expression)
Returns a list of vertex indexes that meet the condition defined by expression with the context expre...
Definition: qgsmeshlayer.cpp:1247
QgsMeshRendererSettings::activeVectorDatasetGroup
int activeVectorDatasetGroup() const
Returns the active vector dataset group.
Definition: qgsmeshrenderersettings.cpp:517
QgsTriangularMesh::contains
bool contains(const QgsMesh::ElementType &type) const
Returns whether the mesh contains mesh elements of given type.
Definition: qgstriangularmesh.cpp:329
QgsMeshLayer
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:98
qgsmaplayerutils.h
QgsMeshLayer::setDatasetGroupTreeRootItem
void setDatasetGroupTreeRootItem(QgsMeshDatasetGroupTreeItem *rootItem)
Sets the root items of the dataset group tree item.
Definition: qgsmeshlayer.cpp:759
QgsTriangularMesh::edges
const QVector< QgsMeshEdge > & edges() const
Returns edges.
Definition: qgstriangularmesh.cpp:362
QgsMapLayer::generalHtmlMetadata
QString generalHtmlMetadata() const
Returns an HTML fragment containing general metadata information, for use in the htmlMetadata() metho...
Definition: qgsmaplayer.cpp:2303
QgsMeshLayer::writeSymbology
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const override
Definition: qgsmeshlayer.cpp:1458
QgsMeshEditor::validFacesCount
int validFacesCount() const
Returns the count of valid faces, that is non void faces in the mesh.
Definition: qgsmesheditor.cpp:434
QgsPainting::getCompositionMode
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Definition: qgspainting.cpp:20
QgsMeshEditor::extent
QgsRectangle extent() const
Returns the extent of the edited mesh.
Definition: qgsmesheditor.cpp:957
QgsMeshDatasetIndex::isValid
bool isValid() const
Returns whether index is valid, ie at least groups is set.
Definition: qgsmeshdataset.cpp:37
QgsRasterShaderFunction::setMaximumValue
virtual void setMaximumValue(double value)
Sets the maximum value for the raster shader.
Definition: qgsrastershaderfunction.cpp:30
QgsMeshLayer::meshFaceCount
int meshFaceCount() const
Returns the faces count of the mesh frame.
Definition: qgsmeshlayer.cpp:1157
QgsMeshLayer::readSymbology
bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) override
Definition: qgsmeshlayer.cpp:1418
QgsMeshLayer::LayerOptions::skipCrsValidation
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
Definition: qgsmeshlayer.h:141
QgsMapLayer::setOpacity
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
Definition: qgsmaplayer.cpp:325
QgsInterpolatedLineColor
Class defining color to render mesh datasets. The color can vary depending on the dataset value.
Definition: qgsinterpolatedlinerenderer.h:38
QgsMeshEditingError
Class that represents an error during mesh editing.
Definition: qgsmesheditor.h:42
QgsMeshDatasetValue::x
double x() const
Returns x value.
Definition: qgsmeshdataset.cpp:94
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:409
QgsMesh::Edge
@ Edge
Definition: qgsmeshdataprovider.h:68
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:177
qgspainting.h
QgsMeshDataProvider
Base class for providing data for QgsMeshLayer.
Definition: qgsmeshdataprovider.h:436
Qgis::MeshEditingErrorType::InvalidFace
@ InvalidFace
An error occurs due to an invalid face (for example, vertex indexes are unordered)
QgsMeshLayerTemporalProperties::referenceTime
QDateTime referenceTime() const
Returns the reference time.
Definition: qgsmeshlayertemporalproperties.cpp:92
QgsMapLayer::loadDefaultStyle
virtual QString loadDefaultStyle(bool &resultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
Definition: qgsmaplayer.cpp:1050
QgsMeshLayer::nativeMesh
QgsMesh * nativeMesh()
Returns native mesh (nullptr before rendering or calling to updateMesh)
Definition: qgsmeshlayer.cpp:275
QgsMeshEditor::initialize
QgsMeshEditingError initialize()
Initialize the mesh editor and return errors if the internal native mesh have topologic errors.
Definition: qgsmesheditor.cpp:64
QgsMessageLog::logMessage
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
Definition: qgsmessagelog.cpp:27
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:555
QgsProfileRequest
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
Definition: qgsprofilerequest.h:37
QgsMeshLayer::commitFrameEditing
bool commitFrameEditing(const QgsCoordinateTransform &transform, bool continueEditing=true)
Commits edition of the mesh frame, Rebuilds the triangular mesh and its spatial index with transform,...
Definition: qgsmeshlayer.cpp:1013
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:41
QgsMeshDataSourceInterface::edgeCount
virtual int edgeCount() const =0
Returns number of edges in the native mesh.
QgsMapLayerTemporalProperties
Base class for storage of map layer temporal properties.
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:68
QgsMapLayer::mDataSource
QString mDataSource
Data source description string, varies by layer type.
Definition: qgsmaplayer.h:1941
QgsColorRampShader::setColorRampItemList
void setColorRampItemList(const QList< QgsColorRampShader::ColorRampItem > &list)
Sets a custom colormap.
Definition: qgscolorrampshader.cpp:99
QgsMeshLayer::triangularMeshByLodIndex
QgsTriangularMesh * triangularMeshByLodIndex(int lodIndex) const
Returns triangular corresponding to the index of level of details.
Definition: qgsmeshlayer.cpp:304
QgsMeshRendererSettings::setNativeMeshSettings
void setNativeMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new native mesh renderer settings, triggers repaint.
Definition: qgsmeshrenderersettings.h:604
QgsMapLayer::layerModified
void layerModified()
Emitted when modifications has been done on layer.
Qgis::MeshEditingErrorType::InvalidVertex
@ InvalidVertex
An error occurs due to an invalid vertex (for example, vertex index is out of range the available ver...
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:713
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:928
QgsMeshDataSourceInterface::vertexCount
virtual int vertexCount() const =0
Returns number of vertices in the native mesh.
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:447
QgsMeshDatasetGroupMetadata::DataOnEdges
@ DataOnEdges
Data is defined on edges.
Definition: qgsmeshdataset.h:361
QgsMeshLayerProfileGenerator
Implementation of QgsAbstractProfileGenerator for mesh layers.
Definition: qgsmeshlayerprofilegenerator.h:69
QgsExpression::prepare
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
Definition: qgsexpression.cpp:327
QgsMeshFace
QVector< int > QgsMeshFace
List of vertex indexes.
Definition: qgsmeshdataprovider.h:42
QgsTemporalProperty::setIsActive
void setIsActive(bool active)
Sets whether the temporal property is active.
Definition: qgstemporalproperty.cpp:27
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:1492
QgsMeshLayerElevationProperties::clone
QgsMeshLayerElevationProperties * clone() const override
Creates a clone of the properties.
Definition: qgsmeshlayerelevationproperties.cpp:91
QgsMeshRendererScalarSettings::setColorRampShader
void setColorRampShader(const QgsColorRampShader &shader)
Sets color ramp shader function.
Definition: qgsmeshrenderersettings.cpp:86
qgsmesheditor.h
QgsExpression::evaluate
QVariant evaluate()
Evaluate the feature and return the result.
Definition: qgsexpression.cpp:350
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:1497
QgsMesh3dAveragingMethod
Abstract class to interpolate 3d stacked mesh data to 2d data.
Definition: qgsmesh3daveraging.h:39
QgsMeshDatasetGroup
Abstract class that represents a dataset group.
Definition: qgsmeshdataset.h:578
QgsMeshSimplificationSettings
Represents an overview renderer settings.
Definition: qgsmeshsimplificationsettings.h:39
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
QgsMeshEditor::resetTriangularMesh
void resetTriangularMesh(QgsTriangularMesh *triangularMesh)
Resets the triangular mesh.
Definition: qgsmesheditor.cpp:73
QgsExpressionContext::appendScope
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Definition: qgsexpressioncontext.cpp:494
qgsmeshlayer.h
QgsPointXY
A class to represent a 2D point.
Definition: qgspointxy.h:58
QgsMeshDatasetGroupMetadata::dataType
DataType dataType() const
Returns whether dataset group data is defined on vertices or faces or volumes.
Definition: qgsmeshdataset.cpp:172
QgsMeshEditingError::elementIndex
int elementIndex
Definition: qgsmesheditor.h:54
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:1502
QgsMapLayer::dataChanged
void dataChanged()
Data of layer changed.
QgsMeshLayer::enabledDatasetGroupsIndexes
QList< int > enabledDatasetGroupsIndexes() const
Returns the list of indexes of enables dataset groups handled by the layer.
Definition: qgsmeshlayer.cpp:399
QgsDataProvider::setTransformContext
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)
Sets data coordinate transform context to transformContext.
Definition: qgsdataprovider.cpp:87
QgsPathResolver::readPath
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
Definition: qgspathresolver.cpp:37
QgsMeshRendererScalarSettings
Represents a mesh renderer settings for scalar datasets.
Definition: qgsmeshrenderersettings.h:94
QgsMapLayer::source
QString source() const
Returns the source for the layer.
Definition: qgsmaplayer.cpp:300
QgsMeshRendererVectorSettings::setColorRampShader
void setColorRampShader(const QgsColorRampShader &colorRampShader)
Returns the color ramp shader used to render vector datasets.
Definition: qgsmeshrenderersettings.cpp:664
QgsTriangularMesh::faceIndexesForRectangle
QList< int > faceIndexesForRectangle(const QgsRectangle &rectangle) const
Finds indexes of triangles intersecting given bounding box It uses spatial indexing.
Definition: qgstriangularmesh.cpp:460
QgsMeshDataSourceInterface::faceCount
virtual int faceCount() const =0
Returns number of faces in the native mesh.
QgsMeshDatasetGroupMetadata::extraOptions
QMap< QString, QString > extraOptions() const
Returns extra metadata options, for example description.
Definition: qgsmeshdataset.cpp:147
QgsMeshDatasetGroupMetadata
QgsMeshDatasetGroupMetadata is a collection of dataset group metadata such as whether the data is vec...
Definition: qgsmeshdataset.h:351
QgsInterpolatedLineWidth::setMaximumValue
void setMaximumValue(double maximumValue)
Sets the maximum value used to defined the variable width.
Definition: qgsinterpolatedlinerenderer.cpp:300
QgsUnitTypes::TemporalMilliseconds
@ TemporalMilliseconds
Milliseconds.
Definition: qgsunittypes.h:151
qgsmeshlayerrenderer.h
QgsMeshDataProvider::driverMetadata
virtual QgsMeshDriverMetadata driverMetadata() const
Returns the mesh driver metadata of the provider.
Definition: qgsmeshdataprovider.cpp:47
QgsMeshLayer::addDatasets
bool addDatasets(const QString &path, const QDateTime &defaultReferenceTime=QDateTime())
Adds datasets to the mesh from file with path.
Definition: qgsmeshlayer.cpp:231
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:951
QgsExpressionContextUtils::meshExpressionScope
static QgsExpressionContextScope * meshExpressionScope(QgsMesh::ElementType elementType)
Creates a new scope which contains functions relating to mesh layer element elementType.
QgsMeshEdge
QPair< int, int > QgsMeshEdge
Edge is a straight line seqment between 2 points.
Definition: qgsmeshdataprovider.h:49
QgsMeshDatasetGroupMetadata::maximum
double maximum() const
Returns maximum scalar value/vector magnitude present for whole dataset group.
Definition: qgsmeshdataset.cpp:182
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:356
QgsMeshEditor::meshEdited
void meshEdited()
Emitted when the mesh is edited.
QgsMeshDataProvider::close
virtual void close()=0
Closes the data provider and free every resources used.
QgsMeshLayer::createProfileGenerator
QgsAbstractProfileGenerator * createProfileGenerator(const QgsProfileRequest &request) override
Given a profile request, returns a new profile generator ready for generating elevation profiles.
Definition: qgsmeshlayer.cpp:1413
QgsTopologicalMesh::checkTopology
static QgsMeshEditingError checkTopology(const QgsMesh &mesh, int maxVerticesPerFace)
Checks the topology of the mesh mesh, if error occurs, this mesh can't be edited.
Definition: qgstopologicalmesh.cpp:584
QgsMeshLayer::datasetIndexInRelativeTimeInterval
QList< QgsMeshDatasetIndex > datasetIndexInRelativeTimeInterval(const QgsInterval &startRelativeTime, const QgsInterval &endRelativeTime, int datasetGroupIndex) const
Returns a list of dataset indexes from datasets group that are in a interval time from the layer refe...
Definition: qgsmeshlayer.cpp:599
Qgis::MeshEditingErrorType::ManifoldFace
@ ManifoldFace
ManifoldFace.
QgsMapLayer
Base class for all map layer types. This is the base class for all map layer types (vector,...
Definition: qgsmaplayer.h:72
QgsTriangularMesh::trianglesToNativeFaces
const QVector< int > & trianglesToNativeFaces() const
Returns mapping between triangles and original faces.
Definition: qgstriangularmesh.cpp:382
QgsMeshLayer::loadDefaultStyle
QString loadDefaultStyle(bool &resultFlag) FINAL
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
Definition: qgsmeshlayer.cpp:169
QgsDataProvider::extent
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
QgsMapLayer::invalidateWgs84Extent
void invalidateWgs84Extent()
Invalidates the WGS84 extent.
Definition: qgsmaplayer.cpp:2294
QgsPointXY::x
double x
Definition: qgspointxy.h:62
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:99
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:49
QgsMeshLayer::timeSettingsChanged
void timeSettingsChanged()
Emitted when time format is changed.
QgsMeshLayerRenderer
Implementation of threaded rendering for mesh layers.
Definition: qgsmeshlayerrenderer.h:91
QgsMeshRendererSettings::readXml
void readXml(const QDomElement &elem, const QgsReadWriteContext &context=QgsReadWriteContext())
Reads configuration from the given DOM element.
Definition: qgsmeshrenderersettings.cpp:456
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:1309
qgslayermetadataformatter.h
QgsMeshEditor::reindex
bool reindex(bool renumbering)
Reindexes the mesh, that is remove unusued index of face and vertices, this operation void the undo/r...
Definition: qgsmesheditor.cpp:970
QgsMapLayer::name
QString name
Definition: qgsmaplayer.h:76
QgsMeshLayer::resetDatasetGroupTreeItem
void resetDatasetGroupTreeItem()
Reset the dataset group tree item to default from provider.
Definition: qgsmeshlayer.cpp:897
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:394
qgsmaplayerlegend.h
QgsMeshDatasetGroupStore::datasetGroupsAdded
void datasetGroupsAdded(QList< int > indexes)
Emitted after dataset groups are added.
QgsMeshDataBlock
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
Definition: qgsmeshdataset.h:137
QgsMeshLayer::datasetGroupMetadata
QgsMeshDatasetGroupMetadata datasetGroupMetadata(const QgsMeshDatasetIndex &index) const
Returns the dataset groups metadata.
Definition: qgsmeshlayer.cpp:404
QgsMeshDatasetGroupTreeItem::datasetGroupIndex
int datasetGroupIndex() const
Definition: qgsmeshdataset.cpp:634
QgsMeshEditingError::errorType
Qgis::MeshEditingErrorType errorType
Definition: qgsmesheditor.h:52
Qgis::MeshEditingErrorType::TooManyVerticesInFace
@ TooManyVerticesInFace
A face has more vertices than the maximum number supported per face.
QgsTriangularMesh
Triangular/Derived Mesh is mesh with vertices in map coordinates.
Definition: qgstriangularmesh.h:51
QgsMeshLayer::meshEditor
QgsMeshEditor * meshEditor()
Returns a pointer to the mesh editor own by the mesh layer.
Definition: qgsmeshlayer.cpp:1121
Qgis::MeshEditingErrorType::NoError
@ NoError
No type.
QgsColorRampShader::ColorRampItem::label
QString label
Definition: qgscolorrampshader.h:116
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:136
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:2031
QgsMeshSimplificationSettings::writeXml
QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a new DOM element.
Definition: qgsmeshsimplificationsettings.cpp:40
QgsInterpolatedLineRenderer
Represents a simple line renderer with width and color varying depending on values.
Definition: qgsinterpolatedlinerenderer.h:200
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:424
QgsMeshLayer::temporalProperties
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
Definition: qgsmeshlayer.cpp:1824
qgslogger.h
QgsMeshLayer::elevationProperties
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation properties.
Definition: qgsmeshlayer.cpp:1829
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:1325
QgsMeshDatasetGroupMetadata::isVector
bool isVector() const
Returns whether dataset group has vector data.
Definition: qgsmeshdataset.cpp:152
QgsLayerMetadataFormatter::extentSectionHtml
QString extentSectionHtml(const bool showSpatialExtent=true) const
Formats the "Extents" section according to a metadata object (extent and temporal).
Definition: qgslayermetadataformatter.cpp:110
QgsMeshLayerTemporalProperties::matchingMethod
QgsMeshDataProviderTemporalCapabilities::MatchingTemporalDatasetMethod matchingMethod() const
Returns the method used to match dataset from temporal capabilities.
Definition: qgsmeshlayertemporalproperties.cpp:109
QgsMapLayer::setValid
void setValid(bool valid)
Sets whether layer is valid or not.
Definition: qgsmaplayer.cpp:2061
QgsMeshDataBlock::value
QgsMeshDatasetValue value(int index) const
Returns a value represented by the index For active flag the behavior is undefined.
Definition: qgsmeshdataset.cpp:267
QgsMeshLayer::providerType
QString providerType() const
Returns the provider type for this layer.
Definition: qgsmeshlayer.cpp:151
QgsMeshLayer::~QgsMeshLayer
~QgsMeshLayer() override
Definition: qgsmeshlayer.cpp:105
QgsMeshEditor::checkConsistency
bool checkConsistency(QgsMeshEditingError &error) const
Return true if the edited mesh is consistent.
Definition: qgsmesheditor.cpp:362
QgsMeshLayer::activeVectorDatasetGroupChanged
void activeVectorDatasetGroupChanged(int index)
Emitted when active vector group dataset is changed.
QgsExpression
Class for parsing and evaluation of expressions (formerly called "search strings")....
Definition: qgsexpression.h:102
QgsMeshLayer::setRendererSettings
void setRendererSettings(const QgsMeshRendererSettings &settings)
Sets new renderer settings.
Definition: qgsmeshlayer.cpp:349
QgsMapLayer::trigger3DUpdate
void trigger3DUpdate()
Will advise any 3D maps that this layer requires to be updated in the scene.
Definition: qgsmaplayer.cpp:2123
QgsCoordinateTransform
Class for doing transforms between two map coordinate systems.
Definition: qgscoordinatetransform.h:57
QgsMeshDatasetGroupTreeItem::child
QgsMeshDatasetGroupTreeItem * child(int row) const
Returns a child.
Definition: qgsmeshdataset.cpp:548
QgsMeshLayer::datasetGroupCount
int datasetGroupCount() const
Returns the dataset groups count handle by the layer.
Definition: qgsmeshlayer.cpp:384
QgsMesh3dAveragingMethod::calculate
QgsMeshDataBlock calculate(const QgsMesh3dDataBlock &block3d, QgsFeedback *feedback=nullptr) const
Calculated 2d block values from 3d stacked mesh values.
Definition: qgsmesh3daveraging.cpp:58
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:73
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:2192
QgsMeshRendererSettings::setActiveScalarDatasetGroup
void setActiveScalarDatasetGroup(int activeScalarDatasetGroup)
Sets the active scalar dataset group.
Definition: qgsmeshrenderersettings.cpp:512
QgsMeshLayer::areFacesActive
QgsMeshDataBlock areFacesActive(const QgsMeshDatasetIndex &index, int faceIndex, int count) const
Returns whether the faces are active for particular dataset.
Definition: qgsmeshlayer.cpp:434
qgsmeshdataprovider.h
QgsPoint::x
double x
Definition: qgspoint.h:69
QgsMeshLayer::dataProvider
QgsMeshDataProvider * dataProvider() override
Returns the layer's data provider, it may be nullptr.
Definition: qgsmeshlayer.cpp:110
QgsMapLayer::setLegend
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
Definition: qgsmaplayer.cpp:2070
QgsMeshLayer::activeScalarDatasetAtTime
QgsMeshDatasetIndex activeScalarDatasetAtTime(const QgsDateTimeRange &timeRange) const
Returns dataset index from active scalar group depending on the time range.
Definition: qgsmeshlayer.cpp:705
QgsStyle::colorRamp
QgsColorRamp * colorRamp(const QString &name) const
Returns a new copy of the specified color ramp.
Definition: qgsstyle.cpp:462
QgsColorRampShader::ColorRampItem::value
double value
Definition: qgscolorrampshader.h:117
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:1233
qgsmeshlayertemporalproperties.h
QgsDataProvider::isValid
virtual bool isValid() const =0
Returns true if this is a valid layer.
QgsMeshRendererSettings::hasSettings
bool hasSettings(int datasetGroupIndex) const
Returns whether the group with index has render settings (scalar or vector)
Definition: qgsmeshrenderersettings.cpp:743
Qgis::MeshEditingErrorType::UniqueSharedVertex
@ UniqueSharedVertex
A least two faces share only one vertices.
QgsMeshLayer::isEditable
bool isEditable() const override
Returns true if the layer can be edited.
Definition: qgsmeshlayer.cpp:1759
QgsLayerMetadataFormatter::identificationSectionHtml
QString identificationSectionHtml() const
Formats the "Identification" section according to a metadata object.
Definition: qgslayermetadataformatter.cpp:180
QgsMeshEditor::maximumVerticesPerFace
int maximumVerticesPerFace() const
Returns the maximum count of vertices per face that the mesh can support.
Definition: qgsmesheditor.cpp:444
QgsDataProvider::subLayers
virtual QStringList subLayers() const
Sub-layers handled by this provider, in order from bottom to top.
Definition: qgsdataprovider.h:296
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:262
qgsmessagelog.h
QgsDataProvider::crs
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
QgsMapLayer::error
virtual QgsError error() const
Gets current status error.
Definition: qgsmaplayer.cpp:2014
INVALID_MESHLAYER_TIME
#define INVALID_MESHLAYER_TIME
Definition: qgsmeshdataprovidertemporalcapabilities.h:25
QgsMesh::Vertex
@ Vertex
Definition: qgsmeshdataprovider.h:67
QgsMapLayer::type
QgsMapLayerType type
Definition: qgsmaplayer.h:80