本文整理汇总了C++中QTransform::isScaling方法的典型用法代码示例。如果您正苦于以下问题:C++ QTransform::isScaling方法的具体用法?C++ QTransform::isScaling怎么用?C++ QTransform::isScaling使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTransform
的用法示例。
在下文中一共展示了QTransform::isScaling方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testTransformCombined
void TransformTest::testTransformCombined()
{
QFETCH(int, type);
QFETCH(double, rotation);
qint32 dx = -3000;
qint32 dy = 16000;
qreal scale_x = 4.5;
qreal scale_y = 2.5;
QTransform qt;
// Template::applyTemplateTransform order: translate, rotate, scale
qt.translate(dx / 1000.0, dy / 1000.0);
qt.rotate(qreal(rotation));
qt.scale(scale_x, scale_y);
QVERIFY(qt.isScaling());
QCOMPARE(int(qt.type()), type);
auto t = TemplateTransform::fromQTransform(qt);
QCOMPARE(t.template_x, dx);
QCOMPARE(t.template_y, dy);
QCOMPARE(t.template_scale_x, scale_x);
QCOMPARE(t.template_scale_y, scale_y);
if (rotation <= 180.0)
QCOMPARE(t.template_rotation, -qDegreesToRadians(qreal(rotation)));
else
QCOMPARE(t.template_rotation, -qDegreesToRadians(qreal(rotation - 360.0)));
}
示例2: r
static inline void qwtDrawPixmapSymbols( QPainter *painter,
const QPointF *points, int numPoints, const QwtSymbol &symbol )
{
QSize size = symbol.size();
if ( size.isEmpty() )
size = symbol.pixmap().size();
const QTransform transform = painter->transform();
if ( transform.isScaling() )
{
const QRect r( 0, 0, size.width(), size.height() );
size = transform.mapRect( r ).size();
}
QPixmap pm = symbol.pixmap();
if ( pm.size() != size )
pm = pm.scaled( size );
QPointF pinPoint( 0.5 * size.width(), 0.5 * size.height() );
if ( symbol.isPinPointEnabled() )
pinPoint = symbol.pinPoint();
painter->resetTransform();
for ( int i = 0; i < numPoints; i++ )
{
const QPointF pos = transform.map( points[i] ) - pinPoint;
QwtPainter::drawPixmap( painter,
QRect( pos.toPoint(), pm.size() ), pm );
}
}
示例3: 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()));
}
示例4: testTransformProject
void TransformTest::testTransformProject()
{
qreal scale_x = 4.5;
qreal scale_y = 2.5;
QTransform qt;
qt.scale(scale_x, scale_y);
QVERIFY(qt.isScaling());
QCOMPARE(int(qt.type()), int(QTransform::TxScale));
auto t = TemplateTransform::fromQTransform(qt);
QCOMPARE(t.template_x, 0);
QCOMPARE(t.template_y, 0);
QCOMPARE(t.template_scale_x, scale_x);
QCOMPARE(t.template_scale_y, scale_y);
QCOMPARE(t.template_rotation, 0.0);
}
示例5: paint
void KPrShapeManagerAnimationStrategy::paint( KoShape * shape, QPainter &painter, const KoViewConverter &converter, bool forPrint )
{
if ( ! dynamic_cast<KPrPlaceholderShape *>( shape ) && m_strategy->page()->displayShape( shape ) ) {
if ( m_animationCache->value(shape, "visibility", true).toBool() ) {
painter.save();
QTransform animationTransform = m_animationCache->value(shape, "transform", QTransform()).value<QTransform>();;
QTransform transform(painter.transform() * shape->absoluteTransformation(&converter));
if (animationTransform.isScaling()) {
transform = animationTransform * transform;
} else {
transform = transform * animationTransform;
}
painter.setTransform(transform);
// paint shape
shapeManager()->paintShape( shape, painter, converter, forPrint );
painter.restore(); // for the transform
}
}
}
示例6: 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());
}