Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
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
30 Q_ASSERT(xf.type() <= QTransform::TxScale
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:25
\inmodule QtCore\reentrant
Definition qrect.h:484
\inmodule QtCore\reentrant
Definition qrect.h:30
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:472
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
rect
[4]
Combined button and popup list for selecting options.
bool qFuzzyIsNull(qfloat16 f) noexcept
Definition qfloat16.h:349
#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:187