本文整理汇总了C++中KisLayerSP类的典型用法代码示例。如果您正苦于以下问题:C++ KisLayerSP类的具体用法?C++ KisLayerSP怎么用?C++ KisLayerSP使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KisLayerSP类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KisImage
void KisImageTest::testLayerComposition()
{
KisImageSP image = new KisImage(0, IMAGE_WIDTH, IMAGE_WIDTH, 0, "layer tests");
QVERIFY(image->rootLayer() != 0);
QVERIFY(image->rootLayer()->firstChild() == 0);
KisLayerSP layer = new KisPaintLayer(image, "layer 1", OPACITY_OPAQUE_U8);
image->addNode(layer);
KisLayerSP layer2 = new KisPaintLayer(image, "layer 2", OPACITY_OPAQUE_U8);
image->addNode(layer2);
QVERIFY(layer->visible());
QVERIFY(layer2->visible());
KisLayerComposition comp(image, "comp 1");
comp.store();
layer2->setVisible(false);
QVERIFY(layer->visible());
QVERIFY(!layer2->visible());
KisLayerComposition comp2(image, "comp 2");
comp2.store();
comp.apply();
QVERIFY(layer->visible());
QVERIFY(layer2->visible());
comp2.apply();
QVERIFY(layer->visible());
QVERIFY(!layer2->visible());
}
示例2: img
void KisImageTest::testMergeDownDestinationSameCompositeOp()
{
FlattenTestImage p;
TestUtil::ExternalImageChecker img("flatten", "imagetest");
TestUtil::ExternalImageChecker chk("mergedown_sameop_fastpath", "imagetest");
{
QCOMPARE(p.layer8->compositeOpId(), COMPOSITE_ADD);
QCOMPARE(p.layer8->alphaChannelDisabled(), false);
QCOMPARE(p.layer7->compositeOpId(), COMPOSITE_ADD);
QCOMPARE(p.layer7->alphaChannelDisabled(), false);
KisLayerSP newLayer = p.image->mergeDown(p.layer8, KisMetaData::MergeStrategyRegistry::instance()->get("Drop"));
p.image->waitForDone();
QVERIFY(img.checkDevice(p.image->projection(), p.image, "00_initial"));
QVERIFY(chk.checkDevice(newLayer->projection(), p.image, "01_layer8_layerproj"));
QCOMPARE(newLayer->compositeOpId(), COMPOSITE_ADD);
QCOMPARE(newLayer->exactBounds(), QRect(50, 350, 50, 100));
QCOMPARE(newLayer->alphaChannelDisabled(), false);
}
}
示例3: testMergeCrossColorSpaceImpl
void testMergeCrossColorSpaceImpl(bool useProjectionColorSpace, bool swapSpaces)
{
QRect refRect;
TestUtil::MaskParent p;
KisPaintLayerSP layer1;
KisPaintLayerSP layer2;
KisPaintLayerSP layer3;
const KoColorSpace *cs2 = useProjectionColorSpace ?
p.image->colorSpace() : KoColorSpaceRegistry::instance()->lab16();
const KoColorSpace *cs3 = KoColorSpaceRegistry::instance()->rgb16();
if (swapSpaces) {
qSwap(cs2, cs3);
}
dbgKrita << "Testing testMergeCrossColorSpaceImpl:";
dbgKrita << " " << ppVar(cs2);
dbgKrita << " " << ppVar(cs3);
layer1 = p.layer;
layer2 = new KisPaintLayer(p.image, "paint2", OPACITY_OPAQUE_U8, cs2);
layer3 = new KisPaintLayer(p.image, "paint3", OPACITY_OPAQUE_U8, cs3);
QRect rect1(100, 100, 100, 100);
QRect rect2(150, 150, 150, 150);
QRect rect3(250, 250, 200, 200);
layer1->paintDevice()->fill(rect1, KoColor(Qt::red, layer1->colorSpace()));
layer2->paintDevice()->fill(rect2, KoColor(Qt::green, layer2->colorSpace()));
layer3->paintDevice()->fill(rect3, KoColor(Qt::blue, layer3->colorSpace()));
p.image->addNode(layer2);
p.image->addNode(layer3);
p.image->initialRefreshGraph();
{
KisLayerSP newLayer = p.image->mergeDown(layer3, KisMetaData::MergeStrategyRegistry::instance()->get("Drop"));
p.image->waitForDone();
QCOMPARE(newLayer->colorSpace(), p.image->colorSpace());
p.undoStore->undo();
}
{
layer2->disableAlphaChannel(true);
KisLayerSP newLayer = p.image->mergeDown(layer3, KisMetaData::MergeStrategyRegistry::instance()->get("Drop"));
p.image->waitForDone();
QCOMPARE(newLayer->colorSpace(), p.image->colorSpace());
p.undoStore->undo();
}
}
示例4: KisImage
void KisAsyncMergerTest::debugObligeChild()
{
const KoColorSpace * colorSpace = KoColorSpaceRegistry::instance()->rgb8();
KisImageSP image = new KisImage(0, 640, 441, colorSpace, "merger test");
QImage sourceImage1(QString(FILES_DATA_DIR) + QDir::separator() + "hakonepa.png");
KisPaintDeviceSP device1 = new KisPaintDevice(colorSpace);
device1->convertFromQImage(sourceImage1, 0, 0, 0);
KisLayerSP paintLayer1 = new KisPaintLayer(image, "paint1", OPACITY_OPAQUE_U8, device1);
KisLayerSP groupLayer = new KisGroupLayer(image, "group", OPACITY_OPAQUE_U8);
image->addNode(groupLayer, image->rootLayer());
image->addNode(paintLayer1, groupLayer);
QRect testRect1(0,0,640,441);
QRect cropRect(image->bounds());
KisMergeWalker walker(cropRect);
KisAsyncMerger merger;
walker.collectRects(paintLayer1, testRect1);
merger.startMerge(walker);
KisLayerSP rootLayer = image->rootLayer();
QVERIFY(rootLayer->original() == groupLayer->projection());
QVERIFY(groupLayer->original() == paintLayer1->projection());
}
示例5: addNewLayer
bool addNewLayer(int row) {
Q_UNUSED(row);
if (nodeInterface) {
KisLayerSP layer = nodeInterface->addPaintLayer();
layer->setUseInTimeline(true);
}
return true;
}
示例6: convertPaintDevice
bool KisColorSpaceConvertVisitor::visit(KisGroupLayer * layer)
{
convertPaintDevice(layer);
KisLayerSP child = dynamic_cast<KisLayer*>(layer->firstChild().data());
while (child) {
child->accept(*this);
child = dynamic_cast<KisLayer*>(child->nextSibling().data());
}
layer->resetCache();
return true;
}
示例7: mergeToLayerImpl
void KisIndirectPaintingSupport::mergeToLayerImpl(KisLayerSP layer,
UndoAdapter *undoAdapter,
const KUndo2MagicString &transactionText)
{
/**
* We do not apply selection here, because it has already
* been taken into account in a tool code
*/
KisPainter gc(layer->paintDevice());
setupTemporaryPainter(&gc);
d->lock.lockForWrite();
/**
* Scratchpad may not have an undo adapter
*/
if(undoAdapter) {
gc.beginTransaction(transactionText);
}
foreach (const QRect &rc, d->temporaryTarget->region().rects()) {
gc.bitBlt(rc.topLeft(), d->temporaryTarget, rc);
}
releaseResources();
if(undoAdapter) {
gc.endTransaction(undoAdapter);
}
d->lock.unlock();
}
示例8: findNode
KisNodeSP findNode(KisNodeSP node, const QPoint &point, bool wholeGroup, bool editableOnly)
{
KisNodeSP foundNode = 0;
while (node) {
KisLayerSP layer = dynamic_cast<KisLayer*>(node.data());
if (!layer || !layer->isEditable()) {
node = node->prevSibling();
continue;
}
KoColor color(layer->projection()->colorSpace());
layer->projection()->pixel(point.x(), point.y(), &color);
KisGroupLayerSP group = dynamic_cast<KisGroupLayer*>(layer.data());
if ((group && group->passThroughMode()) || color.opacityU8() != OPACITY_TRANSPARENT_U8) {
if (layer->inherits("KisGroupLayer") && (!editableOnly || layer->isEditable())) {
// if this is a group and the pixel is transparent, don't even enter it
foundNode = findNode(node->lastChild(), point, wholeGroup, editableOnly);
}
else {
foundNode = !wholeGroup ? node : node->parent();
}
}
if (foundNode) break;
node = node->prevSibling();
}
return foundNode;
}
示例9: play
void KisRecordedFilterAction::play(KisNodeSP node, const KisPlayInfo& _info, KoUpdater* _updater) const
{
KisFilterConfiguration * kfc = d->configuration();
KisPaintDeviceSP dev = node->paintDevice();
KisLayerSP layer = dynamic_cast<KisLayer*>(node.data());
QRect r1 = dev->extent();
KisTransaction transaction(kundo2_i18n("Filter: \"%1\"", d->filter->name()), dev);
KisImageWSP image = _info.image();
r1 = r1.intersected(image->bounds());
if (layer && layer->selection()) {
r1 = r1.intersected(layer->selection()->selectedExactRect());
}
d->filter->process(dev, dev, layer->selection(), r1, kfc, _updater);
node->setDirty(r1);
transaction.commit(_info.undoAdapter());
}
示例10: activeSelection
KisSelectionSP KisResourcesSnapshot::activeSelection() const
{
/**
* It is possible to have/use the snapshot without the image. Such
* usecase is present for example in the scratchpad.
*/
KisSelectionSP selection = m_d->image ? m_d->image->globalSelection() : 0;
KisLayerSP layer = dynamic_cast<KisLayer*>(m_d->currentNode.data());
KisSelectionMaskSP mask;
if((layer = dynamic_cast<KisLayer*>(m_d->currentNode.data()))) {
selection = layer->selection();
} else if ((mask = dynamic_cast<KisSelectionMask*>(m_d->currentNode.data())) &&
mask->selection() == selection) {
selection = 0;
}
return selection;
}
示例11: mergeToLayer
void KisIndirectPaintingSupport::mergeToLayer(KisLayerSP layer, const QRegion ®ion, const QString &transactionText)
{
/**
* We do not apply selection here, because it has already
* been taken into account in a tool code
*/
KisPainter gc(layer->paintDevice());
gc.setCompositeOp(d->compositeOp);
gc.setOpacity(d->compositeOpacity);
gc.setChannelFlags(layer->channelFlags());
if (KisPaintLayer* paintLayer = dynamic_cast<KisPaintLayer*>(layer.data())) {
if (paintLayer->alphaLocked()) {
gc.setLockAlpha(paintLayer->alphaLocked());
}
}
d->lock.lockForWrite();
if(layer->image()) {
gc.beginTransaction(transactionText);
}
foreach(const QRect& rc, region.rects()) {
gc.bitBlt(rc.topLeft(), d->temporaryTarget, rc);
}
d->temporaryTarget = 0;
// in the scratchpad the layer has no image and there is no undo adapter
if(layer->image()) {
gc.endTransaction(layer->image()->undoAdapter());
}
d->lock.unlock();
}
示例12: run
void KisRecalculateTransformMaskJob::run()
{
/**
* The mask might have been deleted from the layers stack. In
* such a case, don't try do update it.
*/
if (!m_mask->parent()) return;
m_mask->recaclulateStaticImage();
KisLayerSP layer = dynamic_cast<KisLayer*>(m_mask->parent().data());
if (!layer) {
warnKrita << "WARNING: KisRecalculateTransformMaskJob::run() Mask has no parent layer! Skipping projection update!";
return;
}
KisImageSP image = layer->image();
Q_ASSERT(image);
image->requestProjectionUpdateNoFilthy(layer, layer->extent(), image->bounds());
}
示例13:
KoShapeManager* KisCanvas2::shapeManager() const
{
if (!m_d->view) return m_d->shapeManager;
if (!m_d->view->layerManager()) return m_d->shapeManager;
KisLayerSP activeLayer = m_d->view->layerManager()->activeLayer();
if (activeLayer) {
KisShapeLayer * shapeLayer = dynamic_cast<KisShapeLayer*>(activeLayer.data());
if (shapeLayer) {
dbgUI << "Current shape manager belongs to a shape layer " << shapeLayer->shapeManager();
return shapeLayer->shapeManager();
}
if (activeLayer->selection() && activeLayer->selection()->hasShapeSelection()) {
KoShapeManager* m = static_cast<KisShapeSelection*>(activeLayer->selection()->shapeSelection())->shapeManager();
dbgUI << "Current shape manager belongs to a shape selection " << m;
return m;
}
}
dbgUI << "current shape manager belongs to the main canvas " << m_d->shapeManager;
return m_d->shapeManager;
}
示例14: TestLayer
void KisLayerTest::testHasEffectMasks()
{
KisLayerSP layer = new TestLayer(0, "layer1", OPACITY_OPAQUE) ;
QVERIFY(layer->hasEffectMasks() == false);
KisFilterMaskSP mask = new KisFilterMask();
layer->setPreviewMask(mask);
QVERIFY(layer->hasEffectMasks());
layer->removePreviewMask();
QVERIFY(layer->hasEffectMasks() == false);
}
示例15: KisPaintOpPreset
/**
* This benchmark runs a series of huge strokes on a canvas with a
* particular configuration of the swapper/pooler and history
* management. After the test is done you can visualize the results
* with the GNU Octave. Please use kis_low_memory_show_report.m file
* for that.
*/
void KisLowMemoryBenchmark::benchmarkWideArea(const QString presetFileName,
const QRectF &rect, qreal vstep,
int numCycles,
bool createTransaction,
int hardLimitMiB,
int softLimitMiB,
int poolLimitMiB,
int index)
{
KisPaintOpPresetSP preset = new KisPaintOpPreset(QString(FILES_DATA_DIR) + QDir::separator() + presetFileName);
LOAD_PRESET_OR_RETURN(preset, presetFileName);
/**
* Initialize image and painter
*/
const KoColorSpace *colorSpace = KoColorSpaceRegistry::instance()->rgb8();
KisImageSP image = new KisImage(0, HUGE_IMAGE_SIZE, HUGE_IMAGE_SIZE, colorSpace, "stroke sample image", true);
KisLayerSP layer = new KisPaintLayer(image, "temporary for stroke sample", OPACITY_OPAQUE_U8, colorSpace);
KisLayerSP layerExtra = new KisPaintLayer(image, "temporary for threading", OPACITY_OPAQUE_U8, colorSpace);
image->addNode(layer, image->root());
image->addNode(layerExtra, image->root());
KisPainter *painter = new KisPainter(layer->paintDevice());
painter->setPaintColor(KoColor(Qt::black, colorSpace));
painter->setPaintOpPreset(preset, layer, image);
/**
* A simple adapter that will store all the transactions for us
*/
KisSurrogateUndoAdapter undoAdapter;
/**
* Reset configuration to the desired settings
*/
KisImageConfig config;
qreal oldHardLimit = config.memoryHardLimitPercent();
qreal oldSoftLimit = config.memorySoftLimitPercent();
qreal oldPoolLimit = config.memoryPoolLimitPercent();
const qreal _MiB = 100.0 / KisImageConfig::totalRAM();
config.setMemoryHardLimitPercent(hardLimitMiB * _MiB);
config.setMemorySoftLimitPercent(softLimitMiB * _MiB);
config.setMemoryPoolLimitPercent(poolLimitMiB * _MiB);
KisTileDataStore::instance()->testingRereadConfig();
/**
* Create an empty the log file
*/
QString fileName;
fileName = QString("log_%1_%2_%3_%4_%5.txt")
.arg(createTransaction)
.arg(hardLimitMiB)
.arg(softLimitMiB)
.arg(poolLimitMiB)
.arg(index);
QFile logFile(fileName);
logFile.open(QFile::WriteOnly | QFile::Truncate);
QTextStream logStream(&logFile);
logStream.setFieldWidth(10);
logStream.setFieldAlignment(QTextStream::AlignRight);
/**
* Start painting on the image
*/
QTime cycleTime;
QTime lineTime;
cycleTime.start();
lineTime.start();
qreal rectBottom = rect.y() + rect.height();
for (int i = 0; i < numCycles; i++) {
cycleTime.restart();
QLineF line(rect.topLeft(), rect.topLeft() + QPointF(rect.width(), 0));
if (createTransaction) {
painter->beginTransaction();
}
KisDistanceInformation currentDistance;
while(line.y1() < rectBottom) {
lineTime.restart();
KisPaintInformation pi1(line.p1(), 0.0);
KisPaintInformation pi2(line.p2(), 1.0);
painter->paintLine(pi1, pi2, ¤tDistance);
//.........这里部分代码省略.........