18 #ifndef QGSMESHTRACERENDERER_H 19 #define QGSMESHTRACERENDERER_H 25 #include "qgis_core.h" 45 class QgsMeshVectorValueInterpolator
58 QgsMeshVectorValueInterpolator(
const QgsMeshVectorValueInterpolator &other );
61 virtual QgsMeshVectorValueInterpolator *clone() = 0;
64 virtual ~QgsMeshVectorValueInterpolator() =
default;
70 QgsMeshVectorValueInterpolator &operator=(
const QgsMeshVectorValueInterpolator &other );
73 void updateCacheFaceIndex(
const QgsPointXY &point )
const;
79 mutable int mCacheFaceIndex = -1;
80 bool mUseScalarActiveFaceFlagValues =
false;
81 bool isVectorValid(
const QgsVector &v )
const;
85 void activeFaceFilter(
QgsVector &vector,
int faceIndex )
const;
87 virtual QgsVector interpolatedValuePrivate(
int faceIndex,
const QgsPointXY point )
const = 0;
98 class QgsMeshVectorValueInterpolatorFromVertex:
public QgsMeshVectorValueInterpolator
102 QgsMeshVectorValueInterpolatorFromVertex(
const QgsTriangularMesh &triangularMesh,
106 QgsMeshVectorValueInterpolatorFromVertex(
const QgsTriangularMesh &triangularMesh,
111 QgsMeshVectorValueInterpolatorFromVertex(
const QgsMeshVectorValueInterpolatorFromVertex &other );
114 virtual QgsMeshVectorValueInterpolatorFromVertex *clone()
override;
117 QgsMeshVectorValueInterpolatorFromVertex &operator=(
const QgsMeshVectorValueInterpolatorFromVertex &other );
120 QgsVector interpolatedValuePrivate(
int faceIndex,
const QgsPointXY point )
const override;
131 class QgsMeshVectorValueInterpolatorFromFace:
public QgsMeshVectorValueInterpolator
144 QgsMeshVectorValueInterpolatorFromFace(
const QgsMeshVectorValueInterpolatorFromFace &other );
147 virtual QgsMeshVectorValueInterpolatorFromFace *clone()
override;
150 QgsMeshVectorValueInterpolatorFromFace &operator=(
const QgsMeshVectorValueInterpolatorFromFace &other );
153 QgsVector interpolatedValuePrivate(
int faceIndex,
const QgsPointXY point )
const override;
164 class QgsMeshStreamField
180 double magnitudeMaximum,
181 bool dataIsOnVertices,
183 int resolution = 1 );
186 QgsMeshStreamField(
const QgsMeshStreamField &other );
189 virtual ~QgsMeshStreamField();
206 bool isValid()
const;
212 QPoint topLeft()
const;
215 void addTrace( QPoint startPixel );
221 void addRandomTraces();
224 void addRandomTrace();
227 void addGriddedTraces(
int dx,
int dy );
233 void setResolution(
int width );
236 int resolution()
const;
239 QSize imageSize()
const;
242 virtual QImage image();
245 void setPixelFillingDensity(
double maxFilling );
248 void setColor( QColor color );
251 void setLineWidth(
double width );
254 void setFilter(
double min,
double max );
257 void setMinimizeFieldSize(
bool minimizeFieldSize );
260 QgsMeshStreamField &operator=(
const QgsMeshStreamField &other );
264 QPointF fieldToDevice(
const QPoint &pixel )
const;
265 bool filterMag(
double value )
const;
268 QgsPointXY positionToMapCoordinates(
const QPoint &pixelPosition,
const QgsPointXY &positionInPixel );
269 bool addPixelToChunkTrace( QPoint &pixel,
270 QgsMeshStreamField::FieldData &data,
271 std::list<QPair<QPoint, QgsMeshStreamField::FieldData> > &chunkTrace );
272 void setChunkTrace( std::list<QPair<QPoint, FieldData>> &chunkTrace );
273 virtual void drawChunkTrace(
const std::list<QPair<QPoint, FieldData>> &chunkTrace ) = 0;
274 void clearChunkTrace( std::list<QPair<QPoint, FieldData>> &chunkTrace );
275 virtual void storeInField(
const QPair<QPoint, FieldData> pixelData ) = 0;
276 virtual void initField() = 0;
277 void simplifyChunkTrace( std::list<QPair<QPoint, FieldData>> &shunkTrace );
279 virtual bool isTraceExists(
const QPoint &pixel )
const = 0;
280 bool isTraceOutside(
const QPoint &pixel )
const;
285 std::unique_ptr<QPainter> mPainter = std::unique_ptr<QPainter>( nullptr );
286 int mFieldResolution = 1;
293 int mPixelFillingCount = 0;
294 int mMaxPixelFillingCount = 0;
295 std::unique_ptr<QgsMeshVectorValueInterpolator> mVectorValueInterpolator;
298 QPoint mFieldTopLeftInDeviceCoordinates;
300 double mMaximumMagnitude = 0;
301 double mPixelFillingDensity = 0;
302 double mMinMagFilter = -1;
303 double mMaxMagFilter = -1;
305 bool mMinimizeFieldSize =
true;
316 class QgsMeshStreamlinesField:
public QgsMeshStreamField
327 QgsMeshStreamlinesField(
const QgsMeshStreamlinesField &other );
330 QgsMeshStreamlinesField &operator=(
const QgsMeshStreamlinesField &other );
333 void storeInField(
const QPair<QPoint, FieldData> pixelData )
override;
334 void initField()
override;
335 bool isTraceExists(
const QPoint &pixel )
const override;
336 void drawChunkTrace(
const std::list<QPair<QPoint, FieldData> > &chunkTrace )
override;
338 QVector<bool> mField;
342 class QgsMeshParticleTracesField;
352 struct QgsMeshTraceParticle
356 std::list<QPoint> tail;
357 double remainingTime = 0;
368 class QgsMeshParticleTracesField:
public QgsMeshStreamField
377 bool dataIsOnVertices,
381 QgsMeshParticleTracesField(
const QgsMeshParticleTracesField &other );
384 void addParticle(
const QPoint &startPoint,
double lifeTime );
387 void addParticleXY(
const QgsPointXY &startPoint,
double lifeTime );
390 void addRandomParticles();
393 void moveParticles();
396 QImage imageRendered()
const;
399 void setParticlesCount(
int particlesCount );
402 void setParticlesLifeTime(
double particlesLifeTime );
412 void setStumpFactor(
int sf );
415 void setTimeStep(
double timeStep );
418 void setParticleColor(
const QColor &particleColor );
421 void setParticleSize(
double particleSize );
424 void setTailFactor(
double tailFactor );
427 void setMinTailLength(
int minTailLength );
430 QgsMeshParticleTracesField &operator=(
const QgsMeshParticleTracesField &other );
433 void setStumpParticleWithLifeTime(
bool stumpParticleWithLifeTime );
436 QPoint direction( QPoint position )
const;
438 float time( QPoint position )
const;
440 void drawParticleTrace(
const QgsMeshTraceParticle &particle );
442 void storeInField(
const QPair<QPoint, FieldData> pixelData )
override;
443 void initField()
override;
444 bool isTraceExists(
const QPoint &pixel )
const override;
445 void drawChunkTrace(
const std::list<QPair<QPoint, FieldData>> &chunkTrace )
override {Q_UNUSED( chunkTrace );}
454 QVector<float> mTimeField;
469 QVector<char> mDirectionField;
470 QList<QgsMeshTraceParticle> mParticles;
473 double mTimeStep = 200;
474 double mParticlesLifeTime = 5000;
475 int mParticlesCount = 1000;
476 double mTailFactor = 5;
477 int mMinTailLength = 3;
478 QColor mParticleColor = Qt::white;
479 double mParticleSize = 2.5;
480 int mStumpFactor = 50;
481 bool mStumpParticleWithLifeTime =
true;
492 class QgsMeshVectorStreamlineRenderer:
public QgsMeshVectorRenderer
499 bool dataIsOnVertices,
505 void draw()
override;
508 std::unique_ptr<QgsMeshStreamField> mStreamlineField;
521 class QgsMeshVectorTraceRenderer:
public QgsMeshVectorRenderer
528 bool dataIsOnVertices,
534 void draw()
override;
537 std::unique_ptr<QgsMeshParticleTracesField> mParticleField;
560 bool dataIsOnVertices,
575 void seedRandomParticles(
int count );
578 QImage imageRendered();
581 void setFPS(
int FPS );
584 void setMaxSpeedPixel(
int max );
587 void setParticlesLifeTime(
double particleLifeTime );
590 void setParticlesColor(
const QColor &
c );
593 void setParticlesSize(
double width );
596 void setTailFactor(
double fct );
599 void setMinimumTailLength(
int l );
602 void setTailPersitence(
double p );
607 std::unique_ptr<QgsMeshParticleTracesField> mParticleField;
611 double mParticleLifeTime = 5;
613 void updateFieldParameter();
616 #endif // QGSMESHTRACERENDERER_H A rectangle specified with double values.
Triangular/Derived Mesh is mesh with vertices in map coordinates.
A class to represent a 2D point.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e...
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
Perform transforms between map coordinates and device coordinates.
A wrapper for QgsMeshParticuleTracesField used to render the particles.
Represents a streamline renderer settings for vector datasets.
A class to represent a vector.
Contains information about the context of a rendering operation.
QVector< int > QgsMeshFace
List of vertex indexes.
Represents a mesh layer supporting display of data on structured or unstructured meshes.