13#ifndef QT_NO_DEBUG_STREAM
14#include <QtCore/QDebug>
17#ifndef QT_NO_DATASTREAM
18#include <QtCore/QDataStream>
23QT_IMPL_METATYPE_EXTERN(QGeoShape)
25QGeoShapePrivate::QGeoShapePrivate(QGeoShape::ShapeType type)
30QGeoShapePrivate::~QGeoShapePrivate()
34bool QGeoShapePrivate::operator==(
const QGeoShapePrivate &other)
const
36 return type == other.type;
40
41
42
44
45
46
47
48
49
50
51
52
53
54
55
58
59
60
61
62
63
64
65
66
67
70
71
72
73
74
75
76
77
80
81
82
83
84
85
86
87
88
89
90
91
92
95
96
97
98
99
100
101
102
103
104
105inline QGeoShapePrivate *QGeoShape::d_func()
107 return static_cast<QGeoShapePrivate *>(d_ptr.data());
110inline const QGeoShapePrivate *QGeoShape::d_func()
const
112 return static_cast<
const QGeoShapePrivate *>(d_ptr.constData());
116
117
118QGeoShape::QGeoShape()
123
124
125QGeoShape::QGeoShape(
const QGeoShape &other)
131
132
133QGeoShape::QGeoShape(QGeoShapePrivate *d)
138bool QGeoShape::equals(
const QGeoShape &lhs,
const QGeoShape &rhs)
140 if (lhs.d_func() == rhs.d_func())
143 if (!lhs.d_func() || !rhs.d_func())
146 return *lhs.d_func() == *rhs.d_func();
150
151
152QGeoShape::~QGeoShape()
157
158
159QGeoShape::ShapeType QGeoShape::type()
const
161 Q_D(
const QGeoShape);
170
171
172
173bool QGeoShape::isValid()
const
175 Q_D(
const QGeoShape);
184
185
186
187
188bool QGeoShape::isEmpty()
const
190 Q_D(
const QGeoShape);
199
200
201bool QGeoShape::contains(
const QGeoCoordinate &coordinate)
const
203 Q_D(
const QGeoShape);
206 return d->contains(coordinate);
212
213
214
215
216
217QGeoRectangle QGeoShape::boundingGeoRectangle()
const
219 Q_D(
const QGeoShape);
222 return d->boundingGeoRectangle();
224 return QGeoRectangle();
228
229
230
233
234
235
236
237QGeoCoordinate QGeoShape::center()
const
239 Q_D(
const QGeoShape);
244 return QGeoCoordinate();
248
249
250
251
252
255
256
257
258
259
262
263
264QGeoShape &QGeoShape::operator=(
const QGeoShape &other)
274
275
276
277
278QString QGeoShape::toString()
const
280 return QStringLiteral(
"QGeoShape(%1)").arg(type());
283#ifndef QT_NO_DEBUG_STREAM
286 const auto size = coordinates.size();
288 for (qsizetype i = 0; i < size; ++i) {
295 dbg <<
'(' << coordinates.at(i).toString() <<
')';
299QDebug QGeoShape::debugStreaming(QDebug dbg,
const QGeoShape &shape)
301 QDebugStateSaver saver(dbg);
302 dbg.nospace().noquote() <<
"QGeoShape(";
303 switch (shape.type()) {
304 case QGeoShape::UnknownType:
307 case QGeoShape::RectangleType: {
308 const auto &rect =
static_cast<
const QGeoRectangle &>(shape);
309 dbg <<
"Rectangle, (" << rect.topLeft().toString() <<
"), ("
310 << rect.bottomRight().toString() <<
')';
313 case QGeoShape::PathType:
315 formatGeoCoordinates(dbg,
static_cast<
const QGeoPath &>(shape).path());
317 case QGeoShape::PolygonType:
319 formatGeoCoordinates(dbg,
static_cast<
const QGeoPolygon &>(shape).perimeter());
321 case QGeoShape::CircleType: {
322 const auto &circle =
static_cast<
const QGeoCircle &>(shape);
323 dbg <<
"Circle, center=(" << circle.center().toString() <<
"), radius=" << circle.radius();
334#ifndef QT_NO_DATASTREAM
335QDataStream &QGeoShape::dataStreamOut(QDataStream &stream,
const QGeoShape &shape)
337 stream << quint32(shape.type());
338 switch (shape.type()) {
339 case QGeoShape::UnknownType:
341 case QGeoShape::RectangleType: {
342 QGeoRectangle r = shape;
343 stream << r.topLeft() << r.bottomRight();
346 case QGeoShape::CircleType: {
347 QGeoCircle c = shape;
348 stream << c.center() << c.radius();
351 case QGeoShape::PathType: {
354 stream << p.path().size();
355 for (
const auto &c: p.path())
359 case QGeoShape::PolygonType: {
360 QGeoPolygon p = shape;
361 stream << p.perimeter().size();
362 for (
const auto &c: p.perimeter())
364 if (stream.version() >= QDataStream::Qt_6_10) {
366 const qsizetype holesCount = p.holesCount();
367 stream << holesCount;
368 for (qsizetype i = 0; i < holesCount; ++i)
369 stream << p.holePath(i);
378QDataStream &QGeoShape::dataStreamIn(QDataStream &stream, QGeoShape &shape)
384 case QGeoShape::UnknownType:
387 case QGeoShape::RectangleType: {
391 shape = QGeoRectangle(tl, br);
394 case QGeoShape::CircleType: {
398 shape = QGeoCircle(c, r);
401 case QGeoShape::PathType: {
402 QList<QGeoCoordinate> l;
408 for (qsizetype i = 0; i < sz; i++) {
412 shape = QGeoPath(l, width);
415 case QGeoShape::PolygonType: {
416 QList<QGeoCoordinate> l;
420 for (qsizetype i = 0; i < sz; i++) {
425 if (stream.version() >= QDataStream::Qt_6_10) {
427 qsizetype holesCount = 0;
428 stream >> holesCount;
429 for (qsizetype i = 0; i < holesCount; ++i) {
430 QList<QGeoCoordinate> holePath;
445
446
447
448
449
453 return shape.d_ptr->hash(seed);
455 return qHashMulti(seed, shape.type());
460#include "moc_qgeoshape.cpp"
static void formatGeoCoordinates(QDebug dbg, const QList< QGeoCoordinate > &coordinates)
constexpr size_t qHash(const QSize &s, size_t seed=0) noexcept