QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsmeshlayer.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsmeshlayer.cpp
3  ----------------
4  begin : April 2018
5  copyright : (C) 2018 by Peter Petrik
6  email : zilolv at gmail dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #include <cstddef>
19 #include <limits>
20 
21 #include <QUuid>
22 
23 #include "qgscolorramp.h"
24 #include "qgslogger.h"
25 #include "qgsmaplayerlegend.h"
26 #include "qgsmeshdataprovider.h"
27 #include "qgsmeshlayer.h"
28 #include "qgsmeshlayerrenderer.h"
29 #include "qgsmeshlayerutils.h"
30 #include "qgspainting.h"
31 #include "qgsproviderregistry.h"
32 #include "qgsreadwritecontext.h"
33 #include "qgsstyle.h"
34 #include "qgstriangularmesh.h"
35 
36 
37 QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
38  const QString &baseName,
39  const QString &providerKey,
40  const LayerOptions & )
41  : QgsMapLayer( MeshLayer, baseName, meshLayerPath )
42  , mProviderKey( providerKey )
43 {
44  // if we’re given a provider type, try to create and bind one to this layer
45  if ( !meshLayerPath.isEmpty() && !providerKey.isEmpty() )
46  {
47  QgsDataProvider::ProviderOptions providerOptions;
48  setDataProvider( providerKey, providerOptions );
49  }
50 
52 
53  // show at least the mesh by default so we render something
54  QgsMeshRendererMeshSettings meshSettings;
55  meshSettings.setEnabled( true );
56  mRendererSettings.setNativeMeshSettings( meshSettings );
57 
58 } // QgsMeshLayer ctor
59 
60 
61 
63 {
64  delete mDataProvider;
65 }
66 
68 {
69  return mDataProvider;
70 }
71 
73 {
74  return mDataProvider;
75 }
76 
78 {
79  QgsMeshLayer *layer = new QgsMeshLayer( source(), name(), mProviderKey );
80  QgsMapLayer::clone( layer );
81  return layer;
82 }
83 
85 {
86  if ( mDataProvider )
87  return mDataProvider->extent();
88  else
89  {
90  QgsRectangle rec;
91  rec.setMinimal();
92  return rec;
93  }
94 }
95 
97 {
98  return mProviderKey;
99 }
100 
102 {
103  return mNativeMesh.get();
104 }
105 
106 
108 {
109  return mTriangularMesh.get();
110 }
111 
112 QgsMeshLayerRendererCache *QgsMeshLayer::rendererCache()
113 {
114  return mRendererCache.get();
115 }
116 
118 {
119  return mRendererSettings;
120 }
121 
123 {
124  mRendererSettings = settings;
125  emit rendererChanged();
126  triggerRepaint();
127 }
128 
130 {
131  QgsMeshDatasetValue value;
132 
133  if ( mTriangularMesh && dataProvider() && dataProvider()->isValid() && index.isValid() )
134  {
135  int faceIndex = mTriangularMesh->faceIndexForPoint( point ) ;
136  if ( faceIndex >= 0 )
137  {
138  int nativeFaceIndex = mTriangularMesh->trianglesToNativeFaces().at( faceIndex );
139  if ( dataProvider()->isFaceActive( index, nativeFaceIndex ) )
140  {
141 
142  if ( dataProvider()->datasetGroupMetadata( index ).dataType() == QgsMeshDatasetGroupMetadata::DataOnFaces )
143  {
144  int nativeFaceIndex = mTriangularMesh->trianglesToNativeFaces().at( faceIndex );
145  value = dataProvider()->datasetValue( index, nativeFaceIndex );
146  }
147  else
148  {
149  const QgsMeshFace &face = mTriangularMesh->triangles()[faceIndex];
150  const int v1 = face[0], v2 = face[1], v3 = face[2];
151  const QgsPoint p1 = mTriangularMesh->vertices()[v1], p2 = mTriangularMesh->vertices()[v2], p3 = mTriangularMesh->vertices()[v3];
152  const QgsMeshDatasetValue val1 = dataProvider()->datasetValue( index, v1 );
153  const QgsMeshDatasetValue val2 = dataProvider()->datasetValue( index, v2 );
154  const QgsMeshDatasetValue val3 = dataProvider()->datasetValue( index, v3 );
155  const double x = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.x(), val2.x(), val3.x(), point );
156  double y = std::numeric_limits<double>::quiet_NaN();
157  bool isVector = dataProvider()->datasetGroupMetadata( index ).isVector();
158  if ( isVector )
159  y = QgsMeshLayerUtils::interpolateFromVerticesData( p1, p2, p3, val1.y(), val2.y(), val3.y(), point );
160 
161  value = QgsMeshDatasetValue( x, y );
162  }
163 
164  }
165  }
166  }
167 
168  return value;
169 }
170 
171 void QgsMeshLayer::fillNativeMesh()
172 {
173  Q_ASSERT( !mNativeMesh );
174 
175  mNativeMesh.reset( new QgsMesh() );
176 
177  if ( !( dataProvider() && dataProvider()->isValid() ) )
178  return;
179 
180  mNativeMesh->vertices.resize( dataProvider()->vertexCount() );
181  for ( int i = 0; i < dataProvider()->vertexCount(); ++i )
182  {
183  mNativeMesh->vertices[i] = dataProvider()->vertex( i );
184  }
185 
186  mNativeMesh->faces.resize( dataProvider()->faceCount() );
187  for ( int i = 0; i < dataProvider()->faceCount(); ++i )
188  {
189  mNativeMesh->faces[i] = dataProvider()->face( i );
190  }
191 }
192 
193 void QgsMeshLayer::onDatasetGroupsAdded( int count )
194 {
195  // assign default style to new dataset groups
196  int newDatasetGroupCount = mDataProvider->datasetGroupCount();
197  for ( int i = newDatasetGroupCount - count; i < newDatasetGroupCount; ++i )
198  assignDefaultStyleToDatasetGroup( i );
199 }
200 
201 static QgsColorRamp *_createDefaultColorRamp()
202 {
203  QgsColorRamp *ramp = QgsStyle::defaultStyle()->colorRamp( QStringLiteral( "Plasma" ) );
204  if ( ramp )
205  return ramp;
206 
207  // definition of "Plasma" color ramp (in case it is not available in the style for some reason)
208  QgsStringMap props;
209  props["color1"] = "13,8,135,255";
210  props["color2"] = "240,249,33,255";
211  props["stops"] =
212  "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:"
213  "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:"
214  "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:"
215  "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:"
216  "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:"
217  "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:"
218  "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:"
219  "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:"
220  "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:"
221  "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";
222  return QgsGradientColorRamp::create( props );
223 }
224 
225 void QgsMeshLayer::assignDefaultStyleToDatasetGroup( int groupIndex )
226 {
227  double groupMin, groupMax;
228  QgsMeshLayerUtils::calculateMinMaxForDatasetGroup( groupMin, groupMax, mDataProvider, groupIndex );
229 
230  QgsColorRampShader fcn( groupMin, groupMax, _createDefaultColorRamp() );
231  fcn.classifyColorRamp( 5, -1, QgsRectangle(), nullptr );
232 
233  QgsMeshRendererScalarSettings scalarSettings;
234  scalarSettings.setClassificationMinimumMaximum( groupMin, groupMax );
235  scalarSettings.setColorRampShader( fcn );
236  mRendererSettings.setScalarSettings( groupIndex, scalarSettings );
237 }
238 
240 {
241  // Native mesh
242  if ( !mNativeMesh )
243  {
244  // lazy loading of mesh data
245  fillNativeMesh();
246  }
247 
248  // Triangular mesh
249  if ( !mTriangularMesh )
250  mTriangularMesh.reset( new QgsTriangularMesh() );
251 
252  mTriangularMesh->update( mNativeMesh.get(), &rendererContext );
253 
254  // Cache
255  if ( !mRendererCache )
256  mRendererCache.reset( new QgsMeshLayerRendererCache() );
257 
258  return new QgsMeshLayerRenderer( this, rendererContext );
259 }
260 
261 bool QgsMeshLayer::readSymbology( const QDomNode &node, QString &errorMessage,
262  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories )
263 {
264  Q_UNUSED( errorMessage );
265  // TODO: implement categories for raster layer
266 
267  QDomElement elem = node.toElement();
268 
269  readCommonStyle( elem, context, categories );
270 
271  QDomElement elemRendererSettings = elem.firstChildElement( "mesh-renderer-settings" );
272  if ( !elemRendererSettings.isNull() )
273  mRendererSettings.readXml( elemRendererSettings );
274 
275  // get and set the blend mode if it exists
276  QDomNode blendModeNode = node.namedItem( QStringLiteral( "blendMode" ) );
277  if ( !blendModeNode.isNull() )
278  {
279  QDomElement e = blendModeNode.toElement();
280  setBlendMode( QgsPainting::getCompositionMode( static_cast< QgsPainting::BlendMode >( e.text().toInt() ) ) );
281  }
282 
283  return true;
284 }
285 
286 bool QgsMeshLayer::writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
287  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories ) const
288 {
289  Q_UNUSED( errorMessage );
290  // TODO: implement categories for raster layer
291 
292  QDomElement elem = node.toElement();
293 
294  writeCommonStyle( elem, doc, context, categories );
295 
296  QDomElement elemRendererSettings = mRendererSettings.writeXml( doc );
297  elem.appendChild( elemRendererSettings );
298 
299  // add blend mode node
300  QDomElement blendModeElement = doc.createElement( QStringLiteral( "blendMode" ) );
301  QDomText blendModeText = doc.createTextNode( QString::number( QgsPainting::getBlendModeEnum( blendMode() ) ) );
302  blendModeElement.appendChild( blendModeText );
303  node.appendChild( blendModeElement );
304 
305  return true;
306 }
307 
308 QString QgsMeshLayer::decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const
309 {
310  QString src( source );
311  if ( provider == QLatin1String( "mdal" ) )
312  {
313  src = context.pathResolver().readPath( src );
314  }
315  return src;
316 }
317 
318 QString QgsMeshLayer::encodedSource( const QString &source, const QgsReadWriteContext &context ) const
319 {
320  QString src( source );
321  if ( providerType() == QLatin1String( "mdal" ) )
322  {
323  src = context.pathResolver().writePath( src );
324  }
325  return src;
326 }
327 
328 bool QgsMeshLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &context )
329 {
330  QgsDebugMsgLevel( QStringLiteral( "Datasource in QgsMeshLayer::readXml: %1" ).arg( mDataSource.toLocal8Bit().data() ), 3 );
331 
332  //process provider key
333  QDomNode pkeyNode = layer_node.namedItem( QStringLiteral( "provider" ) );
334 
335  if ( pkeyNode.isNull() )
336  {
337  mProviderKey.clear();
338  }
339  else
340  {
341  QDomElement pkeyElt = pkeyNode.toElement();
342  mProviderKey = pkeyElt.text();
343  }
344 
345  QgsDataProvider::ProviderOptions providerOptions;
346  if ( !setDataProvider( mProviderKey, providerOptions ) )
347  {
348  return false;
349  }
350 
351  QDomElement elemExtraDatasets = layer_node.firstChildElement( QStringLiteral( "extra-datasets" ) );
352  if ( !elemExtraDatasets.isNull() )
353  {
354  QDomElement elemUri = elemExtraDatasets.firstChildElement( QStringLiteral( "uri" ) );
355  while ( !elemUri.isNull() )
356  {
357  QString uri = context.pathResolver().readPath( elemUri.text() );
358 
359  bool res = mDataProvider->addDataset( uri );
360 #ifdef QGISDEBUG
361  QgsDebugMsg( QStringLiteral( "extra dataset (res %1): %2" ).arg( res ).arg( uri ) );
362 #else
363  ( void )res; // avoid unused warning in release builds
364 #endif
365 
366  elemUri = elemUri.nextSiblingElement( QStringLiteral( "uri" ) );
367  }
368  }
369 
370  QString errorMsg;
371  readSymbology( layer_node, errorMsg, context );
372 
373  return mValid; // should be true if read successfully
374 }
375 
376 bool QgsMeshLayer::writeXml( QDomNode &layer_node, QDomDocument &document, const QgsReadWriteContext &context ) const
377 {
378  // first get the layer element so that we can append the type attribute
379  QDomElement mapLayerNode = layer_node.toElement();
380 
381  if ( mapLayerNode.isNull() || ( QLatin1String( "maplayer" ) != mapLayerNode.nodeName() ) )
382  {
383  QgsDebugMsgLevel( QStringLiteral( "can't find <maplayer>" ), 2 );
384  return false;
385  }
386 
387  mapLayerNode.setAttribute( QStringLiteral( "type" ), QStringLiteral( "mesh" ) );
388 
389  // add provider node
390  if ( mDataProvider )
391  {
392  QDomElement provider = document.createElement( QStringLiteral( "provider" ) );
393  QDomText providerText = document.createTextNode( providerType() );
394  provider.appendChild( providerText );
395  layer_node.appendChild( provider );
396 
397  const QStringList extraDatasetUris = mDataProvider->extraDatasets();
398  QDomElement elemExtraDatasets = document.createElement( QStringLiteral( "extra-datasets" ) );
399  for ( const QString &uri : extraDatasetUris )
400  {
401  QString path = context.pathResolver().writePath( uri );
402  QDomElement elemUri = document.createElement( QStringLiteral( "uri" ) );
403  elemUri.appendChild( document.createTextNode( path ) );
404  elemExtraDatasets.appendChild( elemUri );
405  }
406  layer_node.appendChild( elemExtraDatasets );
407  }
408 
409  // renderer specific settings
410  QString errorMsg;
411  return writeSymbology( layer_node, document, errorMsg, context );
412 }
413 
414 bool QgsMeshLayer::setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options )
415 {
416  delete mDataProvider;
417 
418  mProviderKey = provider;
419  QString dataSource = mDataSource;
420 
421  mDataProvider = qobject_cast<QgsMeshDataProvider *>( QgsProviderRegistry::instance()->createProvider( provider, dataSource, options ) );
422  if ( !mDataProvider )
423  {
424  QgsDebugMsgLevel( QStringLiteral( "Unable to get mesh data provider" ), 2 );
425  return false;
426  }
427 
428  mDataProvider->setParent( this );
429  QgsDebugMsgLevel( QStringLiteral( "Instantiated the mesh data provider plugin" ), 2 );
430 
431  mValid = mDataProvider->isValid();
432  if ( !mValid )
433  {
434  QgsDebugMsgLevel( QStringLiteral( "Invalid mesh provider plugin %1" ).arg( QString( mDataSource.toUtf8() ) ), 2 );
435  return false;
436  }
437 
438  setCrs( mDataProvider->crs() );
439 
440  if ( provider == QStringLiteral( "mesh_memory" ) )
441  {
442  // required so that source differs between memory layers
443  mDataSource = mDataSource + QStringLiteral( "&uid=%1" ).arg( QUuid::createUuid().toString() );
444  }
445 
446  for ( int i = 0; i < mDataProvider->datasetGroupCount(); ++i )
447  assignDefaultStyleToDatasetGroup( i );
448 
449  connect( mDataProvider, &QgsMeshDataProvider::dataChanged, this, &QgsMeshLayer::dataChanged );
450  connect( mDataProvider, &QgsMeshDataProvider::datasetGroupsAdded, this, &QgsMeshLayer::onDatasetGroupsAdded );
451 
452  return true;
453 }
void setClassificationMinimumMaximum(double minimum, double maximum)
Sets min/max values used for creation of the color ramp shader.
The class is used as a container of context for various read/write operations on other objects...
A rectangle specified with double values.
Definition: qgsrectangle.h:40
Base class for all map layer types.
Definition: qgsmaplayer.h:63
QgsMeshRendererSettings rendererSettings() const
Returns renderer settings.
Triangular/Derived Mesh is mesh with vertices in map coordinates.
bool isValid() const
Returns the status of the layer.
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
Definition: qgsrectangle.h:150
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
QgsMeshDatasetValue datasetValue(const QgsMeshDatasetIndex &index, const QgsPointXY &point) const
Interpolates the value on the given point from given dataset.
void setRendererSettings(const QgsMeshRendererSettings &settings)
Sets new renderer settings.
QString name() const
Returns the display name of the layer.
QDomElement writeXml(QDomDocument &doc) const
Writes configuration to a new DOM element.
QgsColorRamp * colorRamp(const QString &name) const
Returns a new copy of the specified color ramp.
Definition: qgsstyle.cpp:272
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
#define QgsDebugMsg(str)
Definition: qgslogger.h:38
virtual int faceCount() const =0
Returns number of faces in the native mesh.
Represents a mesh renderer settings for mesh object.
A class to represent a 2D point.
Definition: qgspointxy.h:43
Abstract base class for color ramps.
Definition: qgscolorramp.h:31
virtual bool addDataset(const QString &uri)=0
Associate dataset with the mesh.
Represents a mesh renderer settings for scalar datasets.
bool isValid() const
Returns whether index is valid, ie at least groups is set.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write style data common to all layer types.
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
Definition: qgspainting.cpp:80
virtual int vertexCount() const =0
Returns number of vertices in the native mesh.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
QString encodedSource(const QString &source, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by derived classes to encode provider&#39;s specific data source to proje...
QString source() const
Returns the source for the layer.
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
Definition: qgspainting.cpp:20
Setting options for loading mesh layers.
Definition: qgsmeshlayer.h:97
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
void setScalarSettings(int groupIndex, const QgsMeshRendererScalarSettings &settings)
Sets new renderer settings.
static QgsMapLayerLegend * defaultMeshLegend(QgsMeshLayer *ml)
Create new legend implementation for mesh layer.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:577
bool isVector() const
Returns whether dataset group has vector data.
QgsMesh * nativeMesh()
Returns native mesh (nullptr before rendering)
static QgsStyle * defaultStyle()
Returns default application-wide style.
Definition: qgsstyle.cpp:46
Implementation of threaded rendering for mesh layers.
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const override
QgsRectangle extent() const override
Returns the extent of the layer.
QgsDataProvider * createProvider(const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options=QgsDataProvider::ProviderOptions())
Creates a new instance of a provider.
void dataChanged()
This is emitted whenever an asynchronous operation has finished and the data should be redrawn...
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
Represents all mesh renderer settings.
QgsRectangle extent() const override
Returns the extent of the layer.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted...
#define QgsDebugMsgLevel(str, level)
Definition: qgslogger.h:39
#define SIP_SKIP
Definition: qgis_sip.h:119
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer&#39;s spatial reference system.
virtual bool isValid() const =0
Returns true if this is a valid layer.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
void setColorRampShader(const QgsColorRampShader &shader)
Sets color ramp shader function.
~QgsMeshLayer() override
void datasetGroupsAdded(int count)
Emitted when some new dataset groups have been added.
QString providerType() const
Returns the provider type for this layer.
QString decodedSource(const QString &source, const QString &provider, const QgsReadWriteContext &context) const override
Called by readLayerXML(), used by derived classes to decode provider&#39;s specific data source from proj...
double y() const
Returns y value.
QgsMeshDataProvider * dataProvider() override
Returns the layer&#39;s data provider.
void rendererChanged()
Signal emitted when renderer is changed.
bool mValid
Indicates if the layer is valid and can be drawn.
Definition: qgsmaplayer.h:1359
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
void setEnabled(bool enabled)
Sets whether mesh structure rendering is enabled.
void classifyColorRamp(int classes=0, int band=-1, const QgsRectangle &extent=QgsRectangle(), QgsRasterInterface *input=nullptr)
Classify color ramp shader.
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context...
Base class for providing data for QgsMeshLayer.
virtual QgsMeshVertex vertex(int index) const =0
Returns the mesh vertex at index.
static QgsColorRamp * create(const QgsStringMap &properties=QgsStringMap())
Creates a new QgsColorRamp from a map of properties.
bool writeXml(QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by children to write state specific to them to project files...
Contains information about the context of a rendering operation.
Setting options for creating vector data providers.
virtual QgsMeshFace face(int index) const =0
Returns the mesh face at index.
Mesh - vertices and faces.
QString mDataSource
Data source description string, varies by layer type.
Definition: qgsmaplayer.h:1362
QgsMeshLayer * clone() const override
Returns a new instance equivalent to this one except for the id which is still unique.
void setNativeMeshSettings(const QgsMeshRendererMeshSettings &settings)
Sets new renderer settings, triggers repaint.
QVector< int > QgsMeshFace
List of vertex indexes.
QgsMeshDatasetIndex is index that identifies the dataset group (e.g.
virtual QStringList extraDatasets() const =0
Returns list of additional dataset file URIs added using addDataset() calls.
QgsMeshLayerRendererCache * rendererCache()
Returns native mesh (nullptr before rendering)
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
void dataChanged()
Data of layer changed.
Base class for utility classes that encapsulate information necessary for rendering of map layers...
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Definition: qgsmeshlayer.h:89
virtual int datasetGroupCount() const =0
Returns number of datasets groups loaded.
QgsMeshDatasetValue represents single dataset value.
double x() const
Returns x value.
virtual QgsMeshDatasetValue datasetValue(QgsMeshDatasetIndex index, int valueIndex) const =0
Returns vector/scalar value associated with the index from the dataset.
void readXml(const QDomElement &elem)
Reads configuration from the given DOM element.
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
bool readXml(const QDomNode &layer_node, QgsReadWriteContext &context) override
Called by readLayerXML(), used by children to read state specific to them from project files...
bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) override
QgsTriangularMesh * triangularMesh()
Returns triangular mesh (nullptr before rendering)
QgsMeshLayer(const QString &path=QString(), const QString &baseName=QString(), const QString &providerLib="mesh_memory", const QgsMeshLayer::LayerOptions &options=QgsMeshLayer::LayerOptions())
Constructor - creates a mesh layer.
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types.
virtual QgsMeshDatasetGroupMetadata datasetGroupMetadata(int groupIndex) const =0
Returns dataset group metadata.