chalk

kis_datamanager.h
1/*
2 * Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18#ifndef KIS_DATAMANAGER_H_
19#define KIS_DATAMANAGER_H_
20
21#include <tqglobal.h>
22#include <tqvaluevector.h>
23#include <tqrect.h>
24
25class KoStore;
26
27
28// Change the following two lines to switch (at compiletime) to another datamanager
29#include "tiles/kis_tileddatamanager.h"
30#define ACTUAL_DATAMGR KisTiledDataManager
31
45class KisDataManager : public ACTUAL_DATAMGR {
46
47public:
48 KisDataManager(TQ_UINT32 pixelSize, const TQ_UINT8 *defPixel) : ACTUAL_DATAMGR(pixelSize, defPixel) {}
49 KisDataManager(const KisDataManager& dm) : ACTUAL_DATAMGR(dm) { }
50
51public:
56 inline void setDefaultPixel(const TQ_UINT8 *defPixel) { return ACTUAL_DATAMGR::setDefaultPixel(defPixel); }
57
61 inline const TQ_UINT8 *defaultPixel() const { return ACTUAL_DATAMGR::defaultPixel(); }
62
69 inline KisMementoSP getMemento() { return ACTUAL_DATAMGR::getMemento(); }
70
77 inline void rollback(KisMementoSP memento) { ACTUAL_DATAMGR::rollback(memento); }
78
86 inline void rollforward(KisMementoSP memento) { ACTUAL_DATAMGR::rollforward(memento); }
87
88public:
93 inline bool write(KoStore *store) { return ACTUAL_DATAMGR::write(store); }
94 inline bool read(KoStore *store) { return ACTUAL_DATAMGR::read(store); }
95
96public:
97
101 inline TQ_UINT32 pixelSize() { return ACTUAL_DATAMGR::pixelSize(); }
102
106 inline void extent(TQ_INT32 &x, TQ_INT32 &y, TQ_INT32 &w, TQ_INT32 &h) const
107 { return ACTUAL_DATAMGR::extent(x, y, w, h); }
108
109 TQRect extent() const { return ACTUAL_DATAMGR::extent(); }
110
111
112public:
113
117 inline void setExtent(TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h)
118 { return ACTUAL_DATAMGR::setExtent(x, y, w, h); }
119
120 inline void setExtent(const TQRect & rect) { setExtent(rect.x(), rect.y(), rect.width(), rect.height()); }
121
122public:
123
127 inline void clear(TQ_INT32 x, TQ_INT32 y,
128 TQ_INT32 w, TQ_INT32 h,
129 TQ_UINT8 def) { ACTUAL_DATAMGR::clear(x, y, w, h, def); }
130
134 inline void clear(TQ_INT32 x, TQ_INT32 y,
135 TQ_INT32 w, TQ_INT32 h,
136 const TQ_UINT8 * def) { ACTUAL_DATAMGR::clear(x, y, w, h, def); }
137
141 inline void clear() { ACTUAL_DATAMGR::clear(); }
142
143
144public:
145
150 inline void paste(KisDataManagerSP data, TQ_INT32 sx, TQ_INT32 sy, TQ_INT32 dx, TQ_INT32 dy,
151 TQ_INT32 w, TQ_INT32 h) { ACTUAL_DATAMGR::paste(data, sx, sy, dx, dy, w, h); }
152
153public:
157 inline TDE_DEPRECATED const TQ_UINT8* pixel(TQ_INT32 x, TQ_INT32 y)
158 { return ACTUAL_DATAMGR::pixel(x, y); }
159
163 inline TDE_DEPRECATED TQ_UINT8* writablePixel(TQ_INT32 x, TQ_INT32 y)
164 { return ACTUAL_DATAMGR::writablePixel(x, y); }
165
169 inline void setPixel(TQ_INT32 x, TQ_INT32 y, const TQ_UINT8 * data)
170 { ACTUAL_DATAMGR::setPixel(x, y, data);}
171
172
178 inline void readBytes(TQ_UINT8 * data,
179 TQ_INT32 x, TQ_INT32 y,
180 TQ_INT32 w, TQ_INT32 h)
181 { ACTUAL_DATAMGR::readBytes(data, x, y, w, h);}
182
187 inline void writeBytes(const TQ_UINT8 * data,
188 TQ_INT32 x, TQ_INT32 y,
189 TQ_INT32 w, TQ_INT32 h)
190 {ACTUAL_DATAMGR::writeBytes( data, x, y, w, h); }
191
192 // Get the number of contiguous columns starting at x, valid for all values
193 // of y between minY and maxY.
194 inline TQ_INT32 numContiguousColumns(TQ_INT32 x, TQ_INT32 minY, TQ_INT32 maxY)
195 { return ACTUAL_DATAMGR::numContiguousColumns(x, minY, maxY); }
196
197
198 // Get the number of contiguous rows starting at y, valid for all values
199 // of x between minX and maxX.
200 inline TQ_INT32 numContiguousRows(TQ_INT32 y, TQ_INT32 minX, TQ_INT32 maxX)
201 { return ACTUAL_DATAMGR::numContiguousRows(y, minX, maxX); }
202
203
204 // Get the row stride at pixel (x, y). This is the number of bytes to add to a
205 // pointer to pixel (x, y) to access (x, y + 1).
206 inline TQ_INT32 rowStride(TQ_INT32 x, TQ_INT32 y)
207 { return ACTUAL_DATAMGR::rowStride(x, y); }
208
209protected:
210 friend class KisRectIterator;
211 friend class KisHLineIterator;
212 friend class KisVLineIterator;
213};
214
215
216#endif // KIS_DATAMANAGER_H_
217
void clear(TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h, const TQ_UINT8 *def)
Clear the specified rect to the specified pixel value.
void readBytes(TQ_UINT8 *data, TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h)
Copy the bytes in the specified rect to a chunk of memory.
void setExtent(TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h)
Crop or extend the data to x, y, w, h.
KisMementoSP getMemento()
Reguests a memento from the data manager.
void setPixel(TQ_INT32 x, TQ_INT32 y, const TQ_UINT8 *data)
Write the specified data to x, y.
void rollforward(KisMementoSP memento)
Restores the image data to the state at the time of the rollback call of the memento.
void extent(TQ_INT32 &x, TQ_INT32 &y, TQ_INT32 &w, TQ_INT32 &h) const
Return the extent of the data in x,y,w,h.
void rollback(KisMementoSP memento)
Restores the image data to the state at the time of the getMemento() call.
TDE_DEPRECATED const TQ_UINT8 * pixel(TQ_INT32 x, TQ_INT32 y)
Get a read-only pointer to the specified pixel.
const TQ_UINT8 * defaultPixel() const
Gets the default pixel.
TDE_DEPRECATED TQ_UINT8 * writablePixel(TQ_INT32 x, TQ_INT32 y)
Get a read-write pointer to the specified pixel.
void clear()
Clear all back to default values.
void writeBytes(const TQ_UINT8 *data, TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h)
Copy the bytes to the specified rect.
void clear(TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h, TQ_UINT8 def)
Clear the specified rect to the specified value.
bool write(KoStore *store)
Reads and writes the tiles from/onto a KoStore (wich is simply a file within a zip file).
void paste(KisDataManagerSP data, TQ_INT32 sx, TQ_INT32 sy, TQ_INT32 dx, TQ_INT32 dy, TQ_INT32 w, TQ_INT32 h)
Copy the specified rect from the specified data into this data.
void setDefaultPixel(const TQ_UINT8 *defPixel)
Sets the default pixel.
TQ_UINT32 pixelSize()
Returns the number of bytes a pixel takes.