本文整理汇总了C++中KisImageWSP::root方法的典型用法代码示例。如果您正苦于以下问题:C++ KisImageWSP::root方法的具体用法?C++ KisImageWSP::root怎么用?C++ KisImageWSP::root使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KisImageWSP
的用法示例。
在下文中一共展示了KisImageWSP::root方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setImage
void KisDummiesFacadeBase::setImage(KisImageWSP image)
{
if (m_d->image) {
emit sigActivateNode(0);
m_d->image->disconnect(this);
KisNodeDummy *rootDummy = this->rootDummy();
if(rootDummy) {
slotRemoveNode(rootDummy->node());
}
}
m_d->image = image;
if (image) {
slotNodeAdded(image->root());
connect(image, SIGNAL(sigNodeAddedAsync(KisNodeSP)),
SLOT(slotNodeAdded(KisNodeSP)), Qt::DirectConnection);
connect(image, SIGNAL(sigRemoveNodeAsync(KisNodeSP)),
SLOT(slotRemoveNode(KisNodeSP)), Qt::DirectConnection);
connect(image, SIGNAL(sigLayersChangedAsync()),
SLOT(slotLayersChanged()), Qt::DirectConnection);
connect(image, SIGNAL(sigNodeChanged(KisNodeSP)),
SLOT(slotNodeChanged(KisNodeSP)));
connect(image, SIGNAL(sigNodeAddedAsync(KisNodeSP)),
SLOT(slotNodeActivationRequested(KisNodeSP)), Qt::AutoConnection);
emit sigActivateNode(findFirstLayer(image->root()));
}
}
示例2: testObligeSingleChildImpl
void testObligeSingleChildImpl(bool transpDefaultPixel)
{
QString id = !transpDefaultPixel ?
"single_layer_no_channel_flags_nontransp_def_pixel.kra" :
"single_layer_no_channel_flags_transp_def_pixel.kra";
QString fileName = TestUtil::fetchDataFileLazy(id);
KisDocument *doc = KisPart::instance()->createDocument();
doc->loadNativeFormat(fileName);
KisImageWSP image = doc->image();
QVERIFY(image);
QCOMPARE(image->nlayers(), 2);
KisNodeSP root = image->root();
KisNodeSP child = root->firstChild();
QVERIFY(child);
QCOMPARE(root->original(), root->projection());
if (transpDefaultPixel) {
QCOMPARE(root->original(), child->projection());
} else {
QVERIFY(root->original() != child->projection());
}
delete doc;
}
示例3: testLoading
void KisKraLoaderTest::testLoading()
{
KisDocument *doc = KisPart::instance()->createDocument();
doc->loadNativeFormat(QString(FILES_DATA_DIR) + QDir::separator() + "load_test.kra");
KisImageWSP image = doc->image();
image->lock();
QCOMPARE(image->nlayers(), 12);
QCOMPARE(doc->documentInfo()->aboutInfo("title"), QString("test image for loading"));
QCOMPARE(image->height(), 753);
QCOMPARE(image->width(), 1000);
QCOMPARE(image->colorSpace()->id(), KoColorSpaceRegistry::instance()->rgb8()->id());
KisNodeSP node = image->root()->firstChild();
QVERIFY(node);
QCOMPARE(node->name(), QString("Background"));
QVERIFY(node->inherits("KisPaintLayer"));
node = node->nextSibling();
QVERIFY(node);
QCOMPARE(node->name(), QString("Group 1"));
QVERIFY(node->inherits("KisGroupLayer"));
QCOMPARE((int) node->childCount(), 2);
delete doc;
}
示例4: createImageFromClipboardDelayed
void ImageBuilder::createImageFromClipboardDelayed()
{
DocumentManager::instance()->disconnect(this, SLOT(createImageFromClipboardDelayed()));
KisConfig cfg;
cfg.setPasteBehaviour(PASTE_ASSUME_MONITOR);
QSize sz = KisClipboard::instance()->clipSize();
KisPaintDeviceSP clipDevice = KisClipboard::instance()->clip(QRect(0, 0, sz.width(), sz.height()), false);
KisImageWSP image = DocumentManager::instance()->document()->image();
if (image && image->root() && image->root()->firstChild()) {
KisLayer * layer = dynamic_cast<KisLayer*>(image->root()->firstChild().data());
Q_ASSERT(layer);
layer->setOpacity(OPACITY_OPAQUE_U8);
QRect r = clipDevice->exactBounds();
KisPainter::copyAreaOptimized(QPoint(), clipDevice, layer->paintDevice(), r);
layer->setDirty(QRect(0, 0, sz.width(), sz.height()));
}
}
示例5: run
void KisCopyMergedActionFactory::run(KisView2 *view)
{
KisImageWSP image = view->image();
image->barrierLock();
KisPaintDeviceSP dev = image->root()->projection();
ActionHelper::copyFromDevice(view, dev);
image->unlock();
KisProcessingApplicator *ap = beginAction(view, i18n("Copy Merged"));
endAction(ap, KisOperationConfiguration(id()).toXML());
}
示例6: run
void KisPasteActionFactory::run(KisViewManager *view)
{
KisImageWSP image = view->image();
if (!image) return;
KisPaintDeviceSP clip = KisClipboard::instance()->clip(image->bounds(), true);
if (clip) {
KisPaintLayer *newLayer = new KisPaintLayer(image.data(), image->nextLayerName() + i18n("(pasted)"), OPACITY_OPAQUE_U8, clip);
KisNodeSP aboveNode = view->activeLayer();
KisNodeSP parentNode = aboveNode ? aboveNode->parent() : image->root();
KUndo2Command *cmd = new KisImageLayerAddCommand(image, newLayer, parentNode, aboveNode);
KisProcessingApplicator *ap = beginAction(view, cmd->text());
ap->applyCommand(cmd, KisStrokeJobData::SEQUENTIAL, KisStrokeJobData::NORMAL);
endAction(ap, KisOperationConfiguration(id()).toXML());
} else {
// XXX: "Add saving of XML data for Paste of shapes"
view->canvasBase()->toolProxy()->paste();
}
}
示例7: slotOffsetImage
void OffsetImage::slotOffsetImage()
{
KisImageWSP image = m_view->image();
if (image) {
DlgOffsetImage * dlgOffsetImage = new DlgOffsetImage(m_view, "OffsetImage", offsetWrapRect().size());
Q_CHECK_PTR(dlgOffsetImage);
QString actionName = i18n("Offset Image");
dlgOffsetImage->setCaption(actionName);
if (dlgOffsetImage->exec() == QDialog::Accepted) {
QPoint offsetPoint = QPoint(dlgOffsetImage->offsetX(), dlgOffsetImage->offsetY());
offsetImpl(actionName, image->root(), offsetPoint);
}
delete dlgOffsetImage;
}
else
{
kWarning() << "KisImage not available";
}
}
示例8: loadBinaryData
void KisKraLoader::loadBinaryData(KoStore * store, KisImageWSP image, const QString & uri, bool external)
{
// icc profile: if present, this overrides the profile product name loaded in loadXML.
QString location = external ? QString() : uri;
location += m_d->imageName + ICC_PATH;
if (store->hasFile(location)) {
if (store->open(location)) {
QByteArray data; data.resize(store->size());
bool res = (store->read(data.data(), store->size()) > -1);
store->close();
if (res) {
const KoColorProfile *profile = KoColorSpaceRegistry::instance()->createColorProfile(image->colorSpace()->colorModelId().id(), image->colorSpace()->colorDepthId().id(), data);
if (profile && profile->valid()) {
res = image->assignImageProfile(profile);
}
if (!res) {
profile = KoColorSpaceRegistry::instance()->profileByName(KoColorSpaceRegistry::instance()->colorSpaceFactory(image->colorSpace()->id())->defaultProfile());
Q_ASSERT(profile && profile->valid());
image->assignImageProfile(profile);
}
}
}
}
// Load the layers data: if there is a profile associated with a layer it will be set now.
KisKraLoadVisitor visitor(image, store, m_d->layerFilenames, m_d->imageName, m_d->syntaxVersion);
if (external) {
visitor.setExternalUri(uri);
}
image->rootLayer()->accept(visitor);
if (!visitor.errorMessages().isEmpty()) {
m_d->errorMessages.append(visitor.errorMessages());
}
// annotations
// exif
location = external ? QString() : uri;
location += m_d->imageName + EXIF_PATH;
if (store->hasFile(location)) {
QByteArray data;
store->open(location);
data = store->read(store->size());
store->close();
image->addAnnotation(KisAnnotationSP(new KisAnnotation("exif", "", data)));
}
// layer styles
location = external ? QString() : uri;
location += m_d->imageName + LAYER_STYLES_PATH;
if (store->hasFile(location)) {
KisPSDLayerStyleCollectionResource *collection =
new KisPSDLayerStyleCollectionResource("Embedded Styles.asl");
collection->setName(i18nc("Auto-generated layer style collection name for embedded styles (collection)", "<%1> (embedded)", m_d->imageName));
KIS_ASSERT_RECOVER_NOOP(!collection->valid());
store->open(location);
{
KoStoreDevice device(store);
device.open(QIODevice::ReadOnly);
/**
* ASL loading code cannot work with non-sequential IO devices,
* so convert the device beforehand!
*/
QByteArray buf = device.readAll();
QBuffer raDevice(&buf);
raDevice.open(QIODevice::ReadOnly);
collection->loadFromDevice(&raDevice);
}
store->close();
if (collection->valid()) {
KoResourceServer<KisPSDLayerStyleCollectionResource> *server = KisResourceServerProvider::instance()->layerStyleCollectionServer();
server->addResource(collection, false);
collection->assignAllLayerStyles(image->root());
} else {
warnKrita << "WARNING: Couldn't load layer styles library from .kra!";
delete collection;
}
}
if (m_d->document && m_d->document->documentInfo()->aboutInfo("title").isNull())
m_d->document->documentInfo()->setAboutInfo("title", m_d->imageName);
if (m_d->document && m_d->document->documentInfo()->aboutInfo("comment").isNull())
m_d->document->documentInfo()->setAboutInfo("comment", m_d->imageComment);
loadAssistants(store, uri, external);
}