Commit 07405a98 authored by Boudewijn Rempt's avatar Boudewijn Rempt

The test shows that we can save a shape in a shape layer correctly

svn path=/trunk/koffice/; revision=894720
parent 37b854f9
......@@ -147,7 +147,7 @@ KisImageSP KisKraLoader::loadXML(const KoXmlElement& element)
}
if (cs == 0) {
kWarning(41008) << "Could not open colorspace";
warnFile << "Could not open colorspace";
return KisImageSP(0);
}
......@@ -222,7 +222,7 @@ KisNode* KisKraLoader::loadNodes(const KoXmlElement& element, KisImageSP img, Ki
KisNode* node = loadNode( child.toElement(), img );
if ( !node ) {
kWarning(41008) << "Could not load node";
warnFile << "Could not load node";
} else {
img->nextLayerName(); // Make sure the nameserver is current with the number of nodes.
img->addNode(node, parent);
......@@ -248,6 +248,8 @@ KisNode* KisKraLoader::loadNode(const KoXmlElement& element, KisImageSP img)
QString name = element.attribute(NAME, "No Name");
qDebug() << "Load node >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" << name;
qint32 x = element.attribute(X, "0").toInt();
qint32 y = element.attribute(Y, "0").toInt();
......@@ -273,36 +275,28 @@ KisNode* KisKraLoader::loadNode(const KoXmlElement& element, KisImageSP img)
if (attr.isNull())
node = loadPaintLayer(element, img, name, colorSpace, opacity);
else if (attr == PAINT_LAYER)
node = loadPaintLayer(element, img, name, colorSpace, opacity);
else if (attr == GROUP_LAYER)
node = loadGroupLayer(element, img, name, colorSpace, opacity);
else if (attr == ADJUSTMENT_LAYER )
node = loadAdjustmentLayer(element, img, name, colorSpace, opacity);
else if (attr == SHAPE_LAYER )
node = loadShapeLayer(element, img, name, colorSpace, opacity);
else if ( attr == GENERATOR_LAYER )
node = loadGeneratorLayer( element, img, name, colorSpace, opacity);
else if ( attr == CLONE_LAYER )
node = loadCloneLayer( element, img, name, colorSpace, opacity);
else if ( attr == FILTER_MASK )
node = loadFilterMask( element );
else if ( attr == TRANSPARENCY_MASK )
node = loadTransparencyMask( element );
else if ( attr == TRANSFORMATION_MASK )
node = loadTransformationMask( element );
else if ( attr == SELECTION_MASK )
node = loadSelectionMask( img, element );
else
warnKrita << "Trying to load layer of unsupported type " << attr;
Q_ASSERT( node );
node->setVisible( visible );
......@@ -381,13 +375,13 @@ KisNode* KisKraLoader::loadAdjustmentLayer(const KoXmlElement& element, KisImage
if ((filtername = element.attribute( FILTER_NAME )).isNull()) {
// XXX: Invalid adjustmentlayer! We should warn about it!
kWarning(41008) << "No filter in adjustment layer";
warnFile << "No filter in adjustment layer";
return 0;
}
KisFilterSP f = KisFilterRegistry::instance()->value(filtername);
if (!f) {
kWarning(41008) << "No filter for filtername" << filtername << "";
warnFile << "No filter for filtername" << filtername << "";
return 0; // XXX: We don't have this filter. We should warn about it!
}
......@@ -426,13 +420,13 @@ KisNode* KisKraLoader::loadGeneratorLayer(const KoXmlElement& element, KisImageS
if (generatorname.isNull()) {
// XXX: Invalid generator layer! We should warn about it!
kWarning(41008) << "No generator in generator layer";
warnFile << "No generator in generator layer";
return 0;
}
KisGeneratorSP generator = KisGeneratorRegistry::instance()->value(generatorname);
if (!generator) {
kWarning(41008) << "No generator for generatorname" << generatorname << "";
warnFile << "No generator for generatorname" << generatorname << "";
return 0; // XXX: We don't have this generator. We should warn about it!
}
......@@ -481,13 +475,13 @@ KisNode* KisKraLoader::loadFilterMask(const KoXmlElement& element )
if ((filtername = element.attribute( FILTER_NAME )).isNull()) {
// XXX: Invalid filter layer! We should warn about it!
kWarning(41008) << "No filter in filter layer";
warnFile << "No filter in filter layer";
return 0;
}
KisFilterSP f = KisFilterRegistry::instance()->value(filtername);
if (!f) {
kWarning(41008) << "No filter for filtername" << filtername << "";
warnFile << "No filter for filtername" << filtername << "";
return 0; // XXX: We don't have this filter. We should warn about it!
}
......
......@@ -67,7 +67,7 @@ bool KisKraSaveVisitor::visit(KisExternalLayer * layer)
{
bool result = false;
if (KisShapeLayer * shapeLayer = dynamic_cast<KisShapeLayer*>(layer)) {
qDebug() << "saving shape layer " << m_name;
QString location = m_external ? QString::null : m_uri;
m_store->pushDirectory();
m_store->enterDirectory(m_name + SHAPE_LAYER_PATH + QString::number( m_count ));
......@@ -242,7 +242,6 @@ bool KisKraSaveVisitor::saveFilterConfiguration(KisNode* node)
if (node->inherits( "KisNodeFilterInterface" )) {
KisNodeFilterInterface* filterInterface = dynamic_cast<KisNodeFilterInterface*>(node);
qDebug() << "filter interface " << filterInterface;
if (!filterInterface) return false;
KisFilterConfiguration* filter = filterInterface->filter();
if (filter) {
......
......@@ -53,10 +53,18 @@ void KisKraSaverTest::testRoundTrip()
{
KisDoc2* doc = createCompleteDocument();
doc->saveNativeFormat( "roundtriptest.kra" );
QStringList list;
KisCountVisitor cv1(list, KoProperties());
doc->image()->rootLayer()->accept(cv1);
delete doc;
KisDoc2 doc2;
doc2.loadNativeFormat( "roundtriptest.kra" );
assertDoc( doc2 );
KisCountVisitor cv2(list, KoProperties());
doc2.image()->rootLayer()->accept(cv2);
QCOMPARE( cv1.count(), cv2.count() );
}
QTEST_KDEMAIN(KisKraSaverTest, GUI)
......
......@@ -18,7 +18,8 @@
#ifndef _UTIL_H_
#define _UTIL_H_
#include <qtest_kde.h>
#include <QTest>
#include <QBitArray>
#include <KoDocument.h>
......@@ -28,6 +29,7 @@
#include <KoColorSpace.h>
#include <KoPathShape.h>
#include <kis_count_visitor.h>
#include "kis_types.h"
#include "filter/kis_filter_registry.h"
#include "filter/kis_filter_configuration.h"
......@@ -134,8 +136,16 @@ KisDoc2* createCompleteDocument()
KoShapeContainer * parentContainer =
dynamic_cast<KoShapeContainer*>(doc->shapeForNode(group1));
// XXX: Set a shape on this layer!
KoPathShape* path = new KoPathShape();
path->setShapeId(KoPathShapeId);
path->moveTo(QPointF( 10, 10 ));
path->lineTo(QPointF( 10, 10 ) + QPointF(100, 0));
path->lineTo(QPointF( 100, 100 ));
path->lineTo(QPointF( 10, 10 ) + QPointF(0, 100));
path->close();
path->normalize();
KisShapeLayerSP shapeLayer = new KisShapeLayer( parentContainer, image, "shapeLayer1", 75 );
shapeLayer->addChild( path );
image->addNode( shapeLayer, group1 );
image->addNode( adjustmentLayer2, group1 );
......@@ -146,7 +156,7 @@ KisDoc2* createCompleteDocument()
image->addNode( filterMask1, paintLayer1 );
KisFilterMaskSP filterMask2 = new KisFilterMask();
filterMask1->setName( "filterMask2" );
filterMask2->setName( "filterMask2" );
filterMask2->setFilter( kfc );
filterMask2->setSelection( createVectorSelection( paintLayer2->paintDevice(), image ) );
image->addNode( filterMask2, paintLayer2 );
......@@ -179,9 +189,6 @@ KisDoc2* createCompleteDocument()
}
bool assertDoc( KisDoc2& doc )
{
return false;
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment