File indexing completed on 2024-12-22 04:15:46
0001 /* 0002 * SPDX-FileCopyrightText: 2002 Patrick Julien <freak@codepimps.org> 0003 * SPDX-FileCopyrightText: 2005 C. Boemann <cbo@boemann.dk> 0004 * SPDX-FileCopyrightText: 2007 Boudewijn Rempt <boud@valdyas.org> 0005 * 0006 * SPDX-License-Identifier: GPL-2.0-or-later 0007 */ 0008 #ifndef KIS_KRA_LOAD_VISITOR_H_ 0009 #define KIS_KRA_LOAD_VISITOR_H_ 0010 0011 #include <QRect> 0012 #include <QStringList> 0013 0014 // kritaimage 0015 #include "kis_types.h" 0016 #include "kis_node_visitor.h" 0017 0018 #include "kritalibkra_export.h" 0019 0020 class KisFilterConfiguration; 0021 class KoStore; 0022 class KoShapeControllerBase; 0023 class KoColorProfile; 0024 class KisNodeFilterInterface; 0025 0026 class KRITALIBKRA_EXPORT KisKraLoadVisitor : public KisNodeVisitor 0027 { 0028 public: 0029 0030 0031 KisKraLoadVisitor(KisImageSP image, 0032 KoStore *store, 0033 KoShapeControllerBase *shapeController, 0034 QMap<KisNode *, QString> &layerFilenames, 0035 QMap<KisNode *, QString> &keyframeFilenames, 0036 const QString & name, 0037 int syntaxVersion); 0038 0039 public: 0040 void setExternalUri(const QString &uri); 0041 0042 bool visit(KisNode*) override { 0043 return true; 0044 } 0045 bool visit(KisExternalLayer *) override; 0046 bool visit(KisPaintLayer *layer) override; 0047 bool visit(KisGroupLayer *layer) override; 0048 bool visit(KisAdjustmentLayer* layer) override; 0049 bool visit(KisGeneratorLayer* layer) override; 0050 bool visit(KisCloneLayer *layer) override; 0051 bool visit(KisFilterMask *mask) override; 0052 bool visit(KisTransformMask *mask) override; 0053 bool visit(KisTransparencyMask *mask) override; 0054 bool visit(KisSelectionMask *mask) override; 0055 bool visit(KisColorizeMask *mask) override; 0056 0057 QStringList errorMessages() const; 0058 QStringList warningMessages() const; 0059 0060 private: 0061 0062 bool loadPaintDevice(KisPaintDeviceSP device, const QString& location); 0063 0064 template<class DevicePolicy> 0065 bool loadPaintDeviceFrame(KisPaintDeviceSP device, const QString &location, DevicePolicy policy); 0066 0067 bool loadProfile(KisPaintDeviceSP device, const QString& location); 0068 bool loadFilterConfiguration(KisFilterConfigurationSP kfc, const QString& location); 0069 const KoColorProfile* loadProfile(const QString& location, const QString &colorModelId, const QString &colorDepthId); 0070 void fixOldFilterConfigurations(KisFilterConfigurationSP kfc); 0071 bool loadMetaData(KisNode* node); 0072 void initSelectionForMask(KisMask *mask); 0073 bool loadSelection(const QString& location, KisSelectionSP dstSelection); 0074 QString getLocation(KisNode* node, const QString& suffix = QString()); 0075 QString getLocation(const QString &filename, const QString &suffix = QString()); 0076 void loadNodeKeyframes(KisNode *node); 0077 0078 /** 0079 * Load deprecated filters. 0080 * Most deprecated filters can be handled by this, but the brightnesscontact to perchannels 0081 * conversion needs to be handled in the perchannel class because those filters 0082 * have their own xml loading functionality. 0083 */ 0084 void loadDeprecatedFilter(KisFilterConfigurationSP cfg); 0085 0086 private: 0087 KisImageSP m_image; 0088 KoStore *m_store; 0089 bool m_external; 0090 QString m_uri; 0091 QMap<KisNode *, QString> m_layerFilenames; 0092 QMap<KisNode *, QString> m_keyframeFilenames; 0093 QString m_name; 0094 int m_syntaxVersion; 0095 QStringList m_errorMessages; 0096 QStringList m_warningMessages; 0097 KoShapeControllerBase *m_shapeController; 0098 QMap<QString, const KoColorProfile *> m_profileCache; 0099 }; 0100 0101 #endif // KIS_KRA_LOAD_VISITOR_H_ 0102