chalk

kis_iterator.cpp
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
20#include <tqglobal.h>
21
22#include <kdebug.h>
23
24#include "kis_iterator.h"
25#include "kis_datamanager.h"
26#include "kis_tilediterator.h"
27
28KisRectIterator::KisRectIterator ( KisDataManager *dm, TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, TQ_INT32 h, bool writable)
29{
30 m_iter = new KisTiledRectIterator(dm, x, y, w, h, writable);
31}
32KisRectIterator::KisRectIterator(const KisRectIterator& rhs)
33{
34 m_iter = rhs.m_iter;
35}
36
37KisRectIterator& KisRectIterator::operator=(const KisRectIterator& rhs)
38{
39 m_iter = rhs.m_iter;
40 return *this;
41}
42
43KisRectIterator::~KisRectIterator()
44{
45}
46
47TQ_UINT8 * KisRectIterator::rawData() const { return m_iter->rawData();}
48
49const TQ_UINT8 * KisRectIterator::oldRawData() const { return m_iter->oldRawData();}
50
51TQ_INT32 KisRectIterator::nConseqPixels() const { return m_iter->nConseqPixels(); }
52
53KisRectIterator & KisRectIterator::operator+=(int n) { m_iter->operator+=(n); return *this; }
54
55KisRectIterator & KisRectIterator::operator++() { m_iter->operator++(); return *this; }
56
57bool KisRectIterator::isDone() const { return m_iter->isDone(); }
58
59TQ_INT32 KisRectIterator::x() const { return m_iter->x(); }
60TQ_INT32 KisRectIterator::y() const { return m_iter->y(); }
61
62//---------------------------------------------------------------------------------------
63
64KisHLineIterator::KisHLineIterator ( KisDataManager *dm, TQ_INT32 x, TQ_INT32 y, TQ_INT32 w, bool writable)
65{
66 m_iter = new KisTiledHLineIterator(dm, x, y, w, writable);
67}
68
69KisHLineIterator::KisHLineIterator(const KisHLineIterator& rhs)
70{
71 m_iter = rhs.m_iter;
72}
73
74KisHLineIterator& KisHLineIterator::operator=(const KisHLineIterator& rhs)
75{
76
77 m_iter=rhs.m_iter;
78 return *this;
79}
80
81KisHLineIterator::~KisHLineIterator()
82{
83}
84
85TQ_UINT8 *KisHLineIterator::rawData() const
86{
87 return m_iter->rawData();
88}
89
90const TQ_UINT8 *KisHLineIterator::oldRawData() const { return m_iter->oldRawData();}
91
92KisHLineIterator & KisHLineIterator::operator++() { m_iter->operator++(); return *this; }
93
94TQ_INT32 KisHLineIterator::nConseqHPixels() const { return m_iter->nConseqHPixels(); }
95
96KisHLineIterator & KisHLineIterator::operator+=(int n) { m_iter->operator+=(n); return *this; }
97
98KisHLineIterator & KisHLineIterator::operator--() { m_iter->operator--(); return *this; }
99
100bool KisHLineIterator::isDone() const { return m_iter->isDone(); }
101
102TQ_INT32 KisHLineIterator::x() const { return m_iter->x(); }
103
104TQ_INT32 KisHLineIterator::y() const { return m_iter->y(); }
105
106void KisHLineIterator::nextRow() { m_iter->nextRow(); }
107
108//---------------------------------------------------------------------------------------
109
110KisVLineIterator::KisVLineIterator ( KisDataManager *dm, TQ_INT32 x, TQ_INT32 y, TQ_INT32 h, bool writable)
111{
112 m_iter = new KisTiledVLineIterator(dm, x, y, h, writable);
113}
114
115KisVLineIterator::KisVLineIterator(const KisVLineIterator& rhs)
116{
117 m_iter = rhs.m_iter;
118}
119
120KisVLineIterator& KisVLineIterator::operator=(const KisVLineIterator& rhs)
121{
122 m_iter = rhs.m_iter;
123 return *this;
124}
125
126KisVLineIterator::~KisVLineIterator()
127{
128}
129
130TQ_UINT8 *KisVLineIterator::rawData() const { return m_iter->rawData();}
131
132const TQ_UINT8 * KisVLineIterator::oldRawData() const { return m_iter->oldRawData();}
133
134KisVLineIterator & KisVLineIterator::operator++() { m_iter->operator++(); return *this; }
135
136bool KisVLineIterator::isDone() const { return m_iter->isDone(); }
137
138TQ_INT32 KisVLineIterator::x() const { return m_iter->x(); }
139
140TQ_INT32 KisVLineIterator::y() const { return m_iter->y(); }
141
142void KisVLineIterator::nextCol() { return m_iter->nextCol(); }
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.