39 , mFeedback( new QgsMeshLayerRendererFeedback )
41 , mRendererNativeMeshSettings( layer->rendererNativeMeshSettings() )
42 , mRendererTriangularMeshSettings( layer->rendererTriangularMeshSettings() )
43 , mRendererScalarSettings( layer-> rendererScalarSettings() )
44 , mRendererVectorSettings( layer-> rendererVectorSettings() )
55 copyScalarDatasetValues( layer );
56 copyVectorDatasetValues( layer );
58 calculateOutputSize();
66 void QgsMeshLayerRenderer::calculateOutputSize()
73 int width = int( bottomright.
x() - topleft.
x() );
74 int height = int( bottomright.
y() - topleft.
y() );
78 void QgsMeshLayerRenderer::createMeshSymbol( std::unique_ptr<QgsSymbol> &symbol,
94 void QgsMeshLayerRenderer::copyScalarDatasetValues(
QgsMeshLayer *layer )
108 for (
int i = 0; i < count; ++i )
116 void QgsMeshLayerRenderer::copyVectorDatasetValues(
QgsMeshLayer *layer )
123 bool isScalar = metadata.
isScalar();
140 for (
int i = 0; i < count; ++i )
158 renderScalarDataset();
163 renderVectorDataset();
168 void QgsMeshLayerRenderer::renderMesh(
const std::unique_ptr<QgsSymbol> &symbol,
const QVector<QgsMeshFace> &faces )
177 for (
int i = 0; i < faces.size(); ++i )
185 QVector<QgsPointXY> ring;
186 for (
int j = 0; j < face.size(); ++j )
188 int vertex_id = face[j];
191 ring.append( vertex );
194 polygon.append( ring );
197 renderer.renderFeature( feat,
mContext );
203 void QgsMeshLayerRenderer::renderScalarDataset()
210 if ( std::isnan( vMin ) )
215 if ( std::isnan( vMax ) )
218 QList<QgsColorRampShader::ColorRampItem> lst;
223 fcn->setColorRampItemList( lst );
229 QImage img = bl->image();
234 void QgsMeshLayerRenderer::renderVectorDataset()
A rectangle specified with double values.
Interface for all raster shaders.
QVector< double > mVectorDatasetValuesX
double maxValue() const
Returns max scalar value that represents maxColor()
void setFields(const QgsFields &fields, bool initAttributes=false)
Assign a field map with the feature to allow attribute access by attribute name.
int activeVectorDataset() const
Returns active vector dataset.
QColor minColor() const
Returns color representing minimum scalar value in the dataset.
A ramp shader will color a raster pixel based on a list of values ranges in a ramp.
Represents a mesh renderer settings for mesh object.
A class to represent a 2D point.
virtual QgsMeshDatasetMetadata datasetMetadata(int datasetIndex) const =0
Returns dataset metadata.
bool isEnabled() const
Returns whether mesh structure rendering is enabled.
virtual QgsMeshDatasetValue datasetValue(int datasetIndex, int valueIndex) const =0
Returns vector/scalar value associated with the index from the dataset.
QVector< QgsPolylineXY > QgsPolygonXY
Polygon: first item of the list is outer ring, inner rings (if any) start from second item...
bool renderingStopped() const
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
QVector< double > mScalarDatasetValues
bool mScalarDataOnVertices
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsMesh * nativeMesh()
Returns native mesh (nullptr before rendering)
const int NO_ACTIVE_MESH_DATASET
bool mVectorDataOnVertices
QVector< double > mVectorDatasetValuesMag
double y() const
Returns y value.
QVector< QgsMeshVertex > vertices
vertices
QgsTriangularMesh mTriangularMesh
Base class for feedback objects to be used for cancelation of something running in a worker thread...
Perform transforms between map coordinates and device coordinates.
double lineWidth() const
Returns line width used for rendering (in millimeters)
QgsPointXY transform(const QgsPointXY &p) const
Transform the point from map (world) coordinates to device coordinates.
QgsFeedback * feedback() const override
Access to feedback object of the layer renderer (may be null)
const QVector< QgsMeshFace > & triangles() const
Returns triangles.
QColor maxColor() const
Returns color representing maximum scalar value in the dataset.
bool render() override
Do the rendering (based on data stored in the class)
const QgsRectangle & extent() const
QgsMeshRendererScalarSettings mRendererScalarSettings
double minValue() const
Returns min scalar value that represents minColor()
Raster renderer pipe for single band pseudocolor.
void setRasterShaderFunction(QgsRasterShaderFunction *function)
A public method that allows the user to set their own shader function.
QList< QgsSymbolLayer * > QgsSymbolLayerList
std::unique_ptr< QgsSymbol > mTriangularMeshSymbol
QgsMeshDataProvider * dataProvider() override
Returns the layer's data provider.
QVector< double > mVectorDatasetValuesY
double scalar() const
Returns magnitude of vector for vector data or scalar value for scalar data.
Point geometry type, with support for z-dimension and m-values.
std::unique_ptr< QgsMeshLayerRendererFeedback > mFeedback
feedback class for cancelation
QgsMeshRendererVectorSettings mRendererVectorSettings
QgsRenderContext & mContext
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
static QgsGeometry fromPolygonXY(const QgsPolygonXY &polygon)
Creates a new geometry from a QgsPolygon.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
void startRender(QgsRenderContext &context, const QgsFields &fields) override
Must be called when a new render cycle is started.
int activeScalarDataset() const
Returns active scalar dataset.
Contains information about the context of a rendering operation.
QPainter * painter()
Returns the destination QPainter for the render operation.
const QgsMapToPixel & mapToPixel() const
QgsMeshLayerRenderer(QgsMeshLayer *layer, QgsRenderContext &context)
Ctor.
QColor color() const
Returns color used for rendering.
QVector< int > QgsMeshFace
List of vertex indexes.
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
QgsMeshRendererMeshSettings mRendererNativeMeshSettings
Base class for utility classes that encapsulate information necessary for rendering of map layers...
double yMaximum() const
Returns the y maximum value (top side of rectangle).
Represents a mesh layer supporting display of data on structured or unstructured meshes.
QVector< QgsMeshFace > faces
faces
QgsMeshRendererMeshSettings mRendererTriangularMeshSettings
const QVector< QgsMeshVertex > & vertices() const
Returns vertices in map CRS.
QgsTriangularMesh * triangularMesh()
Returns triangular mesh (nullptr before rendering)
std::unique_ptr< QgsSymbol > mNativeMeshSymbol
QgsRasterBlock * block(int bandNo, const QgsRectangle &extent, int width, int height, QgsRasterBlockFeedback *feedback=nullptr) override
Read block of data using given extent and size.
double x() const
Returns x value.