18#ifndef QGSMESHTRACERENDERER_H
19#define QGSMESHTRACERENDERER_H
33class QgsMeshLayerInterpolator;
34class QgsMeshLayerRendererFeedback;
48class QgsMeshVectorValueInterpolator
52 QgsMeshVectorValueInterpolator(
57 QgsMeshVectorValueInterpolator(
62 QgsMeshVectorValueInterpolator(
const QgsMeshVectorValueInterpolator &other );
65 virtual QgsMeshVectorValueInterpolator *clone() = 0;
67 virtual ~QgsMeshVectorValueInterpolator() =
default;
76 QgsMeshVectorValueInterpolator &operator=(
const QgsMeshVectorValueInterpolator &other );
79 void updateCacheFaceIndex(
const QgsPointXY &point )
const;
85 mutable int mCacheFaceIndex = -1;
86 bool mUseScalarActiveFaceFlagValues =
false;
87 bool isVectorValid(
const QgsVector &v )
const;
91 void activeFaceFilter(
QgsVector &vector,
int faceIndex )
const;
93 virtual QgsVector interpolatedValuePrivate(
int faceIndex,
const QgsPointXY point )
const = 0;
104class QgsMeshVectorValueInterpolatorFromVertex:
public QgsMeshVectorValueInterpolator
108 QgsMeshVectorValueInterpolatorFromVertex(
113 QgsMeshVectorValueInterpolatorFromVertex(
118 QgsMeshVectorValueInterpolatorFromVertex(
const QgsMeshVectorValueInterpolatorFromVertex &other );
121 virtual QgsMeshVectorValueInterpolatorFromVertex *clone()
override;
123 QgsMeshVectorValueInterpolatorFromVertex &operator=(
const QgsMeshVectorValueInterpolatorFromVertex &other );
126 QgsVector interpolatedValuePrivate(
int faceIndex,
const QgsPointXY point )
const override;
137class QgsMeshVectorValueInterpolatorFromFace:
public QgsMeshVectorValueInterpolator
141 QgsMeshVectorValueInterpolatorFromFace(
146 QgsMeshVectorValueInterpolatorFromFace(
151 QgsMeshVectorValueInterpolatorFromFace(
const QgsMeshVectorValueInterpolatorFromFace &other );
154 virtual QgsMeshVectorValueInterpolatorFromFace *clone()
override;
156 QgsMeshVectorValueInterpolatorFromFace &operator=(
const QgsMeshVectorValueInterpolatorFromFace &other );
159 QgsVector interpolatedValuePrivate(
int faceIndex,
const QgsPointXY point )
const override;
170class QgsMeshStreamField
187 double magnitudeMaximum,
188 bool dataIsOnVertices,
191 int resolution = 1 );
193 QgsMeshStreamField(
const QgsMeshStreamField &other );
194 virtual ~QgsMeshStreamField();
211 bool isValid()
const;
217 QPoint topLeft()
const;
220 void addTrace( QPoint startPixel );
226 void addRandomTraces();
229 void addRandomTrace();
232 void addGriddedTraces(
int dx,
int dy );
238 void setResolution(
int width );
241 int resolution()
const;
244 QSize imageSize()
const;
247 virtual QImage image()
const;
250 void setPixelFillingDensity(
double maxFilling );
253 void setColor( QColor color );
256 void setLineWidth(
double width );
259 void setFilter(
double min,
double max );
262 void setMinimizeFieldSize(
bool minimizeFieldSize );
265 QgsMeshStreamField &operator=(
const QgsMeshStreamField &other );
268 virtual void initImage();
269 QPointF fieldToDevice(
const QPoint &pixel )
const;
270 bool filterMag(
double value )
const;
271 bool isTraceOutside(
const QPoint &pixel )
const;
274 QgsPointXY positionToMapCoordinates(
const QPoint &pixelPosition,
const QgsPointXY &positionInPixel );
275 bool addPixelToChunkTrace( QPoint &pixel,
276 QgsMeshStreamField::FieldData &data,
277 std::list<QPair<QPoint, QgsMeshStreamField::FieldData> > &chunkTrace );
278 void setChunkTrace( std::list<QPair<QPoint, FieldData>> &chunkTrace );
279 virtual void drawTrace(
const QPoint & )
const {}
280 void clearChunkTrace( std::list<QPair<QPoint, FieldData>> &chunkTrace );
281 virtual void storeInField(
const QPair<QPoint, FieldData> pixelData ) = 0;
282 virtual void initField() = 0;
283 void simplifyChunkTrace( std::list<QPair<QPoint, FieldData>> &shunkTrace );
285 virtual bool isTraceExists(
const QPoint &pixel )
const = 0;
290 std::unique_ptr<QPainter> mPainter = std::unique_ptr<QPainter>(
nullptr );
291 int mFieldResolution = 1;
312 QVector<unsigned char> mDirectionField;
316 int mPixelFillingCount = 0;
317 int mMaxPixelFillingCount = 0;
318 std::unique_ptr<QgsMeshVectorValueInterpolator> mVectorValueInterpolator;
321 QPoint mFieldTopLeftInDeviceCoordinates;
323 double mMaximumMagnitude = 0;
324 double mPixelFillingDensity = 0;
325 double mMinMagFilter = -1;
326 double mMaxMagFilter = -1;
327 bool mMinimizeFieldSize =
true;
338class QgsMeshStreamlinesField:
public QgsMeshStreamField
342 Q_DECL_DEPRECATED QgsMeshStreamlinesField(
const QgsTriangularMesh &triangularMesh,
347 bool dataIsOnVertices,
354 const QVector<double> &datasetMagValues,
356 QgsMeshLayerRendererFeedback *feedBack,
358 bool dataIsOnVertices,
365 void storeInField(
const QPair<QPoint, FieldData> pixelData )
override;
366 void initField()
override;
367 void initImage()
override;
368 bool isTraceExists(
const QPoint &pixel )
const override;
369 void drawTrace(
const QPoint &start )
const override;
371 QVector<bool> mField;
372 QImage mDrawingTraceImage;
373 std::unique_ptr<QPainter> mDrawingTracePainter;
377 QVector<double> mMagValues;
380 QgsMeshLayerRendererFeedback *mFeedBack =
nullptr;
384class QgsMeshParticleTracesField;
394struct QgsMeshTraceParticle
398 std::list<QPoint> tail;
399 double remainingTime = 0;
410class QgsMeshParticleTracesField:
public QgsMeshStreamField
419 bool dataIsOnVertices,
423 QgsMeshParticleTracesField(
const QgsMeshParticleTracesField &other );
426 void addParticle(
const QPoint &startPoint,
double lifeTime );
429 void addParticleXY(
const QgsPointXY &startPoint,
double lifeTime );
432 void addRandomParticles();
435 void moveParticles();
438 QImage imageRendered()
const;
441 void setParticlesCount(
int particlesCount );
444 void setParticlesLifeTime(
double particlesLifeTime );
454 void setStumpFactor(
int sf );
457 void setTimeStep(
double timeStep );
460 void setParticleSize(
double particleSize );
463 void setTailFactor(
double tailFactor );
466 void setMinTailLength(
int minTailLength );
469 void setStumpParticleWithLifeTime(
bool stumpParticleWithLifeTime );
472 void setParticlesColor(
const QColor &
c );
474 QgsMeshParticleTracesField &operator=(
const QgsMeshParticleTracesField &other );
477 QPoint direction( QPoint position )
const;
479 float time( QPoint position )
const;
480 float magnitude( QPoint position )
const;
482 void drawParticleTrace(
const QgsMeshTraceParticle &particle );
484 void storeInField(
const QPair<QPoint, FieldData> pixelData )
override;
485 void initField()
override;
486 bool isTraceExists(
const QPoint &pixel )
const override;
495 QVector<float> mTimeField;
496 QVector<float> mMagnitudeField;
498 QList<QgsMeshTraceParticle> mParticles;
501 double mTimeStep = 200;
502 double mParticlesLifeTime = 5000;
503 int mParticlesCount = 1000;
504 double mTailFactor = 5;
505 int mMinTailLength = 3;
506 QColor mParticleColor = Qt::white;
507 double mParticleSize = 2.5;
508 int mStumpFactor = 50;
509 bool mStumpParticleWithLifeTime =
true;
522class QgsMeshVectorStreamlineRenderer:
public QgsMeshVectorRenderer
526 Q_DECL_DEPRECATED QgsMeshVectorStreamlineRenderer(
530 bool dataIsOnVertices,
536 QgsMeshVectorStreamlineRenderer(
540 const QVector<double> &datasetMagValues,
541 bool dataIsOnVertices,
545 QgsMeshLayerRendererFeedback *feedBack,
548 void draw()
override;
551 std::unique_ptr<QgsMeshStreamlinesField> mStreamlineField;
566class QgsMeshVectorTraceRenderer:
public QgsMeshVectorRenderer
570 QgsMeshVectorTraceRenderer(
574 bool dataIsOnVertices,
580 void draw()
override;
583 std::unique_ptr<QgsMeshParticleTracesField> mParticleField;
607 bool dataIsOnVertices,
653 std::unique_ptr<QgsMeshParticleTracesField> mParticleField;
657 double mParticleLifeTime = 5;
659 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)
void setMinimumTailLength(int l)
Sets the minimum tail length.
QgsMeshVectorTraceAnimationGenerator(const QgsMeshVectorTraceAnimationGenerator &other)
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
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.