18#include <QApplication>
66 QString intern = _intern;
70 while ((pos = intern.indexOf(
'/')) != -1) {
71 if (QChar(intern.at(0)).isDigit())
73 result += intern.left(pos + 1);
74 intern = intern.mid(pos + 1);
77 if (!intern.isEmpty() && QChar(intern.at(0)).isDigit())
88 QMap<KisNode *, QString> &layerFilenames,
89 QMap<KisNode *, QString> &keyframeFilenames,
96 , m_layerFilenames(layerFilenames)
97 , m_keyframeFilenames(keyframeFilenames)
99 , m_shapeController(shapeController)
106 if (directories.size() > 0) {
107 dbgFile <<
"Could not locate the directory, maybe some encoding issue? Grab the first directory, that'll be the image one." <<
m_name << directories;
108 m_name = directories.first();
111 dbgFile <<
"Could not enter directory" <<
m_name <<
", probably an old-style file with 'part' added.";
132 Q_FOREACH(
KoShape *shape, referencesLayer->shapes()) {
136 while (!reference->loadImage(
m_store)) {
137 if (reference->embed()) {
138 m_errorMessages << i18n(
"Could not load embedded reference image %1 ", reference->internalFile());
143 "A reference image linked to an external file could not be loaded.\n\n"
145 "Do you want to select another location?", reference->filename());
148 int locateManually = QMessageBox::warning(qApp->activeWindow(), i18nc(
"@title:window",
"File not found"), msg, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes);
151 if (locateManually == QMessageBox::Yes) {
154 url = dialog.filename();
160 reference->setFilename(url);
161 reference->setEmbed(
false);
177 result = shapeLayer->loadLayer(
m_store, &vectorWarnings);
212 pixelSelection->disconnect();
257 m_warningMessages.append(i18nc(
"Warning during loading a kra file with a filter layer",
258 "Selection on layer %s couldn't be loaded. It will be replaced by an empty selection.", layer->
name()));
272 kfc->createLocalResourcesSnapshot();
294 kfc->createLocalResourcesSnapshot();
321 m_warningMessages.append(i18nc(
"Loading a .kra file",
"The file contains a clone layer that has an incorrect source node id. "
322 "This layer will be converted into a paint layer."));
337 cloneLayer->
accept(*
this);
342 Q_ASSERT(parentLayer);
359 kfc->createLocalResourcesSnapshot();
374 if (!data.isEmpty()) {
376 doc.setContent(data);
378 QDomElement rootElement = doc.documentElement();
386 QString
id =
main.attribute(
"id",
"not-valid");
389 if (
id ==
"animatedtransformparams") {
390 id =
"tooltransformparams";
392 if (
id ==
"not-valid") {
393 m_errorMessages << i18n(
"Could not load \"id\" of the transform mask");
416 if (
id ==
"dumbparams") {
418 params->transformSrcAndDst(QTransform::fromTranslate(center.x(), center.y()));
463 if (!doc.setContent(data))
467 if (!KisDomUtils::loadValue(doc.documentElement(),
471 QPoint(mask->
x(), mask->
y()))) {
497 profile = parent->colorSpace()->profile();
532 return dev->
read(stream);
562 if (frameInterface) {
566 if (!frameInterface || frames.count() <= 1) {
571 for (
int i = 0; i < frames.count(); i++) {
574 m_warningMessages << i18n(
"Could not find keyframe pixel data for frame %1 in %2.",
id, location);
579 Q_ASSERT(!frameFilename.isEmpty());
582 m_warningMessages << i18n(
"Could not load keyframe pixel data for frame %1 in %2.",
id, location);
591template<
class DevicePolicy>
606 policy.setDefaultPixel(device, color);
612 device->disconnect();
648 dbgFile <<
"Data to load: " <<
m_store->
size() <<
" from " << location <<
" with color space " << colorModelId << colorDepthId;
676 if (!data.isEmpty()) {
678 doc.setContent(data);
679 QDomElement e = doc.documentElement();
680 if (e.tagName() ==
"filterconfig") {
681 kfc->fromLegacyXML(e);
707 KisLayer* layer = qobject_cast<KisLayer*>(node);
708 if (!layer)
return true;
714 dbgFile <<
"Backend " << backend->
id() <<
" does not support loading.";
716 dbgFile <<
"Could not load the XMP backend at all";
721 dbgFile <<
"going to load " << backend->
id() <<
", " << backend->
name() <<
" from " << location;
728 QBuffer buffer(&data);
819 m_errorMessages << i18n(
"Could not load keyframes from %1.", location);
828 bool ok = dom.setContent(
m_store->
device(), &errorMsg, &errorLine, &errorColumn);
833 m_errorMessages << i18n(
"parsing error in the keyframe file %1 at line %2, column %3\nError message: %4", location, errorLine, errorColumn, i18n(errorMsg.toUtf8()));
837 QDomElement root = dom.firstChildElement();
839 for (QDomElement child = root.firstChildElement(); !child.isNull(); child = child.nextSiblingElement()) {
840 if (child.nodeName().toUpper() ==
"CHANNEL") {
841 QString
id = child.attribute(
"name");
846 m_warningMessages << i18n(
"unknown keyframe channel type: %1 in %2",
id, location);
857 if (cfg->getString(
"legacy") ==
"left edge detections") {
858 cfg->setProperty(
"horizRadius", 1);
859 cfg->setProperty(
"vertRadius", 1);
860 cfg->setProperty(
"type",
"prewitt");
861 cfg->setProperty(
"output",
"yFall");
862 cfg->setProperty(
"lockAspect",
true);
863 cfg->setProperty(
"transparency",
false);
864 }
else if (cfg->getString(
"legacy") ==
"right edge detections") {
865 cfg->setProperty(
"horizRadius", 1);
866 cfg->setProperty(
"vertRadius", 1);
867 cfg->setProperty(
"type",
"prewitt");
868 cfg->setProperty(
"output",
"yGrowth");
869 cfg->setProperty(
"lockAspect",
true);
870 cfg->setProperty(
"transparency",
false);
871 }
else if (cfg->getString(
"legacy") ==
"top edge detections") {
872 cfg->setProperty(
"horizRadius", 1);
873 cfg->setProperty(
"vertRadius", 1);
874 cfg->setProperty(
"type",
"prewitt");
875 cfg->setProperty(
"output",
"xGrowth");
876 cfg->setProperty(
"lockAspect",
true);
877 cfg->setProperty(
"transparency",
false);
878 }
else if (cfg->getString(
"legacy") ==
"bottom edge detections") {
879 cfg->setProperty(
"horizRadius", 1);
880 cfg->setProperty(
"vertRadius", 1);
881 cfg->setProperty(
"type",
"prewitt");
882 cfg->setProperty(
"output",
"xFall");
883 cfg->setProperty(
"lockAspect",
true);
884 cfg->setProperty(
"transparency",
false);
void setFilter(KisFilterConfigurationSP filterConfig, bool checkCompareConfig=true) override
void setKeyStrokesDirect(const QList< KisLazyFillTools::KeyStroke > &strokes)
const KoColorSpace * colorSpace() const override
void setProfile(const KoColorProfile *profile, KUndo2Command *parentCommand)
qint32 y() const override
KisPaintDeviceSP coloringProjection() const
qint32 x() const override
void setFilter(KisFilterConfigurationSP filterConfig, bool checkCompareConfig=true) override
static KisFilterRegistry * instance()
virtual bool configurationAllowedForMask(KisFilterConfigurationSP config) const
virtual void fixLoadedFilterConfigurationForMasks(KisFilterConfigurationSP config) const
static KisGeneratorRegistry * instance()
static KisResourcesInterfaceSP instance()
KisGroupLayerSP rootLayer() const
const KoColorSpace * colorSpace() const
QRect bounds() const override
static QStringList supportedMimeTypes(Direction direction)
KisKeyframeChannel stores and manages KisKeyframes. Maps units of time to virtual keyframe values....
virtual void loadXML(const QDomElement &channelNode)
bool loadProfile(KisPaintDeviceSP device, const QString &location)
bool loadPaintDevice(KisPaintDeviceSP device, const QString &location)
void initSelectionForMask(KisMask *mask)
QMap< KisNode *, QString > m_keyframeFilenames
KoShapeControllerBase * m_shapeController
bool loadFilterConfiguration(KisFilterConfigurationSP kfc, const QString &location)
bool loadMetaData(KisNode *node)
void fixOldFilterConfigurations(KisFilterConfigurationSP kfc)
QMap< QString, const KoColorProfile * > m_profileCache
QMap< KisNode *, QString > m_layerFilenames
void setExternalUri(const QString &uri)
KisKraLoadVisitor(KisImageSP image, KoStore *store, KoShapeControllerBase *shapeController, QMap< KisNode *, QString > &layerFilenames, QMap< KisNode *, QString > &keyframeFilenames, const QString &name, int syntaxVersion)
QStringList m_errorMessages
void loadDeprecatedFilter(KisFilterConfigurationSP cfg)
bool loadSelection(const QString &location, KisSelectionSP dstSelection)
void loadNodeKeyframes(KisNode *node)
QStringList warningMessages() const
QString getLocation(KisNode *node, const QString &suffix=QString())
bool loadPaintDeviceFrame(KisPaintDeviceSP device, const QString &location, DevicePolicy policy)
QStringList m_warningMessages
bool visit(KisNode *) override
QStringList errorMessages() const
virtual KisFilterConfigurationSP filter() const
KisNodeSP findNode(KisNodeSP rootNode)
bool visitAll(KisNode *node, bool breakOnFail=false)
void setFrameDefaultPixel(const KoColor &defPixel, int frameId)
bool readFrame(QIODevice *stream, int frameId)
bool read(QIODevice *stream)
KisRasterKeyframeChannel * keyframeChannel() const
void setDefaultPixel(const KoColor &defPixel)
KisPaintDeviceFramesInterface * framesInterface()
const KoColorSpace * colorSpace() const
bool setProfile(const KoColorProfile *profile, KUndo2Command *parentCommand)
The KisRasterKeyframeChannel is a concrete KisKeyframeChannel subclass that stores and manages KisRas...
QString frameFilename(int frameId) const
The KisReferenceImage class represents a single reference image.
bool loadSelection(KoStore *store, const QRect &imageRect)
virtual quint32 pixelSize() const =0
virtual KoID colorModelId() const =0
virtual KoID colorDepthId() const =0
virtual const KoColorProfile * profile() const =0
static KoColor createTransparent(const KoColorSpace *cs)
const T value(const QString &id) const
T get(const QString &id) const
static QString generateHash(const QString &filename)
generateHash reads the given file and generates a hex-encoded md5sum for the file.
QIODevice * device() const
bool extractFile(const QString &sourceName, QByteArray &data)
virtual QStringList directoryList() const
virtual bool enterDirectory(const QString &directory)
bool hasFile(const QString &fileName) const
bool open(const QString &name)
QByteArray read(qint64 max)
#define KIS_SAFE_ASSERT_RECOVER(cond)
#define KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(cond, val)
#define KIS_SAFE_ASSERT_RECOVER_RETURN(cond)
#define KIS_SAFE_ASSERT_RECOVER_NOOP(cond)
QString expandEncodedDirectory(const QString &_intern)
KisSharedPtr< KisSelection > KisSelectionSP
int main(int argc, char **argv)
const QString DOT_SHAPE_SELECTION
const QString DOT_PIXEL_SELECTION
const QString DOT_METADATA
const QString DOT_SHAPE_LAYER
const QString DOT_FILTERCONFIG
const QString DOT_COLORIZE_MASK
const QString COLORIZE_KEYSTROKE
const QString DOT_TRANSFORMCONFIG
const QString COLORIZE_COLORING_DEVICE
const QString COLORIZE_KEYSTROKES_SECTION
bool findOnlyElement(const QDomElement &parent, const QString &tag, QDomElement *el, QStringList *errorMessages)
bool read(KisPaintDeviceSP dev, QIODevice *stream)
void setDefaultPixel(KisPaintDeviceSP dev, const KoColor &defaultPixel) const
FramedDevicePolicy(int frameId)
KoColor defaultPixel(KisPaintDeviceSP dev) const
KisKeyframeChannel * getKeyframeChannel(const QString &id, bool create)
virtual KisFilterConfigurationSP factoryConfiguration(KisResourcesInterfaceSP resourcesInterface) const
void setCopyFrom(KisLayerSP layer)
KisNodeUuidInfo copyFromInfo
void setFilter(KisFilterConfigurationSP filterConfig, bool checkCompareConfig=true) override
KisMetaData::Store * metaData()
void initSelection(KisSelectionSP copyFrom, KisLayerSP parentLayer)
initSelection initializes the selection for the mask from the given selection's projection.
void setSelection(KisSelectionSP selection)
bool addNode(KisNodeSP node, KisNodeSP parent=KisNodeSP(), KisNodeAdditionFlags flags=KisNodeAdditionFlag::None)
KisNodeSP firstChild() const
bool accept(KisNodeVisitor &v) override
KisPaintDeviceSP paintDevice
void invalidateOutlineCache()
bool read(QIODevice *stream)
void setInternalSelection(KisSelectionSP selection)
KisSelectionSP internalSelection() const
void updateProjection(const QRect &rect)
KisPixelSelectionSP pixelSelection
void convertToVectorSelectionNoUndo(KisSelectionComponent *shapeSelection)
static KoColorSpaceRegistry * instance()
const KoColorProfile * createColorProfile(const QString &colorModelId, const QString &colorDepthId, const QByteArray &rawData)
bool read(KisPaintDeviceSP dev, QIODevice *stream)
void setDefaultPixel(KisPaintDeviceSP dev, const KoColor &defaultPixel) const
KoColor defaultPixel(KisPaintDeviceSP dev) const