本文整理汇总了C++中QTransform::isIdentity方法的典型用法代码示例。如果您正苦于以下问题:C++ QTransform::isIdentity方法的具体用法?C++ QTransform::isIdentity怎么用?C++ QTransform::isIdentity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTransform
的用法示例。
在下文中一共展示了QTransform::isIdentity方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: svgGenerator
QImage minigis::svgGenerator(QSvgRenderer &render, const QString &cls, const QRectF &rgn, const QTransform &tr, const QTransform &invertedTr, QPointF *start)
{
if (tr.isIdentity()) {
if (start)
*start = rgn.topLeft();
return genSvg(render, cls, rgn.size());
}
return genSvgTransform(render, cls, rgn.size(), rgn.topLeft(), tr, invertedTr, start);
// return generateTransformImage(genSvg(render, cls, rgn.size()), rgn.topLeft(), tr, invertedTr, start);
}
示例2: saveTransform
void GraphicsUtils::saveTransform(QXmlStreamWriter & streamWriter, const QTransform & transform) {
if (transform.isIdentity()) return;
streamWriter.writeStartElement("transform");
streamWriter.writeAttribute("m11", QString::number(transform.m11()));
streamWriter.writeAttribute("m12", QString::number(transform.m12()));
streamWriter.writeAttribute("m13", QString::number(transform.m13()));
streamWriter.writeAttribute("m21", QString::number(transform.m21()));
streamWriter.writeAttribute("m22", QString::number(transform.m22()));
streamWriter.writeAttribute("m23", QString::number(transform.m23()));
streamWriter.writeAttribute("m31", QString::number(transform.m31()));
streamWriter.writeAttribute("m32", QString::number(transform.m32()));
streamWriter.writeAttribute("m33", QString::number(transform.m33()));
streamWriter.writeEndElement();
}
示例3: 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());
}
示例4: init
void KisPerspectiveTransformWorker::init(const QTransform &transform)
{
m_isIdentity = transform.isIdentity();
m_forwardTransform = transform;
m_backwardTransform = transform.inverted();
if (m_dev) {
m_srcRect = m_dev->exactBounds();
QPolygonF dstClipPolygonUnused;
fillParams(m_srcRect,
m_dev->defaultBounds()->bounds(),
&m_dstRegion,
&dstClipPolygonUnused);
}
}
示例5: serialize
bool QGIPiece::serialize( S11nNode & dest ) const
{
if( ! this->Serializable::serialize( dest ) ) return false;
//S11nNodeTraits::set( dest, "QGIFlags", int(this->flags()) );
QList<QGraphicsItem *> chgi( qboard::childItems(this) );
if( ! chgi.isEmpty() )
{
if( -1 == s11n::qt::serializeQGIList<Serializable>( s11n::create_child(dest,"children"),
chgi, false ) )
{
return false;
}
}
const QTransform tra( this->transform() );
if( ! tra.isIdentity() )
{
s11n::serialize_subnode( dest, "transform", tra );
}
// EVIL KLUDGE: we must ensure that our 'pos' property is set
// properly. We must violate constness to do so or use a proxy
// object :/
PropObj props;
#if 0
qboard::copyProperties( this, &props );
#if 1
QStringList no;
no << "alpha"
<< "angle"
<< "color"
<< "borderColor"
<< "borderSize"
<< "borderStyle"
<< "borderAlpha"
<< "scale"
;
foreach( QString k, no )
{
props.setProperty(k.toAscii().constData(), QVariant());
}
示例6: diffxyz
QVector3D Conversions::enu2xyz(const QVector3D & enu, qreal reflat, qreal reflon, qreal refalt)
{
const QTransform R1 = Conversions::rot(90.0 + reflon,3);
const QTransform R2 = Conversions::rot(90.0 - reflat,1);
const QTransform R = R2*R1;
const QTransform invR = R.inverted();
if (invR.isIdentity())
{
qDebug() << "Failed to invert rotation matrix --- did you enter a bad lat,lon,or alt?";
return enu;
}
qreal x = invR.m11()*enu.x() + invR.m12()*enu.y() + invR.m13()*enu.z();
qreal y = invR.m21()*enu.x() + invR.m22()*enu.y() + invR.m23()*enu.z();
qreal z = invR.m31()*enu.x() + invR.m32()*enu.y() + invR.m33()*enu.z();
QVector3D diffxyz(x,y,z);
QVector3D refxyz = Conversions::lla2xyz(reflat,reflon,refalt);
return (diffxyz + refxyz);
}
示例7: paint
void QDeclarativeImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *)
{
Q_D(QDeclarativeImage);
if (d->pix.pixmap().isNull() )
return;
int drawWidth = width();
int drawHeight = height();
bool doClip = false;
QTransform transform;
qreal widthScale = width() / qreal(d->pix.width());
qreal heightScale = height() / qreal(d->pix.height());
if (width() != d->pix.width() || height() != d->pix.height()) {
if (d->fillMode >= Tile) {
if (d->fillMode == TileVertically) {
transform.scale(widthScale, 1.0);
drawWidth = d->pix.width();
} else if (d->fillMode == TileHorizontally) {
transform.scale(1.0, heightScale);
drawHeight = d->pix.height();
}
} else {
if (d->fillMode == PreserveAspectFit) {
if (widthScale <= heightScale) {
heightScale = widthScale;
transform.translate(0, (height() - heightScale * d->pix.height()) / 2);
} else if(heightScale < widthScale) {
widthScale = heightScale;
transform.translate((width() - widthScale * d->pix.width()) / 2, 0);
}
} else if (d->fillMode == PreserveAspectCrop) {
if (widthScale < heightScale) {
widthScale = heightScale;
transform.translate((width() - widthScale * d->pix.width()) / 2, 0);
} else if(heightScale < widthScale) {
heightScale = widthScale;
transform.translate(0, (height() - heightScale * d->pix.height()) / 2);
}
}
transform.scale(widthScale, heightScale);
drawWidth = d->pix.width();
drawHeight = d->pix.height();
doClip = clip();
}
}
QTransform oldTransform;
bool oldAA = p->testRenderHint(QPainter::Antialiasing);
bool oldSmooth = p->testRenderHint(QPainter::SmoothPixmapTransform);
if (d->smooth)
p->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, d->smooth);
if (doClip) {
p->save();
p->setClipRect(QRectF(0, 0, d->mWidth, d->mHeight), Qt::IntersectClip);
}
if (d->mirror)
transform.translate(drawWidth, 0).scale(-1.0, 1.0);
if (!transform.isIdentity()) {
oldTransform = p->transform();
p->setWorldTransform(transform * oldTransform);
}
if (d->fillMode >= Tile)
p->drawTiledPixmap(QRectF(0, 0, drawWidth, drawHeight), d->pix);
else
p->drawPixmap(QRectF(0, 0, drawWidth, drawHeight), d->pix, QRectF(0, 0, drawWidth, drawHeight));
if (d->smooth) {
p->setRenderHint(QPainter::Antialiasing, oldAA);
p->setRenderHint(QPainter::SmoothPixmapTransform, oldSmooth);
}
if (doClip)
p->restore();
if (!transform.isIdentity())
p->setWorldTransform(oldTransform);
}
示例8: toXml
void AbstractContent::toXml(QDomElement & contentElement, const QDir & /*baseDir*/) const
{
// Save general item properties
contentElement.setTagName("abstract");
QDomDocument doc = contentElement.ownerDocument();
QDomElement domElement;
QDomText text;
QString valueStr;
// Save item position and size
QDomElement rectParent = doc.createElement("rect");
QDomElement xElement = doc.createElement("x");
rectParent.appendChild(xElement);
QDomElement yElement = doc.createElement("y");
rectParent.appendChild(yElement);
QDomElement wElement = doc.createElement("w");
rectParent.appendChild(wElement);
QDomElement hElement = doc.createElement("h");
rectParent.appendChild(hElement);
QRectF rect = m_contentRect;
xElement.appendChild(doc.createTextNode(QString::number(rect.left())));
yElement.appendChild(doc.createTextNode(QString::number(rect.top())));
wElement.appendChild(doc.createTextNode(QString::number(rect.width())));
hElement.appendChild(doc.createTextNode(QString::number(rect.height())));
contentElement.appendChild(rectParent);
// Save the position
domElement = doc.createElement("pos");
xElement = doc.createElement("x");
yElement = doc.createElement("y");
valueStr.setNum(pos().x());
xElement.appendChild(doc.createTextNode(valueStr));
valueStr.setNum(pos().y());
yElement.appendChild(doc.createTextNode(valueStr));
domElement.appendChild(xElement);
domElement.appendChild(yElement);
contentElement.appendChild(domElement);
// Save the stacking position
domElement= doc.createElement("zvalue");
contentElement.appendChild(domElement);
valueStr.setNum(zValue());
text = doc.createTextNode(valueStr);
domElement.appendChild(text);
// Save the visible state
domElement= doc.createElement("visible");
contentElement.appendChild(domElement);
valueStr.setNum(isVisible());
text = doc.createTextNode(valueStr);
domElement.appendChild(text);
// Save the opacity
if (contentOpacity() < 1.0) {
domElement= doc.createElement("opacity");
contentElement.appendChild(domElement);
domElement.appendChild(doc.createTextNode(QString::number(contentOpacity())));
}
// Save the Fx Index
if (fxIndex() > 0) {
domElement = doc.createElement("fxindex");
contentElement.appendChild(domElement);
domElement.appendChild(doc.createTextNode(QString::number(fxIndex())));
}
// Save the frame class
valueStr.setNum(frameClass());
domElement= doc.createElement("frame-class");
contentElement.appendChild(domElement);
text = doc.createTextNode(valueStr);
domElement.appendChild(text);
domElement= doc.createElement("frame-text-enabled");
contentElement.appendChild(domElement);
valueStr.setNum(frameTextEnabled());
text = doc.createTextNode(valueStr);
domElement.appendChild(text);
if(frameTextEnabled()) {
domElement= doc.createElement("frame-text");
contentElement.appendChild(domElement);
text = doc.createTextNode(frameText());
domElement.appendChild(text);
}
// save transformation
const QTransform t = transform();
if (!t.isIdentity() || rotation() != 0) {
domElement = doc.createElement("transformation");
domElement.setAttribute("xRot", m_perspectiveAngles.x());
domElement.setAttribute("yRot", m_perspectiveAngles.y());
#if QT_VERSION < 0x040600
domElement.setAttribute("zRot", m_rotationAngle);
#else
domElement.setAttribute("zRot", rotation());
#endif
contentElement.appendChild(domElement);
}
//.........这里部分代码省略.........
示例9: toXml
void AbstractContent::toXml(QDomElement & pe) const
{
// Save general item properties
pe.setTagName("abstract");
QDomDocument doc = pe.ownerDocument();
QDomElement domElement;
QDomText text;
QString valueStr;
// Save item position and size
QDomElement rectParent = doc.createElement("rect");
QDomElement xElement = doc.createElement("x");
rectParent.appendChild(xElement);
QDomElement yElement = doc.createElement("y");
rectParent.appendChild(yElement);
QDomElement wElement = doc.createElement("w");
rectParent.appendChild(wElement);
QDomElement hElement = doc.createElement("h");
rectParent.appendChild(hElement);
QRectF rect = m_contentsRect;
xElement.appendChild(doc.createTextNode(QString::number(rect.left())));
yElement.appendChild(doc.createTextNode(QString::number(rect.top())));
wElement.appendChild(doc.createTextNode(QString::number(rect.width())));
hElement.appendChild(doc.createTextNode(QString::number(rect.height())));
pe.appendChild(rectParent);
// Save the position
domElement= doc.createElement("pos");
xElement = doc.createElement("x");
yElement = doc.createElement("y");
valueStr.setNum(pos().x());
xElement.appendChild(doc.createTextNode(valueStr));
valueStr.setNum(pos().y());
yElement.appendChild(doc.createTextNode(valueStr));
domElement.appendChild(xElement);
domElement.appendChild(yElement);
pe.appendChild(domElement);
// Save the stacking position
domElement= doc.createElement("zvalue");
pe.appendChild(domElement);
valueStr.setNum(zValue());
text = doc.createTextNode(valueStr);
domElement.appendChild(text);
// Save the visible state
domElement= doc.createElement("visible");
pe.appendChild(domElement);
valueStr.setNum(isVisible());
text = doc.createTextNode(valueStr);
domElement.appendChild(text);
// Save the frame class
valueStr.setNum(frameClass());
domElement= doc.createElement("frame-class");
pe.appendChild(domElement);
text = doc.createTextNode(valueStr);
domElement.appendChild(text);
domElement= doc.createElement("frame-text-enabled");
pe.appendChild(domElement);
valueStr.setNum(frameTextEnabled());
text = doc.createTextNode(valueStr);
domElement.appendChild(text);
if(frameTextEnabled()) {
domElement= doc.createElement("frame-text");
pe.appendChild(domElement);
text = doc.createTextNode(frameText());
domElement.appendChild(text);
}
// save transformation
const QTransform t = transform();
if (!t.isIdentity()) {
domElement = doc.createElement("transformation");
domElement.setAttribute("xRot", m_xRotationAngle);
domElement.setAttribute("yRot", m_yRotationAngle);
domElement.setAttribute("zRot", m_zRotationAngle);
pe.appendChild(domElement);
}
}
示例10: drawWithSpreadType
void drawWithSpreadType(T_Rasterizer *ras, Bitmap<Pixel> *bitmap, BlendOp *blendOp, const PaintEngineState &state)
{
const Brush brush = state.brush;
const float opacity = state.opacity;
if (brush.type() == Malachite::BrushTypeColor)
{
ColorFiller filler(brush.pixel());
fill(ras, bitmap, blendOp, &filler, opacity);
return;
}
QTransform fillShapeTransform = brush.transform() * state.shapeTransform;
if (brush.type() == Malachite::BrushTypeImage)
{
if (transformIsIntegerTranslating(fillShapeTransform))
{
QPoint offset(fillShapeTransform.dx(), fillShapeTransform.dy());
ImageFiller<T_SpreadType> filler(brush.image().constBitmap(), offset);
fill(ras, bitmap, blendOp, &filler, opacity);
return;
}
else
{
drawTransformedImageBrush<T_Rasterizer, T_SpreadType, Bitmap<Pixel> >(ras, bitmap, blendOp, brush.image().constBitmap(), opacity, fillShapeTransform.inverted(), state.imageTransformType);
return;
}
}
if (brush.type() == Malachite::BrushTypeSurface)
{
drawTransformedImageBrush<T_Rasterizer, T_SpreadType, Surface>(ras, bitmap, blendOp, brush.surface(), opacity, fillShapeTransform.inverted(), state.imageTransformType);
return;
}
if (brush.type() == Malachite::BrushTypeLinearGradient)
{
LinearGradientShape info = brush.linearGradientShape();
if (info.transformable(fillShapeTransform))
{
info.transform(fillShapeTransform);
fillShapeTransform = QTransform();
}
if (fillShapeTransform.isIdentity())
{
LinearGradientMethod method(info.start, info.end);
GradientGenerator<ColorGradient, LinearGradientMethod, T_SpreadType> gen(brush.gradient(), &method);
Filler<GradientGenerator<ColorGradient, LinearGradientMethod, T_SpreadType>, false> filler(&gen);
fill(ras, bitmap, blendOp, &filler, opacity);
return;
}
else
{
LinearGradientMethod method(info.start, info.end);
GradientGenerator<ColorGradient, LinearGradientMethod, T_SpreadType> gen(brush.gradient(), &method);
Filler<GradientGenerator<ColorGradient, LinearGradientMethod, T_SpreadType>, true> filler(&gen, fillShapeTransform.inverted());
fill(ras, bitmap, blendOp, &filler, opacity);
return;
}
}
if (brush.type() == Malachite::BrushTypeRadialGradient)
{
RadialGradientShape info = brush.radialGradientShape();
if (info.transformable(fillShapeTransform))
{
info.transform(fillShapeTransform);
fillShapeTransform = QTransform();
}
if (info.center == info.focal)
{
if (fillShapeTransform.isIdentity())
{
RadialGradientMethod method(info.center, info.radius);
GradientGenerator<ColorGradient, RadialGradientMethod, T_SpreadType> gen(brush.gradient(), &method);
Filler<GradientGenerator<ColorGradient, RadialGradientMethod, T_SpreadType>, false> filler(&gen);
fill(ras, bitmap, blendOp, &filler, opacity);
return;
}
else
{
RadialGradientMethod method(info.center, info.radius);
GradientGenerator<ColorGradient, RadialGradientMethod, T_SpreadType> gen(brush.gradient(), &method);
Filler<GradientGenerator<ColorGradient, RadialGradientMethod, T_SpreadType>, true> filler(&gen, fillShapeTransform.inverted());
fill(ras, bitmap, blendOp, &filler, opacity);
return;
}
}
else
{
if (fillShapeTransform.isIdentity())
{
FocalGradientMethod method(info.center, info.radius, info.focal);
GradientGenerator<ColorGradient, FocalGradientMethod, T_SpreadType> gen(brush.gradient(), &method);
Filler<GradientGenerator<ColorGradient, FocalGradientMethod, T_SpreadType>, false> filler(&gen);
fill(ras, bitmap, blendOp, &filler, opacity);
return;
//.........这里部分代码省略.........