4#ifndef QPOLYGONCLIPPER_P_H
5#define QPOLYGONCLIPPER_P_H
18#include <QtCore/qrect.h>
19#include <QtGui/private/qdatabuffer_p.h>
25template <
typename InType,
typename OutType,
typename CastType>
class QPolygonClipper
29 buffer1(0), buffer2(0)
56 t.y =
static_cast<CastType
>(
p2.y + (
x1 -
p2.x) * dy);
66 t.y =
static_cast<CastType
>(
p2.y + (
x2 -
p2.x) * dy);
75 t.x =
static_cast<CastType
>(
p2.x + (
y1 -
p2.y) * dx);
85 t.x =
static_cast<CastType
>(
p2.x + (
y2 -
p2.y) * dx);
91 void clipPolygon(
const InType *inPoints,
int inCount, OutType **outPoints,
int *outCount,
92 bool closePolygon =
true)
109 bool doLeft =
false, doRight =
false, doTop =
false, doBottom =
false;
111 for (
int i=0;
i<inCount; ++
i) {
125 if (doLeft && clipped->
size() > 1) {
132 lastPos =
source->size() - 1;
141 const OutType &cpt =
source->at(
i);
142 const OutType &ppt =
source->at(lastPos);
151 }
else if (ppt.x >=
x1) {
158 if (doRight && clipped->
size() > 1) {
165 lastPos =
source->size() - 1;
174 const OutType &cpt =
source->at(
i);
175 const OutType &ppt =
source->at(lastPos);
184 }
else if (ppt.x <=
x2) {
193 if (doTop && clipped->
size() > 1) {
200 lastPos =
source->size() - 1;
209 const OutType &cpt =
source->at(
i);
210 const OutType &ppt =
source->at(lastPos);
219 }
else if (ppt.y >=
y1) {
227 if (doBottom && clipped->
size() > 1) {
234 lastPos =
source->size() - 1;
243 const OutType &cpt =
source->at(
i);
244 const OutType &ppt =
source->at(lastPos);
253 }
else if (ppt.y <=
y2) {
260 if (closePolygon && clipped->
size() > 0) {
262 if (clipped->
at(0).x != clipped->
at(clipped->
size()-1).x ||
263 clipped->
at(0).y != clipped->
at(clipped->
size()-1).y) {
264 OutType ot = clipped->
at(0);
268 *outCount = clipped->
size();
269 *outPoints = clipped->
data();
\inmodule QtCore\reentrant
OutType intersectTop(const OutType &p1, const OutType &p2)
OutType intersectBottom(const OutType &p1, const OutType &p2)
void setBoundingRect(const QRect bounds)
OutType intersectRight(const OutType &p1, const OutType &p2)
OutType intersectLeft(const OutType &p1, const OutType &p2)
void clipPolygon(const InType *inPoints, int inCount, OutType **outPoints, int *outCount, bool closePolygon=true)
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int x() const noexcept
Returns the x-coordinate of the rectangle's left edge.
constexpr int width() const noexcept
Returns the width of the rectangle.
constexpr int y() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Combined button and popup list for selecting options.
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint GLfloat GLfloat GLfloat x1
GLsizei GLsizei GLchar * source
GLfixed GLfixed GLfixed y2