本文整理汇总了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();
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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() );
}
示例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());
}
}
示例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());
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}