Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qmath_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QMATH_P_H
5#define QMATH_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <qmath.h>
19#include <private/qglobal_p.h>
20#include <qtransform.h>
21
23
24static const qreal Q_PI = qreal(M_PI); // pi
25static const qreal Q_MM_PER_INCH = 25.4;
26
27inline QRect qt_mapFillRect(const QRectF &rect, const QTransform &xf)
28{
29 // Only for xf <= scaling or 90 degree rotations
31 || (xf.type() == QTransform::TxRotate && qFuzzyIsNull(xf.m11()) && qFuzzyIsNull(xf.m22())));
32 // Transform the corners instead of the rect to avoid hitting numerical accuracy limit
33 // when transforming topleft and size separately and adding afterwards,
34 // as that can sometimes be slightly off around the .5 point, leading to wrong rounding
35 QPoint pt1 = xf.map(rect.topLeft()).toPoint();
36 QPoint pt2 = xf.map(rect.bottomRight()).toPoint();
37 // Normalize and adjust for the QRect vs. QRectF bottomright
38 return QRect::span(pt1, pt2).adjusted(0, 0, -1, -1);
39}
40
42
43#endif // QMATH_P_H
\inmodule QtCore\reentrant
Definition qpoint.h:23
\inmodule QtCore\reentrant
Definition qrect.h:483
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition qrect.h:369
static constexpr QRect span(const QPoint &p1, const QPoint &p2) noexcept
Returns a rectangle spanning the two points p1 and p2, including both and everything in between.
Definition qrect.h:471
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
QPoint map(const QPoint &p) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
qreal m11() const
Returns the horizontal scaling factor.
Definition qtransform.h:199
TransformationType type() const
Returns the transformation type of this matrix.
qreal m22() const
Returns the vertical scaling factor.
Definition qtransform.h:215
rect
[4]
Combined button and popup list for selecting options.
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:303
#define M_PI
Definition qmath.h:209
static const qreal Q_MM_PER_INCH
Definition qmath_p.h:25
QRect qt_mapFillRect(const QRectF &rect, const QTransform &xf)
Definition qmath_p.h:27
static QT_BEGIN_NAMESPACE const qreal Q_PI
Definition qmath_p.h:24
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
double qreal
Definition qtypes.h:92