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(
 
  348      bool dataIsOnVertices,
 
  352    QgsMeshStreamlinesField(
 
  356      const QVector<double> &datasetMagValues,
 
  358      QgsMeshLayerRendererFeedback *feedBack,
 
  360      bool dataIsOnVertices,
 
  367    void storeInField( 
const QPair<QPoint, FieldData> pixelData ) 
override;
 
  368    void initField() 
override;
 
  369    void initImage() 
override;
 
  370    bool isTraceExists( 
const QPoint &pixel ) 
const override;
 
  371    void drawTrace( 
const QPoint &start ) 
const override;
 
  373    QVector<bool> mField;
 
  374    QImage mDrawingTraceImage;
 
  375    std::unique_ptr<QPainter> mDrawingTracePainter;
 
  379    QVector<double> mMagValues;
 
  382    QgsMeshLayerRendererFeedback *mFeedBack = 
nullptr;
 
  386class QgsMeshParticleTracesField;
 
  396struct QgsMeshTraceParticle
 
  400  std::list<QPoint> tail;
 
  401  double remainingTime = 0; 
 
  412class QgsMeshParticleTracesField: 
public QgsMeshStreamField
 
  416    QgsMeshParticleTracesField(
 
  422      bool dataIsOnVertices,
 
  426    QgsMeshParticleTracesField( 
const QgsMeshParticleTracesField &other );
 
  429    void addParticle( 
const QPoint &startPoint, 
double lifeTime );
 
  432    void addParticleXY( 
const QgsPointXY &startPoint, 
double lifeTime );
 
  435    void addRandomParticles();
 
  438    void moveParticles();
 
  441    QImage imageRendered() 
const;
 
  444    void setParticlesCount( 
int particlesCount );
 
  447    void setParticlesLifeTime( 
double particlesLifeTime );
 
  457    void setStumpFactor( 
int sf );
 
  460    void setTimeStep( 
double timeStep );
 
  463    void setParticleSize( 
double particleSize );
 
  466    void setTailFactor( 
double tailFactor );
 
  469    void setMinTailLength( 
int minTailLength );
 
  472    void setStumpParticleWithLifeTime( 
bool stumpParticleWithLifeTime );
 
  475    void setParticlesColor( 
const QColor &
c );
 
  477    QgsMeshParticleTracesField &operator=( 
const QgsMeshParticleTracesField &other );
 
  480    QPoint direction( QPoint position ) 
const;
 
  482    float time( QPoint position ) 
const;
 
  483    float magnitude( QPoint position ) 
const;
 
  485    void drawParticleTrace( 
const QgsMeshTraceParticle &particle );
 
  487    void storeInField( 
const QPair<QPoint, FieldData> pixelData ) 
override;
 
  488    void initField() 
override;
 
  489    bool isTraceExists( 
const QPoint &pixel ) 
const override;
 
  498    QVector<float> mTimeField;
 
  499    QVector<float> mMagnitudeField;
 
  501    QList<QgsMeshTraceParticle> mParticles;
 
  504    double mTimeStep = 200;
 
  505    double mParticlesLifeTime = 5000;
 
  506    int mParticlesCount = 1000;
 
  507    double mTailFactor = 5;
 
  508    int mMinTailLength = 3;
 
  509    QColor mParticleColor = Qt::white;
 
  510    double mParticleSize = 2.5;
 
  511    int mStumpFactor = 50;
 
  512    bool mStumpParticleWithLifeTime = 
true;
 
  525class QgsMeshVectorStreamlineRenderer: 
public QgsMeshVectorRenderer
 
  529    Q_DECL_DEPRECATED QgsMeshVectorStreamlineRenderer(
 
  533      bool dataIsOnVertices,
 
  539    QgsMeshVectorStreamlineRenderer(
 
  543      const QVector<double> &datasetMagValues,
 
  544      bool dataIsOnVertices,
 
  548      QgsMeshLayerRendererFeedback *feedBack,
 
  551    void draw() 
override;
 
  554    std::unique_ptr<QgsMeshStreamlinesField> mStreamlineField;
 
  569class QgsMeshVectorTraceRenderer: 
public QgsMeshVectorRenderer
 
  573    QgsMeshVectorTraceRenderer(
 
  577      bool dataIsOnVertices,
 
  583    void draw() 
override;
 
  586    std::unique_ptr<QgsMeshParticleTracesField> mParticleField;
 
  610      bool dataIsOnVertices,
 
  656    std::unique_ptr<QgsMeshParticleTracesField> mParticleField;
 
  660    double mParticleLifeTime = 5;
 
  662    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.