本文整理汇总了C++中QTransform::isRotating方法的典型用法代码示例。如果您正苦于以下问题:C++ QTransform::isRotating方法的具体用法?C++ QTransform::isRotating怎么用?C++ QTransform::isRotating使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTransform
的用法示例。
在下文中一共展示了QTransform::isRotating方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transform
void Selection::transform(QTransform transform, int pageNum)
{
m_selectionPolygon = transform.map(m_selectionPolygon);
qreal sx = transform.m11();
qreal sy = transform.m22();
qreal s = (sx + sy) / 2.0;
for (int i = 0; i < m_strokes.size(); ++i)
{
m_strokes[i].points = transform.map(m_strokes[i].points);
/*
'if (!transform.isRotating())' doesn't work, since rotation of 180 and 360 degrees is treated as a scaling transformation. Same goes for
'if (transform.isScaling())'
*/
if (transform.determinant() != 1)
{
m_strokes[i].penWidth = m_strokes[i].penWidth * s;
}
}
if (transform.determinant() != 1)
{
m_x_padding *= sx;
m_y_padding *= sy;
}
if (transform.isRotating())
{
m_x_padding = m_padding;
m_y_padding = m_padding;
}
m_angle = 0.0;
setPageNum(pageNum);
}
示例2: testEstimateNonIsometric
void TransformTest::testEstimateNonIsometric()
{
// Scaling and translation
PassPointList passpoints;
passpoints.resize(3);
passpoints[0].src_coords = MapCoordF { 128.0, 0.0 };
passpoints[0].dest_coords = MapCoordF { 64.0, 64.0 };
passpoints[1].src_coords = MapCoordF { 256.0, 0.0 };
passpoints[1].dest_coords = MapCoordF { 96.0, 64.0 };
passpoints[2].src_coords = MapCoordF { 128.0, 128.0 };
passpoints[2].dest_coords = MapCoordF { 64.0, 96.0 };
QTransform qt;
QVERIFY(passpoints.estimateNonIsometricSimilarityTransform(&qt));
QVERIFY(qt.isTranslating());
QVERIFY(qt.isScaling());
QCOMPARE(int(qt.type()), int(QTransform::TxScale));
QCOMPARE(qt.map(passpoints[0].src_coords), QPointF{passpoints[0].dest_coords});
QCOMPARE(qt.map(passpoints[1].src_coords), QPointF{passpoints[1].dest_coords});
QCOMPARE(qt.map(passpoints[2].src_coords), QPointF{passpoints[2].dest_coords});
auto t = TemplateTransform::fromQTransform(qt);
QCOMPARE(t.template_x, MapCoord(32,64).nativeX());
QCOMPARE(t.template_y, MapCoord(32,64).nativeY());
QCOMPARE(t.template_scale_x, 0.25);
QCOMPARE(t.template_scale_y, 0.25);
QVERIFY(qAbs(t.template_rotation) < 0.000001);
// Rotation
passpoints[0].src_coords = MapCoordF { 0.0, 0.0 };
passpoints[0].dest_coords = MapCoordF { 0.0, 0.0 };
passpoints[1].src_coords = MapCoordF { 5.0, 0.0 };
passpoints[1].dest_coords = MapCoordF { 4.0, -3.0 };
passpoints[2].src_coords = MapCoordF { 0.0, 5.0 };
passpoints[2].dest_coords = MapCoordF { 3.0, 4.0 };
QVERIFY(passpoints.estimateNonIsometricSimilarityTransform(&qt));
QVERIFY(qt.isRotating());
QCOMPARE(int(qt.type()), int(QTransform::TxRotate));
QCOMPARE(qt.map(passpoints[0].src_coords), QPointF{passpoints[0].dest_coords});
QCOMPARE(qt.map(passpoints[1].src_coords), QPointF{passpoints[1].dest_coords});
QCOMPARE(qt.map(passpoints[2].src_coords), QPointF{passpoints[2].dest_coords});
t = TemplateTransform::fromQTransform(qt);
QCOMPARE(t.template_x, 0);
QCOMPARE(t.template_y, 0);
QCOMPARE(t.template_scale_x, 1.0);
QCOMPARE(t.template_scale_y, 1.0);
QCOMPARE(t.template_rotation, qAcos(passpoints[1].dest_coords.x() / passpoints[1].src_coords.x()));
}
示例3: drawRectangles
// draw shapes
// NOTE: if drawing many shapes of same size, use drawGlyphs
void ScenePainter::drawRectangles(double *x, double *y, double *w, double *h,
int n)
{
QTransform tform = transform();
QPen pen = this->pen();
for (int i = 0; i < n; i++) {
QPointF point = QPointF(x[i], y[i]);
QRectF rect = tform.mapRect(QRectF(point, QSizeF(w[i], h[i])));
if (!tform.isRotating()) {
STORE_INDEX(_scene->addRect(tform.mapRect(rect), pen));
}
else STORE_INDEX(_scene->addPolygon(tform.map(QPolygonF(rect))));
}
}
示例4: testTransformIdentity
void TransformTest::testTransformIdentity()
{
// Default QTransform: identity
QTransform qt;
QVERIFY(qt.isIdentity());
QCOMPARE(int(qt.type()), int(QTransform::TxNone));
// Default TemplateTransform: identity
TemplateTransform t;
// TemplateTransform list initialization, and assignment
t = { 12, -3, 0.1, 2.0, 3.0 };
QCOMPARE(t.template_x, 12);
QCOMPARE(t.template_y, -3);
QCOMPARE(t.template_scale_x, 2.0);
QCOMPARE(t.template_scale_y, 3.0);
QCOMPARE(t.template_rotation, 0.1);
// Now transfer the identity QTransform to the TemplateTransform
t = TemplateTransform::fromQTransform(qt);
QCOMPARE(t.template_x, 0);
QCOMPARE(t.template_y, 0);
QCOMPARE(t.template_scale_x, 1.0);
QCOMPARE(t.template_scale_y, 1.0);
QCOMPARE(t.template_rotation, 0.0);
// Put something different in the QTransform
qt.translate(4, 8);
qt.rotate(1);
qt.scale(2.0, 1.5);
QVERIFY(qt.isAffine());
QVERIFY(!qt.isIdentity());
QVERIFY(qt.isTranslating());
QVERIFY(qt.isRotating());
QVERIFY(qt.isScaling());
}