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


C++ KisBrushSP类代码示例

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


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

示例1: KisPaintOp

KisHairyPaintOp::KisHairyPaintOp(const KisBrushBasedPaintOpSettings *settings, KisPainter * painter, KisNodeSP node, KisImageSP image)
    : KisPaintOp(painter)
{
    Q_UNUSED(image)
    Q_ASSERT(settings);

    m_dev = node ? node->paintDevice() : 0;

    KisBrushOption brushOption;
    brushOption.readOptionSetting(settings);
    KisBrushSP brush = brushOption.brush();
    KisFixedPaintDeviceSP dab = cachedDab(painter->device()->compositionSourceColorSpace());
    if (brush->brushType() == IMAGE || brush->brushType() == PIPE_IMAGE) {
        dab = brush->paintDevice(source()->colorSpace(), 1.0, 0.0, KisPaintInformation());
    }
    else {
        brush->mask(dab, painter->paintColor(), 1.0, 1.0, 0.0, KisPaintInformation());
    }

    m_brush.fromDabWithDensity(dab, settings->getDouble(HAIRY_BRISTLE_DENSITY) * 0.01);
    m_brush.setInkColor(painter->paintColor());

    loadSettings(settings);
    m_brush.setProperties(&m_properties);

    m_rotationOption.readOptionSetting(settings);
    m_opacityOption.readOptionSetting(settings);
    m_sizeOption.readOptionSetting(settings);
    m_rotationOption.resetAllSensors();
    m_opacityOption.resetAllSensors();
    m_sizeOption.resetAllSensors();
}
开发者ID:TheTypoMaster,项目名称:calligra,代码行数:32,代码来源:kis_hairy_paintop.cpp

示例2: c

KisBrushSP KisAutoBrushFactory::getOrCreateBrush(const QDomElement& brushDefinition)
{
    KisMaskGenerator* mask = KisMaskGenerator::fromXML(brushDefinition.firstChildElement("MaskGenerator"));
    bool result;
    QLocale c(QLocale::German);

    double angle = brushDefinition.attribute("angle", "0.0").toDouble(&result);
    if (!result) {
        angle = c.toDouble(brushDefinition.attribute("angle"));
    }

    double randomness = brushDefinition.attribute("randomness", "0.0").toDouble(&result);
    if (!result) {
        randomness = c.toDouble(brushDefinition.attribute("randomness"));
    }

    qreal density = brushDefinition.attribute("density", "1.0").toDouble(&result);
    if (!result) {
        density = c.toDouble(brushDefinition.attribute("density"));
    }

    double spacing = brushDefinition.attribute("spacing", "1.0").toDouble(&result);
    if (!result) {
        spacing = c.toDouble(brushDefinition.attribute("spacing"));
    }

    KisBrushSP brush = new KisAutoBrush(mask, angle, randomness, density);
    brush->setSpacing(spacing);
    return brush;
}
开发者ID:,项目名称:,代码行数:30,代码来源:

示例3: brushOutlineImpl

QPainterPath KisBrushBasedPaintOpSettings::brushOutlineImpl(const KisPaintInformation &info,
                                                            OutlineMode mode,
                                                            qreal additionalScale,
                                                            bool forceOutline)
{
    QPainterPath path;

    if (forceOutline || mode == CursorIsOutline || mode == CursorIsCircleOutline || mode == CursorTiltOutline) {
        KisBrushSP brush = this->brush();
        if (!brush) return path;
        qreal finalScale = brush->scale() * additionalScale;

        QPainterPath realOutline = brush->outline();

        if (mode == CursorIsCircleOutline || mode == CursorTiltOutline ||
            (forceOutline && mode == CursorNoOutline)) {

            QPainterPath ellipse;
            ellipse.addEllipse(realOutline.boundingRect());
            realOutline = ellipse;
        }

        path = outlineFetcher()->fetchOutline(info, this, realOutline, finalScale, brush->angle());

        if (mode == CursorTiltOutline) {
            QPainterPath tiltLine = makeTiltIndicator(info,
                realOutline.boundingRect().center(),
                realOutline.boundingRect().width() * 0.5,
                3.0);
            path.addPath(outlineFetcher()->fetchOutline(info, this, tiltLine, finalScale, 0.0, true, realOutline.boundingRect().center().x(), realOutline.boundingRect().center().y()));
        }
    }

    return path;
}
开发者ID:KDE,项目名称:krita,代码行数:35,代码来源:kis_brush_based_paintop_settings.cpp

