本文整理汇总了C++中QPolygonF::toPolygon方法的典型用法代码示例。如果您正苦于以下问题:C++ QPolygonF::toPolygon方法的具体用法?C++ QPolygonF::toPolygon怎么用?C++ QPolygonF::toPolygon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QPolygonF
的用法示例。
在下文中一共展示了QPolygonF::toPolygon方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testSafeTransformSingleVanishingPoint
void KisTransformMaskTest::testSafeTransformSingleVanishingPoint()
{
// rotation around 0X has a single vanishing point for 0Y axis
QTransform transform(1, 0, 0,
-0.870208, -0.414416, -0.000955222,
132.386, 1082.91, 1.99439);
QTransform R; R.rotateRadians(M_PI / 4.0);
//transform *= R;
QRectF testRect(1536, 1024, 512, 512);
KisSafeTransform t2(transform, QRect(0, 0, 2048, 2048), testRect.toRect());
QPolygonF fwdPoly = t2.mapForward(testRect);
QRectF fwdRect = t2.mapRectForward(testRect);
QPolygonF bwdPoly = t2.mapBackward(fwdPoly);
QRectF bwdRect = t2.mapRectBackward(fwdRect);
/**
* A special weird rect that crosses the vanishing point,
* which is (911.001, 433.84) in this case
*/
QRectF fwdNastyRect(800, 100, 400, 600);
//QRectF fwdNastyRect(100, 400, 1000, 800);
QRectF bwdNastyRect = t2.mapRectBackward(fwdNastyRect);
/*
dbgKrita << ppVar(testRect);
dbgKrita << ppVar(fwdPoly);
dbgKrita << ppVar(fwdRect);
dbgKrita << ppVar(bwdPoly);
dbgKrita << ppVar(bwdRect);
dbgKrita << ppVar(bwdNastyRect);
*/
QPolygon ref;
ref.clear();
ref << QPoint(765,648);
ref << QPoint(1269, 648);
ref << QPoint(1601, 847);
ref << QPoint(629, 847);
ref << QPoint(765, 648);
QCOMPARE(fwdPoly.toPolygon(), ref);
QCOMPARE(fwdRect.toRect(), QRect(629,648,971,199));
ref.clear();
ref << QPoint(1536,1024);
ref << QPoint(2048,1024);
ref << QPoint(2048,1536);
ref << QPoint(1536,1536);
ref << QPoint(1536,1024);
QCOMPARE(bwdPoly.toPolygon(), ref);
QCOMPARE(bwdRect.toRect(), QRect(1398,1024,650,512));
QCOMPARE(bwdNastyRect.toRect(), QRect(1463,0,585,1232));
}
示例2: QPolygon
/*!
Returns the Bezier points for the four control points in this
array.
*/
Q3PointArray Q3PointArray::cubicBezier() const
{
if (size() != 4) {
qWarning( "Q3PointArray::bezier: The array must have 4 control points" );
return QPolygon();
}
QPolygonF polygon = QBezier::fromPoints(at(0), at(1), at(2), at(3)).toPolygon();
return polygon.toPolygon();
}
示例3: resizeEvent
void AMExtendedControlEditorStyledInputDialog::resizeEvent(QResizeEvent * event )
{
QDialog::resizeEvent(event);
// Create a rounded-rectangle mask to shape this window:
QPainterPath path;
path.addRoundedRect(0, 0, width(), height(), 14, 14);
QPolygonF polygonf = path.toFillPolygon(QTransform());
QRegion maskedRegion( polygonf.toPolygon() );
setMask(maskedRegion);
}
示例4: toRect
QRect toRect(QPolygonF polygon)
{
return toRect(polygon.toPolygon());
}
示例5: testSafeTransform
void KisTransformMaskTest::testSafeTransform()
{
QTransform transform(-0.177454, -0.805953, -0.00213713,
-1.9295, -0.371835, -0.00290463,
3075.05, 2252.32, 7.62371);
QRectF testRect(0, 1024, 512, 512);
KisSafeTransform t2(transform, QRect(0, 0, 2048, 2048), testRect.toRect());
QPolygonF fwdPoly = t2.mapForward(testRect);
QRectF fwdRect = t2.mapRectForward(testRect);
QPolygonF bwdPoly = t2.mapBackward(fwdPoly);
QRectF bwdRect = t2.mapRectBackward(fwdRect);
QPolygon ref;
ref.clear();
ref << QPoint(284, 410);
ref << QPoint(10, 613);
ref << QPoint(35, 532);
ref << QPoint(236, 403);
ref << QPoint(284, 410);
QCOMPARE(fwdPoly.toPolygon(), ref);
QCOMPARE(fwdRect.toRect(), QRect(10,403,274,211));
ref.clear();
ref << QPoint(512, 1024);
ref << QPoint(512, 1536);
ref << QPoint(0, 1536);
ref << QPoint(0, 1024);
ref << QPoint(512, 1024);
QCOMPARE(bwdPoly.toPolygon(), ref);
QCOMPARE(bwdRect.toRect(), QRect(0, 994, 1198, 584));
/*
QImage image(2500, 2500, QImage::Format_ARGB32);
QPainter gc(&image);
gc.setPen(Qt::cyan);
gc.setOpacity(0.7);
gc.setBrush(Qt::red);
gc.drawPolygon(t2.srcClipPolygon());
gc.setBrush(Qt::green);
gc.drawPolygon(t2.dstClipPolygon());
dbgKrita << ppVar(testRect);
dbgKrita << ppVar(fwdPoly);
dbgKrita << ppVar(fwdRect);
dbgKrita << ppVar(bwdPoly);
dbgKrita << ppVar(bwdRect);
gc.setBrush(Qt::yellow);
gc.drawPolygon(testRect);
gc.setBrush(Qt::red);
gc.drawPolygon(fwdRect);
gc.setBrush(Qt::blue);
gc.drawPolygon(fwdPoly);
gc.setBrush(Qt::magenta);
gc.drawPolygon(bwdRect);
gc.setBrush(Qt::cyan);
gc.drawPolygon(bwdPoly);
gc.end();
image.save("polygons_safety.png");
*/
}