krita

kis_iterators_pixel.h

00001 /* This file is part of the KDE project
00002  *  Copyright (c) 2004 Cyrille Berger <cberger@cberger.net>
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #ifndef KIS_ITERATORS_PIXEL_H_
00020 #define KIS_ITERATORS_PIXEL_H_
00021 
00022 #include "kis_iterator.h"
00023 #include "kis_iteratorpixeltrait.h"
00024 
00032 class KisHLineIteratorPixel : public KisHLineIterator, public KisIteratorPixelTrait <KisHLineIterator>
00033 {
00034 
00035 public:
00036 
00037     KisHLineIteratorPixel( KisPaintDevice *ndevice, KisDataManager *dm, KisDataManager *sel_dm,
00038                            Q_INT32 x , Q_INT32 y , Q_INT32 w, Q_INT32 offsetx, Q_INT32 offsety,
00039                            bool writable);
00040     
00041     KisHLineIteratorPixel(const KisHLineIteratorPixel& rhs) : KisHLineIterator(rhs), KisIteratorPixelTrait<KisHLineIterator>(rhs)
00042         { m_offsetx = rhs.m_offsetx;  m_offsety = rhs.m_offsety; }
00043         
00044     KisHLineIteratorPixel& operator=(const KisHLineIteratorPixel& rhs)
00045         {
00046           KisHLineIterator::operator=(rhs);
00047           KisIteratorPixelTrait<KisHLineIterator>::operator=(rhs);
00048           m_offsetx = rhs.m_offsetx;  m_offsety = rhs.m_offsety;
00049           return *this;
00050         }
00051 
00052     inline KisHLineIteratorPixel & operator ++() { KisHLineIterator::operator++(); advance(1); return *this;}
00053 
00055     KisHLineIteratorPixel & operator+=(int n) { KisHLineIterator::operator+=(n); advance(n); return *this; };
00056 
00057     Q_INT32 x() const { return KisHLineIterator::x() + m_offsetx; }
00058     
00059     Q_INT32 y() const { return KisHLineIterator::y() + m_offsety; }
00060     
00061     Q_INT32 nConseqHPixels() const {
00062         if (m_selectionIterator) {
00063             Q_INT32 parent = KisHLineIteratorPixel::nConseqHPixels();
00064             Q_INT32 selection = m_selectionIterator->nConseqHPixels();
00065             if (parent < selection)
00066                 return parent;
00067             return selection;
00068         }
00069         return KisHLineIteratorPixel::nConseqHPixels();
00070     }
00071 protected:
00072 
00073     Q_INT32 m_offsetx, m_offsety;
00074 };
00075 
00076 class KisVLineIteratorPixel : public KisVLineIterator, public KisIteratorPixelTrait <KisVLineIterator>
00077 {
00078 public:
00079     KisVLineIteratorPixel( KisPaintDevice *ndevice, KisDataManager *dm, KisDataManager *sel_dm,
00080                            Q_INT32 xpos , Q_INT32 ypos , Q_INT32 height, Q_INT32 offsetx, Q_INT32 offsety,
00081                            bool writable);
00082                            
00083     KisVLineIteratorPixel(const KisVLineIteratorPixel& rhs) : KisVLineIterator(rhs), KisIteratorPixelTrait<KisVLineIterator>(rhs)
00084         { m_offsetx = rhs.m_offsetx;  m_offsety = rhs.m_offsety; }
00085         
00086     KisVLineIteratorPixel& operator=(const KisVLineIteratorPixel& rhs)
00087         {
00088           KisVLineIterator::operator=(rhs);
00089           KisIteratorPixelTrait<KisVLineIterator>::operator=(rhs);
00090           m_offsetx = rhs.m_offsetx;  m_offsety = rhs.m_offsety;
00091           return *this; }
00092 
00093     inline KisVLineIteratorPixel & operator ++() { KisVLineIterator::operator++(); advance(1); return *this;}
00094 
00095     Q_INT32 x() const { return KisVLineIterator::x() + m_offsetx; }
00096     
00097     Q_INT32 y() const { return KisVLineIterator::y() + m_offsety; }
00098 
00099 protected:
00100 
00101     Q_INT32 m_offsetx, m_offsety;
00102 };
00103 
00104 class KisRectIteratorPixel : public KisRectIterator, public KisIteratorPixelTrait <KisRectIterator>
00105 {
00106 public:
00107     KisRectIteratorPixel( KisPaintDevice *ndevice, KisDataManager *dm, KisDataManager *sel_dm,
00108                           Q_INT32 x, Q_INT32 y, Q_INT32 w, Q_INT32 h, Q_INT32 offsetx, Q_INT32 offsety,
00109                           bool writable);
00110     
00111     KisRectIteratorPixel(const KisRectIteratorPixel& rhs) : KisRectIterator(rhs), KisIteratorPixelTrait<KisRectIterator>(rhs)
00112         { m_offsetx = rhs.m_offsetx;  m_offsety = rhs.m_offsety; }
00113         
00114     KisRectIteratorPixel& operator=(const KisRectIteratorPixel& rhs)
00115         {
00116           KisRectIterator::operator=(rhs);
00117           KisIteratorPixelTrait<KisRectIterator>::operator=(rhs);
00118           m_offsetx = rhs.m_offsetx;  m_offsety = rhs.m_offsety;
00119           return *this; }
00120 
00121     inline KisRectIteratorPixel & operator ++() { KisRectIterator::operator++(); advance(1); return *this;}
00122 
00123     Q_INT32 x() const { return KisRectIterator::x() + m_offsetx; }
00124     
00125     Q_INT32 y() const { return KisRectIterator::y() + m_offsety; }
00126 
00127     Q_INT32 nConseqPixels() const {
00128         if (m_selectionIterator) {
00129             Q_INT32 parent = KisRectIterator::nConseqPixels();
00130             Q_INT32 selection = m_selectionIterator->nConseqPixels();
00131             if (parent < selection)
00132                 return parent;
00133             return selection;
00134         }
00135         return KisRectIterator::nConseqPixels();
00136     }
00137 
00138 protected:
00139 
00140     Q_INT32 m_offsetx, m_offsety;
00141 };
00142 
00143 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys