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


C++ KisImageWSP::perspectiveGrid方法代码示例

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


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

示例1: updateGUI

void KisPerspectiveGridManager::updateGUI()
{
    KisImageWSP image = m_view->image();

    if (image) {
        KisPerspectiveGrid* pGrid = image->perspectiveGrid();
        m_toggleGrid->setEnabled(pGrid->hasSubGrids());
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:9,代码来源:kis_perspective_grid_manager.cpp

示例2: clearPerspectiveGrid

void KisPerspectiveGridManager::clearPerspectiveGrid()
{
    KisImageWSP image = m_view->image();
    if (image) {
        image->perspectiveGrid()->clearSubGrids();
        m_view->canvas()->update();
        m_toggleGrid->setChecked(false);
        m_toggleGrid->setEnabled(false);
    }
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:10,代码来源:kis_perspective_grid_manager.cpp

示例3: drawDecoration

void KisPerspectiveGridManager::drawDecoration(QPainter& gc, const QRectF& updateRect, const KisCoordinatesConverter *converter)
{
    Q_UNUSED(updateRect);

    KisImageWSP image = m_view->resourceProvider()->currentImage();
    Q_ASSERT(image);

    KisPerspectiveGrid* pGrid = image->perspectiveGrid();

    QPen mainPen = KisGridPainterConfiguration::mainPen();
    QPen subdivisionPen = KisGridPainterConfiguration::subdivisionPen();
    QPen errorPen = mainPen;
    errorPen.setColor(Qt::red);


    QTransform transform = converter->imageToWidgetTransform();
    gc.save();
    gc.setTransform(transform);

    for (QList<KisSubPerspectiveGrid*>::const_iterator it = pGrid->begin(); it != pGrid->end(); ++it) {
        const KisSubPerspectiveGrid* grid = *it;

        /**
         * Note that the notion of top-bottom-right-left
         * is purely theorical
         */
        LineWrapper lineTop(*grid->topLeft(), *grid->topRight());
        LineWrapper lineRight(*grid->topRight(), *grid->bottomRight());
        LineWrapper lineBottom(*grid->bottomRight(), *grid->bottomLeft());
        LineWrapper lineLeft(*grid->bottomLeft(), *grid->topLeft());

        QPointF horizIntersection;
        QPointF vertIntersection;

        bool linesNotNull = true;
        bool polygonIsConvex = true;

        if(lineTop.isNull(SMALLEST_LINE) ||
           lineBottom.isNull(SMALLEST_LINE) ||
           lineLeft.isNull(SMALLEST_LINE) ||
           lineRight.isNull(SMALLEST_LINE)) {

            linesNotNull = false;
        }

        if(linesNotNull) {
            horizIntersection = lineTop.intersects(lineBottom);
            vertIntersection = lineLeft.intersects(lineRight);

            if(lineTop.contains(horizIntersection) ||
               lineBottom.contains(horizIntersection) ||
               lineLeft.contains(vertIntersection) ||
               lineRight.contains(vertIntersection)) {

                polygonIsConvex = false;
            }
        }

        if(polygonIsConvex && linesNotNull) {
            gc.setPen(subdivisionPen);

            SubdivisionLinesInfo info;
            info = getSubdivisionsInfo(lineTop, lineBottom, vertIntersection,
                                       grid->subdivisions());
            drawSubdivisions(gc, info);

            info = getSubdivisionsInfo(lineLeft, lineRight, horizIntersection,
                                       grid->subdivisions());
            drawSubdivisions(gc, info);
        }

        gc.setPen(polygonIsConvex && linesNotNull ? mainPen : errorPen);
        gc.drawLine(*grid->topLeft(), *grid->topRight());
        gc.drawLine(*grid->topRight(), *grid->bottomRight());
        gc.drawLine(*grid->bottomRight(), *grid->bottomLeft());
        gc.drawLine(*grid->bottomLeft(), *grid->topLeft());
    }
    gc.restore();
}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:79,代码来源:kis_perspective_grid_manager.cpp

示例4: paintAt

KisSpacingInformation KisDuplicateOp::paintAt(const KisPaintInformation& info)
{
    if (!painter()->device()) return 1.0;

    KisBrushSP brush = m_brush;
    if (!brush)
        return 1.0;

    if (!brush->canPaintFor(info))
        return 1.0;

    if (!m_duplicateStartIsSet) {
        m_duplicateStartIsSet = true;
        m_duplicateStart = info.pos();
    }

    KisPaintDeviceSP realSourceDevice = settings->node()->paintDevice();

    qreal scale = m_sizeOption.apply(info);
    if (checkSizeTooSmall(scale)) return KisSpacingInformation();

    QPointF hotSpot = brush->hotSpot(scale, scale, 0, info);
    QPointF pt = info.pos() - hotSpot;

    setCurrentScale(scale);

    // Split the coordinates into integer plus fractional parts. The integer
    // is where the dab will be positioned and the fractional part determines
    // the sub-pixel positioning.
    qint32 x, y;
    qreal xFraction, yFraction; // will not be used
    splitCoordinate(pt.x(), &x, &xFraction);
    splitCoordinate(pt.y(), &y, &yFraction);

    QPoint srcPoint;

    if(m_moveSourcePoint)
    {
        srcPoint = QPoint(x - static_cast<qint32>(settings->offset().x()),
                          y - static_cast<qint32>(settings->offset().y()));
    } else {
        srcPoint = QPoint(static_cast<qint32>(settings->position().x() - hotSpot.x()),
                          static_cast<qint32>(settings->position().y() - hotSpot.y()));
    }

    qint32 sw = brush->maskWidth(scale, 0.0, xFraction, yFraction, info);
    qint32 sh = brush->maskHeight(scale, 0.0, xFraction, yFraction, info);

    if (srcPoint.x() < 0)
        srcPoint.setX(0);

    if (srcPoint.y() < 0)
        srcPoint.setY(0);

    // Perspective correction ?
    KisImageWSP image = settings->m_image;
    if (m_perspectiveCorrection && image && image->perspectiveGrid()->countSubGrids() == 1) {
        Matrix3qreal startM = Matrix3qreal::Identity();
        Matrix3qreal endM = Matrix3qreal::Identity();

        // First look for the grid corresponding to the start point
        KisSubPerspectiveGrid* subGridStart = *image->perspectiveGrid()->begin();
        QRect r = QRect(0, 0, image->width(), image->height());

#if 1
        if (subGridStart) {
            startM = KisPerspectiveMath::computeMatrixTransfoFromPerspective(r, *subGridStart->topLeft(), *subGridStart->topRight(), *subGridStart->bottomLeft(), *subGridStart->bottomRight());
        }
#endif
#if 1
        // Second look for the grid corresponding to the end point
        KisSubPerspectiveGrid* subGridEnd = *image->perspectiveGrid()->begin();
        if (subGridEnd) {
            endM = KisPerspectiveMath::computeMatrixTransfoToPerspective(*subGridEnd->topLeft(), *subGridEnd->topRight(), *subGridEnd->bottomLeft(), *subGridEnd->bottomRight(), r);
        }
#endif

        // Compute the translation in the perspective transformation space:
        QPointF positionStartPaintingT = KisPerspectiveMath::matProd(endM, QPointF(m_duplicateStart));
        QPointF duplicateStartPositionT = KisPerspectiveMath::matProd(endM, QPointF(m_duplicateStart) - QPointF(settings->offset()));
        QPointF translat = duplicateStartPositionT - positionStartPaintingT;

        KisRectIteratorSP dstIt = m_srcdev->createRectIteratorNG(0, 0, sw, sh);
        KisRandomSubAccessorSP srcAcc = realSourceDevice->createRandomSubAccessor();
        //Action
        do {
            QPointF p =  KisPerspectiveMath::matProd(startM, KisPerspectiveMath::matProd(endM, QPointF(dstIt->x() + x, dstIt->y() + y)) + translat);
            srcAcc->moveTo(p);
            srcAcc->sampledOldRawData(dstIt->rawData());
        } while (dstIt->nextPixel());


    } else {
        KisPainter copyPainter(m_srcdev);
        copyPainter.setCompositeOp(COMPOSITE_COPY);
        copyPainter.bitBltOldData(0, 0, realSourceDevice, srcPoint.x(), srcPoint.y(), sw, sh);
        copyPainter.end();
    }

    // heal ?
//.........这里部分代码省略.........
开发者ID:nemomobile-packages,项目名称:calligra,代码行数:101,代码来源:kis_duplicateop.cpp


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