当前位置: 首页>>代码示例>>C++>>正文


C++ QTransform::type方法代码示例

本文整理汇总了C++中QTransform::type方法的典型用法代码示例。如果您正苦于以下问题:C++ QTransform::type方法的具体用法?C++ QTransform::type怎么用?C++ QTransform::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QTransform的用法示例。


在下文中一共展示了QTransform::type方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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()));
}
开发者ID:sikmir,项目名称:mapper,代码行数:52,代码来源:transform_t.cpp

示例2: 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)));
}
开发者ID:sikmir,项目名称:mapper,代码行数:28,代码来源:transform_t.cpp

示例3:

QT_BEGIN_NAMESPACE

static inline bool qtransform_equals_no_translate(const QTransform &a, const QTransform &b)
{
    if (a.type() <= QTransform::TxTranslate && b.type() <= QTransform::TxTranslate) {
        return true;
    } else {
        // We always use paths for perspective text anyway, so no
        // point in checking the full matrix...
        Q_ASSERT(a.type() < QTransform::TxProject);
        Q_ASSERT(b.type() < QTransform::TxProject);

        return a.m11() == b.m11()
            && a.m12() == b.m12()
            && a.m21() == b.m21()
            && a.m22() == b.m22();
    }
}
开发者ID:venkatarajasekhar,项目名称:ECE497,代码行数:18,代码来源:qfontengine.cpp

示例4: transformed

QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
                                         Qt::TransformationMode mode) const
{
    QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
#ifdef QT_NO_DIRECTFB_SUBSURFACE
    if (lockFlags())
        that->unlockSurface();
#endif

    if (!dfbSurface || transform.type() != QTransform::TxScale
        || mode != Qt::FastTransformation)
    {
        const QImage *image = that->buffer();
        Q_ASSERT(image);
        const QImage transformed = image->transformed(transform, mode);
        QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType);
        data->fromImage(transformed, Qt::AutoColor);
        return QPixmap(data);
    }

    const QSize size = transform.mapRect(QRect(0, 0, w, h)).size();
    if (size.isEmpty())
        return QPixmap();

    QDirectFBPixmapData *data = new QDirectFBPixmapData(screen, QPixmapData::PixmapType);
    data->setSerialNumber(++global_ser_no);
    DFBSurfaceBlittingFlags flags = DSBLIT_NOFX;
    data->alpha = alpha;
    if (alpha) {
        flags = DSBLIT_BLEND_ALPHACHANNEL;
    }
    data->dfbSurface = screen->createDFBSurface(size,
                                                imageFormat,
                                                QDirectFBScreen::TrackSurface);
    if (flags & DSBLIT_BLEND_ALPHACHANNEL) {
        data->dfbSurface->Clear(data->dfbSurface, 0, 0, 0, 0);
    }
    data->dfbSurface->SetBlittingFlags(data->dfbSurface, flags);

    const DFBRectangle destRect = { 0, 0, size.width(), size.height() };
    data->dfbSurface->StretchBlit(data->dfbSurface, dfbSurface, 0, &destRect);
    data->w = size.width();
    data->h = size.height();
    data->is_null = (data->w <= 0 || data->h <= 0);

#if (Q_DIRECTFB_VERSION >= 0x010000)
    data->dfbSurface->ReleaseSource(data->dfbSurface);
#endif
    return QPixmap(data);
}
开发者ID:stephaneAG,项目名称:PengPod700,代码行数:50,代码来源:qdirectfbpixmap.cpp

示例5: testTransformTranslate

void TransformTest::testTransformTranslate()
{
	MapCoord offset { 100.0, 100.0 };
	QTransform qt;
	qt.translate(offset.x(), offset.y());
	QVERIFY(qt.isTranslating());
	QCOMPARE(int(qt.type()), int(QTransform::TxTranslate));
	
	auto t = TemplateTransform::fromQTransform(qt);
	QCOMPARE(t.template_x, offset.nativeX());
	QCOMPARE(t.template_y, offset.nativeY());
	QCOMPARE(t.template_scale_x, 1.0);
	QCOMPARE(t.template_scale_y, 1.0);
	QCOMPARE(t.template_rotation, 0.0);
}
开发者ID:sikmir,项目名称:mapper,代码行数:15,代码来源:transform_t.cpp

示例6: 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);
}
开发者ID:sikmir,项目名称:mapper,代码行数:17,代码来源:transform_t.cpp

示例7: testTransformRotate

void TransformTest::testTransformRotate()
{
	QFETCH(int, type);
	QFETCH(double, rotation);
	
	QTransform qt;
	qt.rotate(qreal(rotation), Qt::ZAxis);
	QCOMPARE(int(qt.type()), type);
	
	auto 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);
	if (rotation <= 180.0)
		QCOMPARE(t.template_rotation, -qDegreesToRadians(qreal(rotation)));
	else
		QCOMPARE(t.template_rotation, -qDegreesToRadians(qreal(rotation - 360.0)));
}
开发者ID:sikmir,项目名称:mapper,代码行数:19,代码来源:transform_t.cpp

示例8: preciselyInverted

static QTransform preciselyInverted( const QTransform& transform )
{
    QTransform inverted;

    switch ( transform.type() ) {
        case QTransform::TxNone:
            break;

        case QTransform::TxTranslate:
            inverted.translate( -transform.dx(), -transform.dy() );
            break;

        case QTransform::TxScale:
            inverted.scale( 1.0 / transform.m11(), 1.0 / transform.m22() );
            inverted.translate( -transform.dx(), -transform.dy() );
            break;

        default:
            inverted = transform.inverted();
    }

    return inverted;
}
开发者ID:WhiteSymmetry,项目名称:fraqtive,代码行数:23,代码来源:fractalpresenter.cpp

示例9: transformed

QPixmap QDirectFBPixmapData::transformed(const QTransform &transform,
                                         Qt::TransformationMode mode) const
{
    if (!surface || transform.type() != QTransform::TxScale
        || mode != Qt::FastTransformation)
    {
        QDirectFBPixmapData *that = const_cast<QDirectFBPixmapData*>(this);
        const QImage *image = that->buffer();
        if (image) { // avoid deep copy
            const QImage transformed = image->transformed(transform, mode);
            that->unlockDirectFB();
            QDirectFBPixmapData *data = new QDirectFBPixmapData(pixelType());
            data->fromImage(transformed, Qt::AutoColor);
            return QPixmap(data);
        }
        return QPixmapData::transformed(transform, mode);
    }

    int w, h;
    surface->GetSize(surface, &w, &h);

    const QSize size = transform.mapRect(QRect(0, 0, w, h)).size();
    if (size.isEmpty())
        return QPixmap();

    QDirectFBPixmapData *data = new QDirectFBPixmapData(pixelType());
    data->resize(size.width(), size.height());

    IDirectFBSurface *dest = data->surface;
    dest->SetBlittingFlags(dest, DSBLIT_NOFX);

    const DFBRectangle srcRect = { 0, 0, w, h };
    const DFBRectangle destRect = { 0, 0, size.width(), size.height() };
    dest->StretchBlit(dest, surface, &srcRect, &destRect);

    return QPixmap(data);
}
开发者ID:FilipBE,项目名称:qtextended,代码行数:37,代码来源:qdirectfbpixmap.cpp

示例10: 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());
}
开发者ID:sikmir,项目名称:mapper,代码行数:36,代码来源:transform_t.cpp


注:本文中的QTransform::type方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。