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


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

本文整理汇总了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);
}
开发者ID:IGLOU-EU,项目名称:krita,代码行数:28,代码来源:kis_free_transform_strategy.cpp

示例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();
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:34,代码来源:kis_coordinates_converter.cpp

示例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();
    }
}
开发者ID:davidmueller13,项目名称:vexx,代码行数:31,代码来源:nodedock.cpp

示例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 );
}
开发者ID:GeoCat,项目名称:QGIS,代码行数:26,代码来源:qgslayoutitemshape.cpp

示例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);
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:25,代码来源:kis_transform_processing_visitor.cpp

示例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);
}
开发者ID:luocs,项目名称:GammaRay,代码行数:34,代码来源:sceneinspector.cpp

示例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);
}
开发者ID:lbovard,项目名称:covise,代码行数:31,代码来源:trackspiralarcspiral.cpp

示例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() );
}
开发者ID:AlisterH,项目名称:Quantum-GIS,代码行数:60,代码来源:qgslayoutitemshape.cpp

示例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);
    }
}
开发者ID:sachiinb,项目名称:COPASI,代码行数:47,代码来源:qrenderconverter.cpp

示例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;
}
开发者ID:3liz,项目名称:Quantum-GIS,代码行数:64,代码来源:qwt_polar_renderer.cpp

示例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;
    }
}
开发者ID:AndySardina,项目名称:fotowall,代码行数:52,代码来源:AbstractContent.cpp

示例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;
}
开发者ID:KDE,项目名称:calligra-history,代码行数:50,代码来源:KarbonBooleanCommand.cpp

示例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);
}
开发者ID:aTom3333,项目名称:tiled,代码行数:14,代码来源:mapview.cpp

示例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);
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:15,代码来源:kis_perspectivetransform_worker.cpp

示例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;
    }
开发者ID:3163504123,项目名称:phantomjs,代码行数:48,代码来源:qgraphicssceneindex.cpp


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