19#ifndef KIS_LOAD_VISITOR_H_
20#define KIS_LOAD_VISITOR_H_
24#include "kis_layer_visitor.h"
26#include "kis_selection.h"
28#include "kis_paint_layer.h"
29#include "kis_group_layer.h"
30#include "kis_adjustment_layer.h"
31#include "kis_filter_configuration.h"
33#include "kis_datamanager.h"
35class KisLoadVisitor :
public KisLayerVisitor {
37 KisLoadVisitor(KisImageSP img, KoStore *store, TQMap<KisLayerSP, TQString> &layerFilenames) :
39 m_layerFilenames(layerFilenames)
47 void setExternalUri(TQString &uri)
53 virtual bool visit(KisPaintLayer *layer)
56 TQString location = m_external ? TQString() : m_uri;
57 location += m_img->name() +
"/layers/" + m_layerFilenames[layer];
60 if (m_store->open(location)) {
61 if (!layer->paintDevice()->read(m_store)) {
62 layer->paintDevice()->disconnect();
72 location = m_external ? TQString() : m_uri;
73 location += m_img->name() +
"/layers/" + m_layerFilenames[layer] +
".icc";
75 if (m_store->hasFile(location)) {
77 m_store->open(location);
78 data = m_store->read(m_store->size());
81 KisColorSpace * cs = KisMetaRegistry::instance()->csRegistry()->
getColorSpace(layer->paintDevice()->colorSpace()->id(),
82 new KisProfile(data));
84 layer->paintDevice()->setData(layer->paintDevice()->dataManager(), cs);
85 TQRect rc = layer->paintDevice()->extent();
86 kdDebug() <<
"After loading " << layer->name() <<
" extent is: " << rc.x() <<
", " << rc.y() <<
", " << rc.width() <<
", " << rc.height() << endl;
88 kdDebug(DBG_AREA_FILE) <<
"Opened icc information, size is " << data.size() << endl;
93 KisPaintDeviceSP mask = layer->
getMask();
94 location = m_external ? TQString() : m_uri;
95 location += m_img->name() +
"/layers/" + m_layerFilenames[layer] +
".mask";
98 if (m_store->open(location)) {
99 if (!mask->read(m_store)) {
115 virtual bool visit(KisGroupLayer *layer)
117 KisLoadVisitor visitor(m_img,m_store ,m_layerFilenames);
120 visitor.setExternalUri(m_uri);
126 child->accept(visitor);
127 child = child->nextSibling();
134 virtual bool visit(KisPartLayer *)
139 virtual bool visit(KisAdjustmentLayer* layer)
144 TQString location = m_external ? TQString() : m_uri;
145 location += m_img->name() +
"/layers/" + m_layerFilenames[layer] +
".selection";
146 if (m_store->hasFile(location)) {
147 m_store->open(location);
148 KisSelectionSP selection =
new KisSelection();
149 if (!selection->read(m_store)) {
150 selection->disconnect();
160 location = m_external ? TQString() : m_uri;
161 location += m_img->name() +
"/layers/" + m_layerFilenames[layer] +
".filterconfig";
163 if (m_store->hasFile(location) && layer->filter()) {
165 m_store->open(location);
166 data = m_store->read(m_store->size());
168 if (!data.isNull()) {
169 KisFilterConfiguration * kfc = layer->filter();
183 TQMap<KisLayerSP, TQString> m_layerFilenames;
void setSelection(KisSelectionSP selection)
Set the selction of this adjustment layer to a copy of selection.
KisColorSpace * getColorSpace(const KisID &csID, const TQString &profileName)
Return the colorspace + profile as named, or NULL if impossible combination.
virtual void fromXML(const TQString &)
Fill the filter configuration object from the XML encoded representation in s.
virtual KisLayerSP firstChild() const
Returns the first child layer of this layer (if it supports that).
virtual void setDirty(bool propagate=true)
Set the entire layer extent dirty; this percolates up to parent layers all the way to the root layer.
KisPaintDeviceSP getMask()
Returns the layer mask's device. Creates one if there is currently none.
virtual void setDirty(bool propagate=true)
Overridden to call the private convertMaskToSelection.
bool hasMask() const
Does this layer have a layer mask?