本文整理汇总了C++中QTransform::dx方法的典型用法代码示例。如果您正苦于以下问题:C++ QTransform::dx方法的具体用法?C++ QTransform::dx怎么用?C++ QTransform::dx使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTransform
的用法示例。
在下文中一共展示了QTransform::dx方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transform
void VGradientEx::transform( const QTransform &m )
{
double mx, my;
mx = m.m11() * m_origin.x() + m.m21() * m_origin.y() + m.dx();
my = m.m22() * m_origin.y() + m.m12() * m_origin.x() + m.dy();
m_origin = FPoint(mx, my);
mx = m.m11() * m_focalPoint.x() + m.m21() * m_focalPoint.y() + m.dx();
my = m.m22() * m_focalPoint.y() + m.m12() * m_focalPoint.x() + m.dy();
m_focalPoint = FPoint(mx, my);
mx = m.m11() * m_vector.x() + m.m21() * m_vector.y() + m.dx();
my = m.m22() * m_vector.y() + m.m12() * m_vector.x() + m.dy();
m_vector = FPoint(mx, my);
}
示例2: preciselyMap
static QLineF preciselyMap( const QTransform& transform, const QLineF& line )
{
qreal fx1 = line.x1();
qreal fy1 = line.y1();
qreal fx2 = line.x2();
qreal fy2 = line.y2();
qreal x1 = transform.m11() * fx1 + transform.m21() * fy1 + transform.dx();
qreal y1 = transform.m12() * fx1 + transform.m22() * fy1 + transform.dy();
qreal x2 = transform.m11() * fx2 + transform.m21() * fy2 + transform.dx();
qreal y2 = transform.m12() * fx2 + transform.m22() * fy2 + transform.dy();
return QLineF( x1, y1, x2, y2 );
}
示例3: draw
void QFontEngineQPF::draw(QPaintEngine *p, qreal _x, qreal _y, const QTextItemInt &si)
{
QPaintEngineState *pState = p->state;
QRasterPaintEngine *paintEngine = static_cast<QRasterPaintEngine*>(p);
QTransform matrix = pState->transform();
matrix.translate(_x, _y);
QFixed x = QFixed::fromReal(matrix.dx());
QFixed y = QFixed::fromReal(matrix.dy());
QVarLengthArray<QFixedPoint> positions;
QVarLengthArray<glyph_t> glyphs;
getGlyphPositions(si.glyphs, si.num_glyphs, matrix, si.flags, glyphs, positions);
if (glyphs.size() == 0)
return;
for(int i = 0; i < glyphs.size(); i++) {
const Glyph *glyph = findGlyph(glyphs[i]);
if (!glyph)
continue;
const bool mono = false; // ###
paintEngine->alphaPenBlt(reinterpret_cast<const uchar *>(glyph) + sizeof(Glyph), glyph->bytesPerLine, mono,
qRound(positions[i].x) + glyph->x,
qRound(positions[i].y) + glyph->y,
glyph->width, glyph->height);
}
}
示例4: glDrawArrays
void MGLES2Renderer::draw(const QRect &rectangle)
{
GLfloat *vertices = d_ptr->m_vertices.data();
vertices[0] = rectangle.left(); vertices[1] = rectangle.top();
vertices[2] = rectangle.left(); vertices[3] = rectangle.top() + rectangle.height();
vertices[4] = rectangle.left() + rectangle.width(); vertices[5] = rectangle.top() + rectangle.height();
vertices[6] = rectangle.left() + rectangle.width(); vertices[7] = rectangle.top();
QTransform transform;
GLfloat o = 1.0;
if (d_ptr->m_activePainter) {
transform = d_ptr->m_activePainter->combinedTransform();
o = d_ptr->m_activePainter->opacity();
}
d_ptr->m_matWorld[0][0] = transform.m11();
d_ptr->m_matWorld[0][1] = transform.m12();
d_ptr->m_matWorld[0][3] = transform.m13();
d_ptr->m_matWorld[1][0] = transform.m21();
d_ptr->m_matWorld[1][1] = transform.m22();
d_ptr->m_matWorld[1][3] = transform.m23();
d_ptr->m_matWorld[3][0] = transform.dx();
d_ptr->m_matWorld[3][1] = transform.dy();
d_ptr->m_matWorld[3][3] = transform.m33();
d_ptr->m_activeProgram->setUniformValue("matWorld", d_ptr->m_matWorld);
d_ptr->m_activeProgram->setUniformValue("opacity", o);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
}
示例5: rotate
void ellipse::rotate(qreal angle)
{
this->transformationRotate = this->transformationRotate.rotate(angle);
QPointF translatePoint(this->transformationTranslate.dx(),this->transformationTranslate.dy());
QTransform tempRotate(1, 0, 0, 1, 0, 0);
tempRotate.rotate(angle);
QPointF rotatedPoint = tempRotate.map(translatePoint);
this->transformationTranslate = QTransform(1, 0, 0, 1, rotatedPoint.x(), rotatedPoint.y());
this->transformationMatrix = this->transformationScale* this->transformationRotate * this->transformationTranslate;
if(!this->transformationMatrix.isInvertible())
{
//qDebug() << "Notinvertible";
}
QTransform inverted = this->transformationMatrix.inverted();
data.scaleX = (cl_float) inverted.m11();
data.scaleY = (cl_float) inverted.m22();
data.angleX = (cl_float) inverted.m21();
data.angleY = (cl_float) inverted.m12();
data.dx = (cl_float) inverted.dx();
data.dy = (cl_float) inverted.dy();
}
示例6: alignSelectedItemsHCenter
void QgsComposition::alignSelectedItemsHCenter()
{
QList<QgsComposerItem*> selectedItems = selectedComposerItems();
if ( selectedItems.size() < 2 )
{
return;
}
QRectF selectedItemBBox;
if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
{
return;
}
double averageXCoord = ( selectedItemBBox.left() + selectedItemBBox.right() ) / 2.0;
//place items
QUndoCommand* parentCommand = new QUndoCommand( tr( "Aligned items hcenter" ) );
QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
for ( ; align_it != selectedItems.end(); ++align_it )
{
QgsComposerItemCommand* subcommand = new QgsComposerItemCommand( *align_it, "", parentCommand );
subcommand->savePreviousState();
QTransform itemTransform = ( *align_it )->transform();
itemTransform.translate( averageXCoord - itemTransform.dx() - ( *align_it )->rect().width() / 2.0, 0 );
( *align_it )->setTransform( itemTransform );
subcommand->saveAfterState();
}
mUndoStack.push( parentCommand );
}
示例7: transformClones
void KisTransformProcessingVisitor::transformClones(KisLayer *layer, KisUndoAdapter *undoAdapter)
{
QList<KisCloneLayerWSP> clones = layer->registeredClones();
foreach(KisCloneLayerSP clone, clones) {
// we have just casted an object from a weak pointer,
// so check validity first
if(!clone) continue;
KisTransformWorker tw(clone->projection(), m_sx, m_sy, m_shearx, m_sheary,
m_shearOrigin.x(), m_shearOrigin.y(),
m_angle, m_tx, m_ty, 0,
m_filter);
QTransform trans = tw.transform();
QTransform offsetTrans = QTransform::fromTranslate(clone->x(), clone->y());
QTransform newTrans = trans.inverted() * offsetTrans * trans;
QPoint oldPos(clone->x(), clone->y());
QPoint newPos(newTrans.dx(), newTrans.dy());
KUndo2Command *command = new KisNodeMoveCommand2(clone, oldPos, newPos, undoAdapter);
undoAdapter->addCommand(command);
}
}
示例8: drawText
void ZebraPaintEngine::drawText ( const QPointF &p, const QString & text, const QFont &font )
{
QTransform transform = painter()->worldTransform();
int xInDots = (int)(transform.dx());
int yInDots = (int)(transform.dy());
int carHeight = (font.pointSize() * resolution()) / 72;
const int minSize = 10;
if(carHeight < minSize) {
carHeight = minSize;
}
int carWidth = qRound((carHeight * 15.0) / 28.0); // fixed width/height ratio for the scalable A0 font
QString rotation = transformRotationCmd();
if(rotation == rotation90Cmd()) {
xInDots -= carHeight;
}
else if(rotation == rotation180Cmd()) {
yInDots -= carHeight;
xInDots -= (carWidth * text.length());
}
else if(rotation == rotation270Cmd()) {
yInDots -= (carWidth * text.length());
}
QString output = QString(m_CmdPrefix + "FO%1,%2" + m_CmdPrefix + "FW%3").arg(xInDots).arg(yInDots).arg(rotation);
output += QString(m_CmdPrefix + "A0,%1,0" + m_CmdPrefix + "FD" + text + m_CmdPrefix + "FS\n").arg(carHeight);
QTextCodec *codec = QTextCodec::codecForName("IBM 850");
m_printBuffer.append(codec->fromUnicode(output));
}
示例9: addChild
void AbstractGroupPrivate::addChild(QGraphicsWidget *child)
{
QPointF newPos = q->mapFromItem(child->parentItem(), child->pos());
if (groupType == AbstractGroup::ConstrainedGroup) {
child->setTransform(QTransform());
} else {
QTransform t(child->itemTransform(q));
if (t.m11() != 0) {
qreal angle = (t.m12() > 0 ? acos(t.m11()) : -acos(t.m11()));
QTransform at;
QSizeF size(child->size());
at.translate(size.width() / 2, size.height() / 2);
at.rotateRadians(angle);
at.translate(-size.width() / 2, -size.height() / 2);
child->setTransform(at);
newPos -= QPointF(at.dx(), at.dy());
}
}
child->setParentItem(q);
child->setProperty("group", QVariant::fromValue(q));
child->setPos(newPos);
if (groupType == AbstractGroup::FreeGroup) {
q->connect(child, SIGNAL(geometryChanged()), q, SLOT(onChildGeometryChanged()));
}
}
示例10: setSceneTransform
void QgsComposerRuler::setSceneTransform( const QTransform& transform )
{
QString debug = QString::number( transform.dx() ) + "," + QString::number( transform.dy() ) + ","
+ QString::number( transform.m11() ) + "," + QString::number( transform.m22() );
mTransform = transform;
update();
}
示例11: glDrawElements
void MGLES2Renderer::draw(const QList<QRect>& targets, const QList<QRect>& sources)
{
GLuint num = d_ptr->setupVertices(d_ptr->m_boundTexSize, sources, targets);
QTransform transform;
GLfloat o = 1.0;
if (d_ptr->m_activePainter) {
transform = d_ptr->m_activePainter->combinedTransform();
o = d_ptr->m_activePainter->opacity();
}
d_ptr->m_matWorld[0][0] = transform.m11();
d_ptr->m_matWorld[0][1] = transform.m12();
d_ptr->m_matWorld[0][3] = transform.m13();
d_ptr->m_matWorld[1][0] = transform.m21();
d_ptr->m_matWorld[1][1] = transform.m22();
d_ptr->m_matWorld[1][3] = transform.m23();
d_ptr->m_matWorld[3][0] = transform.dx();
d_ptr->m_matWorld[3][1] = transform.dy();
d_ptr->m_matWorld[3][3] = transform.m33();
d_ptr->m_activeProgram->setUniformValue("matWorld", d_ptr->m_matWorld);
d_ptr->m_activeProgram->setUniformValue("opacity", o);
glDrawElements(GL_TRIANGLES, num, GL_UNSIGNED_SHORT, d_ptr->m_indices.data());
}
示例12: alignSelectedItemsRight
void QgsComposition::alignSelectedItemsRight()
{
QList<QgsComposerItem*> selectedItems = selectedComposerItems();
if ( selectedItems.size() < 2 )
{
return;
}
QRectF selectedItemBBox;
if ( boundingRectOfSelectedItems( selectedItemBBox ) != 0 )
{
return;
}
double maxXCoordinate = selectedItemBBox.right();
//align items right to maximum x coordinate
QUndoCommand* parentCommand = new QUndoCommand( tr( "Aligned items right" ) );
QList<QgsComposerItem*>::iterator align_it = selectedItems.begin();
for ( ; align_it != selectedItems.end(); ++align_it )
{
QgsComposerItemCommand* subcommand = new QgsComposerItemCommand( *align_it, "", parentCommand );
subcommand->savePreviousState();
QTransform itemTransform = ( *align_it )->transform();
itemTransform.translate( maxXCoordinate - itemTransform.dx() - ( *align_it )->rect().width(), 0 );
( *align_it )->setTransform( itemTransform );
subcommand->saveAfterState();
}
mUndoStack.push( parentCommand );
}
示例13: updateVertices
void updateVertices(const QTransform &t)
{
worldMatrix[0][0] = t.m11();
worldMatrix[0][1] = t.m12();
worldMatrix[0][3] = t.m13();
worldMatrix[1][0] = t.m21();
worldMatrix[1][1] = t.m22();
worldMatrix[1][3] = t.m23();
worldMatrix[3][0] = t.dx();
worldMatrix[3][1] = t.dy();
worldMatrix[3][3] = t.m33();
}
示例14: initializeTransform
void UBGraphicsDelegateFrame::initializeTransform()
{
QTransform itemTransform = delegated()->sceneTransform();
QRectF itemRect = delegated()->boundingRect();
QPointF topLeft = itemTransform.map(itemRect.topLeft());
QPointF topRight = itemTransform.map(itemRect.topRight());
QPointF bottomLeft = itemTransform.map(itemRect.bottomLeft());
qreal horizontalFlip = (topLeft.x() > topRight.x()) ? -1 : 1;
mMirrorX = horizontalFlip < 0 ;
if(horizontalFlip < 0) {
// why this is because of the way of calculating the translations that checks which side is the most is the
// nearest instead of checking which one is the left side.
QPointF tmp = topLeft;
topLeft = topRight;
topRight = tmp;
// because of the calculation of the height is done by lenght and not deltaY
bottomLeft = itemTransform.map(itemRect.bottomRight());
}
qreal verticalFlip = (bottomLeft.y() < topLeft.y()) ? -1 : 1;
// not sure that is usefull
mMirrorY = verticalFlip < 0;
if(verticalFlip < 0 && !mMirrorX) {
topLeft = itemTransform.map(itemRect.bottomLeft());
topRight = itemTransform.map(itemRect.bottomRight());
bottomLeft = itemTransform.map(itemRect.topLeft());
}
QLineF topLine(topLeft, topRight);
QLineF leftLine(topLeft, bottomLeft);
qreal width = topLine.length();
qreal height = leftLine.length();
mAngle = topLine.angle();
// the fact the the length is used we loose the horizontalFlip information
// a better way to do this is using DeltaX that preserve the direction information.
mTotalScaleX = (width / itemRect.width()) * horizontalFlip;
mTotalScaleY = height / itemRect.height() * verticalFlip;
QTransform tr;
QPointF center = delegated()->boundingRect().center();
tr.translate(center.x() * mTotalScaleX, center.y() * mTotalScaleY);
tr.rotate(-mAngle);
tr.translate(-center.x() * mTotalScaleX, -center.y() * mTotalScaleY);
tr.scale(mTotalScaleX, mTotalScaleY);
mTotalTranslateX = delegated()->transform().dx() - tr.dx();
mTotalTranslateY = delegated()->transform().dy() - tr.dy();
}
示例15: 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;
}