chalk

kis_iterator.h
1/* This file is part of the KDE project
2 * Copyright (c) 2004 Casper Boemann <cbr@boemann.dkt>
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*/
19#ifndef KIS_ITERATOR_H_
20#define KIS_ITERATOR_H_
21
22#include <tqglobal.h>
23#include <ksharedptr.h>
24
25class KisTiledRectIterator;
26typedef TDESharedPtr<KisTiledRectIterator> KisTiledRectIteratorSP;
27
28class KisTiledVLineIterator;
29typedef TDESharedPtr<KisTiledVLineIterator> KisTiledVLineIteratorSP;
30
31class KisTiledHLineIterator;
32typedef TDESharedPtr<KisTiledHLineIterator> KisTiledHLineIteratorSP;
33
34class KisDataManager;
35
41{
42
43
44public:
45 KisRectIterator ( KisDataManager *dm, TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h, bool writable);
46
47public:
48 virtual ~KisRectIterator();
50 KisRectIterator& operator=(const KisRectIterator& rhs);
51
52
53public:
55 TQ_UINT8 * rawData() const;
56
58 const TQ_UINT8 * oldRawData() const;
59
62 TQ_INT32 nConseqPixels() const;
63
66
69
71 bool isDone() const;
72
73 // current x position
74 TQ_INT32 x() const;
75
76 // current y position
77 TQ_INT32 y() const;
78
79private:
80
81 KisTiledRectIteratorSP m_iter;
82};
83
84class KisHLineIterator
85{
86
87public:
88
89 KisHLineIterator ( KisDataManager *dm, TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, bool writable);
90
91public:
92
93 virtual ~KisHLineIterator();
94 KisHLineIterator(const KisHLineIterator& rhs);
95 KisHLineIterator& operator=(const KisHLineIterator& rhs);
96
97public:
99 TQ_UINT8 *rawData() const;
100
102 const TQ_UINT8 *oldRawData() const;
103
105 KisHLineIterator & operator++();
106
109 TQ_INT32 nConseqHPixels() const;
110
112 KisHLineIterator & operator+=(int n);
113
115 KisHLineIterator & operator--();
116
118 bool isDone() const;
119
121 TQ_INT32 x() const;
122
124 TQ_INT32 y() const;
125
127 void nextRow();
128
129
130private:
131
132 KisTiledHLineIteratorSP m_iter;
133};
134
135class KisVLineIterator
136{
137
138public:
139 KisVLineIterator ( KisDataManager *dm, TQ_INT32 x, TQ_INT32 y, TQ_INT32 h, bool writable);
140public:
141 ~KisVLineIterator();
142 KisVLineIterator(const KisVLineIterator& rhs);
143 KisVLineIterator& operator=(const KisVLineIterator& rhs);
144
145public:
147 TQ_UINT8 *rawData() const;
148
150 const TQ_UINT8 * oldRawData() const;
151
153 KisVLineIterator & operator++();
154
156 bool isDone() const;
157
159 TQ_INT32 x() const;
160
162 TQ_INT32 y() const;
163
165 void nextCol();
166
167private:
168
169 KisTiledVLineIteratorSP m_iter;
170
171};
172
173#endif
KisDataManager defines the interface that modules responsible for storing and retrieving data must in...
The KisRectIterator iterators over a rectangular area in the most efficient order.
TQ_UINT8 * rawData() const
returns a pointer to the pixel data. Do NOT interpret the data - leave that to a colorstrategy
KisRectIterator & operator++()
Advances one pixel going to the beginning of the next line when it reaches the end of a line.
const TQ_UINT8 * oldRawData() const
Returns a pointer to the pixel data as it was at the moment of the last memento creation.
bool isDone() const
returns true when iterators has reached the end
KisRectIterator & operator+=(int n)
Advances a number of pixels until it reaches the end of the rect.
TQ_INT32 nConseqPixels() const
Returns the number of consequtive pixels that we point at This is useful for optimizing.