示例4: dabSizeHelper

static void dabSizeHelper(KisBrushSP const& brush,
    QString const& name, KisDabShape const& shape, int expectedWidth, int expectedHeight)
{
    qDebug() << name;
    QCOMPARE(brush->maskWidth(shape, 0.0, 0.0, KisPaintInformation()), expectedWidth);
    QCOMPARE(brush->maskHeight(shape, 0.0, 0.0, KisPaintInformation()), expectedHeight);
}
开发者ID:KDE,项目名称:krita,代码行数:7,代码来源:kis_auto_brush_test.cpp

示例5: getOrCreateBrush

KisBrushSP KisPredefinedBrushFactory::getOrCreateBrush(const QDomElement& brushDefinition)
{
    KoResourceServer<KisBrush> *rServer = KisBrushServer::instance()->brushServer();
    QString brushFileName = brushDefinition.attribute("filename", "");
    KisBrushSP brush = rServer->resourceByFilename(brushFileName);

    //Fallback for files that still use the old format
    if(!brush) {
        QFileInfo info(brushFileName);
        brush = rServer->resourceByFilename(info.fileName());
    }

    if(!brush) {
        brush = rServer->resources().first();
    }

    Q_ASSERT(brush);

    double spacing = brushDefinition.attribute("spacing", "0.25").toDouble();
    brush->setSpacing(spacing);

    double angle = brushDefinition.attribute("angle", "0.0").toDouble();
    brush->setAngle(angle);

    double scale = brushDefinition.attribute("scale", "1.0").toDouble();
    brush->setScale(scale);

    return brush;
}
开发者ID:crayonink,项目名称:calligra-2,代码行数:29,代码来源:kis_predefined_brush_factory.cpp

示例6: KisAutoBrush

