本文整理汇总了C++中QTransform::inverted方法的典型用法代码示例。如果您正苦于以下问题:C++ QTransform::inverted方法的具体用法?C++ QTransform::inverted怎么用?C++ QTransform::inverted使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTransform
的用法示例。
在下文中一共展示了QTransform::inverted方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: m
void KisFreeTransformStrategy::Private::recalculateTransformations()
{
KisTransformUtils::MatricesPack m(currentArgs);
QTransform sanityCheckMatrix = m.TS * m.SC * m.S * m.projectedP;
/**
* The center of the original image should still
* stay the origin of CS
*/
KIS_ASSERT_RECOVER_NOOP(sanityCheckMatrix.map(currentArgs.originalCenter()).manhattanLength() < 1e-4);
transform = m.finalTransform();
QTransform viewScaleTransform = converter->imageToDocumentTransform() * converter->documentToFlakeTransform();
handlesTransform = transform * viewScaleTransform;
QTransform tl = QTransform::fromTranslate(transaction.originalTopLeft().x(), transaction.originalTopLeft().y());
paintingTransform = tl.inverted() * q->thumbToImageTransform() * tl * transform * viewScaleTransform;
paintingOffset = transaction.originalTopLeft();
// check whether image is too big to be displayed or not
imageTooBig = KisTransformUtils::checkImageTooBig(transaction.originalRect(), m);
// recalculate cached handles position
recalculateTransformedHandles();
emit q->requestShowImageTooBig(imageTooBig);
}
示例2: mirror
QPoint KisCoordinatesConverter::mirror(QPointF center, bool mirrorXAxis, bool mirrorYAxis, bool keepOrientation)
{
bool doXMirroring = m_d->isXAxisMirrored ^ mirrorXAxis;
bool doYMirroring = m_d->isYAxisMirrored ^ mirrorYAxis;
qreal scaleX = doXMirroring ? -1.0 : 1.0;
qreal scaleY = doYMirroring ? -1.0 : 1.0;
QTransform mirror = QTransform::fromScale(scaleX, scaleY);
QTransform rot;
rot.rotate(m_d->rotationAngle);
m_d->flakeToWidget *= QTransform::fromTranslate(-center.x(),-center.y());
if(keepOrientation)
m_d->flakeToWidget *= rot.inverted();
m_d->flakeToWidget *= mirror;
if(keepOrientation)
m_d->flakeToWidget *= rot;
m_d->flakeToWidget *= QTransform::fromTranslate(center.x(),center.y());
if(!keepOrientation && (doXMirroring ^ doYMirroring))
m_d->rotationAngle = -m_d->rotationAngle;
m_d->isXAxisMirrored = mirrorXAxis;
m_d->isYAxisMirrored = mirrorYAxis;
correctOffsetToTransformation();
recalculateTransformations();
return m_d->documentOffset.toPoint();
}
示例3: centreNode
void nodeDock::centreNode( AEntity *ent ) // places the node in the centre of the view
{
nodeEntity *node( ent->castTo<nodeEntity*>() );
if( node )
{
connect( node, SIGNAL(requestNetworkRedraw()), mScene, SLOT(update()), Qt::UniqueConnection );
if( qFuzzyCompare( node->property("nodeEntity/pos")->toVector3D(), QVector3D( 0, 0, 0 ) ) )
{
// set pos to centre of screen
QPointF pos;
pos.setX(mView->rect().width()/2);
pos.setY(mView->rect().height()/2);
// get transformation matrix and invert it (viewMatrix moves the scene, so invert to move to view)
QTransform viewMatrix = mView->getTransform();
viewMatrix = viewMatrix.inverted();
// map point to matrix
pos = viewMatrix.map(pos);
// set position
QVector3D vectPos;
vectPos.setX(pos.x());
vectPos.setY(pos.y());
node->property("nodeEntity/pos") = vectPos;
}
//Rebuild gui from here, rather than direct signal so only rebuild on NODE added, not just any entity
rebuildGui();
}
}
示例4: draw
void QgsLayoutItemEllipseShape::draw( QgsRenderContext &context, const QStyleOptionGraphicsItem * )
{
QPainter *painter = context.painter();
painter->setPen( Qt::NoPen );
painter->setBrush( Qt::NoBrush );
double scale = context.convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
//shapes with curves must be enlarged before conversion to QPolygonF, or
//the curves are approximated too much and appear jaggy
QTransform t = QTransform::fromScale( 100, 100 );
//inverse transform used to scale created polygons back to expected size
QTransform ti = t.inverted();
//create an ellipse
QPainterPath ellipsePath;
ellipsePath.addEllipse( QRectF( 0, 0, rect().width() * scale, rect().height() * scale ) );
QPolygonF ellipsePoly = ellipsePath.toFillPolygon( t );
QPolygonF shapePolygon = ti.map( ellipsePoly );
QList<QPolygonF> rings; //empty list
symbol()->startRender( context );
symbol()->renderPolygon( shapePolygon, &rings, nullptr, context );
symbol()->stopRender( context );
}
示例5: 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);
}
}
示例6: renderScene
void SceneInspector::renderScene(const QTransform &transform, const QSize &size)
{
if (!Endpoint::isConnected()) {
// only do something if we are connected to a remote client
return;
}
QGraphicsScene *scene = m_sceneModel->scene();
if (!scene) {
return;
}
// initialize transparent pixmap
QPixmap view(size);
view.fill(Qt::transparent);
// setup painter and apply transformation of client view
QPainter painter(&view);
painter.setWorldTransform(transform);
// the area we want to paint has the size of the client's viewport _after_ applying
// the transformation. Thus first apply the inverse to yield the desired area afterwards
QRectF area(QPointF(0, 0), size);
area = transform.inverted().mapRect(area);
scene->render(&painter, area, area, Qt::IgnoreAspectRatio);
QGraphicsItem *currentItem = m_itemSelectionModel->currentIndex().data(SceneModel::SceneItemRole).value<QGraphicsItem*>();
if (currentItem) {
paintItemDecoration(currentItem, transform, &painter);
}
emit sceneRendered(view);
}
示例7: deltaHeading
/*! \brief Convenience function.
*
*/
void
TrackSpiralArcSpiral::setLocalStartHeading(double startHeading)
{
while (startHeading <= -180.0)
{
startHeading += 360.0;
}
while (startHeading > 180.0)
{
startHeading -= 360.0;
}
// Local to internal (Parameters are given in internal coordinates) //
//
double deltaHeading(startHeading - heading());
QTransform trafo;
trafo.rotate(deltaHeading);
pa_->setEndHeadingDeg(pa_->getEndHeadingRad() * 360.0 / (2.0 * M_PI) - deltaHeading);
pa_->setEndPoint(trafo.inverted().map(pa_->getEndPoint()));
pa_->init();
applyParameters();
// Set local translation //
//
setLocalRotation(startHeading);
}
示例8: draw
void QgsLayoutItemShape::draw( QgsLayoutItemRenderContext &context )
{
QPainter *painter = context.renderContext().painter();
painter->setPen( Qt::NoPen );
painter->setBrush( Qt::NoBrush );
double scale = context.renderContext().convertToPainterUnits( 1, QgsUnitTypes::RenderMillimeters );
QPolygonF shapePolygon;
//shapes with curves must be enlarged before conversion to QPolygonF, or
//the curves are approximated too much and appear jaggy
QTransform t = QTransform::fromScale( 100, 100 );
//inverse transform used to scale created polygons back to expected size
QTransform ti = t.inverted();
switch ( mShape )
{
case Ellipse:
{
//create an ellipse
QPainterPath ellipsePath;
ellipsePath.addEllipse( QRectF( 0, 0, rect().width() * scale, rect().height() * scale ) );
QPolygonF ellipsePoly = ellipsePath.toFillPolygon( t );
shapePolygon = ti.map( ellipsePoly );
break;
}
case Rectangle:
{
//if corner radius set, then draw a rounded rectangle
if ( mCornerRadius.length() > 0 )
{
QPainterPath roundedRectPath;
double radius = mLayout->convertToLayoutUnits( mCornerRadius ) * scale;
roundedRectPath.addRoundedRect( QRectF( 0, 0, rect().width() * scale, rect().height() * scale ), radius, radius );
QPolygonF roundedPoly = roundedRectPath.toFillPolygon( t );
shapePolygon = ti.map( roundedPoly );
}
else
{
shapePolygon = QPolygonF( QRectF( 0, 0, rect().width() * scale, rect().height() * scale ) );
}
break;
}
case Triangle:
{
shapePolygon << QPointF( 0, rect().height() * scale );
shapePolygon << QPointF( rect().width() * scale, rect().height() * scale );
shapePolygon << QPointF( rect().width() / 2.0 * scale, 0 );
shapePolygon << QPointF( 0, rect().height() * scale );
break;
}
}
QList<QPolygonF> rings; //empty list
symbol()->startRender( context.renderContext() );
symbol()->renderPolygon( shapePolygon, &rings, nullptr, context.renderContext() );
symbol()->stopRender( context.renderContext() );
}
示例9: transform
void transform(QGraphicsItem *item, const CLTransformation2D* trans, const CLGroup* group)
{
if (trans != NULL && trans->isSetMatrix())
{
QRectF pathRect = item->boundingRect();
QTransform transform(
trans->getMatrix2D()[0],
trans->getMatrix2D()[1],
trans->getMatrix2D()[2],
trans->getMatrix2D()[3],
trans->getMatrix2D()[4],
trans->getMatrix2D()[5]
);
QTransform matrix;
matrix = matrix.translate(pathRect.x(), pathRect.y());
matrix = matrix.inverted();
matrix = matrix * transform;
QTransform translate;
translate = translate.translate(pathRect.x(), pathRect.y());
matrix = matrix * translate;
item->setTransform(matrix, true);
}
else if (group != NULL && group->isSetMatrix())
{
QRectF pathRect = item->boundingRect();
QTransform transform(
group->getMatrix2D()[0],
group->getMatrix2D()[1],
group->getMatrix2D()[2],
group->getMatrix2D()[3],
group->getMatrix2D()[4],
group->getMatrix2D()[5]
);
QTransform matrix;
matrix = matrix.translate(pathRect.x(), pathRect.y());
matrix = matrix.inverted();
matrix = matrix * transform;
QTransform translate;
translate = translate.translate(pathRect.x(), pathRect.y());
matrix = matrix * translate;
item->setTransform(matrix, true);
}
}
示例10: render
/*!
\brief Render the plot to a given rectangle ( f.e QPrinter, QSvgRenderer )
\param plot Plot widget to be rendered
\param painter Painter
\param plotRect Bounding rectangle for the plot
*/
void QwtPolarRenderer::render( QwtPolarPlot *plot,
QPainter *painter, const QRectF &plotRect ) const
{
if ( plot == NULL || painter == NULL || !painter->isActive() ||
!plotRect.isValid() || plot->size().isNull() )
{
return;
}
d_data->plot = plot;
/*
The layout engine uses the same methods as they are used
by the Qt layout system. Therefore we need to calculate the
layout in screen coordinates and paint with a scaled painter.
*/
QTransform transform;
transform.scale(
double( painter->device()->logicalDpiX() ) / plot->logicalDpiX(),
double( painter->device()->logicalDpiY() ) / plot->logicalDpiY() );
const QRectF layoutRect = transform.inverted().mapRect( plotRect );
QwtPolarLayout *layout = plot->plotLayout();
// All paint operations need to be scaled according to
// the paint device metrics.
QwtPolarLayout::Options layoutOptions =
QwtPolarLayout::IgnoreScrollbars | QwtPolarLayout::IgnoreFrames;
layout->activate( plot, layoutRect, layoutOptions );
painter->save();
painter->setWorldTransform( transform, true );
painter->save();
renderTitle( painter, layout->titleRect() );
painter->restore();
painter->save();
renderLegend( painter, layout->legendRect() );
painter->restore();
const QRectF &canvasRect = layout->canvasRect();
painter->save();
painter->setClipRect( canvasRect );
plot->drawCanvas( painter, canvasRect );
painter->restore();
painter->restore();
layout->invalidate();
d_data->plot = NULL;
}
示例11: slotSaveAs
void AbstractContent::slotSaveAs()
{
// make up the default save path (stored as 'Fotowall/ExportDir')
QSettings s;
QString defaultSavePath = tr("Unnamed %1.png").arg(QDate::currentDate().toString());
if (s.contains("Fotowall/ExportDir"))
defaultSavePath.prepend(s.value("Fotowall/ExportDir").toString() + QDir::separator());
// ask the file name, validate it, store back to settings
QString imgFilePath = QFileDialog::getSaveFileName(0, tr("Choose the Image file"), defaultSavePath, tr("Images (*.jpeg *.jpg *.png *.bmp *.tif *.tiff)"));
if (imgFilePath.isNull())
return;
s.setValue("Fotowall/ExportDir", QFileInfo(imgFilePath).absolutePath());
if (QFileInfo(imgFilePath).suffix().isEmpty())
imgFilePath += ".png";
// find out the Transform chain to mirror a rotated item
QRectF sceneRectF = mapToScene(boundingRect()).boundingRect();
QTransform tFromItem = transform() * QTransform(1, 0, 0, 1, pos().x(), pos().y());
QTransform tFromPixmap = QTransform(1, 0, 0, 1, sceneRectF.left(), sceneRectF.top());
QTransform tItemToPixmap = tFromItem * tFromPixmap.inverted();
// render on the image
int iHeight = (int)sceneRectF.height();
if (m_mirrorItem)
iHeight += (int)m_mirrorItem->boundingRect().height();
QImage image((int)sceneRectF.width(), iHeight, QImage::Format_ARGB32);
image.fill(Qt::transparent);
// enable hi-q rendering
bool prevHQ = RenderOpts::HQRendering;
RenderOpts::HQRendering = true;
// draw the transformed item onto the pixmap
QPainter p(&image);
p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, true);
p.setTransform(tItemToPixmap);
paint(&p, 0, 0);
if (m_mirrorItem) {
p.resetTransform();
p.translate(0, (qreal)((int)sceneRectF.height()));
m_mirrorItem->paint(&p, 0, 0);
}
p.end();
RenderOpts::HQRendering = prevHQ;
// save image and check errors
if (!image.save(imgFilePath) || !QFile::exists(imgFilePath)) {
QMessageBox::warning(0, tr("File Error"), tr("Error saving the Object to '%1'").arg(imgFilePath));
return;
}
}
示例12: redo
void KarbonBooleanCommand::redo()
{
if (! d->resultingPath) {
QPainterPath pa = d->pathA->absoluteTransformation(0).map(d->pathA->outline());
QPainterPath pb = d->pathB->absoluteTransformation(0).map(d->pathB->outline());
QPainterPath pr;
switch (d->operation) {
case Intersection:
pr = pa.intersected(pb);
break;
case Subtraction:
pr = pa.subtracted(pb);
break;
case Exclusion:
pr = pa.subtracted(pb);
pr.addPath(pb.subtracted(pa));
break;
case Union:
pr = pa.united(pb);
break;
}
QTransform transformation = d->pathA->transformation();
pr = transformation.inverted().map(pr);
d->resultingPath = KoPathShape::createShapeFromPainterPath(pr);
d->resultingPath->setBorder(d->pathA->border());
d->resultingPath->setBackground(d->pathA->background());
d->resultingPath->setShapeId(d->pathA->shapeId());
d->resultingPath->setTransformation(transformation);
d->resultingPath->setName(d->pathA->name());
d->resultingPath->setZIndex(d->pathA->zIndex());
d->resultingPath->setFillRule(d->pathA->fillRule());
KoShapeGroup * group = dynamic_cast<KoShapeGroup*>(d->pathA->parent());
if (group) {
QList<KoShape*> children;
d->resultParentCmd = new KoShapeGroupCommand(group, children << d->resultingPath, this);
}
}
if (d->controller) {
if (d->resultParent)
d->resultParent->addShape(d->resultingPath);
d->controller->addShape(d->resultingPath);
}
QUndoCommand::redo();
d->isExecuted = true;
}
示例13: updateSceneRect
void MapView::updateSceneRect(const QRectF &sceneRect, const QTransform &transform)
{
// Calculate a scene rect that includes a margin on the edge of the map,
// taking into account the scale
const QSize maxSize = maximumViewportSize();
const qreal marginWidth = maxSize.width() * 0.9;
const qreal marginHeight = maxSize.height() * 0.9;
QRectF viewRect = transform.mapRect(sceneRect);
viewRect.adjust(-marginWidth, -marginHeight, marginWidth, marginHeight);
const QRectF expandedSceneRect = transform.inverted().mapRect(viewRect);
setSceneRect(expandedSceneRect);
}
示例14: init
KisPerspectiveTransformWorker::KisPerspectiveTransformWorker(KisPaintDeviceSP dev, QPointF center, double aX, double aY, double distance, KoUpdaterPtr progress)
: m_dev(dev), m_progressUpdater(progress)
{
QMatrix4x4 m;
m.rotate(180. * aX / M_PI, QVector3D(1, 0, 0));
m.rotate(180. * aY / M_PI, QVector3D(0, 1, 0));
QTransform project = m.toTransform(distance);
QTransform t = QTransform::fromTranslate(center.x(), center.y());
QTransform forwardTransform = t.inverted() * project * t;
init(forwardTransform);
}
示例15: intersect_rect
static bool intersect_rect(const QGraphicsItem *item, const QRectF &exposeRect, Qt::ItemSelectionMode mode,
const QTransform &deviceTransform, const void *intersectData)
{
const QRectF sceneRect = *static_cast<const QRectF *>(intersectData);
QRectF brect = item->boundingRect();
_q_adjustRect(&brect);
// ### Add test for this (without making things slower?)
Q_UNUSED(exposeRect);
bool keep = true;
const QGraphicsItemPrivate *itemd = QGraphicsItemPrivate::get(item);
if (itemd->itemIsUntransformable()) {
// Untransformable items; map the scene rect to item coordinates.
const QTransform transform = item->deviceTransform(deviceTransform);
QRectF itemRect = (deviceTransform * transform.inverted()).mapRect(sceneRect);
if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
keep = itemRect.contains(brect) && itemRect != brect;
else
keep = itemRect.intersects(brect);
if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
QPainterPath itemPath;
itemPath.addRect(itemRect);
keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, itemPath, mode);
}
} else {
Q_ASSERT(!itemd->dirtySceneTransform);
const QRectF itemSceneBoundingRect = itemd->sceneTransformTranslateOnly
? brect.translated(itemd->sceneTransform.dx(),
itemd->sceneTransform.dy())
: itemd->sceneTransform.mapRect(brect);
if (mode == Qt::ContainsItemShape || mode == Qt::ContainsItemBoundingRect)
keep = sceneRect != brect && sceneRect.contains(itemSceneBoundingRect);
else
keep = sceneRect.intersects(itemSceneBoundingRect);
if (keep && (mode == Qt::ContainsItemShape || mode == Qt::IntersectsItemShape)) {
QPainterPath rectPath;
rectPath.addRect(sceneRect);
if (itemd->sceneTransformTranslateOnly)
rectPath.translate(-itemd->sceneTransform.dx(), -itemd->sceneTransform.dy());
else
rectPath = itemd->sceneTransform.inverted().map(rectPath);
keep = QGraphicsSceneIndexPrivate::itemCollidesWithPath(item, rectPath, mode);
}
}
return keep;
}