QGIS API Documentation 4.3.0-Master (0cef2469b72)
Loading...
Searching...
No Matches
qgsvectorfieldengine.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorfieldengine.h
3 ---------------------
4 begin : September 2026
5 copyright : (C) 2026 by Stefanos Natsis
6 email : uclaros at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSVECTORFIELDENGINE_H
17#define QGSVECTORFIELDENGINE_H
18
19#include <memory>
20
22#include "qgspointxy.h"
24
25#include <QSize>
26
27#define SIP_NO_FILE
28
30class QgsFeedback;
35
46{
47 public:
49 QgsVectorFieldEngine( double datasetMagMaximumValue, double datasetMagMinimumValue, const QgsVectorFieldSettings &settings, QgsRenderContext &context, QSize size );
52
55
62 double glyphExtentBuffer() const;
63
71 void drawGlyph( const QgsPointXY &lineStart, double xVal, double yVal, double magnitude );
72
84 void drawGlyphs( std::unique_ptr<QgsVectorFieldValueSource> source, const QgsPointXY &anchor, QgsFeedback *feedback = nullptr );
85
92 void drawStreamlines( std::unique_ptr<QgsVectorFieldValueSource> source, QgsRasterBlockFeedback *feedback = nullptr );
93
98 void drawTraces( std::unique_ptr<QgsVectorFieldValueSource> source );
99
100 private:
102 struct GlyphLayout
103 {
104 QgsPointXY origin;
105 double spacingX = 0;
106 double spacingY = 0;
107
109 bool isValid() const { return spacingX > 0 && spacingY > 0; }
110 };
111
117 GlyphLayout glyphLayout( const QgsPointXY &anchor, const QgsVectorFieldValueSource &source ) const;
118
120 void drawArrow( const QgsPointXY &lineStart, double xVal, double yVal, double magnitude );
121
123 void drawWindBarb( const QgsPointXY &lineStart, double xVal, double yVal, double magnitude );
124
126 bool calcVectorLineEnd(
127 QgsPointXY &lineEnd,
128 double &vectorLength,
129 double &cosAlpha,
130 double &sinAlpha, //out
131 const QgsPointXY &lineStart,
132 double xVal,
133 double yVal,
134 double magnitude //in
135 );
136
137 double mMinMag = 0.0;
138 double mMaxMag = 0.0;
139
140 QgsRenderContext &mContext;
141 const QgsVectorFieldSettings mCfg;
142 QgsInterpolatedLineColor mVectorColoring;
143
144 QSize mOutputSize;
145
146 std::unique_ptr<QgsCoordinateTransform> mGeographicTransform;
147 std::unique_ptr<QgsScopedQPainterState> mScopedPainterState;
148};
149
150#endif // QGSVECTORFIELDENGINE_H
Handles coordinate transforms between two coordinate systems.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Represents a 2D point.
Definition qgspointxy.h:62
Feedback object tailored for raster block reading.
Contains information about the context of a rendering operation.
Scoped object for saving and restoring a QPainter object's state.
QgsVectorFieldEngine(double datasetMagMaximumValue, double datasetMagMinimumValue, const QgsVectorFieldSettings &settings, QgsRenderContext &context, QSize size)
Ctor.
void drawGlyph(const QgsPointXY &lineStart, double xVal, double yVal, double magnitude)
Draws a single glyph at lineStart, in painter coordinates, using the symbology of the settings the en...
QgsVectorFieldEngine(const QgsVectorFieldEngine &)=delete
void drawStreamlines(std::unique_ptr< QgsVectorFieldValueSource > source, QgsRasterBlockFeedback *feedback=nullptr)
Integrates and draws streamlines over the whole rendered extent, sampling the vector field from sourc...
QgsVectorFieldEngine & operator=(const QgsVectorFieldEngine &)=delete
void drawGlyphs(std::unique_ptr< QgsVectorFieldValueSource > source, const QgsPointXY &anchor, QgsFeedback *feedback=nullptr)
Draws one glyph per position of the placement grid described by the settings the engine was construct...
void drawTraces(std::unique_ptr< QgsVectorFieldValueSource > source)
Seeds particles over the whole rendered extent, moves them one time step and draws their traces,...
double glyphExtentBuffer() const
Returns the distance, in painter units, by which the rendered extent must be grown so that glyphs cen...
Represents a renderer settings for vector datasets.
Abstract source of vector (u/v) values sampled at arbitrary map positions.