31 if (qFuzzyCompare(y1, y2)) {
35 qreal x_tmp = x2; x2 = x1; x1 = x_tmp;
36 qreal y_tmp = y2; y2 = y1; y1 = y_tmp;
40 if (y >= y1 && y < y2) {
41 qreal x = x1 + ((x2 - x1) / (y2 - y1)) * (y - y1);
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
86
90
91
94
95
96
97
98
99
102
103
104
105
106
107
110
111
112
113
114
115
116
117
118
119
120
121
122
126 reserve(closed ? 5 : 4);
127 *
this <<
QPoint(r.x(), r.y())
128 <<
QPoint(r.x() + r.width(), r.y())
129 <<
QPoint(r.x() + r.width(), r.y() + r.height())
130 <<
QPoint(r.x(), r.y() + r.height());
132 *
this <<
QPoint(r.left(), r.top());
136
137
138
139
140
141
145 setPoints(nPoints, points);
149
150
151
152
156 if (dx == 0 && dy == 0)
169
170
171
172
173
174
175
178
179
180
181
182
186 copy.translate(dx, dy);
191
192
193
194
195
196
197
198
201
202
203
204
205
217
218
219
220
221
224
225
226
227
228
231
232
233
234
235
238 (*
this)[index] = QPoint(x, y);
243
244
245
246
247
248
249
250
251
252
259 setPoint(i++, *points, *(points+1));
265
266
267
268
269
270
271
272
273
274
275
276
282 setPoint(0, firstx, firsty);
284 va_start(ap, firsty);
294
295
296
297
298
299
300
301
302
306 if (index + nPoints > size())
307 resize(index + nPoints);
310 setPoint(i++, *points, *(points+1));
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
339 if (index + nPoints > size())
340 resize(index + nPoints);
343 setPoint(index, firstx, firsty);
345 va_start(ap, firsty);
356
357
358
359
360
361
362
363
364
368 if (index + nPoints > size())
369 resize(index + nPoints);
374 setPoint(index + n, from[fromIndex+n]);
381
382
383
384
385
389 const QPoint *pd = constData();
390 const QPoint *pe = pd + size();
392 return QRect(0, 0, 0, 0);
393 int minx, maxx, miny, maxy;
394 minx = maxx = pd->x();
395 miny = maxy = pd->y();
397 for (; pd != pe; ++pd) {
400 else if (pd->x() > maxx)
404 else if (pd->y() > maxy)
407 return QRect(QPoint(minx,miny), QPoint(maxx,maxy));
411
412
413
414
415
416
417
420#ifndef QT_NO_DEBUG_STREAM
423 return QtPrivate::printSequentialContainer(dbg,
"QPolygon", a);
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
458
462
463
466
467
468
469
470
471
474
475
476
477
480
481
482
483
484
485
486
487
488
494 append(
QPointF(r.x() + r.width(), r.y()));
495 append(
QPointF(r.x() + r.width(), r.y() + r.height()));
496 append(
QPointF(r.x(), r.y() + r.height()));
501
502
503
504
505
506
507
512 for (
int i=0; i<a.size(); ++i)
517
518
519
520
536
537
538
539
540
541
542
545
546
547
548
549
553 copy.translate(offset);
558
559
560
561
562
563
564
565
568
569
570
571
572
573
574
575
578
579
580
581
582
586 const QPointF *pd = constData();
587 const QPointF *pe = pd + size();
589 return QRectF(0, 0, 0, 0);
590 qreal minx, maxx, miny, maxy;
591 minx = maxx = pd->x();
592 miny = maxy = pd->y();
597 else if (pd->x() > maxx)
601 else if (pd->y() > maxy)
605 return QRectF(minx,miny, maxx - minx, maxy - miny);
609
610
611
612
613
619 for (
int i=0; i<size(); ++i)
620 a.append(at(i).toPoint());
625
626
627
628
631
632
633
634
637
638
641 return QVariant::fromValue(*
this);
645
646
647#ifndef QT_NO_DATASTREAM
649
650
651
652
653
654
655
656
657
658QDataStream &operator<<(QDataStream &s,
const QPolygon &a)
660 const QList<QPoint> &v = a;
665
666
667
668
669
670
671
672
673
676 QList<QPoint> &v = a;
682
683
684#ifndef QT_NO_DATASTREAM
686
687
688
689
690
691
692
693
695QDataStream &operator<<(QDataStream &s,
const QPolygonF &a)
697 return s <<
static_cast<
const QList<QPointF> &>(a);
701
702
703
704
705
706
707
708
716#ifndef QT_NO_DEBUG_STREAM
719 return QtPrivate::printSequentialContainer(dbg,
"QPolygonF", a);
725
726
727
728
729
730
731
737 int winding_number = 0;
741 for (
int i = 1; i < size(); ++i) {
743 qt_polygon_isect_line(last_pt, e, pt, &winding_number);
748 if (last_pt != last_start)
749 qt_polygon_isect_line(last_pt, last_start, pt, &winding_number);
751 return (fillRule == Qt::WindingFill
752 ? (winding_number != 0)
753 : ((winding_number % 2) != 0));
757
758
759
760
761
762
768 int winding_number = 0;
771 QPoint last_start = at(0);
772 for (
int i = 1; i < size(); ++i) {
774 qt_polygon_isect_line(last_pt, e, pt, &winding_number);
779 if (last_pt != last_start)
780 qt_polygon_isect_line(last_pt, last_start, pt, &winding_number);
782 return (fillRule == Qt::WindingFill
783 ? (winding_number != 0)
784 : ((winding_number % 2) != 0));
788
789
790
791
792
793
794
795
796
800 QPainterPath subject; subject.addPolygon(*
this);
801 QPainterPath clip; clip.addPolygon(r);
803 return subject.united(clip).toFillPolygon().toPolygon();
807
808
809
810
811
812
813
814
815
819 QPainterPath subject; subject.addPolygon(*
this);
820 QPainterPath clip; clip.addPolygon(r);
822 return subject.intersected(clip).toFillPolygon().toPolygon();
826
827
828
829
830
831
832
833
837 QPainterPath subject; subject.addPolygon(*
this);
838 QPainterPath clip; clip.addPolygon(r);
840 return subject.subtracted(clip).toFillPolygon().toPolygon();
844
845
846
847
848
849
850
851
852
853
857 QPainterPath subject; subject.addPolygon(*
this);
858 QPainterPath clip; clip.addPolygon(p);
860 return subject.intersects(clip);
864
865
866
867
868
869
870
871
872
876 QPainterPath subject; subject.addPolygon(*
this);
877 QPainterPath clip; clip.addPolygon(r);
879 return subject.united(clip).toFillPolygon();
883
884
885
886
887
888
889
890
891
895 QPainterPath subject; subject.addPolygon(*
this);
896 QPainterPath clip; clip.addPolygon(r);
898 return subject.intersected(clip).toFillPolygon();
902
903
904
905
906
907
908
909
913 QPainterPath subject; subject.addPolygon(*
this);
914 QPainterPath clip; clip.addPolygon(r);
915 return subject.subtracted(clip).toFillPolygon();
919
920
921
922
923
924
925
926
927
928
932 QPainterPath subject; subject.addPolygon(*
this);
933 QPainterPath clip; clip.addPolygon(p);
935 return subject.intersects(clip);
939
940
944 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)