30 if (qFuzzyCompare(y1, y2)) {
34 qreal x_tmp = x2; x2 = x1; x1 = x_tmp;
35 qreal y_tmp = y2; y2 = y1; y1 = y_tmp;
39 if (y >= y1 && y < y2) {
40 qreal x = x1 + ((x2 - x1) / (y2 - y1)) * (y - y1);
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
89
90
93
94
95
96
97
98
101
102
103
104
105
106
109
110
111
112
113
114
115
116
117
118
119
120
121
125 reserve(closed ? 5 : 4);
126 *
this <<
QPoint(r.x(), r.y())
127 <<
QPoint(r.x() + r.width(), r.y())
128 <<
QPoint(r.x() + r.width(), r.y() + r.height())
129 <<
QPoint(r.x(), r.y() + r.height());
131 *
this <<
QPoint(r.left(), r.top());
135
136
137
138
139
140
144 setPoints(nPoints, points);
148
149
150
151
155 if (dx == 0 && dy == 0)
168
169
170
171
172
173
174
177
178
179
180
181
185 copy.translate(dx, dy);
190
191
192
193
194
195
196
197
200
201
202
203
204
216
217
218
219
220
223
224
225
226
227
230
231
232
233
234
237 (*
this)[index] = QPoint(x, y);
242
243
244
245
246
247
248
249
250
251
258 setPoint(i++, *points, *(points+1));
264
265
266
267
268
269
270
271
272
273
274
275
281 setPoint(0, firstx, firsty);
283 va_start(ap, firsty);
293
294
295
296
297
298
299
300
301
305 if (index + nPoints > size())
306 resize(index + nPoints);
309 setPoint(i++, *points, *(points+1));
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
338 if (index + nPoints > size())
339 resize(index + nPoints);
342 setPoint(index, firstx, firsty);
344 va_start(ap, firsty);
355
356
357
358
359
360
361
362
363
367 if (index + nPoints > size())
368 resize(index + nPoints);
373 setPoint(index + n, from[fromIndex+n]);
380
381
382
383
384
388 const QPoint *pd = constData();
389 const QPoint *pe = pd + size();
391 return QRect(0, 0, 0, 0);
392 int minx, maxx, miny, maxy;
393 minx = maxx = pd->x();
394 miny = maxy = pd->y();
396 for (; pd != pe; ++pd) {
399 else if (pd->x() > maxx)
403 else if (pd->y() > maxy)
406 return QRect(QPoint(minx,miny), QPoint(maxx,maxy));
410
411
412
413
414
415
416
419#ifndef QT_NO_DEBUG_STREAM
422 return QtPrivate::printSequentialContainer(dbg,
"QPolygon", a);
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
461
462
465
466
467
468
469
470
473
474
475
476
479
480
481
482
483
484
485
486
487
493 append(
QPointF(r.x() + r.width(), r.y()));
494 append(
QPointF(r.x() + r.width(), r.y() + r.height()));
495 append(
QPointF(r.x(), r.y() + r.height()));
500
501
502
503
504
505
506
511 for (
int i=0; i<a.size(); ++i)
516
517
518
519
535
536
537
538
539
540
541
544
545
546
547
548
552 copy.translate(offset);
557
558
559
560
561
562
563
564
567
568
569
570
571
572
573
574
577
578
579
580
581
585 const QPointF *pd = constData();
586 const QPointF *pe = pd + size();
588 return QRectF(0, 0, 0, 0);
589 qreal minx, maxx, miny, maxy;
590 minx = maxx = pd->x();
591 miny = maxy = pd->y();
596 else if (pd->x() > maxx)
600 else if (pd->y() > maxy)
604 return QRectF(minx,miny, maxx - minx, maxy - miny);
608
609
610
611
612
618 for (
int i=0; i<size(); ++i)
619 a.append(at(i).toPoint());
624
625
626
627
630
631
632
633
636
637
640 return QVariant::fromValue(*
this);
644
645
646#ifndef QT_NO_DATASTREAM
648
649
650
651
652
653
654
655
656
657QDataStream &operator<<(QDataStream &s,
const QPolygon &a)
659 const QList<QPoint> &v = a;
664
665
666
667
668
669
670
671
672
675 QList<QPoint> &v = a;
681
682
683#ifndef QT_NO_DATASTREAM
685
686
687
688
689
690
691
692
694QDataStream &operator<<(QDataStream &s,
const QPolygonF &a)
696 return s <<
static_cast<
const QList<QPointF> &>(a);
700
701
702
703
704
705
706
707
715#ifndef QT_NO_DEBUG_STREAM
718 return QtPrivate::printSequentialContainer(dbg,
"QPolygonF", a);
724
725
726
727
728
729
730
736 int winding_number = 0;
740 for (
int i = 1; i < size(); ++i) {
742 qt_polygon_isect_line(last_pt, e, pt, &winding_number);
747 if (last_pt != last_start)
748 qt_polygon_isect_line(last_pt, last_start, pt, &winding_number);
750 return (fillRule == Qt::WindingFill
751 ? (winding_number != 0)
752 : ((winding_number % 2) != 0));
756
757
758
759
760
761
767 int winding_number = 0;
770 QPoint last_start = at(0);
771 for (
int i = 1; i < size(); ++i) {
773 qt_polygon_isect_line(last_pt, e, pt, &winding_number);
778 if (last_pt != last_start)
779 qt_polygon_isect_line(last_pt, last_start, pt, &winding_number);
781 return (fillRule == Qt::WindingFill
782 ? (winding_number != 0)
783 : ((winding_number % 2) != 0));
787
788
789
790
791
792
793
794
795
799 QPainterPath subject; subject.addPolygon(*
this);
800 QPainterPath clip; clip.addPolygon(r);
802 return subject.united(clip).toFillPolygon().toPolygon();
806
807
808
809
810
811
812
813
814
818 QPainterPath subject; subject.addPolygon(*
this);
819 QPainterPath clip; clip.addPolygon(r);
821 return subject.intersected(clip).toFillPolygon().toPolygon();
825
826
827
828
829
830
831
832
836 QPainterPath subject; subject.addPolygon(*
this);
837 QPainterPath clip; clip.addPolygon(r);
839 return subject.subtracted(clip).toFillPolygon().toPolygon();
843
844
845
846
847
848
849
850
851
852
856 QPainterPath subject; subject.addPolygon(*
this);
857 QPainterPath clip; clip.addPolygon(p);
859 return subject.intersects(clip);
863
864
865
866
867
868
869
870
871
875 QPainterPath subject; subject.addPolygon(*
this);
876 QPainterPath clip; clip.addPolygon(r);
878 return subject.united(clip).toFillPolygon();
882
883
884
885
886
887
888
889
890
894 QPainterPath subject; subject.addPolygon(*
this);
895 QPainterPath clip; clip.addPolygon(r);
897 return subject.intersected(clip).toFillPolygon();
901
902
903
904
905
906
907
908
912 QPainterPath subject; subject.addPolygon(*
this);
913 QPainterPath clip; clip.addPolygon(r);
914 return subject.subtracted(clip).toFillPolygon();
918
919
920
921
922
923
924
925
926
927
931 QPainterPath subject; subject.addPolygon(*
this);
932 QPainterPath clip; clip.addPolygon(p);
934 return subject.intersects(clip);
938
939
943 return QVariant::fromValue(*
this);
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
The QPolygonF class provides a list of points using floating point precision.
Q_GUI_EXPORT bool intersects(const QPolygonF &r) const
The QPolygon class provides a list of points using integer precision.
Q_GUI_EXPORT bool intersects(const QPolygon &r) const
Q_GUI_EXPORT void putPoints(int index, int nPoints, int firstx, int firsty,...)
Copies nPoints points from the variable argument list into this polygon from the given index.
Q_GUI_EXPORT void translate(int dx, int dy)
Translates all points in the polygon by ({dx}, {dy}).
Q_GUI_EXPORT void putPoints(int index, int nPoints, const QPolygon &from, int fromIndex=0)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Q_GUI_EXPORT void setPoints(int nPoints, int firstx, int firsty,...)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Q_GUI_EXPORT void putPoints(int index, int nPoints, const int *points)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Q_GUI_EXPORT void setPoint(int index, int x, int y)
Sets the point at the given index to the point specified by ({x}, {y}).
Q_GUI_EXPORT void point(int i, int *x, int *y) const
Extracts the coordinates of the point at the given index to {x} and *{y} (if they are valid pointers)...
Q_GUI_EXPORT void setPoints(int nPoints, const int *points)
Resizes the polygon to nPoints and populates it with the given points.
Combined button and popup list for selecting options.
QDataStream & operator>>(QDataStream &s, QPolygon &a)
static QT_BEGIN_NAMESPACE void qt_polygon_isect_line(const QPointF &p1, const QPointF &p2, const QPointF &pos, int *winding)
QDataStream & operator>>(QDataStream &s, QPolygonF &a)
QDebug operator<<(QDebug dbg, const QPolygon &a)
QDebug operator<<(QDebug dbg, const QPolygonF &a)