27 QVector<double> QgsMeshLayerUtils::calculateMagnitudes(
const QgsMeshDataBlock &block )
30 int count = block.
count();
31 QVector<double> ret( count );
33 for (
int i = 0; i < count; ++i )
41 void QgsMeshLayerUtils::boundingBoxToScreenRectangle(
const QgsMapToPixel &mtp,
42 const QSize &outputSize,
51 topLim = std::max(
int( ur.
y() ), 0 );
52 bottomLim = std::min(
int( ll.
y() ), outputSize.height() - 1 );
53 leftLim = std::max(
int( ll.
x() ), 0 );
54 rightLim = std::min(
int( ur.
x() ), outputSize.width() - 1 );
57 static void lamTol(
double &lam )
59 const static double eps = 1e-6;
60 if ( ( lam < 0.0 ) && ( lam > -eps ) )
67 double &lam1,
double &lam2,
double &lam3 )
69 if ( pA == pB || pA == pC || pB == pC )
78 double dot00 = v0 * v0;
79 double dot01 = v0 * v1;
80 double dot02 = v0 * v2;
81 double dot11 = v1 * v1;
82 double dot12 = v1 * v2;
85 double invDenom = 1.0 / ( dot00 * dot11 - dot01 * dot01 );
86 lam1 = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;
87 lam2 = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;
88 lam3 = 1.0 - lam1 - lam2;
96 if ( ( lam1 < 0 ) || ( lam2 < 0 ) || ( lam3 < 0 ) )
105 double val1,
double val2,
double val3,
const QgsPointXY &pt )
107 double lam1, lam2, lam3;
108 if ( !E3T_physicalToBarycentric( p1, p2, p3, pt, lam1, lam2, lam3 ) )
109 return std::numeric_limits<double>::quiet_NaN();
111 return lam1 * val3 + lam2 * val2 + lam3 * val1;
117 double lam1, lam2, lam3;
118 if ( !E3T_physicalToBarycentric( p1, p2, p3, pt, lam1, lam2, lam3 ) )
119 return std::numeric_limits<double>::quiet_NaN();
127 double xMin = p1.
x();
128 double xMax = p1.
x();
129 double yMin = p1.
y();
130 double yMax = p1.
y();
133 xMin = ( ( xMin < p2.
x() ) ? xMin : p2.
x() );
134 xMax = ( ( xMax > p2.
x() ) ? xMax : p2.
x() );
135 yMin = ( ( yMin < p2.
y() ) ? yMin : p2.
y() );
136 yMax = ( ( yMax > p2.
y() ) ? yMax : p2.
y() );
139 xMin = ( ( xMin < p3.
x() ) ? xMin : p3.
x() );
140 xMax = ( ( xMax > p3.
x() ) ? xMax : p3.
x() );
141 yMin = ( ( yMin < p3.
y() ) ? yMin : p3.
y() );
142 yMax = ( ( yMax > p3.
y() ) ? yMax : p3.
y() );
155 int seconds =
static_cast<int>( hours * 3600.0 );
156 dateTime = dateTime.addSecs( seconds );
159 ret = dateTime.toString();
164 format = format.trimmed();
166 int totalHours =
static_cast<int>( hours );
168 if ( format == QStringLiteral(
"hh:mm:ss.zzz" ) )
170 int ms =
static_cast<int>( hours * 3600.0 * 1000 );
171 int seconds = ms / 1000;
173 int m = seconds / 60;
174 int s = seconds % 60;
177 ret = QStringLiteral(
"%1:%2:%3.%4" ).
178 arg( h, 2, 10, QLatin1Char(
'0' ) ).
179 arg( m, 2, 10, QLatin1Char(
'0' ) ).
180 arg( s, 2, 10, QLatin1Char(
'0' ) ).
181 arg( z, 3, 10, QLatin1Char(
'0' ) );
183 else if ( format == QStringLiteral(
"hh:mm:ss" ) )
185 int seconds =
static_cast<int>( hours * 3600.0 );
186 int m = seconds / 60;
187 int s = seconds % 60;
190 ret = QStringLiteral(
"%1:%2:%3" ).
191 arg( h, 2, 10, QLatin1Char(
'0' ) ).
192 arg( m, 2, 10, QLatin1Char(
'0' ) ).
193 arg( s, 2, 10, QLatin1Char(
'0' ) );
196 else if ( format == QStringLiteral(
"d hh:mm:ss" ) )
198 int seconds =
static_cast<int>( hours * 3600.0 );
199 int m = seconds / 60;
200 int s = seconds % 60;
203 int d = totalHours / 24;
205 ret = QStringLiteral(
"%1 d %2:%3:%4" ).
207 arg( h, 2, 10, QLatin1Char(
'0' ) ).
208 arg( m, 2, 10, QLatin1Char(
'0' ) ).
209 arg( s, 2, 10, QLatin1Char(
'0' ) );
211 else if ( format == QStringLiteral(
"d hh" ) )
213 int d = totalHours / 24;
214 int h = totalHours % 24;
215 ret = QStringLiteral(
"%1 d %2" ).
219 else if ( format == QStringLiteral(
"d" ) )
221 int d = totalHours / 24;
222 ret = QStringLiteral(
"%1" ).arg( d );
224 else if ( format == QStringLiteral(
"ss" ) )
226 int seconds =
static_cast<int>( hours * 3600.0 );
227 ret = QStringLiteral(
"%1" ).arg( seconds );
231 ret = QStringLiteral(
"%1" ).arg( hours );
A rectangle specified with double values.
A class to represent a 2D point.
int count() const
Number of items stored in the block.
QgsMeshDataBlock is a block of integers/doubles that can be used to retrieve: active flags (e...
DataType type() const
Type of data stored in the block.
double relativeTimeOffsetHours() const
Returns number of offset hours for relative time formatting.
Perform transforms between map coordinates and device coordinates.
QgsPointXY transform(const QgsPointXY &p) const
Transform the point from map (world) coordinates to device coordinates.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
QString absoluteTimeFormat() const
Returns format used for absolute time.
Integer boolean flag whether face is active.
bool useAbsoluteTime() const
Returns whether to use absolute time format.
double scalar() const
Returns magnitude of vector for vector data or scalar value for scalar data.
Represents a mesh time settings for mesh datasets.
A class to represent a vector.
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QDateTime absoluteTimeReferenceTime() const
Returns reference time used for absolute time format.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
QgsMeshDatasetValue value(int index) const
Returns a value represented by the index For active flag the behavior is undefined.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
QString relativeTimeFormat() const
Returns format used for relative time.