Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qclipperutils_p.h
Go to the documentation of this file.
1// Copyright (C) 2021 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#ifndef QCLIPPERUTILS_P_H
4#define QCLIPPERUTILS_P_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17/*
18 * This file is intended to be include only in source files of
19 * QtPositioning/QtLocation. It is in QtPositioning to enable manipulation
20 * of geo polygons
21 */
22
23#include <QtPositioning/private/qpositioningglobal_p.h>
24#include <QtCore/QtGlobal>
25#include <QtCore/QList>
26#include <QtPositioning/private/qdoublevector2d_p.h>
27
28QT_BEGIN_NAMESPACE
29
30/*
31 * This class provides a wrapper around the clip2tri library, so that
32 * we do not need to export any of the internal types. That is needed
33 * because after QtLocation and QtPositioning are moved to different
34 * repos, we need to use the features of the library in QtLocation without
35 * explicitly linking to it.
36*/
37
38class QClipperUtilsPrivate;
39class Q_POSITIONING_EXPORT QClipperUtils
40{
41public:
42 QClipperUtils();
43 QClipperUtils(const QClipperUtils &other);
44 ~QClipperUtils();
45
46 // Must be in sync with c2t::clip2tri::Operation
47 enum Operation {
48 Union,
49 Intersection,
50 Difference,
51 Xor
52 };
53
54 // Must be in sync with QtClipperLib::PolyFillType
55 enum PolyFillType {
56 pftEvenOdd,
57 pftNonZero,
58 pftPositive,
59 pftNegative
60 };
61
62 static double clipperScaleFactor();
63
64 static int pointInPolygon(const QDoubleVector2D &point, const QList<QDoubleVector2D> &polygon);
65
66 // wrap some useful non-static methods of c2t::clip2tri
67 void clearClipper();
68 void addSubjectPath(const QList<QDoubleVector2D> &path, bool closed);
69 void addClipPolygon(const QList<QDoubleVector2D> &path);
70 QList<QList<QDoubleVector2D>> execute(Operation op, PolyFillType subjFillType = pftNonZero,
71 PolyFillType clipFillType = pftNonZero);
72
73 // For optimization purposes. Set the polygon once and check for multiple
74 // points. Without the need to convert between Qt and clip2tri types
75 // every time
76 void setPolygon(const QList<QDoubleVector2D> &polygon);
77 int pointInPolygon(const QDoubleVector2D &point) const;
78
79private:
80 QClipperUtilsPrivate *d_ptr;
81};
82
83QT_END_NAMESPACE
84
85#endif // QCLIPPERUTILS_P_H
c2t::clip2tri m_clipper
Combined button and popup list for selecting options.
static IntPoint toIntPoint(const QDoubleVector2D &p)
static const double kClipperScaleFactor
static QDoubleVector2D toVector2D(const IntPoint &p)
static const double kClipperScaleFactorInv
static QList< QList< QDoubleVector2D > > pathsToQList(const Paths &paths)
static QList< QDoubleVector2D > pathToQList(const Path &path)
static Path qListToPath(const QList< QDoubleVector2D > &list)