18#ifndef QGSMESHTRACERENDERER_H
19#define QGSMESHTRACERENDERER_H
33class QgsMeshLayerInterpolator;
34class QgsMeshLayerRendererFeedback;
48class QgsMeshVectorValueInterpolator
52 QgsMeshVectorValueInterpolator(
57 QgsMeshVectorValueInterpolator(
63 QgsMeshVectorValueInterpolator(
const QgsMeshVectorValueInterpolator &other );
66 virtual QgsMeshVectorValueInterpolator *clone() = 0;
69 virtual ~QgsMeshVectorValueInterpolator() =
default;
78 QgsMeshVectorValueInterpolator &operator=(
const QgsMeshVectorValueInterpolator &other );
81 void updateCacheFaceIndex(
const QgsPointXY &point )
const;
87 mutable int mCacheFaceIndex = -1;
88 bool mUseScalarActiveFaceFlagValues =
false;
89 bool isVectorValid(
const QgsVector &v )
const;
93 void activeFaceFilter(
QgsVector &vector,
int faceIndex )
const;
95 virtual QgsVector interpolatedValuePrivate(
int faceIndex,
const QgsPointXY point )
const = 0;
106class QgsMeshVectorValueInterpolatorFromVertex:
public QgsMeshVectorValueInterpolator
110 QgsMeshVectorValueInterpolatorFromVertex(
115 QgsMeshVectorValueInterpolatorFromVertex(
121 QgsMeshVectorValueInterpolatorFromVertex(
const QgsMeshVectorValueInterpolatorFromVertex &other );
124 virtual QgsMeshVectorValueInterpolatorFromVertex *clone()
override;
127 QgsMeshVectorValueInterpolatorFromVertex &operator=(
const QgsMeshVectorValueInterpolatorFromVertex &other );
130 QgsVector interpolatedValuePrivate(
int faceIndex,
const QgsPointXY point )
const override;
141class QgsMeshVectorValueInterpolatorFromFace:
public QgsMeshVectorValueInterpolator
145 QgsMeshVectorValueInterpolatorFromFace(
150 QgsMeshVectorValueInterpolatorFromFace(
156 QgsMeshVectorValueInterpolatorFromFace(
const QgsMeshVectorValueInterpolatorFromFace &other );
159 virtual QgsMeshVectorValueInterpolatorFromFace *clone()
override;
162 QgsMeshVectorValueInterpolatorFromFace &operator=(
const QgsMeshVectorValueInterpolatorFromFace &other );
165 QgsVector interpolatedValuePrivate(
int faceIndex,
const QgsPointXY point )
const override;
176class QgsMeshStreamField
193 double magnitudeMaximum,
194 bool dataIsOnVertices,
197 int resolution = 1 );
200 QgsMeshStreamField(
const QgsMeshStreamField &other );
203 virtual ~QgsMeshStreamField();
220 bool isValid()
const;
226 QPoint topLeft()
const;
229 void addTrace( QPoint startPixel );
235 void addRandomTraces();
238 void addRandomTrace();
241 void addGriddedTraces(
int dx,
int dy );
247 void setResolution(
int width );
250 int resolution()
const;
253 QSize imageSize()
const;
256 virtual QImage image()
const;
259 void setPixelFillingDensity(
double maxFilling );
262 void setColor( QColor color );
265 void setLineWidth(
double width );
268 void setFilter(
double min,
double max );
271 void setMinimizeFieldSize(
bool minimizeFieldSize );
274 QgsMeshStreamField &operator=(
const QgsMeshStreamField &other );
277 virtual void initImage();
278 QPointF fieldToDevice(
const QPoint &pixel )
const;
279 bool filterMag(
double value )
const;
280 bool isTraceOutside(
const QPoint &pixel )
const;
283 QgsPointXY positionToMapCoordinates(
const QPoint &pixelPosition,
const QgsPointXY &positionInPixel );
284 bool addPixelToChunkTrace( QPoint &pixel,
285 QgsMeshStreamField::FieldData &data,
286 std::list<QPair<QPoint, QgsMeshStreamField::FieldData> > &chunkTrace );
287 void setChunkTrace( std::list<QPair<QPoint, FieldData>> &chunkTrace );
288 virtual void drawTrace(
const QPoint & )
const {}
289 void clearChunkTrace( std::list<QPair<QPoint, FieldData>> &chunkTrace );
290 virtual void storeInField(
const QPair<QPoint, FieldData> pixelData ) = 0;
291 virtual void initField() = 0;
292 void simplifyChunkTrace( std::list<QPair<QPoint, FieldData>> &shunkTrace );
294 virtual bool isTraceExists(
const QPoint &pixel )
const = 0;
299 std::unique_ptr<QPainter> mPainter = std::unique_ptr<QPainter>(
nullptr );
300 int mFieldResolution = 1;
321 QVector<unsigned char> mDirectionField;
325 int mPixelFillingCount = 0;
326 int mMaxPixelFillingCount = 0;
327 std::unique_ptr<QgsMeshVectorValueInterpolator> mVectorValueInterpolator;
330 QPoint mFieldTopLeftInDeviceCoordinates;
332 double mMaximumMagnitude = 0;
333 double mPixelFillingDensity = 0;
334 double mMinMagFilter = -1;
335 double mMaxMagFilter = -1;
336 bool mMinimizeFieldSize =
true;
347class QgsMeshStreamlinesField:
public QgsMeshStreamField
351 Q_DECL_DEPRECATED QgsMeshStreamlinesField(
357 bool dataIsOnVertices,
361 QgsMeshStreamlinesField(
365 const QVector<double> &datasetMagValues,
367 QgsMeshLayerRendererFeedback *feedBack,
369 bool dataIsOnVertices,
376 void storeInField(
const QPair<QPoint, FieldData> pixelData )
override;
377 void initField()
override;
378 void initImage()
override;
379 bool isTraceExists(
const QPoint &pixel )
const override;
380 void drawTrace(
const QPoint &start )
const override;
382 QVector<bool> mField;
383 QImage mDrawingTraceImage;
384 std::unique_ptr<QPainter> mDrawingTracePainter;
388 QVector<double> mMagValues;
391 QgsMeshLayerRendererFeedback *mFeedBack =
nullptr;
395class QgsMeshParticleTracesField;
405struct QgsMeshTraceParticle
409 std::list<QPoint> tail;
410 double remainingTime = 0;
421class QgsMeshParticleTracesField:
public QgsMeshStreamField
425 QgsMeshParticleTracesField(
431 bool dataIsOnVertices,
436 QgsMeshParticleTracesField(
const QgsMeshParticleTracesField &other );
439 void addParticle(
const QPoint &startPoint,
double lifeTime );
442 void addParticleXY(
const QgsPointXY &startPoint,
double lifeTime );
445 void addRandomParticles();
448 void moveParticles();
451 QImage imageRendered()
const;
454 void setParticlesCount(
int particlesCount );
457 void setParticlesLifeTime(
double particlesLifeTime );
467 void setStumpFactor(
int sf );
470 void setTimeStep(
double timeStep );
473 void setParticleSize(
double particleSize );
476 void setTailFactor(
double tailFactor );
479 void setMinTailLength(
int minTailLength );
482 void setStumpParticleWithLifeTime(
bool stumpParticleWithLifeTime );
485 void setParticlesColor(
const QColor &
c );
487 QgsMeshParticleTracesField &operator=(
const QgsMeshParticleTracesField &other );
490 QPoint direction( QPoint position )
const;
492 float time( QPoint position )
const;
493 float magnitude( QPoint position )
const;
495 void drawParticleTrace(
const QgsMeshTraceParticle &particle );
497 void storeInField(
const QPair<QPoint, FieldData> pixelData )
override;
498 void initField()
override;
499 bool isTraceExists(
const QPoint &pixel )
const override;
508 QVector<float> mTimeField;
509 QVector<float> mMagnitudeField;
511 QList<QgsMeshTraceParticle> mParticles;
514 double mTimeStep = 200;
515 double mParticlesLifeTime = 5000;
516 int mParticlesCount = 1000;
517 double mTailFactor = 5;
518 int mMinTailLength = 3;
519 QColor mParticleColor = Qt::white;
520 double mParticleSize = 2.5;
521 int mStumpFactor = 50;
522 bool mStumpParticleWithLifeTime =
true;
535class QgsMeshVectorStreamlineRenderer:
public QgsMeshVectorRenderer
539 Q_DECL_DEPRECATED QgsMeshVectorStreamlineRenderer(
543 bool dataIsOnVertices,
549 QgsMeshVectorStreamlineRenderer(
553 const QVector<double> &datasetMagValues,
554 bool dataIsOnVertices,
558 QgsMeshLayerRendererFeedback *feedBack,
561 void draw()
override;
564 std::unique_ptr<QgsMeshStreamlinesField> mStreamlineField;
579class QgsMeshVectorTraceRenderer:
public QgsMeshVectorRenderer
583 QgsMeshVectorTraceRenderer(
587 bool dataIsOnVertices,
593 void draw()
override;
596 std::unique_ptr<QgsMeshParticleTracesField> mParticleField;
620 bool dataIsOnVertices,
669 std::unique_ptr<QgsMeshParticleTracesField> mParticleField;
673 double mParticleLifeTime = 5;
675 void updateFieldParameter();
Class defining color to render mesh datasets.
Perform transforms between map coordinates and device coordinates.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e....
Represents a mesh layer supporting display of data on structured or unstructured meshes.
Represents a renderer settings for vector datasets.
A wrapper for QgsMeshParticuleTracesField used to render the particles.
void setParticlesLifeTime(double particleLifeTime)
Sets maximum life time of particles in seconds.
QgsMeshVectorTraceAnimationGenerator & operator=(const QgsMeshVectorTraceAnimationGenerator &other)
Assignment operator.
void setMinimumTailLength(int l)
Sets the minimum tail length.
QgsMeshVectorTraceAnimationGenerator(const QgsMeshVectorTraceAnimationGenerator &other)
Copy constructor.
void setTailPersitence(double p)
Sets the visual persistence of the tail.
void setParticlesColor(const QColor &c)
Sets colors of particle.
QImage imageRendered()
Moves all the particles using frame per second (fps) to calculate the displacement and return the ren...
QgsMeshVectorTraceAnimationGenerator(QgsMeshLayer *layer, const QgsRenderContext &rendererContext)
Constructor to use with Python binding.
void setTailFactor(double fct)
Sets the tail factor, used to adjust the length of the tail. 0 : minimum length, >1 increase the tail...
~QgsMeshVectorTraceAnimationGenerator()=default
Destructor.
void setFPS(int FPS)
Sets the number of frames per seconds that will be rendered.
QgsMeshVectorTraceAnimationGenerator(const QgsTriangularMesh &triangularMesh, const QgsMeshDataBlock &dataSetVectorValues, const QgsMeshDataBlock &scalarActiveFaceFlagValues, bool dataIsOnVertices, const QgsRenderContext &rendererContext, const QgsRectangle &layerExtent, double magMax, const QgsMeshRendererVectorSettings &vectorSettings)
Constructor to use from QgsMeshVectorRenderer.
void setParticlesSize(double width)
Sets particle size in px.
void setMaxSpeedPixel(int max)
Sets the max number of pixels that can be go through by the particles in 1 second.
void seedRandomParticles(int count)
seeds particles in the vector fields
A class to represent a 2D point.
A rectangle specified with double values.
Contains information about the context of a rendering operation.
Triangular/Derived Mesh is mesh with vertices in map coordinates.
A class to represent a vector.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
QVector< int > QgsMeshFace
List of vertex indexes.