KisBrushSP KisAutoBrushFactory::getOrCreateBrush( const QDomElement& brushDefinition )
{
    KisMaskGenerator* mask = KisMaskGenerator::fromXML(brushDefinition);
    KisBrushSP brush = new KisAutoBrush( mask );
    double spacing = brushDefinition.attribute("brush_spacing", "1.0").toDouble();
    brush->setSpacing( spacing );
    return brush;
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例7: fromXML

KisBrushSP KisBrush::fromXML(const QDomElement& element)
{
    KisBrushSP brush = KisBrushRegistry::instance()->getOrCreateBrush(element);
    if (brush && element.attribute("BrushVersion", "1") == "1") {
        brush->setScale(brush->scale() * 2.0);
    }
    return brush;
}
开发者ID:,项目名称:,代码行数:8,代码来源:

示例8: paintOutlineRect

QRectF KisDuplicateOpSettings::paintOutlineRect(const QPointF& pos, KisImageSP image) const
{
    KisBrushSP brush = m_optionsWidget->m_brushOption->brush();
    QPointF hotSpot = brush->hotSpot(1.0, 1.0);
    QRectF rect = image->pixelToDocument(QRect(0,0, brush->width(), brush->height()) );
    rect.translate( pos - hotSpot + QPoint(1,1) );
    rect |= duplicateOutlineRect(pos, image);
    return rect;
}
开发者ID:,项目名称:,代码行数:9,代码来源:

示例9: paintOutline

void KisDuplicateOpSettings::paintOutline(const QPointF& pos, KisImageSP image, QPainter &painter, const KoViewConverter &converter) const
{
    KisBrushSP brush = m_optionsWidget->m_brushOption->brush();
    QPointF hotSpot = brush->hotSpot(1.0, 1.0);
    painter.setPen(Qt::black);
    painter.setBackground(Qt::black);
    painter.drawEllipse( converter.documentToView( image->pixelToDocument(QRect(0,0, brush->width(), brush->height()) ).translated( pos - hotSpot + QPoint(1,1) ) ) );
    
    QRectF rect2 = converter.documentToView( duplicateOutlineRect( pos, image ) );
    painter.drawLine(rect2.topLeft(), rect2.bottomRight() );
    painter.drawLine(rect2.topRight(), rect2.bottomLeft() );

}
开发者ID:,项目名称:,代码行数:13,代码来源:

示例10: KisCircleMaskGenerator

void KisAutoBrushTest::testMaskGeneration()
{
    KisCircleMaskGenerator* circle = new KisCircleMaskGenerator(10, 1.0, 1.0, 1.0, 2, false);
    KisBrushSP a = new KisAutoBrush(circle, 0.0, 0.0);
    const KoColorSpace * cs = KoColorSpaceRegistry::instance()->rgb8();

    KisPaintInformation info(QPointF(100.0, 100.0), 0.5);

    // check masking an existing paint device
    KisFixedPaintDeviceSP fdev = new KisFixedPaintDevice(cs);
    fdev->setRect(QRect(0, 0, 100, 100));
    fdev->initialize();
    cs->setOpacity(fdev->data(), OPACITY_OPAQUE_U8, 100 * 100);

    QPoint errpoint;
    QImage result(QString(FILES_DATA_DIR) + QDir::separator() + "result_autobrush_1.png");
    QImage image = fdev->convertToQImage(0);

    if (!TestUtil::compareQImages(errpoint, image, result)) {
        image.save("kis_autobrush_test_1.png");
        QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
    }

    // Check creating a mask dab with a single color
    fdev = new KisFixedPaintDevice(cs);
    a->mask(fdev, KoColor(Qt::black, cs), KisDabShape(), info);

    result = QImage(QString(FILES_DATA_DIR) + QDir::separator() + "result_autobrush_3.png");
    image = fdev->convertToQImage(0);
    if (!TestUtil::compareQImages(errpoint, image, result)) {
        image.save("kis_autobrush_test_3.png");
        QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
    }

    // Check creating a mask dab with a color taken from a paint device
    KoColor red(Qt::red, cs);
    cs->setOpacity(red.data(), quint8(128), 1);
    KisPaintDeviceSP dev = new KisPaintDevice(cs);
    dev->fill(0, 0, 100, 100, red.data());

    fdev = new KisFixedPaintDevice(cs);
    a->mask(fdev, dev, KisDabShape(), info);

    result = QImage(QString(FILES_DATA_DIR) + QDir::separator() + "result_autobrush_4.png");
    image = fdev->convertToQImage(0);
    if (!TestUtil::compareQImages(errpoint, image, result)) {
        image.save("kis_autobrush_test_4.png");
        QFAIL(QString("Failed to create identical image, first different pixel: %1,%2 \n").arg(errpoint.x()).arg(errpoint.y()).toLatin1());
    }

}
开发者ID:KDE,项目名称:krita,代码行数:51,代码来源:kis_auto_brush_test.cpp

示例11: brushOutline

QPainterPath KisBrushBasedPaintOpSettings::brushOutline(const KisPaintInformation &info, OutlineMode mode) const
{
    if (mode != CursorIsOutline) return QPainterPath();

    KisBrushBasedPaintopOptionWidget *widget = dynamic_cast<KisBrushBasedPaintopOptionWidget*>(optionsWidget());

    if (!widget) {
        return KisPaintOpSettings::brushOutline(info, mode);
    }

    KisBrushSP brush = widget->brush();

    return outlineFetcher()->fetchOutline(info, this, brush->outline(), brush->scale(), brush->angle());
}
开发者ID:,项目名称:,代码行数:14,代码来源:

示例12: getOrCreateBrush

KisBrushSP KisAbrBrushFactory::getOrCreateBrush(const QDomElement& brushDefinition)
{
    KoResourceServer<KisBrush>* rServer = KisBrushServer::instance()->brushServer();
    QString brushName = brushDefinition.attribute("name", "test_1");
    
    KisBrushSP brush = rServer->getResourceByName(brushName);
    if (!brush){
        return 0;
    }
    
    double spacing = brushDefinition.attribute("spacing", "0.25").toDouble();
    brush->setSpacing(spacing);

    return brush;

}
开发者ID:abhishekmurthy,项目名称:Calligra,代码行数:16,代码来源:kis_abr_brush_factory.cpp

示例13: setCurrentBrush

void KisBrushSelectionWidget::setCurrentBrush( KisBrushSP brush)
{
    // XXX: clever code have brush plugins know their configuration
    //      pane, so we don't have to have this if statement and
    //      have an extensible set of brush types
    if ( dynamic_cast<KisAutoBrush*>(brush.data()) ) {
        m_brushesTab->setCurrentWidget( m_autoBrushWidget );
        m_autoBrushWidget->setBrush(brush);
    }
    else if (dynamic_cast<KisTextBrush*>(brush.data())) {
        m_brushesTab->setCurrentWidget( m_textBrushWidget );
        m_textBrushWidget->setBrush(brush);
    }
    else {
        m_brushesTab->setCurrentWidget( m_brushChooser );
        m_brushChooser->setBrush(brush);
    }

}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例14: setBrush

void KisAutoBrushWidget::setBrush(KisBrushSP brush)
{
    m_autoBrush = brush;
    m_brush = brush->image();
    // XXX: lock, set and unlock the widgets.
    KisAutoBrush* aBrush = dynamic_cast<KisAutoBrush*>(brush.data());
    if (aBrush->maskGenerator()->type() == KisMaskGenerator::CIRCLE) {
        comboBoxShape->setCurrentIndex(0);
    }
    else if (aBrush->maskGenerator()->type() == KisMaskGenerator::RECTANGLE) {
        comboBoxShape->setCurrentIndex(1);
    }
    else {
        comboBoxShape->setCurrentIndex(2);
    }

    comboBoxMaskType->setCurrentIndex(comboBoxMaskType->findText(aBrush->maskGenerator()->name()));


    inputRadius->setValue(aBrush->maskGenerator()->diameter());
    inputRatio->setValue(aBrush->maskGenerator()->ratio());

    inputVFade->blockSignals(true);
    inputHFade->blockSignals(true);
    inputHFade->setValue(aBrush->maskGenerator()->horizontalFade());
    inputVFade->setValue(aBrush->maskGenerator()->verticalFade());
    inputVFade->blockSignals(false);
    inputHFade->blockSignals(false);

    inputAngle->setValue(aBrush->angle() * 180 / M_PI);
    inputSpikes->setValue(aBrush->maskGenerator()->spikes());
    inputSpacing->setValue(aBrush->spacing());
    inputSpacing->setExponentRatio(3.0);
    inputRandomness->setValue(aBrush->randomness() * 100);
    density->setValue(aBrush->density() * 100);

    if (!aBrush->maskGenerator()->curveString().isEmpty()) {
        KisCubicCurve curve;
        curve.fromString(aBrush->maskGenerator()->curveString());
        softnessCurve->setCurve(curve);
    }
}
开发者ID:,项目名称:,代码行数:42,代码来源:

示例15: paintAt

void KisBrushOp::paintAt(const KisPaintInformation& info)
{
    if (!painter()->device()) return;

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

    KisPaintInformation adjustedInfo = settings->m_optionsWidget->m_sizeOption->apply(info);
    if (!brush->canPaintFor(adjustedInfo))
        return;

    KisPaintDeviceSP device = painter()->device();

    double pScale = KisPaintOp::scaleForPressure(adjustedInfo.pressure());   // TODO: why is there scale and pScale that seems to contains the same things ?
    QPointF hotSpot = brush->hotSpot(pScale, pScale);
    QPointF pt = info.pos() - hotSpot;

    // 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;
    double xFraction;
    qint32 y;
    double yFraction;

    splitCoordinate(pt.x(), &x, &xFraction);
    splitCoordinate(pt.y(), &y, &yFraction);

    quint8 origOpacity = settings->m_optionsWidget->m_opacityOption->apply(painter(), info.pressure());
    KoColor origColor = settings->m_optionsWidget->m_darkenOption->apply(painter(), info.pressure());

    double scale = KisPaintOp::scaleForPressure(adjustedInfo.pressure());

    KisFixedPaintDeviceSP dab = cachedDab(device->colorSpace());
    if (brush->brushType() == IMAGE || brush->brushType() == PIPE_IMAGE) {
        dab = brush->image(device->colorSpace(), scale, 0.0, adjustedInfo, xFraction, yFraction);
    } else {
        KoColor color = painter()->paintColor();
        color.convertTo(dab->colorSpace());
        brush->mask(dab, color, scale, scale, 0.0, info, xFraction, yFraction);
    }

    painter()->bltFixed(QPoint(x, y), dab, dab->bounds());
    painter()->setOpacity(origOpacity);
    painter()->setPaintColor(origColor);

}
开发者ID:,项目名称:,代码行数:48,代码来源:


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